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

    Interface Settings

    Add pages to the player's Options window. plugin.settings.

    Use a settings page for preferences that change rarely. The player owns the Options window (640×480 by default, at least 600×420, resizable): a category tree on the left, the selected page on the right, a Close button at the bottom. The standard close keys close it, and command key bindings do not fire while it has focus. Opening it does not affect playback.

    A page file exports one component and one global, like a panel: the global (the bridge) declares the properties and callbacks, the component lays the page out and reads them. Pages are 440 logical pixels wide; the window scrolls a taller page.

    Options ▸ Playback ▸ Resume shows the plugin's Resume switch. page registers the page with the Options window (compiled by the player on its own), bind sends the stored value, and the page's callback saves the user's change.

    const store = plugin.storage.json("settings", { defaults: { resume: true } });
    const page = plugin.settings.page("ui/settings.slint", {
    id: "resume",
    category: "playback",
    title: "Resume",
    });
    page.bind(() => ({ resume: store.value.resume }));
    // The bridge's `resume-toggled(bool)`: save, and `bind` sends it back.
    page.on("resumeToggled", (on: boolean) => store.save({ ...store.value, resume: on }));

    1.0.0

    interface Settings {
        page(
            file: string,
            options: {
                id: string;
                category: SettingsCategory;
                title: string;
                order?: number;
            },
        ): SettingsPage;
        show(pageId?: string): Promise<void>;
    }
    Index
    • Add a page to the Options window.

      Parameters

      • file: string

        Path relative to the package directory, for example "ui/settings.slint".

      • options: { id: string; category: SettingsCategory; title: string; order?: number }

        The page's identity and place: id (unique in this plugin, 1–64 letters, digits, ., - or _), category, title (shown in the tree, 1–24 characters) and order (an integer within ±1,000,000, default 0; smaller first).

        • id: string

          Unique in this plugin: 1–64 letters, digits, ., - or _.

        • category: SettingsCategory

          Where the page appears in the tree.

        • title: string

          The page's name in the tree, 1–24 characters.

        • Optionalorder?: number

          An integer within ±1,000,000, smaller first (default 0).

      Returns SettingsPage

      A SettingsPage owned by this scope.

      The SDK finds the component and the global from the file's export component and export global lines; the file must export one of each. In the next microtask it registers the page with every property bound or set so far; ready reports the result.

      Within a category, pages are sorted by order, then by plugin id and page id.

      invalid (throws) A bad id, category, title or order, or this plugin already has a page with this id.

      Error without a code (throws) The file does not export exactly one component and one global. A file that cannot be read throws Node's file system error (code ENOENT and so on).

      An "My plugin" page appears under Plugins, or the reason it could not be added is logged. page returns at once; the player compiles the page on its own, and ready rejects (for example with ui-prepare and the compiler's diagnostics) when it refuses it.

      const page = plugin.settings.page("ui/advanced.slint", {
      id: "advanced",
      category: "plugins",
      title: "My plugin",
      order: 10, // after pages with a smaller order in the category
      });
      page.ready.catch((error: PluginError) => console.error(error.message));

      1.0.0

    • Open the Options window at one of this plugin's pages, or bring it to the front.

      Parameters

      • OptionalpageId: string

        The id of one of this plugin's pages.

      Returns Promise<void>

      Resolves once the window is shown.

      Without pageId it shows the page that is selected; when the window first opens, that is the page the user saw last (the player remembers it), else the first one.

      invalid (rejects) pageId is not a page of this plugin.

      unavailable (rejects) The player runs without a user interface.

      ui (rejects) The window could not be built (for example a page wrote a property its file does not declare).

      The button in the plugin's window opens the Options window at the plugin's Blur page, or brings it to the front. show takes the id the page was registered with and rejects with invalid for any other.

      const controls = plugin.windows.create("ui/window.slint");
      controls.on("openOptions", () => plugin.settings.show("blur"));

      1.0.0