summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2017-04-07 19:25:06 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2017-04-07 19:25:06 +0300
commitc7c3ee19ee66ab5f3ad57c16f546e35674093c0d (patch)
treebfe5f7129977344e70f9f52d2cab9ec7f744cbc8 /src
parentUse const refs for the deserialized data (diff)
downloadnheko-c7c3ee19ee66ab5f3ad57c16f546e35674093c0d.tar.xz
Use QLabel to display registration errors
Diffstat (limited to 'src')
-rw-r--r--src/LoginPage.cc2
-rw-r--r--src/MainWindow.cc5
-rw-r--r--src/RegisterPage.cc33
3 files changed, 22 insertions, 18 deletions
diff --git a/src/LoginPage.cc b/src/LoginPage.cc
index 68927c33..54eda384 100644
--- a/src/LoginPage.cc
+++ b/src/LoginPage.cc
@@ -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);
diff --git a/src/MainWindow.cc b/src/MainWindow.cc
index 82976f23..3989e096 100644
--- a/src/MainWindow.cc
+++ b/src/MainWindow.cc
@@ -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()
diff --git a/src/RegisterPage.cc b/src/RegisterPage.cc
index fcb43b86..bad6eeb4 100644
--- a/src/RegisterPage.cc
+++ b/src/RegisterPage.cc
@@ -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();