import QtQuick Item { property var theme: null property var entries: [] readonly property var sections: entries.filter(entry => entry.configuration !== null).map(entry => entry.configuration) property string selectedSection: "appearance" readonly property var section: sections.find(candidate => candidate.name === selectedSection) || null property bool popupOpen: false property string mode: "dark" property bool busy: false property string error: "" property int writes: 0 property string requestedMode: "" property string orientation: "horizontal" property string orientationError: "" function setOrientation(value: string): string { const next = value === "toggle" ? (orientation === "vertical" ? "horizontal" : "vertical") : value; if (next === "horizontal" || next === "vertical") orientation = next; return orientation; } signal openRequested function selectSection(name: string): void { if (name === selectedSection || !sections.some(candidate => candidate.name === name)) return; if (popupOpen && section) section.left(); selectedSection = name; if (popupOpen && section) section.entered(); } function requestSection(name: string): void { selectSection(name); openRequested(); } function setOpen(value: bool): void { if (popupOpen === value) return; popupOpen = value; if (section) { if (value) section.entered(); else section.left(); } } function selectMode(value: string): void { if (busy || (value !== "dark" && value !== "light")) return; writes++; requestedMode = value; busy = true; error = ""; } function finishMode(partial: bool): void { mode = requestedMode; error = partial ? "desktop preference incomplete; retry selected mode" : ""; busy = false; } function externalUpdate(value: string): void { mode = value; } function fixtureState(): var { return { selectedSection: selectedSection, popupOpen: popupOpen, mode: mode, busy: busy, error: error, writes: writes, requestedMode: requestedMode, orientation: orientation, sectionScroll: section ? section.scrollY : 0, sectionFocusRow: section ? section.focusRow : -1 }; } }