1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- #include "dialogform.h"
- #include "ui_dialogform.h"
- DialogForm::DialogForm(QWidget *parent) :
- Scene(parent),
- ui(new Ui::DialogForm)
- {
- ok = false;
- setWindowModality(Qt::ApplicationModal);
- ui->setupUi(this);
- raise();
- }
- void DialogForm::exec()
- {
- raise();
- QEventLoop loop;
- connect(ui->ok_button, &QPushButton::clicked, &loop, &QEventLoop::quit);
- connect(ui->cancel_button, &QPushButton::clicked, &loop, &QEventLoop::quit);
- loop.exec();
- }
- bool DialogForm::isOk()
- {
- return ok;
- }
- void DialogForm::setTitle(QString title)
- {
- ui->title->setText(title);
- }
- void DialogForm::setText(QString text)
- {
- ui->text->setText(text);
- }
- void DialogForm::setShowCancel(bool show)
- {
- show ? ui->cancel_button->show() : ui->cancel_button->hide();
- }
- DialogForm::~DialogForm()
- {
- delete ui;
- }
- void DialogForm::on_cancel_button_clicked()
- {
- ok = false;
- }
- void DialogForm::on_ok_button_clicked()
- {
- ok = true;
- }
|