Dialog.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include "Dialog.h"
  2. #include "options.h"
  3. #include <QBoxLayout>
  4. #include <QLineEdit>
  5. #include <QSpinBox>
  6. #include <QDialogButtonBox>
  7. #include <QLabel>
  8. #include <QFormLayout>
  9. #include <QCheckBox>
  10. Dialog::Dialog(Options *option, QWidget *parent) :
  11. QDialog(parent),
  12. _option(option)
  13. {
  14. QHBoxLayout *layoutLineEdit = new QHBoxLayout;
  15. //QHBoxLayout *layoutTemps = new QHBoxLayout;
  16. QVBoxLayout *layoutDialog = new QVBoxLayout;
  17. QFormLayout *layoutForm = new QFormLayout;
  18. QDialogButtonBox *boutonJouer = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
  19. checkBoxSon = new QCheckBox();
  20. checkBoxSon->setChecked(option->son());
  21. spinTempsDepart = new QSpinBox;
  22. spinTempsDepart->setMinimum(1);
  23. spinTempsDepart->setMaximum(300);
  24. spinTempsDepart->setValue(option->tempsDepart());
  25. joueur1LineEdit = new QLineEdit(option->nomJoueur1() , this);
  26. joueur2LineEdit = new QLineEdit(option->nomJoueur2() , this);
  27. joueur1LineEdit->selectAll();
  28. layoutLineEdit->addWidget(joueur1LineEdit);
  29. layoutLineEdit->addWidget(joueur2LineEdit);
  30. //layoutTemps->addWidget(labelTempsDepart);
  31. //layoutTemps->addWidget(spinTempsDepart);
  32. layoutForm->addRow("Son", checkBoxSon);
  33. layoutForm->addRow("Temps de départ (minutes)", spinTempsDepart);
  34. layoutDialog->addLayout(layoutForm);
  35. //layoutDialog->addLayout(layoutTemps);
  36. layoutDialog->addLayout(layoutLineEdit);
  37. layoutDialog->addWidget(boutonJouer);
  38. setLayout(layoutDialog);
  39. QObject::connect(boutonJouer , SIGNAL(accepted()) , this, SLOT(valider()));
  40. QObject::connect(boutonJouer , SIGNAL(rejected()) , this, SLOT(close()));
  41. }
  42. Dialog::~Dialog() {
  43. }
  44. void Dialog::valider() {
  45. _option->setNomJoueur1(joueur1LineEdit->text());
  46. _option->setNomJoueur2(joueur2LineEdit->text());
  47. _option->setTempsDepart(spinTempsDepart->value());
  48. _option->setSon(checkBoxSon->isChecked());
  49. this->accept();
  50. }