diff --git a/qml/Forms/Login.qml b/qml/Forms/Login.qml index 698ab2c..c4e4d35 100644 --- a/qml/Forms/Login.qml +++ b/qml/Forms/Login.qml @@ -6,7 +6,7 @@ import magpie.API Column { signal register() - spacing: 10 + spacing: 5 Label { anchors.horizontalCenter: parent.horizontalCenter diff --git a/qml/Forms/Register.qml b/qml/Forms/Register.qml index 673efb3..f63941f 100644 --- a/qml/Forms/Register.qml +++ b/qml/Forms/Register.qml @@ -6,7 +6,7 @@ import magpie.API Column { signal login() - spacing: 10 + spacing: 5 Label { anchors.horizontalCenter: parent.horizontalCenter diff --git a/qml/Welcome.qml b/qml/Welcome.qml index 340b91c..c0380ab 100644 --- a/qml/Welcome.qml +++ b/qml/Welcome.qml @@ -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) + } + } } } } diff --git a/qml/main.qml b/qml/main.qml index 23160d6..b1c591d 100644 --- a/qml/main.qml +++ b/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() - } - } }