Changeset View
Changeset View
Standalone View
Standalone View
applets/batterymonitor/package/contents/ui/batterymonitor.qml
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | 46 | } else if (pmSource.data["Battery"]["State"] !== "FullyCharged") { | |||
---|---|---|---|---|---|
47 | return PlasmaCore.Types.ActiveStatus | 47 | return PlasmaCore.Types.ActiveStatus | ||
48 | } | 48 | } | ||
49 | } | 49 | } | ||
50 | 50 | | |||
51 | return PlasmaCore.Types.PassiveStatus | 51 | return PlasmaCore.Types.PassiveStatus | ||
52 | } | 52 | } | ||
53 | 53 | | |||
54 | Plasmoid.toolTipMainText: { | 54 | Plasmoid.toolTipMainText: { | ||
55 | if (batteries.count === 0) { | 55 | if (batteries.count === 0 || !pmSource.data["Battery"]["Has Cumulative"]) { | ||
56 | return i18n("No Batteries Available"); | 56 | return plasmoid.title | ||
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… | |||||
57 | } else if (!pmSource.data["Battery"]["Has Cumulative"]) { | | |||
58 | // Bug 362924: Distinguish between no batteries and no power supply batteries | | |||
59 | // just show the generic applet title in the latter case | | |||
60 | return i18n("Battery and Brightness") | | |||
61 | } else if (pmSource.data["Battery"]["State"] === "FullyCharged") { | 57 | } else if (pmSource.data["Battery"]["State"] === "FullyCharged") { | ||
62 | return i18n("Fully Charged"); | 58 | return i18n("Fully Charged"); | ||
63 | } else if (pmSource.data["AC Adapter"] && pmSource.data["AC Adapter"]["Plugged in"]) { | 59 | } | ||
ngraham: Un-capitalize the B | |||||
64 | var percent = pmSource.data.Battery.Percent | 60 | if (pmSource.data["AC Adapter"] && pmSource.data["AC Adapter"]["Plugged in"]) { | ||
65 | var state = pmSource.data.Battery.State | 61 | if (pmSource.data.Battery.State === "NoCharge") { | ||
66 | if (state === "Charging") { | 62 | return i18n("Battery at %1%, not Charging", pmSource.data.Battery.Percent) | ||
ngraham: un-capitalize the R | |||||
ngraham: Un-capitalize the R | |||||
ngraham: Un-capitalize the B | |||||
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 | } | 63 | } | ||
73 | } else { | 64 | } else { | ||
74 | if (remainingTime > 0) { | 65 | return i18n("Battery at %1%", pmSource.data.Battery.Percent); | ||
75 | return i18nc("%1 is remaining time, %2 is percentage", "%1 Remaining (%2%)", | 66 | } | ||
76 | KCoreAddons.Format.formatDuration(remainingTime, KCoreAddons.FormatTypes.HideSeconds), | 67 | } | ||
77 | pmSource.data["Battery"]["Percent"]) | 68 | | ||
69 | Plasmoid.toolTipSubText: { | ||||
70 | var parts = []; | ||||
71 | if (batteries.count === 0) { | ||||
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… | |||||
72 | parts.push("No Batteries Available"); | ||||
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… | |||||
73 | } else if (remainingTime > 0) { | ||||
74 | var remainingTimeString = KCoreAddons.Format.formatDuration(remainingTime, KCoreAddons.FormatTypes.HideSeconds); | ||||
75 | if (pmSource.data["Battery"]["State"] === "FullyCharged") { | ||||
76 | // Don't add anything | ||||
77 | } else if (pmSource.data["AC Adapter"] && pmSource.data["AC Adapter"]["Plugged in"]) { | ||||
78 | parts.push(i18nc("time until fully charged - HH:MM","%1 until fully charged", remainingTimeString)); | ||||
78 | } else { | 79 | } else { | ||
ngraham: This block also needs` if (remainingTime > 0) {` like the one below it | |||||
79 | return i18n("%1% Battery Remaining", pmSource.data["Battery"]["Percent"]); | 80 | parts.push(i18nc("remaining time left of battery usage - HH:MM","%1 remaining", remainingTimeString)); | ||
broulik: Keep the `i18nc` explaining that %1 is remaining time | |||||
80 | } | 81 | } | ||
82 | } else if (pmSource.data.Battery.State === "NoCharge") { | ||||
83 | return i18n("Battery may be damaged") | ||||
broulik: Why this early return? | |||||
84 | } // otherwise, don't add anything | ||||
85 | | ||||
86 | if (powermanagementDisabled) { | ||||
87 | parts.push(i18n("Power management is disabled")); | ||||
ngraham: Un-capitalize the B | |||||
81 | } | 88 | } | ||
89 | return parts.join("\n"); | ||||
broulik: This code path will never be reached | |||||
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 172 Lines • Show Last 20 Lines |
You can probably just return plasmoid.title in the default case.
Also, what's the reason for not showing percentage when power management is disabled? This isn't about the service not running or being a desktop PC, this is true when screens are forced on.