QtMvvm  1.0.0
A mvvm oriented library for Qt, to create Projects for Widgets and Quick in parallel
DataSyncView.qml
1 import QtQuick 2.10
2 import QtQuick.Controls 2.3
3 import QtQuick.Controls.Material 2.3
4 import QtQuick.Controls.Universal 2.3
5 import QtQuick.Layouts 1.3
6 import de.skycoder42.QtDataSync 4.0
7 import de.skycoder42.QtMvvm.Core 1.0
8 import de.skycoder42.QtMvvm.Quick 1.0
10 
20 Page {
21  id: _dataSyncView
22 
34  property DataSyncViewModel viewModel: null
35 
36  header: ContrastToolBar {
37  id: _toolBar
38 
39  RowLayout {
40  id: _toolLayout
41  anchors.fill: parent
42  spacing: 0
43 
44  ToolBarLabel {
45  id: _titleLabel
46  Layout.fillWidth: true
47  text: qsTr("Synchronization")
48  }
49 
50  ActionButton {
51  id: _syncButton
52  icon.name: "view-refresh"
53  icon.source: "qrc:/de/skycoder42/qtmvvm/quick/icons/ic_sync.svg"
54  text: qsTr("Synchronize")
55  onClicked: viewModel.syncOrConnect()
56  }
57 
58  ActionButton {
59  id: _idButton
60  icon.name: "fingerprint-gui"
61  icon.source: "qrc:/de/skycoder42/qtmvvm/quick/icons/ic_fingerprint.svg"
62  text: qsTr("Edit Identity")
63  onClicked: viewModel.showDeviceInfo()
64  }
65 
66  MenuButton {
67  id: _moreButton
68 
69  MenuItem {
70  text: qsTr("Update exchange key")
71  onClicked: viewModel.accountManager.updateExchangeKey()
72  }
73 
74  MenuSeparator {}
75 
76  MenuItem {
77  text: qsTr("Reload devices list")
78  onClicked: viewModel.accountManager.listDevices()
79  }
80 
81  MenuSeparator {}
82 
83  MenuItem {
84  text: qsTr("Change remote server")
85  onClicked: viewModel.changeRemote()
86  }
87 
88  MenuItem {
89  text: qsTr("Reset Identity")
90  onClicked: viewModel.performReset()
91  }
92  }
93  }
94  }
95 
96  Pane {
97  anchors.fill: parent
98  ColumnLayout {
99  id: _layout
100  anchors.fill: parent
101  spacing: 16
102 
103  Switch {
104  id: _syncSwitch
105  text: qsTr("Synchronization enabled")
106  Layout.fillWidth: true
107 
108  MvvmBinding {
109  viewModel: _dataSyncView.viewModel.syncManager
110  viewModelProperty: "syncEnabled"
111  view: _syncSwitch
112  viewProperty: "checked"
113  }
114  }
115 
116  Label {
117  id: _statusLabel
118  Layout.fillWidth: true
119  text: viewModel.statusString
120  font.bold: true
121  font.pointSize: 16
122  horizontalAlignment: Text.AlignHCenter
123  verticalAlignment: Text.AlignVCenter
124  }
125 
126  ProgressBar {
127  id: _syncProgress
128  Layout.fillWidth: true
129  from: 0
130  to: 1
131  value: viewModel.syncManager.syncProgress
132  visible: !_errorLabel.visible
133  }
134 
135  Label {
136  id: _errorLabel
137  Layout.fillWidth: true
138  wrapMode: Text.WordWrap
139  text: viewModel.syncManager.lastError
140  visible: text != ""
141  color: "#aa0000"
142  font.bold: true
143  }
144 
145  Rectangle {
146  Layout.fillWidth: true
147  Layout.minimumHeight: 1
148  Layout.maximumHeight: 1
149  color: {
150  if(QuickPresenter.currentStyle === "Material")
151  return Material.foreground;
152  else if(QuickPresenter.currentStyle === "Universal")
153  return Universal.foreground;
154  else
155  return "black";
156  }
157  }
158 
159  Label {
160  Layout.fillWidth: true
161  text: qsTr("Other Devices:")
162  }
163 
164  ListView {
165  id: _devicesList
166  Layout.fillWidth: true
167  Layout.fillHeight: true
168  clip: true
169  model: viewModel.sortedModel
170 
171  ScrollBar.vertical: ScrollBar {}
172 
173  delegate: SwipeDelegate {
174  id: _swipeDelegate
175  width: parent.width
176 
177  contentItem: ColumnLayout {
178  id: _delegateLayout
179  spacing: 8
180 
181  Label {
182  id: _nameLabel
183  Layout.fillWidth: true
184  text: name
185  }
186 
187  Label {
188  id: _fpLabel
189  font.pointSize: _nameLabel.font.pointSize * 0.8
190  Layout.fillWidth: true
191  Layout.leftMargin: 8
192  text: fingerPrint
193  elide: Text.ElideMiddle
194  opacity: 0.75
195  }
196  }
197 
198  ListView.onRemove: SequentialAnimation {
199  PropertyAction {
200  target: _swipeDelegate
201  property: "ListView.delayRemove"
202  value: true
203  }
204  NumberAnimation {
205  target: _swipeDelegate
206  property: "height"
207  to: 0
208  easing.type: Easing.InOutQuad
209  }
210  PropertyAction {
211  target: _swipeDelegate
212  property: "ListView.delayRemove"
213  value: false
214  }
215  }
216 
217  swipe.right: Rectangle {
218  height: parent.height
219  width: height
220  anchors.right: parent.right
221  color: {
222  if(QuickPresenter.currentStyle === "Material")
223  return Material.color(Material.Red);
224  else if(QuickPresenter.currentStyle === "Universal")
225  return Universal.color(Universal.Red);
226  else
227  return "#FF0000";
228  }
229 
230  ActionButton {
231  anchors.centerIn: parent
232  implicitHeight: parent.height
233  implicitWidth: parent.width
234 
235  icon.name: "user-trash"
236  icon.source: "qrc:/de/skycoder42/qtmvvm/quick/icons/ic_delete_forever.svg"
237  text: qsTr("Remove Device")
238 
239  Material.foreground: "white"
240  Universal.foreground: "white"
241 
242  onClicked: {
243  _swipeDelegate.swipe.close();
244  viewModel.removeDevice(index)
245  }
246  }
247  }
248  }
249  }
250  }
251  }
252 
254  id: _addButton
255  z: 7
256  anchors.right: parent.right
257  anchors.bottom: parent.bottom
258  anchors.margins: 16
259  checkable: true
260  text: qsTr("Add new devices")
261  icon.name: checked ? "tab-close" : "list-add"
262  icon.source: checked ?
263  "qrc:/de/skycoder42/qtmvvm/quick/icons/ic_close.svg" :
264  "qrc:/de/skycoder42/qtmvvm/quick/icons/ic_add.svg"
265  }
266 
267  SubButton {
268  id: _exchangeButton
269  z: 3
270  reference: _addButton
271  expanded: _addButton.checked
272 
273  text: qsTr("Network Exchange")
274  icon.name: "network-connect"
275  icon.source: "qrc:/de/skycoder42/qtmvvm/quick/icons/ic_exchange.svg"
276 
277  onClicked: {
278  viewModel.startNetworkExchange();
279  _addButton.checked = false;
280  }
281  }
282 
283  SubButton {
284  id: _exportButton
285  z: 3
286  reference: _exchangeButton
287  expanded: _addButton.checked
288 
289  text: qsTr("Export to file")
290  icon.name: "document-export"
291  icon.source: "qrc:/de/skycoder42/qtmvvm/quick/icons/ic_export.svg"
292 
293  onClicked: {
294  viewModel.startExport();
295  _addButton.checked = false;
296  }
297  }
298 
299  SubButton {
300  id: _importButton
301  z: 3
302  reference: _exportButton
303  expanded: _addButton.checked
304 
305  text: qsTr("Import from file")
306  icon.name: "document-import"
307  icon.source: "qrc:/de/skycoder42/qtmvvm/quick/icons/ic_import.svg"
308 
309  onClicked: {
310  viewModel.startImport();
311  _addButton.checked = false;
312  }
313  }
314 }
A QML class to create a local mvvm multiway binding.
The QML import for the QtMvvmDataSyncCore QML module.
An extension of the ToolBar for better appearance.
An extension of the RoundButton for better appearance.
The QML import for the QtMvvmCore QML module.
QString currentStyle
The name of the currently active Quick Controls 2 Style.
An extension of the Label for better appearance when used in a toolbar.
The QML import for the QtMvvmQuick QML module.
Definition: ActionButton.qml:4
QObject viewModel
The object in the role of a viewmodel.
An extension of the ActionButton to provide a simple "more menu" button.
Definition: MenuButton.qml:29
An extension of the ToolButton for better appearance.
A QML singleton to access common presenter methods globally.