From 50e993e014818bd8ee701cb00d3d725ea354f442 Mon Sep 17 00:00:00 2001 From: nowrep Date: Sun, 3 Mar 2013 20:18:34 +0100 Subject: [PATCH] [TabBar] Compute minimum tab sizes with ProxyStyle pixelMetrics. It will make it possible for styles to basically style tabs. --- src/lib/app/mainapplication.cpp | 5 +++++ src/lib/app/mainapplication.h | 2 ++ src/lib/webview/tabbar.cpp | 12 ++++++++---- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/lib/app/mainapplication.cpp b/src/lib/app/mainapplication.cpp index e07d51ca1..706fff51d 100644 --- a/src/lib/app/mainapplication.cpp +++ b/src/lib/app/mainapplication.cpp @@ -1167,6 +1167,11 @@ void MainApplication::destroyRestoreManager() m_restoreManager = 0; } +ProxyStyle* MainApplication::proxyStyle() const +{ + return m_proxyStyle; +} + void MainApplication::setProxyStyle(ProxyStyle* style) { m_proxyStyle = style; diff --git a/src/lib/app/mainapplication.h b/src/lib/app/mainapplication.h index fa29a1423..41f113ff6 100644 --- a/src/lib/app/mainapplication.h +++ b/src/lib/app/mainapplication.h @@ -94,7 +94,9 @@ public: void destroyRestoreManager(); void clearTempPath(); + ProxyStyle* proxyStyle() const; void setProxyStyle(ProxyStyle* style); + QString currentStyle() const; QString tempPath() const; diff --git a/src/lib/webview/tabbar.cpp b/src/lib/webview/tabbar.cpp index 01680635c..ba6e95fda 100644 --- a/src/lib/webview/tabbar.cpp +++ b/src/lib/webview/tabbar.cpp @@ -26,6 +26,7 @@ #include "tabbedwebview.h" #include "mainapplication.h" #include "pluginproxy.h" +#include "proxystyle.h" #include #include @@ -173,9 +174,11 @@ void TabBar::contextMenuRequested(const QPoint &position) QSize TabBar::tabSizeHint(int index) const { - if (!isVisible()) { + if (!isVisible() || !mApp->proxyStyle()) { // Don't calculate it when tabbar is not visible // It produces invalid size anyway + // + // We also need ProxyStyle to be set before calculating minimum sizes for tabs return QSize(-1, -1); } @@ -183,9 +186,10 @@ QSize TabBar::tabSizeHint(int index) const static int MINIMUM_ACTIVE_TAB_WIDTH = -1; if (PINNED_TAB_WIDTH == -1) { - PINNED_TAB_WIDTH = 16 + style()->pixelMetric(QStyle::PM_TabBarTabHSpace, 0, this); - MINIMUM_ACTIVE_TAB_WIDTH = PINNED_TAB_WIDTH + style()->pixelMetric(QStyle::PM_TabCloseIndicatorWidth, 0, this); - // just a hack: we want to be sure buttonAddTab and buttonListTabs can't cover the active tab + PINNED_TAB_WIDTH = 16 + mApp->proxyStyle()->pixelMetric(QStyle::PM_TabBarTabHSpace, 0, this); + MINIMUM_ACTIVE_TAB_WIDTH = PINNED_TAB_WIDTH + mApp->proxyStyle()->pixelMetric(QStyle::PM_TabCloseIndicatorWidth, 0, this); + + // We want to be sure buttonAddTab and buttonListTabs can't cover the active tab MINIMUM_ACTIVE_TAB_WIDTH = qMax(MINIMUM_ACTIVE_TAB_WIDTH, 6 + m_tabWidget->buttonListTabs()->width() + m_tabWidget->buttonAddTab()->width()); }