magpie/qml/Forms/Login.qml

104 lines
2.1 KiB
QML
Raw Normal View History

2023-12-17 00:06:04 +00:00
import QtQuick
import QtQuick.Controls
import magpie.API
import magpie.Components as Components
2023-12-17 00:06:04 +00:00
Column {
signal register()
function login(login, password) {
if (modal.inProgress)
return;
loginField.text = login;
passwordField.text = password;
modal.inProgress = true;
modal.status = qsTr("Logging in as") + " " + login + "...";
modal.open();
API.sendLogin(login, password, function (err, result) {
if (!modal.inProgress)
return;
modal.inProgress = false;
if (err)
modal.status = err;
else
modal.status = qsTr("Success");
if (!!result)
modal.close();
});
}
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, log in to your account")
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: loginField
2023-12-17 00:06:04 +00:00
}
Label {
text: qsTr("Password") + ":";
}
TextField {
id: passwordField
2023-12-17 00:06:04 +00:00
echoMode: TextField.Password
}
}
Button {
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("Login")
onClicked: login(loginField.text, passwordField.text)
}
Components.Modal {
id: modal
2023-12-17 00:06:04 +00:00
}
Row {
anchors.horizontalCenter: parent.horizontalCenter
spacing: 5
topPadding: 10
Label {
text: qsTr("Don't have account?")
}
Label {
text: qsTr("Sign up") + "!"
font {
italic: true
underline: true
}
MouseArea {
anchors.fill: parent
onClicked: register()
}
}
}
}