magpie/qml/main.qml

66 lines
1.3 KiB
QML

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)
}
}
}