bar: warning for high resource usage

This commit is contained in:
end-4
2025-08-26 09:15:59 +07:00
parent 376f2bfeb1
commit 63b7a3a36c
6 changed files with 22 additions and 13 deletions
@@ -1,29 +1,27 @@
import qs
import qs.modules.common
import qs.modules.common.functions
import qs.modules.common.widgets
import qs.services
import QtQuick
import QtQuick.Layouts
import Quickshell
Item {
id: root
required property string iconName
required property double percentage
property int warningThreshold: 100
implicitHeight: resourceProgress.implicitHeight
implicitWidth: Appearance.sizes.verticalBarWidth
// Helper function to format KB to GB
function formatKB(kb) {
return (kb / (1024 * 1024)).toFixed(1) + " GB";
}
property bool warning: percentage * 100 >= warningThreshold
ClippedFilledCircularProgress {
id: resourceProgress
anchors.centerIn: parent
value: percentage
enableAnimation: false
colPrimary: root.warning ? Appearance.colors.colError : Appearance.colors.colOnSecondaryContainer
accountForLightBleeding: !root.warning
MaterialSymbol {
font.weight: Font.Medium
fill: 1
@@ -40,5 +38,4 @@ Item {
acceptedButtons: Qt.NoButton
enabled: root.visible
}
}
@@ -1,4 +1,5 @@
import qs.services
import qs.modules.common
import QtQuick
import QtQuick.Layouts
import "../bar" as Bar
@@ -19,18 +20,21 @@ MouseArea {
Layout.alignment: Qt.AlignHCenter
iconName: "memory"
percentage: ResourceUsage.memoryUsedPercentage
warningThreshold: Config.options.bar.resources.memoryWarningThreshold
}
Resource {
Layout.alignment: Qt.AlignHCenter
iconName: "swap_horiz"
percentage: ResourceUsage.swapUsedPercentage
warningThreshold: Config.options.bar.resources.swapWarningThreshold
}
Resource {
Layout.alignment: Qt.AlignHCenter
iconName: "planner_review"
percentage: ResourceUsage.cpuUsage
warningThreshold: Config.options.bar.resources.cpuWarningThreshold
}
}