1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 18:56:34 +01:00

Fixed changing TabsOnTop option when there are more than one window.

This commit is contained in:
S. Razi Alavizadeh 2013-08-04 00:39:54 +04:30
parent 17a6879715
commit 7dbaf71f23
4 changed files with 25 additions and 10 deletions

View File

@ -126,6 +126,7 @@ QupZilla::QupZilla(Qz::BrowserWindow type, QUrl startUrl)
, m_sideBarManager(new SideBarManager(this)) , m_sideBarManager(new SideBarManager(this))
, m_statusBarMessage(new StatusBarMessage(this)) , m_statusBarMessage(new StatusBarMessage(this))
, m_usingTransparentBackground(false) , m_usingTransparentBackground(false)
, m_tabsOnTopState(-1)
{ {
setObjectName("mainwindow"); setObjectName("mainwindow");
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
@ -919,7 +920,7 @@ Qz::BrowserWindow QupZilla::windowType() const
QWidget* QupZilla::navigationContainer() const QWidget* QupZilla::navigationContainer() const
{ {
if (!qzSettings->tabsOnTop) { if (!tabsOnTop()) {
return 0; return 0;
} }
@ -938,6 +939,15 @@ bool QupZilla::isTransparentBackgroundAllowed()
return m_usingTransparentBackground && !isFullScreen(); 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) void QupZilla::setWindowTitle(const QString &t)
{ {
QString title = t; QString title = t;
@ -1213,7 +1223,7 @@ void QupZilla::aboutToShowViewMenu()
m_actionShowStatusbar->setChecked(statusBar()->isVisible()); m_actionShowStatusbar->setChecked(statusBar()->isVisible());
m_actionShowBookmarksToolbar->setChecked(m_bookmarksToolbar->isVisible()); m_actionShowBookmarksToolbar->setChecked(m_bookmarksToolbar->isVisible());
m_actionTabsOnTop->setChecked(qzSettings->tabsOnTop); m_actionTabsOnTop->setChecked(tabsOnTop());
m_actionPageSource->setEnabled(true); m_actionPageSource->setEnabled(true);
@ -1682,9 +1692,12 @@ void QupZilla::triggerTabsOnTop(bool enable)
m_mainLayout->insertWidget(0, m_navigationContainer); m_mainLayout->insertWidget(0, m_navigationContainer);
} }
m_tabsOnTopState = enable ? 1 : 0;
if (enable != qzSettings->tabsOnTop) {
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 #ifdef Q_OS_WIN
// workaround for changing TabsOnTop state when sidebar is visible // workaround for changing TabsOnTop state when sidebar is visible
@ -1778,7 +1791,7 @@ void QupZilla::webSearch()
void QupZilla::searchOnPage() void QupZilla::searchOnPage()
{ {
SearchToolBar* toolBar = searchToolBar(); SearchToolBar* toolBar = searchToolBar();
const int searchPos = qzSettings->tabsOnTop ? 1 : 2; const int searchPos = tabsOnTop() ? 1 : 2;
if (!toolBar) { if (!toolBar) {
toolBar = new SearchToolBar(weView(), this); toolBar = new SearchToolBar(weView(), this);
@ -2212,7 +2225,7 @@ void QupZilla::closeEvent(QCloseEvent* event)
SearchToolBar* QupZilla::searchToolBar() SearchToolBar* QupZilla::searchToolBar()
{ {
SearchToolBar* toolBar = 0; SearchToolBar* toolBar = 0;
const int searchPos = qzSettings->tabsOnTop ? 1 : 2; const int searchPos = tabsOnTop() ? 1 : 2;
if (m_mainLayout->count() == searchPos + 1) { if (m_mainLayout->count() == searchPos + 1) {
toolBar = qobject_cast<SearchToolBar*>(m_mainLayout->itemAt(searchPos)->widget()); toolBar = qobject_cast<SearchToolBar*>(m_mainLayout->itemAt(searchPos)->widget());

View File

@ -114,6 +114,7 @@ public:
QUrl homepageUrl() { return m_homepage; } QUrl homepageUrl() { return m_homepage; }
bool isTransparentBackgroundAllowed(); bool isTransparentBackgroundAllowed();
bool tabsOnTop() const;
signals: signals:
void startingCompleted(); void startingCompleted();
@ -345,6 +346,7 @@ private:
QTimer* m_hideNavigationTimer; QTimer* m_hideNavigationTimer;
QList<QPointer<QWidget> > m_deleteOnCloseWidgets; QList<QPointer<QWidget> > m_deleteOnCloseWidgets;
mutable int m_tabsOnTopState;
}; };
#endif // QUPZILLA_H #endif // QUPZILLA_H

View File

@ -31,7 +31,7 @@ void NavigationContainer::paintEvent(QPaintEvent* event)
{ {
QWidget::paintEvent(event); QWidget::paintEvent(event);
if (qzSettings->tabsOnTop) { if (p_QupZilla->tabsOnTop()) {
// Draw line at the bottom of navigation bar if tabs are on top // Draw line at the bottom of navigation bar if tabs are on top
// To visually distinguish navigation bar from the page // To visually distinguish navigation bar from the page
QPainter p(this); QPainter p(this);

View File

@ -335,7 +335,7 @@ QPixmap WebTab::renderTabPreview()
void WebTab::showNotification(QWidget* notif) 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) { if (m_layout->count() > notifPos + 1) {
delete m_layout->itemAt(notifPos)->widget(); delete m_layout->itemAt(notifPos)->widget();
@ -408,7 +408,7 @@ void WebTab::disconnectObjects()
void WebTab::hideNavigationBar() void WebTab::hideNavigationBar()
{ {
if (m_navigationContainer && qzSettings->tabsOnTop) { if (m_navigationContainer && p_QupZilla->tabsOnTop()) {
m_layout->removeWidget(m_navigationContainer); m_layout->removeWidget(m_navigationContainer);
// Needed to prevent flickering when closing tabs // Needed to prevent flickering when closing tabs