~cimi/ubuntu-system-settings/wizard.privacy

« back to all changes in this revision

Viewing changes to plugins/system-update/PageComponent.qml

  • Committer: Andrea Cimitan
  • Date: 2014-04-11 12:07:23 UTC
  • mfrom: (662.2.47 wizard.wifi)
  • Revision ID: andrea.cimitan@gmail.com-20140411120723-hzbv5ekjurprc6uw
* Bump version for new package ubuntu-system-settings-wizard
[ Andrea Cimitan ]
* Detect SIM and if negative show no sim page
[ Victor R. Ruiz ]
* Autopilot: Move launch_system_settings to a helper module.
[ Iain Lane ]
* Hide 'Serial' and 'IMEI' entries when the info isn't available
* Don't look for PkgConfig explicitly, breaks with Multi-Arch.
  FindPkgConfig.cmake does this for us anyway.
[ CI bot ]
* Resync trunk
[ Diego Sarmentero ]
* Add click updates support. .

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
    title: i18n.tr("Updates")
36
36
 
37
37
    property bool installAll: false
 
38
    property int updatesAvailable: 0
38
39
 
39
40
    DeviceInfo {
40
41
        id: deviceInfo
78
79
            PropertyChanges { target: notification; visible: false}
79
80
            PropertyChanges { target: installAllButton; visible: false}
80
81
            PropertyChanges { target: checkForUpdatesArea; visible: true}
81
 
            PropertyChanges { target: notification; visible: false}
82
 
            PropertyChanges { target: updatedNotification; visible: false}
 
82
            PropertyChanges { target: updateNotification; visible: false}
83
83
        },
84
84
        State {
85
85
            name: "NOUPDATES"
86
 
            PropertyChanges { target: updatedNotification; text: i18n.tr("Software is up to date")}
87
 
            PropertyChanges { target: updatedNotification; visible: true}
 
86
            PropertyChanges { target: updateNotification; text: i18n.tr("Software is up to date")}
 
87
            PropertyChanges { target: updateNotification; visible: true}
88
88
            PropertyChanges { target: updateList; visible: false}
89
89
            PropertyChanges { target: installAllButton; visible: false}
90
 
            PropertyChanges { target: checkForUpdatesArea; visible: false}
91
90
        },
92
91
        State {
93
92
            name: "SYSTEMUPDATEFAILED"
98
97
            PropertyChanges { target: installingImageUpdate; visible: false}
99
98
            PropertyChanges { target: installAllButton; visible: false}
100
99
            PropertyChanges { target: checkForUpdatesArea; visible: false}
101
 
            PropertyChanges { target: updatedNotification; visible: false}
 
100
            PropertyChanges { target: updateNotification; visible: false}
102
101
        },
103
102
        State {
104
103
            name: "UPDATE"
105
104
            PropertyChanges { target: notification; visible: false}
106
105
            PropertyChanges { target: updateList; visible: true}
107
106
            PropertyChanges { target: installAllButton; visible: true}
108
 
            PropertyChanges { target: checkForUpdatesArea; visible: false}
109
 
            PropertyChanges { target: updatedNotification; visible: false}
 
107
            PropertyChanges { target: updateNotification; visible: false}
 
108
        },
 
109
        State {
 
110
            name: "NOCREDENTIALS"
 
111
            PropertyChanges { target: notification; text: i18n.tr("Please log into your Ubuntu One account.")}
 
112
            PropertyChanges { target: notification; onClicked: root.open_online_accounts() }
 
113
            PropertyChanges { target: notification; progression: true}
 
114
            PropertyChanges { target: notification; visible: true}
 
115
            PropertyChanges { target: updateNotification; text: i18n.tr("Credentials not found")}
 
116
            PropertyChanges { target: updateNotification; visible: true}
 
117
            PropertyChanges { target: installAllButton; visible: false}
110
118
        }
111
119
    ]
112
120
 
 
121
    function open_online_accounts() {
 
122
        Qt.openUrlExternally("settings:///system/online-accounts");
 
123
    }
 
124
 
