summaryrefslogtreecommitdiffstats
path: root/mobile-widgets/qml/TemplateSpinBox.qml
blob: 51f26aa668b6e35588cbacdd0db9f64d52d9c128 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// SPDX-License-Identifier: GPL-2.0
import QtQuick 2.11
import QtQuick.Controls 2.4
import QtQuick.Layouts 1.11
import org.subsurfacedivelog.mobile 1.0
import org.kde.kirigami 2.4 as Kirigami

SpinBox {
	id: control
	editable: true
	font.pointSize: subsurfaceTheme.regularPointSize

	contentItem: TextInput {
		z: 2
		text: control.textFromValue(control.value, control.locale)
		font: control.font
		color: control.enabled ? subsurfaceTheme.textColor : subsurfaceTheme.disabledTextColor
		horizontalAlignment: Qt.AlignHCenter
		verticalAlignment: Qt.AlignVCenter

		readOnly: !control.editable
		validator: control.validator
		inputMethodHints: Qt.ImhFormattedNumbersOnly
	}

	up.indicator: Rectangle {
		x: control.mirrored ? 0 : parent.width - width
		height: Kirigami.Units.gridUnit * 2
		implicitWidth: Kirigami.Units.gridUnit * 1.5
		implicitHeight: Kirigami.Units.gridUnit * 1.5
		color: control.enabled ? subsurfaceTheme.primaryColor : subsurfaceTheme.backgroundColor
		border.color: control.enabled ? subsurfaceTheme.primaryColor : subsurfaceTheme.backgroundColor
		Text {
			text: "+"
			font.pixelSize: control.font.pixelSize * 2
			color: control.enabled ? subsurfaceTheme.textColor : subsurfaceTheme.disabledTextColor
			anchors.fill: parent
			fontSizeMode: Text.Fit
			horizontalAlignment: Text.AlignHCenter
			verticalAlignment: Text.AlignVCenter
		}
	}

	down.indicator: Rectangle {
		x: control.mirrored ? parent.width - width : 0
		height: Kirigami.Units.gridUnit * 2
		implicitWidth: Kirigami.Units.gridUnit * 1.5
		implicitHeight: Kirigami.Units.gridUnit * 1.5
		color: control.enabled ? subsurfaceTheme.primaryColor : subsurfaceTheme.backgroundColor
		border.color: control.enabled ? subsurfaceTheme.primaryColor : subsurfaceTheme.backgroundColor
		Text {
			text: "-"
			font.pixelSize: control.font.pixelSize * 2
			color: control.enabled ? subsurfaceTheme.textColor : subsurfaceTheme.disabledTextColor
			anchors.fill: parent
			fontSizeMode: Text.Fit
			horizontalAlignment: Text.AlignHCenter
			verticalAlignment: Text.AlignVCenter
		}
	}

	background: Rectangle {
		implicitWidth: 5* Kirigami.Units.gridUnit
		color: subsurfaceTheme.backgroundColor
		border.color: subsurfaceTheme.backgroundColor
	}
}