diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2016-02-11 08:24:34 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2016-02-11 08:25:04 +0100 |
commit | d456f87ece0323982b7601047712545ab95426ad (patch) | |
tree | 46b90468b01144615f280620d73763fc189d25ac /src/widgets/styles | |
parent | cc2938b5b6aa07210b04bd48ad8a2830701a06e5 (diff) | |
parent | 4fc070a4192d5b914b6f814a8dcab3f552d9abac (diff) |
Merge remote-tracking branch 'origin/5.6' into dev
Conflicts:
src/corelib/io/qfilesystemwatcher_win.cpp
src/corelib/plugin/plugin.pri
src/plugins/platforms/cocoa/qcocoaaccessibility.mm
tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
Change-Id: Id6824631252609a75eff8b68792e4d10095c8fc1
Diffstat (limited to 'src/widgets/styles')
-rw-r--r-- | src/widgets/styles/qwindowsvistastyle.cpp | 48 | ||||
-rw-r--r-- | src/widgets/styles/qwindowsxpstyle.cpp | 38 | ||||
-rw-r--r-- | src/widgets/styles/qwindowsxpstyle_p_p.h | 1 |
3 files changed, 43 insertions, 44 deletions
diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp index 3136118cdd..c8ecc3f192 100644 --- a/src/widgets/styles/qwindowsvistastyle.cpp +++ b/src/widgets/styles/qwindowsvistastyle.cpp @@ -219,6 +219,26 @@ void QWindowsVistaAnimation::paint(QPainter *painter, const QStyleOption *option painter->drawImage(option->rect, currentImage()); } +static inline bool supportsStateTransition(QStyle::PrimitiveElement element, + const QStyleOption *option, + const QWidget *widget) +{ + bool result = false; + switch (element) { + case QStyle::PE_IndicatorRadioButton: + case QStyle::PE_IndicatorCheckBox: + result = true; + break; + // QTBUG-40634, do not animate when color is set in palette for PE_PanelLineEdit. + case QStyle::PE_FrameLineEdit: + result = !QWindowsXPStylePrivate::isLineEditBaseColorSet(option, widget); + break; + default: + break; + } + return result; +} + /*! \internal @@ -249,6 +269,7 @@ void QWindowsVistaAnimation::paint(QPainter *painter, const QStyleOption *option starting image for the hover transition. */ + void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const { @@ -265,11 +286,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt QRect oldRect; QRect newRect; - /* widgets that support state transitions : */ - if ( element == PE_FrameLineEdit - || element == PE_IndicatorRadioButton - || element == PE_IndicatorCheckBox) - { + if (supportsStateTransition(element, option, widget)) { // Retrieve and update the dynamic properties tracking // the previous state of the widget: QObject *styleObject = option->styleObject; @@ -504,26 +521,9 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt case PE_PanelLineEdit: if (const QStyleOptionFrame *panel = qstyleoption_cast<const QStyleOptionFrame *>(option)) { - QBrush bg; - bool usePalette = false; bool isEnabled = option->state & State_Enabled; - uint resolve_mask = panel->palette.resolve(); - if (widget) { - // Since spin box includes a line edit we need to resolve the palette mask also from - // the parent, as while the color is always correct on the palette supplied by panel, - // the mask can still be empty. If either mask specifies custom base color, use that. -#ifndef QT_NO_SPINBOX - if (QAbstractSpinBox *spinbox = qobject_cast<QAbstractSpinBox*>(widget->parentWidget())) - resolve_mask |= spinbox->palette().resolve(); -#endif // QT_NO_SPINBOX - } - if (resolve_mask & (1 << QPalette::Base)) { - // Base color is set for this widget, so use it - bg = panel->palette.brush(QPalette::Base); - usePalette = true; - } - if (usePalette) { - painter->fillRect(panel->rect, bg); + if (QWindowsXPStylePrivate::isLineEditBaseColorSet(option, widget)) { + painter->fillRect(panel->rect, panel->palette.brush(QPalette::Base)); } else { int partId = EP_BACKGROUND; int stateId = EBS_NORMAL; diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index 7529bcaafb..fecfb02782 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -377,6 +377,22 @@ bool QWindowsXPStylePrivate::isItemViewDelegateLineEdit(const QWidget *widget) && parent2->inherits("QAbstractItemView"); } +// Returns whether base color is set for this widget +bool QWindowsXPStylePrivate::isLineEditBaseColorSet(const QStyleOption *option, const QWidget *widget) +{ + uint resolveMask = option->palette.resolve(); + if (widget) { + // Since spin box includes a line edit we need to resolve the palette mask also from + // the parent, as while the color is always correct on the palette supplied by panel, + // the mask can still be empty. If either mask specifies custom base color, use that. +#ifndef QT_NO_SPINBOX + if (const QAbstractSpinBox *spinbox = qobject_cast<QAbstractSpinBox*>(widget->parentWidget())) + resolveMask |= spinbox->palette().resolve(); +#endif // QT_NO_SPINBOX + } + return (resolveMask & (1 << QPalette::Base)) != 0; +} + /*! \internal This function will always return a valid window handle, and might create a limbo widget to do so. @@ -1606,30 +1622,12 @@ case PE_Frame: themeNumber = QWindowsXPStylePrivate::EditTheme; partId = EP_EDITTEXT; noBorder = true; - QBrush bg; - bool usePalette = false; bool isEnabled = flags & State_Enabled; - uint resolve_mask = panel->palette.resolve(); - -#ifndef QT_NO_SPINBOX - // Since spin box includes a line edit we need to resolve the palette mask also from - // the parent, as while the color is always correct on the palette supplied by panel, - // the mask can still be empty. If either mask specifies custom base color, use that. - if (widget) { - if (QAbstractSpinBox *spinbox = qobject_cast<QAbstractSpinBox*>(widget->parentWidget())) - resolve_mask |= spinbox->palette().resolve(); - } -#endif // QT_NO_SPINBOX - if (resolve_mask & (1 << QPalette::Base)) { - // Base color is set for this widget, so use it - bg = panel->palette.brush(QPalette::Base); - usePalette = true; - } stateId = isEnabled ? ETS_NORMAL : ETS_DISABLED; - if (usePalette) { - p->fillRect(panel->rect, bg); + if (QWindowsXPStylePrivate::isLineEditBaseColorSet(option, widget)) { + p->fillRect(panel->rect, panel->palette.brush(QPalette::Base)); } else { XPThemeData theme(0, p, themeNumber, partId, stateId, rect); if (!theme.isValid()) { diff --git a/src/widgets/styles/qwindowsxpstyle_p_p.h b/src/widgets/styles/qwindowsxpstyle_p_p.h index b88e171e99..7daef62ce0 100644 --- a/src/widgets/styles/qwindowsxpstyle_p_p.h +++ b/src/widgets/styles/qwindowsxpstyle_p_p.h @@ -421,6 +421,7 @@ public: static QString themeName(int theme); static inline bool hasTheme(int theme) { return theme >= 0 && theme < NThemes && m_themes[theme]; } static bool isItemViewDelegateLineEdit(const QWidget *widget); + static bool isLineEditBaseColorSet(const QStyleOption *option, const QWidget *widget); QIcon dockFloat, dockClose; |