a-la-karte/src/qml/DiagnosticsSheet.qml

127 lines
4.2 KiB
QML
Raw Normal View History

2026-01-30 10:02:28 +00:00
import QtQuick
import QtQuick.Controls as QQC2
import QtQuick.Layouts
import org.kde.kirigami as Kirigami
import org.kde.alakarte
Kirigami.OverlaySheet {
id: diagnosticsSheet
property var game
property var launchInfo: ({})
title: i18n("Diagnostics")
parent: applicationWindow().overlay
closePolicy: QQC2.Popup.CloseOnEscape | QQC2.Popup.CloseOnPressOutside
implicitWidth: {
let w = applicationWindow()
if (!w) return Kirigami.Units.gridUnit * 30
if (w.isMobile) return w.width
if (w.isNarrowScreen) return w.width - Kirigami.Units.largeSpacing * 2
return Math.min(w.width - Kirigami.Units.gridUnit * 2, Kirigami.Units.gridUnit * 34)
}
implicitHeight: {
let w = applicationWindow()
if (!w) return Kirigami.Units.gridUnit * 30
if (w.isMobile) return w.height
return Math.min(w.height - Kirigami.Units.gridUnit * 2, Kirigami.Units.gridUnit * 42)
}
onOpened: {
if (game) {
launchInfo = App.launcher.resolveLaunchInfo(game)
} else {
launchInfo = ({ "ok": false, "error": i18n("No game selected") })
}
closeButton.forceActiveFocus()
}
header: Kirigami.ShadowedRectangle {
implicitHeight: headerRow.implicitHeight + Kirigami.Units.largeSpacing * 2
radius: Kirigami.Units.mediumSpacing
color: Kirigami.Theme.backgroundColor
RowLayout {
id: headerRow
anchors.fill: parent
anchors.margins: Kirigami.Units.largeSpacing
spacing: Kirigami.Units.mediumSpacing
Kirigami.Heading {
text: diagnosticsSheet.title
level: 2
Layout.fillWidth: true
elide: Text.ElideRight
}
QQC2.ToolButton {
id: closeButton
text: i18n("Close")
icon.name: "dialog-close"
display: QQC2.AbstractButton.IconOnly
onClicked: diagnosticsSheet.close()
}
}
}
contentItem: QQC2.ScrollView {
id: scroll
clip: true
ColumnLayout {
width: scroll.availableWidth
spacing: Kirigami.Units.largeSpacing
Kirigami.InlineMessage {
Layout.fillWidth: true
visible: launchInfo && launchInfo.ok === false
type: Kirigami.MessageType.Error
text: launchInfo && launchInfo.error ? launchInfo.error : i18n("Unknown error")
}
Kirigami.FormLayout {
Layout.fillWidth: true
QQC2.Label {
Kirigami.FormData.label: i18n("Launch command:")
text: launchInfo && launchInfo.launchCommand ? launchInfo.launchCommand : ""
wrapMode: Text.WrapAnywhere
}
QQC2.Label {
Kirigami.FormData.label: i18n("Runner:")
text: launchInfo && launchInfo.runner ? launchInfo.runner : i18n("None")
wrapMode: Text.WrapAnywhere
}
QQC2.Label {
Kirigami.FormData.label: i18n("Program:")
text: launchInfo && launchInfo.finalProgram ? launchInfo.finalProgram : ""
wrapMode: Text.WrapAnywhere
}
QQC2.Label {
Kirigami.FormData.label: i18n("Args:")
text: launchInfo && launchInfo.finalArgs ? launchInfo.finalArgs.join(" ") : ""
wrapMode: Text.WrapAnywhere
}
QQC2.Label {
Kirigami.FormData.label: i18n("Working directory:")
text: launchInfo && launchInfo.workingDirectory ? launchInfo.workingDirectory : i18n("Not specified")
wrapMode: Text.WrapAnywhere
}
QQC2.Label {
Kirigami.FormData.label: i18n("Prefix:")
text: launchInfo && launchInfo.resolvedPrefixPath ? launchInfo.resolvedPrefixPath : (launchInfo && launchInfo.prefixPath ? launchInfo.prefixPath : "")
wrapMode: Text.WrapAnywhere
}
}
}
}
}