@@ -19,6 +19,15 @@ Item {
19
19
radius: 2
20
20
}
21
21
22
+ function up () {
23
+ if (value < to) value += stepSize
24
+ value = Math .max (from, Math .min (to, value)).toFixed (decimals)
25
+ }
26
+ function down () {
27
+ if (value > from) value -= stepSize
28
+ value = Math .max (from, Math .min (to, value)).toFixed (decimals)
29
+ }
30
+
22
31
Kirigami .Icon {
23
32
source: " arrow-up"
24
33
height: parent .height / 2
@@ -31,10 +40,17 @@ Item {
31
40
id: upMouse
32
41
anchors .fill : parent
33
42
hoverEnabled: true
34
- onClicked: {
35
- root .parent .forceActiveFocus ()
36
- if (value < to) value += stepSize
37
- value = Math .max (from, Math .min (to, value)).toFixed (decimals)
43
+ onPressed: { timerUp .start () }
44
+ onReleased: { timerUp .stop () }
45
+ }
46
+ Timer {
47
+ id: timerUp
48
+ interval: 150
49
+ repeat: true
50
+ triggeredOnStart: true
51
+ running: false
52
+ onTriggered: {
53
+ up ()
38
54
}
39
55
}
40
56
}
@@ -51,17 +67,25 @@ Item {
51
67
id: downMouse
52
68
anchors .fill : parent
53
69
hoverEnabled: true
54
- onClicked: {
55
- root .parent .forceActiveFocus ()
56
- if (value > from) value -= stepSize
57
- value = Math .max (from, Math .min (to, value)).toFixed (decimals)
70
+ onPressed: { timerDown .start () }
71
+ onReleased: { timerDown .stop () }
72
+ }
73
+ Timer {
74
+ id: timerDown
75
+ interval: 150
76
+ repeat: true
77
+ triggeredOnStart: true
78
+ running: false
79
+ onTriggered: {
80
+ down ()
58
81
}
59
82
}
60
83
}
61
84
62
85
MouseArea {
63
86
anchors .fill : parent
64
87
propagateComposedEvents: true
88
+ acceptedButtons: Qt .MiddleButton
65
89
onWheel : (wheel ) => {
66
90
root .parent .forceActiveFocus ()
67
91
if (wheel .angleDelta .y > 0 && value < to) {
0 commit comments