blob: 79377a6c253366245fe957179f2ea310ad021eac (
plain)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtQuick.Controls as QQC2
import WearableStyle
Item {
function addAlarm() {
alarms.append(
{
"title": qsTr("New alarm"),
"hour": 0,
"minute": 0,
"nextRing": qsTr("Thursday 20. Nov."),
"armed": false
})
}
QQC2.AbstractButton {
id: plusButton
anchors.top: parent.top
anchors.right: parent.right
anchors.topMargin: 5
anchors.leftMargin: 5
width: height
height: 40
onClicked: parent.addAlarm()
Image {
anchors.centerIn: parent
width: 32
height: 32
source: UIStyle.iconPath("plus")
}
}
ListModel {
id: alarms
ListElement {
title: qsTr("Workday morning")
hour: 6
minute: 30
nextRing: qsTr("Thursday 20. Nov.")
armed: false
}
ListElement {
title: qsTr("Weekend morning")
hour: 8
minute: 40
nextRing: qsTr("Saturday 22. Nov.")
armed: false
}
}
property alias alarmList: listview
ListView {
id: listview
anchors.fill: parent
anchors.margins: 15
anchors.topMargin: 40 + 15
spacing: 10
model: alarms
delegate: ListHeaderItem {
id: alarmItem
property alias onSwitch: onSwitch
property alias minuteTumbler: minuteTumbler
property alias hourTumbler: hourTumbler
required property string title
required property string nextRing
required property bool armed
width: parent.width
height: 94
Item {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
height: 28
Text {
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.margins: 10
text: alarmItem.title
color: UIStyle.titletextColor
font: UIStyle.h3
}
Text {
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
anchors.margins: 10
text: alarmItem.nextRing
color: UIStyle.titletextColor
font: UIStyle.p1
}
}
Item {
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
height: 66
Switch {
id: onSwitch
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.margins: 15
checked: alarmItem.armed
}
QQC2.Tumbler {
id: minuteTumbler
height: parent.height
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
anchors.rightMargin: 0
visibleItemCount: 1
model: 60
delegate: Text {
required property int modelData
text: (modelData < 10 ? "0" : "") + modelData
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
leftPadding: 5
font: UIStyle.tumblerFont
color: UIStyle.textColor
}
}
Text {
id: timespacer
anchors.verticalCenter: parent.verticalCenter
anchors.right: minuteTumbler.left
verticalAlignment: Text.AlignVCenter
font: UIStyle.tumblerFont
color: UIStyle.textColor
text: ":"
}
QQC2.Tumbler {
id: hourTumbler
height: parent.height
anchors.verticalCenter: parent.verticalCenter
anchors.right: timespacer.left
visibleItemCount: 1
model: 12
delegate: Text {
required property int modelData
text: (modelData < 10 ? "0" : "") + modelData
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
rightPadding: 5
font: UIStyle.tumblerFont
color: UIStyle.textColor
}
}
}
}
}
}
|