Use QLabel to display registration errors

remotes/origin/HEAD
Konstantinos Sideris 8 years ago
parent 73e73f46ea
commit c7c3ee19ee
  1. 6
      Makefile
  2. 5
      include/RegisterPage.h
  3. 2
      src/LoginPage.cc
  4. 5
      src/MainWindow.cc
  5. 33
      src/RegisterPage.cc

@ -1,13 +1,13 @@
run: build
run: debug
./build/nheko
debug:
@cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Debug
@make -C build
@make -C build -j2
release-debug:
@cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=RelWithDebInfo
@make -C build
@make -C build -j2
clean:
rm -rf build

@ -43,6 +43,10 @@ signals:
// responsible for the actual registering on the remote Matrix server.
void registerUser(const QString &username, const QString &password, const QString &server);
public slots:
// Display registration specific errors to the user.
void registerError(const QString &msg);
private slots:
void onBackButtonClicked();
void onRegisterButtonClicked();
@ -55,6 +59,7 @@ private:
QHBoxLayout *button_layout_;
QLabel *logo_;
QLabel *error_label_;
FlatButton *back_button_;
RaisedButton *register_button_;

@ -55,7 +55,7 @@ LoginPage::LoginPage(QWidget *parent)
form_layout_ = new QVBoxLayout();
form_layout_->setSpacing(20);
form_layout_->setContentsMargins(0, 00, 0, 30);
form_layout_->setContentsMargins(0, 0, 0, 30);
form_widget_->setLayout(form_layout_);
form_wrapper_->addStretch(1);

@ -88,8 +88,9 @@ void MainWindow::showChatPage(QString userid, QString homeserver, QString token)
void MainWindow::matrixRegister(const QString &username, const QString &password, const QString &server)
{
qDebug() << "About to register to Matrix";
qDebug() << "Username: " << username << " Password: " << password << " Server: " << server;
Q_UNUSED(password);
qDebug() << "Registering" << username << "at" << server;
}
void MainWindow::showWelcomePage()

@ -56,7 +56,7 @@ RegisterPage::RegisterPage(QWidget *parent)
form_layout_ = new QVBoxLayout();
form_layout_->setSpacing(20);
form_layout_->setContentsMargins(0, 00, 0, 60);
form_layout_->setContentsMargins(0, 0, 0, 40);
form_widget_->setLayout(form_layout_);
form_wrapper_->addStretch(1);
@ -92,7 +92,10 @@ RegisterPage::RegisterPage(QWidget *parent)
button_layout_ = new QHBoxLayout();
button_layout_->setSpacing(0);
button_layout_->setContentsMargins(0, 0, 0, 50);
button_layout_->setContentsMargins(0, 0, 0, 30);
error_label_ = new QLabel(this);
error_label_->setStyleSheet("margin-bottom: 20px; color: #E22826; font-size: 11pt;");
register_button_ = new RaisedButton("REGISTER", this);
register_button_->setBackgroundColor(QColor("#171919"));
@ -110,9 +113,10 @@ RegisterPage::RegisterPage(QWidget *parent)
top_layout_->addStretch(1);
top_layout_->addLayout(logo_layout_);
top_layout_->addLayout(form_wrapper_);
top_layout_->addStretch(2);
top_layout_->addStretch(1);
top_layout_->addLayout(button_layout_);
top_layout_->addStretch(1);
top_layout_->addWidget(error_label_, 0, Qt::AlignHCenter);
connect(back_button_, SIGNAL(clicked()), this, SLOT(onBackButtonClicked()));
connect(register_button_, SIGNAL(clicked()), this, SLOT(onRegisterButtonClicked()));
@ -134,24 +138,23 @@ void RegisterPage::onBackButtonClicked()
emit backButtonClicked();
}
void RegisterPage::registerError(const QString &msg)
{
error_label_->setText(msg);
}
void RegisterPage::onRegisterButtonClicked()
{
error_label_->setText("");
if (!username_input_->hasAcceptableInput()) {
QString text("Invalid username");
QPoint point = username_input_->mapToGlobal(username_input_->rect().topRight());
QToolTip::showText(point, text);
registerError("Invalid username");
} else if (!password_input_->hasAcceptableInput()) {
QString text("Password is not long enough");
QPoint point = password_input_->mapToGlobal(password_input_->rect().topRight());
QToolTip::showText(point, text);
registerError("Password is not long enough (min 8 chars)");
} else if (password_input_->text() != password_confirmation_->text()) {
QString text("Passwords don't match");
QPoint point = password_confirmation_->mapToGlobal(password_confirmation_->rect().topRight());
QToolTip::showText(point, text);
registerError("Passwords don't match");
} else if (!server_input_->hasAcceptableInput()) {
QString text("Invalid server name");
QPoint point = server_input_->mapToGlobal(server_input_->rect().topRight());
QToolTip::showText(point, text);
registerError("Invalid server name");
} else {
QString username = username_input_->text();
QString password = password_input_->text();

Loading…
Cancel
Save