bring back config

This commit is contained in:
Flummi 2024-06-07 02:05:50 +02:00
parent b2e7b948fe
commit 6e47175625
Signed by: Flummi
GPG Key ID: AA2AEF822A6F4817
5 changed files with 222 additions and 225 deletions

View File

@ -7,4 +7,9 @@ ConfigModel {
icon: "configure" icon: "configure"
source: "config/general.qml" source: "config/general.qml"
} }
ConfigCategory {
name: i18n("Debug")
icon: "cab_view"
source: "config/debug.qml"
}
} }

View File

@ -1,212 +0,0 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import org.kde.plasma.core as PlasmaCore
import org.kde.plasma.components as PlasmaComponents
import org.kde.kirigami as Kirigami
import org.kde.kquickcontrols as KQControls
import org.kde.kcmutils as KCM
import "../lib/helper.js" as Helper
KCM.SimpleKCM {
id: root
/*property alias cfg_pollingrate: pollingrate.value
property alias cfg_batteryheight: batteryheight.value
property alias cfg_colorEmpty: colorEmpty.color
property alias cfg_colorHalf: colorHalf.color
property alias cfg_colorFull: colorFull.color
property alias cfg_notifications: notifications.checked
property alias cfg_batteryThreshold: batteryThreshold.value*/
Kirigami.FormLayout {
Slider {
from: 2
to: 60
stepSize: 2
KCM.SettingStateBinding {
configObject: KCM.plasmaSettings
settingName: "pollingrate"
}
}
}
/*Kirigami.FormLayout {
anchors.fill: parent
wideMode: false
GridLayout {
columns: 3
rows: 2
rowSpacing: 10
// first row
Text {
text: "polling rate:"
color: PlasmaCore.Theme.textColor
}
Slider {
id: pollingrate
value: 10
from: 2
to: 60
stepSize: 2
}
Text {
text: cfg_pollingrate + " seconds"
color: PlasmaCore.Theme.textColor
}
// second row
Text {
text: "battery height:"
color: PlasmaCore.Theme.textColor
}
Slider {
id: batteryheight
value: 8.0
from: 1
to: 10
stepSize: 1
}
Text {
text: cfg_batteryheight
color: PlasmaCore.Theme.textColor
}
}
// color config
GridLayout {
columns: 3
rows: 3
rowSpacing: 1
// first row
Text {
text: "empty:"
color: PlasmaCore.Theme.textColor
}
KQControls.ColorButton {
id: colorEmpty
color: cfg_colorEmpty
}
Text {
text: cfg_colorEmpty
color: PlasmaCore.Theme.textColor
}
// secod row
Text {
text: "half:"
color: PlasmaCore.Theme.textColor
}
KQControls.ColorButton {
id: colorHalf
color: cfg_colorHalf
}
Text {
text: cfg_colorHalf
color: PlasmaCore.Theme.textColor
}
// third row
Text {
text: "full:"
color: PlasmaCore.Theme.textColor
}
KQControls.ColorButton {
id: colorFull
color: cfg_colorFull
}
Text {
text: cfg_colorFull
color: PlasmaCore.Theme.textColor
}
}
// color gradient example
GridLayout {
columns: 10
rows: 1
rowSpacing: 0
Text {
text: "█"
color: Helper.interpolateColor(.1, [ cfg_colorEmpty.toString(), cfg_colorHalf.toString(), cfg_colorFull.toString() ])
}
Text {
text: "█"
color: Helper.interpolateColor(.2, [ cfg_colorEmpty.toString(), cfg_colorHalf.toString(), cfg_colorFull.toString() ])
}
Text {
text: "█"
color: Helper.interpolateColor(.3, [ cfg_colorEmpty.toString(), cfg_colorHalf.toString(), cfg_colorFull.toString() ])
}
Text {
text: "█"
color: Helper.interpolateColor(.4, [ cfg_colorEmpty.toString(), cfg_colorHalf.toString(), cfg_colorFull.toString() ])
}
Text {
text: "█"
color: Helper.interpolateColor(.5, [ cfg_colorEmpty.toString(), cfg_colorHalf.toString(), cfg_colorFull.toString() ])
}
Text {
text: "█"
color: Helper.interpolateColor(.6, [ cfg_colorEmpty.toString(), cfg_colorHalf.toString(), cfg_colorFull.toString() ])
}
Text {
text: "█"
color: Helper.interpolateColor(.7, [ cfg_colorEmpty.toString(), cfg_colorHalf.toString(), cfg_colorFull.toString() ])
}
Text {
text: "█"
color: Helper.interpolateColor(.8, [ cfg_colorEmpty.toString(), cfg_colorHalf.toString(), cfg_colorFull.toString() ])
}
Text {
text: "█"
color: Helper.interpolateColor(.9, [ cfg_colorEmpty.toString(), cfg_colorHalf.toString(), cfg_colorFull.toString() ])
}
Text {
text: "█"
color: Helper.interpolateColor( 1, [ cfg_colorEmpty.toString(), cfg_colorHalf.toString(), cfg_colorFull.toString() ])
}
}
GridLayout {
columns: 3
rows: 2
rowSpacing: 10
// first row
Text {
text: "notifications:"
color: PlasmaCore.Theme.textColor
}
PlasmaComponents.CheckBox {
id: notifications
}
Text {
text: ""
}
// second row
Text {
text: "battery threshold:"
color: PlasmaCore.Theme.textColor
}
Slider {
id: batteryThreshold
value: 10
from: 1
to: 50
stepSize: 1
}
Text {
text: cfg_batteryThreshold
color: PlasmaCore.Theme.textColor
}
}
}*/
}

