merge systemd + machinectl into one module/applet (step 1)
This commit is contained in:
parent
96bfc1fd5a
commit
6fc7e8bc8a
16 changed files with 261 additions and 1029 deletions
|
|
@ -1,354 +0,0 @@
|
|||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import "../services" as S
|
||||
import NovaStats as NS
|
||||
|
||||
Column {
|
||||
id: root
|
||||
|
||||
required property color accentColor
|
||||
property bool active: true
|
||||
|
||||
property bool _localExpanded: true
|
||||
|
||||
// Localhost section header
|
||||
Item {
|
||||
width: root.width
|
||||
height: 32
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 4
|
||||
anchors.rightMargin: 4
|
||||
color: _localHdrHover.hovered ? NS.ThemeService.base02 : "transparent"
|
||||
radius: NS.ThemeService.radius
|
||||
z: -1
|
||||
}
|
||||
|
||||
HoverHandler {
|
||||
id: _localHdrHover
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 12
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: " localhost"
|
||||
color: NS.ThemeService.base05
|
||||
font.pixelSize: NS.ThemeService.fontSize
|
||||
font.family: NS.ThemeService.fontFamily
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: _localStateChip
|
||||
anchors.right: _localChevron.left
|
||||
anchors.rightMargin: 8
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
visible: S.SystemdService.systemState !== "unknown"
|
||||
color: {
|
||||
const st = S.SystemdService.systemState;
|
||||
if (st === "running")
|
||||
return NS.ThemeService.base0B;
|
||||
if (st === "degraded")
|
||||
return NS.ThemeService.base0A;
|
||||
return NS.ThemeService.base08;
|
||||
}
|
||||
opacity: 0.85
|
||||
radius: 3
|
||||
width: _localStateLbl.width + 8
|
||||
height: 14
|
||||
|
||||
Text {
|
||||
id: _localStateLbl
|
||||
anchors.centerIn: parent
|
||||
text: S.SystemdService.systemState
|
||||
color: NS.ThemeService.base00
|
||||
font.pixelSize: NS.ThemeService.fontSize - 3
|
||||
font.family: NS.ThemeService.fontFamily
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
id: _localChevron
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 12
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: root._localExpanded ? "" : ""
|
||||
color: NS.ThemeService.base04
|
||||
font.pixelSize: NS.ThemeService.fontSize - 2
|
||||
font.family: NS.ThemeService.iconFontFamily
|
||||
}
|
||||
|
||||
TapHandler {
|
||||
onTapped: root._localExpanded = !root._localExpanded
|
||||
}
|
||||
}
|
||||
|
||||
// Localhost expanded content
|
||||
Column {
|
||||
visible: root._localExpanded
|
||||
width: root.width
|
||||
|
||||
// System sub-section
|
||||
Item {
|
||||
width: root.width
|
||||
height: 22
|
||||
|
||||
Text {
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 24
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: "SYSTEM"
|
||||
color: NS.ThemeService.base03
|
||||
font.pixelSize: NS.ThemeService.fontSize - 3
|
||||
font.family: NS.ThemeService.fontFamily
|
||||
font.letterSpacing: 1
|
||||
}
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: S.SystemdService.systemUnits
|
||||
delegate: SystemdUnitRow {
|
||||
required property var modelData
|
||||
unitName: modelData.name
|
||||
description: modelData.description
|
||||
subState: modelData.subState
|
||||
isUser: false
|
||||
machineName: ""
|
||||
accentColor: root.accentColor
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
visible: S.SystemdService.systemUnits.length === 0
|
||||
width: root.width
|
||||
height: 22
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "no failures"
|
||||
color: NS.ThemeService.base0B
|
||||
font.pixelSize: NS.ThemeService.fontSize - 2
|
||||
font.family: NS.ThemeService.fontFamily
|
||||
}
|
||||
}
|
||||
|
||||
// User sub-section
|
||||
Item {
|
||||
width: root.width
|
||||
height: 22
|
||||
|
||||
Text {
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 24
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: "USER"
|
||||
color: NS.ThemeService.base03
|
||||
font.pixelSize: NS.ThemeService.fontSize - 3
|
||||
font.family: NS.ThemeService.fontFamily
|
||||
font.letterSpacing: 1
|
||||
}
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: S.SystemdService.userUnits
|
||||
delegate: SystemdUnitRow {
|
||||
required property var modelData
|
||||
unitName: modelData.name
|
||||
description: modelData.description
|
||||
subState: modelData.subState
|
||||
isUser: true
|
||||
machineName: ""
|
||||
accentColor: root.accentColor
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
visible: S.SystemdService.userUnits.length === 0
|
||||
width: root.width
|
||||
height: 22
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "no failures"
|
||||
color: NS.ThemeService.base0B
|
||||
font.pixelSize: NS.ThemeService.fontSize - 2
|
||||
font.family: NS.ThemeService.fontFamily
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Containers
|
||||
Repeater {
|
||||
model: S.MachinectlService.machines
|
||||
|
||||
delegate: Column {
|
||||
id: _machineSection
|
||||
required property var modelData
|
||||
required property int index
|
||||
|
||||
property bool _expanded: false
|
||||
property bool _loading: false
|
||||
|
||||
width: root.width
|
||||
|
||||
Connections {
|
||||
target: S.MachinectlService
|
||||
function onMachineReady(machineName) {
|
||||
if (machineName === _machineSection.modelData.name)
|
||||
_machineSection._loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
Separator {}
|
||||
|
||||
// Machine header
|
||||
Item {
|
||||
width: _machineSection.width
|
||||
height: 32
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 4
|
||||
anchors.rightMargin: 4
|
||||
color: _mHdrHover.hovered ? NS.ThemeService.base02 : "transparent"
|
||||
radius: NS.ThemeService.radius
|
||||
z: -1
|
||||
}
|
||||
|
||||
HoverHandler {
|
||||
id: _mHdrHover
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 12
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: " " + _machineSection.modelData.name
|
||||
color: NS.ThemeService.base05
|
||||
font.pixelSize: NS.ThemeService.fontSize
|
||||
font.family: NS.ThemeService.fontFamily
|
||||
elide: Text.ElideRight
|
||||
width: parent.width - 100
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: _mStateChip
|
||||
anchors.right: _mChevron.left
|
||||
anchors.rightMargin: 8
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
visible: _machineSection._expanded && !_machineSection._loading
|
||||
color: {
|
||||
const st = S.MachinectlService.machineState(_machineSection.modelData.name);
|
||||
if (st === "running")
|
||||
return NS.ThemeService.base0B;
|
||||
if (st === "degraded")
|
||||
return NS.ThemeService.base0A;
|
||||
return st === "unknown" ? "transparent" : NS.ThemeService.base08;
|
||||
}
|
||||
opacity: 0.85
|
||||
radius: 3
|
||||
width: _mStateLbl.width + 8
|
||||
height: 14
|
||||
|
||||
Text {
|
||||
id: _mStateLbl
|
||||
anchors.centerIn: parent
|
||||
text: S.MachinectlService.machineState(_machineSection.modelData.name)
|
||||
color: NS.ThemeService.base00
|
||||
font.pixelSize: NS.ThemeService.fontSize - 3
|
||||
font.family: NS.ThemeService.fontFamily
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
id: _mChevron
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 12
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: _machineSection._expanded ? "" : ""
|
||||
color: NS.ThemeService.base04
|
||||
font.pixelSize: NS.ThemeService.fontSize - 2
|
||||
font.family: NS.ThemeService.iconFontFamily
|
||||
}
|
||||
|
||||
TapHandler {
|
||||
onTapped: {
|
||||
_machineSection._expanded = !_machineSection._expanded;
|
||||
if (_machineSection._expanded) {
|
||||
_machineSection._loading = true;
|
||||
S.MachinectlService.fetchMachine(_machineSection.modelData.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Machine expanded content
|
||||
Column {
|
||||
visible: _machineSection._expanded
|
||||
width: _machineSection.width
|
||||
|
||||
Item {
|
||||
visible: _machineSection._loading
|
||||
width: _machineSection.width
|
||||
height: 28
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "loading..."
|
||||
color: NS.ThemeService.base04
|
||||
font.pixelSize: NS.ThemeService.fontSize - 2
|
||||
font.family: NS.ThemeService.fontFamily
|
||||
}
|
||||
}
|
||||
|
||||
// System units inside the container
|
||||
Item {
|
||||
visible: !_machineSection._loading
|
||||
width: _machineSection.width
|
||||
height: 22
|
||||
|
||||
Text {
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 24
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: "SYSTEM"
|
||||
color: NS.ThemeService.base03
|
||||
font.pixelSize: NS.ThemeService.fontSize - 3
|
||||
font.family: NS.ThemeService.fontFamily
|
||||
font.letterSpacing: 1
|
||||
}
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: !_machineSection._loading ? S.MachinectlService.machineUnits(_machineSection.modelData.name) : []
|
||||
delegate: SystemdUnitRow {
|
||||
required property var modelData
|
||||
unitName: modelData.name
|
||||
description: modelData.description
|
||||
subState: modelData.subState
|
||||
isUser: false
|
||||
machineName: _machineSection.modelData.name
|
||||
accentColor: root.accentColor
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
visible: !_machineSection._loading && S.MachinectlService.machineUnits(_machineSection.modelData.name).length === 0
|
||||
width: _machineSection.width
|
||||
height: 22
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "no failures"
|
||||
color: NS.ThemeService.base0B
|
||||
font.pixelSize: NS.ThemeService.fontSize - 2
|
||||
font.family: NS.ThemeService.fontFamily
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
width: 1
|
||||
height: 4
|
||||
}
|
||||
}
|
||||
|
|
@ -9,156 +9,43 @@ 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 {
|
||||
onHeightChanged: root.contentResized()
|
||||
|
||||
// Local machine header + units
|
||||
SystemdMachineSection {
|
||||
width: root.width
|
||||
height: 28
|
||||
|
||||
Text {
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 12
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: "SYSTEM"
|
||||
color: NS.ThemeService.base03
|
||||
font.pixelSize: NS.ThemeService.fontSize - 3
|
||||
font.family: NS.ThemeService.fontFamily
|
||||
font.letterSpacing: 1
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 12
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
visible: S.SystemdService.systemState !== "unknown"
|
||||
color: {
|
||||
const st = S.SystemdService.systemState;
|
||||
if (st === "running")
|
||||
return NS.ThemeService.base0B;
|
||||
if (st === "degraded")
|
||||
return NS.ThemeService.base0A;
|
||||
return NS.ThemeService.base08;
|
||||
}
|
||||
opacity: 0.85
|
||||
radius: 3
|
||||
width: _sysStateLbl.width + 8
|
||||
height: 14
|
||||
|
||||
Text {
|
||||
id: _sysStateLbl
|
||||
anchors.centerIn: parent
|
||||
text: S.SystemdService.systemState
|
||||
color: NS.ThemeService.base00
|
||||
font.pixelSize: NS.ThemeService.fontSize - 3
|
||||
font.family: NS.ThemeService.fontFamily
|
||||
}
|
||||
}
|
||||
accentColor: root.accentColor
|
||||
machineName: ""
|
||||
title: S.SystemdService.hostname
|
||||
marker: " this machine"
|
||||
systemState: S.SystemdService.systemState
|
||||
units: S.SystemdService.failedUnits
|
||||
startExpanded: true
|
||||
}
|
||||
|
||||
// Containers
|
||||
Repeater {
|
||||
model: S.SystemdService.systemUnits
|
||||
model: S.SystemdService.containers
|
||||
|
||||
delegate: SystemdUnitRow {
|
||||
delegate: Column {
|
||||
id: _row
|
||||
required property var modelData
|
||||
unitName: modelData.name
|
||||
description: modelData.description
|
||||
subState: modelData.subState
|
||||
isUser: false
|
||||
machineName: ""
|
||||
accentColor: root.accentColor
|
||||
onHeightChanged: root.contentResized()
|
||||
}
|
||||
}
|
||||
width: root.width
|
||||
|
||||
Item {
|
||||
visible: S.SystemdService.systemUnits.length === 0
|
||||
width: root.width
|
||||
height: 24
|
||||
Separator {}
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "no failed system units"
|
||||
color: NS.ThemeService.base0B
|
||||
font.pixelSize: NS.ThemeService.fontSize - 2
|
||||
font.family: NS.ThemeService.fontFamily
|
||||
}
|
||||
}
|
||||
|
||||
Separator {}
|
||||
|
||||
// User section
|
||||
Item {
|
||||
width: root.width
|
||||
height: 28
|
||||
|
||||
Text {
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 12
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: "USER"
|
||||
color: NS.ThemeService.base03
|
||||
font.pixelSize: NS.ThemeService.fontSize - 3
|
||||
font.family: NS.ThemeService.fontFamily
|
||||
font.letterSpacing: 1
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 12
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
visible: S.SystemdService.userState !== "unknown"
|
||||
color: {
|
||||
const st = S.SystemdService.userState;
|
||||
if (st === "running")
|
||||
return NS.ThemeService.base0B;
|
||||
if (st === "degraded")
|
||||
return NS.ThemeService.base0A;
|
||||
return NS.ThemeService.base08;
|
||||
SystemdMachineSection {
|
||||
width: _row.width
|
||||
accentColor: root.accentColor
|
||||
machineName: _row.modelData.name
|
||||
title: _row.modelData.name
|
||||
marker: ""
|
||||
systemState: _row.modelData.systemState ?? "unknown"
|
||||
units: _row.modelData.failedUnits ?? []
|
||||
startExpanded: (_row.modelData.failedUnits ?? []).length > 0
|
||||
}
|
||||
opacity: 0.85
|
||||
radius: 3
|
||||
width: _userStateLbl.width + 8
|
||||
height: 14
|
||||
|
||||
Text {
|
||||
id: _userStateLbl
|
||||
anchors.centerIn: parent
|
||||
text: S.SystemdService.userState
|
||||
color: NS.ThemeService.base00
|
||||
font.pixelSize: NS.ThemeService.fontSize - 3
|
||||
font.family: NS.ThemeService.fontFamily
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: S.SystemdService.userUnits
|
||||
|
||||
delegate: SystemdUnitRow {
|
||||
required property var modelData
|
||||
unitName: modelData.name
|
||||
description: modelData.description
|
||||
subState: modelData.subState
|
||||
isUser: true
|
||||
machineName: ""
|
||||
accentColor: root.accentColor
|
||||
onHeightChanged: root.contentResized()
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
visible: S.SystemdService.userUnits.length === 0
|
||||
width: root.width
|
||||
height: 24
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "no failed user units"
|
||||
color: NS.ThemeService.base0B
|
||||
font.pixelSize: NS.ThemeService.fontSize - 2
|
||||
font.family: NS.ThemeService.fontFamily
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
111
shell/applets/SystemdMachineSection.qml
Normal file
111
shell/applets/SystemdMachineSection.qml
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import "../services" as S
|
||||
import NovaStats as NS
|
||||
|
||||
// One section of the systemd applet: a header with title + state chip,
|
||||
// expandable list of failed units underneath.
|
||||
Column {
|
||||
id: root
|
||||
|
||||
required property color accentColor
|
||||
required property string machineName
|
||||
required property string title
|
||||
required property string marker
|
||||
required property string systemState
|
||||
required property var units
|
||||
property bool startExpanded: false
|
||||
|
||||
width: parent?.width ?? 0
|
||||
|
||||
property bool _expanded: startExpanded
|
||||
|
||||
Item {
|
||||
width: root.width
|
||||
height: 32
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 4
|
||||
anchors.rightMargin: 4
|
||||
color: _hdrHover.hovered ? NS.ThemeService.base02 : "transparent"
|
||||
radius: NS.ThemeService.radius
|
||||
z: -1
|
||||
}
|
||||
|
||||
HoverHandler {
|
||||
id: _hdrHover
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 12
|
||||
anchors.right: _stateChip.left
|
||||
anchors.rightMargin: 6
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: root.title + (root.marker !== "" ? " " + root.marker : "")
|
||||
color: NS.ThemeService.base05
|
||||
font.pixelSize: NS.ThemeService.fontSize
|
||||
font.family: NS.ThemeService.fontFamily
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: _stateChip
|
||||
anchors.right: _chevron.left
|
||||
anchors.rightMargin: 8
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
visible: root.systemState !== "unknown"
|
||||
color: {
|
||||
const st = root.systemState;
|
||||
if (st === "running")
|
||||
return NS.ThemeService.base0B;
|
||||
if (st === "degraded")
|
||||
return NS.ThemeService.base0A;
|
||||
return NS.ThemeService.base08;
|
||||
}
|
||||
opacity: 0.85
|
||||
radius: 3
|
||||
width: _stateLbl.width + 8
|
||||
height: 14
|
||||
|
||||
Text {
|
||||
id: _stateLbl
|
||||
anchors.centerIn: parent
|
||||
text: root.systemState
|
||||
color: NS.ThemeService.base00
|
||||
font.pixelSize: NS.ThemeService.fontSize - 3
|
||||
font.family: NS.ThemeService.fontFamily
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
id: _chevron
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 12
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: root._expanded ? "" : ""
|
||||
color: NS.ThemeService.base04
|
||||
font.pixelSize: NS.ThemeService.fontSize - 2
|
||||
font.family: NS.ThemeService.iconFontFamily
|
||||
}
|
||||
|
||||
TapHandler {
|
||||
onTapped: root._expanded = !root._expanded
|
||||
}
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: root._expanded ? root.units : []
|
||||
delegate: SystemdUnitRow {
|
||||
required property var modelData
|
||||
unitName: modelData.name
|
||||
description: modelData.description ?? ""
|
||||
subState: modelData.subState ?? ""
|
||||
scope: modelData.scope ?? "system"
|
||||
machineName: root.machineName
|
||||
accentColor: root.accentColor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -8,233 +8,95 @@ Item {
|
|||
required property string unitName
|
||||
required property string description
|
||||
required property string subState
|
||||
required property bool isUser
|
||||
property string machineName: ""
|
||||
required property string scope
|
||||
required property string machineName
|
||||
required property color accentColor
|
||||
|
||||
property string _jText: ""
|
||||
property bool _expanded: false
|
||||
property bool _loading: false
|
||||
|
||||
width: parent?.width ?? 0
|
||||
height: _row.height + (_expanded ? _journalArea.height : 0)
|
||||
height: 28
|
||||
|
||||
Behavior on height {
|
||||
NumberAnimation {
|
||||
duration: 150
|
||||
HoverHandler {
|
||||
id: _rowHover
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 4
|
||||
anchors.rightMargin: 4
|
||||
color: _rowHover.hovered ? NS.ThemeService.base02 : "transparent"
|
||||
radius: NS.ThemeService.radius
|
||||
z: -1
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 12
|
||||
anchors.right: _subStateTag.left
|
||||
anchors.rightMargin: 6
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: root.unitName
|
||||
color: NS.ThemeService.base05
|
||||
font.pixelSize: NS.ThemeService.fontSize - 1
|
||||
font.family: NS.ThemeService.fontFamily
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: _subStateTag
|
||||
anchors.right: _restartBtn.left
|
||||
anchors.rightMargin: 6
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
color: NS.ThemeService.base08
|
||||
opacity: 0.85
|
||||
radius: 3
|
||||
width: _subStateLbl.width + 8
|
||||
height: 14
|
||||
|
||||
Text {
|
||||
id: _subStateLbl
|
||||
anchors.centerIn: parent
|
||||
text: root.subState
|
||||
color: NS.ThemeService.base00
|
||||
font.pixelSize: NS.ThemeService.fontSize - 3
|
||||
font.family: NS.ThemeService.fontFamily
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: S.SystemdService
|
||||
enabled: root.machineName === ""
|
||||
function onJournalReady(unitName, isUser, text) {
|
||||
if (unitName === root.unitName && isUser === root.isUser) {
|
||||
root._jText = text;
|
||||
root._loading = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: S.MachinectlService
|
||||
enabled: root.machineName !== ""
|
||||
function onMachineJournalReady(mname, unitName, text) {
|
||||
if (mname === root.machineName && unitName === root.unitName) {
|
||||
root._jText = text;
|
||||
root._loading = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _fetchJournal() {
|
||||
root._loading = true;
|
||||
root._jText = "";
|
||||
if (root.machineName === "")
|
||||
S.SystemdService.fetchJournal(root.unitName, root.isUser);
|
||||
else
|
||||
S.MachinectlService.fetchMachineJournal(root.machineName, root.unitName);
|
||||
}
|
||||
|
||||
function _doRestart() {
|
||||
if (root.machineName === "")
|
||||
S.SystemdService.restartUnit(root.unitName, root.isUser);
|
||||
else
|
||||
S.MachinectlService.restartMachineUnit(root.machineName, root.unitName);
|
||||
}
|
||||
|
||||
// Row
|
||||
// Restart button only visible while hovering the row. = fa-refresh
|
||||
Item {
|
||||
id: _row
|
||||
width: parent.width
|
||||
height: 32
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 4
|
||||
anchors.rightMargin: 4
|
||||
color: _rowHover.hovered ? NS.ThemeService.base02 : "transparent"
|
||||
radius: NS.ThemeService.radius
|
||||
z: -1
|
||||
}
|
||||
|
||||
HoverHandler {
|
||||
id: _rowHover
|
||||
id: _restartBtn
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 8
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: 24
|
||||
height: 24
|
||||
opacity: _rowHover.hovered ? 1 : 0
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: 80
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 12
|
||||
anchors.right: _subStateTag.left
|
||||
anchors.rightMargin: 6
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: root.unitName
|
||||
color: NS.ThemeService.base05
|
||||
font.pixelSize: NS.ThemeService.fontSize - 1
|
||||
font.family: NS.ThemeService.fontFamily
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: _subStateTag
|
||||
anchors.right: _restartBtn.left
|
||||
anchors.rightMargin: 6
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
color: NS.ThemeService.base08
|
||||
opacity: 0.85
|
||||
radius: 3
|
||||
width: _subStateLbl.width + 8
|
||||
height: 14
|
||||
|
||||
Text {
|
||||
id: _subStateLbl
|
||||
anchors.centerIn: parent
|
||||
text: root.subState
|
||||
color: NS.ThemeService.base00
|
||||
font.pixelSize: NS.ThemeService.fontSize - 3
|
||||
font.family: NS.ThemeService.fontFamily
|
||||
}
|
||||
}
|
||||
|
||||
// Restart button - = fa-refresh
|
||||
Item {
|
||||
id: _restartBtn
|
||||
anchors.right: _expandBtn.left
|
||||
anchors.rightMargin: 2
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: 24
|
||||
height: 24
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: ""
|
||||
color: _rHover.hovered ? root.accentColor : NS.ThemeService.base04
|
||||
font.pixelSize: NS.ThemeService.fontSize
|
||||
font.family: NS.ThemeService.iconFontFamily
|
||||
Behavior on color {
|
||||
ColorAnimation {
|
||||
duration: 80
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HoverHandler {
|
||||
id: _rHover
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
}
|
||||
TapHandler {
|
||||
onTapped: {
|
||||
root._doRestart();
|
||||
if (root._expanded) {
|
||||
root._jText = "";
|
||||
Qt.callLater(root._fetchJournal);
|
||||
}
|
||||
anchors.centerIn: parent
|
||||
text: ""
|
||||
color: _rHover.hovered ? root.accentColor : NS.ThemeService.base04
|
||||
font.pixelSize: NS.ThemeService.fontSize
|
||||
font.family: NS.ThemeService.iconFontFamily
|
||||
Behavior on color {
|
||||
ColorAnimation {
|
||||
duration: 80
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Expand chevron - = fa-chevron-down, = fa-chevron-up
|
||||
Item {
|
||||
id: _expandBtn
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 4
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: 24
|
||||
height: 24
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: root._expanded ? "" : ""
|
||||
color: _expHover.hovered ? root.accentColor : NS.ThemeService.base04
|
||||
font.pixelSize: NS.ThemeService.fontSize - 1
|
||||
font.family: NS.ThemeService.iconFontFamily
|
||||
Behavior on color {
|
||||
ColorAnimation {
|
||||
duration: 80
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HoverHandler {
|
||||
id: _expHover
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
}
|
||||
TapHandler {
|
||||
onTapped: {
|
||||
root._expanded = !root._expanded;
|
||||
if (root._expanded && root._jText === "")
|
||||
root._fetchJournal();
|
||||
}
|
||||
}
|
||||
HoverHandler {
|
||||
id: _rHover
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
}
|
||||
}
|
||||
|
||||
// Journal area
|
||||
Item {
|
||||
id: _journalArea
|
||||
anchors.top: _row.bottom
|
||||
width: parent.width
|
||||
height: 120
|
||||
visible: root._expanded
|
||||
clip: true
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 8
|
||||
anchors.rightMargin: 8
|
||||
anchors.bottomMargin: 4
|
||||
color: NS.ThemeService.base01
|
||||
radius: NS.ThemeService.radius
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
visible: root._loading
|
||||
text: "loading..."
|
||||
color: NS.ThemeService.base04
|
||||
font.pixelSize: NS.ThemeService.fontSize - 2
|
||||
font.family: NS.ThemeService.fontFamily
|
||||
}
|
||||
|
||||
Flickable {
|
||||
id: _flick
|
||||
anchors.fill: parent
|
||||
anchors.margins: 6
|
||||
visible: !root._loading
|
||||
contentHeight: _jContent.height
|
||||
clip: true
|
||||
|
||||
Text {
|
||||
id: _jContent
|
||||
width: _flick.width
|
||||
text: root._jText
|
||||
color: NS.ThemeService.base04
|
||||
font.pixelSize: NS.ThemeService.fontSize - 3
|
||||
font.family: NS.ThemeService.fontFamily
|
||||
wrapMode: Text.WrapAnywhere
|
||||
}
|
||||
|
||||
onContentHeightChanged: contentY = Math.max(0, contentHeight - height)
|
||||
}
|
||||
TapHandler {
|
||||
enabled: _rowHover.hovered
|
||||
onTapped: S.SystemdService.restartUnit(root.unitName, root.scope, root.machineName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ GpuApplet 1.0 GpuApplet.qml
|
|||
HexWaveBackground 1.0 HexWaveBackground.qml
|
||||
HoverableListItem 1.0 HoverableListItem.qml
|
||||
InfoRow 1.0 InfoRow.qml
|
||||
MachinectlApplet 1.0 MachinectlApplet.qml
|
||||
MemoryApplet 1.0 MemoryApplet.qml
|
||||
MprisApplet 1.0 MprisApplet.qml
|
||||
NetworkApplet 1.0 NetworkApplet.qml
|
||||
|
|
@ -19,6 +18,7 @@ PowerApplet 1.0 PowerApplet.qml
|
|||
Separator 1.0 Separator.qml
|
||||
SparklineCanvas 1.0 SparklineCanvas.qml
|
||||
SystemdApplet 1.0 SystemdApplet.qml
|
||||
SystemdMachineSection 1.0 SystemdMachineSection.qml
|
||||
SystemdUnitRow 1.0 SystemdUnitRow.qml
|
||||
TemperatureApplet 1.0 TemperatureApplet.qml
|
||||
VolumeApplet 1.0 VolumeApplet.qml
|
||||
|
|
|
|||
Reference in a new issue