diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-10-23 11:01:02 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-10-27 20:48:01 +0200 |
commit | a11fcb6b2520eacef3c4ea541c33b1f8b7325893 (patch) | |
tree | 07b30c035d2b7ce608636de03118c7ef336195a2 /src/plugins | |
parent | e0fea817a5694b69d56cbea5f1dbbfca36e62abb (diff) | |
download | qtbase-a11fcb6b2520eacef3c4ea541c33b1f8b7325893.tar.gz |
Windows 11: draw checked menu items with an explicit background
On Windows 11, the UXTheme API draws both MBI_PUSHED and MBI_HOT in the
exact same color as the icon grove. For menu items with icon, but with
no explicit "On" icon, that makes it impossible to see whether the item
is checked.
Work around this problem by drawing the background in a light version of
the highlight color, which simulates the style on Windows 10.
Note: In modern Windows 11 menus, checkable items with icons render both
the checkmark, and the icon next to each other.
Fixes: QTBUG-98354
Change-Id: I830eca5cdb3317f69dd5c863586e0b0eaa8774d2
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
(cherry picked from commit b3ce494bac20aae52a530bcd990b027f37fc3464)
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/styles/windowsvista/qwindowsvistastyle.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp b/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp index 0380ef82d8..ebe11f7bb9 100644 --- a/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp +++ b/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp @@ -41,6 +41,14 @@ static const int windowsRightBorder = 15; // right border on windows # define CMDLGS_DISABLED 4 #endif +namespace QOSWorkaround { + // Due to a mingw bug being confused by static constexpr variables in an exported class, + // we cannot use QOperatingSystemVersion::Windows11 in libraries outside of QtCore. + // ### TODO Remove this when that problem is fixed. + static constexpr QOperatingSystemVersionBase Windows11 { QOperatingSystemVersionBase::Windows, + 10, 0, 22000 }; +} + /* \internal Checks if we should use Vista style , or if we should fall back to Windows style. @@ -1241,6 +1249,9 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption else theme.stateId = bullet ? MC_BULLETNORMAL: MC_CHECKMARKNORMAL; d->drawBackground(theme); + } else if (QOperatingSystemVersion::current() >= QOSWorkaround::Windows11 + && !act) { + painter->fillRect(checkRect, menuitem->palette.highlight().color().lighter(200)); } } |