aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/shared/Slider.qml
diff options
context:
space:
mode:
authorShawn Rutledge <[email protected]>2021-10-04 14:34:03 +0200
committerShawn Rutledge <[email protected]>2021-10-04 15:53:33 +0200
commit8fc3c036debf8e230200e1c7d2a8e65df140ca76 (patch)
treee79f15e509d9b20bdfc804285c4253026e2929dd /examples/quick/shared/Slider.qml
parent2c99a8db69e40620d91d7415b02a8e222f2a2c59 (diff)
Flickable manual test: add sliders to adjust flick-speed metrics
The sliders adjust maximumFlickVelocity and flickDeceleration. Also in the shared Slider: try harder to end up with value being the same as init, after initialization, by making the range of movement divisible by more numbers, by default. 180 is highly divisible, and keeps the default Slider size reasonable. You can still override the size of the Slider arbitrarily, though. Task-number: QTBUG-97055 Change-Id: I6fb41ccb87e401a747d5a8add3100053a06d9d88 Reviewed-by: Shawn Rutledge <[email protected]>
Diffstat (limited to 'examples/quick/shared/Slider.qml')
-rw-r--r--examples/quick/shared/Slider.qml16
1 files changed, 10 insertions, 6 deletions
diff --git a/examples/quick/shared/Slider.qml b/examples/quick/shared/Slider.qml
index 5b08034571..8509facf6f 100644
--- a/examples/quick/shared/Slider.qml
+++ b/examples/quick/shared/Slider.qml
@@ -53,7 +53,8 @@ import QtQuick 2.12
Item {
id: slider
height: 26
- width: 320
+ // default drag range is 180: divisible by 2, 3, 4, 5, 6, 9, 10, ...
+ width: sliderName.width + 223 + handle.width / 2
property real min: 0
property real max: 1
@@ -67,16 +68,19 @@ Item {
id: dragHandler
target: handle
xAxis.minimum: Math.round(-handle.width / 2 + 3)
- xAxis.maximum: Math.round(foo.width - handle.width/2 - 3)
+ xAxis.maximum: Math.round(groove.width - handle.width / 2 - 3)
property real value: (handle.x - xAxis.minimum) / (xAxis.maximum - xAxis.minimum)
}
Component.onCompleted: setValue(init)
function setValue(v) {
- if (min < max)
- handle.x = Math.round( v / (max - min) *
+ if (min < max) {
+ handle.x = Math.round( v / (max - min) *
(dragHandler.xAxis.maximum - dragHandler.xAxis.minimum)
+ dragHandler.xAxis.minimum);
+// console.log(name, v, "-> handle.x", handle.x, "from fraction", (v / (max - min)),
+// "of drag range", (dragHandler.xAxis.maximum - dragHandler.xAxis.minimum), "px", min, ":", max)
+ }
}
Rectangle {
id:sliderName
@@ -92,8 +96,8 @@ Item {
}
}
- Rectangle{
- id: foo
+ Rectangle {
+ id: groove
width: parent.width - 8 - sliderName.width
color: "#eee"
height: 7