68 lines
1.6 KiB
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.API
|
|
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: API.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: API
|
|
function onAddressChanged (url) {
|
|
if (pickingServer && url.toString().length > 0)
|
|
stack.pop()
|
|
}
|
|
function onStateChanged (state) {
|
|
if (state === API.Authenticated)
|
|
stack.push(app);
|
|
else if (runningApp && state === API.NotAuthenticated)
|
|
stack.pop();
|
|
}
|
|
}
|
|
}
|