Repository navigation
Expand file tree
/
Copy pathtimeSelectDialog.qml
More file actions
93 lines (83 loc) · 2.73 KB
/
Copy pathtimeSelectDialog.qml
File metadata and controls
93 lines (83 loc) · 2.73 KB
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
import QtQuick
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
Window {
id:timeSelectDialog
title: "Choose a new time"
flags: Qt.Dialog
modality: Qt.ApplicationModal
width: 200;
height: 100;
minimumWidth: width; maximumWidth: width; minimumHeight: height; maximumHeight: height;
signal chosen(int choiceTime)
onVisibleChanged: {
if (visible) {
inputHours.value = 0; inputMins.value=0; inputSecs.value=0;
inputMins.forceActiveFocus(); // Set focus to the TextField when the window is shown
}
}
Rectangle{
anchors.fill: parent;
MouseArea {
anchors.fill: parent
onClicked: forceActiveFocus()
KeyNavigation.tab: inputMins
} // Click anywhere in window to unfocus currently focused item
Keys.onEscapePressed: btnReject.clicked();
Keys.onReturnPressed: btnAccept.clicked();
Keys.onEnterPressed: btnAccept.clicked();
ColumnLayout{
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
Row{
spacing: 2;
SpinBox {
id: inputHours
from: 0; to: 99;
editable: true;
width: 60
}
Text{text:":"}
SpinBox {
id: inputMins
from: 0; to: 60;
editable: true;
focus: true;
width: 60;
}
Text{text:":"}
SpinBox {
id: inputSecs
from: 0; to: 60;
editable: true;
width: 60
}
}
Row{
Layout.alignment: Qt.AlignRight;
Button{
focusPolicy: Qt.NoFocus
id: btnReject
text: "Cancel"
onClicked: {
console.log("Cancel clicked")
timeSelectDialog.hide();
}
}
Button{
focusPolicy: Qt.NoFocus
id: btnAccept
text: "Ok"
onClicked: {
forceActiveFocus()
timeSelectDialog.chosen(inputHours.value*3600+inputMins.value*60+inputSecs.value)
console.log("Ok clicked")
console.log(inputHours.value*3600+inputMins.value*60+inputSecs.value)
timeSelectDialog.hide();
}
}
}
}
}
}