#include #include "generic_dialog.h" display::GenericDialog::GenericDialog(std::string title, std::string action) { setAttribute(Qt::WA_DeleteOnClose); setWindowTitle(QString::fromStdString(title)); setLayout(new QVBoxLayout()); content = new QWidget(this); layout()->addWidget(content); auto actionWidget = new QWidget(this); auto actionBar = new QHBoxLayout(actionWidget); layout()->addWidget(actionWidget); // if action isn't defined only close button is offered if(!action.empty()) { okButton = new QPushButton(QString::fromStdString(action), this); connect(okButton, &QPushButton::clicked, this, [this](){if(this->onUpdate()) this->accept();}); actionBar->addWidget(okButton); } cancelButton = new QPushButton("Odustani", this); connect(cancelButton, &QPushButton::clicked, [this]() { reject(); }); actionBar->addWidget(cancelButton); } void display::GenericDialog::setOkButtonDisabled(bool disabled) { okButton->setDisabled(disabled); }