Luigit
repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by admin

quickshell/nuguland/features/clock/ClockBarControl.qml

Raw
import QtQuick
import QtQuick.Layouts
import "../.."

// The clock's bar presentation: HH | rule | MM in a row on a horizontal bar,
// HH / rule / MM stacked on a vertical one. The accent rule is a Rectangle, so
// it never depends on a font glyph. `label` is the entry's "HH:MM" barLabel.
BarControl {
    id: root

    required property Theme theme
    readonly property var parts: String(root.label).split(":")
    readonly property string hh: root.parts[0] || "--"
    readonly property string mm: root.parts[1] || "--"

    implicitWidth: content.implicitWidth + (root.vertical ? 12 : 16)
    implicitHeight: content.implicitHeight + (root.vertical ? 12 : 8)
    width: implicitWidth
    height: implicitHeight
    radius: 9
    color: !root.theme ? "transparent" : (root.selected ? root.theme.ui.focus : root.theme.withAlpha(root.theme.ui.minor, 0.1))
    clip: true

    GridLayout {
        id: content

        anchors.centerIn: parent
        columns: root.vertical ? 1 : 3
        rowSpacing: root.vertical ? 3 : 0
        columnSpacing: 6

        NuguText {
            Layout.alignment: Qt.AlignCenter
            theme: root.theme
            variant: "meta"
            text: root.hh
            color: !root.theme ? "transparent" : (root.selected ? root.theme.content.backdrop : root.theme.content.normal)
        }

        Rectangle {
            Layout.alignment: Qt.AlignCenter
            Layout.preferredWidth: root.vertical ? 16 : 2
            Layout.preferredHeight: root.vertical ? 2 : 14
            radius: 1
            color: root.theme ? root.theme.ui.accent : "transparent"
        }

        NuguText {
            Layout.alignment: Qt.AlignCenter
            theme: root.theme
            variant: "meta"
            text: root.mm
            color: !root.theme ? "transparent" : (root.selected ? root.theme.content.backdrop : root.theme.content.normal)
        }
    }
}