#include "Dialog.h" #include "options.h" #include #include #include #include #include #include #include #include Dialog::Dialog(Options *option, QWidget *parent) : QDialog(parent), _option(option) { QHBoxLayout *layoutLineEdit = 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 QTimeEdit; spinTempsDepart->setTimeRange(QTime(0,0,5,0), QTime(3,0,0,0)); spinTempsDepart->setTime(_option->tempsDepart()); spinTempsDepart->setDisplayFormat("HH:mm:ss"); joueur1LineEdit = new QLineEdit(_option->nomJoueur1() , this); joueur2LineEdit = new QLineEdit(_option->nomJoueur2() , this); joueur1LineEdit->selectAll(); layoutLineEdit->addWidget(joueur1LineEdit); layoutLineEdit->addWidget(joueur2LineEdit); layoutForm->addRow("Son", checkBoxSon); layoutForm->addRow("Temps de départ", spinTempsDepart); layoutDialog->addLayout(layoutLineEdit); layoutDialog->addLayout(layoutForm); layoutDialog->addWidget(boutonJouer); setLayout(layoutDialog); QObject::connect(boutonJouer , SIGNAL(accepted()) , this, SLOT(accept())); QObject::connect(boutonJouer , SIGNAL(rejected()) , this, SLOT(close())); } Dialog::~Dialog() { } void Dialog::accept() { _option->setNomJoueur1(joueur1LineEdit->text()); _option->setNomJoueur2(joueur2LineEdit->text()); _option->setTempsDepart(spinTempsDepart->time()); _option->setSon(checkBoxSon->isChecked()); QDialog::accept(); }