This repository has been archived by the owner on Nov 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAlarmDelegate.qml
70 lines (61 loc) · 1.64 KB
/
AlarmDelegate.qml
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
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls.Material as Controls
import HeAlarm
import "HeAlarmJs.js" as HeAlarmJs
Item {
property int hour: 10
property int minute: 10
property bool isActive
property string title: "闹铃"
property int activeDays: HeAlarm.All
signal clicked()
signal cancled()
id: root
implicitWidth: card.implicitWidth; implicitHeight: card.implicitHeight
onIsActiveChanged: activeSwitch.checked = isActive
MouseArea {
anchors.fill: parent
onClicked: root.cancled
Card {
id: card
implicitWidth: layout.implicitWidth; implicitHeight: layout.implicitHeight
anchors.centerIn: parent
MouseArea {
anchors.fill: parent
onClicked: root.clicked()
}
GridLayout {
id: layout
anchors.fill: parent
GridLayout {
Layout.margins: 12
rows: 2; columns: 3
columnSpacing: 16
Text {Layout.rowSpan: 2; text: HeAlarmJs.timeTxt(hour) + ":" + HeAlarmJs.timeTxt(minute); font.bold: true; font.pointSize: 18}
Text {Layout.row: 0; Layout.column: 1; Layout.alignment: Qt.AlignCenter; text: title}
RowLayout {
Layout.row: 1; Layout.column: 1
Layout.alignment: Qt.AlignCenter
Repeater {
model: 7
delegate: WeekIndicator {
text: HeAlarmJs.dayNames[model.index]
activeColor: "lightgreen"
isActive: activeDays & HeAlarmJs.setBit(0, model.index, 1)
}
}
}
Controls.Switch {
Layout.row: 0; Layout.column: 2
Layout.rowSpan: 2
Controls.Material.accent: "lightgreen"
id: activeSwitch
checked: isActive
onCheckedChanged: root.isActive = checked
}
}
}
}
}
}