diff options
| author | Christian Ehrlicher <[email protected]> | 2025-08-20 21:41:11 +0200 |
|---|---|---|
| committer | Christian Ehrlicher <[email protected]> | 2025-10-25 21:15:37 +0200 |
| commit | 3e649c9a42c430c904c13a93daa1173dbadf6bd8 (patch) | |
| tree | ef7836aa9d6c21db08fc833b5600129a4c08b633 | |
| parent | 37459a15e5cde505c376bb1b4f7362efe8869efa (diff) | |
In pressed state the text color is subtlePressedColor, only for hover we
have to use subtleHighlightColor.
Pick-to: 6.10
Change-Id: I7ad7505a73df5ab8255210a237efcc0903b7b445
Reviewed-by: Volker Hilsheimer <[email protected]>
| -rw-r--r-- | src/plugins/styles/modernwindows/qwindows11style.cpp | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/src/plugins/styles/modernwindows/qwindows11style.cpp b/src/plugins/styles/modernwindows/qwindows11style.cpp index 33775ecb9bb..27a944a33e2 100644 --- a/src/plugins/styles/modernwindows/qwindows11style.cpp +++ b/src/plugins/styles/modernwindows/qwindows11style.cpp @@ -123,8 +123,8 @@ static constexpr int percentToAlpha(double percent) } static constexpr std::array<QColor, 33> WINUI3ColorsLight { - QColor(0x00,0x00,0x00,0x09), //subtleHighlightColor - QColor(0x00,0x00,0x00,0x06), //subtlePressedColor + QColor(0x00,0x00,0x00,percentToAlpha(3.73)), // subtleHighlightColor (fillSubtleSecondary) + QColor(0x00,0x00,0x00,percentToAlpha(2.41)), // subtlePressedColor (fillSubtleTertiary) QColor(0x00,0x00,0x00,0x0F), //frameColorLight QColor(0x00,0x00,0x00,percentToAlpha(60.63)), //frameColorStrong QColor(0x00,0x00,0x00,percentToAlpha(21.69)), //frameColorStrongDisabled @@ -159,8 +159,8 @@ static constexpr std::array<QColor, 33> WINUI3ColorsLight { }; static constexpr std::array<QColor, 33> WINUI3ColorsDark { - QColor(0xFF,0xFF,0xFF,0x0F), //subtleHighlightColor - QColor(0xFF,0xFF,0xFF,0x0A), //subtlePressedColor + QColor(0xFF,0xFF,0xFF,percentToAlpha(6.05)), // subtleHighlightColor (fillSubtleSecondary) + QColor(0xFF,0xFF,0xFF,percentToAlpha(4.19)), // subtlePressedColor (fillSubtleTertiary) QColor(0xFF,0xFF,0xFF,0x12), //frameColorLight QColor(0xFF,0xFF,0xFF,percentToAlpha(60.47)), //frameColorStrong QColor(0xFF,0xFF,0xFF,percentToAlpha(15.81)), //frameColorStrongDisabled @@ -1509,32 +1509,33 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op break; case CE_MenuBarItem: if (const auto *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { + using namespace StyleOptionHelper; + constexpr int hPadding = 11; constexpr int topPadding = 4; constexpr int bottomPadding = 6; - bool active = mbi->state & State_Selected; - bool hasFocus = mbi->state & State_HasFocus; - bool down = mbi->state & State_Sunken; - bool enabled = mbi->state & State_Enabled; QStyleOptionMenuItem newMbi = *mbi; + + if (auto mbiV2 = qstyleoption_cast<const QStyleOptionMenuItemV2 *>(option)) + newMbi.state.setFlag(State_Sunken, mbiV2->mouseDown); + newMbi.font.setPointSize(10); - if (enabled && active) { - if (down) - painter->setBrushOrigin(painter->brushOriginF() + QPoint(1, 1)); - if (hasFocus) { - if (highContrastTheme) - painter->setPen(QPen(newMbi.palette.highlight().color(), 2)); - else - painter->setPen(Qt::NoPen); - painter->setBrush(highContrastTheme ? newMbi.palette.window().color() : WINUI3Colors[colorSchemeIndex][subtleHighlightColor]); - QRect rect = mbi->rect.marginsRemoved(QMargins(5,0,5,0)); - painter->drawRoundedRect(rect,secondLevelRoundingRadius,secondLevelRoundingRadius, Qt::AbsoluteSize); + newMbi.palette.setColor(QPalette::ButtonText, controlTextColor(&newMbi)); + if (!isDisabled(&newMbi)) { + QPen pen(Qt::NoPen); + QBrush brush(Qt::NoBrush); + if (highContrastTheme) { + pen = QPen(newMbi.palette.highlight().color(), 2); + brush = newMbi.palette.window(); + } else if (isPressed(&newMbi)) { + brush = winUI3Color(subtlePressedColor); + } else if (isHover(&newMbi)) { + brush = winUI3Color(subtleHighlightColor); + } + if (pen != Qt::NoPen || brush != Qt::NoBrush) { + const QRect rect = mbi->rect.marginsRemoved(QMargins(5, 0, 5, 0)); + drawRoundedRect(painter, rect, pen, brush); } - } else if (enabled && highContrastTheme) { - painter->setPen(QPen(newMbi.palette.windowText().color(), 2)); - painter->setBrush(newMbi.palette.window().color()); - QRect rect = mbi->rect.marginsRemoved(QMargins(5,0,5,0)); - painter->drawRoundedRect(rect,secondLevelRoundingRadius,secondLevelRoundingRadius, Qt::AbsoluteSize); } newMbi.rect.adjust(hPadding,topPadding,-hPadding,-bottomPadding); painter->setFont(newMbi.font); |
