7import org.kde.kirigami as Kirigami
9import org.kde.kirigamiaddons.dateandtime
29 property bool _pm: false
31 property bool _init: false
33 readonly property bool _isAmPm: Qt.locale().timeFormat().includes("AP")
38 Component.onCompleted: {
39 hoursTumbler.currentIndex = (_isAmPm && hours > 12 ? hours - 12 : hours);
40 minutesTumbler.currentIndex = minutes;
42 root._pm = hours > 12 ? 1 : 0;
43 amPmTumbler.currentIndex = _pm;
51 function formatText(count, modelData) {
52 var data = count === 12 && modelData === 0 ? 12 : modelData;
53 return data.toString().length < 2 ?
"0" + data : data;
65 text: formatText(Tumbler.tumbler.count, modelData)
66 opacity: 1.0 - Math.abs(Tumbler.displacement) / (Tumbler.tumbler.visibleItemCount / 2)
70 Accessible.ignored: true
77 width: delegate === Tumbler.tumbler.currentItem ? 1 : 0
85 Layout.fillWidth: true
91 model: _isAmPm ? 12 : 24
92 delegate: delegateComponent
94 onCurrentIndexChanged: if (_init) {
95 hours = currentIndex + (_isAmPm && _pm ? 12 : 0)
97 Accessible.name:
i18nd(
"kirigami-addons6",
"Hours")
98 Accessible.role: Accessible.Dial
99 Accessible.onDecreaseAction: hoursTumbler.currentIndex = (hoursTumbler.currentIndex + hoursTumbler.model - 1) % hoursTumbler.model
100 Accessible.onIncreaseAction: hoursTumbler.currentIndex = (hoursTumbler.currentIndex + 1) % hoursTumbler.model
102 property
int minimumValue: root._isAmPm ? 1 : 0
103 property
int maximumValue: root._isAmPm ? 12 : 23
104 property
int stepSize: 1
105 property
int value: root.hours
107 if (root._isAmPm && value === 12)
108 hoursTumbler.currentIndex = 0;
110 hoursTumbler.currentIndex = value;
111 hoursTumbler.value =
Qt.binding(function() {
return root.hours; });
118 Layout.alignment:
Qt.AlignCenter
119 text:
i18ndc(
"kirigami-addons6",
"Time separator",
":")
120 font.pointSize:
Kirigami.Theme.defaultFont.pointSize * 1.3
121 Accessible.ignored: true
126 Layout.preferredHeight:
Kirigami.Units.gridUnit * 10
128 delegate: delegateComponent
130 onCurrentIndexChanged:
if (_init) {
131 minutes = currentIndex;
134 Accessible.name:
i18nd(
"kirigami-addons6",
"Minutes")
135 Accessible.role: Accessible.Dial
136 Accessible.onDecreaseAction: minutesTumbler.currentIndex = (minutesTumbler.currentIndex + 59) % 60
137 Accessible.onIncreaseAction: minutesTumbler.currentIndex = (minutesTumbler.currentIndex + 1) % 60
139 property
int minimumValue: 0
140 property
int maximumValue: 59
141 property
int stepSize: 1
142 property alias value: minutesTumbler.currentIndex
148 Layout.preferredHeight:
Kirigami.Units.gridUnit * 10
149 model: [
Qt.locale().amText,
Qt.locale().pmText]
150 Accessible.name: currentItem.text
151 Accessible.role: Accessible.CheckBox
152 Accessible.ignored: !_isAmPm
153 Accessible.onPressAction: amPmTumbler.currentIndex = (amPmTumbler.currentIndex + 1) % 2
154 Accessible.onToggleAction: amPmTumbler.currentIndex = (amPmTumbler.currentIndex + 1) % 2
155 delegate: delegateComponent
157 onCurrentIndexChanged: if (_isAmPm && _init) {
159 hours = (hours + 12) % 24;
164 Layout.fillWidth:
true
QString i18ndc(const char *domain, const char *context, const char *text, const TYPE &arg...)
QString i18nd(const char *domain, const char *text, const TYPE &arg...)
qreal pixelSize(qreal scale)