Skip to content
Snippets Groups Projects
Commit ba599ee2 authored by Nicolas Werner's avatar Nicolas Werner
Browse files

[konheko] Fix some login page flow issues

* Fix page not transitioning back, if error happens to fast
* Fix error label not going away, when you fixed the login id
* Fix homeserver not updating, when you change your mxid
parent 62380000
No related branches found
No related tags found
No related merge requests found
Pipeline #147 passed
...@@ -65,9 +65,8 @@ Page { ...@@ -65,9 +65,8 @@ Page {
TextArea { TextArea {
id: user_parse_error id: user_parse_error
visible: false visible: text
color: "red" color: "red"
font.pixelSize: 0
wrapMode: Text.WrapAtWordBoundaryOrAnywhere wrapMode: Text.WrapAtWordBoundaryOrAnywhere
readOnly: true readOnly: true
...@@ -80,7 +79,6 @@ Page { ...@@ -80,7 +79,6 @@ Page {
target: login target: login
onUserParseError: { onUserParseError: {
user_parse_error.text = error; user_parse_error.text = error;
user_parse_error.visible = true;
} }
} }
...@@ -88,7 +86,6 @@ Page { ...@@ -88,7 +86,6 @@ Page {
target: login target: login
onHomeserverInvalid: { onHomeserverInvalid: {
user_parse_error.text = error; user_parse_error.text = error;
user_parse_error.visible = true;
column.validateLogin(); column.validateLogin();
} }
} }
...@@ -97,7 +94,7 @@ Page { ...@@ -97,7 +94,7 @@ Page {
target: login target: login
onLoginError: { onLoginError: {
user_parse_error.text = error; user_parse_error.text = error;
user_parse_error.visible = true; pageStack.completeAnimation();
pageStack.navigateBack(); pageStack.navigateBack();
column.validateLogin(); column.validateLogin();
} }
...@@ -108,12 +105,11 @@ Page { ...@@ -108,12 +105,11 @@ Page {
TextField { TextField {
id: mxid id: mxid
//: TextField hint for entering matrix id function validateInput() {
label: qsTr("@matrix-id:your.homeserver") if (activeFocus)
placeholderText: label return ;
EnterKey.enabled: text || inputMethodComposing
EnterKey.iconSource: "image://theme/icon-m-enter-next" user_parse_error.text = "";
EnterKey.onClicked: {
if (homeserver.text.length == 0) if (homeserver.text.length == 0)
homeserver.visible = false; homeserver.visible = false;
...@@ -121,6 +117,14 @@ Page { ...@@ -121,6 +117,14 @@ Page {
password.focus = true; password.focus = true;
column.validateLogin(); column.validateLogin();
} }
//: TextField hint for entering matrix id
label: qsTr("@matrix-id:your.homeserver")
placeholderText: label
EnterKey.enabled: text || inputMethodComposing
EnterKey.iconSource: "image://theme/icon-m-enter-next"
onActiveFocusChanged: validateInput()
EnterKey.onClicked: validateInput()
inputMethodHints: Qt.ImhNoPredictiveText inputMethodHints: Qt.ImhNoPredictiveText
anchors { anchors {
...@@ -184,6 +188,9 @@ Page { ...@@ -184,6 +188,9 @@ Page {
homeserver.text = server; homeserver.text = server;
homeserver.visible = true; homeserver.visible = true;
} }
onHomeserverValid: {
homeserver.text = server;
}
} }
validator: RegExpValidator { validator: RegExpValidator {
......
...@@ -100,6 +100,8 @@ void Login::validateServer(QString server) { ...@@ -100,6 +100,8 @@ void Login::validateServer(QString server) {
"the homeserver domain is valid.")); "the homeserver domain is valid."));
return; return;
} }
emit homeserverValid(server);
}); });
} }
...@@ -132,7 +134,7 @@ void Login::login(QString mxid, QString password, QString server) { ...@@ -132,7 +134,7 @@ void Login::login(QString mxid, QString password, QString server) {
http::client().login(user.localpart(), password.toStdString(), "Konheko", http::client().login(user.localpart(), password.toStdString(), "Konheko",
[this, homeserver](const mtx::responses::Login &response, mtx::http::RequestErr error) { [this, homeserver](const mtx::responses::Login &response, mtx::http::RequestErr error) {
if (error) { if (error) {
qDebug() << "Failed login!\n"; qDebug() << "Failed login!: " << *error;
if (!error->matrix_error.error.empty()) { if (!error->matrix_error.error.empty()) {
emit loginError(QString::fromStdString(error->matrix_error.error)); emit loginError(QString::fromStdString(error->matrix_error.error));
return; return;
......
...@@ -11,6 +11,7 @@ class Login : public QObject { ...@@ -11,6 +11,7 @@ class Login : public QObject {
signals: signals:
void userParseError(QString error); void userParseError(QString error);
void homeserverInvalid(QString server, QString error); void homeserverInvalid(QString server, QString error);
void homeserverValid(QString server);
void loginError(QString error); void loginError(QString error);
void loginSuccess(); void loginSuccess();
void loggedOut(); void loggedOut();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment