1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- #include "Dialog.h"
- #include "options.h"
- #include <QBoxLayout>
- #include <QLineEdit>
- #include <QTimeEdit>
- #include <QTime>
- #include <QDialogButtonBox>
- #include <QLabel>
- #include <QFormLayout>
- #include <QCheckBox>
- 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 , &QDialogButtonBox::accepted , this, &Dialog::accept);
- QObject::connect(boutonJouer , &QDialogButtonBox::rejected , this, &Dialog::close);
- }
- Dialog::~Dialog() {
- }
- void Dialog::accept() {
- _option->setNomJoueur1(joueur1LineEdit->text());
- _option->setNomJoueur2(joueur2LineEdit->text());
- _option->setTempsDepart(spinTempsDepart->time());
- _option->setSon(checkBoxSon->isChecked());
- QDialog::accept();
- }
|