From 7dbaf71f23f496f3ca5cf46b3a23af02c1362a76 Mon Sep 17 00:00:00 2001 From: "S. Razi Alavizadeh" Date: Sun, 4 Aug 2013 00:39:54 +0430 Subject: [PATCH] Fixed changing TabsOnTop option when there are more than one window. --- src/lib/app/qupzilla.cpp | 27 ++++++++++++++++------ src/lib/app/qupzilla.h | 2 ++ src/lib/navigation/navigationcontainer.cpp | 2 +- src/lib/webview/webtab.cpp | 4 ++-- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/lib/app/qupzilla.cpp b/src/lib/app/qupzilla.cpp index 5b4425cf2..aaddb0a6b 100644 --- a/src/lib/app/qupzilla.cpp +++ b/src/lib/app/qupzilla.cpp @@ -126,6 +126,7 @@ QupZilla::QupZilla(Qz::BrowserWindow type, QUrl startUrl) , m_sideBarManager(new SideBarManager(this)) , m_statusBarMessage(new StatusBarMessage(this)) , m_usingTransparentBackground(false) + , m_tabsOnTopState(-1) { setObjectName("mainwindow"); setAttribute(Qt::WA_DeleteOnClose); @@ -919,7 +920,7 @@ Qz::BrowserWindow QupZilla::windowType() const QWidget* QupZilla::navigationContainer() const { - if (!qzSettings->tabsOnTop) { + if (!tabsOnTop()) { return 0; } @@ -938,6 +939,15 @@ bool QupZilla::isTransparentBackgroundAllowed() return m_usingTransparentBackground && !isFullScreen(); } +bool QupZilla::tabsOnTop() const +{ + if (m_tabsOnTopState == -1) { + m_tabsOnTopState = qzSettings->tabsOnTop ? 1 : 0; + } + + return m_tabsOnTopState == 1; +} + void QupZilla::setWindowTitle(const QString &t) { QString title = t; @@ -1213,7 +1223,7 @@ void QupZilla::aboutToShowViewMenu() m_actionShowStatusbar->setChecked(statusBar()->isVisible()); m_actionShowBookmarksToolbar->setChecked(m_bookmarksToolbar->isVisible()); - m_actionTabsOnTop->setChecked(qzSettings->tabsOnTop); + m_actionTabsOnTop->setChecked(tabsOnTop()); m_actionPageSource->setEnabled(true); @@ -1682,9 +1692,12 @@ void QupZilla::triggerTabsOnTop(bool enable) m_mainLayout->insertWidget(0, m_navigationContainer); } - Settings settings; - settings.setValue("Browser-Tabs-Settings/TabsOnTop", enable); - qzSettings->tabsOnTop = enable; + m_tabsOnTopState = enable ? 1 : 0; + if (enable != qzSettings->tabsOnTop) { + Settings settings; + settings.setValue("Browser-Tabs-Settings/TabsOnTop", enable); + qzSettings->tabsOnTop = enable; + } #ifdef Q_OS_WIN // workaround for changing TabsOnTop state when sidebar is visible @@ -1778,7 +1791,7 @@ void QupZilla::webSearch() void QupZilla::searchOnPage() { SearchToolBar* toolBar = searchToolBar(); - const int searchPos = qzSettings->tabsOnTop ? 1 : 2; + const int searchPos = tabsOnTop() ? 1 : 2; if (!toolBar) { toolBar = new SearchToolBar(weView(), this); @@ -2212,7 +2225,7 @@ void QupZilla::closeEvent(QCloseEvent* event) SearchToolBar* QupZilla::searchToolBar() { SearchToolBar* toolBar = 0; - const int searchPos = qzSettings->tabsOnTop ? 1 : 2; + const int searchPos = tabsOnTop() ? 1 : 2; if (m_mainLayout->count() == searchPos + 1) { toolBar = qobject_cast(m_mainLayout->itemAt(searchPos)->widget()); diff --git a/src/lib/app/qupzilla.h b/src/lib/app/qupzilla.h index 5a94a74f4..b318df454 100644 --- a/src/lib/app/qupzilla.h +++ b/src/lib/app/qupzilla.h @@ -114,6 +114,7 @@ public: QUrl homepageUrl() { return m_homepage; } bool isTransparentBackgroundAllowed(); + bool tabsOnTop() const; signals: void startingCompleted(); @@ -345,6 +346,7 @@ private: QTimer* m_hideNavigationTimer; QList > m_deleteOnCloseWidgets; + mutable int m_tabsOnTopState; }; #endif // QUPZILLA_H diff --git a/src/lib/navigation/navigationcontainer.cpp b/src/lib/navigation/navigationcontainer.cpp index adf1a4519..6019d9e12 100644 --- a/src/lib/navigation/navigationcontainer.cpp +++ b/src/lib/navigation/navigationcontainer.cpp @@ -31,7 +31,7 @@ void NavigationContainer::paintEvent(QPaintEvent* event) { QWidget::paintEvent(event); - if (qzSettings->tabsOnTop) { + if (p_QupZilla->tabsOnTop()) { // Draw line at the bottom of navigation bar if tabs are on top // To visually distinguish navigation bar from the page QPainter p(this); diff --git a/src/lib/webview/webtab.cpp b/src/lib/webview/webtab.cpp index 00e9cf4fb..2b4ff4c5e 100644 --- a/src/lib/webview/webtab.cpp +++ b/src/lib/webview/webtab.cpp @@ -335,7 +335,7 @@ QPixmap WebTab::renderTabPreview() void WebTab::showNotification(QWidget* notif) { - const int notifPos = qzSettings->tabsOnTop ? 1 : 0; + const int notifPos = p_QupZilla->tabsOnTop() ? 1 : 0; if (m_layout->count() > notifPos + 1) { delete m_layout->itemAt(notifPos)->widget(); @@ -408,7 +408,7 @@ void WebTab::disconnectObjects() void WebTab::hideNavigationBar() { - if (m_navigationContainer && qzSettings->tabsOnTop) { + if (m_navigationContainer && p_QupZilla->tabsOnTop()) { m_layout->removeWidget(m_navigationContainer); // Needed to prevent flickering when closing tabs