magpie/qml/main.qml
2023-12-16 21:06:04 -03:00

57 lines
1.1 KiB
QML

import QtQuick
import QtQuick.Window
import QtQuick.Controls
import QtQuick.Layouts
import QtCore
import magpie.API
ApplicationWindow {
property int counter: 0
property bool pickingServer: false
id: window
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
StackView.onRemoved: pickingServer = false
}
Connections {
target: API
function onAddressChanged (url) {
if (pickingServer && url.toString().length > 0)
stack.pop()
}
}
Welcome {
id: welcome
onPickServer: function (address) {
const pick = pickComponent.createObject(stack);
pick.address = address;
stack.push(pick);
pickingServer = true;
}
}
Component {
id: pickComponent
ServerPick {
StackView.onRemoved: destroy()
onBack: stack.pop()
}
}
}