-
Notifications
You must be signed in to change notification settings - Fork 0
/
SettingsPage.qml
executable file
·166 lines (140 loc) · 4.26 KB
/
SettingsPage.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
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
import QtQuick
import QtQuick.Controls
import com.chattymango.settings_connector 1.0
Page {
height: window.height
width: window.width
title: qsTr("Settings")
Column {
id: column
anchors.fill: parent
anchors.rightMargin: parent.width * 0.1
anchors.leftMargin: parent.width * 0.1
anchors.bottomMargin: parent.height * 0.1
anchors.topMargin: parent.height * 0.1
spacing: 10
Row {
height: 60
width: parent.width
Label {
text: qsTr("Seconds before new exercise")
wrapMode: Text.WordWrap
anchors.verticalCenter: parent.verticalCenter
verticalAlignment: Text.AlignVCenter
font.bold: true
font.pointSize: 16
height: 60
width: parent.width * 0.8
}
SpinBox {
id: countdownSpinBox
height: 50
width: parent.width * 0.2
anchors.verticalCenter: parent.verticalCenter
to: 100
editable: true
from: 1
}
}
Row {
height: 60
width: parent.width
Label {
text: qsTr("Minutes of inactivity to mark a new session in the reports")
wrapMode: Text.WordWrap
anchors.verticalCenter: parent.verticalCenter
verticalAlignment: Text.AlignVCenter
font.pointSize: 16
font.bold: true
height: 60
width: parent.width * 0.8
}
SpinBox {
id: newSessionGapSpinBox
height: 50
width: parent.width * 0.2
anchors.verticalCenter: parent.verticalCenter
to: 100
editable: true
from: 10
value: 10
}
}
Row {
height: 60
width: parent.width
Item {
height: 50
width: parent.width * 0.8
}
Button {
height: 50
width: parent.width * 0.2
text: qsTr("Save")
checkable: false
flat: true
icon.source: "qrc:/icons/save.svg"
display: AbstractButton.TextBesideIcon
onClicked: {
const data = [
{name:"countdown", value:countdownSpinBox.value},
{name:"new_session_gap", value:newSessionGapSpinBox.value}
];
settings_connector.saveData(JSON.stringify(data));
}
}
}
}
Component.onCompleted: {
settings_connector.getData();
}
SettingsConnector {
id: settings_connector
onDataSent:
data => {
const dataObj = JSON.parse(data);
for (var key in dataObj) {
switch (dataObj[key].name) {
case "countdown":
countdownSpinBox.value = parseInt(dataObj[key].value);
break;
case "new_session_gap":
newSessionGapSpinBox.value = parseInt(dataObj[key].value);
break;
}
}
}
onDataSaved: {
savedPopup.open();
popupTimer.start();
}
}
Popup {
id: savedPopup
x: 100
y: 100
width: parent.width - 200
height: parent.height - 200
anchors.centerIn: parent
modal: true
focus: true
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
Column {
spacing: 10
anchors.centerIn: parent
Label {
text: qsTr("The data was saved.")
font.pixelSize: 36
font.bold: true
}
}
}
Timer {
id: popupTimer
interval: 2000
running: false
repeat: false
onTriggered: savedPopup.close()
triggeredOnStart: false
}
}