165 lines
5.8 KiB
QML
165 lines
5.8 KiB
QML
import QtQuick
|
|
import qs.config
|
|
import qs.services
|
|
|
|
SettingsCard {
|
|
id: root
|
|
|
|
objectName: "health-summary"
|
|
implicitHeight: 126
|
|
|
|
// The verdict itself is Health's, not this card's — see Health.headlineState
|
|
// for why it can only be decided in one place. This card renders it and
|
|
// adds the long-form detail underneath.
|
|
readonly property int observationCount: Health.observationCount
|
|
readonly property string heroTitle: Health.headline
|
|
readonly property string heroDetail: {
|
|
switch (Health.headlineState) {
|
|
case "unavailable":
|
|
return Health.lastError || "The latest health check could not be completed.";
|
|
case "checking":
|
|
return "Checking the desktop services, tools, and integrations this application owns.";
|
|
case "error":
|
|
return root.observationCount === 1
|
|
? "One part of the desktop needs action."
|
|
: `${root.observationCount} parts of the desktop need action.`;
|
|
case "warning":
|
|
return root.observationCount === 1
|
|
? "Your desktop is working. One feature needs a decision."
|
|
: `Your desktop is working. ${root.observationCount} features need a decision.`;
|
|
default:
|
|
return "Desktop services and tools are working normally.";
|
|
}
|
|
}
|
|
readonly property color statusColor: {
|
|
switch (Health.tone) {
|
|
case "danger": return Theme.danger;
|
|
case "warn": return Theme.warn;
|
|
case "muted": return Theme.fgMuted;
|
|
default: return Theme.ok;
|
|
}
|
|
}
|
|
|
|
function scanTime(): string {
|
|
const generatedAt = String(Health.snapshot.generatedAt || "");
|
|
if (generatedAt === "")
|
|
return "No completed check yet";
|
|
const date = new Date(generatedAt);
|
|
if (Number.isNaN(date.getTime()))
|
|
return "Last check completed";
|
|
return `Last checked ${date.toLocaleTimeString(Qt.locale(), Locale.ShortFormat)}`;
|
|
}
|
|
|
|
Item {
|
|
width: parent.width
|
|
implicitHeight: 96
|
|
|
|
Column {
|
|
anchors.left: parent.left
|
|
anchors.right: actions.left
|
|
anchors.rightMargin: 22
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
spacing: 4
|
|
|
|
Text {
|
|
width: parent.width
|
|
text: Health.diagnosticUnavailable
|
|
? "DIAGNOSTICS"
|
|
: root.observationCount > 0
|
|
? root.observationCount + (root.observationCount === 1 ? " OBSERVATION" : " OBSERVATIONS")
|
|
: "PANAMA DESKTOP"
|
|
color: root.statusColor
|
|
font.family: Theme.fontFamily
|
|
font.pixelSize: Theme.fontSizeSmall
|
|
font.weight: Font.DemiBold
|
|
font.letterSpacing: 1.15
|
|
}
|
|
|
|
Text {
|
|
width: parent.width
|
|
text: root.heroTitle
|
|
color: Theme.fg
|
|
font.family: Theme.fontFamily
|
|
font.pixelSize: 24
|
|
font.weight: Font.DemiBold
|
|
elide: Text.ElideRight
|
|
}
|
|
|
|
Text {
|
|
width: parent.width
|
|
text: root.heroDetail
|
|
color: Theme.fgDim
|
|
font.family: Theme.fontFamily
|
|
font.pixelSize: Theme.fontSizeSmall
|
|
elide: Text.ElideRight
|
|
}
|
|
|
|
Row {
|
|
spacing: 10
|
|
|
|
Text {
|
|
text: root.scanTime()
|
|
color: Theme.fgMuted
|
|
font.family: Theme.fontFamily
|
|
font.pixelSize: Theme.fontSizeSmall
|
|
}
|
|
|
|
Text {
|
|
objectName: "health-checking-label"
|
|
visible: Health.busy
|
|
text: "Checking…"
|
|
color: Theme.fgDim
|
|
font.family: Theme.fontFamily
|
|
font.pixelSize: Theme.fontSizeSmall
|
|
}
|
|
|
|
Text {
|
|
visible: Health.lastCopyResult !== ""
|
|
text: Health.lastCopyResult
|
|
color: Health.lastCopyResult === "Report copied." ? Theme.ok : Theme.warn
|
|
font.family: Theme.fontFamily
|
|
font.pixelSize: Theme.fontSizeSmall
|
|
}
|
|
}
|
|
}
|
|
|
|
Row {
|
|
id: actions
|
|
|
|
anchors.right: parent.right
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
spacing: 8
|
|
|
|
SettingsButton {
|
|
id: copyButton
|
|
|
|
objectName: "health-copy-report-button"
|
|
visible: !Health.diagnosticUnavailable
|
|
text: "Copy report"
|
|
enabled: Health.checks.length > 0
|
|
activeFocusOnTab: enabled
|
|
border.width: activeFocus ? 2 : 1
|
|
border.color: activeFocus ? Theme.accent : Theme.alpha(Theme.fg, 0.08)
|
|
onClicked: Health.copyReport()
|
|
Keys.onReturnPressed: if (enabled) Health.copyReport()
|
|
Keys.onSpacePressed: if (enabled) Health.copyReport()
|
|
}
|
|
|
|
SettingsButton {
|
|
id: refreshButton
|
|
|
|
objectName: "health-refresh-button"
|
|
text: Health.diagnosticUnavailable ? "Retry" : "Refresh"
|
|
tone: Health.diagnosticUnavailable ? "normal" : "accent"
|
|
enabled: !Health.busy
|
|
activeFocusOnTab: enabled
|
|
border.width: activeFocus ? 2 : (tone === "accent" ? 0 : 1)
|
|
border.color: activeFocus ? Theme.accent : Theme.alpha(Theme.fg, 0.08)
|
|
onClicked: Health.refresh()
|
|
Keys.onReturnPressed: if (enabled) Health.refresh()
|
|
Keys.onSpacePressed: if (enabled) Health.refresh()
|
|
}
|
|
}
|
|
}
|
|
}
|