Windowsvista style: Fix hover widget attribute when using contrast theme
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.9 6.8 Change-Id: I5562f46385c6f1b498bc659c65e501f9e9376db3 Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io> (cherry picked from commit 4720b592d729982faf85093b7511457b4945cf8d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
023e36e0e7
commit
6874de0e50
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
Loading…
x
Reference in New Issue
Block a user