mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-26 13:08:48 +03:00
Added QLabel for matrixIdError output and added new function which output input id error, improve code like suggest @deepbluev7, return for error_label setWordWrap
This commit is contained in:
parent
ec34af3d85
commit
8a2cfddf7e
2 changed files with 30 additions and 6 deletions
|
@ -108,6 +108,14 @@ LoginPage::LoginPage(QWidget *parent)
|
||||||
matrixidLayout_ = new QHBoxLayout();
|
matrixidLayout_ = new QHBoxLayout();
|
||||||
matrixidLayout_->addWidget(matrixid_input_, 0, Qt::AlignVCenter);
|
matrixidLayout_->addWidget(matrixid_input_, 0, Qt::AlignVCenter);
|
||||||
|
|
||||||
|
QFont font;
|
||||||
|
|
||||||
|
error_matrixid_label_ = new QLabel(this);
|
||||||
|
error_matrixid_label_->setFont(font);
|
||||||
|
|
||||||
|
matrixid_error_layout_ = new QVBoxLayout();
|
||||||
|
matrixid_error_layout_->addWidget(error_matrixid_label_, 0, Qt::AlignHCenter);
|
||||||
|
|
||||||
password_input_ = new TextField(this);
|
password_input_ = new TextField(this);
|
||||||
password_input_->setLabel(tr("Password"));
|
password_input_->setLabel(tr("Password"));
|
||||||
password_input_->setEchoMode(QLineEdit::Password);
|
password_input_->setEchoMode(QLineEdit::Password);
|
||||||
|
@ -129,6 +137,7 @@ LoginPage::LoginPage(QWidget *parent)
|
||||||
serverLayout_ = new QHBoxLayout();
|
serverLayout_ = new QHBoxLayout();
|
||||||
serverLayout_->addWidget(serverInput_, 0, Qt::AlignVCenter);
|
serverLayout_->addWidget(serverInput_, 0, Qt::AlignVCenter);
|
||||||
|
|
||||||
|
form_layout_->addLayout(matrixid_error_layout_);
|
||||||
form_layout_->addLayout(matrixidLayout_);
|
form_layout_->addLayout(matrixidLayout_);
|
||||||
form_layout_->addWidget(password_input_);
|
form_layout_->addWidget(password_input_);
|
||||||
form_layout_->addWidget(deviceName_, Qt::AlignHCenter);
|
form_layout_->addWidget(deviceName_, Qt::AlignHCenter);
|
||||||
|
@ -147,10 +156,9 @@ LoginPage::LoginPage(QWidget *parent)
|
||||||
button_layout_->addWidget(login_button_);
|
button_layout_->addWidget(login_button_);
|
||||||
button_layout_->addStretch(1);
|
button_layout_->addStretch(1);
|
||||||
|
|
||||||
QFont font;
|
|
||||||
|
|
||||||
error_label_ = new QLabel(this);
|
error_label_ = new QLabel(this);
|
||||||
error_label_->setFont(font);
|
error_label_->setFont(font);
|
||||||
|
error_label_->setWordWrap(true);
|
||||||
|
|
||||||
top_layout_->addLayout(top_bar_layout_);
|
top_layout_->addLayout(top_bar_layout_);
|
||||||
top_layout_->addStretch(1);
|
top_layout_->addStretch(1);
|
||||||
|
@ -183,6 +191,12 @@ LoginPage::loginError(const QString &msg)
|
||||||
error_label_->setText(msg);
|
error_label_->setText(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
LoginPage::matrixIdError(const QString &msg)
|
||||||
|
{
|
||||||
|
error_matrixid_label_->setText(msg);
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
LoginPage::isMatrixIdValid()
|
LoginPage::isMatrixIdValid()
|
||||||
{
|
{
|
||||||
|
@ -199,8 +213,11 @@ LoginPage::onMatrixIdEntered()
|
||||||
|
|
||||||
User user;
|
User user;
|
||||||
|
|
||||||
if (isMatrixIdValid() == 0) {
|
if (!isMatrixIdValid()) {
|
||||||
return loginError("You have entered an invalid Matrix ID e.g @joe:matrix.org");
|
matrixIdError("You have entered an invalid Matrix ID e.g @joe:matrix.org");
|
||||||
|
return ;
|
||||||
|
} else {
|
||||||
|
error_matrixid_label_->setText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -354,8 +371,12 @@ LoginPage::onLoginButtonClicked()
|
||||||
error_label_->setText("");
|
error_label_->setText("");
|
||||||
|
|
||||||
User user;
|
User user;
|
||||||
if (isMatrixIdValid() == 0) {
|
|
||||||
return loginError("You have entered an invalid Matrix ID e.g @joe:matrix.org");
|
if (!isMatrixIdValid()) {
|
||||||
|
matrixIdError("You have entered an invalid Matrix ID e.g @joe:matrix.org");
|
||||||
|
return ;
|
||||||
|
} else {
|
||||||
|
error_matrixid_label_->setText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -67,6 +67,7 @@ protected:
|
||||||
public slots:
|
public slots:
|
||||||
// Displays errors produced during the login.
|
// Displays errors produced during the login.
|
||||||
void loginError(const QString &msg);
|
void loginError(const QString &msg);
|
||||||
|
void matrixIdError(const QString &msg);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
// Callback for the back button.
|
// Callback for the back button.
|
||||||
|
@ -105,6 +106,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
QVBoxLayout *top_layout_;
|
QVBoxLayout *top_layout_;
|
||||||
|
QVBoxLayout *matrixid_error_layout_;
|
||||||
|
|
||||||
QHBoxLayout *top_bar_layout_;
|
QHBoxLayout *top_bar_layout_;
|
||||||
QHBoxLayout *logo_layout_;
|
QHBoxLayout *logo_layout_;
|
||||||
|
@ -112,6 +114,7 @@ private:
|
||||||
|
|
||||||
QLabel *logo_;
|
QLabel *logo_;
|
||||||
QLabel *error_label_;
|
QLabel *error_label_;
|
||||||
|
QLabel *error_matrixid_label_;
|
||||||
|
|
||||||
QHBoxLayout *serverLayout_;
|
QHBoxLayout *serverLayout_;
|
||||||
QHBoxLayout *matrixidLayout_;
|
QHBoxLayout *matrixidLayout_;
|
||||||
|
|
Loading…
Reference in a new issue