Compare commits

..

No commits in common. "92c931d6aabdb53c5b7b43503dce62257695b869" and "026f9b740aa51ccc9e00082f87aeabc8303477e0" have entirely different histories.

11 changed files with 22 additions and 59 deletions

View File

@ -1,6 +1,6 @@
# Headset Battery Widget
## Install
## Install:
```
git clone https://git.lat/Flummi/headsetcontrol-battery-widget.git
@ -8,9 +8,9 @@ cd headsetcontrol-battery-widget
kpackagetool5 -t Plasma/Applet --install ./package
```
## Uninstall
## Uninstall:
```
cd headsetcontrol-battery-widget
kpackagetool5 -t Plasma/Applet --remove org.kde.plasma.headsetcontrol-battery-widget
kpackagetool5 -t Plasma/Applet --remove ./package
```

BIN
battery.xcf Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -30,12 +30,12 @@ QQC2.Pane {
snapMode: Slider.SnapAlways
Kirigami.FormData.label: i18nc("@label", "polling rate in seconds:")
onMoved: {
pollingratevalue.text = this.value + " seconds";
test.text = this.value + " seconds";
}
}
Text {
id: pollingratevalue
id: test
text: pollingrate.value + " seconds"
color: PlasmaCore.Theme.textColor
}

View File

@ -2,7 +2,6 @@ import QtQuick 2.0
import QtQuick.Layouts 1.3
import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.kirigami 2.14 as Kirigami
Item {
id: main
@ -25,70 +24,34 @@ Item {
Plasmoid.preferredRepresentation: Plasmoid.compactRepresentation
Plasmoid.compactRepresentation: Item {
Layout.minimumWidth: units.iconSizes.large
Layout.alignment: Qt.AlignHCenter
Layout.minimumWidth: units.iconSizes.medium
Rectangle { // battery
id: container
Image {
anchors.fill: parent
anchors.rightMargin: 15
anchors.topMargin: 2
anchors.bottomMargin: 2
color: "transparent"
border.color: PlasmaCore.Theme.textColor
radius: 4
smooth: true
fillMode: Image.PreserveAspectFit
source: batteryIcon()
Plasmoid.toolTipMainText: "battery level: " + batteryLevel()
Plasmoid.toolTipSubText: "polling rate: " + pollingrate + " seconds"
Item {
anchors.fill: parent
anchors.margins: 2
Rectangle { // battery fill
anchors.left: parent.left
anchors.top: parent.top
anchors.bottom: parent.bottom
color: batteryColor()
width: parent.width * Math.max(0, Math.min(batteryPercent, 100)) / 100
}
}
}
Rectangle { // battery cap
anchors.left: container.right
anchors.leftMargin: 1
anchors.verticalCenter: parent.verticalCenter
radius: 4
height: parent.height / 3
width: 2
color: PlasmaCore.Theme.textColor
}
Rectangle { // symbol: headset
anchors.fill: parent
anchors.rightMargin: 23
color: "transparent"
Kirigami.Icon {
anchors.bottom: parent.bottom
anchors.left: parent.right
height: container.height * 0.45
source: "audio-headset-symbolic"
}
}
function batteryColor() {
let color = "red"
function batteryIcon() {
let iconName = "battery_100"
if(batteryPercent == -1) // charging
color = "green";
iconName = "battery_charging"
else if(batteryPercent == -2) // not connected
color = "red";
iconName = "battery_nc";
else if(batteryPercent > 80)
color = "green";
iconName = "battery_100";
else if(batteryPercent > 60)
color = "green";
iconName = "battery_80";
else if(batteryPercent > 40)
color = "yellow";
iconName = "battery_60";
else if(batteryPercent > 20)
color = "red";
return color;
iconName = "battery_40";
else
iconName = "battery_20";
return "../icons/" + iconName + ".png";
}
function batteryLevel() {