1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

[TabBar] Compute minimum tab sizes with ProxyStyle pixelMetrics.

It will make it possible for styles to basically style tabs.
This commit is contained in:
nowrep 2013-03-03 20:18:34 +01:00
parent aa2f6664bf
commit 50e993e014
3 changed files with 15 additions and 4 deletions

View File

@ -1167,6 +1167,11 @@ void MainApplication::destroyRestoreManager()
m_restoreManager = 0; m_restoreManager = 0;
} }
ProxyStyle* MainApplication::proxyStyle() const
{
return m_proxyStyle;
}
void MainApplication::setProxyStyle(ProxyStyle* style) void MainApplication::setProxyStyle(ProxyStyle* style)
{ {
m_proxyStyle = style; m_proxyStyle = style;

View File

@ -94,7 +94,9 @@ public:
void destroyRestoreManager(); void destroyRestoreManager();
void clearTempPath(); void clearTempPath();
ProxyStyle* proxyStyle() const;
void setProxyStyle(ProxyStyle* style); void setProxyStyle(ProxyStyle* style);
QString currentStyle() const; QString currentStyle() const;
QString tempPath() const; QString tempPath() const;

View File

@ -26,6 +26,7 @@
#include "tabbedwebview.h" #include "tabbedwebview.h"
#include "mainapplication.h" #include "mainapplication.h"
#include "pluginproxy.h" #include "pluginproxy.h"
#include "proxystyle.h"
#include <QMenu> #include <QMenu>
#include <QMimeData> #include <QMimeData>
@ -173,9 +174,11 @@ void TabBar::contextMenuRequested(const QPoint &position)
QSize TabBar::tabSizeHint(int index) const QSize TabBar::tabSizeHint(int index) const
{ {
if (!isVisible()) { if (!isVisible() || !mApp->proxyStyle()) {
// Don't calculate it when tabbar is not visible // Don't calculate it when tabbar is not visible
// It produces invalid size anyway // It produces invalid size anyway
//
// We also need ProxyStyle to be set before calculating minimum sizes for tabs
return QSize(-1, -1); return QSize(-1, -1);
} }
@ -183,9 +186,10 @@ QSize TabBar::tabSizeHint(int index) const
static int MINIMUM_ACTIVE_TAB_WIDTH = -1; static int MINIMUM_ACTIVE_TAB_WIDTH = -1;
if (PINNED_TAB_WIDTH == -1) { if (PINNED_TAB_WIDTH == -1) {
PINNED_TAB_WIDTH = 16 + style()->pixelMetric(QStyle::PM_TabBarTabHSpace, 0, this); PINNED_TAB_WIDTH = 16 + mApp->proxyStyle()->pixelMetric(QStyle::PM_TabBarTabHSpace, 0, this);
MINIMUM_ACTIVE_TAB_WIDTH = PINNED_TAB_WIDTH + style()->pixelMetric(QStyle::PM_TabCloseIndicatorWidth, 0, this); MINIMUM_ACTIVE_TAB_WIDTH = PINNED_TAB_WIDTH + mApp->proxyStyle()->pixelMetric(QStyle::PM_TabCloseIndicatorWidth, 0, this);
// just a hack: we want to be sure buttonAddTab and buttonListTabs can't cover the active tab
// 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()); MINIMUM_ACTIVE_TAB_WIDTH = qMax(MINIMUM_ACTIVE_TAB_WIDTH, 6 + m_tabWidget->buttonListTabs()->width() + m_tabWidget->buttonAddTab()->width());
} }