Merge lp:~ken-vandine/ubuntu-system-settings/rtm-lp1329702_battery_charging_status into lp:ubuntu-system-settings/rtm-14.09

Proposed by Ken VanDine on 2015-01-30
Status: Merged
Approved by: Jonas G. Drange on 2015-02-02
Approved revision: 975
Merged at revision: 978
Proposed branch: lp:~ken-vandine/ubuntu-system-settings/rtm-lp1329702_battery_charging_status
Merge into: lp:ubuntu-system-settings/rtm-14.09
Diff against target: 165 lines (+23/-61)
4 files modified
debian/control (+1/-0)
plugins/battery/PageComponent.qml (+20/-31)
plugins/battery/SleepValues.qml (+0/-1)
plugins/system-update/PageComponent.qml (+2/-29)
To merge this branch: bzr merge lp:~ken-vandine/ubuntu-system-settings/rtm-lp1329702_battery_charging_status
Reviewer Review Type Date Requested Status
Jonas G. Drange (community) 2015-01-30 Approve on 2015-02-02
PS Jenkins bot continuous-integration Needs Fixing on 2015-01-30
Review via email: mp+248154@code.launchpad.net

Commit Message

Use device-state from indicator-power to determine charging status. QtSystemsInfo doesn't support UPower 0.99.

Description of the Change

Use device-state from indicator-power to determine charging status. QtSystemsInfo doesn't support UPower 0.99.

This change requires indicator-power from https://code.launchpad.net/~charlesk/indicator-power/lp-1416096-publish-primary-device-state-on-bus/+merge/248142

