QtMvvm  1.1.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.1
8 import de.skycoder42.QtMvvm.Quick 1.1
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 
99  ColorHelper {
100  id: helper
101  }
102 
103  ColumnLayout {
104  id: _layout
105  anchors.fill: parent
106  spacing: 16
107 
108  Switch {
109  id: _syncSwitch
110  text: qsTr("Synchronization enabled")
111  Layout.fillWidth: true
112 
113  MvvmBinding {
114  viewModel: _dataSyncView.viewModel.syncManager
115  viewModelProperty: "syncEnabled"
116  view: _syncSwitch
117  viewProperty: "checked"
118  }
119  }
120 
121  Label {
122  id: _statusLabel
123  Layout.fillWidth: true
124  text: viewModel.statusString
125  font.bold: true
126  font.pointSize: 16
127  horizontalAlignment: Text.AlignHCenter
128  verticalAlignment: Text.AlignVCenter
129  }
130 
131  ProgressBar {
132  id: _syncProgress
133  Layout.fillWidth: true
134  from: 0
135  to: 1
136  value: viewModel.syncManager.syncProgress
137  visible: !_errorLabel.visible
138  }
139 
140  Label {
141  id: _errorLabel
142  Layout.fillWidth: true
143  wrapMode: Text.WordWrap
144  text: viewModel.syncManager.lastError
145  visible: text != ""
146  color: "#aa0000"
147  font.bold: true
148  }
149 
150  Rectangle {
151  Layout.fillWidth: true
152  Layout.minimumHeight: 1
153  Layout.maximumHeight: 1
154  color: helper.text
155  }
156 
157  Label {
158  Layout.fillWidth: true
159  text: qsTr("Other Devices:")
160  }
161 
162  ScrollView {
163  id: _devicesScrollView
164 
165  Layout.fillWidth: true
166  Layout.fillHeight: true
167  clip: true
168 
169  ListView {
170  id: _devicesList
171 
172  model: viewModel.sortedModel
173  delegate: SwipeDelegate {
174  id: _swipeDelegate
175  width: _devicesScrollView.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: _devicesScrollView.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  }
253 
255  id: _addButton
256 
257  anchors.right: parent.right
258  anchors.bottom: parent.bottom
259  anchors.margins: 16
260 
261  text: qsTr("Add new devices")
262  icon.name: checked ? "tab-close" : "list-add"
263  icon.source: checked ?
264  "qrc:/de/skycoder42/qtmvvm/quick/icons/ic_close.svg" :
265  "qrc:/de/skycoder42/qtmvvm/quick/icons/ic_add.svg"
266  stickyToolTips: true
267 
268  Action {
269  text: qsTr("Network Exchange")
270  icon.name: "network-connect"
271  icon.source: "qrc:/de/skycoder42/qtmvvm/quick/icons/ic_exchange.svg"
272 
273  onTriggered: viewModel.startNetworkExchange()
274  }
275 
276  Action {
277  text: qsTr("Export to file")
278  icon.name: "document-export"
279  icon.source: "qrc:/de/skycoder42/qtmvvm/quick/icons/ic_export.svg"
280 
281  onTriggered: viewModel.startExport()
282  }
283 
284  Action {
285  text: qsTr("Import from file")
286  icon.name: "document-import"
287  icon.source: "qrc:/de/skycoder42/qtmvvm/quick/icons/ic_import.svg"
288 
289  onTriggered: viewModel.startImport()
290  }
291  }
292 }
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 RoundActionButton to provide a roudn button with sub-elements.
The QML import for the QtMvvmCore QML module.
Definition: qqmlcoreapp.h:9
QString currentStyle
The name of the currently active Quick Controls 2 Style.
A helper class to get style-dependant colors.
Definition: ColorHelper.qml:17
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.