Luigit
repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by admin

quickshell/nuguland/features/launcher/fixtures/load.qml

Raw
import QtQuick
import QtQuick.Window
import Quickshell
import "../../.." as N
import "../../../features/launcher" as LauncherFeature

// `just load-test launcher`: the registry entry's own panel, bound to the
// launcher double the load harness overlays. Both apps render in title order, a
// query filters them through the panel's session state, launching the selected
// app reaches the service once, clears the query, and emits the panel's close
// intent, and the launched app then leads the empty query. No desktop entries,
// compositor, input, or pixels.
ShellRoot {
    id: root

    readonly property N.FeatureEntry feature: registry.popup("launcher")
    readonly property LauncherFeature.LauncherPanel panel: loader.item as LauncherFeature.LauncherPanel
    property int step: 0
    property string closeReason: ""
    // The overlaid double's fixture surface; production Launcher has no fixtureState.
    readonly property var launcherDouble: registry.launcher

    function finish(): void {
        const panel = root.panel;
        if (!panel || !panel.stateReady)
            return;
        if (root.step === 0 && panel.results.length === 2 && root.feature.barLabel === "apps" && panel.sessionState.selectedId === "editor") {
            root.step = 1;
            panel.setQuery("terminal");
        } else if (root.step === 1 && panel.results.length === 1 && panel.sessionState.selectedId === "terminal") {
            root.step = 2;
            panel.activateSelected();
        } else if (root.step === 2 && root.launcherDouble.fixtureState().activations === 1 && root.closeReason === "launcher-activated" && panel.sessionState.query === "") {
            root.step = 3;
        } else if (root.step === 3 && panel.results.length === 2 && panel.results[0].id === "terminal") {
            console.log("load launcher: PASS");
            Qt.quit();
        }
    }

    N.Theme {
        id: nuguTheme
    }

    N.Registry {
        id: registry

        theme: nuguTheme
    }

    Connections {
        target: root.panel
        function onCloseRequested(reason: string): void {
            root.closeReason = reason;
        }
    }

    // Plain Window: Quickshell windows set input masks the offscreen platform rejects.
    Window {
        width: 728
        height: 400
        visible: true
        color: "transparent"

        Loader {
            id: loader

            anchors.fill: parent
            sourceComponent: root.feature ? root.feature.panel : null
        }
    }

    Timer {
        interval: 25
        running: true
        repeat: true
        onTriggered: root.finish()
    }

    Timer {
        interval: 5000
        running: true
        onTriggered: {
            console.error("ERROR load launcher: registry panel never launched the double's filtered app, cleared its query, or listed it first");
            Qt.quit();
        }
    }
}