Debian Codegraph @

qml/generic/Backup.qml

raw
1 import QtQuick 2.2
2 import QtQuick.Controls 1.1
3 import QtQuick.Dialogs 1.1
4 import QtQuick.Layouts 1.1
5 import QtQuick.Window 2.1
6 import Qt.labs.settings 1.0
7 import BackupTools 1.0
8 import "UI" 1.0
9
10
11 Item {
12 id: main
13 visible: i.device !== null && i.completed && !i.loginBlock && !i.wrongPass
14 anchors { fill: parent; leftMargin: 20; topMargin: 20 }
15
16 MessageDialog {
17 id: timeoutWarning
18 title: qsTr("Timed out")
19 informativeText: qsTr("The request timed out. Please backup blind. This is a bug that Blackberry needs to fix.")
20 standardButtons: StandardButton.Ok
21 }
22 Timer {
23 id: attemptLookup
24 running: false
25 interval: 40000
26 onTriggered: timeoutWarning.open()
27 }
28
29 ColumnLayout {
30 ColumnLayout {
31 Text {
32 text: qsTr("Options") + translator.lang
33 font.pointSize: 14
34 font.bold: true
35 }
36 id: options
37 property int value: 0
38 RowLayout {
39 visible: attemptLookup.running
40 Text {
41 text: qsTr("Refreshing backup sizes") + translator.lang
42 font.pointSize: 12
43 }
44 BusyIndicator {
45 width: parent.height
46 height: parent.height
47 }
48 }
49 ColumnLayout {
50 Repeater {
51 onCountChanged: options.value = 0
52 model: i.backMethods
53 delegate: CheckBox {
54 property double curSize: i.backSizes[index]
55 text: (i.backNames[index] + " (" + (i.backSizes[index] < 0 ? qsTr("Unknown Size") : qsTr("%1 MB").arg( ((index == 0 ? appData.selectedSize : i.backSizes[index]) / 1024 / 1024).toFixed(1))) + ")") + translator.lang // index
56 onCurSizeChanged: if (index == 0) appData.selectedSize = curSize
57 onTextChanged: if (attemptLookup.running) attemptLookup.stop()
58 onCheckedChanged: {
59 if (checked) {
60 options.value += 1 << index;
61 totalText.totalVal += i.backSizes[index];
62 } else {
63 options.value -= 1 << index;
64 totalText.totalVal -= i.backSizes[index]
65 }
66 }
67 Button {
68 anchors.left: parent.right
69 visible: index == 0 && i.backSizes[0] > 0 && !appDataSelect.visible
70 text: qsTr("Choose") + translator.lang
71 onClicked: appDataSelect.show()
72 }
73 }
74 }
75 }
76 Window {
77 id: appDataSelect
78 width: 600
79 height: 600
80 title: qsTr("Choose Application Data") + translator.lang
81 onVisibleChanged: if (visible) {
82 x = window.x + (window.width - width) / 2
83 y = window.y + (window.height - height) / 2
84 }
85 ColumnLayout {
86 anchors.fill: parent
87 Text {
88 text: qsTr("Total Application Data: %1 MB (%2 Apps)").arg(i.backMethods > 0 ? (i.backSizes[0] / 1024 / 1024).toFixed(1) : "0").arg(backAppView.count) + translator.lang
89 Layout.fillWidth: true
90 wrapMode: Text.Wrap
91 }
92 Text {
93 id: appData
94 Layout.fillWidth: true
95 property double selectedSize: -1.0
96 text: qsTr("Selected Application Data: %1 MB").arg((selectedSize / 1024 / 1024).toFixed(1)) + translator.lang
97 wrapMode: Text.Wrap
98 }
99
100 Component {
101 id: sectionHeading
102
103 RowLayout{
104 CheckBox {
105 checked: true
106 onClicked: appData.selectedSize += i.changeBackAppMode(section)
107 }
108 Rectangle {
109 //width: container.width
110 height: childrenRect.height
111 color: "lightsteelblue"
112
113 Text {
114 text: section
115 font.bold: true
116 font.pixelSize: 20
117 }
118 }
119 }
120 }
121 ScrollView {
122 Layout.fillWidth: true
123 Layout.fillHeight: true
124 ListView {
125 anchors.fill: parent
126 id: backAppView
127 model: i.backAppList
128 section.property: "type"
129 section.criteria: ViewSection.FullString
130 section.delegate: sectionHeading
131 Menu {
132 id: back_options_menu
133 signal checkAll()
134 signal uncheckAll()
135 title: qsTr("Options") + translator.lang
136 MenuItem {
137 text: qsTr("Check All Visible") + translator.lang
138 onTriggered: {
139 back_options_menu.checkAll();
140 }
141 }
142 MenuItem {
143 text: qsTr("Uncheck All Visible") + translator.lang
144 onTriggered: {
145 back_options_menu.uncheckAll()
146 }
147 }
148 }
149
150 MouseArea {
151 acceptedButtons: Qt.RightButton
152 onClicked: back_options_menu.popup()
153 anchors.fill: parent
154 }
155 delegate: Item {
156 visible: type !== "";
157 width: parent.width - 3
158 height: type === "" ? 0 : 26
159 Rectangle {
160 anchors.fill: parent
161 color: { switch(type) {
162 case "bin": return "red";
163 case "data": return "purple";
164 case "system": return "steelblue";
165 default: return "transparent";
166 }
167 }
168 opacity: 0.2
169 }
170 CheckBox {
171 id: backDelegateBox
172 text: friendlyName + " (" + type + ") " + version
173 width: Math.min(implicitWidth, parent.width - sizeText.width)
174 clip: true
175 checked: isMarked
176 // Per-app backup wasn't working when > 1 app selected
177 enabled: false
178
179 onCheckedChanged: isMarked = checked
180 onClicked: {
181 if (checked)
182 appData.selectedSize += size;
183 else
184 appData.selectedSize -= size;
185 }
186 Connections {
187 target: back_options_menu
188 onCheckAll: {
189 if (!backDelegateBox.checked) {
190 backDelegateBox.checked = true;
191 appData.selectedSize += size;
192 }
193 }
194 onUncheckAll: {
195 if (backDelegateBox.checked) {
196 backDelegateBox.checked = false;
197 appData.selectedSize -= size;
198 }
199 }
200 }
201 }
202 Label {
203 id: sizeText
204 anchors.right: parent.right
205 text: qsTr("%1 MB").arg((size / 1024 / 1024).toFixed(1)) + translator.lang
206 font.pointSize: 12;
207 }
208 }
209 }
210 }
211 }
212 }
213
214 Text {
215 visible: i.backMethods
216 id: totalText
217 property double totalVal: 0.0
218 text: (qsTr("Total:") + " " + (totalVal < 0 ? qsTr("Unknown Size") : qsTr("%1 MB").arg((totalVal / 1024 / 1024).toFixed(1)))) + translator.lang
219 font.pointSize: 12
220 }
221 }
222
223 Button {
224 visible: /*!i.backMethods &&*/ !attemptLookup.running
225 enabled: !i.installing && !i.backing && !i.restoring && i.device !== null && i.device.bbid !== ""
226 text: qsTr("Refresh Backup Sizes") + translator.lang
227 onClicked: { appDataSelect.hide(); totalText.totalVal = 0; i.backupQuery(); attemptLookup.start(); }
228 }
229
230 Label {
231 visible: !settings.advanced
232 text: qsTr("Loading backup sizes can sometimes fail. In this situation, you can backup 'blind'.") + translator.lang
233 }
234 RowLayout {
235 visible: i.backMethods
236 FileDialog {
237 id: backup_files
238 title: qsTr("Choose Backup Filename") + translator.lang
239 folder: settings.backupFolder
240 onAccepted: {
241 i.backup(fileUrl, options.value)
242 settings.backupFolder = folder;
243 }
244 selectExisting: false
245
246 nameFilters: [ qsTr("Blackberry Backup (*.bbb)") + translator.lang ]
247 }
248 FileDialog {
249 id: restore_files
250 title: qsTr("Select Restore File") + translator.lang
251 folder: settings.backupFolder
252 onAccepted: {
253 i.restore(fileUrl, options.value)
254 settings.backupFolder = folder;
255 }
256
257 nameFilters: [ qsTr("Blackberry Backup (*.bbb)") + translator.lang ]
258 }
259
260 Button {
261 text: (totalText.totalVal < 0 ? qsTr("Create Backup Blind") : qsTr("Create Backup")) + translator.lang
262 enabled: !i.installing && !i.backing && !i.restoring && options.value != 0 && i.device !== null && i.device.bbid !== ""
263 onClicked: backup_files.open();
264 }
265 Button {
266 text: qsTr("Restore Backup") + translator.lang
267 enabled: !i.installing && !i.backing && !i.restoring && options.value != 0 && i.device !== null && i.device.bbid !== ""
268 onClicked: restore_files.open();
269 }
270 }
271 Label {
272 visible: i.device !== null && i.device.bbid === ""
273 text: qsTr("Your device needs a Blackberry ID to perform backups or restores!") + translator.lang
274 }
275 Label {
276 visible: !settings.advanced
277 text: qsTr("Please note that backups can take a long time, depending on your device data.") + translator.lang
278 }
279 }
280 Rectangle {
281 id: progressBar
282 visible: i.backing || i.restoring
283 anchors {bottom: parent.bottom; bottomMargin: 20; horizontalCenter: parent.horizontalCenter }
284 height: 66; width: parent.width - parent.width / 4; radius: 8
285 z: 5;
286 color: "gray"
287 opacity: 0.95
288 Column {
289 anchors {verticalCenter: parent.verticalCenter; left: parent.left; leftMargin: parent.width / 2 - 150 }
290 Text {
291 font.pointSize: 12
292 text: (i.backing ? qsTr("Creating Backup (%1%)").arg(i.backProgress) : qsTr("Restoring Backup (%1%)").arg(i.backProgress)) + translator.lang
293 }
294 Row {
295 spacing: 10
296 Text {
297 font.pointSize: 12
298 text: i.backStatus + " (" + i.backCurProgress + "%)";
299 }
300
301 BusyIndicator {
302 width: parent.height
303 height: parent.height
304 }
305 }
306 Text {
307 font.pointSize: 10
308 visible: i.backProgress == 0
309 text: "The device is currently generating a list of files to backup. Please wait."
310 }
311 }
312 }
313 }