2023-12-27 20:59:22 +00:00
|
|
|
// 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
|
2023-12-26 23:31:55 +00:00
|
|
|
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
|
2024-01-10 19:27:03 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2023-12-26 23:31:55 +00:00
|
|
|
|
|
|
|
Component {
|
|
|
|
id: app
|
|
|
|
Application.Root {
|
2024-01-10 19:27:03 +00:00
|
|
|
StackView.onActivating: runningApp = true;
|
|
|
|
StackView.onDeactivating: runningApp = false;
|
2023-12-26 23:31:55 +00:00
|
|
|
}
|
|
|
|
}
|
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()
|
|
|
|
}
|
2023-12-26 23:31:55 +00:00
|
|
|
function onStateChanged (state) {
|
2024-01-20 21:17:21 +00:00
|
|
|
if (state === Magpie.Authenticated)
|
2024-01-10 19:27:03 +00:00
|
|
|
stack.push(app);
|
2024-01-20 21:17:21 +00:00
|
|
|
else if (runningApp && state === Magpie.NotAuthenticated)
|
2024-01-10 19:27:03 +00:00
|
|
|
stack.pop();
|
2023-12-26 23:31:55 +00:00
|
|
|
}
|
2023-11-24 23:48:01 +00:00
|
|
|
}
|
2023-11-22 23:13:33 +00:00
|
|
|
}
|