Changeset View
Changeset View
Standalone View
Standalone View
applets/batterymonitor/package/contents/ui/CompactRepresentation.qml
Show All 23 Lines | |||||
24 | import org.kde.plasma.core 2.0 as PlasmaCore | 24 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
25 | import org.kde.plasma.components 2.0 as Components | 25 | import org.kde.plasma.components 2.0 as Components | ||
26 | import org.kde.plasma.workspace.components 2.0 | 26 | import org.kde.plasma.workspace.components 2.0 | ||
27 | 27 | | |||
28 | MouseArea { | 28 | MouseArea { | ||
29 | id: root | 29 | id: root | ||
30 | Layout.minimumWidth: units.iconSizes.small * view.count | 30 | Layout.minimumWidth: units.iconSizes.small * view.count | ||
31 | Layout.minimumHeight: units.iconSizes.small | 31 | Layout.minimumHeight: units.iconSizes.small | ||
32 | hoverEnabled: true | ||||
32 | property real itemSize: Math.min(root.height, root.width/view.count) | 33 | property real itemSize: Math.min(root.height, root.width/view.count) | ||
33 | 34 | | |||
34 | onClicked: plasmoid.expanded = !plasmoid.expanded | 35 | onClicked: plasmoid.expanded = !plasmoid.expanded | ||
35 | 36 | | |||
36 | readonly property bool isConstrained: plasmoid.formFactor === PlasmaCore.Types.Vertical || plasmoid.formFactor === PlasmaCore.Types.Horizontal | 37 | readonly property bool isConstrained: plasmoid.formFactor === PlasmaCore.Types.Vertical || plasmoid.formFactor === PlasmaCore.Types.Horizontal | ||
37 | 38 | | |||
38 | //Should we consider turning this into a Flow item? | 39 | //Should we consider turning this into a Flow item? | ||
39 | Row { | 40 | Row { | ||
Show All 13 Lines | 50 | Item { | |||
53 | property int percent: view.singleBattery ? pmSource.data["Battery"]["Percent"] : model["Percent"] | 54 | property int percent: view.singleBattery ? pmSource.data["Battery"]["Percent"] : model["Percent"] | ||
54 | property bool pluggedIn: pmSource.data["AC Adapter"] && pmSource.data["AC Adapter"]["Plugged in"] && (view.singleBattery || model["Is Power Supply"]) | 55 | property bool pluggedIn: pmSource.data["AC Adapter"] && pmSource.data["AC Adapter"]["Plugged in"] && (view.singleBattery || model["Is Power Supply"]) | ||
55 | 56 | | |||
56 | height: root.itemSize | 57 | height: root.itemSize | ||
57 | width: root.width/view.count | 58 | width: root.width/view.count | ||
58 | 59 | | |||
59 | property real iconSize: Math.min(width, height) | 60 | property real iconSize: Math.min(width, height) | ||
60 | 61 | | |||
62 | Item { | ||||
63 | id: batteryItem | ||||
64 | | ||||
65 | anchors.fill: batteryContainer | ||||
66 | | ||||
61 | BatteryIcon { | 67 | BatteryIcon { | ||
62 | id: batteryIcon | 68 | id: batteryIcon | ||
63 | anchors.centerIn: parent | 69 | anchors.centerIn: parent | ||
64 | hasBattery: batteryContainer.hasBattery | 70 | hasBattery: batteryContainer.hasBattery | ||
65 | percent: batteryContainer.percent | 71 | percent: batteryContainer.percent | ||
66 | pluggedIn: batteryContainer.pluggedIn | 72 | pluggedIn: batteryContainer.pluggedIn | ||
67 | height: isConstrained ? batteryContainer.iconSize : batteryContainer.iconSize - batteryLabel.height | 73 | height: batteryContainer.iconSize | ||
kmaterka: `batteryLabel` does not exist anymore, it was replaced by `BadgeOverlay` | |||||
68 | width: height | 74 | width: height | ||
69 | } | 75 | } | ||
70 | 76 | | |||
71 | BadgeOverlay { | 77 | BadgeOverlay { | ||
72 | anchors.fill: batteryIcon | 78 | anchors.fill: batteryIcon | ||
73 | text: batteryContainer.hasBattery ? i18nc("battery percentage below battery icon", "%1%", percent) : i18nc("short symbol to signal there is no battery currently available", "-") | 79 | text: batteryContainer.hasBattery ? i18nc("battery percentage below battery icon", "%1%", percent) : i18nc("short symbol to signal there is no battery currently available", "-") | ||
74 | icon: batteryIcon | 80 | icon: batteryIcon | ||
75 | visible: plasmoid.configuration.showPercentage | 81 | visible: plasmoid.configuration.showPercentage | ||
76 | } | 82 | } | ||
77 | } | 83 | } | ||
84 | | ||||
85 | IconEffects { | ||||
86 | source: batteryItem | ||||
kmaterka: Must be a sibling | |||||
87 | iconActive: root.containsMouse | ||||
Is it a good candidate for a component? It can be reused in Notifications applet. kmaterka: Is it a good candidate for a component? It can be reused in Notifications applet. | |||||
88 | } | ||||
0.7 is from KIconEffect::init(). Theoretically it can be overwritten by kglobalconfig: ["DesktopIcons"]["ActiveEffect"]["value"], but I looked and found no usage of this config parameter. kmaterka: 0.7 is from [[ https://phabricator.kde.org/source/kiconthemes/browse/master/src/kiconeffect.cpp… | |||||
89 | } | ||||
78 | } | 90 | } | ||
79 | } | 91 | } | ||
80 | } | 92 | } |
batteryLabel does not exist anymore, it was replaced by BadgeOverlay