import QtQuick import QtQuick.Layouts import org.kde.plasma.plasmoid import org.kde.kirigami as Kirigami import "./lib/helper.js" as Helper Item { Rectangle { // battery id: container anchors.fill: parent anchors.rightMargin: 1 anchors.topMargin: 10 - batteryheight anchors.bottomMargin: 10 - batteryheight color: "transparent" border.color: Kirigami.Theme.textColor radius: 4 Item { anchors.fill: parent anchors.margins: 2 Rectangle { // battery fill anchors.left: parent.left anchors.top: parent.top anchors.bottom: parent.bottom color: Helper.interpolateColor(batteryPercent / 100, [ colorEmpty, colorHalf, colorFull ]) width: parent.width * Math.max(0, Math.min(batteryPercent, 100)) / 100 } Kirigami.Icon { // headphones icon anchors.bottom: parent.bottom anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter anchors.topMargin: 1 anchors.bottomMargin: 1 source: Helper.batteryIcon(batteryStatus) color: batteryPercent == -1 ? colorFull : Kirigami.Theme.textColor } } } Rectangle { // battery cap anchors.left: container.right anchors.leftMargin: 1 anchors.verticalCenter: parent.verticalCenter radius: 4 height: parent.height / 3 width: 2 color: Kirigami.Theme.textColor } MouseArea { anchors.fill: parent onClicked: { plasmoid.expanded = !plasmoid.expanded } } }