Changeset View
Standalone View
applets/batterymonitor/package/contents/ui/batterymonitor.qml
Show All 33 Lines | 30 | Item { | |||
---|---|---|---|---|---|
34 | 34 | | |||
35 | LayoutMirroring.enabled: Qt.application.layoutDirection == Qt.RightToLeft | 35 | LayoutMirroring.enabled: Qt.application.layoutDirection == Qt.RightToLeft | ||
36 | LayoutMirroring.childrenInherit: true | 36 | LayoutMirroring.childrenInherit: true | ||
37 | 37 | | |||
38 | Plasmoid.status: { | 38 | Plasmoid.status: { | ||
39 | if (powermanagementDisabled) { | 39 | if (powermanagementDisabled) { | ||
40 | return PlasmaCore.Types.ActiveStatus | 40 | return PlasmaCore.Types.ActiveStatus | ||
41 | } | 41 | } | ||
42 | | ||||
43 | if (pmSource.data.Battery["Has Cumulative"]) { | 42 | if (pmSource.data.Battery["Has Cumulative"]) { | ||
44 | if (pmSource.data.Battery.State !== "Charging" && pmSource.data.Battery.Percent <= 5) { | 43 | if (pmSource.data.Battery.State !== "Charging" && pmSource.data.Battery.Percent <= 5) { | ||
45 | return PlasmaCore.Types.NeedsAttentionStatus | 44 | return PlasmaCore.Types.NeedsAttentionStatus | ||
46 | } else if (pmSource.data["Battery"]["State"] !== "FullyCharged") { | 45 | } else if (pmSource.data["Battery"]["State"] !== "FullyCharged") { | ||
47 | return PlasmaCore.Types.ActiveStatus | 46 | return PlasmaCore.Types.ActiveStatus | ||
48 | } | 47 | } | ||
49 | } | 48 | } | ||
50 | | ||||
51 | return PlasmaCore.Types.PassiveStatus | 49 | return PlasmaCore.Types.PassiveStatus | ||
52 | } | 50 | } | ||
53 | 51 | | |||
54 | Plasmoid.toolTipMainText: { | 52 | Plasmoid.toolTipMainText: { | ||
53 | if (batteries.count === 0 || !pmSource.data["Battery"]["Has Cumulative"]) { | ||||
ngraham: Un-capitalize the B | |||||
54 | return plasmoid.title | ||||
You can probably just return plasmoid.title in the default case. broulik: You can probably just return `plasmoid.title` in the default case.
Also, what's the reason for… | |||||
You still haven't addressed this. Don't just return when powermanagementDisabled, I would still want to see my battery state when this is the case? broulik: You still haven't addressed this. Don't just `return` when `powermanagementDisabled`, I would… | |||||
OK, would you like to see: mthw: OK, would you like to see:
MainText: Power management disabled
SubText: Battery at X%, HH:MM… | |||||
55 | } | ||||
56 | if (pmSource.data["Battery"]["State"] === "FullyCharged") { | ||||
ngraham: un-capitalize the R | |||||
ngraham: Un-capitalize the R | |||||
57 | return i18n("Plugged in"); | ||||
58 | } | ||||
59 | if (pmSource.data["AC Adapter"] && pmSource.data["AC Adapter"]["Plugged in"]) { | ||||
60 | if (state === "NoCharge") { | ||||
61 | return i18n("Plugged in"); | ||||
ngraham: Un-capitalize the B | |||||
62 | } | ||||
63 | } | ||||
64 | return i18n("Battery at %1%", pmSource.data.Battery.Percent); | ||||
65 | } | ||||
66 | | ||||
67 | Plasmoid.toolTipSubText: { | ||||
68 | var parts = []; | ||||
69 | if (powermanagementDisabled) { | ||||
When power management is disabled the subtext shows no useful information now. Powermanagement disabled means disabled screen powermanagement (i.e. keep screen always on), has nothing to do with the battery percentage, which is still useful to have. broulik: When power management is disabled the subtext shows no useful information now.
Powermanagement… | |||||
70 | parts.push(i18n("Power management is disabled")); | ||||
This early return still hasn't been addressed. broulik: This early return still hasn't been addressed.
When I keep the screen on I still want to see my… | |||||
71 | } | ||||
55 | if (batteries.count === 0) { | 72 | if (batteries.count === 0) { | ||
56 | return i18n("No Batteries Available"); | 73 | parts.push("No Batteries Available"); | ||
57 | } else if (!pmSource.data["Battery"]["Has Cumulative"]) { | 74 | return parts.join("\n"); | ||
58 | // Bug 362924: Distinguish between no batteries and no power supply batteries | 75 | } | ||
59 | // just show the generic applet title in the latter case | 76 | if (pmSource.data["Battery"]["State"] === "FullyCharged") { | ||
60 | return i18n("Battery and Brightness") | 77 | parts.push(i18n("Fully Charged")); | ||
61 | } else if (pmSource.data["Battery"]["State"] === "FullyCharged") { | 78 | return parts.join("\n") | ||
ngraham: This block also needs` if (remainingTime > 0) {` like the one below it | |||||
62 | return i18n("Fully Charged"); | | |||
63 | } else if (pmSource.data["AC Adapter"] && pmSource.data["AC Adapter"]["Plugged in"]) { | | |||
64 | var percent = pmSource.data.Battery.Percent | | |||
65 | var state = pmSource.data.Battery.State | | |||
66 | if (state === "Charging") { | | |||
67 | return i18n("%1% Charging", percent) | | |||
68 | } else if (state === "NoCharge") { | | |||
69 | return i18n("%1% Plugged in, not Charging", percent) | | |||
70 | } else { | | |||
71 | return i18n("%1% Plugged in", percent) | | |||
72 | } | 79 | } | ||
73 | } else { | | |||
74 | if (remainingTime > 0) { | 80 | if (remainingTime > 0) { | ||
75 | return i18nc("%1 is remaining time, %2 is percentage", "%1 Remaining (%2%)", | 81 | if (pmSource.data["AC Adapter"] && pmSource.data["AC Adapter"]["Plugged in"]) { | ||
76 | KCoreAddons.Format.formatDuration(remainingTime, KCoreAddons.FormatTypes.HideSeconds), | 82 | parts.push(i18nc("time until fully charged - HH:MM","%1 until fully charged", KCoreAddons.Format.formatDuration(remainingTime, KCoreAddons.FormatTypes.HideSeconds))); | ||
77 | pmSource.data["Battery"]["Percent"]) | | |||
78 | } else { | 83 | } else { | ||
79 | return i18n("%1% Battery Remaining", pmSource.data["Battery"]["Percent"]); | 84 | parts.push(i18nc("remaining time left of battery usage - HH:MM","%1 remaining", KCoreAddons.Format.formatDuration(remainingTime, KCoreAddons.FormatTypes.HideSeconds))); | ||
broulik: Keep the `i18nc` explaining that %1 is remaining time | |||||
80 | } | 85 | } | ||
86 | return parts.join("\n") | ||||
ngraham: Un-capitalize the B | |||||
81 | } | 87 | } | ||
broulik: Why this early return? | |||||
88 | parts.push(i18n("Calculating remaining time...")); | ||||
broulik: This code path will never be reached | |||||
89 | return parts.join("\n"); | ||||
82 | } | 90 | } | ||
broulik: What in the `else` case? Perhaps at least explicitly `return "";` | |||||
83 | Plasmoid.toolTipSubText: powermanagementDisabled ? i18n("Power management is disabled") : "" | 91 | | ||
84 | Plasmoid.icon: "battery" | 92 | Plasmoid.icon: "battery" | ||
85 | 93 | | |||
86 | property bool disableBrightnessUpdate: true | 94 | property bool disableBrightnessUpdate: true | ||
87 | 95 | | |||
88 | property int screenBrightness | 96 | property int screenBrightness | ||
89 | readonly property int maximumScreenBrightness: pmSource.data["PowerDevil"] ? pmSource.data["PowerDevil"]["Maximum Screen Brightness"] || 0 : 0 | 97 | readonly property int maximumScreenBrightness: pmSource.data["PowerDevil"] ? pmSource.data["PowerDevil"]["Maximum Screen Brightness"] || 0 : 0 | ||
90 | 98 | | |||
91 | property int keyboardBrightness | 99 | property int keyboardBrightness | ||
▲ Show 20 Lines • Show All 163 Lines • Show Last 20 Lines |
Un-capitalize the B