magpie/qml/main.qml

57 lines
1.1 KiB
QML
Raw Normal View History

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
2023-12-17 00:06:04 +00:00
import magpie.API
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
2023-11-22 23:13:33 +00:00
id: window
width: 640
height: 480
visible: true
2023-12-03 21:34:16 +00:00
title: "Magpie"
2023-11-24 23:48:01 +00:00
header: Label {
text: stack.currentItem.title
horizontalAlignment: Text.AlignHCenter
}
2023-11-22 23:13:33 +00:00
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 00:06:04 +00:00
StackView.onRemoved: pickingServer = false
}
Connections {
target: API
function onAddressChanged (url) {
if (pickingServer && url.toString().length > 0)
stack.pop()
}
2023-11-24 23:48:01 +00:00
}
Welcome {
id: welcome
onPickServer: function (address) {
2023-12-17 00:06:04 +00:00
const pick = pickComponent.createObject(stack);
2023-11-24 23:48:01 +00:00
pick.address = address;
2023-12-17 00:06:04 +00:00
stack.push(pick);
pickingServer = true;
2023-11-22 23:13:33 +00:00
}
2023-11-24 23:48:01 +00:00
}
2023-11-22 23:13:33 +00:00
2023-12-17 00:06:04 +00:00
Component {
id: pickComponent
ServerPick {
StackView.onRemoved: destroy()
onBack: stack.pop()
2023-11-22 23:13:33 +00:00
}
}
}