aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2021-05-04 14:36:57 +0200
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2021-05-05 14:34:04 +0200
commitcad9ba218f04bc3de14a08e93bfa2ff33164e6fd (patch)
tree84e5a97ab7d852c55df0eb2a9d9cb5069e3c8e5d /src/imports
parent47576dccadac1c56fd3b67d7d0cfcd53e5c8af7e (diff)
macOS, Slider: draw a focus rect, and not a focus ring
In the mac style, we draw the focus ring for a slider from QML around the handle. This has shown to be fragile, since UIKit doesn't draw the handle in the center of the rect we get when we query UIKit (using the [cell knobRectFlipped:slider.isFlipped]). And then the focus ring will be offset as well. While we could try to adjust the rect manually from QQuickMacStyle, this will only be quaranteed to work on top of the current macOS SDK (macosx11.1). So for that reason, this patch falls back to use the less correct, but more future safe, solution of drawng the focus ring as a rect around the handle instead. While this doesn't look native, it still looks better (and correct, for the uninformed) compared to an eliptic ring that is misplaced on the target. Fixes: QTBUG-93423 Pick-to: 6.1 6.0 Change-Id: Ibc00f12f9606cd66c8ff384967aa3ea0d7727964 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/imports')
-rw-r--r--src/imports/nativestyle/qstyle/mac/qquickmacstyle_mac.mm7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/imports/nativestyle/qstyle/mac/qquickmacstyle_mac.mm b/src/imports/nativestyle/qstyle/mac/qquickmacstyle_mac.mm
index 47fac5b3..5d061667 100644
--- a/src/imports/nativestyle/qstyle/mac/qquickmacstyle_mac.mm
+++ b/src/imports/nativestyle/qstyle/mac/qquickmacstyle_mac.mm
@@ -2227,8 +2227,11 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt) const
ret = 10;
break;
case PM_SliderFocusFrameRadius:
- if (const QStyleOptionSlider *sliderOpt = qstyleoption_cast<const QStyleOptionSlider *>(opt))
- ret = sliderOpt->tickPosition == QStyleOptionSlider::NoTicks ? 10 : 3;
+ // QTBUG-93423: We currently need to skip drawing a focus ring around the handle, since
+ // the handle drawn by the UIKit is not centered inside the rect we get from calling
+ // [cell knobRectFlipped:slider.isFlipped]. So we choose to draw the focus as
+ // a rect instead until we have a better solution available.
+ ret = 0;
break;
case PM_DialFocusFrameRadius:
case PM_SpinBoxFocusFrameRadius: