Changeset View
Changeset View
Standalone View
Standalone View
applets/batterymonitor/package/contents/ui/CompactRepresentation.qml
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | 50 | Item { | |||
---|---|---|---|---|---|
54 | property int percent: view.singleBattery ? pmSource.data["Battery"]["Percent"] : model["Percent"] | 54 | property int percent: view.singleBattery ? pmSource.data["Battery"]["Percent"] : model["Percent"] | ||
55 | 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"]) | ||
56 | 56 | | |||
57 | height: root.itemSize | 57 | height: root.itemSize | ||
58 | width: root.width/view.count | 58 | width: root.width/view.count | ||
59 | 59 | | |||
60 | property real iconSize: Math.min(width, height) | 60 | property real iconSize: Math.min(width, height) | ||
61 | 61 | | |||
62 | Column { | | |||
63 | anchors.centerIn: parent | | |||
64 | | ||||
65 | BatteryIcon { | 62 | BatteryIcon { | ||
66 | id: batteryIcon | 63 | id: batteryIcon | ||
67 | anchors.horizontalCenter: isConstrained ? undefined : parent.horizontalCenter | 64 | anchors.centerIn: parent | ||
68 | hasBattery: batteryContainer.hasBattery | 65 | hasBattery: batteryContainer.hasBattery | ||
69 | percent: batteryContainer.percent | 66 | percent: batteryContainer.percent | ||
70 | pluggedIn: batteryContainer.pluggedIn | 67 | pluggedIn: batteryContainer.pluggedIn | ||
71 | height: isConstrained ? batteryContainer.iconSize : batteryContainer.iconSize - batteryLabel.height | 68 | height: isConstrained ? batteryContainer.iconSize : batteryContainer.iconSize - batteryLabel.height | ||
72 | width: height | 69 | width: height | ||
73 | } | 70 | } | ||
74 | 71 | | |||
75 | Components.Label { | 72 | BadgeOverlay { | ||
broulik: for fonts avoid vertically anchoring it, use verticalAlignment instead to ensure descenders are… | |||||
Can you instead try an OpacityMask / ShaderEffect thing like I did in task manager for the badge so we actually cut out a piece of the icon instead of just overlaying an opaque rectangle? broulik: Can you instead try an OpacityMask / ShaderEffect thing like I did in task manager for the… | |||||
mart: sure | |||||
76 | id: batteryLabel | 73 | anchors.fill: batteryIcon | ||
77 | width: parent.width | | |||
78 | height: visible ? paintedHeight : 0 | | |||
79 | horizontalAlignment: Text.AlignHCenter | | |||
80 | text: i18nc("battery percentage below battery icon", "%1%", percent) | 74 | text: i18nc("battery percentage below battery icon", "%1%", percent) | ||
81 | font.pixelSize: Math.max(batteryContainer.iconSize/8, theme.mSize(theme.smallestFont).height) | 75 | icon: batteryIcon | ||
82 | visible: false//!isConstrained() | 76 | visible: plasmoid.configuration.showPercentage | ||
83 | } | | |||
84 | } | 77 | } | ||
85 | } | 78 | } | ||
86 | } | 79 | } | ||
87 | } | 80 | } | ||
88 | } | 81 | } |
for fonts avoid vertically anchoring it, use verticalAlignment instead to ensure descenders are properly taken into account