-
Notifications
You must be signed in to change notification settings - Fork 0
/
SyncPage.qml
executable file
·198 lines (166 loc) · 6.89 KB
/
SyncPage.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
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
Component {
id: syncPage
Item {
id: syncPageRectangle
//color: "transparent"
//visible: false
ScrollView {
id: syncPageScrollView
anchors {
right: parent.right
top: parent.top
left: parent.left
bottom: syncPageBottomColumnLayout.top
}
BusyIndicator {
id: syncPageBusyIndicator
anchors.centerIn: parent
visible: false
running: true
}
ColumnLayout {
spacing: 2
anchors.fill: parent
anchors.margins: 10
Label {
text: "Synchronization method"
}
ComboBox {
id: syncPageSyncMethodComboBox
Layout.fillWidth: true
Layout.alignment: Qt.AlignJustify
model: [
"Download and replace",
"Download and merge",
"Download and add new",
"Upload and replace",
"Upload and merge",
"Upload and add new"
]
delegate: ItemDelegate {
id: control
width: parent.width
contentItem: Text {
text: modelData
color: "#000000"
font: control.font
elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter
}
background: Rectangle {
anchors.fill: control
color: control.highlighted ? "skyblue" : "transparent"
}
highlighted: syncPageSyncMethodComboBox.highlightedIndex === index
}
currentIndex: stackView.syncPageSyncMethod
onCurrentIndexChanged: {
oSettingsModel.fnUpdateStringValue("syncPageSyncMethod", syncPageSyncMethodComboBox.currentIndex);
oSettingsModel.fnSave();
}
}
Label {
id: syncPageStatusLabel
padding: 10
text: passwordSyncClient.sStatus
wrapMode: Text.WordWrap
}
Label {
id: syncPageErrorLabel
padding: 10
text: ''
}
Item { Layout.fillHeight: true }
}
}
ColumnLayout {
id: syncPageBottomColumnLayout
anchors {
right: parent.right
bottom: parent.bottom
left: parent.left
}
RowLayout {
Button {
id: syncPageServersListButton
Layout.fillWidth: true
text: "Synchronization servers list"
onClicked: {
stackView.push(serversListViewPage);
}
}
}
RowLayout {
Button {
id: syncPageBackButton
Layout.fillWidth: true
text: "Back"
onClicked: {
stackView.pop();
}
}
Button {
id: syncPageSyncButton
property int iServerIndex: 0
property int iServersCount;
Layout.fillWidth: true
text: "Sync"
onClicked: {
syncPageBackButton.enabled = false;
syncPageSyncButton.enabled = false;
syncPageServersListButton.enabled = false;
syncPageSyncMethodComboBox.enabled = false
syncPageBusyIndicator.visible = true;
syncPageErrorLabel.text = '';
iServerIndex = 0;
iServersCount = oServersListModel.fnSize();
fnSyncNext();
}
function fnSyncNext()
{
if (oServersListModel.fnGetBoolValue(iServerIndex, "isEnabled")) {
passwordSyncClient.sCommand = "SYNC_"+oSettingsModel.fnGetStringValue("syncPageSyncMethod");
passwordSyncClient.fnCallBack = this.settingsPageSyncButtonCallBack;
passwordSyncClient.fnErrorCallBack = this.settingsPageSyncButtonErrorCallBack;
passwordSyncClient.sHost = oServersListModel.fnGetStringValue(iServerIndex, "host", "127.0.0.1");
passwordSyncClient.sPort = oServersListModel.fnGetStringValue(iServerIndex, "port", "3002");
passwordSyncClient.url = "ws://"+
oServersListModel.fnGetStringValue(iServerIndex, "host", "127.0.0.1")+
":"+
oServersListModel.fnGetStringValue(iServerIndex, "port", "3002");
iServerIndex++;
passwordSyncClient.active = true;
} else {
iServerIndex++;
settingsPageSyncButtonCallBack();
}
}
function settingsPageSyncButtonErrorCallBack(sErrorString)
{
console.log('Error', iServerIndex, iServersCount);
//iServerIndex = iServersCount;
syncPageErrorLabel.text += sErrorString + '<br>';
settingsPageSyncButtonCallBack();
}
function settingsPageSyncButtonCallBack()
{
passwordSyncClient.active = false;
console.log(iServerIndex, iServersCount);
if (iServerIndex >= iServersCount) {
syncPageBusyIndicator.visible = false;
syncPageBackButton.enabled = true;
syncPageSyncButton.enabled = true;
syncPageServersListButton.enabled = true;
syncPageSyncMethodComboBox.enabled = true;
} else {
fnSyncNext();
}
}
}
}
}
}
}