SysMon: Card and Panel, use the first available widget settings for the favorite disk.

This commit is contained in:
Lemmy
2025-12-27 23:56:19 -05:00
parent 8b8a86784a
commit cec3d02f21
2 changed files with 37 additions and 7 deletions
+13 -4
View File
@@ -3,12 +3,22 @@ import QtQuick.Layouts
import Quickshell
import qs.Commons
import qs.Services.System
import qs.Services.UI
import qs.Widgets
// Unified system card: monitors CPU, temp, memory, disk
NBox {
id: root
// Get diskPath from bar's SystemMonitor widget if available, otherwise use settings
readonly property string diskPath: {
const sysMonWidget = BarService.lookupWidget("SystemMonitor");
if (sysMonWidget && sysMonWidget.diskPath) {
return sysMonWidget.diskPath;
}
return Settings.data.systemMonitor.diskPath || "/";
}
Item {
id: content
anchors.fill: parent
@@ -52,15 +62,14 @@ NBox {
tooltipText: I18n.tr("system-monitor.memory") + `: ${Math.round(SystemStatService.memPercent)}%`
}
NCircleStat {
readonly property string diskPath: Settings.data.systemMonitor.diskPath || "/"
ratio: (SystemStatService.diskPercents[diskPath] ?? 0) / 100
ratio: (SystemStatService.diskPercents[root.diskPath] ?? 0) / 100
icon: "storage"
flat: true
contentScale: 0.95
height: content.widgetHeight
Layout.alignment: Qt.AlignHCenter
fillColor: SystemStatService.getDiskColor(diskPath)
tooltipText: I18n.tr("system-monitor.disk") + `: ${SystemStatService.diskPercents[diskPath] || 0}%`
fillColor: SystemStatService.getDiskColor(root.diskPath)
tooltipText: I18n.tr("system-monitor.disk") + `: ${SystemStatService.diskPercents[root.diskPath] || 0}%\n${root.diskPath}`
}
}
}
@@ -5,6 +5,7 @@ import Quickshell
import qs.Commons
import qs.Modules.MainScreen
import qs.Services.System
import qs.Services.UI
import qs.Widgets
SmartPanel {
@@ -13,6 +14,26 @@ SmartPanel {
preferredWidth: Math.round(440 * Style.uiScaleRatio)
preferredHeight: Math.round(420 * Style.uiScaleRatio)
// Get diskPath from bar's SystemMonitor widget if available, otherwise use "/"
// Use a dummy dependency on activeWidgetsChanged to re-evaluate when widgets change
property int _widgetChangeCounter: 0
readonly property string diskPath: {
// Force re-evaluation when widgets change
void root._widgetChangeCounter;
const sysMonWidget = BarService.lookupWidget("SystemMonitor");
if (sysMonWidget && sysMonWidget.diskPath) {
return sysMonWidget.diskPath;
}
return "/";
}
Connections {
target: BarService
function onActiveWidgetsChanged() {
root._widgetChangeCounter++;
}
}
panelContent: Item {
property real contentPreferredHeight: mainColumn.implicitHeight + Style.marginL * 2
@@ -125,12 +146,12 @@ SmartPanel {
// Disk Usage
NCircleStat {
ratio: (SystemStatService.diskPercents["/"] ?? 0) / 100
ratio: (SystemStatService.diskPercents[root.diskPath] ?? 0) / 100
icon: "storage"
suffix: "%"
flat: true
fillColor: SystemStatService.getDiskColor("/")
tooltipText: I18n.tr("system-monitor.disk") + `: ${SystemStatService.diskPercents["/"] || 0}%`
fillColor: SystemStatService.getDiskColor(root.diskPath)
tooltipText: I18n.tr("system-monitor.disk") + `: ${SystemStatService.diskPercents[root.diskPath] || 0}%\n${root.diskPath}`
Layout.fillWidth: true
}
}