From 6b54d8cbfdec6d9667b6d82e0ac346e486163ee5 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Tue, 30 Jun 2015 21:40:39 +0200 Subject: [PATCH] Fixed issues --- cockatrice/src/window_main.cpp | 16 +++++++--------- cockatrice/src/window_main.h | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/cockatrice/src/window_main.cpp b/cockatrice/src/window_main.cpp index ce85f37f..6e64a06f 100644 --- a/cockatrice/src/window_main.cpp +++ b/cockatrice/src/window_main.cpp @@ -307,9 +307,7 @@ void MainWindow::loginError(Response::ResponseCode r, QString reasonStr, quint32 break; } case Response::RespUsernameInvalid: { - QString errorStr; - extractInvalidUsernameMessage(reasonStr, errorStr); - QMessageBox::critical(this, tr("Error"), errorStr); + QMessageBox::critical(this, tr("Error"), extractInvalidUsernameMessage(reasonStr)); break; } case Response::RespRegistrationRequired: @@ -335,9 +333,9 @@ void MainWindow::loginError(Response::ResponseCode r, QString reasonStr, quint32 actConnect(); } -void MainWindow::extractInvalidUsernameMessage(QString & in, QString & out) +QString MainWindow::extractInvalidUsernameMessage(QString & in) { - out = tr("Invalid username.") + "
"; + QString out = tr("Invalid username.") + "
"; QStringList rules = in.split(QChar('|')); if (rules.size() == 7) { @@ -357,12 +355,14 @@ void MainWindow::extractInvalidUsernameMessage(QString & in, QString & out) rules.at(6).toHtmlEscaped() #endif ) + ""; - if(rules.at(5).toInt() > 0) + if(rules.at(5).toInt() == 0) out += "
  • " + tr("the first character can't be a punctuation") + "
  • "; out += ""; } else { out += tr("You may only use A-Z, a-z, 0-9, _, ., and - in your username."); } + + return out; } void MainWindow::registerError(Response::ResponseCode r, QString reasonStr, quint32 endTime) @@ -396,9 +396,7 @@ void MainWindow::registerError(Response::ResponseCode r, QString reasonStr, quin break; } case Response::RespUsernameInvalid: { - QString errorStr; - extractInvalidUsernameMessage(reasonStr, errorStr); - QMessageBox::critical(this, tr("Error"), errorStr); + QMessageBox::critical(this, tr("Error"), extractInvalidUsernameMessage(reasonStr)); break; } case Response::RespRegistrationFailed: diff --git a/cockatrice/src/window_main.h b/cockatrice/src/window_main.h index 9bde26b1..5c319318 100644 --- a/cockatrice/src/window_main.h +++ b/cockatrice/src/window_main.h @@ -109,7 +109,7 @@ public: protected: void closeEvent(QCloseEvent *event); void changeEvent(QEvent *event); - void extractInvalidUsernameMessage(QString & in, QString & out); + QString extractInvalidUsernameMessage(QString & in); }; #endif