Luigit
repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by admin

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

Raw
import QtQuick
import QtQuick.Window
import Quickshell
import "../../.." as N
import "../../../features/media" as MediaFeature

// `just load-test media`: the registry entry's own panel, bound to the media
// double the load harness overlays. The player renders, then emptying the double
// flips the entry's empty flag and shows the empty state. No MPRIS, compositor,
// input, or pixels.
ShellRoot {
    id: root

    readonly property N.FeatureEntry feature: registry.popup("media")
    property bool emptied: false
    // The overlaid double's fixture surface; production Media has no setEmpty.
    readonly property var mediaDouble: registry.media

    function finish(): void {
        const panel = loader.item as MediaFeature.MediaPanel;
        if (!panel || panel.contentHeight <= 0)
            return;
        if (!root.emptied) {
            if (panel.hasMedia && !root.feature.empty && root.feature.barActive && root.feature.barLabel === "media") {
                root.emptied = true;
                root.mediaDouble.setEmpty(true);
            }
            return;
        }
        if (!panel.hasMedia && root.feature.empty) {
            console.log("load media: 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: 544
        height: 404
        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 media: registry panel never rendered its populated and empty fixture states");
            Qt.quit();
        }
    }
}