[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kde-workspace] plasma/generic/applets/batterymonitor/contents/ui: fix Battery Monitor widget stops
From: Lukas Tinkl <lukas () kde ! org>
Date: 2012-07-09 16:26:53
Message-ID: 20120709162653.F2F6AA60A6 () git ! kde ! org
[Download RAW message or body]
Git commit cbfaa5161731e0789b348c9a6ebe67e10d49b190 by Lukas Tinkl.
Committed on 09/07/2012 at 18:21.
Pushed by lukas into branch 'master'.
fix Battery Monitor widget stops tracking charging state changes after suspend/resume \
cycle
also fix the description to correctly reflect charging/discharging state
BUG: 287952
M +3 -2 plasma/generic/applets/batterymonitor/contents/ui/PopupDialog.qml
M +21 -8 plasma/generic/applets/batterymonitor/contents/ui/batterymonitor.qml
http://commits.kde.org/kde-workspace/cbfaa5161731e0789b348c9a6ebe67e10d49b190
diff --git a/plasma/generic/applets/batterymonitor/contents/ui/PopupDialog.qml \
b/plasma/generic/applets/batterymonitor/contents/ui/PopupDialog.qml index \
4d106d2..dd99ec3 100644
--- a/plasma/generic/applets/batterymonitor/contents/ui/PopupDialog.qml
+++ b/plasma/generic/applets/batterymonitor/contents/ui/PopupDialog.qml
@@ -26,6 +26,7 @@ Item {
height: childrenRect.height+24
property int percent
+ property string batteryState
property bool hasBattery
property bool pluggedIn
property alias screenBrightness: brightnessSlider.value
@@ -65,7 +66,7 @@ Item {
visible: remainingTime.visible
anchors.right: parent.right
}
-
+
Components.Label {
text: i18nc("Label for power management inhibition", "Power management \
enabled:") anchors.right: parent.right
@@ -87,7 +88,7 @@ Item {
}
Components.Label {
- text: dialog.hasBattery ? stringForState(pluggedIn, percent) : \
i18nc("Battery is not plugged in", "Not present") + text: \
dialog.hasBattery ? stringForState(batteryState, percent) : i18nc("Battery is not \
plugged in", "Not present") font.weight: Font.Bold
}
diff --git a/plasma/generic/applets/batterymonitor/contents/ui/batterymonitor.qml \
b/plasma/generic/applets/batterymonitor/contents/ui/batterymonitor.qml index \
412c4b6..72bb8ec 100644
--- a/plasma/generic/applets/batterymonitor/contents/ui/batterymonitor.qml
+++ b/plasma/generic/applets/batterymonitor/contents/ui/batterymonitor.qml
@@ -50,6 +50,7 @@ Item {
property QtObject pmSource: plasmoid.rootItem.pmSource
property bool hasBattery: pmSource.data["Battery"]["Has Battery"]
property int percent: pmSource.data["Battery0"]["Percent"]
+ property string batteryState: pmSource.data["Battery0"]["State"]
property bool pluggedIn: pmSource.data["AC Adapter"]["Plugged in"]
property bool showOverlay: false
@@ -75,7 +76,7 @@ Item {
property real size: Math.min(parent.width, parent.height)
width: size
height: size
-
+
BatteryIcon {
id: batteryIcon
monochrome: true
@@ -119,7 +120,7 @@ Item {
var text="";
text += i18n("<b>Battery:</b>");
text += " ";
- text += hasBattery ? plasmoid.rootItem.stringForState(pluggedIn, \
percent) : i18nc("Battery is not plugged in", "Not present"); + \
text += hasBattery ? plasmoid.rootItem.stringForState(batteryState, percent) : \
i18nc("Battery is not plugged in", "Not present"); text += "<br/>";
text += i18nc("tooltip", "<b>AC Adapter:</b>");
text += " ";
@@ -146,20 +147,32 @@ Item {
}
plasmoid.status = status;
}
+ onSourceAdded: {
+ if (source == "Battery0") {
+ connectSource(source)
+ }
+ }
+ onSourceRemoved: {
+ if (source == "Battery0") {
+ disconnectSource(source)
+ }
+ }
}
- function stringForState(pluggedIn, percent) {
- if (pluggedIn) {
- if (percent<100) return i18n("%1% (charging)", percent);
- else return i18n("%1% (charged)", percent);
- } else {
+ function stringForState(state, percent) {
+ if (state == "Charging")
+ return i18n("%1% (charging)", percent);
+ else if (state == "Discharging")
return i18n("%1% (discharging)", percent);
- }
+ else
+ return i18n("%1% (charged)", percent);
+
}
PopupDialog {
id: dialogItem
percent: pmSource.data["Battery0"]["Percent"]
+ batteryState: pmSource.data["Battery0"]["State"]
hasBattery: pmSource.data["Battery"]["Has Battery"]
pluggedIn: pmSource.data["AC Adapter"]["Plugged in"]
screenBrightness: pmSource.data["PowerDevil"]["Screen Brightness"]
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic