1 /*-==============================================================-
3 file : CustomDialog.cpp
5 creation date : 08/02/2012
7 author : S. Domas (sdomas@iut-bm.univ-fcomte.fr)
11 supp. infos : saved in UTF-8 [éè]
13 -==============================================================-*/
14 #include "CustomDialog.h"
16 CustomDialog::CustomDialog(const QString &dialogTitle, const QString &boxTitle, QWidget *_parent) : QDialog(_parent) {
18 setWindowTitle(dialogTitle);
19 box = new QGroupBox(boxTitle);
21 okButton = new QPushButton(tr("OK"));
22 cancelButton = new QPushButton(tr("Cancel"));
24 layBottom = new QHBoxLayout;
25 layBottom->addStretch();
26 layBottom->addWidget(okButton);
27 layBottom->addWidget(cancelButton);
29 connect(okButton,SIGNAL(clicked()),this, SLOT(checkBeforeAccept()));
30 connect(cancelButton,SIGNAL(clicked()),this,SLOT(reject()));
33 void CustomDialog::checkBeforeAccept() {
37 bool CustomDialog::confirmAccept() {
39 int ret = QMessageBox::question(NULL,tr("Confirmation"),tr("Are you sure ?"),QMessageBox::Ok | QMessageBox::Cancel,QMessageBox::Ok);
40 if (ret == QMessageBox::Ok) return true;
44 void CustomDialog::setContent(QVBoxLayout *boxLayout) {
45 box->setLayout(boxLayout);
47 QVBoxLayout *layAll = new QVBoxLayout;
49 layAll->addWidget(box);
50 layAll->addLayout(layBottom);