magpie/qml/main.qml

68 lines
1.6 KiB
QML
Raw Permalink Normal View History

// SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
// SPDX-License-Identifier: GPL-3.0-or-later
2023-11-22 23:13:33 +00:00
import QtQuick
import QtQuick.Window
import QtQuick.Controls
import QtQuick.Layouts
2023-12-05 22:17:27 +00:00
import QtCore
2023-11-24 23:48:01 +00:00
2024-01-20 21:17:21 +00:00
import magpie
import magpie.Application as Application
2023-11-24 23:48:01 +00:00
ApplicationWindow {
2023-11-22 23:13:33 +00:00
property int counter: 0
2023-12-17 00:06:04 +00:00
property bool pickingServer: false
property bool runningApp: false
2023-11-22 23:13:33 +00:00
width: 640
height: 480
visible: true
2023-12-03 21:34:16 +00:00
title: "Magpie"
2023-11-24 23:48:01 +00:00
StackView {
id: stack
initialItem: welcome
2023-11-22 23:13:33 +00:00
anchors.fill: parent
2023-12-17 20:10:27 +00:00
Component {
id: welcome
Welcome {
onPickServer: stack.push(serverPick)
}
}
Component {
id: serverPick
ServerPick {
2024-01-20 21:17:21 +00:00
address: Magpie.address
2023-12-17 20:10:27 +00:00
onBack: stack.pop()
StackView.onActivating: pickingServer = true;
StackView.onDeactivating: pickingServer = false;
}
}
Component {
id: app
Application.Root {
StackView.onActivating: runningApp = true;
StackView.onDeactivating: runningApp = false;
}
}
2023-12-17 00:06:04 +00:00
}
Connections {
2024-01-20 21:17:21 +00:00
target: Magpie
2023-12-17 00:06:04 +00:00
function onAddressChanged (url) {
if (pickingServer && url.toString().length > 0)
stack.pop()
}
function onStateChanged (state) {
2024-01-20 21:17:21 +00:00
if (state === Magpie.Authenticated)
stack.push(app);
2024-01-20 21:17:21 +00:00
else if (runningApp && state === Magpie.NotAuthenticated)
stack.pop();
}
2023-11-24 23:48:01 +00:00
}
2023-11-22 23:13:33 +00:00
}