Changeset View
Changeset View
Standalone View
Standalone View
src/declarativeimports/plasmacomponents3/SpinBox.qml
Show All 30 Lines | 25 | contentItem: TextInput { | |||
---|---|---|---|---|---|
31 | selectionColor: theme.highlightColor | 31 | selectionColor: theme.highlightColor | ||
32 | selectedTextColor: theme.selectedTextColor | 32 | selectedTextColor: theme.selectedTextColor | ||
33 | horizontalAlignment: Qt.AlignHCenter | 33 | horizontalAlignment: Qt.AlignHCenter | ||
34 | verticalAlignment: Qt.AlignVCenter | 34 | verticalAlignment: Qt.AlignVCenter | ||
35 | 35 | | |||
36 | readOnly: !control.editable | 36 | readOnly: !control.editable | ||
37 | validator: control.validator | 37 | validator: control.validator | ||
38 | inputMethodHints: Qt.ImhFormattedNumbersOnly | 38 | inputMethodHints: Qt.ImhFormattedNumbersOnly | ||
39 | | ||||
40 | // Allow adjusting the value by scrolling over it | ||||
41 | MouseArea { | ||||
42 | anchors.fill: parent | ||||
43 | | ||||
44 | // Only handle scroll events | ||||
45 | acceptedButtons: Qt.NoButton | ||||
46 | cursorShape: Qt.IBeamCursor | ||||
47 | onWheel: { | ||||
48 | if (wheel.angleDelta.y > 0 && control.value <= control.to) { | ||||
49 | control.value += control.stepSize | ||||
cblack: `control.value` is already a numeric type as `control` is a SpinBox, so you don't need to… | |||||
50 | control.valueModified() | ||||
I think you would need to explicitly call this on control? control.valueModified(). cblack: I think you would need to explicitly call this on `control`? `control.valueModified()`. | |||||
51 | } else if (wheel.angleDelta.y < 0 && control.value >= control.from) { | ||||
You can do mouse.accepted = false instead of forceActiveFocus to allow the mouse press to go to items below it. However, you might instead want to use DragHandler's onActiveChanged for this, as that signals when the actual drag is active. ahiemstra: You can do `mouse.accepted = false` instead of forceActiveFocus to allow the mouse press to go… | |||||
52 | control.value -= control.stepSize | ||||
cblack: `control.value =- control.stepSize` | |||||
53 | control.valueModified() | ||||
cblack: `control.valueModified()`. | |||||
54 | } | ||||
55 | } | ||||
56 | } | ||||
39 | } | 57 | } | ||
40 | 58 | | |||
41 | up.indicator: Item { | 59 | up.indicator: Item { | ||
42 | x: control.mirrored ? 0 : parent.width - width | 60 | x: control.mirrored ? 0 : parent.width - width | ||
43 | implicitHeight: parent.height | 61 | implicitHeight: parent.height | ||
44 | implicitWidth: implicitHeight | 62 | implicitWidth: implicitHeight | ||
45 | PlasmaCore.FrameSvgItem { | 63 | PlasmaCore.FrameSvgItem { | ||
46 | anchors { | 64 | anchors { | ||
▲ Show 20 Lines • Show All 43 Lines • Show Last 20 Lines |
control.value is already a numeric type as control is a SpinBox, so you don't need to parseInt here. control.value =+ control.stepSize