2019-04-28 08:54:33 +10:00
|
|
|
import QtQuick 2.7
|
2019-04-29 05:45:42 +10:00
|
|
|
import QtQuick.Layouts 1.3
|
2019-04-29 05:18:36 +10:00
|
|
|
import "../Base"
|
2019-04-28 08:54:33 +10:00
|
|
|
|
|
|
|
Item {
|
|
|
|
property string loginWith: "username"
|
|
|
|
onFocusChanged: identifierField.forceActiveFocus()
|
|
|
|
|
2019-04-29 05:18:36 +10:00
|
|
|
HInterfaceBox {
|
2019-04-28 08:54:33 +10:00
|
|
|
id: signInBox
|
|
|
|
title: "Sign in"
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
|
|
|
enterButtonTarget: "login"
|
|
|
|
|
|
|
|
buttonModel: [
|
|
|
|
{ name: "register", text: qsTr("Register") },
|
|
|
|
{ name: "login", text: qsTr("Login") },
|
|
|
|
{ name: "forgot", text: qsTr("Forgot?") }
|
|
|
|
]
|
|
|
|
|
|
|
|
buttonCallbacks: {
|
|
|
|
"register": function(button) {},
|
|
|
|
|
|
|
|
"login": function(button) {
|
2019-05-03 04:54:37 +10:00
|
|
|
var future = Backend.clients.new(
|
2019-04-28 11:07:20 +10:00
|
|
|
"matrix.org", identifierField.text, passwordField.text
|
2019-04-28 08:54:33 +10:00
|
|
|
)
|
2019-04-28 11:07:20 +10:00
|
|
|
button.loadingUntilFutureDone(future)
|
|
|
|
future.onGotResult.connect(function(client) {
|
|
|
|
pageStack.showPage(
|
|
|
|
"RememberAccount",
|
|
|
|
{"loginWith": loginWith, "client": client}
|
|
|
|
)
|
|
|
|
})
|
2019-04-28 08:54:33 +10:00
|
|
|
},
|
|
|
|
|
|
|
|
"forgot": function(button) {}
|
|
|
|
}
|
|
|
|
|
2019-04-29 05:18:36 +10:00
|
|
|
HRowLayout {
|
2019-04-28 08:54:33 +10:00
|
|
|
spacing: signInBox.margins * 1.25
|
|
|
|
Layout.margins: signInBox.margins
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
|
|
|
|
Repeater {
|
|
|
|
model: ["username", "email", "phone"]
|
|
|
|
|
2019-04-29 05:18:36 +10:00
|
|
|
HButton {
|
2019-04-28 08:54:33 +10:00
|
|
|
iconName: modelData
|
|
|
|
circle: true
|
|
|
|
checked: loginWith == modelData
|
|
|
|
autoExclusive: true
|
2019-05-14 00:52:26 +10:00
|
|
|
checkedLightens: true
|
2019-04-28 08:54:33 +10:00
|
|
|
onClicked: loginWith = modelData
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-29 05:18:36 +10:00
|
|
|
HTextField {
|
2019-04-28 08:54:33 +10:00
|
|
|
id: identifierField
|
|
|
|
placeholderText: qsTr(
|
|
|
|
loginWith === "email" ? "Email" :
|
|
|
|
loginWith === "phone" ? "Phone" :
|
|
|
|
"Username"
|
|
|
|
)
|
|
|
|
onAccepted: signInBox.clickEnterButtonTarget()
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.margins: signInBox.margins
|
|
|
|
}
|
|
|
|
|
2019-04-29 05:18:36 +10:00
|
|
|
HTextField {
|
2019-04-28 08:54:33 +10:00
|
|
|
id: passwordField
|
|
|
|
placeholderText: qsTr("Password")
|
2019-04-29 05:36:43 +10:00
|
|
|
echoMode: HTextField.Password
|
2019-04-28 08:54:33 +10:00
|
|
|
onAccepted: signInBox.clickEnterButtonTarget()
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.margins: signInBox.margins
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|