magpie/qml/Welcome.qml

95 lines
2.7 KiB
QML
Raw Normal View History

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
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)
2023-12-25 20:07:51 +00:00
// title: qsTr("Welcome")
2023-11-24 23:48:01 +00:00
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 {
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)
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)
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
}
}
}
}