lobbyroomrequest_moc.cpp 888 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include "lobbyroomrequest_moc.h"
  2. #include "ui_lobbyroomrequest_moc.h"
  3. LobbyRoomRequest::LobbyRoomRequest(SocketLobby & socket, const QString & room, QWidget *parent) :
  4. QDialog(parent),
  5. ui(new Ui::LobbyRoomRequest),
  6. socketLobby(socket)
  7. {
  8. ui->setupUi(this);
  9. ui->nameEdit->setText(room);
  10. if(!room.isEmpty())
  11. {
  12. ui->nameEdit->setReadOnly(true);
  13. ui->totalPlayers->setEnabled(false);
  14. }
  15. show();
  16. }
  17. LobbyRoomRequest::~LobbyRoomRequest()
  18. {
  19. delete ui;
  20. }
  21. void LobbyRoomRequest::on_buttonBox_accepted()
  22. {
  23. if(ui->nameEdit->isReadOnly())
  24. {
  25. socketLobby.requestJoinSession(ui->nameEdit->text(), ui->passwordEdit->text());
  26. }
  27. else
  28. {
  29. if(!ui->nameEdit->text().isEmpty())
  30. {
  31. int totalPlayers = ui->totalPlayers->currentIndex() + 2; //where 2 is a minimum amount of players
  32. socketLobby.requestNewSession(ui->nameEdit->text(), totalPlayers, ui->passwordEdit->text());
  33. }
  34. }
  35. }