import QtQuick
import "../.."
import "../../Window" as ShellWindow

ShellWindow.Window {
    id: quickSettingsWindow
    property var manager: ShellStateManager

    property var quickSettingsApp: null

    width: 1217 + 52
    height: 767 + 52
    visible: manager ? manager.quickSettingsOpen : false
    anchors.centerIn: parent

    Loader {
        id: quickSettingsLoader
        anchors.fill: parent
        asynchronous: true
        source: "./QuickSettingsApp.qml"
        onLoaded: {
            quickSettingsApp = item;
            if (quickSettingsApp)
                quickSettingsApp.manager = manager;
        }
    }

    onManagerChanged: {
        if (quickSettingsApp)
            quickSettingsApp.manager = manager;
    }

    QtObject {
        id: quickSettingsKeyHandler
        function handle(event) {
            if (quickSettingsApp && quickSettingsApp.handleKey)
                return quickSettingsApp.handleKey(event.key);
            return false;
        }

        Component.onCompleted: ShellInputManager.registerHandler("quickSettings", handle)
        Component.onDestruction: ShellInputManager.unregisterHandler("quickSettings")
    }
}