View File

@ -1,6 +1,6 @@
import QtQuick 2.0 import QtQuick
import QtQuick.Controls 2.5 import QtQuick.Controls
import QtQuick.Layouts 1.15 import QtQuick.Layouts
import org.kde.plasma.core as PlasmaCore import org.kde.plasma.core as PlasmaCore
import org.kde.plasma.components as PlasmaComponents import org.kde.plasma.components as PlasmaComponents
import org.kde.kirigami as Kirigami import org.kde.kirigami as Kirigami
@ -15,6 +15,25 @@ KCM.SimpleKCM {
property alias cfg_debug_active: debug_active.checked property alias cfg_debug_active: debug_active.checked
property alias cfg_debug_charge: debug_charge.value property alias cfg_debug_charge: debug_charge.value
property bool debug_activeDefault
property int debug_chargeDefault
property int cfg_pollingrate
property int cfg_batteryheight
property string cfg_colorEmpty
property string cfg_colorHalf
property string cfg_colorFull
property bool cfg_notifications
property int cfg_batteryThreshold
property int cfg_pollingrateDefault
property int cfg_batteryheightDefault
property string cfg_colorEmptyDefault
property string cfg_colorHalfDefault
property string cfg_colorFullDefault
property bool cfg_notificationsDefault
property int cfg_batteryThresholdDefault
Kirigami.FormLayout { Kirigami.FormLayout {
anchors.fill: parent anchors.fill: parent
wideMode: false wideMode: false
@ -44,7 +63,7 @@ KCM.SimpleKCM {
Slider { Slider {
id: debug_charge id: debug_charge
value: 0 value: 0
from: -2 from: 0
to: 100 to: 100
stepSize: 1 stepSize: 1
} }

View File

@ -2,10 +2,10 @@ import QtQuick
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
import org.kde.plasma.core as PlasmaCore import org.kde.plasma.core as PlasmaCore
import org.kde.plasma.components as PlasmaComponents
import org.kde.kirigami as Kirigami import org.kde.kirigami as Kirigami
import org.kde.kquickcontrols as KQControls import org.kde.kquickcontrols as KQControls
import org.kde.kcmutils as KCM import org.kde.kcmutils as KCM
import org.kde.plasma.components as PlasmaComponents3
import "../lib/helper.js" as Helper import "../lib/helper.js" as Helper
@ -13,15 +13,200 @@ KCM.SimpleKCM {
id: root id: root
property alias cfg_pollingrate: pollingrate.value property alias cfg_pollingrate: pollingrate.value
property alias cfg_pollingrateDefault: pollingrate.value property alias cfg_batteryheight: batteryheight.value
property alias cfg_colorEmpty: colorEmpty.color
property alias cfg_colorHalf: colorHalf.color
property alias cfg_colorFull: colorFull.color
property alias cfg_notifications: notifications.checked
property alias cfg_batteryThreshold: batteryThreshold.value
property int cfg_pollingrateDefault
property int cfg_batteryheightDefault
property string cfg_colorEmptyDefault
property string cfg_colorHalfDefault
property string cfg_colorFullDefault
property bool cfg_notificationsDefault
property int cfg_batteryThresholdDefault
property bool cfg_debug_active
property int cfg_debug_charge
property bool cfg_debug_activeDefault
property int cfg_debug_chargeDefault
Kirigami.FormLayout { Kirigami.FormLayout {
anchors.fill: parent
wideMode: false
GridLayout {
columns: 3
rows: 2
rowSpacing: 10
// first row
Text {
text: "polling rate:"
color: PlasmaCore.Theme.textColor
}
Slider { Slider {
id: pollingrate id: pollingrate
Layout.fillWidth: true value: 10
from: 2 from: 2
to: 60 to: 60
stepSize: 2 stepSize: 2
} }
Text {
text: cfg_pollingrate + " seconds"
color: PlasmaCore.Theme.textColor
}
// second row
Text {
text: "battery height:"
color: PlasmaCore.Theme.textColor
}
Slider {
id: batteryheight
value: 8.0
from: 1
to: 10
stepSize: 1
}
Text {
text: cfg_batteryheight
color: PlasmaCore.Theme.textColor
}
}
// color config
GridLayout {
columns: 3
rows: 3
rowSpacing: 1
// first row
Text {
text: "empty:"
color: PlasmaCore.Theme.textColor
}
KQControls.ColorButton {
id: colorEmpty
color: cfg_colorEmpty
}
Text {
text: cfg_colorEmpty
color: PlasmaCore.Theme.textColor
}
// secod row
Text {
text: "half:"
color: PlasmaCore.Theme.textColor
}
KQControls.ColorButton {
id: colorHalf
color: cfg_colorHalf
}
Text {
text: cfg_colorHalf
color: PlasmaCore.Theme.textColor
}
// third row
Text {
text: "full:"
color: PlasmaCore.Theme.textColor
}
KQControls.ColorButton {
id: colorFull
color: cfg_colorFull
}
Text {
text: cfg_colorFull
color: PlasmaCore.Theme.textColor
}
}
// color gradient example
GridLayout {
columns: 10
rows: 1
rowSpacing: 0
Text {
text: "█"
color: Helper.interpolateColor(.1, [ cfg_colorEmpty.toString(), cfg_colorHalf.toString(), cfg_colorFull.toString() ])
}
Text {
text: "█"
color: Helper.interpolateColor(.2, [ cfg_colorEmpty.toString(), cfg_colorHalf.toString(), cfg_colorFull.toString() ])
}
Text {
text: "█"
color: Helper.interpolateColor(.3, [ cfg_colorEmpty.toString(), cfg_colorHalf.toString(), cfg_colorFull.toString() ])
}
Text {
text: "█"
color: Helper.interpolateColor(.4, [ cfg_colorEmpty.toString(), cfg_colorHalf.toString(), cfg_colorFull.toString() ])
}
Text {
text: "█"
color: Helper.interpolateColor(.5, [ cfg_colorEmpty.toString(), cfg_colorHalf.toString(), cfg_colorFull.toString() ])
}
Text {
text: "█"
color: Helper.interpolateColor(.6, [ cfg_colorEmpty.toString(), cfg_colorHalf.toString(), cfg_colorFull.toString() ])
}
Text {
text: "█"
color: Helper.interpolateColor(.7, [ cfg_colorEmpty.toString(), cfg_colorHalf.toString(), cfg_colorFull.toString() ])
}
Text {
text: "█"
color: Helper.interpolateColor(.8, [ cfg_colorEmpty.toString(), cfg_colorHalf.toString(), cfg_colorFull.toString() ])
}
Text {
text: "█"
color: Helper.interpolateColor(.9, [ cfg_colorEmpty.toString(), cfg_colorHalf.toString(), cfg_colorFull.toString() ])
}
Text {
text: "█"
color: Helper.interpolateColor( 1, [ cfg_colorEmpty.toString(), cfg_colorHalf.toString(), cfg_colorFull.toString() ])
}
}
GridLayout {
columns: 3
rows: 2
rowSpacing: 10
// first row
Text {
text: "notifications:"
color: PlasmaCore.Theme.textColor
}
PlasmaComponents.CheckBox {
id: notifications
}
Text {
text: ""
}
// second row
Text {
text: "battery threshold:"
color: PlasmaCore.Theme.textColor
}
Slider {
id: batteryThreshold
value: 10
from: 1
to: 50
stepSize: 1
}
Text {
text: cfg_batteryThreshold
color: PlasmaCore.Theme.textColor
}
}
} }
} }

View File

@ -34,8 +34,8 @@ PlasmoidItem {
interval: pollingrate * 1e3 interval: pollingrate * 1e3
onNewData: (_, data) => { onNewData: (_, data) => {
const res = JSON.parse(data.stdout); const res = JSON.parse(data.stdout);
batteryStatus = res.devices[0].battery.status;
batteryPercent = res.devices[0].battery.level; batteryPercent = res.devices[0].battery.level;
batteryStatus = batteryPercent > 0 ? res.devices[0].battery.status : "BATTERY_UNAVAILABLE";
if(debug_active) { if(debug_active) {
batteryStatus = "BATTERY_AVAILABLE"; batteryStatus = "BATTERY_AVAILABLE";