From a187141e739ea32ec20513db867915a3fb1b4caf Mon Sep 17 00:00:00 2001 From: David Redondo Date: Tue, 13 Oct 2020 15:19:48 +0200 Subject: [PATCH] Round slider handle position We are dividing by two and additionally availableHeight can be fractional (observed when running kirigami gallery with plasma style for example). Round the resulting values to avoid blurry rendering due to fractional positioning. --- src/declarativeimports/plasmacomponents3/RangeSlider.qml | 4 ++-- src/declarativeimports/plasmacomponents3/Slider.qml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/declarativeimports/plasmacomponents3/RangeSlider.qml b/src/declarativeimports/plasmacomponents3/RangeSlider.qml index 6d73d93cc..85a8d646d 100644 --- a/src/declarativeimports/plasmacomponents3/RangeSlider.qml +++ b/src/declarativeimports/plasmacomponents3/RangeSlider.qml @@ -23,8 +23,8 @@ T.RangeSlider { } first.handle: Item { property bool horizontal: control.orientation === Qt.Horizontal - x: control.leftPadding + (horizontal ? control.first.visualPosition * (control.availableWidth - width) : (control.availableWidth - width) / 2) - y: control.topPadding + (horizontal ? (control.availableHeight - height) / 2 : control.first.visualPosition * (control.availableHeight - height)) + x: Math.round(control.leftPadding + (horizontal ? control.first.visualPosition * (control.availableWidth - width) : (control.availableWidth - width) / 2)) + y: Math.round(control.topPadding + (horizontal ? (control.availableHeight - height) / 2 : control.first.visualPosition * (control.availableHeight - height))) width: grooveSvg.hasElement("hint-handle-size") ? grooveSvg.elementSize("hint-handle-size").width : firstHandle.width height: grooveSvg.hasElement("hint-handle-size") ? grooveSvg.elementSize("hint-handle-size").height : firstHandle.height diff --git a/src/declarativeimports/plasmacomponents3/Slider.qml b/src/declarativeimports/plasmacomponents3/Slider.qml index 8b5aeefa6..46b8f03ad 100644 --- a/src/declarativeimports/plasmacomponents3/Slider.qml +++ b/src/declarativeimports/plasmacomponents3/Slider.qml @@ -26,8 +26,8 @@ T.Slider { } handle: Item { property bool horizontal: control.orientation === Qt.Horizontal - x: control.leftPadding + (horizontal ? control.visualPosition * (control.availableWidth - width) : (control.availableWidth - width) / 2) - y: control.topPadding + (horizontal ? (control.availableHeight - height) / 2 : control.visualPosition * (control.availableHeight - height)) + x: Math.round(control.leftPadding + (horizontal ? control.visualPosition * (control.availableWidth - width) : (control.availableWidth - width) / 2)) + y: Math.round(control.topPadding + (horizontal ? (control.availableHeight - height) / 2 : control.visualPosition * (control.availableHeight - height))) width: grooveSvg.hasElement("hint-handle-size") ? grooveSvg.elementSize("hint-handle-size").width : firstHandle.width height: grooveSvg.hasElement("hint-handle-size") ? grooveSvg.elementSize("hint-handle-size").height : firstHandle.height