12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- #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 const& option, QWidget *parent) :
- QDialog(parent)
- {
- 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() {
- }
- QString Dialog::champs_joueur1() const
- {
- return joueur1LineEdit->text();
- }
- QString Dialog::champs_joueur2() const
- {
- return joueur2LineEdit->text();
- }
- bool Dialog::champs_son() const
- {
- return checkBoxSon->isChecked();
- }
- QTime Dialog::champs_temps() const
- {
- return spinTempsDepart->time();
- }
|