fix qmllint warnings in systemd/machinectl modules and services

This commit is contained in:
Damocles 2026-05-03 18:37:14 +02:00
parent 545812cf75
commit db2bcb2e69
6 changed files with 39 additions and 24 deletions

View file

@ -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)
}
}

View file

@ -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)
}
}