QTfrontend/hwform.cpp
changeset 9549 ac5c1f691ce2
parent 9541 312bb4384f33
child 9648 3a3defce1b28
equal deleted inserted replaced
9547:f9e82f34c904 9549:ac5c1f691ce2
  1126     if (!ok || newNick.isEmpty())
  1126     if (!ok || newNick.isEmpty())
  1127     {
  1127     {
  1128         //ForcedDisconnect(tr("No nickname supplied."));
  1128         //ForcedDisconnect(tr("No nickname supplied."));
  1129         bool retry = RetryDialog(tr("Hedgewars - Empty nickname"), tr("No nickname supplied."));
  1129         bool retry = RetryDialog(tr("Hedgewars - Empty nickname"), tr("No nickname supplied."));
  1130         GoBack();
  1130         GoBack();
  1131         if (retry) {
  1131         if (retry && hwnet) {
  1132             if (hwnet->m_private_game) {
  1132             if (hwnet->m_private_game) {
  1133                 QStringList list = hwnet->getHost().split(":");
  1133                 QStringList list = hwnet->getHost().split(":");
  1134                 NetConnectServer(list.at(0), list.at(1).toShort());
  1134                 NetConnectServer(list.at(0), list.at(1).toShort());
  1135             } else
  1135             } else
  1136                 NetConnectOfficialServer();
  1136                 NetConnectOfficialServer();
  1137         }
  1137         }
  1138         return;
  1138         return;
  1139     }
  1139     }
  1140 
  1140 
  1141     hwnet->NewNick(newNick);
  1141     if(hwnet)
       
  1142         hwnet->NewNick(newNick);
  1142     config->setValue("net/nick", newNick);
  1143     config->setValue("net/nick", newNick);
  1143     config->updNetNick();
  1144     config->updNetNick();
  1144 
  1145 
  1145     ui.pageRoomsList->setUser(nick);
  1146     ui.pageRoomsList->setUser(nick);
  1146     ui.pageNetGame->setUser(nick);
  1147     ui.pageNetGame->setUser(nick);
  1158     config->clearPasswordHash();
  1159     config->clearPasswordHash();
  1159     config->clearTempHash();
  1160     config->clearTempHash();
  1160     if (retry) {
  1161     if (retry) {
  1161        NetConnectOfficialServer();
  1162        NetConnectOfficialServer();
  1162     }
  1163     }
       
  1164 }
       
  1165 
       
  1166 void HWForm::askRoomPassword()
       
  1167 {
       
  1168     QString password = QInputDialog::getText(this, tr("Room password"), tr("The room is protected with password.\nPlease, enter the password:"));
       
  1169     if(hwnet && !password.isEmpty())
       
  1170         hwnet->roomPasswordEntered(password);
  1163 }
  1171 }
  1164 
  1172 
  1165 bool HWForm::RetryDialog(const QString & title, const QString & label)
  1173 bool HWForm::RetryDialog(const QString & title, const QString & label)
  1166 {
  1174 {
  1167     QMessageBox retryMsg(this);
  1175     QMessageBox retryMsg(this);
  1239     connect(hwnet, SIGNAL(NickRegistered(const QString&)), this, SLOT(NetNickRegistered(const QString&)), Qt::QueuedConnection);
  1247     connect(hwnet, SIGNAL(NickRegistered(const QString&)), this, SLOT(NetNickRegistered(const QString&)), Qt::QueuedConnection);
  1240     connect(hwnet, SIGNAL(NickNotRegistered(const QString&)), this, SLOT(NetNickNotRegistered(const QString&)), Qt::QueuedConnection);
  1248     connect(hwnet, SIGNAL(NickNotRegistered(const QString&)), this, SLOT(NetNickNotRegistered(const QString&)), Qt::QueuedConnection);
  1241     connect(hwnet, SIGNAL(NickTaken(const QString&)), this, SLOT(NetNickTaken(const QString&)), Qt::QueuedConnection);
  1249     connect(hwnet, SIGNAL(NickTaken(const QString&)), this, SLOT(NetNickTaken(const QString&)), Qt::QueuedConnection);
  1242     connect(hwnet, SIGNAL(AuthFailed()), this, SLOT(NetAuthFailed()), Qt::QueuedConnection);
  1250     connect(hwnet, SIGNAL(AuthFailed()), this, SLOT(NetAuthFailed()), Qt::QueuedConnection);
  1243     //connect(ui.pageNetGame->BtnBack, SIGNAL(clicked()), hwnet, SLOT(partRoom()));
  1251     //connect(ui.pageNetGame->BtnBack, SIGNAL(clicked()), hwnet, SLOT(partRoom()));
       
  1252     connect(hwnet, SIGNAL(askForRoomPassword()), this, SLOT(askRoomPassword()), Qt::QueuedConnection);
  1244 
  1253 
  1245     ui.pageRoomsList->chatWidget->setUsersModel(hwnet->lobbyPlayersModel());
  1254     ui.pageRoomsList->chatWidget->setUsersModel(hwnet->lobbyPlayersModel());
  1246     ui.pageNetGame->chatWidget->setUsersModel(hwnet->roomPlayersModel());
  1255     ui.pageNetGame->chatWidget->setUsersModel(hwnet->roomPlayersModel());
  1247 
  1256 
  1248 // rooms list page stuff
  1257 // rooms list page stuff
  1255     connect(hwnet, SIGNAL(serverMessage(const QString&)),
  1264     connect(hwnet, SIGNAL(serverMessage(const QString&)),
  1256             ui.pageRoomsList->chatWidget, SLOT(onServerMessage(const QString&)), Qt::QueuedConnection);
  1265             ui.pageRoomsList->chatWidget, SLOT(onServerMessage(const QString&)), Qt::QueuedConnection);
  1257 
  1266 
  1258     connect(ui.pageRoomsList, SIGNAL(askForCreateRoom(const QString &, const QString &)),
  1267     connect(ui.pageRoomsList, SIGNAL(askForCreateRoom(const QString &, const QString &)),
  1259             hwnet, SLOT(CreateRoom(const QString&, const QString &)));
  1268             hwnet, SLOT(CreateRoom(const QString&, const QString &)));
  1260     connect(ui.pageRoomsList, SIGNAL(askForJoinRoom(const QString &)),
  1269     connect(ui.pageRoomsList, SIGNAL(askForJoinRoom(const QString &, const QString &)),
  1261             hwnet, SLOT(JoinRoom(const QString&)));
  1270             hwnet, SLOT(JoinRoom(const QString&, const QString &)));
  1262 //  connect(ui.pageRoomsList, SIGNAL(askForCreateRoom(const QString &)),
  1271 //  connect(ui.pageRoomsList, SIGNAL(askForCreateRoom(const QString &)),
  1263 //      this, SLOT(NetGameMaster()));
  1272 //      this, SLOT(NetGameMaster()));
  1264 //  connect(ui.pageRoomsList, SIGNAL(askForJoinRoom(const QString &)),
  1273 //  connect(ui.pageRoomsList, SIGNAL(askForJoinRoom(const QString &)),
  1265 //      this, SLOT(NetGameSlave()));
  1274 //      this, SLOT(NetGameSlave()));
  1266     connect(ui.pageRoomsList, SIGNAL(askForRoomList()),
  1275     connect(ui.pageRoomsList, SIGNAL(askForRoomList()),