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"); | ||
59 | } | ||||
ngraham: Un-capitalize the B | |||||
60 | if (pmSource.data["AC Adapter"] && pmSource.data["AC Adapter"]["Plugged in"]) { | ||||
61 | if (pmSource.data.Battery.State === "NoCharge") { | ||||
62 | return i18n("Battery at %1%, not Charging", pmSource.data.Battery.Percent) | ||||
ngraham: un-capitalize the R | |||||
ngraham: Un-capitalize the R | |||||
63 | } | ||||
64 | } else { | ||||
65 | return i18n("Battery at %1%", pmSource.data.Battery.Percent); | ||||
66 | } | ||||
67 | } | ||||
68 | | ||||
69 | Plasmoid.toolTipSubText: { | ||||
70 | var parts = []; | ||||
71 | if (batteries.count === 0) { | ||||
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 | ||||
63 | } else if (pmSource.data["AC Adapter"] && pmSource.data["AC Adapter"]["Plugged in"]) { | 77 | } else if (pmSource.data["AC Adapter"] && pmSource.data["AC Adapter"]["Plugged in"]) { | ||
64 | var percent = pmSource.data.Battery.Percent | 78 | parts.push(i18nc("time until fully charged - HH:MM","%1 until fully charged", remainingTimeString)); | ||
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 { | 79 | } else { | ||
71 | return i18n("%1% Plugged in", percent) | 80 | parts.push(i18nc("remaining time left of battery usage - HH:MM","%1 remaining", remainingTimeString)); | ||
ngraham: Un-capitalize the B | |||||
72 | } | 81 | } | ||
73 | } else { | 82 | } else { | ||
74 | if (remainingTime > 0) { | 83 | if (pmSource.data["Battery"]["State"] === "FullyCharged") { | ||
75 | return i18nc("%1 is remaining time, %2 is percentage", "%1 Remaining (%2%)", | 84 | // Don't add anything | ||
76 | KCoreAddons.Format.formatDuration(remainingTime, KCoreAddons.FormatTypes.HideSeconds), | 85 | } else if (pmSource.data.Battery.State === "NoCharge") { | ||
77 | pmSource.data["Battery"]["Percent"]) | 86 | return i18n("Battery may be damaged FIXME") | ||
78 | } else { | 87 | } else { | ||
79 | return i18n("%1% Battery Remaining", pmSource.data["Battery"]["Percent"]); | 88 | parts.push(i18n("Calculating remaining time...")); | ||
broulik: Keep the `i18nc` explaining that %1 is remaining time | |||||
80 | } | 89 | } | ||
ngraham: Un-capitalize the B | |||||
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… | |||||
81 | } | 90 | } | ||
91 | if (powermanagementDisabled) { | ||||
broulik: This code path will never be reached | |||||
broulik: Why this early return? | |||||
92 | parts.push(i18n("Power management is disabled")); | ||||
82 | } | 93 | } | ||
83 | Plasmoid.toolTipSubText: powermanagementDisabled ? i18n("Power management is disabled") : "" | 94 | return parts.join("\n"); | ||
95 | } | ||||
broulik: What in the `else` case? Perhaps at least explicitly `return "";` | |||||
96 | | ||||
84 | Plasmoid.icon: "battery" | 97 | Plasmoid.icon: "battery" | ||
ngraham: This block also needs` if (remainingTime > 0) {` like the one below it | |||||
85 | 98 | | |||
86 | property bool disableBrightnessUpdate: true | 99 | property bool disableBrightnessUpdate: true | ||
87 | 100 | | |||
88 | property int screenBrightness | 101 | property int screenBrightness | ||
89 | readonly property int maximumScreenBrightness: pmSource.data["PowerDevil"] ? pmSource.data["PowerDevil"]["Maximum Screen Brightness"] || 0 : 0 | 102 | readonly property int maximumScreenBrightness: pmSource.data["PowerDevil"] ? pmSource.data["PowerDevil"]["Maximum Screen Brightness"] || 0 : 0 | ||
90 | 103 | | |||
91 | property int keyboardBrightness | 104 | property int keyboardBrightness | ||
92 | readonly property int maximumKeyboardBrightness: pmSource.data["PowerDevil"] ? pmSource.data["PowerDevil"]["Maximum Keyboard Brightness"] || 0 : 0 | 105 | readonly property int maximumKeyboardBrightness: pmSource.data["PowerDevil"] ? pmSource.data["PowerDevil"]["Maximum Keyboard Brightness"] || 0 : 0 | ||
▲ Show 20 Lines • Show All 171 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.