~ubuntu-branches/ubuntu/utopic/ubuntu-system-settings/utopic-proposed

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, Ken VanDine, Sebastien Bacher, Mathieu Trudel-Lapierre, Michael Terry
  • Date: 2014-09-09 16:40:09 UTC
  • mfrom: (1.1.165)
  • Revision ID: package-import@ubuntu.com-20140909164009-suc8v816kz1r7qi4
Tags: 0.3+14.10.20140909-0ubuntu1
[ Ken VanDine ]
* Notify the user if the phone needs to be plug to power for update.

[ Sebastien Bacher ]
* [system-update] don't draw a frame around ubuntu updates (LP:
  #1367136)

[ Mathieu Trudel-Lapierre ]
* Also allow Speakers and Carkits as valid audio devices to pair.

[ Michael Terry ]
* Allow switch from PIN code to passphrase and back using the same
  password. (LP: #1357043) (LP: #1357043)
* Fix false-negatives from AccountsService when switching from swipe
  to password (LP: #1363405) (LP: #1363405)

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
20
20
 */
21
21
 
 
22
import QMenuModel 0.1
22
23
import QtQuick 2.0
23
24
import QtSystemInfo 5.0
24
25
import SystemSettings 1.0
37
38
 
38
39
    property bool installAll: false
39
40
    property bool includeSystemUpdate: false
 
41
    property bool systemUpdateInProgress: false
40
42
    property int updatesAvailable: 0
41
 
 
 
43
    property bool isCharging: false
 
44
    property bool batterySafeForUpdate: isCharging || chargeLevel > 25
 
45
    property var chargeLevel: indicatorPower.batteryLevel || 0
42
46
    property var notificationAction;
43
47
 
 
48
    QDBusActionGroup {
 
49
        id: indicatorPower
 
50
        busType: 1
 
51
        busName: "com.canonical.indicator.power"
 
52
        objectPath: "/com/canonical/indicator/power"
 
53
        property variant batteryLevel: action("battery-level").state
 
54
        Component.onCompleted: start()
 
55
    }
 
56
 
44
57
    DeviceInfo {
45
58
        id: deviceInfo
46
59
    }
47
60
 
 
61
    BatteryInfo {
 
62
        id: batteryInfo
 
63
        monitorChargingState: true
 
64
 
 
65
        onChargingStateChanged: {
 
66
            if (state === BatteryInfo.Charging) {
 
67
                isCharging = true
 
68
            }
 
69
            else if (state === BatteryInfo.Discharging &&
 
70
                     batteryInfo.batteryStatus(0) !== BatteryInfo.BatteryFull) {
 
71
                isCharging = false
 
72
            }
 
73
            else if (batteryInfo.batteryStatus(0) === BatteryInfo.BatteryFull ||
 
74
                     state === BatteryInfo.NotCharging) {
 
75
                isCharging = true
 
76
            }
 
77
        }
 
78
        Component.onCompleted: {
 
79
            onChargingStateChanged(0, chargingState(0))
 
80
        }
 
81
    }
 
82
 
48
83
    Component {
49
84
         id: dialogInstallComponent
50
85
         Dialog {
51
86
             id: dialogueInstall
52
87
             title: i18n.tr("Update System")
53
 
             text: i18n.tr("The phone needs to restart to install the system update.")
 
88
             text: root.batterySafeForUpdate ? i18n.tr("The phone needs to restart to install the system update.") : i18n.tr("Connect the phone to power before installing the system update.")
54
89
 
55
90
             Button {
56
91
                 text: i18n.tr("Install & Restart")
 
92
                 visible: root.batterySafeForUpdate ? true : false
57
93
                 color: UbuntuColors.orange
58
94
                 onClicked: {
59
95
                     installingImageUpdate.visible = true;
69
105
                     var item = updateList.currentItem;
70
106
                     var modelItem = updateManager.model[0];
71
107
                     item.actionButton.text = i18n.tr("Install");
 
108
                     item.progressBar.opacity = 0;
72
109
                     modelItem.updateReady = true;
 
110
                     modelItem.selected = false;
 
111
                     root.systemUpdateInProgress = false;
73
112
                     PopupUtils.close(dialogueInstall);
74
113
                 }
75
114
             }
143
182
        }
144
183
 
145
184
        onSystemUpdateDownloaded: {
146
 
            root.updatesAvailable -= 1;
147
 
            PopupUtils.open(dialogInstallComponent);
 
185
            if (!root.systemUpdateInProgress && !installingImageUpdate.visible) {
 
186
                root.systemUpdateInProgress = true;
 
187
                PopupUtils.open(dialogInstallComponent);
 
188
            }
148
189
        }
149
190
 
150
191
        onSystemUpdateFailed: {
248
289
                delegate: ListItem.Subtitled {
249
290
                    id: listItem
250
291
                    iconSource: Qt.resolvedUrl(modelData.iconUrl)
 
292
                    iconFrame: modelData.systemUpdate ? false : true
251
293
                    height: modelData.selected ? units.gu(14) : units.gu(8)
252
294
                    highlightWhenPressed: false
253
295
                    showDivider: false
254
296
 
255
297
                    property alias actionButton: buttonAppUpdate
 
298
                    property alias progressBar: progress
256
299
 
257
300
                    Rectangle {
258
301
                        id: textArea
294
337
                                    textArea.retry = false;
295
338
                                    updateManager.retryDownload(modelData.packageName);
296
339
                                } else if (modelData.updateReady) {
297
 
                                    updateManager.applySystemUpdate();
298
 
                                    installingImageUpdate.visible = true;
 
340
                                    PopupUtils.open(dialogInstallComponent);
299
341
                                } else if (modelData.updateState) {
300
342
                                    if (modelData.systemUpdate) {
301
343
                                        updateManager.pauseDownload(modelData.packageName);