import QtQuick Item { property int generation: 0 property bool powered: false property bool found: false property bool trusted: true property bool blocked: false property bool forgotten: false // A later scan finds a device that sends no name, only its address. property bool namelessFound: false // The typed state the production service exposes to the panel. readonly property bool adapterAvailable: true readonly property bool adapterPowered: powered || generation > 0 readonly property bool adapterDiscovering: false readonly property string error: "" readonly property var devices: namelessFound ? [ { "id": "AA:BB:CC:DD:EE:FF", "name": "AA:BB:CC:DD:EE:FF", "type": "", "connected": false, "paired": false, "trusted": false, "blocked": false, "battery": -1 } ] : found && powered && !forgotten ? [ { "id": "fixture-headphones", "name": "fixture headphones", "type": "audio-headphones", "connected": true, "paired": true, "trusted": trusted, "blocked": blocked, "battery": 80 } ] : [] function toggle(enabled) { powered = enabled; } // A scan that finds the fixture headphones at once; after they are forgotten, a nameless device. function scan() { powered = true; found = true; namelessFound = forgotten; } // Trust, block and forget act on the fixture headphones at once. function deviceAction(kind, id) { if (kind === "trust" || kind === "untrust") trusted = kind === "trust"; if (kind === "block" || kind === "unblock") blocked = kind === "block"; if (kind === "forget") forgotten = true; } // A live adapter refresh, e.g. after an asynchronous action, while the popup is open. function externalUpdate() { generation++; } function fixtureState() { return { "powered": powered, "found": found }; } }