To post a comment you must log in.
review: Needs Information
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2015-01-21 12:04:00 +0000
3+++ debian/control 2015-01-30 18:38:02 +0000
4@@ -61,6 +61,7 @@
5 gsettings-ubuntu-schemas (>= 0.0.2+14.10.20140815),
6 indicator-bluetooth (>> 0.0.6+13.10.20131010),
7 indicator-network (>= 0.5.0+13.10.20130918),
8+ indicator-power (>= 12.10.6+15.04.20150130),
9 powerd (>= 0.15) | gnome-settings-daemon,
10 qmenumodel-qml,
11 qtdeclarative5-folderlistmodel-plugin,
12
13=== modified file 'plugins/battery/PageComponent.qml'
14--- plugins/battery/PageComponent.qml 2014-12-09 14:16:25 +0000
15+++ plugins/battery/PageComponent.qml 2015-01-30 18:38:02 +0000
16@@ -34,8 +34,6 @@
17 title: i18n.tr("Battery")
18 flickable: scrollWidget
19
20- property bool isCharging
21-
22 function timeDeltaString(timeDelta) {
23 var sec = timeDelta,
24 min = Math.round (timeDelta / 60),
25@@ -71,36 +69,10 @@
26 objectPath: "/com/canonical/indicator/power"
27 property variant brightness: action("brightness").state
28 property variant batteryLevel: action("battery-level").state
29+ property variant deviceState: action("device-state").state
30 Component.onCompleted: start()
31 }
32
33- BatteryInfo {
34- id: batteryInfo
35-
36- monitorChargingState: true
37- monitorBatteryStatus: true
38-
39- onChargingStateChanged: {
40- if (state === BatteryInfo.Charging) {
41- chargingEntry.text = i18n.tr("Charging now")
42- isCharging = true
43- }
44- else if (state === BatteryInfo.Discharging &&
45- batteryInfo.batteryStatus(0) !== BatteryInfo.BatteryFull) {
46- chargingEntry.text = i18n.tr("Last full charge")
47- isCharging = false
48- }
49- else if (batteryInfo.batteryStatus(0) === BatteryInfo.BatteryFull ||
50- state === BatteryInfo.NotCharging) {
51- chargingEntry.text = i18n.tr("Fully charged")
52- isCharging = true
53- }
54- }
55- Component.onCompleted: {
56- onChargingStateChanged(0, chargingState(0))
57- }
58- }
59-
60 UbuntuBatteryPanel {
61 id: batteryBackend
62 }
63@@ -283,8 +255,25 @@
64
65 ListItem.SingleValue {
66 id: chargingEntry
67- value: isCharging ?
68- "" : (batteryBackend.lastFullCharge ? timeDeltaString(batteryBackend.lastFullCharge) : i18n.tr("N/A"))
69+ text: {
70+ if (indicatorPower.deviceState === "charging")
71+ return i18n.tr("Charging now")
72+ else if (indicatorPower.deviceState === "discharging")
73+ return i18n.tr("Last full charge")
74+ else if (indicatorPower.deviceState === "fully-charged")
75+ return i18n.tr("Fully charged")
76+ }
77+
78+ value: {
79+ if (indicatorPower.deviceState === "discharging") {
80+ if (batteryBackend.lastFullCharge)
81+ return timeDeltaString(batteryBackend.lastFullCharge)
82+ else
83+ return i18n.tr("N/A")
84+ }
85+ else
86+ return ""
87+ }
88 showDivider: false
89 }
90
91
92=== modified file 'plugins/battery/SleepValues.qml'
93--- plugins/battery/SleepValues.qml 2014-11-12 16:03:25 +0000
94+++ plugins/battery/SleepValues.qml 2015-01-30 18:38:02 +0000
95@@ -23,7 +23,6 @@
96
97 import GSettings 1.0
98 import QtQuick 2.0
99-import QtSystemInfo 5.0
100 import Ubuntu.Components 0.1
101 import Ubuntu.Components.ListItems 0.1 as ListItem
102 import SystemSettings 1.0
103
104=== modified file 'plugins/system-update/PageComponent.qml'
105--- plugins/system-update/PageComponent.qml 2014-10-20 20:53:02 +0000
106+++ plugins/system-update/PageComponent.qml 2015-01-30 18:38:02 +0000
107@@ -21,7 +21,6 @@
108
109 import QMenuModel 0.1
110 import QtQuick 2.0
111-import QtSystemInfo 5.0
112 import SystemSettings 1.0
113 import Ubuntu.Components 0.1
114 import Ubuntu.Components.ListItems 0.1 as ListItem
115@@ -42,7 +41,7 @@
116 property bool includeSystemUpdate: false
117 property bool systemUpdateInProgress: false
118 property int updatesAvailable: 0
119- property bool isCharging: false
120+ property bool isCharging: indicatorPower.deviceState === "charging"
121 property bool batterySafeForUpdate: isCharging || chargeLevel > 25
122 property var chargeLevel: indicatorPower.batteryLevel || 0
123 property var notificationAction;
124@@ -54,6 +53,7 @@
125 busName: "com.canonical.indicator.power"
126 objectPath: "/com/canonical/indicator/power"
127 property variant batteryLevel: action("battery-level").state
128+ property variant deviceState: action("device-state").state
129 Component.onCompleted: start()
130 }
131
132@@ -71,33 +71,6 @@
133 }
134 }
135
136-
137- DeviceInfo {
138- id: deviceInfo
139- }
140-
141- BatteryInfo {
142- id: batteryInfo
143- monitorChargingState: true
144-
145- onChargingStateChanged: {
146- if (state === BatteryInfo.Charging) {
147- isCharging = true
148- }
149- else if (state === BatteryInfo.Discharging &&
150- batteryInfo.batteryStatus(0) !== BatteryInfo.BatteryFull) {
151- isCharging = false
152- }
153- else if (batteryInfo.batteryStatus(0) === BatteryInfo.BatteryFull ||
154- state === BatteryInfo.NotCharging) {
155- isCharging = true
156- }
157- }
158- Component.onCompleted: {
159- onChargingStateChanged(0, chargingState(0))
160- }
161- }
162-
163 Setup {
164 id: uoaConfig
165 applicationId: "ubuntu-system-settings"

Subscribers

People subscribed via source and target branches