diff options
author | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2014-10-27 13:00:36 +0100 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2014-10-27 13:00:36 +0100 |
commit | 2eb26c170920d28213b71e549d5dac4663febb14 (patch) | |
tree | 8df5223ac114d758c2112a8fc787992175556418 /src/widgets/styles | |
parent | 49ddae28e0dcd1c59dd5d742cffedd5290d1224a (diff) | |
parent | 81998b4e8e440076bd22a9164f0a93481c0e597a (diff) |
Merge remote-tracking branch 'origin/5.4' into dev
Conflicts:
src/gui/text/qfontdatabase.cpp
Change-Id: I6ac1f55faa22b8e7b591386fb67f0333d0ea443d
Diffstat (limited to 'src/widgets/styles')
-rw-r--r-- | src/widgets/styles/qmacstyle_mac.mm | 2 | ||||
-rw-r--r-- | src/widgets/styles/qstyle.cpp | 12 | ||||
-rw-r--r-- | src/widgets/styles/qstylesheetstyle.cpp | 14 | ||||
-rw-r--r-- | src/widgets/styles/qwindowsvistastyle.cpp | 22 | ||||
-rw-r--r-- | src/widgets/styles/qwindowsxpstyle.cpp | 33 | ||||
-rw-r--r-- | src/widgets/styles/qwindowsxpstyle_p_p.h | 1 |
6 files changed, 36 insertions, 48 deletions
diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index ff0f51ee13..fb0bafa66d 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -6025,8 +6025,10 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex p->fillPath(path, brush); } else if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) { static QPixmap pm(QLatin1String(":/qt-project.org/mac/style/images/leopard-unified-toolbar-on.png")); + p->save(); p->setRenderHint(QPainter::SmoothPixmapTransform); QStyleHelper::drawBorderPixmap(pm, p, tb->rect, 2, 2, 2, 2); + p->restore(); } else { QPen oldPen = p->pen(); p->setPen(QColor(0, 0, 0, 0x3a)); diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp index 3affd84124..7c4d239894 100644 --- a/src/widgets/styles/qstyle.cpp +++ b/src/widgets/styles/qstyle.cpp @@ -1463,6 +1463,12 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value PM_TabCloseIndicatorWidth The default width of a close button on a tab in a tab bar. \value PM_TabCloseIndicatorHeight The default height of a close button on a tab in a tab bar. + \value PM_ScrollView_ScrollBarSpacing Distance between frame and scrollbar + with SH_ScrollView_FrameOnlyAroundContents set. + \value PM_ScrollView_ScrollBarOverlap Overlap between scroll bars and scroll content + + \value PM_SubMenuOverlap The horizontal overlap between a submenu and its parent. + \value PM_TreeViewIndentation The indentation of items in a tree view. This enum value has been introduced in Qt 5.4. @@ -1483,12 +1489,6 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, and PM_LayoutVerticalSpacing instead. - \value PM_ScrollView_ScrollBarSpacing Distance between frame and scrollbar - with SH_ScrollView_FrameOnlyAroundContents set. - \value PM_ScrollView_ScrollBarOverlap Overlap between scroll bars and scroll content - - \value PM_SubMenuOverlap The horizontal overlap between a submenu and its parent. - \sa pixelMetric() */ diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index a6c7f5dde2..e9f20de842 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -4047,26 +4047,28 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q } if (!dwOpt->title.isEmpty()) { - QRect r = opt->rect; + QRect r = subElementRect(SE_DockWidgetTitleBarText, opt, w); if (dwOpt->verticalTitleBar) { QSize s = r.size(); s.transpose(); r.setSize(s); - p->save(); p->translate(r.left(), r.top() + r.width()); p->rotate(-90); p->translate(-r.left(), -r.top()); } + r = subRule.contentsRect(r); Qt::Alignment alignment = 0; if (subRule.hasPosition()) alignment = subRule.position()->textAlignment; if (alignment == 0) alignment = Qt::AlignLeft; - drawItemText(p, subRule.contentsRect(opt->rect), + + QString titleText = p->fontMetrics().elidedText(dwOpt->title, Qt::ElideRight, r.width()); + drawItemText(p, r, alignment | Qt::TextShowMnemonic, dwOpt->palette, - dwOpt->state & State_Enabled, dwOpt->title, + dwOpt->state & State_Enabled, titleText, QPalette::WindowText); if (dwOpt->verticalTitleBar) @@ -5826,6 +5828,10 @@ bool QStyleSheetStyle::event(QEvent *e) void QStyleSheetStyle::updateStyleSheetFont(QWidget* w) const { + // Qt's fontDialog relies on the font of the sample edit for its selection, + // we should never override it. + if (w->objectName() == QLatin1String("qt_fontDialog_sampleEdit")) + return; QWidget *container = containerWidget(w); QRenderRule rule = renderRule(container, PseudoElement_None, PseudoClass_Active | PseudoClass_Enabled | extendedPseudoClass(container)); diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp index a6eb2c0bc6..007952192a 100644 --- a/src/widgets/styles/qwindowsvistastyle.cpp +++ b/src/widgets/styles/qwindowsvistastyle.cpp @@ -1756,26 +1756,8 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle theme.stateId = stateId; d->drawBackground(theme); - // Calculate rect of gripper - const int swidth = theme.rect.width(); - const int sheight = theme.rect.height(); - - const QMargins contentsMargin = theme.margins(theme.rect, TMT_SIZINGMARGINS) - / QWindowsXPStylePrivate::devicePixelRatio(widget); - - theme.partId = flags & State_Horizontal ? SBP_GRIPPERHORZ : SBP_GRIPPERVERT; - const QSize size = theme.size() / QWindowsXPStylePrivate::devicePixelRatio(widget); - if (QSysInfo::WindowsVersion < QSysInfo::WV_WINDOWS8) { - QPoint gripperBoundsPos(0, 0); - if ((flags & State_Horizontal - && swidth - contentsMargin.left() - contentsMargin.right() > size.width()) - || sheight - contentsMargin.top() - contentsMargin.bottom() > size.height()) { - gripperBoundsPos = QPoint(theme.rect.left() + (swidth - size.width()) / 2, - theme.rect.top() + (sheight - size.height()) / 2); - } - const QRect gripperBounds(gripperBoundsPos, size); - + const QRect gripperBounds = QWindowsXPStylePrivate::scrollBarGripperBounds(flags, widget, &theme); // Draw gripper if there is enough space if (!gripperBounds.isEmpty() && flags & State_Enabled) { painter->save(); @@ -2285,7 +2267,7 @@ int QWindowsVistaStyle::pixelMetric(PixelMetric metric, const QStyleOption *opti if (!QWindowsVistaStylePrivate::useVista()) return QWindowsStyle::pixelMetric(metric, option, widget); - int ret = QWindowsStylePrivate::fixedPixelMetric(metric); + int ret = QWindowsVistaStylePrivate::fixedPixelMetric(metric); if (ret != QWindowsStylePrivate::InvalidMetric) return int(QStyleHelper::dpiScaled(ret)); diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index 624023f627..c18bbb3431 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -2529,6 +2529,20 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op d->drawBackground(theme); } +QRect QWindowsXPStylePrivate::scrollBarGripperBounds(QStyle::State flags, const QWidget *widget, XPThemeData *theme) +{ + const bool horizontal = flags & QStyle::State_Horizontal; + const QMargins contentsMargin = theme->margins(theme->rect, TMT_SIZINGMARGINS) + / QWindowsStylePrivate::devicePixelRatio(widget); + theme->partId = horizontal ? SBP_GRIPPERHORZ : SBP_GRIPPERVERT; + const QSize size = theme->size() / QWindowsStylePrivate::devicePixelRatio(widget); + + const int hSpace = theme->rect.width() - size.width(); + const int vSpace = theme->rect.height() - size.height(); + const bool sufficientSpace = horizontal && hSpace > (contentsMargin.left() + contentsMargin.right()) + || vSpace > contentsMargin.top() + contentsMargin.bottom(); + return sufficientSpace ? QRect(theme->rect.topLeft() + QPoint(hSpace, vSpace) / 2, size) : QRect(); +} /*! \reimp @@ -2754,24 +2768,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo theme.stateId = stateId; d->drawBackground(theme); - // Calculate rect of gripper - const int swidth = theme.rect.width(); - const int sheight = theme.rect.height(); - - const QMargins contentsMargin = theme.margins(theme.rect, TMT_SIZINGMARGINS) - / QWindowsStylePrivate::devicePixelRatio(widget); - - theme.partId = flags & State_Horizontal ? SBP_GRIPPERHORZ : SBP_GRIPPERVERT; - const QSize size = theme.size() / QWindowsStylePrivate::devicePixelRatio(widget); - QPoint gripperBoundsPos(0, 0); - if ((flags & State_Horizontal - && swidth - contentsMargin.left() - contentsMargin.right() > size.width()) - || sheight - contentsMargin.top() - contentsMargin.bottom() > size.height()) { - gripperBoundsPos = QPoint(theme.rect.left() + (swidth - size.width()) / 2, - theme.rect.top() + (sheight - size.height()) /2); - } - const QRect gripperBounds(gripperBoundsPos, size); - + const QRect gripperBounds = QWindowsXPStylePrivate::scrollBarGripperBounds(flags, widget, &theme); // Draw gripper if there is enough space if (!gripperBounds.isEmpty()) { p->save(); diff --git a/src/widgets/styles/qwindowsxpstyle_p_p.h b/src/widgets/styles/qwindowsxpstyle_p_p.h index 4f42b60681..5027588c93 100644 --- a/src/widgets/styles/qwindowsxpstyle_p_p.h +++ b/src/widgets/styles/qwindowsxpstyle_p_p.h @@ -392,6 +392,7 @@ public: static bool resolveSymbols(); static bool useXP(bool update = false); + static QRect scrollBarGripperBounds(QStyle::State flags, const QWidget *widget, XPThemeData *theme); bool isTransparent(XPThemeData &themeData); QRegion region(XPThemeData &themeData); |