diff options
Diffstat (limited to 'src/widgets/styles/qstylehelper.cpp')
-rw-r--r-- | src/widgets/styles/qstylehelper.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/widgets/styles/qstylehelper.cpp b/src/widgets/styles/qstylehelper.cpp index 5314ab1518..1084761d30 100644 --- a/src/widgets/styles/qstylehelper.cpp +++ b/src/widgets/styles/qstylehelper.cpp @@ -25,8 +25,18 @@ Q_GUI_EXPORT int qt_defaultDpiX(); namespace QStyleHelper { +static inline bool usePixmapCache(const QStyleOption *opt) +{ + if (QWidget *widget = qobject_cast<QWidget *>(opt->styleObject)) + return !widget->testAttribute(Qt::WA_StyleSheetTarget); + return true; +} + QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size) { + if (!usePixmapCache(option)) + return {}; + const QStyleOptionComplex *complexOption = qstyleoption_cast<const QStyleOptionComplex *>(option); QString tmp = key % HexString<uint>(option->state) % HexString<uint>(option->direction) @@ -89,7 +99,7 @@ Q_WIDGETS_EXPORT qreal dpiScaled(qreal value, const QStyleOption *option) return dpiScaled(value, dpi(option)); } -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) bool isInstanceOf(QObject *obj, QAccessible::Role role) { bool match = false; @@ -110,7 +120,7 @@ bool hasAncestor(QObject *obj, QAccessible::Role role) } return found; } -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) #if QT_CONFIG(dial) @@ -226,7 +236,7 @@ QPolygonF calcLines(const QStyleOptionSlider *dial) void drawDial(const QStyleOptionSlider *option, QPainter *painter) { - QPalette pal = option->palette; + const QPalette pal = option->palette; QColor buttonColor = pal.button().color(); const int width = option->rect.width(); const int height = option->rect.height(); @@ -240,7 +250,11 @@ void drawDial(const QStyleOptionSlider *option, QPainter *painter) // Draw notches if (option->subControls & QStyle::SC_DialTickmarks) { - painter->setPen(option->palette.dark().color().darker(120)); + const bool inverted = pal.window().color().lightness() < pal.text().color().lightness() + && pal.light().color().lightness() > pal.dark().color().lightness(); + const QColor notchColor = inverted ? pal.light().color().lighter(120) + : pal.dark().color().darker(120); + painter->setPen(notchColor); painter->drawLines(QStyleHelper::calcLines(option)); } |