Luigit
repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by admin

quickshell/nuguland/features/noko/NokoFocusOverlay.qml

Raw
pragma ComponentBehavior: Bound
import QtQuick
import "../.."

// Capture status tab: the noko entry's focus overlay. OverlayHost sizes it to the
// focused output's area outside the bar, so it centres the tab near its top edge.
// Below the phase, the newest words while capturing and transcribing, then the
// typed text while finished; long text elides at the start.
Item {
    id: overlay

    required property Theme theme
    required property Noko nokoService
    readonly property string phase: nokoService.overlayState
    property int tick: 0
    // Finished and failed rest: no wave, a mark instead.
    readonly property bool resting: phase === "finished" || phase === "failed"
    readonly property color accent: phase === "failed" ? theme.warning : (phase === "finished" ? theme.info : theme.ui.accent)
    readonly property string words: phase === "failed" || phase === "starting" ? "" : nokoService.liveText
    readonly property real wordsWidth: Math.max(160, Math.min(640, width - 120))

    visible: phase.length > 0

    Timer {
        interval: 90
        repeat: true
        // Low-power mode holds a still wave: no ticks, no geometry changes.
        running: overlay.visible && !overlay.resting && !overlay.theme.lowPowerMode
        onTriggered: overlay.tick++
    }

    Rectangle {
        id: statusTab

        objectName: "nokoStatusTab"
        x: Math.round((overlay.width - width) / 2)
        y: 18
        width: Math.max(178, tabColumn.implicitWidth + 28)
        height: Math.max(42, tabColumn.implicitHeight + 18)
        radius: overlay.theme.radiusSurface
        color: overlay.theme.withAlpha(overlay.theme.ui.backdrop, 0.92)
        border.width: 1
        border.color: overlay.theme.withAlpha(overlay.accent, 0.48)

        Column {
            id: tabColumn

            anchors.centerIn: parent
            spacing: 4

            Row {
                id: tabRow

                anchors.horizontalCenter: parent.horizontalCenter
                spacing: 12

                NuguText {
                    anchors.verticalCenter: parent.verticalCenter
                    theme: overlay.theme
                    variant: "title"
                    font.pixelSize: overlay.theme.textMeta
                    text: overlay.phase === "failed" ? overlay.nokoService.captureError : overlay.phase
                    color: overlay.accent
                }

                Row {
                    visible: !overlay.resting
                    anchors.verticalCenter: parent.verticalCenter
                    spacing: 3
                    height: 24

                    Repeater {
                        model: 7

                        Rectangle {
                            required property int index

                            objectName: index === 0 ? "nokoWaveBar" : ""
                            anchors.verticalCenter: parent.verticalCenter
                            width: 3
                            height: 7 + Math.abs(Math.sin((overlay.theme.lowPowerMode ? 0 : overlay.tick) / (overlay.phase === "transcribing" ? 2.8 : 1.8) + index)) * 17
                            radius: width / 2
                            color: overlay.accent
                            opacity: 0.82

                            Behavior on height {
                                NumberAnimation {
                                    duration: overlay.theme.lowPowerMode ? 0 : 90
                                    easing.type: Easing.OutCubic
                                }
                            }
                        }
                    }
                }

                Text {
                    visible: overlay.resting
                    anchors.verticalCenter: parent.verticalCenter
                    text: overlay.phase === "failed" ? "!" : "✓"
                    color: overlay.accent
                    font.family: overlay.theme.fontMono
                    font.pixelSize: 16
                    font.bold: true
                }
            }

            NuguText {
                objectName: "nokoLiveText"
                visible: text.length > 0
                anchors.horizontalCenter: parent.horizontalCenter
                width: Math.min(implicitWidth, overlay.wordsWidth)
                theme: overlay.theme
                userText: true
                elide: Text.ElideLeft
                text: overlay.words
            }
        }
    }
}