lobbyroomrequest_moc.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * lobbyroomrequest_moc.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "lobbyroomrequest_moc.h"
  11. #include "ui_lobbyroomrequest_moc.h"
  12. LobbyRoomRequest::LobbyRoomRequest(SocketLobby & socket, const QString & room, const QMap<QString, QString> & mods, QWidget *parent) :
  13. QDialog(parent),
  14. ui(new Ui::LobbyRoomRequest),
  15. socketLobby(socket),
  16. mods(mods)
  17. {
  18. ui->setupUi(this);
  19. ui->nameEdit->setText(room);
  20. if(!room.isEmpty())
  21. {
  22. ui->nameEdit->setReadOnly(true);
  23. ui->totalPlayers->setEnabled(false);
  24. }
  25. show();
  26. }
  27. void LobbyRoomRequest::changeEvent(QEvent *event)
  28. {
  29. if(event->type() == QEvent::LanguageChange)
  30. {
  31. ui->retranslateUi(this);
  32. }
  33. QDialog::changeEvent(event);
  34. }
  35. LobbyRoomRequest::~LobbyRoomRequest()
  36. {
  37. delete ui;
  38. }
  39. void LobbyRoomRequest::on_buttonBox_accepted()
  40. {
  41. if(ui->nameEdit->isReadOnly())
  42. {
  43. socketLobby.requestJoinSession(ui->nameEdit->text(), ui->passwordEdit->text(), mods);
  44. }
  45. else
  46. {
  47. if(!ui->nameEdit->text().isEmpty())
  48. {
  49. int totalPlayers = ui->totalPlayers->currentIndex() + 2; //where 2 is a minimum amount of players
  50. socketLobby.requestNewSession(ui->nameEdit->text(), totalPlayers, ui->passwordEdit->text(), mods);
  51. }
  52. }
  53. }