123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- #include "Dialog.h"
- #include "options.h"
- #include <QBoxLayout>
- #include <QLineEdit>
- #include <QSpinBox>
- #include <QDialogButtonBox>
- #include <QLabel>
- #include <QFormLayout>
- #include <QCheckBox>
- Dialog::Dialog(Options *option, QWidget *parent) :
- QDialog(parent),
- _option(option)
- {
- QHBoxLayout *layoutLineEdit = new QHBoxLayout;
- //QHBoxLayout *layoutTemps = new QHBoxLayout;
- QVBoxLayout *layoutDialog = new QVBoxLayout;
- QFormLayout *layoutForm = new QFormLayout;
- QDialogButtonBox *boutonJouer = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
- checkBoxSon = new QCheckBox();
- checkBoxSon->setChecked(option->son());
- spinTempsDepart = new QSpinBox;
- spinTempsDepart->setMinimum(1);
- spinTempsDepart->setMaximum(300);
- spinTempsDepart->setValue(option->tempsDepart());
- joueur1LineEdit = new QLineEdit(option->nomJoueur1() , this);
- joueur2LineEdit = new QLineEdit(option->nomJoueur2() , this);
- joueur1LineEdit->selectAll();
- layoutLineEdit->addWidget(joueur1LineEdit);
- layoutLineEdit->addWidget(joueur2LineEdit);
- //layoutTemps->addWidget(labelTempsDepart);
- //layoutTemps->addWidget(spinTempsDepart);
- layoutForm->addRow("Son", checkBoxSon);
- layoutForm->addRow("Temps de départ (minutes)", spinTempsDepart);
- layoutDialog->addLayout(layoutForm);
- //layoutDialog->addLayout(layoutTemps);
- layoutDialog->addLayout(layoutLineEdit);
- layoutDialog->addWidget(boutonJouer);
- setLayout(layoutDialog);
- QObject::connect(boutonJouer , SIGNAL(accepted()) , this, SLOT(valider()));
- QObject::connect(boutonJouer , SIGNAL(rejected()) , this, SLOT(close()));
- }
- Dialog::~Dialog() {
- }
- void Dialog::valider() {
- _option->setNomJoueur1(joueur1LineEdit->text());
- _option->setNomJoueur2(joueur2LineEdit->text());
- _option->setTempsDepart(spinTempsDepart->value());
- _option->setSon(checkBoxSon->isChecked());
- this->accept();
- }
|