2023-11-24 23:48:01 +00:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Controls
|
|
|
|
import QtQuick.Layouts
|
|
|
|
|
2023-12-17 00:06:04 +00:00
|
|
|
import magpie.API
|
2023-12-21 18:03:44 +00:00
|
|
|
import magpie.Forms as Forms
|
2023-11-24 23:48:01 +00:00
|
|
|
|
2023-12-16 01:44:25 +00:00
|
|
|
Page {
|
2023-12-17 20:10:27 +00:00
|
|
|
id: page
|
2023-11-24 23:48:01 +00:00
|
|
|
signal pickServer(address: string)
|
|
|
|
|
|
|
|
title: qsTr("Welcome")
|
|
|
|
|
|
|
|
Column {
|
2023-12-17 20:10:27 +00:00
|
|
|
id: column
|
2023-11-24 23:48:01 +00:00
|
|
|
anchors.centerIn: parent
|
2023-12-17 20:10:27 +00:00
|
|
|
spacing: 5
|
2023-11-24 23:48:01 +00:00
|
|
|
|
|
|
|
Label {
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2023-12-03 21:34:16 +00:00
|
|
|
text: qsTr("Welcome to Magpie!")
|
2023-11-24 23:48:01 +00:00
|
|
|
font {
|
|
|
|
pixelSize: 22
|
|
|
|
bold: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Row {
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
spacing: 5
|
|
|
|
|
|
|
|
Label {
|
|
|
|
horizontalAlignment: Label.AlignRight
|
|
|
|
text: qsTr("Current server:")
|
|
|
|
}
|
|
|
|
Label {
|
|
|
|
horizontalAlignment: Label.AlignLeft
|
2023-12-16 01:44:25 +00:00
|
|
|
text: API.state === API.NoServer ? qsTr("choose") : API.address
|
2023-11-24 23:48:01 +00:00
|
|
|
font {
|
|
|
|
italic: true
|
|
|
|
underline: true
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
2023-12-16 01:44:25 +00:00
|
|
|
onClicked: pickServer(API.address)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-17 20:10:27 +00:00
|
|
|
Item {
|
2023-12-16 01:44:25 +00:00
|
|
|
visible: API.state === API.NotAuthenticated
|
|
|
|
|
2023-12-17 20:10:27 +00:00
|
|
|
width: page.width
|
|
|
|
height: stack.currentItem ? stack.currentItem.implicitHeight: 0
|
2023-12-16 01:44:25 +00:00
|
|
|
|
2023-12-17 20:10:27 +00:00
|
|
|
StackView {
|
2023-12-21 18:03:44 +00:00
|
|
|
property string pendingLogin: ""
|
|
|
|
property string pendingPassword: ""
|
|
|
|
|
2023-12-17 20:10:27 +00:00
|
|
|
id: stack
|
|
|
|
initialItem: loginForm
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.topMargin: 20
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: loginForm
|
|
|
|
Forms.Login {
|
|
|
|
onRegister: stack.replace(registerForm)
|
2023-12-21 18:03:44 +00:00
|
|
|
Component.onCompleted: {
|
|
|
|
if (stack.pendingLogin && stack.pendingPassword)
|
|
|
|
this.login(stack.pendingLogin, stack.pendingPassword)
|
|
|
|
|
|
|
|
stack.pendingLogin = "";
|
|
|
|
stack.pendingPassword = "";
|
|
|
|
}
|
2023-12-17 20:10:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: registerForm
|
|
|
|
Forms.Register {
|
|
|
|
onLogin: stack.replace(loginForm, StackView.PopTransition)
|
2023-12-21 18:03:44 +00:00
|
|
|
onSuccess: function(login, password) {
|
|
|
|
stack.pendingLogin = login;
|
|
|
|
stack.pendingPassword = password;
|
|
|
|
stack.replace(loginForm, StackView.PopTransition);
|
|
|
|
}
|
2023-12-17 20:10:27 +00:00
|
|
|
}
|
|
|
|
}
|
2023-11-24 23:48:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|