some more tinkering with qml

This commit is contained in:
Blue 2023-12-17 17:10:27 -03:00
parent ed1ed9fb49
commit 89aa830bfa
Signed by: blue
GPG Key ID: 9B203B252A63EE38
4 changed files with 44 additions and 38 deletions

View File

@ -6,7 +6,7 @@ import magpie.API
Column {
signal register()
spacing: 10
spacing: 5
Label {
anchors.horizontalCenter: parent.horizontalCenter

View File

@ -6,7 +6,7 @@ import magpie.API
Column {
signal login()
spacing: 10
spacing: 5
Label {
anchors.horizontalCenter: parent.horizontalCenter

View File

@ -6,13 +6,15 @@ import magpie.API
import "Forms" as Forms
Page {
id: page
signal pickServer(address: string)
title: qsTr("Welcome")
Column {
id: column
anchors.centerIn: parent
spacing: 10
spacing: 5
Label {
anchors.horizontalCenter: parent.horizontalCenter
@ -46,24 +48,31 @@ Page {
}
}
Row {
id: forms
property bool registering: false
Item {
visible: API.state === API.NotAuthenticated
anchors.horizontalCenter: parent.horizontalCenter
topPadding: 10
Forms.Login {
id: login
visible: !forms.registering
onRegister: forms.registering = true
}
width: page.width
height: stack.currentItem ? stack.currentItem.implicitHeight: 0
Forms.Register {
id: register
visible: forms.registering
onLogin: forms.registering = false
StackView {
id: stack
initialItem: loginForm
anchors.fill: parent
anchors.topMargin: 20
Component {
id: loginForm
Forms.Login {
onRegister: stack.replace(registerForm)
}
}
Component {
id: registerForm
Forms.Register {
onLogin: stack.replace(loginForm, StackView.PopTransition)
}
}
}
}
}

View File

@ -10,7 +10,6 @@ ApplicationWindow {
property int counter: 0
property bool pickingServer: false
id: window
width: 640
height: 480
visible: true
@ -25,7 +24,23 @@ ApplicationWindow {
id: stack
initialItem: welcome
anchors.fill: parent
StackView.onRemoved: pickingServer = false
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;
}
}
}
Connections {
@ -35,22 +50,4 @@ ApplicationWindow {
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()
}
}
}