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

@ -1,3 +1,5 @@
pragma ComponentBehavior: Bound
import QtQuick import QtQuick
import "../services" as S import "../services" as S

View file

@ -1,3 +1,5 @@
pragma ComponentBehavior: Bound
import QtQuick import QtQuick
import "../services" as S import "../services" as S
@ -6,6 +8,8 @@ Column {
required property color accentColor required property color accentColor
property bool active: true property bool active: true
// Emitted when content resizes; parent can connect to extend panel-close grace.
signal contentResized
// Section header: state label + unit count // Section header: state label + unit count
Item { Item {
@ -63,7 +67,7 @@ Column {
isUser: false isUser: false
machineName: "" machineName: ""
accentColor: root.accentColor accentColor: root.accentColor
onHeightChanged: root.keepPanelOpen?.(300) onHeightChanged: root.contentResized()
} }
} }
@ -139,7 +143,7 @@ Column {
isUser: true isUser: true
machineName: "" machineName: ""
accentColor: root.accentColor accentColor: root.accentColor
onHeightChanged: root.keepPanelOpen?.(300) onHeightChanged: root.contentResized()
} }
} }

View file

@ -1,3 +1,5 @@
pragma ComponentBehavior: Bound
import QtQuick import QtQuick
import Quickshell import Quickshell
import "." as M import "." as M

View file

@ -1,3 +1,5 @@
pragma ComponentBehavior: Bound
import QtQuick import QtQuick
import Quickshell import Quickshell
import "." as M import "." as M
@ -19,6 +21,7 @@ M.BarModule {
width: parent.width width: parent.width
accentColor: root.accentColor accentColor: root.accentColor
active: root._showPanel active: root._showPanel
onContentResized: root.keepPanelOpen(300)
} }
} }

View file

@ -33,6 +33,12 @@ QtObject {
signal machineReady(string machineName, string state, var units) signal machineReady(string machineName, string state, var units)
signal machineJournalReady(string machineName, string unitName, string text) 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) { function fetchMachine(name) {
const c = Object.assign({}, _cache); const c = Object.assign({}, _cache);
c[name] = Object.assign({}, c[name] ?? {}, { c[name] = Object.assign({}, c[name] ?? {}, {
@ -40,7 +46,7 @@ QtObject {
}); });
_cache = c; _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 '{}'"]; _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) if (_machineProc.running)
_machineProc.running = false; _machineProc.running = false;
@ -48,8 +54,8 @@ QtObject {
} }
function fetchMachineJournal(machineName, unitName) { function fetchMachineJournal(machineName, unitName) {
_machineJournalProc._machine = machineName; root._journalMachine = machineName;
_machineJournalProc._unit = unitName; root._journalUnit = unitName;
_machineJournalProc.command = ["journalctl", "-M", machineName, "-u", unitName, "-n", "80", "--no-pager", "--output=short-precise"]; _machineJournalProc.command = ["journalctl", "-M", machineName, "-u", unitName, "-n", "80", "--no-pager", "--output=short-precise"];
if (_machineJournalProc.running) if (_machineJournalProc.running)
_machineJournalProc.running = false; _machineJournalProc.running = false;
@ -57,7 +63,7 @@ QtObject {
} }
function restartMachineUnit(machineName, unitName) { function restartMachineUnit(machineName, unitName) {
_machineRestartProc._machine = machineName; root._restartMachine = machineName;
_machineRestartProc.command = ["pkexec", "systemctl", "-M", machineName, "restart", unitName]; _machineRestartProc.command = ["pkexec", "systemctl", "-M", machineName, "restart", unitName];
if (_machineRestartProc.running) if (_machineRestartProc.running)
_machineRestartProc.running = false; _machineRestartProc.running = false;
@ -69,8 +75,8 @@ QtObject {
running: S.Modules.machinectl.enable running: S.Modules.machinectl.enable
repeat: true repeat: true
triggeredOnStart: true triggeredOnStart: true
onTriggered: if (!_listProc.running) onTriggered: if (!root._listProc.running)
_listProc.running = true root._listProc.running = true
} }
property Process _listProc: Process { property Process _listProc: Process {
@ -102,7 +108,6 @@ QtObject {
// 2 lines of output: state, failed-units // 2 lines of output: state, failed-units
property Process _machineProc: Process { property Process _machineProc: Process {
property string _name: ""
stdout: StdioCollector { stdout: StdioCollector {
onStreamFinished: { onStreamFinished: {
const lines = text.trim().split("\n"); const lines = text.trim().split("\n");
@ -122,28 +127,25 @@ QtObject {
})); }));
} catch (e) {} } catch (e) {}
const c = Object.assign({}, root._cache); const c = Object.assign({}, root._cache);
c[root._machineProc._name] = { c[root._machineName] = {
state: state, state: state,
units: units, units: units,
loading: false loading: false
}; };
root._cache = c; root._cache = c;
root.machineReady(root._machineProc._name, state, units); root.machineReady(root._machineName, state, units);
} }
} }
} }
property Process _machineJournalProc: Process { property Process _machineJournalProc: Process {
property string _machine: ""
property string _unit: ""
stdout: StdioCollector { 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 Process _machineRestartProc: Process {
property string _machine: "" onRunningChanged: if (!running && root._restartMachine !== "")
onRunningChanged: if (!running && _machine !== "") root.fetchMachine(root._restartMachine)
root.fetchMachine(_machine)
} }
} }

View file

@ -20,10 +20,14 @@ QtObject {
_pollProc.running = true; _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) { 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.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; root._journalUnitName = unitName;
_journalProc._isUser = isUser; root._journalIsUser = isUser;
if (_journalProc.running) if (_journalProc.running)
_journalProc.running = false; _journalProc.running = false;
_journalProc.running = true; _journalProc.running = true;
@ -64,8 +68,8 @@ QtObject {
running: S.Modules.systemd.enable running: S.Modules.systemd.enable
repeat: true repeat: true
triggeredOnStart: true triggeredOnStart: true
onTriggered: if (!_pollProc.running) onTriggered: if (!root._pollProc.running)
_pollProc.running = true root._pollProc.running = true
} }
// 4 lines of output: systemState, systemUnits, userState, userUnits // 4 lines of output: systemState, systemUnits, userState, userUnits
@ -83,10 +87,8 @@ QtObject {
} }
property Process _journalProc: Process { property Process _journalProc: Process {
property string _unitName: ""
property bool _isUser: false
stdout: StdioCollector { stdout: StdioCollector {
onStreamFinished: root.journalReady(root._journalProc._unitName, root._journalProc._isUser, text) onStreamFinished: root.journalReady(root._journalUnitName, root._journalIsUser, text)
} }
} }