From 96c750b2bb3c2a82bd01ff0db6820697901581e1 Mon Sep 17 00:00:00 2001 From: Sighthesia Date: Fri, 14 Nov 2025 21:32:41 +0800 Subject: [PATCH] SystemMonitorCard: apply threshold highlight for mertrics in control center --- .../Panels/ControlCenter/Cards/SystemMonitorCard.qml | 12 ++++++++++++ Widgets/NCircleStat.qml | 7 ++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Modules/Panels/ControlCenter/Cards/SystemMonitorCard.qml b/Modules/Panels/ControlCenter/Cards/SystemMonitorCard.qml index 2aa62105..d82bbbe4 100644 --- a/Modules/Panels/ControlCenter/Cards/SystemMonitorCard.qml +++ b/Modules/Panels/ControlCenter/Cards/SystemMonitorCard.qml @@ -27,6 +27,9 @@ NBox { contentScale: 0.8 height: content.widgetHeight Layout.alignment: Qt.AlignHCenter + // Highlight color based on thresholds + fillColor: (SystemStatService.cpuUsage > Settings.data.systemMonitor.cpuCriticalThreshold)? (Settings.data.systemMonitor.useCustomColors ? (Settings.data.systemMonitor.criticalColor || Color.mError) : Color.mError): (SystemStatService.cpuUsage > Settings.data.systemMonitor.cpuWarningThreshold)? (Settings.data.systemMonitor.useCustomColors ? (Settings.data.systemMonitor.warningColor || Color.mTertiary) : Color.mTertiary): Color.mPrimary + textColor: (SystemStatService.cpuUsage > Settings.data.systemMonitor.cpuCriticalThreshold)? Color.mSurfaceVariant: (SystemStatService.cpuUsage > Settings.data.systemMonitor.cpuWarningThreshold)? Color.mSurfaceVariant: Color.mOnSurface } NCircleStat { value: SystemStatService.cpuTemp @@ -36,6 +39,9 @@ NBox { contentScale: 0.8 height: content.widgetHeight Layout.alignment: Qt.AlignHCenter + // Highlight color based on thresholds + fillColor: (SystemStatService.cpuTemp > Settings.data.systemMonitor.tempCriticalThreshold)? (Settings.data.systemMonitor.useCustomColors ? (Settings.data.systemMonitor.criticalColor || Color.mError) : Color.mError): (SystemStatService.cpuTemp > Settings.data.systemMonitor.tempWarningThreshold)? (Settings.data.systemMonitor.useCustomColors ? (Settings.data.systemMonitor.warningColor || Color.mTertiary) : Color.mTertiary): Color.mPrimary + textColor: (SystemStatService.cpuTemp > Settings.data.systemMonitor.tempCriticalThreshold)? Color.mSurfaceVariant: (SystemStatService.cpuTemp > Settings.data.systemMonitor.tempWarningThreshold)? Color.mSurfaceVariant: Color.mOnSurface } NCircleStat { value: SystemStatService.memPercent @@ -44,6 +50,9 @@ NBox { contentScale: 0.8 height: content.widgetHeight Layout.alignment: Qt.AlignHCenter + // Highlight color based on thresholds + fillColor: (SystemStatService.memPercent > Settings.data.systemMonitor.memCriticalThreshold)? (Settings.data.systemMonitor.useCustomColors ? (Settings.data.systemMonitor.criticalColor || Color.mError) : Color.mError): (SystemStatService.memPercent > Settings.data.systemMonitor.memWarningThreshold)? (Settings.data.systemMonitor.useCustomColors ? (Settings.data.systemMonitor.warningColor || Color.mTertiary) : Color.mTertiary): Color.mPrimary + textColor: (SystemStatService.memPercent > Settings.data.systemMonitor.memCriticalThreshold)? Color.mSurfaceVariant: (SystemStatService.memPercent > Settings.data.systemMonitor.memWarningThreshold)? Color.mSurfaceVariant: Color.mOnSurface } NCircleStat { value: SystemStatService.diskPercents["/"] ?? 0 @@ -52,6 +61,9 @@ NBox { contentScale: 0.8 height: content.widgetHeight Layout.alignment: Qt.AlignHCenter + // Highlight color based on thresholds + fillColor: ( (SystemStatService.diskPercents["/"] ?? 0) > Settings.data.systemMonitor.diskCriticalThreshold)? (Settings.data.systemMonitor.useCustomColors ? (Settings.data.systemMonitor.criticalColor || Color.mError) : Color.mError): ( (SystemStatService.diskPercents["/"] ?? 0) > Settings.data.systemMonitor.diskWarningThreshold)? (Settings.data.systemMonitor.useCustomColors ? (Settings.data.systemMonitor.warningColor || Color.mTertiary) : Color.mTertiary): Color.mPrimary + textColor: ((SystemStatService.diskPercents["/"] ?? 0) > Settings.data.systemMonitor.diskCriticalThreshold)? Color.mSurfaceVariant: ((SystemStatService.diskPercents["/"] ?? 0) > Settings.data.systemMonitor.diskWarningThreshold)? Color.mSurfaceVariant: Color.mOnSurface } } } diff --git a/Widgets/NCircleStat.qml b/Widgets/NCircleStat.qml index a8c2a059..ade9e360 100644 --- a/Widgets/NCircleStat.qml +++ b/Widgets/NCircleStat.qml @@ -16,7 +16,8 @@ Rectangle { // outer width/height footprint of the component property real contentScale: 1.0 - readonly property color fillColor: Color.mPrimary + property color fillColor: Color.mPrimary + property color textColor: Color.mOnSurface width: 68 height: 92 @@ -118,7 +119,7 @@ Rectangle { text: `${Math.round(root.value)}${root.suffix}` pointSize: Style.fontSizeM * contentScale * 0.9 font.weight: Style.fontWeightBold - color: Color.mOnSurface + color: root.fillColor horizontalAlignment: Text.AlignHCenter } @@ -128,7 +129,7 @@ Rectangle { anchors.top: valueLabel.bottom anchors.topMargin: 8 * contentScale icon: root.icon - color: Color.mPrimary + color: root.fillColor pointSize: Style.fontSizeM horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter