import QtQuick
import QtQuick.Layouts
import org.kde.plasma.components as PlasmaComponents3
import org.kde.kirigami as Kirigami
import "Vigil.js" as Vigil
// An issue's latest event, kept short: the exception (or the message),
// its newest in-app frames, and the last few breadcrumbs.
ColumnLayout {
id: detail
property var cached: null // {loading, event} | {error}
readonly property var event: cached && cached.event ? cached.event : null
readonly property var exceptions: event ? Vigil.exceptions(event) : []
readonly property var primary: exceptions.length > 0 ? exceptions[0] : null
readonly property var frames: primary ? Vigil.topFrames(primary, 4) : []
readonly property var crumbs: event ? Vigil.breadcrumbs(event, 4) : []
readonly property string message: event ? Vigil.message(event) : ""
spacing: 2
PlasmaComponents3.BusyIndicator {
visible: !!detail.cached && !!detail.cached.loading && !detail.event
Layout.preferredWidth: Kirigami.Units.iconSizes.smallMedium
Layout.preferredHeight: Kirigami.Units.iconSizes.smallMedium
}
PlasmaComponents3.Label {
visible: !!detail.cached && !!detail.cached.error
Layout.fillWidth: true
wrapMode: Text.WordWrap
font: Kirigami.Theme.smallFont
color: Kirigami.Theme.negativeTextColor
text: detail.cached && detail.cached.error ? i18n("Couldn't load the latest event: %1", detail.cached.error) : ""
}
// ── exception ───────────────────────────────────────────────────────
RowLayout {
visible: !!detail.primary
Layout.fillWidth: true
spacing: Kirigami.Units.smallSpacing
PlasmaComponents3.Label {
Layout.fillWidth: true
wrapMode: Text.Wrap
maximumLineCount: 3
elide: Text.ElideRight
textFormat: Text.PlainText
font.family: "monospace"
font.pixelSize: Kirigami.Theme.smallFont.pixelSize
text: detail.primary
? (detail.primary.type || i18n("Error")) + (detail.primary.value ? ": " + detail.primary.value : "")
: ""
}
PlasmaComponents3.Label {
visible: !!detail.primary && !!detail.primary.mechanism && detail.primary.mechanism.handled === false
text: i18n("unhandled")
font.pixelSize: Kirigami.Theme.smallFont.pixelSize
font.bold: true
color: Vigil.colors.error
Layout.alignment: Qt.AlignTop
}
}
PlasmaComponents3.Label {
visible: !detail.primary && detail.message !== ""
Layout.fillWidth: true
wrapMode: Text.Wrap
maximumLineCount: 3
elide: Text.ElideRight
textFormat: Text.PlainText
font.pixelSize: Kirigami.Theme.smallFont.pixelSize
text: detail.message
}
// ── frames, newest first ────────────────────────────────────────────
Repeater {
model: detail.frames
RowLayout {
required property var modelData
readonly property var label: Vigil.frameLabel(modelData)
Layout.fillWidth: true
spacing: Kirigami.Units.smallSpacing
Rectangle {
Layout.preferredWidth: 5
Layout.preferredHeight: 5
radius: 2.5
color: modelData.inApp ? Kirigami.Theme.highlightColor : Kirigami.Theme.disabledTextColor
Layout.alignment: Qt.AlignVCenter
}
PlasmaComponents3.Label {
text: parent.label.fn
font.family: "monospace"
font.pixelSize: Kirigami.Theme.smallFont.pixelSize
font.bold: true
elide: Text.ElideRight
textFormat: Text.PlainText
Layout.maximumWidth: detail.width * 0.45
}
PlasmaComponents3.Label {
Layout.fillWidth: true
text: parent.label.where
font.family: "monospace"
font.pixelSize: Kirigami.Theme.smallFont.pixelSize
elide: Text.ElideLeft
textFormat: Text.PlainText
opacity: 0.7
}
}
}
// ── breadcrumbs, oldest of the last few first ───────────────────────
PlasmaComponents3.Label {
visible: detail.crumbs.length > 0
Layout.topMargin: 2
text: i18n("Breadcrumbs")
font.pixelSize: Kirigami.Theme.smallFont.pixelSize
font.bold: true
opacity: 0.7
}
Repeater {
model: detail.crumbs
RowLayout {
required property var modelData
Layout.fillWidth: true
spacing: Kirigami.Units.smallSpacing
Rectangle {
Layout.preferredWidth: 5
Layout.preferredHeight: 5
radius: 2.5
color: Vigil.levelColor(modelData.level === "info" ? "" : modelData.level)
Layout.alignment: Qt.AlignVCenter
}
PlasmaComponents3.Label {
text: Vigil.clockTime(modelData.timestamp)
font.pixelSize: Kirigami.Theme.smallFont.pixelSize
font.family: "monospace"
opacity: 0.6
}
PlasmaComponents3.Label {
text: modelData.category || modelData.type || ""
font.pixelSize: Kirigami.Theme.smallFont.pixelSize
font.bold: true
opacity: 0.8
Layout.maximumWidth: detail.width * 0.25
elide: Text.ElideRight
}
PlasmaComponents3.Label {
Layout.fillWidth: true
text: Vigil.crumbText(modelData)
font.pixelSize: Kirigami.Theme.smallFont.pixelSize
elide: Text.ElideRight
textFormat: Text.PlainText
}
}
}
PlasmaComponents3.Label {
visible: !!detail.event && !detail.primary && detail.message === "" && detail.crumbs.length === 0
text: i18n("No exception or breadcrumbs in the latest event")
font: Kirigami.Theme.smallFont
opacity: 0.6
}
}
neiam
/vigil-plasmoid
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
⭐
Log in to mark this repository.
6.4 KiB · text
History
905ae26