diff options
author | Oliver Eftevaag <[email protected]> | 2025-05-07 13:40:21 +0200 |
---|---|---|
committer | Oliver Eftevaag <[email protected]> | 2025-06-05 02:47:23 +0200 |
commit | 4720b592d729982faf85093b7511457b4945cf8d (patch) | |
tree | cb4db1855714d07f14eb39499b80998dbb1667bc | |
parent | 7f1e6f8079f10ec9f78afec81ec861e06da8e5f5 (diff) |
The windows vista style sets the widget attribute for certain widgets to
have the Qt::WA_Hover attribute, which makes the widget eligible for
receiving hover events from QApplication::notify(QObject*, QEvent*).
However, if the windows system had enabled a high contrast theme,
the QWindowsVistaStyle::polish(QWidget*) function would return early,
without making any widgets eligible for receiving hover events.
Fix the issue by enabling hover events for select controls first,
before potentially returning early due to using a contrast theme.
Pick-to: 6.10 6.9 6.8
Change-Id: I5562f46385c6f1b498bc659c65e501f9e9376db3
Reviewed-by: Santhosh Kumar <[email protected]>
-rw-r--r-- | src/plugins/styles/modernwindows/qwindowsvistastyle.cpp | 51 |
1 files changed, 23 insertions, 28 deletions
diff --git a/src/plugins/styles/modernwindows/qwindowsvistastyle.cpp b/src/plugins/styles/modernwindows/qwindowsvistastyle.cpp index 0967ffadaa3..36333373732 100644 --- a/src/plugins/styles/modernwindows/qwindowsvistastyle.cpp +++ b/src/plugins/styles/modernwindows/qwindowsvistastyle.cpp @@ -4600,9 +4600,6 @@ int QWindowsVistaStyle::pixelMetric(PixelMetric metric, const QStyleOption *opti void QWindowsVistaStyle::polish(QWidget *widget) { QWindowsStyle::polish(widget); - if (!QWindowsVistaStylePrivate::useVista()) - return; - if (false #if QT_CONFIG(abstractbutton) || qobject_cast<QAbstractButton*>(widget) @@ -4623,35 +4620,39 @@ void QWindowsVistaStyle::polish(QWidget *widget) || qobject_cast<QAbstractSpinBox*>(widget) || qobject_cast<QSpinBox*>(widget) #endif // QT_CONFIG(spinbox) +#if QT_CONFIG(lineedit) + || qobject_cast<QLineEdit*>(widget) +#endif // QT_CONFIG(lineedit) + || qobject_cast<QGroupBox*>(widget) ) { widget->setAttribute(Qt::WA_Hover); + } else if (QTreeView *tree = qobject_cast<QTreeView *> (widget)) { + tree->viewport()->setAttribute(Qt::WA_Hover); + } else if (QListView *list = qobject_cast<QListView *> (widget)) { + list->viewport()->setAttribute(Qt::WA_Hover); } + if (!QWindowsVistaStylePrivate::useVista()) + return; + #if QT_CONFIG(rubberband) if (qobject_cast<QRubberBand*>(widget)) widget->setWindowOpacity(0.6); -#endif - -#if QT_CONFIG(lineedit) - if (qobject_cast<QLineEdit*>(widget)) - widget->setAttribute(Qt::WA_Hover); else -#endif // QT_CONFIG(lineedit) - if (qobject_cast<QGroupBox*>(widget)) - widget->setAttribute(Qt::WA_Hover); +#endif #if QT_CONFIG(commandlinkbutton) - else if (qobject_cast<QCommandLinkButton*>(widget)) { - widget->setProperty("_qt_usingVistaStyle", true); - QFont buttonFont = widget->font(); - buttonFont.setFamilies(QStringList{QLatin1String("Segoe UI")}); - widget->setFont(buttonFont); - QPalette pal = widget->palette(); - pal.setColor(QPalette::Active, QPalette::ButtonText, QColor(21, 28, 85)); - pal.setColor(QPalette::Active, QPalette::BrightText, QColor(7, 64, 229)); - widget->setPalette(pal); - } + if (qobject_cast<QCommandLinkButton*>(widget)) { + widget->setProperty("_qt_usingVistaStyle", true); + QFont buttonFont = widget->font(); + buttonFont.setFamilies(QStringList{QLatin1String("Segoe UI")}); + widget->setFont(buttonFont); + QPalette pal = widget->palette(); + pal.setColor(QPalette::Active, QPalette::ButtonText, QColor(21, 28, 85)); + pal.setColor(QPalette::Active, QPalette::BrightText, QColor(7, 64, 229)); + widget->setPalette(pal); + } else #endif // QT_CONFIG(commandlinkbutton) - else if (widget->inherits("QTipLabel")) { + if (widget->inherits("QTipLabel")) { //note that since tooltips are not reused //we do not have to care about unpolishing widget->setContentsMargins(3, 0, 4, 0); @@ -4682,12 +4683,6 @@ void QWindowsVistaStyle::polish(QWidget *widget) #endif } #endif // QT_CONFIG(inputdialog) - else if (QTreeView *tree = qobject_cast<QTreeView *> (widget)) { - tree->viewport()->setAttribute(Qt::WA_Hover); - } - else if (QListView *list = qobject_cast<QListView *> (widget)) { - list->viewport()->setAttribute(Qt::WA_Hover); - } } /*! |