-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSettingsPinePhone.qml
348 lines (276 loc) · 10.6 KB
/
SettingsPinePhone.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
import QtQuick 2.15
//import QtQuick.Window 2.15
import QtQuick.Layouts 1.15
import Qt.labs.platform 1.1
import QtQuick.Dialogs 1.3
import QtQuick.Controls 2.15
//import QtQml.Models 2.15
import QtQuick.Controls.Material 2.15
import QtQuick.Controls.Universal 2.15
import MainWindow 1.0
Page {
id: pageSettings
title: qsTr("Settings")
CMainWindow {
id: mainWindowModel;
}
// Setting UI Control
// Display vertical scroll bar to ListView
ScrollView {
id: sViewSettings
width: parent.width
height : parent.height
contentWidth: settingsItem.width // The important part
contentHeight: settingsItem.height // Same
anchors.fill: parent
clip : true // Prevent drawing column outside the scrollview borders
ColumnLayout {
id: settingsItem
x: parent.x
width: parent.width
spacing: 0
Label {
id: labelEditor
width: parent.width
text: qsTr("Please Input Editor Path.") + qsTr("\n") + qsTr("(Ex. /usr/bin/kate)")
Layout.topMargin: 20
Layout.margins: 20
wrapMode: Label.WordWrap
}
RowLayout {
id: editEditorLayout
width: parent.width
spacing: 20
Layout.topMargin: 5
Layout.margins: 20
TextField {
id: editEditor
text: mainWindowModel.getEditor()
width: pageSettings.width - btnEditorSelect.width - parent.spacing * 2 - Layout.margins * 2
implicitWidth: pageSettings.width - btnEditorSelect.width - parent.spacing * 2 - Layout.margins * 2
placeholderText: qsTr("/usr/bin/kate")
selectedTextColor: mainWindowModel.getColorMode() ? "white" : "black"
cursorVisible: true
horizontalAlignment: TextField.AlignLeft
onTextChanged: {
let iRet = mainWindowModel.saveEditor(editEditor.text);
if(iRet === -1)
{
errorDialog.messageTitle = qsTr("Error : Don't save editor path");
errorDialog.messageText = qsTr("Error : The editor path you inputed could not be saved.") + qsTr("\n") + qsTr("For details, please contact the developer.");
errorDialog.open();
return;
}
}
}
RoundButton {
id: btnEditorSelect
text: "..."
Layout.rightMargin: 20
focus: true
onClicked: {
fileSelectDialog.title = qsTr("Please input a Editor.");
fileSelectDialog.strEditType = qsTr("editor");
fileSelectDialog.open();
}
}
}
Label {
id: labelEditorOption
text: qsTr("Editor Option:")
width: parent.width
Layout.topMargin: 20
Layout.margins: 20
wrapMode: Label.WordWrap
}
TextField {
id: editEditorOption
text: mainWindowModel.getEditorOption()
width: pageSettings.width - parent.spacing * 2 - Layout.margins * 2
implicitWidth: pageSettings.width - parent.spacing * 2 - Layout.margins * 2
Layout.topMargin: 5
Layout.margins: 20
placeholderText: qsTr("Ex. Kate : -b option ")
selectedTextColor: mainWindowModel.getColorMode() ? "white" : "black"
cursorVisible: true
horizontalAlignment: TextField.AlignLeft
}
Label {
id: labelDiff
text: qsTr("Please Input Diff Tool Path.") + qsTr("\n") + qsTr("(Ex. /usr/bin/meld)")
width: parent.width
Layout.topMargin: 20
Layout.margins: 20
wrapMode: Label.WordWrap
}
RowLayout {
id: editDiffLayout
width: parent.width
spacing: 20
Layout.topMargin: 5
Layout.margins: 20
TextField {
id: editDiff
text: mainWindowModel.getDiffTool()
width: pageSettings.width - btnDiffSelect.width - parent.spacing * 2 - Layout.margins * 2
implicitWidth: pageSettings.width - btnDiffSelect.width - parent.spacing * 2 - Layout.margins * 2
placeholderText: qsTr("/usr/bin/meld")
selectedTextColor: mainWindowModel.getColorMode() ? "white" : "black"
cursorVisible: true
horizontalAlignment: TextField.AlignLeft
}
RoundButton {
id: btnDiffSelect
text: "..."
Layout.rightMargin: 20
onClicked: {
fileSelectDialog.title = qsTr("Please input a Diff Tool.");
fileSelectDialog.strEditType = qsTr("diff");
fileSelectDialog.open();
}
}
}
Button {
id: saveBtn
text: qsTr("Save")
Layout.topMargin: 50
Layout.alignment: Qt.AlignHCenter
onPressed: {
// Save editor path
var iRet = mainWindowModel.saveEditorOption(editEditorOption.text);
if(iRet === -1)
{
errorDialog.messageTitle = qsTr("Error : Don't save editor option");
errorDialog.messageText = qsTr("Error : The editor option you inputed could not be saved.") + qsTr("\n") + qsTr("For details, please contact the developer.");
errorDialog.open();
return;
}
// Save diff tool path
iRet = mainWindowModel.saveDiffTool(editDiff.text);
if(iRet === -1)
{
errorDialog.messageTitle = qsTr("Error : Don't save diff tool path");
errorDialog.messageText = qsTr("Error : The diff tool path you inputed could not be saved.") + qsTr("\n") + qsTr("For details, please contact the developer.");
errorDialog.open();
return;
}
// Display a popup when saving is complete
completePopup.messageText = qsTr("\n") + qsTr("The settings have been saved.") + qsTr("\n");
completePopup.open();
}
}
}
}
FileDialog {
id: fileSelectDialog
title: "Please select a File"
visible: false
folder: StandardPaths.standardLocations(StandardPaths.HomeLocation)[0]
modality: Qt.WindowModal
property string strEditType: ""
onAccepted: {
var strDirPath = fileSelectDialog.fileUrl.toString().replace("file://", "");
if (strEditType === qsTr("editor"))
{
editEditor.text = strDirPath;
}
else if (strEditType === qsTr("diff"))
{
editDiff.text = strDirPath;
}
fileSelectDialog.close();
}
onRejected: {
fileSelectDialog.close();
}
}
Popup {
id: completePopup
x: Math.round((pageSettings.width - width) / 2)
y: Math.round(pageSettings.height / 6)
width: Math.round(Math.min(pageSettings.width, pageSettings.height) / 10 * 9)
modal: true
focus: true
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
property string messageText: ""
ColumnLayout {
id: completeColumn
x: parent.x
width: parent.width
spacing: 20
Layout.margins: 50
Label {
text: completePopup.messageText
horizontalAlignment: Label.AlignHCenter
verticalAlignment: Label.AlignVCenter
Layout.fillWidth: true
Layout.fillHeight: true
wrapMode: Label.WordWrap
}
}
onOpened: {
completeTimer.start();
}
Timer {
id: completeTimer
interval: 2000
repeat: false
running: false
onTriggered: {
completeTimer.stop();
completePopup.close();
}
}
}
Dialog {
id: errorDialog
title: errorDialog.messageTitle
x: Math.round((mainWindow.width - width) / 2)
y: Math.round(mainWindow.height / 6)
width: Math.round(Math.min(mainWindow.width, mainWindow.height) / 10 * 9)
modal: true
focus: true
closePolicy: Dialog.CloseOnEscape
property string messageTitle: ""
property string messageText: ""
ColumnLayout {
id: errorColumn
x: parent.x
width: parent.width
spacing: 20
RowLayout {
id: errorRow
x: errorDialog.x
width: errorDialog.width
spacing: 20
Layout.alignment: Qt.AlignVCenter
Layout.bottomMargin: 20
Image {
id: errorIcon
source: "Image/Critical.png"
fillMode: Image.Stretch
Layout.alignment: Qt.AlignVCenter
}
Label {
text: errorDialog.messageText
verticalAlignment: Label.AlignVCenter
Layout.fillWidth: true
Layout.fillHeight: true
wrapMode: Label.WordWrap
}
}
Button {
id: errorBtnOK
text: "OK"
Layout.alignment: Qt.AlignHCenter
Layout.bottomMargin: 20
Connections {
target: errorBtnOK
function onClicked() {
errorDialog.close();
}
}
}
}
}
}