113
125
    UpdateManager {
114
126
        id: updateManager
115
127
        objectName: "updateManager"
121
133
 
122
134
        onUpdateAvailableFound: {
123
135
            if (updateManager.model.length > 0) {
 
136
                root.updatesAvailable = updateManager.model.length;
124
137
                root.state = "UPDATE";
125
138
                root.installAll = downloading
126
139
            } else {
129
142
        }
130
143
 
131
144
        onUpdatesNotFound: {
132
 
            root.state = "NOUPDATES";
 
145
            if (root.state != "NOCREDENTIALS") {
 
146
                root.state = "NOUPDATES";
 
147
            }
 
148
        }
 
149
 
 
150
        onCheckFinished: {
 
151
            checkForUpdatesArea.visible = false;
 
152
        }
 
153
 
 
154
        onCredentialsNotFound: {
 
155
            root.state = "NOCREDENTIALS";
133
156
        }
134
157
 
135
158
        onSystemUpdateDownloaded: {
 
159
            root.updatesAvailable -= 1;
136
160
            PopupUtils.open(dialogInstallComponent);
137
161
        }
138
162
 
197
221
        id: installAllButton
198
222
        objectName: "installAllButton"
199
223
 
200
 
        property string primaryText: i18n.tr("Install %1 update", "Install %1 updates", updateManager.model.length).arg(updateManager.model.length)
 
224
        property string primaryText: i18n.tr("Install %1 update", "Install %1 updates", root.updatesAvailable).arg(root.updatesAvailable)
201
225
        property string secondaryText: i18n.tr("Pause All")
202
226
        text: root.installAll ? secondaryText : primaryText
203
227
        anchors {
217
241
                updateList.currentIndex = i;
218
242
                var item = updateList.currentItem;
219
243
                var modelItem = updateManager.model[i];
220
 
                if (modelItem.updateState == !root.installAll) {
 
244
                if (modelItem.updateState != root.installAll && !modelItem.updateReady) {
221
245
                    item.actionButton.clicked();
222
246
                }
223
247
            }
224
248
        }
 
249
        opacity: root.updatesAvailable > 0 ? 1 : 0
 
250
 
 
251
        Behavior on opacity { PropertyAnimation { duration: UbuntuAnimation.SlowDuration
 
252
                easing: UbuntuAnimation.StandardEasing } }
225
253
    }
226
254
 
227
255
    ListView {
290
318
                            updateManager.applySystemUpdate();
291
319
                            installingImageUpdate.visible = true;
292
320
                        } else if (modelData.updateState) {
293
 
                            updateManager.pauseDownload(modelData.packageName);
 
321
                            if (modelData.systemUpdate) {
 
322
                                updateManager.pauseDownload(modelData.packageName);
 
323
                            } else {
 
324
                                modelData.updateState = false;
 
325
                                tracker.pause();
 
326
                            }
294
327
                        } else {
295
 
                            modelData.selected = true;
296
 
                            updateManager.startDownload(modelData.packageName);
 
328
                            if (!modelData.selected || modelData.systemUpdate) {
 
329
                                modelData.selected = true;
 
330
                                updateManager.startDownload(modelData.packageName);
 
331
                            } else {
 
332
                                modelData.updateState = true;
 
333
                                tracker.resume();
 
334
                            }
297
335
                        }
298
336
                    }
299
337
                }
300
338
 
