diff options
Diffstat (limited to 'src/widgets/styles/qcommonstyle.cpp')
-rw-r--r-- | src/widgets/styles/qcommonstyle.cpp | 62 |
1 files changed, 45 insertions, 17 deletions
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 355a3d2c3f..f639e4a082 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); @@ -2780,13 +2793,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; @@ -2794,6 +2807,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; @@ -5567,6 +5597,11 @@ QIcon QCommonStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption case SP_FileLinkIcon: case SP_DesktopIcon: case SP_ComputerIcon: + case SP_VistaShield: + case SP_MessageBoxInformation: + case SP_MessageBoxWarning: + case SP_MessageBoxCritical: + case SP_MessageBoxQuestion: if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) { QPlatformTheme::StandardPixmap sp = static_cast<QPlatformTheme::StandardPixmap>(standardIcon); for (int size = 16 ; size <= 32 ; size += 16) { @@ -5590,13 +5625,6 @@ QIcon QCommonStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption } } break; - case SP_VistaShield: - if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) { - QPlatformTheme::StandardPixmap sp = static_cast<QPlatformTheme::StandardPixmap>(standardIcon); - QPixmap pixmap = theme->standardPixmap(sp, QSizeF(32, 32)); - icon.addPixmap(pixmap); - } - break; default: break; } |