mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
SysMon: Card and Panel, use the first available widget settings for the favorite disk.
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user