summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2017-08-21 20:55:35 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2017-08-21 20:55:35 +0300
commit18625d9d2704151d65679f2523f012c25ed3b7de (patch)
tree70a6e1f98fd95dfe221f03f55a27fcf0a34ea78b /src
parentPlace the completion popup under the search widget (diff)
downloadnheko-18625d9d2704151d65679f2523f012c25ed3b7de.tar.xz
Fix login UX
The mxid input will not prevent the user from entering any invalid
value.

closes #22
Diffstat (limited to 'src')
-rw-r--r--src/LoginPage.cc19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/LoginPage.cc b/src/LoginPage.cc

index 402206fc..c4048f98 100644 --- a/src/LoginPage.cc +++ b/src/LoginPage.cc
@@ -155,8 +155,6 @@ LoginPage::LoginPage(QSharedPointer<MatrixClient> client, QWidget *parent) connect(client_.data(), SIGNAL(versionError(QString)), this, SLOT(versionError(QString))); connect(client_.data(), SIGNAL(versionSuccess()), this, SLOT(versionSuccess())); connect(serverInput_, SIGNAL(editingFinished()), this, SLOT(onServerAddressEntered())); - - matrixid_input_->setValidator(&InputValidator::Id); } void @@ -165,13 +163,22 @@ LoginPage::loginError(QString error) error_label_->setText(error); } +bool +LoginPage::isMatrixIdValid() +{ + int pos = 0; + auto matrix_id = matrixid_input_->text(); + + return InputValidator::Id.validate(matrix_id, pos) == QValidator::Acceptable; +} + void LoginPage::onMatrixIdEntered() { error_label_->setText(""); - if (!matrixid_input_->hasAcceptableInput()) { - loginError(tr("Invalid Matrix ID")); + if (!isMatrixIdValid()) { + loginError("You have entered an invalid Matrix ID e.g @joe:matrix.org"); return; } else if (password_input_->text().isEmpty()) { loginError(tr("Empty password")); @@ -255,8 +262,8 @@ LoginPage::onLoginButtonClicked() { error_label_->setText(""); - if (!matrixid_input_->hasAcceptableInput()) { - loginError("Invalid Matrix ID"); + if (!isMatrixIdValid()) { + loginError("You have entered an invalid Matrix ID e.g @joe:matrix.org"); } else if (password_input_->text().isEmpty()) { loginError("Empty password"); } else {