diff options
Diffstat (limited to 'src/widgets/styles')
-rw-r--r-- | src/widgets/styles/qcommonstyle.cpp | 50 | ||||
-rw-r--r-- | src/widgets/styles/qstyle.cpp | 11 | ||||
-rw-r--r-- | src/widgets/styles/qstyle.h | 8 |
3 files changed, 57 insertions, 12 deletions
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 83e68d5f5f..5a08801e94 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -552,18 +552,31 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q case PE_IndicatorTabTear: if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) { bool rtl = tab->direction == Qt::RightToLeft; - QRect rect = tab->rect; + const bool horizontal = tab->rect.height() > tab->rect.width(); + const int margin = 4; QPainterPath path; - rect.setTop(rect.top() + ((tab->state & State_Selected) ? 1 : 3)); - rect.setBottom(rect.bottom() - ((tab->state & State_Selected) ? 0 : 2)); + if (horizontal) { + QRect rect = tab->rect.adjusted(rtl ? margin : 0, 0, rtl ? 1 : -margin, 0); + rect.setTop(rect.top() + ((tab->state & State_Selected) ? 1 : 3)); + rect.setBottom(rect.bottom() - ((tab->state & State_Selected) ? 0 : 2)); - path.moveTo(QPoint(rtl ? rect.right() : rect.left(), rect.top())); - int count = 4; - for(int jags = 1; jags <= count; ++jags, rtl = !rtl) - path.lineTo(QPoint(rtl ? rect.left() : rect.right(), rect.top() + jags * rect.height()/count)); + path.moveTo(QPoint(rtl ? rect.right() : rect.left(), rect.top())); + int count = 4; + for (int jags = 1; jags <= count; ++jags, rtl = !rtl) + path.lineTo(QPoint(rtl ? rect.left() : rect.right(), rect.top() + jags * rect.height()/count)); + } else { + QRect rect = tab->rect.adjusted(0, 0, 0, -margin); + rect.setLeft(rect.left() + ((tab->state & State_Selected) ? 1 : 3)); + rect.setRight(rect.right() - ((tab->state & State_Selected) ? 0 : 2)); + + path.moveTo(QPoint(rect.left(), rect.top())); + int count = 4; + for (int jags = 1; jags <= count; ++jags, rtl = !rtl) + path.lineTo(QPoint(rect.left() + jags * rect.width()/count, rtl ? rect.top() : rect.bottom())); + } - p->setPen(QPen(tab->palette.light(), qreal(.8))); + p->setPen(QPen(tab->palette.dark(), qreal(.8))); p->setBrush(tab->palette.background()); p->setRenderHint(QPainter::Antialiasing); p->drawPath(path); @@ -2796,13 +2809,13 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, case QTabBar::TriangularNorth: case QTabBar::RoundedSouth: case QTabBar::TriangularSouth: - r.setRect(tab->rect.left(), tab->rect.top(), 4, opt->rect.height()); + r.setRect(tab->rect.left(), tab->rect.top(), 8, opt->rect.height()); break; case QTabBar::RoundedWest: case QTabBar::TriangularWest: case QTabBar::RoundedEast: case QTabBar::TriangularEast: - r.setRect(tab->rect.left(), tab->rect.top(), opt->rect.width(), 4); + r.setRect(tab->rect.left(), tab->rect.top(), opt->rect.width(), 8); break; default: break; @@ -2810,6 +2823,23 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt, r = visualRect(opt->direction, opt->rect, r); } break; + case SE_TabBarScrollLeftButton: { + const bool vertical = opt->rect.width() < opt->rect.height(); + const Qt::LayoutDirection ld = widget->layoutDirection(); + const int buttonWidth = qMax(pixelMetric(QStyle::PM_TabBarScrollButtonWidth, 0, widget), QApplication::globalStrut().width()); + const int buttonOverlap = pixelMetric(QStyle::PM_TabBar_ScrollButtonOverlap, 0, widget); + + r = vertical ? QRect(0, opt->rect.height() - (buttonWidth * 2) + buttonOverlap, opt->rect.width(), buttonWidth) + : QStyle::visualRect(ld, opt->rect, QRect(opt->rect.width() - (buttonWidth * 2) + buttonOverlap, 0, buttonWidth, opt->rect.height())); + break; } + case SE_TabBarScrollRightButton: { + const bool vertical = opt->rect.width() < opt->rect.height(); + const Qt::LayoutDirection ld = widget->layoutDirection(); + const int buttonWidth = qMax(pixelMetric(QStyle::PM_TabBarScrollButtonWidth, 0, widget), QApplication::globalStrut().width()); + + r = vertical ? QRect(0, opt->rect.height() - buttonWidth, opt->rect.width(), buttonWidth) + : QStyle::visualRect(ld, opt->rect, QRect(opt->rect.width() - buttonWidth, 0, buttonWidth, opt->rect.height())); + break; } #endif case SE_TreeViewDisclosureItem: r = opt->rect; diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp index b368477a39..5f9f0b8e75 100644 --- a/src/widgets/styles/qstyle.cpp +++ b/src/widgets/styles/qstyle.cpp @@ -691,7 +691,9 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value PE_PanelToolBar The panel for a toolbar. \value PE_PanelTipLabel The panel for a tip label. \value PE_FrameTabBarBase The frame that is drawn for a tab bar, ususally drawn for a tab bar that isn't part of a tab widget. - \value PE_IndicatorTabTear An indicator that a tab is partially scrolled out of the visible tab bar when there are many tabs. + \value PE_IndicatorTabTear Deprecated. Use \l{PE_IndicatorTabTearLeft} instead. + \value PE_IndicatorTabTearLeft An indicator that a tab is partially scrolled out on the left side of the visible tab bar when there are many tabs. + \value PE_IndicatorTabTearRight An indicator that a tab is partially scrolled out on the right side of the visible tab bar when there are many tabs. \value PE_IndicatorColumnViewArrow An arrow in a QColumnView. \value PE_Widget A plain QWidget. @@ -1057,7 +1059,12 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value SE_ItemViewItemCheckIndicator Area for a view item's check mark. - \value SE_TabBarTearIndicator Area for the tear indicator on a tab bar with scroll arrows. + \value SE_TabBarTearIndicator Deprecated. Use SE_TabBarTearIndicatorLeft instead. + \value SE_TabBarTearIndicatorLeft Area for the tear indicator on the left side of a tab bar with scroll arrows. + \value SE_TabBarTearIndicatorRight Area for the tear indicator on the right side of a tab bar with scroll arrows. + + \value SE_TabBarScrollLeftButton Area for the scroll left button on a tab bar with scroll buttons. + \value SE_TabBarScrollRightButton Area for the scroll right button on a tab bar with scroll buttons. \value SE_TreeViewDisclosureItem Area for the actual disclosure item in a tree branch. diff --git a/src/widgets/styles/qstyle.h b/src/widgets/styles/qstyle.h index 43addb5eb7..dad93ec0fc 100644 --- a/src/widgets/styles/qstyle.h +++ b/src/widgets/styles/qstyle.h @@ -171,6 +171,7 @@ public: PE_IndicatorToolBarSeparator, PE_PanelTipLabel, PE_IndicatorTabTear, + PE_IndicatorTabTearLeft = PE_IndicatorTabTear, PE_PanelScrollAreaCorner, PE_Widget, @@ -186,6 +187,8 @@ public: PE_IndicatorTabClose, PE_PanelMenu, + PE_IndicatorTabTearRight, + // do not add any values below/greater this PE_CustomBase = 0xf000000 }; @@ -302,6 +305,7 @@ public: SE_ItemViewItemCheckIndicator = SE_ViewItemCheckIndicator, SE_TabBarTearIndicator, + SE_TabBarTearIndicatorLeft = SE_TabBarTearIndicator, SE_TreeViewDisclosureItem, @@ -341,6 +345,10 @@ public: SE_ToolBarHandle, + SE_TabBarScrollLeftButton, + SE_TabBarScrollRightButton, + SE_TabBarTearIndicatorRight, + // do not add any values below/greater than this SE_CustomBase = 0xf0000000 }; |