Merge lp:~laney/ubuntu-system-settings/battery-percentage-indicator into lp:ubuntu-system-settings

Proposed by Iain Lane
Status: Merged
Approved by: Sebastien Bacher
Approved revision: 402
Merged at revision: 403
Proposed branch: lp:~laney/ubuntu-system-settings/battery-percentage-indicator
Merge into: lp:ubuntu-system-settings
Diff against target: 408 lines (+75/-95)
2 files modified
plugins/battery/PageComponent.qml (+11/-7)
po/ubuntu-system-settings.pot (+64/-88)
To merge this branch: bzr merge lp:~laney/ubuntu-system-settings/battery-percentage-indicator
Reviewer Review Type Date Requested Status
Sebastien Bacher (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+188286@code.launchpad.net

Commit message

Use the indicator's value for the charge level instead of calculating it from QtSystems derived information

Description of the change

Seems calculating from the raw values is unreliable; just use what the indicator gives us (which currently is 'capacity').

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Sebastien Bacher (seb128) wrote :

Seems fine to me, thanks

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/battery/PageComponent.qml'
2--- plugins/battery/PageComponent.qml 2013-09-26 11:36:07 +0000
3+++ plugins/battery/PageComponent.qml 2013-09-30 09:57:35 +0000
4@@ -81,12 +81,6 @@
5 isCharging = true
6 }
7 }
8- onRemainingCapacityChanged: {
9- if(batteryInfo.batteryCount > 0)
10- /* TRANSLATORS: %1 refers to a percentage that indicates the charging level of the battery */
11- chargingLevel.value = i18n.tr("%1 %").arg((batteryInfo.remainingCapacity(0)/batteryInfo.maximumCapacity(0)*100).toFixed(0))
12- }
13-
14 Component.onCompleted: {
15 onChargingStateChanged(0, chargingState(0))
16 onRemainingCapacityChanged(0, remainingCapacity(0))
17@@ -104,6 +98,7 @@
18 objectPath: "/com/canonical/indicator/power"
19
20 property variant brightness: action("brightness")
21+ property variant batteryLevel: action("battery-level")
22 }
23
24 Component.onCompleted: indicatorPower.start()
25@@ -122,7 +117,16 @@
26 ListItem.SingleValue {
27 id: chargingLevel
28 text: i18n.tr("Charge level")
29- value: i18n.tr("N/A")
30+ value: {
31+ var chargeLevel = indicatorPower.batteryLevel.state
32+
33+ if (chargeLevel === null)
34+ return i18n.tr("N/A")
35+
36+ /* TRANSLATORS: %1 refers to a percentage that indicates the charging level of the battery */
37+ return i18n.tr("%1%".arg(chargeLevel))
38+ }
39+
40 showDivider: false
41 }
42
43
44=== modified file 'po/ubuntu-system-settings.pot'
45--- po/ubuntu-system-settings.pot 2013-09-26 11:36:07 +0000
46+++ po/ubuntu-system-settings.pot 2013-09-30 09:57:35 +0000
47@@ -8,7 +8,7 @@
48 msgstr ""
49 "Project-Id-Version: ubuntu-system-settings\n"
50 "Report-Msgid-Bugs-To: \n"
51-"POT-Creation-Date: 2013-09-26 13:30+0200\n"
52+"POT-Creation-Date: 2013-09-30 09:38+0000\n"
53 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
54 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
55 "Language-Team: LANGUAGE <LL@li.org>\n"
56@@ -27,9 +27,9 @@
57 msgstr ""
58
59 #: ../plugins/about/PageComponent.qml:77 ../plugins/about/PageComponent.qml:84
60-#: ../plugins/about/Storage.qml:137 ../plugins/battery/PageComponent.qml:125
61-#: ../plugins/battery/PageComponent.qml:132
62-#: ../plugins/cellular/PageComponent.qml:75
63+#: ../plugins/about/Storage.qml:190 ../plugins/battery/PageComponent.qml:124
64+#: ../plugins/battery/PageComponent.qml:136
65+#: ../plugins/cellular/PageComponent.qml:73
66 msgid "N/A"
67 msgstr ""
68
69@@ -46,11 +46,11 @@
70 msgstr ""
71
72 #: ../plugins/about/PageComponent.qml:98
73-#: ../plugins/battery/PageComponent.qml:245
74-#: ../plugins/battery/PageComponent.qml:253
75+#: ../plugins/battery/PageComponent.qml:249
76+#: ../plugins/battery/PageComponent.qml:257
77 #: ../plugins/battery/SleepValues.qml:91
78 #: ../plugins/system-update/Download.qml:53
79-#: ../plugins/system-update/PageComponent.qml:335
80+#: ../plugins/system-update/PageComponent.qml:334
81 msgid "Never"
82 msgstr ""
83
84@@ -58,7 +58,7 @@
85 msgid "Check for updates"
86 msgstr ""
87
88-#: ../plugins/about/PageComponent.qml:112 ../plugins/about/Storage.qml:33
89+#: ../plugins/about/PageComponent.qml:112 ../plugins/about/Storage.qml:32
90 msgid "Storage"
91 msgstr ""
92
93@@ -74,59 +74,47 @@
94 msgid "Regulatory info"
95 msgstr ""
96
97-#: ../plugins/about/Storage.qml:39
98+#: ../plugins/about/Storage.qml:87
99 msgid "Used by Ubuntu"
100 msgstr ""
101
102-#: ../plugins/about/Storage.qml:39
103+#: ../plugins/about/Storage.qml:88
104 msgid "Movies"
105 msgstr ""
106
107-#: ../plugins/about/Storage.qml:39
108+#: ../plugins/about/Storage.qml:89
109 msgid "Audio"
110 msgstr ""
111
112-#: ../plugins/about/Storage.qml:40
113+#: ../plugins/about/Storage.qml:90
114 msgid "Pictures"
115 msgstr ""
116
117-#: ../plugins/about/Storage.qml:40
118+#: ../plugins/about/Storage.qml:91
119 msgid "Other files"
120 msgstr ""
121
122-#: ../plugins/about/Storage.qml:40
123+#: ../plugins/about/Storage.qml:92
124 msgid "Used by apps"
125 msgstr ""
126
127-#: ../plugins/about/Storage.qml:61
128-msgid "kB"
129-msgstr ""
130-
131-#: ../plugins/about/Storage.qml:63
132-msgid "MB"
133-msgstr ""
134-
135-#: ../plugins/about/Storage.qml:65
136-msgid "GB"
137-msgstr ""
138-
139-#: ../plugins/about/Storage.qml:85
140+#: ../plugins/about/Storage.qml:134
141 msgid "Total storage"
142 msgstr ""
143
144-#: ../plugins/about/Storage.qml:94
145+#: ../plugins/about/Storage.qml:145
146 msgid "Free space"
147 msgstr ""
148
149-#: ../plugins/about/Storage.qml:110
150+#: ../plugins/about/Storage.qml:163
151 msgid "Installed apps"
152 msgstr ""
153
154-#: ../plugins/about/Storage.qml:111
155+#: ../plugins/about/Storage.qml:164
156 msgid "By name"
157 msgstr ""
158
159-#: ../plugins/about/Storage.qml:111
160+#: ../plugins/about/Storage.qml:164
161 msgid "By size"
162 msgstr ""
163
164@@ -134,19 +122,19 @@
165 msgid "Background"
166 msgstr ""
167
168-#: ../plugins/background/MainPage.qml:68
169+#: ../plugins/background/MainPage.qml:71
170 msgid "Welcome screen"
171 msgstr ""
172
173-#: ../plugins/background/MainPage.qml:143
174+#: ../plugins/background/MainPage.qml:134
175 msgid "Home screen"
176 msgstr ""
177
178-#: ../plugins/background/MainPage.qml:223
179+#: ../plugins/background/MainPage.qml:160
180 msgid "Same background for both"
181 msgstr ""
182
183-#: ../plugins/background/MainPage.qml:224
184+#: ../plugins/background/MainPage.qml:161
185 msgid "Different background for each"
186 msgstr ""
187
188@@ -194,36 +182,36 @@
189 msgid "Fully charged"
190 msgstr ""
191
192+#: ../plugins/battery/PageComponent.qml:119
193+msgid "Charge level"
194+msgstr ""
195+
196 #. TRANSLATORS: %1 refers to a percentage that indicates the charging level of the battery
197-#: ../plugins/battery/PageComponent.qml:87
198+#: ../plugins/battery/PageComponent.qml:127
199 #, qt-format
200-msgid "%1 %"
201-msgstr ""
202-
203-#: ../plugins/battery/PageComponent.qml:124
204-msgid "Charge level"
205-msgstr ""
206-
207-#: ../plugins/battery/PageComponent.qml:176
208+msgid "%1%"
209+msgstr ""
210+
211+#: ../plugins/battery/PageComponent.qml:180
212 msgid "Ways to reduce battery use:"
213 msgstr ""
214
215-#: ../plugins/battery/PageComponent.qml:180
216+#: ../plugins/battery/PageComponent.qml:184
217 msgid "Display brightness"
218 msgstr ""
219
220-#: ../plugins/battery/PageComponent.qml:237
221+#: ../plugins/battery/PageComponent.qml:241
222 #: ../plugins/security-privacy/PhoneLocking.qml:62
223 msgid "Lock when idle"
224 msgstr ""
225
226-#: ../plugins/battery/PageComponent.qml:237
227+#: ../plugins/battery/PageComponent.qml:241
228 #: ../plugins/security-privacy/PhoneLocking.qml:63
229 msgid "Sleep when idle"
230 msgstr ""
231
232-#: ../plugins/battery/PageComponent.qml:242
233-#: ../plugins/battery/PageComponent.qml:250
234+#: ../plugins/battery/PageComponent.qml:246
235+#: ../plugins/battery/PageComponent.qml:254
236 #: ../plugins/battery/SleepValues.qml:76 ../plugins/battery/SleepValues.qml:79
237 #: ../plugins/battery/SleepValues.qml:82 ../plugins/battery/SleepValues.qml:85
238 #: ../plugins/battery/SleepValues.qml:88
239@@ -233,22 +221,22 @@
240 msgstr[0] ""
241 msgstr[1] ""
242
243-#: ../plugins/battery/PageComponent.qml:263
244+#: ../plugins/battery/PageComponent.qml:267
245 #: ../plugins/wifi/PageComponent.qml:27 ../.build/settings.js:18
246 msgid "Wi-Fi"
247 msgstr ""
248
249-#: ../plugins/battery/PageComponent.qml:287
250+#: ../plugins/battery/PageComponent.qml:291
251 #: ../plugins/bluetooth/PageComponent.qml:98
252 #: ../plugins/bluetooth/PageComponent.qml:106 ../.build/settings.js:5
253 msgid "Bluetooth"
254 msgstr ""
255
256-#: ../plugins/battery/PageComponent.qml:316
257+#: ../plugins/battery/PageComponent.qml:320
258 msgid "GPS"
259 msgstr ""
260
261-#: ../plugins/battery/PageComponent.qml:334
262+#: ../plugins/battery/PageComponent.qml:338
263 msgid "Accurate location detection requires GPS and/or Wi-Fi."
264 msgstr ""
265
266@@ -282,7 +270,7 @@
267
268 #: ../plugins/bluetooth/ConfirmPasskeyDialog.qml:48
269 #: ../plugins/bluetooth/ProvidePasskeyDialog.qml:54
270-#: ../plugins/language/DisplayLanguage.qml:89
271+#: ../plugins/language/DisplayLanguage.qml:95
272 #: ../plugins/phone/CallForwarding.qml:113
273 #: ../plugins/reset/EraseEverything.qml:36
274 #: ../plugins/reset/ResetAllSettings.qml:36
275@@ -432,15 +420,15 @@
276 msgstr ""
277
278 #: ../plugins/cellular/ChooseCarrier.qml:28
279-#: ../plugins/cellular/PageComponent.qml:74
280+#: ../plugins/cellular/PageComponent.qml:72
281 msgid "Carrier"
282 msgstr ""
283
284-#: ../plugins/cellular/ChooseCarrier.qml:80
285+#: ../plugins/cellular/ChooseCarrier.qml:78
286 msgid "Refresh"
287 msgstr ""
288
289-#: ../plugins/cellular/ChooseCarrier.qml:97
290+#: ../plugins/cellular/ChooseCarrier.qml:95
291 msgid "Searching"
292 msgstr ""
293
294@@ -448,52 +436,40 @@
295 msgid "Cellular"
296 msgstr ""
297
298-#: ../plugins/cellular/PageComponent.qml:68
299+#: ../plugins/cellular/PageComponent.qml:66
300 msgid "Choose carrier:"
301 msgstr ""
302
303-#: ../plugins/cellular/PageComponent.qml:69
304+#: ../plugins/cellular/PageComponent.qml:67
305 #: ../plugins/time-date/ChooseTimeZone.qml:35
306 #: ../plugins/time-date/PageComponent.qml:66
307 msgid "Automatically"
308 msgstr ""
309
310-#: ../plugins/cellular/PageComponent.qml:69
311+#: ../plugins/cellular/PageComponent.qml:67
312 #: ../plugins/time-date/ChooseTimeZone.qml:35
313 #: ../plugins/time-date/PageComponent.qml:66
314 msgid "Manually"
315 msgstr ""
316
317-#: ../plugins/cellular/PageComponent.qml:89
318-msgid "Cellular data:"
319-msgstr ""
320-
321-#: ../plugins/cellular/PageComponent.qml:90
322-msgid "Off"
323-msgstr ""
324-
325-#: ../plugins/cellular/PageComponent.qml:91
326-msgid "2G only (saves battery)"
327-msgstr ""
328-
329-#: ../plugins/cellular/PageComponent.qml:92
330-msgid "2G/3G/4G (faster)"
331-msgstr ""
332-
333-#: ../plugins/cellular/PageComponent.qml:103
334+#: ../plugins/cellular/PageComponent.qml:101
335+msgid "Cellular data"
336+msgstr ""
337+
338+#: ../plugins/cellular/PageComponent.qml:109
339 msgid "Data roaming"
340 msgstr ""
341
342-#: ../plugins/cellular/PageComponent.qml:112
343+#: ../plugins/cellular/PageComponent.qml:118
344 msgid "Data usage statistics"
345 msgstr ""
346
347-#: ../plugins/language/DisplayLanguage.qml:34
348+#: ../plugins/language/DisplayLanguage.qml:33
349 #: ../plugins/language/PageComponent.qml:55
350 msgid "Display language"
351 msgstr ""
352
353-#: ../plugins/language/DisplayLanguage.qml:109
354+#: ../plugins/language/DisplayLanguage.qml:115
355 #: ../plugins/security-privacy/LockSecurity.qml:217
356 msgid "Confirm"
357 msgstr ""
358@@ -961,7 +937,7 @@
359 msgstr ""
360
361 #: ../plugins/system-update/Download.qml:29
362-#: ../plugins/system-update/PageComponent.qml:332
363+#: ../plugins/system-update/PageComponent.qml:331
364 msgid "Auto download"
365 msgstr ""
366
367@@ -1036,7 +1012,7 @@
368 msgstr ""
369
370 #: ../plugins/system-update/PageComponent.qml:200
371-#: ../plugins/system-update/PageComponent.qml:310
372+#: ../plugins/system-update/PageComponent.qml:309
373 msgid "Retry"
374 msgstr ""
375
376@@ -1049,27 +1025,27 @@
377 msgid "Version %1"
378 msgstr ""
379
380-#: ../plugins/system-update/PageComponent.qml:280
381+#: ../plugins/system-update/PageComponent.qml:279
382 msgid "Pause downloading"
383 msgstr ""
384
385-#: ../plugins/system-update/PageComponent.qml:287
386+#: ../plugins/system-update/PageComponent.qml:286
387 msgid "Resume downloading"
388 msgstr ""
389
390-#: ../plugins/system-update/PageComponent.qml:303
391+#: ../plugins/system-update/PageComponent.qml:302
392 msgid "Download"
393 msgstr ""
394
395-#: ../plugins/system-update/PageComponent.qml:317
396+#: ../plugins/system-update/PageComponent.qml:316
397 msgid "Install & Restart"
398 msgstr ""
399
400-#: ../plugins/system-update/PageComponent.qml:337
401+#: ../plugins/system-update/PageComponent.qml:336
402 msgid "On wi-fi"
403 msgstr ""
404
405-#: ../plugins/system-update/PageComponent.qml:339
406+#: ../plugins/system-update/PageComponent.qml:338
407 msgid "Always"
408 msgstr ""
409

Subscribers

People subscribed via source and target branches