magpie/qml/Forms/Register.qml

106 lines
2.3 KiB
QML
Raw Normal View History

// SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
// SPDX-License-Identifier: GPL-3.0-or-later
2023-12-17 00:06:04 +00:00
import QtQuick
import QtQuick.Controls
2024-01-20 21:17:21 +00:00
import magpie
import magpie.Components as Components
2023-12-17 00:06:04 +00:00
Column {
signal login()
signal success(login: string, password: string)
2023-12-17 00:06:04 +00:00
2023-12-17 20:10:27 +00:00
spacing: 5
2023-12-17 00:06:04 +00:00
Label {
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("Please, chose login and password")
font {
pixelSize: 14
}
}
Grid {
anchors.horizontalCenter: parent.horizontalCenter
columns: 2
columnSpacing: 10
rowSpacing: 5
verticalItemAlignment: Grid.AlignVCenter
horizontalItemAlignment: Grid.AlignRight
Label {
text: qsTr("Login") + ":";
}
TextField {
id: newLogin
}
Label {
text: qsTr("Password") + ":";
}
TextField {
id: newPassword
echoMode: TextField.Password
}
}
Button {
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("Register")
onClicked: modal.check()
}
Components.Modal {
id: modal
function check () {
if (inProgress)
return;
inProgress = true;
status = qsTr("Registering") + " " + newLogin.text + "...";
open()
2023-12-17 00:06:04 +00:00
API.sendRegister(newLogin.text, newPassword.text, function (err, result) {
if (!modal.inProgress)
return;
modal.inProgress = false;
if (err)
modal.status = err;
else
modal.status = qsTr("Success");
if (!!result) {
modal.close();
success(newLogin.text, newPassword.text);
}
});
}
2023-12-17 00:06:04 +00:00
}
Row {
anchors.horizontalCenter: parent.horizontalCenter
spacing: 5
topPadding: 10
Label {
text: qsTr("Already have an account?")
}
Label {
text: qsTr("Log in") + "!"
font {
italic: true
underline: true
}
MouseArea {
anchors.fill: parent
onClicked: login()
}
}
}
}