@vestra-player/sdk - v1.11.3
    Preparing search index...

    Type Alias SettingsPage

    SettingsPage: View & Disposable & { ready: Promise<void> }

    A page in the player's Options window, made by Settings.page.

    Type Declaration

    • Readonlyready: Promise<void>

      Resolves once the player has registered the page; rejects when it refused it.

      The player compiles the page on its own at registration, so a broken page fails here and does not affect the Options window. Pages added while activate runs must succeed before the plugin is ready: a rejection fails activation. Later failures also go to Scope.onError.

      ui-prepare (rejects) The Slint file does not compile; message has the diagnostics.

      invalid (rejects) The plugin already has 8 pages, or order is beyond ±1,000,000.

      host (rejects) The file is missing or outside the package directory.

    A View like a panel: properties and callbacks live on the file's bridge global, every callback of the global is forwarded, and there is no "bind before show" rule. The page exists from ready on, whether or not the Options window is open; property writes while it is closed are kept and applied when it opens. When pages are added or removed while the window is open, the player rebuilds it and restores every page's properties to the values last written, so mirror every user change in the plugin's state (and bind it), or it reverts.

    dispose(), disposing the scope or stopping the plugin removes the page; if it was showing, the window shows another page.

    Testing: host.settingsPage(id) of @vestra-player/sdk/testing has the page's props and emit(callback, ...args).

    Options ▸ Video ▸ Blur shows two check boxes whose values survive restarts. The checkboxes are bound two-way (<=>) to in-out properties of the bridge global, so the user's clicks show at once; the toggled callbacks tell the plugin, which saves the new value, and bind writes the stored values when the page opens.

    const store = plugin.storage.json("blur", {
    defaults: { restoreOnStart: false, messages: true },
    });
    const page = plugin.settings.page("ui/settings.slint", {
    id: "blur",
    category: "video",
    title: "Blur",
    });
    page.bind(() => ({
    restoreOnStart: store.value.restoreOnStart,
    messages: store.value.messages,
    }));
    // The bridge's `restore-toggled(bool)` callback, in camelCase.
    page.on("restoreToggled", (on: boolean) =>
    store.save({ ...store.value, restoreOnStart: on }),
    );
    page.on("messagesToggled", (on: boolean) =>
    store.save({ ...store.value, messages: on }),
    );

    ui/settings.slint exports the bridge global and the layout:

    import { CheckBox } from "std-widgets.slint";
    import { Theme } from "@vestra/theme.slint";
    
    // The bridge: what the plugin writes and the callbacks it handles.
    export global BlurPage {
        in-out property <bool> restore-on-start;
        in-out property <bool> messages: true;
        callback restore-toggled(bool);
        callback messages-toggled(bool);
    }
    
    export component BlurSettings inherits Rectangle {
        VerticalLayout {
            padding: Theme.dialog-padding;
            spacing: 6px;
            alignment: start;
            CheckBox {
                text: "Turn blur back on when the player starts";
                checked <=> BlurPage.restore-on-start;
                toggled => { BlurPage.restore-toggled(self.checked); }
            }
            CheckBox {
                text: "Show on-screen messages";
                checked <=> BlurPage.messages;
                toggled => { BlurPage.messages-toggled(self.checked); }
            }
        }
    }
    

    1.0.0