1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-24 12:46:35 +01:00

Merge pull request #824 from srazi/master

Fixed Windows related issues.
This commit is contained in:
David Rosca 2013-03-23 13:33:54 -07:00
commit 8d29f46376
4 changed files with 53 additions and 17 deletions

View File

@ -266,7 +266,7 @@ MainApplication::MainApplication(int &argc, char** argv)
translateApp(); translateApp();
QupZilla* qupzilla = new QupZilla(Qz::BW_FirstAppWindow, startUrl); QupZilla* qupzilla = new QupZilla(Qz::BW_FirstAppWindow, startUrl);
m_mainWindows.append(qupzilla); m_mainWindows.prepend(qupzilla);
connect(qupzilla, SIGNAL(message(Qz::AppMessageType,bool)), this, SLOT(sendMessages(Qz::AppMessageType,bool))); connect(qupzilla, SIGNAL(message(Qz::AppMessageType,bool)), this, SLOT(sendMessages(Qz::AppMessageType,bool)));
connect(qupzilla, SIGNAL(startingCompleted()), this, SLOT(restoreCursor())); connect(qupzilla, SIGNAL(startingCompleted()), this, SLOT(restoreCursor()));
@ -636,7 +636,7 @@ QupZilla* MainApplication::makeNewWindow(Qz::BrowserWindow type, const QUrl &sta
} }
QupZilla* newWindow = new QupZilla(type, startUrl); QupZilla* newWindow = new QupZilla(type, startUrl);
m_mainWindows.append(newWindow); m_mainWindows.prepend(newWindow);
return newWindow; return newWindow;
} }

View File

