magpie/qml/main.qml

68 lines
1.6 KiB
QML

// SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
// SPDX-License-Identifier: GPL-3.0-or-later
import QtQuick
import QtQuick.Window
import QtQuick.Controls
import QtQuick.Layouts
import QtCore
import magpie
import magpie.Application as Application
ApplicationWindow {
property int counter: 0
property bool pickingServer: false
property bool runningApp: false
width: 640
height: 480
visible: true
title: "Magpie"
StackView {
id: stack
initialItem: welcome
anchors.fill: parent
Component {
id: welcome
Welcome {
onPickServer: stack.push(serverPick)
}
}
Component {
id: serverPick
ServerPick {
address: Magpie.address
onBack: stack.pop()
StackView.onActivating: pickingServer = true;
StackView.onDeactivating: pickingServer = false;
}
}
Component {
id: app
Application.Root {
StackView.onActivating: runningApp = true;
StackView.onDeactivating: runningApp = false;
}
}
}
Connections {
target: Magpie
function onAddressChanged (url) {
if (pickingServer && url.toString().length > 0)
stack.pop()
}
function onStateChanged (state) {
if (state === Magpie.Authenticated)
stack.push(app);
else if (runningApp && state === Magpie.NotAuthenticated)
stack.pop();
}
}
}