aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickcontrols/basic/Slider.qml
diff options
context:
space:
mode:
authorMohammadHossein Qanbari <mohammad.qanbari@qt.io>2025-05-07 17:39:00 +0200
committerMohammadHossein Qanbari <mohammad.qanbari@qt.io>2025-06-17 10:51:04 +0200
commit0ebecfd29ba3ca5377656b4d6db622ea672e5c46 (patch)
treecf8d740fe45143cd8e275488c11524f6f9a0dc1d /src/quickcontrols/basic/Slider.qml
parent2692b14cfb702ec4b50f05f743babba5973547e4 (diff)
Basic style: Improve accessibility with high-contrast colors
This patch enhances accessibility by introducing high-contrast visual cues across various controls when high-contrast mode is preferred. Previously, controls in the Basic style did not provide sufficient visual distinction in high-contrast mode. This patch adds a visible contour (border) around controls when high-contrast mode is enabled. For some controls, the contour is added by adjusting the border color and width. For others (e.g., highlighted ComboBox items), a Rectangle is drawn around the control. TextArea and Tumbler controls are also updated accordingly. Separator controls now increase their width or height based on orientation in high-contrast mode for better visibility. ScrollBar and ScrollIndicator controls: - Previously, these controls relied solely on handle color changes, which were insufficient in high-contrast mode. - This patch introduces an optional background and increases the handle's contrast to improve visibility. The patch also ensures that text and border colors adapt to the high-contrast palette, improving legibility and focus indication throughout the controls. Minor adjustments to Menu, Delegate, and Header controls for consistent high-contrast appearance. Task-number: QTBUG-135687 Pick-to: 6.10 Change-Id: I460bd6fa2e48a47f20c2ba053ab453f32de18add Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Diffstat (limited to 'src/quickcontrols/basic/Slider.qml')
-rw-r--r--src/quickcontrols/basic/Slider.qml11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/quickcontrols/basic/Slider.qml b/src/quickcontrols/basic/Slider.qml
index 7ca8e02bf1..3578537af4 100644
--- a/src/quickcontrols/basic/Slider.qml
+++ b/src/quickcontrols/basic/Slider.qml
@@ -23,7 +23,14 @@ T.Slider {
radius: width / 2
color: control.pressed ? control.palette.light : control.palette.window
border.width: control.visualFocus ? 2 : 1
- border.color: control.visualFocus ? control.palette.highlight : control.enabled ? control.palette.mid : control.palette.midlight
+ border.color: {
+ if (activeFocus)
+ return control.palette.highlight
+ else if (Qt.styleHints.accessibility.contrastPreference !== Qt.HighContrast)
+ return control.enabled ? control.palette.mid : control.palette.midlight
+ else
+ return control.enabled ? control.palette.windowText : control.palette.mid
+ }
}
background: Rectangle {
@@ -36,6 +43,8 @@ T.Slider {
radius: 3
color: control.palette.midlight
scale: control.horizontal && control.mirrored ? -1 : 1
+ border.width: Qt.styleHints.accessibility.contrastPreference === Qt.HighContrast ? 1 : 0
+ border.color: enabled ? control.palette.dark : control.palette.mid
Rectangle {
y: control.horizontal ? 0 : control.visualPosition * parent.height