Fix login UX
The mxid input will not prevent the user from entering any invalid value. closes #22
This commit is contained in:
parent
c6ec20fa40
commit
18625d9d27
@ -66,6 +66,8 @@ private slots:
|
|||||||
void versionSuccess();
|
void versionSuccess();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool isMatrixIdValid();
|
||||||
|
|
||||||
QVBoxLayout *top_layout_;
|
QVBoxLayout *top_layout_;
|
||||||
|
|
||||||
QHBoxLayout *top_bar_layout_;
|
QHBoxLayout *top_bar_layout_;
|
||||||
|
@ -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(versionError(QString)), this, SLOT(versionError(QString)));
|
||||||
connect(client_.data(), SIGNAL(versionSuccess()), this, SLOT(versionSuccess()));
|
connect(client_.data(), SIGNAL(versionSuccess()), this, SLOT(versionSuccess()));
|
||||||
connect(serverInput_, SIGNAL(editingFinished()), this, SLOT(onServerAddressEntered()));
|
connect(serverInput_, SIGNAL(editingFinished()), this, SLOT(onServerAddressEntered()));
|
||||||
|
|
||||||
matrixid_input_->setValidator(&InputValidator::Id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -165,13 +163,22 @@ LoginPage::loginError(QString error)
|
|||||||
error_label_->setText(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
|
void
|
||||||
LoginPage::onMatrixIdEntered()
|
LoginPage::onMatrixIdEntered()
|
||||||
{
|
{
|
||||||
error_label_->setText("");
|
error_label_->setText("");
|
||||||
|
|
||||||
if (!matrixid_input_->hasAcceptableInput()) {
|
if (!isMatrixIdValid()) {
|
||||||
loginError(tr("Invalid Matrix ID"));
|
loginError("You have entered an invalid Matrix ID e.g @joe:matrix.org");
|
||||||
return;
|
return;
|
||||||
} else if (password_input_->text().isEmpty()) {
|
} else if (password_input_->text().isEmpty()) {
|
||||||
loginError(tr("Empty password"));
|
loginError(tr("Empty password"));
|
||||||
@ -255,8 +262,8 @@ LoginPage::onLoginButtonClicked()
|
|||||||
{
|
{
|
||||||
error_label_->setText("");
|
error_label_->setText("");
|
||||||
|
|
||||||
if (!matrixid_input_->hasAcceptableInput()) {
|
if (!isMatrixIdValid()) {
|
||||||
loginError("Invalid Matrix ID");
|
loginError("You have entered an invalid Matrix ID e.g @joe:matrix.org");
|
||||||
} else if (password_input_->text().isEmpty()) {
|
} else if (password_input_->text().isEmpty()) {
|
||||||
loginError("Empty password");
|
loginError("Empty password");
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user