2.4 KiB · text History 905ae26
import QtQuick
import QtQuick.Layouts
import org.kde.plasma.components as PlasmaComponents3
import org.kde.kirigami as Kirigami

// One cron or uptime monitor: its state, name, project and the line that
// says how it's doing. Click opens it on the web.
PlasmaComponents3.ItemDelegate {
    id: monitorItem

    required property var store
    required property var row

    topPadding: Kirigami.Units.smallSpacing
    bottomPadding: Kirigami.Units.smallSpacing
    onClicked: Qt.openUrlExternally(row.url)

    contentItem: RowLayout {
        spacing: Kirigami.Units.smallSpacing

        Pill {
            text: monitorItem.row.state.label
            pillColor: monitorItem.row.state.color
            Layout.alignment: Qt.AlignTop
            Layout.preferredWidth: Kirigami.Units.gridUnit * 3.6
        }

        ColumnLayout {
            Layout.fillWidth: true
            spacing: 0

            RowLayout {
                Layout.fillWidth: true
                spacing: Kirigami.Units.smallSpacing

                Kirigami.Icon {
                    source: monitorItem.row.kind === "cron" ? "chronometer" : "network-connect"
                    Layout.preferredWidth: Kirigami.Units.iconSizes.small
                    Layout.preferredHeight: Kirigami.Units.iconSizes.small
                    opacity: 0.7
                }

                PlasmaComponents3.Label {
                    Layout.fillWidth: true
                    text: monitorItem.row.name
                    elide: Text.ElideRight
                    font.bold: monitorItem.row.state.failing
                }

                PlasmaComponents3.Label {
                    visible: monitorItem.store.watchedProjects.length !== 1
                    text: monitorItem.row.project.name || monitorItem.row.project.slug
                    font: Kirigami.Theme.smallFont
                    opacity: 0.6
                    elide: Text.ElideRight
                    Layout.maximumWidth: Kirigami.Units.gridUnit * 7
                }
            }

            PlasmaComponents3.Label {
                visible: text !== ""
                Layout.fillWidth: true
                text: monitorItem.row.detail
                font: Kirigami.Theme.smallFont
                opacity: 0.7
                elide: Text.ElideRight
                color: monitorItem.row.state.failing ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.textColor
            }
        }
    }
}