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

// A small tinted pill with a dot: an event level, a monitor's state, as
// the Android app's.
Rectangle {
    id: pill

    property string text: ""
    property color pillColor: Kirigami.Theme.disabledTextColor

    implicitWidth: row.implicitWidth + Kirigami.Units.smallSpacing * 2
    implicitHeight: label.implicitHeight + 2
    radius: 3
    color: Qt.rgba(pillColor.r, pillColor.g, pillColor.b, 0.18)

    Row {
        id: row
        anchors.verticalCenter: parent.verticalCenter
        anchors.left: parent.left
        anchors.leftMargin: Kirigami.Units.smallSpacing
        spacing: 4

        Rectangle {
            anchors.verticalCenter: parent.verticalCenter
            width: 6
            height: 6
            radius: 3
            color: pill.pillColor
        }

        PlasmaComponents3.Label {
            id: label
            text: pill.text
            font.pixelSize: Kirigami.Theme.smallFont.pixelSize
            font.bold: true
            // Readable on a dark theme too.
            color: Kirigami.ColorUtils.brightnessForColor(Kirigami.Theme.backgroundColor) === Kirigami.ColorUtils.Dark
                   ? Qt.lighter(pill.pillColor, 1.35) : pill.pillColor
        }
    }
}