diff --git a/Modules/Bar/Widgets/SystemMonitor.qml b/Modules/Bar/Widgets/SystemMonitor.qml index 05575a0f..d3b9fe8e 100644 --- a/Modules/Bar/Widgets/SystemMonitor.qml +++ b/Modules/Bar/Widgets/SystemMonitor.qml @@ -52,13 +52,25 @@ Rectangle { readonly property int memTextWidth: Math.ceil(memMetrics.boundingRect.width + 3) readonly property color textColor: usePrimaryColor ? Color.mPrimary : Color.mOnSurface + // Threshold settings from widget configuration + readonly property int cpuWarningThreshold: (widgetSettings.cpuWarningThreshold !== undefined) ? widgetSettings.cpuWarningThreshold : widgetMetadata.cpuWarningThreshold + readonly property int cpuCriticalThreshold: (widgetSettings.cpuCriticalThreshold !== undefined) ? widgetSettings.cpuCriticalThreshold : widgetMetadata.cpuCriticalThreshold + readonly property int tempWarningThreshold: (widgetSettings.tempWarningThreshold !== undefined) ? widgetSettings.tempWarningThreshold : widgetMetadata.tempWarningThreshold + readonly property int tempCriticalThreshold: (widgetSettings.tempCriticalThreshold !== undefined) ? widgetSettings.tempCriticalThreshold : widgetMetadata.tempCriticalThreshold + readonly property int memWarningThreshold: (widgetSettings.memWarningThreshold !== undefined) ? widgetSettings.memWarningThreshold : widgetMetadata.memWarningThreshold + readonly property int memCriticalThreshold: (widgetSettings.memCriticalThreshold !== undefined) ? widgetSettings.memCriticalThreshold : widgetMetadata.memCriticalThreshold + readonly property int diskWarningThreshold: (widgetSettings.diskWarningThreshold !== undefined) ? widgetSettings.diskWarningThreshold : widgetMetadata.diskWarningThreshold + readonly property int diskCriticalThreshold: (widgetSettings.diskCriticalThreshold !== undefined) ? widgetSettings.diskCriticalThreshold : widgetMetadata.diskCriticalThreshold + // Warning threshold calculation properties - readonly property bool cpuWarning: showCpuUsage && SystemStatService.cpuUsage > 80 - readonly property bool cpuCritical: showCpuUsage && SystemStatService.cpuUsage > 90 - readonly property bool tempWarning: showCpuTemp && SystemStatService.cpuTemp > 80 - readonly property bool tempCritical: showCpuTemp && SystemStatService.cpuTemp > 90 - readonly property bool memWarning: showMemoryUsage && SystemStatService.memPercent > 80 - readonly property bool memCritical: showMemoryUsage && SystemStatService.memPercent > 90 + readonly property bool cpuWarning: showCpuUsage && SystemStatService.cpuUsage > cpuWarningThreshold + readonly property bool cpuCritical: showCpuUsage && SystemStatService.cpuUsage > cpuCriticalThreshold + readonly property bool tempWarning: showCpuTemp && SystemStatService.cpuTemp > tempWarningThreshold + readonly property bool tempCritical: showCpuTemp && SystemStatService.cpuTemp > tempCriticalThreshold + readonly property bool memWarning: showMemoryUsage && SystemStatService.memPercent > memWarningThreshold + readonly property bool memCritical: showMemoryUsage && SystemStatService.memPercent > memCriticalThreshold + readonly property bool diskWarning: showDiskUsage && SystemStatService.diskPercents["/"] > diskWarningThreshold + readonly property bool diskCritical: showDiskUsage && SystemStatService.diskPercents["/"] > diskCriticalThreshold TextMetrics { id: percentMetrics diff --git a/Modules/Panels/Settings/Bar/WidgetSettings/SystemMonitorSettings.qml b/Modules/Panels/Settings/Bar/WidgetSettings/SystemMonitorSettings.qml index 9ca62f78..caad8b03 100644 --- a/Modules/Panels/Settings/Bar/WidgetSettings/SystemMonitorSettings.qml +++ b/Modules/Panels/Settings/Bar/WidgetSettings/SystemMonitorSettings.qml @@ -21,6 +21,16 @@ ColumnLayout { property bool valueShowNetworkStats: widgetData.showNetworkStats !== undefined ? widgetData.showNetworkStats : widgetMetadata.showNetworkStats property bool valueShowDiskUsage: widgetData.showDiskUsage !== undefined ? widgetData.showDiskUsage : widgetMetadata.showDiskUsage + // Threshold settings + property int valueCpuWarningThreshold: widgetData.cpuWarningThreshold !== undefined ? widgetData.cpuWarningThreshold : widgetMetadata.cpuWarningThreshold + property int valueCpuCriticalThreshold: widgetData.cpuCriticalThreshold !== undefined ? widgetData.cpuCriticalThreshold : widgetMetadata.cpuCriticalThreshold + property int valueTempWarningThreshold: widgetData.tempWarningThreshold !== undefined ? widgetData.tempWarningThreshold : widgetMetadata.tempWarningThreshold + property int valueTempCriticalThreshold: widgetData.tempCriticalThreshold !== undefined ? widgetData.tempCriticalThreshold : widgetMetadata.tempCriticalThreshold + property int valueMemWarningThreshold: widgetData.memWarningThreshold !== undefined ? widgetData.memWarningThreshold : widgetMetadata.memWarningThreshold + property int valueMemCriticalThreshold: widgetData.memCriticalThreshold !== undefined ? widgetData.memCriticalThreshold : widgetMetadata.memCriticalThreshold + property int valueDiskWarningThreshold: widgetData.diskWarningThreshold !== undefined ? widgetData.diskWarningThreshold : widgetMetadata.diskWarningThreshold + property int valueDiskCriticalThreshold: widgetData.diskCriticalThreshold !== undefined ? widgetData.diskCriticalThreshold : widgetMetadata.diskCriticalThreshold + function saveSettings() { var settings = Object.assign({}, widgetData || {}) settings.usePrimaryColor = valueUsePrimaryColor @@ -30,6 +40,14 @@ ColumnLayout { settings.showMemoryAsPercent = valueShowMemoryAsPercent settings.showNetworkStats = valueShowNetworkStats settings.showDiskUsage = valueShowDiskUsage + settings.cpuWarningThreshold = valueCpuWarningThreshold + settings.cpuCriticalThreshold = valueCpuCriticalThreshold + settings.tempWarningThreshold = valueTempWarningThreshold + settings.tempCriticalThreshold = valueTempCriticalThreshold + settings.memWarningThreshold = valueMemWarningThreshold + settings.memCriticalThreshold = valueMemCriticalThreshold + settings.diskWarningThreshold = valueDiskWarningThreshold + settings.diskCriticalThreshold = valueDiskCriticalThreshold return settings } @@ -95,4 +113,214 @@ ColumnLayout { checked: valueShowDiskUsage onToggled: checked => valueShowDiskUsage = checked } + + NDivider { + Layout.fillWidth: true + Layout.topMargin: Style.marginM + Layout.bottomMargin: Style.marginM + } + + NHeader { + Layout.fillWidth: true + label: I18n.tr("bar.widget-settings.system-monitor.thresholds.header") + description: I18n.tr("bar.widget-settings.system-monitor.thresholds.description") + } + + // CPU Usage Thresholds + RowLayout { + Layout.fillWidth: true + spacing: Style.marginM + visible: valueShowCpuUsage + + // Warning threshold + RowLayout { + Layout.fillWidth: true + spacing: Style.marginXS + + NText { + text: I18n.tr("bar.widget-settings.system-monitor.cpu-warning-threshold.label") + pointSize: Style.fontSizeS + Layout.alignment: Qt.AlignVCenter + } + + NSpinBox { + Layout.fillWidth: true + from: 0 + to: 100 + stepSize: 5 + value: valueCpuWarningThreshold + onValueChanged: valueCpuWarningThreshold = value + suffix: "%" + } + } + + // Critical threshold + RowLayout { + Layout.fillWidth: true + spacing: Style.marginXS + + NText { + text: I18n.tr("bar.widget-settings.system-monitor.cpu-critical-threshold.label") + pointSize: Style.fontSizeS + Layout.alignment: Qt.AlignVCenter + } + + NSpinBox { + Layout.fillWidth: true + from: 0 + to: 100 + stepSize: 5 + value: valueCpuCriticalThreshold + onValueChanged: valueCpuCriticalThreshold = value + suffix: "%" + } + } + } + + // Temperature Thresholds + RowLayout { + Layout.fillWidth: true + spacing: Style.marginM + visible: valueShowCpuTemp + + RowLayout { + Layout.fillWidth: true + spacing: Style.marginXS + + NText { + text: I18n.tr("bar.widget-settings.system-monitor.temp-warning-threshold.label") + pointSize: Style.fontSizeS + Layout.alignment: Qt.AlignVCenter + } + + NSpinBox { + Layout.fillWidth: true + from: 0 + to: 100 + stepSize: 5 + value: valueTempWarningThreshold + onValueChanged: valueTempWarningThreshold = value + suffix: "°C" + } + } + + RowLayout { + Layout.fillWidth: true + spacing: Style.marginXS + + NText { + text: I18n.tr("bar.widget-settings.system-monitor.temp-critical-threshold.label") + pointSize: Style.fontSizeS + Layout.alignment: Qt.AlignVCenter + } + + NSpinBox { + Layout.fillWidth: true + from: 0 + to: 100 + stepSize: 5 + value: valueTempCriticalThreshold + onValueChanged: valueTempCriticalThreshold = value + suffix: "°C" + } + } + } + + // Memory Usage Thresholds + RowLayout { + Layout.fillWidth: true + spacing: Style.marginM + visible: valueShowMemoryUsage + + RowLayout { + Layout.fillWidth: true + spacing: Style.marginXS + + NText { + text: I18n.tr("bar.widget-settings.system-monitor.mem-warning-threshold.label") + pointSize: Style.fontSizeS + Layout.alignment: Qt.AlignVCenter + } + + NSpinBox { + Layout.fillWidth: true + from: 0 + to: 100 + stepSize: 5 + value: valueMemWarningThreshold + onValueChanged: valueMemWarningThreshold = value + suffix: "%" + } + } + + RowLayout { + Layout.fillWidth: true + spacing: Style.marginXS + + NText { + text: I18n.tr("bar.widget-settings.system-monitor.mem-critical-threshold.label") + pointSize: Style.fontSizeS + Layout.alignment: Qt.AlignVCenter + } + + NSpinBox { + Layout.fillWidth: true + from: 0 + to: 100 + stepSize: 5 + value: valueMemCriticalThreshold + onValueChanged: valueMemCriticalThreshold = value + suffix: "%" + } + } + } + + // Storage Space Thresholds + RowLayout { + Layout.fillWidth: true + spacing: Style.marginM + visible: valueShowDiskUsage + + RowLayout { + Layout.fillWidth: true + spacing: Style.marginXS + + NText { + text: I18n.tr("bar.widget-settings.system-monitor.disk-warning-threshold.label") + pointSize: Style.fontSizeS + Layout.alignment: Qt.AlignVCenter + } + + NSpinBox { + Layout.fillWidth: true + from: 0 + to: 100 + stepSize: 5 + value: valueDiskWarningThreshold + onValueChanged: valueDiskWarningThreshold = value + suffix: "%" + } + } + + RowLayout { + Layout.fillWidth: true + spacing: Style.marginXS + + NText { + text: I18n.tr("bar.widget-settings.system-monitor.disk-critical-threshold.label") + pointSize: Style.fontSizeS + Layout.alignment: Qt.AlignVCenter + } + + NSpinBox { + Layout.fillWidth: true + from: 0 + to: 100 + stepSize: 5 + value: valueDiskCriticalThreshold + onValueChanged: valueDiskCriticalThreshold = value + suffix: "%" + } + } + } } diff --git a/Services/UI/BarWidgetRegistry.qml b/Services/UI/BarWidgetRegistry.qml index b5632bad..6e9c6cc0 100644 --- a/Services/UI/BarWidgetRegistry.qml +++ b/Services/UI/BarWidgetRegistry.qml @@ -147,7 +147,15 @@ Singleton { "showMemoryUsage": true, "showMemoryAsPercent": false, "showNetworkStats": false, - "showDiskUsage": false + "showDiskUsage": false, + "cpuWarningThreshold": 80, + "cpuCriticalThreshold": 90, + "tempWarningThreshold": 80, + "tempCriticalThreshold": 90, + "memWarningThreshold": 80, + "memCriticalThreshold": 90, + "diskWarningThreshold": 80, + "diskCriticalThreshold": 90 }, "Taskbar": { "allowUserSettings": true,