From 1d919e0172df2e93de4d1b63ecb92e8574829aac Mon Sep 17 00:00:00 2001 From: nowrep Date: Sun, 2 Sep 2012 12:22:11 +0200 Subject: [PATCH] Fixed width of pinned tabs on all Qt styles. closes #518 --- src/lib/app/proxystyle.cpp | 16 +++++++++------- src/lib/app/proxystyle.h | 3 ++- src/lib/webview/tabbar.cpp | 14 ++++++-------- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/lib/app/proxystyle.cpp b/src/lib/app/proxystyle.cpp index 0caff6699..e6d298962 100644 --- a/src/lib/app/proxystyle.cpp +++ b/src/lib/app/proxystyle.cpp @@ -31,11 +31,13 @@ int ProxyStyle::styleHint(StyleHint hint, const QStyleOption* option, const QWid return QProxyStyle::styleHint(hint, option, widget, returnData); } -//int ProxyStyle::pixelMetric(PixelMetric metric, const QStyleOption* option, const QWidget* widget) const -//{ -// if (metric == PM_TabBarTabHSpace) { -// return 8; -// } +int ProxyStyle::pixelMetric(PixelMetric metric, const QStyleOption* option, const QWidget* widget) const +{ + switch (metric) { + case PM_TabBarTabHSpace: + return qMin(QProxyStyle::pixelMetric(PM_TabBarTabHSpace, option, widget), 14); -// return QProxyStyle::pixelMetric(metric, option, widget); -//} + default: + return QProxyStyle::pixelMetric(metric, option, widget); + } +} diff --git a/src/lib/app/proxystyle.h b/src/lib/app/proxystyle.h index d8f8fe8d4..bcee568d1 100644 --- a/src/lib/app/proxystyle.h +++ b/src/lib/app/proxystyle.h @@ -28,7 +28,8 @@ public: explicit ProxyStyle(); int styleHint(StyleHint hint, const QStyleOption* option = 0, const QWidget* widget = 0, QStyleHintReturn* returnData = 0) const; -// int pixelMetric(PixelMetric metric, const QStyleOption* option, const QWidget* widget) const; + + int pixelMetric(PixelMetric metric, const QStyleOption* option, const QWidget* widget) const; }; #endif // PROXYSTYLE_H diff --git a/src/lib/webview/tabbar.cpp b/src/lib/webview/tabbar.cpp index 79416f34c..bb666fcac 100644 --- a/src/lib/webview/tabbar.cpp +++ b/src/lib/webview/tabbar.cpp @@ -36,14 +36,6 @@ #define MAXIMUM_TAB_WIDTH 250 #define MINIMUM_TAB_WIDTH 125 -#ifdef Q_WS_WIN -#define PINNED_TAB_WIDTH 38 -#elif defined(KDE) -#define PINNED_TAB_WIDTH 24 -#else -#define PINNED_TAB_WIDTH 31 -#endif - TabBar::TabBar(QupZilla* mainClass, TabWidget* tabWidget) : QTabBar() , p_QupZilla(mainClass) @@ -176,6 +168,12 @@ void TabBar::contextMenuRequested(const QPoint &position) QSize TabBar::tabSizeHint(int index) const { + static int PINNED_TAB_WIDTH = -1; + + if (PINNED_TAB_WIDTH == -1) { + PINNED_TAB_WIDTH = 16 + style()->pixelMetric(QStyle::PM_TabBarTabHSpace); + } + QSize size = QTabBar::tabSizeHint(index); WebTab* webTab = qobject_cast(m_tabWidget->widget(index)); TabBar* tabBar = const_cast (this);