From db2bcb2e695a32d6c8170445b354574183064501 Mon Sep 17 00:00:00 2001 From: Damocles Date: Sun, 3 May 2026 18:37:14 +0200 Subject: [PATCH] fix qmllint warnings in systemd/machinectl modules and services --- shell/applets/MachinectlApplet.qml | 2 ++ shell/applets/SystemdApplet.qml | 8 +++++-- shell/modules/MachinectlModule.qml | 2 ++ shell/modules/SystemdModule.qml | 3 +++ shell/services/MachinectlService.qml | 32 +++++++++++++++------------- shell/services/SystemdService.qml | 16 ++++++++------ 6 files changed, 39 insertions(+), 24 deletions(-) diff --git a/shell/applets/MachinectlApplet.qml b/shell/applets/MachinectlApplet.qml index d3407b4..68d5296 100644 --- a/shell/applets/MachinectlApplet.qml +++ b/shell/applets/MachinectlApplet.qml @@ -1,3 +1,5 @@ +pragma ComponentBehavior: Bound + import QtQuick import "../services" as S diff --git a/shell/applets/SystemdApplet.qml b/shell/applets/SystemdApplet.qml index a3868e7..6412842 100644 --- a/shell/applets/SystemdApplet.qml +++ b/shell/applets/SystemdApplet.qml @@ -1,3 +1,5 @@ +pragma ComponentBehavior: Bound + import QtQuick import "../services" as S @@ -6,6 +8,8 @@ Column { required property color accentColor property bool active: true + // Emitted when content resizes; parent can connect to extend panel-close grace. + signal contentResized // Section header: state label + unit count Item { @@ -63,7 +67,7 @@ Column { isUser: false machineName: "" accentColor: root.accentColor - onHeightChanged: root.keepPanelOpen?.(300) + onHeightChanged: root.contentResized() } } @@ -139,7 +143,7 @@ Column { isUser: true machineName: "" accentColor: root.accentColor - onHeightChanged: root.keepPanelOpen?.(300) + onHeightChanged: root.contentResized() } } diff --git a/shell/modules/MachinectlModule.qml b/shell/modules/MachinectlModule.qml index a9026b7..5f28523 100644 --- a/shell/modules/MachinectlModule.qml +++ b/shell/modules/MachinectlModule.qml @@ -1,3 +1,5 @@ +pragma ComponentBehavior: Bound + import QtQuick import Quickshell import "." as M diff --git a/shell/modules/SystemdModule.qml b/shell/modules/SystemdModule.qml index 517b399..64cbed3 100644 --- a/shell/modules/SystemdModule.qml +++ b/shell/modules/SystemdModule.qml @@ -1,3 +1,5 @@ +pragma ComponentBehavior: Bound + import QtQuick import Quickshell import "." as M @@ -19,6 +21,7 @@ M.BarModule { width: parent.width accentColor: root.accentColor active: root._showPanel + onContentResized: root.keepPanelOpen(300) } } diff --git a/shell/services/MachinectlService.qml b/shell/services/MachinectlService.qml index 7c2d2a4..a954773 100644 --- a/shell/services/MachinectlService.qml +++ b/shell/services/MachinectlService.qml @@ -33,6 +33,12 @@ QtObject { signal machineReady(string machineName, string state, var units) signal machineJournalReady(string machineName, string unitName, string text) + // Per-call state: kept on root (not on the inline Process objects) so qmllint can see them. + property string _machineName: "" + property string _journalMachine: "" + property string _journalUnit: "" + property string _restartMachine: "" + function fetchMachine(name) { const c = Object.assign({}, _cache); c[name] = Object.assign({}, c[name] ?? {}, { @@ -40,7 +46,7 @@ QtObject { }); _cache = c; - _machineProc._name = name; + root._machineName = name; _machineProc.command = ["sh", "-c", "busctl get-property --json=short --machine=" + name + " org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager SystemState 2>/dev/null || echo '{}'; " + "busctl call --json=short --machine=" + name + " org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager ListUnitsFiltered as 1 failed 2>/dev/null || echo '{}'"]; if (_machineProc.running) _machineProc.running = false; @@ -48,8 +54,8 @@ QtObject { } function fetchMachineJournal(machineName, unitName) { - _machineJournalProc._machine = machineName; - _machineJournalProc._unit = unitName; + root._journalMachine = machineName; + root._journalUnit = unitName; _machineJournalProc.command = ["journalctl", "-M", machineName, "-u", unitName, "-n", "80", "--no-pager", "--output=short-precise"]; if (_machineJournalProc.running) _machineJournalProc.running = false; @@ -57,7 +63,7 @@ QtObject { } function restartMachineUnit(machineName, unitName) { - _machineRestartProc._machine = machineName; + root._restartMachine = machineName; _machineRestartProc.command = ["pkexec", "systemctl", "-M", machineName, "restart", unitName]; if (_machineRestartProc.running) _machineRestartProc.running = false; @@ -69,8 +75,8 @@ QtObject { running: S.Modules.machinectl.enable repeat: true triggeredOnStart: true - onTriggered: if (!_listProc.running) - _listProc.running = true + onTriggered: if (!root._listProc.running) + root._listProc.running = true } property Process _listProc: Process { @@ -102,7 +108,6 @@ QtObject { // 2 lines of output: state, failed-units property Process _machineProc: Process { - property string _name: "" stdout: StdioCollector { onStreamFinished: { const lines = text.trim().split("\n"); @@ -122,28 +127,25 @@ QtObject { })); } catch (e) {} const c = Object.assign({}, root._cache); - c[root._machineProc._name] = { + c[root._machineName] = { state: state, units: units, loading: false }; root._cache = c; - root.machineReady(root._machineProc._name, state, units); + root.machineReady(root._machineName, state, units); } } } property Process _machineJournalProc: Process { - property string _machine: "" - property string _unit: "" stdout: StdioCollector { - onStreamFinished: root.machineJournalReady(root._machineJournalProc._machine, root._machineJournalProc._unit, text) + onStreamFinished: root.machineJournalReady(root._journalMachine, root._journalUnit, text) } } property Process _machineRestartProc: Process { - property string _machine: "" - onRunningChanged: if (!running && _machine !== "") - root.fetchMachine(_machine) + onRunningChanged: if (!running && root._restartMachine !== "") + root.fetchMachine(root._restartMachine) } } diff --git a/shell/services/SystemdService.qml b/shell/services/SystemdService.qml index 0abfd87..ae974ac 100644 --- a/shell/services/SystemdService.qml +++ b/shell/services/SystemdService.qml @@ -20,10 +20,14 @@ QtObject { _pollProc.running = true; } + // Per-fetch journal state: kept here (not on the Process) so qmllint can see them. + property string _journalUnitName: "" + property bool _journalIsUser: false + function fetchJournal(unitName, isUser) { _journalProc.command = isUser ? ["journalctl", "--user", "-u", unitName, "-n", "80", "--no-pager", "--output=short-precise"] : ["journalctl", "-u", unitName, "-n", "80", "--no-pager", "--output=short-precise"]; - _journalProc._unitName = unitName; - _journalProc._isUser = isUser; + root._journalUnitName = unitName; + root._journalIsUser = isUser; if (_journalProc.running) _journalProc.running = false; _journalProc.running = true; @@ -64,8 +68,8 @@ QtObject { running: S.Modules.systemd.enable repeat: true triggeredOnStart: true - onTriggered: if (!_pollProc.running) - _pollProc.running = true + onTriggered: if (!root._pollProc.running) + root._pollProc.running = true } // 4 lines of output: systemState, systemUnits, userState, userUnits @@ -83,10 +87,8 @@ QtObject { } property Process _journalProc: Process { - property string _unitName: "" - property bool _isUser: false stdout: StdioCollector { - onStreamFinished: root.journalReady(root._journalProc._unitName, root._journalProc._isUser, text) + onStreamFinished: root.journalReady(root._journalUnitName, root._journalIsUser, text) } }