magpie/qml/main.qml

69 lines
1.5 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
width: 640
height: 480
visible: true
title: "Magpie"
header: Label {
text: stack.currentItem.title
horizontalAlignment: Text.AlignHCenter
}
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 {
}
}
}
Connections {
target: API
function onAddressChanged (url) {
if (pickingServer && url.toString().length > 0)
stack.pop()
}
function onStateChanged (state) {
if (state === API.Authenticated)
stack.push(app)
}
}
}