-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTimePicker.qml
100 lines (91 loc) · 2.56 KB
/
TimePicker.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
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
import QtQuick 2.0
import QtQuick.Controls 2.5
Item {
id : root
height: 60
width: 400
property int start_hour: 0
property int start_minute: 0
property string start_am_pm: "PM"
signal start_hourchanged()
signal start_minutechanged()
signal start_am_pm_changed()
Column{
anchors.fill: parent
spacing: 10
Row{
spacing: 5
Text {
font.pixelSize: 14
horizontalAlignment: Text.AlignHCenter
width: hour.width
text: qsTr("Hour")
}
Text {
font.pixelSize: 14
horizontalAlignment: Text.AlignHCenter
width: minute.width
text: qsTr("Minute")
}
Text {
font.pixelSize: 14
horizontalAlignment: Text.AlignHCenter
width: ampm.width
text: qsTr("AM/PM")
}
}
Row{
spacing: 5
anchors.horizontalCenter: parent.horizontalCenter
SpinBox {
id: hour
value: 1
from : 1
to : 12
onValueChanged: {
start_hour = hour.value
start_hourchanged()
}
}
SpinBox {
id: minute
value : 0
from : 0
to : 59
onValueChanged: {
start_minute = minute.value
start_minutechanged()
}
}
ComboBox {
id : ampm
model: [ "AM", "PM" ]
currentIndex: 1
onActivated: {
root.start_am_pm = ampm.currentText
console.log("emitted onactivated",root.start_am_pm);
root.start_am_pm_changed()
}
onCurrentIndexChanged: {
root.start_am_pm = ampm.currentText
console.log("emitted oncurrentIndex ",root.start_am_pm);
root.start_am_pm_changed()
}
}
}
}
function resetPickers(){
hour.value = 1;
minute.value = 0;
ampm.currentIndex = 1;
}
function setPickers(start_h,start_m,am_pm){
hour.value = start_h;
minute.value = start_m;
if(am_pm.toString() === "AM"){
ampm.currentIndex = 0;
}else{
ampm.currentIndex = 1;
}
}
}