301
339
                Label {
302
340
                    id: labelSize
 
341
                    objectName: "labelSize"
303
342
                    text: convert_bytes_to_size(modelData.binaryFilesize)
304
343
                    anchors.bottom: labelVersion.bottom
305
344
                    anchors.right: parent.right
309
348
 
310
349
                Label {
311
350
                    id: labelTitle
 
351
                    objectName: "labelTitle"
312
352
                    anchors {
313
353
                        top: parent.top
314
354
                        left: parent.left
315
 
                        right: buttonAppUpdate.right
 
355
                        right: buttonAppUpdate.left
316
356
                        topMargin: units.gu(1)
 
357
                        rightMargin: units.gu(1)
317
358
                    }
318
359
                    height: units.gu(3)
319
360
                    text: modelData.title
320
361
                    font.bold: true
321
 
                    elide: Text.ElideRight
 
362
                    elide: buttonAppUpdate.visible ? Text.ElideRight : Text.ElideNone
322
363
                }
323
364
 
324
365
                Label {
325
366
                    id: labelUpdateStatus
 
367
                    objectName: "labelUpdateStatus"
326
368
                    text: i18n.tr("Installing")
327
369
                    anchors.top: labelTitle.bottom
328
370
                    anchors.left: parent.left
342
384
                    anchors.topMargin: units.gu(1)
343
385
                    anchors.right: parent.right
344
386
                    opacity: modelData.selected ? 1 : 0
345
 
                    value: modelData.downloadProgress
 
387
                    value: modelData.systemUpdate ? modelData.downloadProgress : tracker.progress
346
388
                    minimumValue: 0
347
389
                    maximumValue: 100
348
390
 
 
391
                    DownloadTracker {
 
392
                        id: tracker
 
393
                        objectName: "tracker"
 
394
                        packageName: modelData.packageName
 
395
                        clickToken: modelData.clickToken
 
396
                        download: modelData.downloadUrl
 
397
 
 
398
                        onFinished: {
 
399
                            progress.visible = false;
 
400
                            buttonAppUpdate.visible = false;
 
401
                            textArea.message = i18n.tr("Installed");
 
402
                            root.updatesAvailable -= 1;
 
403
                        }
 
404
 
 
405
                        onErrorFound: {
 
406
                            modelData.updateState = false;
 
407
                            textArea.message = error;
 
408
                        }
 
409
                    }
 
410
 
349
411
                    Behavior on opacity { PropertyAnimation { duration: UbuntuAnimation.SleepyDuration } }
350
412
                }
351
413
 
352
414
                Label {
353
415
                    id: labelVersion
 
416
                    objectName: "labelVersion"
354
417
                    anchors {
355
418
                        left: parent.left
356
419
                        right: buttonAppUpdate.right
357
 
                        top: progress.bottom
358
 
                        topMargin: units.gu(1)
 
420
                        top: (!progress.visible || progress.opacity == 0) ? labelTitle.bottom : progress.bottom
 
421
                        topMargin: (!progress.visible || progress.opacity == 0) ? 0 : units.gu(1)
359
422
                        bottom: parent.bottom
360
423
                        bottomMargin: units.gu(1)
361
424
                    }
369
432
 
370
433
    ListItem.Standard {
371
434
        id: notification
 
435
        objectName: "notification"
372
436
        visible: false
373
437
        anchors.bottom: configuration.top
374
438
    }
375
439
 
376
440
    ListItem.SingleValue {
377
441
        id: configuration
 
442
        objectName: "configuration"
378
443
        anchors.bottom: parent.bottom
379
444
        text: i18n.tr("Auto download")
380
445
        value: {
390
455
    }
391
456
 
392
457
    Rectangle {
393
 
        id: updatedNotification
 
458
        id: updateNotification
 
459
        objectName: "updateNotification"
394
460
        anchors {
395
461
            left: parent.left
396
462
            right: parent.right
408
474
            anchors.centerIn: parent
409
475
 
410
476
            Label {
411
 
                text: updatedNotification.text
 
477
                text: updateNotification.text
412
478
                anchors.horizontalCenter: parent.horizontalCenter
413
479
                fontSize: "large"
414
480
            }
417
483
 
418
484
    Rectangle {
419
485
        id: installingImageUpdate
 
486
        objectName: "installingImageUpdate"
420
487
        anchors.fill: parent
421
488
        visible: false
422
489
 
454
521
            result = bytes + i18n.tr(" bytes");
455
522
        } else if (bytes < SIZE_IN_MIB) {
456
523
            size = (bytes / SIZE_IN_KIB).toFixed(1);
457
 
            result = bytes + i18n.tr(" KiB");
 
524
            result = size + i18n.tr(" KiB");
458
525
        } else if (bytes < SIZE_IN_GIB) {
459
526
            size = (bytes / SIZE_IN_MIB).toFixed(1);
460
527
            result = size + i18n.tr(" MiB");