6import QtQuick.Controls 2.15
7import org.kde.kirigami 2.20 as Kirigami
8import QtQuick.Layouts 1.15
9import org.kde.kirigamiaddons.dateandtime 1.0
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)
69 font.pixelSize: fontMetrics.font.pixelSize * 1.25
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:
if (!_isAmPm) {
98 i18ndc(
"kirigami-addons6",
"time in hour in 24h format",
"%1 hours", root.hours)
99 }
else if (_isAmPm && _pm) {
100 i18ndc(
"kirigami-addons6",
"time in hour (PM)",
"%1 PM", currentIndex + 12)
102 i18ndc(
"kirigami-addons6",
"time in hour (AM)",
"%1 AM", currentIndex)
104 Accessible.role: Accessible.Dial
105 Accessible.onDecreaseAction: hoursTumbler.currentIndex = (hoursTumbler.currentIndex + hoursTumbler.model - 1) % hoursTumbler.model
106 Accessible.onIncreaseAction: hoursTumbler.currentIndex = (hoursTumbler.currentIndex + 1) % hoursTumbler.model
112 text:
i18ndc(
"kirigami-addons6",
"Time separator",
":")
113 font.pointSize:
Kirigami.Theme.defaultFont.pointSize * 1.3
114 Accessible.ignored: true
121 delegate: delegateComponent
123 onCurrentIndexChanged: if (_init) {
124 minutes = currentIndex;
127 Accessible.name:
i18ndc(
"kirigami-addons6",
"number of minutes",
"%1 minutes", root.minutes)
128 Accessible.role: Accessible.Dial
129 Accessible.onDecreaseAction: minutesTumbler.currentIndex = (minutesTumbler.currentIndex + 59) % 60
130 Accessible.onIncreaseAction: minutesTumbler.currentIndex = (minutesTumbler.currentIndex + 1) % 60
136 Layout.preferredHeight:
Kirigami.Units.gridUnit * 10
137 model: [
Qt.locale().amText,
Qt.locale().pmText]
138 Accessible.name: currentItem.text
139 Accessible.role: Accessible.CheckBox
140 Accessible.ignored: !_isAmPm
141 Accessible.onPressAction: amPmTumbler.currentIndex = (amPmTumbler.currentIndex + 1) % 2
142 Accessible.onToggleAction: amPmTumbler.currentIndex = (amPmTumbler.currentIndex + 1) % 2
143 delegate: delegateComponent
145 onCurrentIndexChanged: if (_isAmPm && _init) {
147 hours = (hours + 12) % 24;
152 Layout.fillWidth:
true
QString i18ndc(const char *domain, const char *context, const char *text, const TYPE &arg...)