Luigit
repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by admin

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

Raw
import QtQuick
import QtQuick.Window
import Quickshell
import "../../.." as N
import "../../../features/clipboard" as ClipboardFeature

// `just load-test clipboard`: the registry entry's own panel, bound to the
// clipboard double the load harness overlays. Both rows render, a query filters
// them through the panel's session state, and an external update arrives
// filtered. No wl-paste, compositor, input, or pixels.
ShellRoot {
    id: root

    readonly property N.FeatureEntry feature: registry.popup("clipboard")
    property int step: 0
    // The overlaid double's fixture surface; production Clipboard has no externalUpdate.
    readonly property var clipboardDouble: registry.clipboard

    function finish(): void {
        const panel = loader.item as ClipboardFeature.ClipboardPanel;
        if (!panel || !panel.stateReady)
            return;
        if (root.step === 0 && panel.rows.length === 2 && root.feature.barLabel === "clips" && root.clipboardDouble.surfaces === null) {
            root.step = 1;
            panel.search("needle");
        } else if (root.step === 1 && panel.rows.length === 1 && panel.sessionState.selectedId === "clip-needle") {
            root.step = 2;
            root.clipboardDouble.externalUpdate();
        } else if (root.step === 2 && panel.rows.length === 2 && panel.query === "needle") {
            console.log("load clipboard: PASS");
            Qt.quit();
        }
    }

    N.Theme {
        id: nuguTheme
    }

    N.Registry {
        id: registry

        theme: nuguTheme
    }

    // Plain Window: Quickshell windows set input masks the offscreen platform rejects.
    Window {
        width: 488
        height: 528
        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 clipboard: registry panel never filtered the double's rows");
            Qt.quit();
        }
    }
}