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
@@ -10,11 +10,13 @@ Item {
id: root
required property string iconName
required property double percentage
property int warningThreshold: 100
property bool shown: true
clip: true
visible: width > 0 && height > 0
implicitWidth: resourceRowLayout.x < 0 ? 0 : resourceRowLayout.implicitWidth
implicitHeight: Appearance.sizes.barHeight
property bool warning: percentage * 100 >= warningThreshold
RowLayout {
id: resourceRowLayout
@@ -30,7 +32,8 @@ Item {
lineWidth: Appearance.rounding.unsharpen
value: percentage
implicitSize: 20
colPrimary: Appearance.colors.colOnSecondaryContainer
colPrimary: root.warning ? Appearance.colors.colError : Appearance.colors.colOnSecondaryContainer
accountForLightBleeding: !root.warning
enableAnimation: false
Item {
@@ -1,7 +1,5 @@
import qs.modules.common
import qs.modules.common.widgets
import qs.services
import qs
import QtQuick
import QtQuick.Layouts
@@ -24,6 +22,7 @@ MouseArea {
Resource {
iconName: "memory"
percentage: ResourceUsage.memoryUsedPercentage
warningThreshold: Config.options.bar.resources.memoryWarningThreshold
}
Resource {
@@ -33,6 +32,7 @@ MouseArea {
(MprisController.activePlayer?.trackTitle == null) ||
root.alwaysShowAllResources
Layout.leftMargin: shown ? 6 : 0
warningThreshold: Config.options.bar.resources.swapWarningThreshold
}
Resource {
@@ -42,6 +42,7 @@ MouseArea {
!(MprisController.activePlayer?.trackTitle?.length > 0) ||
root.alwaysShowAllResources
Layout.leftMargin: shown ? 6 : 0
warningThreshold: Config.options.bar.resources.cpuWarningThreshold
}
}