diff options
| author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2026-09-15 15:31:39 +0200 |
|---|---|---|
| committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2026-09-17 11:43:06 +0000 |
| commit | 729690ce06c906cbf96c837c147db85dd0bba531 (patch) | |
| tree | a57005caa0bd974090d5686f45a82e6164f4e40d | |
| parent | 469ffcaf1b9bd86167d949026365a1eca2301391 (diff) | |
StyleKit, fallback: align switchControl with checkBox
checkBox hides indicator.foreground when not checked.
This makes it easy to change the indicator.foreground.color,
since the color will only show when the checkBox is checked.
switchControl, on the other hand, solves it differently.
Rather than hiding the foreground when unchecked, it
sets the color to transparent.
That forces a style designer who wants to override the switch
color to handle both the checked and the unchecked state.
This patch will instead ensure that switch works the same
way as a checkbox, and instead hide the foreground when unchecked.
Worth picking to 6.12.0, since changing it after StyleKit's
first release would break existing styles.
Change-Id: Iab4c4f4bd66e658333c6401f4a239694adb0ecff
Reviewed-by: Doris Verria <doris.verria@qt.io>
(cherry picked from commit 3027a40c87ee06d201620a35b091e5ef1a7bb26a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit c6190b95b5446c0609715b099871bf04a1a656c8)
| -rw-r--r-- | examples/stylekit/stylekitcontrols/styles/Haze.qml | 10 | ||||
| -rw-r--r-- | src/labs/stylekit/impl/FallbackStyle.qml | 7 |
2 files changed, 3 insertions, 14 deletions
diff --git a/examples/stylekit/stylekitcontrols/styles/Haze.qml b/examples/stylekit/stylekitcontrols/styles/Haze.qml index d8f0ce7409..b9800a96a5 100644 --- a/examples/stylekit/stylekitcontrols/styles/Haze.qml +++ b/examples/stylekit/stylekitcontrols/styles/Haze.qml @@ -475,11 +475,6 @@ Style { background.color: Qt.darker("gainsboro", 1.05) } - switchControl { - indicator.foreground.color: "white" - checked.indicator.foreground.color: palette.accent - } - textField { background { shadow.scale: 0 @@ -659,11 +654,6 @@ Style { indicator.foreground.color: "white" } - switchControl { - indicator.foreground.color: Qt.lighter("#8e848a", 1.3) - checked.indicator.foreground.color: palette.accent - } - slider { indicator.foreground.color: palette.accent } diff --git a/src/labs/stylekit/impl/FallbackStyle.qml b/src/labs/stylekit/impl/FallbackStyle.qml index 5fb9f0a37d..99451cdea0 100644 --- a/src/labs/stylekit/impl/FallbackStyle.qml +++ b/src/labs/stylekit/impl/FallbackStyle.qml @@ -652,15 +652,14 @@ BaseStyle { alignment: Qt.AlignLeft | Qt.AlignVCenter radius: style.indicatorSize / 2 foreground { + visible: false fillWidth: true fillHeight: true radius: style.indicatorSize / 2 - color: __transparent + color: palette.accent } } - checked { - indicator.foreground.color: palette.accent - } + checked.indicator.foreground.visible: true } switchDelegate { |
