2023-12-17 00:06:04 +00:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Controls
|
|
|
|
|
|
|
|
import magpie.API
|
2023-12-21 18:03:44 +00:00
|
|
|
import magpie.Components as Components
|
2023-12-17 00:06:04 +00:00
|
|
|
|
|
|
|
Column {
|
|
|
|
signal login()
|
2023-12-21 18:03:44 +00:00
|
|
|
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")
|
2023-12-21 18:03:44 +00:00
|
|
|
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
|
|
|
|
2023-12-21 18:03:44 +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()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|