Fixed issues

This commit is contained in:
Fabio Bas 2015-06-30 21:40:39 +02:00
parent 02dcaff356
commit 6b54d8cbfd
2 changed files with 8 additions and 10 deletions

View file

@ -307,9 +307,7 @@ void MainWindow::loginError(Response::ResponseCode r, QString reasonStr, quint32
break; break;
} }
case Response::RespUsernameInvalid: { case Response::RespUsernameInvalid: {
QString errorStr; QMessageBox::critical(this, tr("Error"), extractInvalidUsernameMessage(reasonStr));
extractInvalidUsernameMessage(reasonStr, errorStr);
QMessageBox::critical(this, tr("Error"), errorStr);
break; break;
} }
case Response::RespRegistrationRequired: case Response::RespRegistrationRequired:
@ -335,9 +333,9 @@ void MainWindow::loginError(Response::ResponseCode r, QString reasonStr, quint32
actConnect(); actConnect();
} }
void MainWindow::extractInvalidUsernameMessage(QString & in, QString & out) QString MainWindow::extractInvalidUsernameMessage(QString & in)
{ {
out = tr("Invalid username.") + "<br/>"; QString out = tr("Invalid username.") + "<br/>";
QStringList rules = in.split(QChar('|')); QStringList rules = in.split(QChar('|'));
if (rules.size() == 7) if (rules.size() == 7)
{ {
@ -357,12 +355,14 @@ void MainWindow::extractInvalidUsernameMessage(QString & in, QString & out)
rules.at(6).toHtmlEscaped() rules.at(6).toHtmlEscaped()
#endif #endif
) + "</li>"; ) + "</li>";
if(rules.at(5).toInt() > 0) if(rules.at(5).toInt() == 0)
out += "<li>" + tr("the first character can't be a punctuation") + "</li>"; out += "<li>" + tr("the first character can't be a punctuation") + "</li>";
out += "</ul>"; out += "</ul>";
} else { } else {
out += tr("You may only use A-Z, a-z, 0-9, _, ., and - in your username."); 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) void MainWindow::registerError(Response::ResponseCode r, QString reasonStr, quint32 endTime)
@ -396,9 +396,7 @@ void MainWindow::registerError(Response::ResponseCode r, QString reasonStr, quin
break; break;
} }
case Response::RespUsernameInvalid: { case Response::RespUsernameInvalid: {
QString errorStr; QMessageBox::critical(this, tr("Error"), extractInvalidUsernameMessage(reasonStr));
extractInvalidUsernameMessage(reasonStr, errorStr);
QMessageBox::critical(this, tr("Error"), errorStr);
break; break;
} }
case Response::RespRegistrationFailed: case Response::RespRegistrationFailed:

View file

@ -109,7 +109,7 @@ public:
protected: protected:
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);
void changeEvent(QEvent *event); void changeEvent(QEvent *event);
void extractInvalidUsernameMessage(QString & in, QString & out); QString extractInvalidUsernameMessage(QString & in);
}; };
#endif #endif