@ -84,6 +84,7 @@
#include <QWebFrame> #include <QWebFrame>
#include <QWebHistory> #include <QWebHistory>
#include <QMessageBox> #include <QMessageBox>
#include <QDesktopWidget>
#if QT_VERSION < 0x050000 #if QT_VERSION < 0x050000
#include "qwebkitversion.h" #include "qwebkitversion.h"
@ -266,17 +267,30 @@ void QupZilla::setupUi()
setWindowState(Qt::WindowMaximized); setWindowState(Qt::WindowMaximized);
} }
else { else {
if (!restoreGeometry(settings.value("WindowGeometry").toByteArray())) { // Let the WM decides where to put new browser window
setGeometry(QRect(20, 20, 800, 550)); if (m_windowType == Qz::BW_NewWindow && mApp->getWindow()) {
#ifdef Q_WS_WIN
// Windows WM places every new window in the middle of screen .. for some reason
QPoint p = mApp->getWindow()->geometry().topLeft();
p.setX(p.x() + 30);
p.setY(p.y() + 30);
if (!mApp->desktop()->availableGeometry(this).contains(p)) {
p.setX(mApp->desktop()->availableGeometry(this).x() + 30);
p.setY(mApp->desktop()->availableGeometry(this).y() + 30);
}
setGeometry(QRect(p, mApp->getWindow()->size()));
#else
resize(mApp->getWindow()->size());
#endif
} }
else if (!restoreGeometry(settings.value("WindowGeometry").toByteArray())) {
if (m_windowType == Qz::BW_NewWindow) { #ifdef Q_WS_WIN
// Moving window +40 x,y to be visible that this is new window setGeometry(QRect(mApp->desktop()->availableGeometry(this).x() + 30,
QPoint p = pos(); mApp->desktop()->availableGeometry(this).y() + 30, 800, 550));
p.setX(p.x() + 40); #else
p.setY(p.y() + 40); resize(800, 550);
#endif
move(p);
} }
} }
@ -822,8 +836,7 @@ void QupZilla::loadSettings()
m_usingTransparentBackground = true; m_usingTransparentBackground = true;
QtWin::enableBlurBehindWindow(m_tabWidget->getTabBar(), true); QtWin::enableBlurBehindWindow(m_tabWidget->getTabBar(), true);
applyBlurToMainWindow(); QtWin::extendFrameIntoClientArea(this);
update();
//install event filter //install event filter
menuBar()->installEventFilter(this); menuBar()->installEventFilter(this);
@ -895,6 +908,11 @@ void QupZilla::popupToolbarsMenu(const QPoint &pos)
aboutToHideViewMenu(); aboutToHideViewMenu();
} }
bool QupZilla::isTransparentBackgroundAllowed()
{
return m_usingTransparentBackground && !isFullScreen();
}
void QupZilla::setWindowTitle(const QString &t) void QupZilla::setWindowTitle(const QString &t)
{ {
QString title = t; QString title = t;
@ -1547,7 +1565,6 @@ SideBar* QupZilla::addSideBar()
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
if (QtWin::isCompositionEnabled()) { if (QtWin::isCompositionEnabled()) {
applyBlurToMainWindow();
m_sideBar.data()->installEventFilter(this); m_sideBar.data()->installEventFilter(this);
} }
#endif #endif
@ -1643,6 +1660,13 @@ void QupZilla::triggerTabsOnTop(bool enable)
Settings settings; Settings settings;
settings.setValue("Browser-Tabs-Settings/TabsOnTop", enable); settings.setValue("Browser-Tabs-Settings/TabsOnTop", enable);
qzSettings->tabsOnTop = enable; qzSettings->tabsOnTop = enable;
#ifdef Q_OS_WIN
// workaround for changing TabsOnTop state when sidebar is visible
// TODO: we need a solution that changing TabsOnTop state
// doesn't call applyBlurToMainWindow() from eventFilter()
QTimer::singleShot(0, this, SLOT(applyBlurToMainWindow()));
#endif
} }
void QupZilla::refreshHistory() void QupZilla::refreshHistory()
@ -2445,11 +2469,11 @@ void QupZilla::paintEvent(QPaintEvent* event)
void QupZilla::applyBlurToMainWindow(bool force) void QupZilla::applyBlurToMainWindow(bool force)
{ {
if (isClosing()) { if (isClosing() || m_isStarting) {
return; return;
} }
if (!force && (m_actionShowFullScreen->isChecked() || !m_usingTransparentBackground)) { if (!force && !isTransparentBackgroundAllowed()) {
return; return;
} }
int topMargin = 0; int topMargin = 0;

View File

@ -111,6 +111,8 @@ public:
bool isClosing() { return m_isClosing; } bool isClosing() { return m_isClosing; }
QUrl homepageUrl() { return m_homepage; } QUrl homepageUrl() { return m_homepage; }
bool isTransparentBackgroundAllowed();
signals: signals:
void startingCompleted(); void startingCompleted();
void message(Qz::AppMessageType mes, bool state); void message(Qz::AppMessageType mes, bool state);

View File

@ -31,7 +31,9 @@
#include "websearchbar.h" #include "websearchbar.h"
#include "settings.h" #include "settings.h"
#include "qzsettings.h" #include "qzsettings.h"
#include "qtwin.h"
#include <QTimer>
#include <QMovie> #include <QMovie>
#include <QMenu> #include <QMenu>
#include <QMimeData> #include <QMimeData>
@ -282,6 +284,11 @@ int TabWidget::addView(const QUrl &url, const QString &title, const Qz::NewTabPo
int TabWidget::addView(QNetworkRequest req, const QString &title, const Qz::NewTabPositionFlags &openFlags, bool selectLine, int position) int TabWidget::addView(QNetworkRequest req, const QString &title, const Qz::NewTabPositionFlags &openFlags, bool selectLine, int position)
{ {
#ifdef Q_OS_WIN
if (p_QupZilla->isTransparentBackgroundAllowed()) {
QtWin::extendFrameIntoClientArea(p_QupZilla);
}
#endif
QUrl url = req.url(); QUrl url = req.url();
m_lastTabIndex = currentIndex(); m_lastTabIndex = currentIndex();
@ -358,6 +365,9 @@ int TabWidget::addView(QNetworkRequest req, const QString &title, const Qz::NewT
} }
} }
#ifdef Q_OS_WIN
QTimer::singleShot(0, p_QupZilla, SLOT(applyBlurToMainWindow()));
#endif
return index; return index;
} }