diff --git a/src/lib/tabwidget/combotabbar.cpp b/src/lib/tabwidget/combotabbar.cpp index c1a8cb7d7..dd8f27db7 100644 --- a/src/lib/tabwidget/combotabbar.cpp +++ b/src/lib/tabwidget/combotabbar.cpp @@ -994,6 +994,16 @@ TabBarHelper::TabBarHelper(bool isPinnedTabBar, ComboTabBar* comboTabBar) connect(this, SIGNAL(tabMoved(int,int)), this, SLOT(tabWasMoved(int,int))); } +int TabBarHelper::tabPadding() const +{ + return m_tabPadding; +} + +void TabBarHelper::setTabPadding(int padding) +{ + m_tabPadding = padding; +} + void TabBarHelper::setTabButton(int index, QTabBar::ButtonPosition position, QWidget* widget) { QTabBar::setTabButton(index, position, widget); @@ -1360,6 +1370,13 @@ void TabBarHelper::initStyleOption(QStyleOptionTab* option, int tabIndex) const { QTabBar::initStyleOption(option, tabIndex); + // Workaround zero padding when tabs are styled using style sheets + if (m_tabPadding > 0 && (tabIndex != currentIndex() || m_dragInProgress)) { + const QRect textRect = style()->subElementRect(QStyle::SE_TabBarTabText, option, this); + const int width = textRect.width() - 2 * m_tabPadding; + option->text = option->fontMetrics.elidedText(tabText(tabIndex), elideMode(), width, Qt::TextShowMnemonic); + } + // Bespin doesn't highlight current tab when there is only one tab in tabbar static int isBespin = -1; diff --git a/src/lib/tabwidget/combotabbar.h b/src/lib/tabwidget/combotabbar.h index eca146390..b07e2508c 100644 --- a/src/lib/tabwidget/combotabbar.h +++ b/src/lib/tabwidget/combotabbar.h @@ -226,10 +226,14 @@ private: class FALKON_EXPORT TabBarHelper : public QTabBar { Q_OBJECT + Q_PROPERTY(int tabPadding READ tabPadding WRITE setTabPadding) public: explicit TabBarHelper(bool isPinnedTabBar, ComboTabBar* comboTabBar); + int tabPadding() const; + void setTabPadding(int padding); + void setTabButton(int index, QTabBar::ButtonPosition position, QWidget* widget); QSize tabSizeHint(int index) const; @@ -274,6 +278,7 @@ private: ComboTabBar* m_comboTabBar; QScrollArea* m_scrollArea; + int m_tabPadding = -1; int m_pressedIndex; int m_pressedGlobalX; bool m_dragInProgress;