From cff5fce5da8eec259f5207733f239c18a23f053d Mon Sep 17 00:00:00 2001 From: nowrep Date: Sun, 2 Sep 2012 14:18:07 +0200 Subject: [PATCH] Fixed showing close buttons on pinned tabs. - regression from 1e5b7d92cd2c92d21ae1896149ded949648cb370 --- src/lib/webview/tabbar.cpp | 16 ++++++++++++++-- src/lib/webview/tabbar.h | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/lib/webview/tabbar.cpp b/src/lib/webview/tabbar.cpp index bb666fcac..3c23c2de2 100644 --- a/src/lib/webview/tabbar.cpp +++ b/src/lib/webview/tabbar.cpp @@ -158,7 +158,7 @@ void TabBar::contextMenuRequested(const QPoint &position) action->setEnabled(m_tabWidget->canRestoreTab()); } - //Prevent choosing first option with double rightclick + // Prevent choosing first option with double rightclick const QPoint &pos = mapToGlobal(position); QPoint p(pos.x(), pos.y() + 1); menu.exec(p); @@ -168,6 +168,12 @@ void TabBar::contextMenuRequested(const QPoint &position) QSize TabBar::tabSizeHint(int index) const { + if (!isVisible()) { + // Don't calculate it when tabbar is not visible + // It produces invalid size anyway + return QSize(-1, -1); + } + static int PINNED_TAB_WIDTH = -1; if (PINNED_TAB_WIDTH == -1) { @@ -234,8 +240,14 @@ QSize TabBar::tabSizeHint(int index) const size.setWidth(m_lastTabWidth); } + // Restore close buttons according to preferences if (tabsClosable() != m_showCloseButtons) { tabBar->setTabsClosable(m_showCloseButtons); + + // Hide close buttons on pinned tabs + for (int i = 0; i < count(); ++i) { + updateCloseButton(i); + } } } } @@ -303,7 +315,7 @@ void TabBar::hideCloseButton(int index) } #endif -void TabBar::updateCloseButton(int index) +void TabBar::updateCloseButton(int index) const { QAbstractButton* button = qobject_cast(tabButton(index, QTabBar::RightSide)); if (!button) { diff --git a/src/lib/webview/tabbar.h b/src/lib/webview/tabbar.h index 2530b9aa9..731debc6d 100644 --- a/src/lib/webview/tabbar.h +++ b/src/lib/webview/tabbar.h @@ -33,7 +33,7 @@ public: explicit TabBar(QupZilla* mainClass, TabWidget* tabWidget); // void hideCloseButton(int index); // void showCloseButton(int index); - void updateCloseButton(int index); + void updateCloseButton(int index) const; QSize getTabSizeHint(int index) { return QTabBar::tabSizeHint(index); } void loadSettings();