QTfrontend/hwform.cpp
changeset 8296 455da122c0ad
parent 8295 6ef114ea2298
child 8297 b236e3afed0d
equal deleted inserted replaced
8295:6ef114ea2298 8296:455da122c0ad
  1100     QString newNick = QInputDialog::getText(this, tr("Nickname"), tr("Someone already uses your nickname %1 on the server.\nPlease pick another nickname:").arg(nick), QLineEdit::Normal, nick, &ok);
  1100     QString newNick = QInputDialog::getText(this, tr("Nickname"), tr("Someone already uses your nickname %1 on the server.\nPlease pick another nickname:").arg(nick), QLineEdit::Normal, nick, &ok);
  1101 
  1101 
  1102     if (!ok || newNick.isEmpty())
  1102     if (!ok || newNick.isEmpty())
  1103     {
  1103     {
  1104         //ForcedDisconnect(tr("No nickname supplied."));
  1104         //ForcedDisconnect(tr("No nickname supplied."));
  1105 	int retry = RetryDialog("Hedgewars - Empty nickname", "No nickname supplied.");
  1105 	bool retry = RetryDialog(tr("Hedgewars - Empty nickname"), tr("No nickname supplied."));
  1106 	GoBack();
  1106 	GoBack();
  1107         if (retry) {
  1107         if (retry) {
  1108        	   NetConnectOfficialServer();
  1108        	   NetConnectOfficialServer();
  1109         }
  1109         }
  1110         return;
  1110         return;
  1122 {
  1122 {
  1123     // Set the password blank if case the user tries to join and enter his password again
  1123     // Set the password blank if case the user tries to join and enter his password again
  1124     config->clearTempHash();
  1124     config->clearTempHash();
  1125 
  1125 
  1126     //Try to login again
  1126     //Try to login again
  1127     bool retry = RetryDialog("Hedgewars - Wrong password", "You entered a wrong password.");
  1127     bool retry = RetryDialog(tr("Hedgewars - Wrong password"), tr("You entered a wrong password."));
  1128     GoBack();
  1128     GoBack();
  1129 
  1129 
  1130     if (retry) {
  1130     if (retry) {
  1131        NetConnectOfficialServer();
  1131        NetConnectOfficialServer();
  1132     }
  1132     }
  1141     retryMsg.setWindowModality(Qt::WindowModal);
  1141     retryMsg.setWindowModality(Qt::WindowModal);
  1142 
  1142 
  1143     retryMsg.addButton(QMessageBox::Cancel);
  1143     retryMsg.addButton(QMessageBox::Cancel);
  1144 
  1144 
  1145     QPushButton *retryButton = retryMsg.addButton(QMessageBox::Ok);
  1145     QPushButton *retryButton = retryMsg.addButton(QMessageBox::Ok);
  1146     retryButton->setText("Try Again");
  1146     retryButton->setText(tr("Try Again"));
  1147     retryButton->setFocus();
  1147     retryButton->setFocus();
  1148 
  1148 
  1149     retryMsg.exec();
  1149     retryMsg.exec();
  1150 
  1150 
  1151     if (retryMsg.clickedButton() == retryButton) {
  1151     if (retryMsg.clickedButton() == retryButton) {
  1361         nickname = pwDialog->leNickname->text();
  1361         nickname = pwDialog->leNickname->text();
  1362         password = pwDialog->lePassword->text();
  1362         password = pwDialog->lePassword->text();
  1363 
  1363 
  1364         //check the nickname variable
  1364         //check the nickname variable
  1365         if (nickname.isEmpty()) {
  1365         if (nickname.isEmpty()) {
  1366             int retry = RetryDialog("Hedgewars - Empty nickname", "No nickname supplied.");
  1366             int retry = RetryDialog(tr("Hedgewars - Empty nickname"), tr("No nickname supplied."));
  1367             GoBack();
  1367             GoBack();
  1368             delete pwDialog;
  1368             delete pwDialog;
  1369             if (retry) {
  1369             if (retry) {
  1370                 NetConnectOfficialServer();
  1370                 NetConnectOfficialServer();
  1371             }
  1371             }
  1476         hwnet->Disconnect();
  1476         hwnet->Disconnect();
  1477 }
  1477 }
  1478 
  1478 
  1479 void HWForm::ForcedDisconnect(const QString & reason)
  1479 void HWForm::ForcedDisconnect(const QString & reason)
  1480 {
  1480 {
       
  1481     if (reason == "Reconnected too fast") { //TODO: this is a hack, which should be remade
       
  1482         bool retry = RetryDialog(tr("Hedgewars - Connection error"), tr("You reconnected too fast.\nPlease wait a few seconds and try again."));
       
  1483         if (retry) {
       
  1484             NetConnectOfficialServer();
       
  1485         }
       
  1486         else {
       
  1487             while (ui.Pages->currentIndex() != ID_PAGE_NET
       
  1488                 && ui.Pages->currentIndex() != ID_PAGE_NETTYPE
       
  1489                 && ui.Pages->currentIndex() != ID_PAGE_MAIN) 
       
  1490             {
       
  1491                 GoBack();
       
  1492             }
       
  1493         }
       
  1494         return;
       
  1495     }
  1481     if (pnetserver)
  1496     if (pnetserver)
  1482         return; // we have server - let it care of all things
  1497         return; // we have server - let it care of all things
  1483     if (hwnet)
  1498     if (hwnet)
  1484     {
  1499     {
  1485         QString errorStr = QMessageBox::tr("Connection to server is lost") + (reason.isEmpty()?"":("\n\n" + HWNewNet::tr("Quit reason: ") + '"' + reason +'"'));
  1500         QString errorStr = QMessageBox::tr("Connection to server is lost") + (reason.isEmpty()?"":("\n\n" + HWNewNet::tr("Quit reason: ") + '"' + reason +'"'));