some more tinkering with qml
This commit is contained in:
parent
ed1ed9fb49
commit
89aa830bfa
@ -6,7 +6,7 @@ import magpie.API
|
||||
Column {
|
||||
signal register()
|
||||
|
||||
spacing: 10
|
||||
spacing: 5
|
||||
|
||||
Label {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
@ -6,7 +6,7 @@ import magpie.API
|
||||
Column {
|
||||
signal login()
|
||||
|
||||
spacing: 10
|
||||
spacing: 5
|
||||
|
||||
Label {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
@ -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
|
||||
|
||||
width: page.width
|
||||
height: stack.currentItem ? stack.currentItem.implicitHeight: 0
|
||||
|
||||
StackView {
|
||||
id: stack
|
||||
initialItem: loginForm
|
||||
anchors.fill: parent
|
||||
anchors.topMargin: 20
|
||||
|
||||
Component {
|
||||
id: loginForm
|
||||
Forms.Login {
|
||||
id: login
|
||||
visible: !forms.registering
|
||||
onRegister: forms.registering = true
|
||||
onRegister: stack.replace(registerForm)
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: registerForm
|
||||
Forms.Register {
|
||||
id: register
|
||||
visible: forms.registering
|
||||
onLogin: forms.registering = false
|
||||
onLogin: stack.replace(loginForm, StackView.PopTransition)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
37
qml/main.qml
37
qml/main.qml
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user