Viergewinnt (four-in-a-row) implementation in c++ and QT
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

creategame.cpp 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* VierGewinnt - A simple 4-in-a-row network game
  2. *
  3. * Copyright (c) 2008 by Sebastian Lohff, seba@seba-geek.de
  4. * http://www.seba-geek.de
  5. *
  6. * This file is part of VierGewinnt.
  7. *
  8. * VierGewinnt is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * VierGewinnt is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with VierGewinnt. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #include "creategame.h"
  22. CreateGameDialog::CreateGameDialog(QTcpSocket *_mysock, QWidget *parent) : QDialog(parent) {
  23. mysock = _mysock;
  24. setWindowTitle(tr("Neues Spiel"));
  25. // stat = new QLabel("");
  26. gname = new QLabel(tr("Spielname"));
  27. editgname = new QLineEdit;
  28. ok = new QPushButton(tr("Ok"));
  29. connect(ok, SIGNAL(clicked()), this, SLOT(startListen()));
  30. cancel = new QPushButton(tr("Abbrechen"));
  31. connect(cancel, SIGNAL(clicked()), this, SLOT(reject()));
  32. layout = new QGridLayout;
  33. // layout->addWidget(stat, 0, 0, 1, 2);
  34. layout->addWidget(gname, 1, 0);
  35. layout->addWidget(editgname, 1, 1);
  36. layout->addWidget(ok, 2, 0);
  37. layout->addWidget(cancel, 2, 1);
  38. setLayout(layout);
  39. setModal(Qt::WindowModal);
  40. }
  41. // void CreateGameDialog::reset() {
  42. // stat->setText("");
  43. // ok->show();
  44. // }
  45. void CreateGameDialog::startListen() {
  46. QTextStream sockstream(mysock);
  47. if(editgname->text()=="")
  48. editgname->insert(tr("Unbenanntes Spiel"));
  49. sockstream << "CREATE " << editgname->text() << "\n";
  50. accept();
  51. }