#include #include "generic_dialog.h" #include "message_source.h" display::GenericDialog::GenericDialog(std::string title, std::optional action, std::string cancel) { setAttribute(Qt::WA_DeleteOnClose); setWindowTitle(QMESSAGE(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.has_value()) { okButton = new QPushButton(QMESSAGE(*action), this); connect(okButton, &QPushButton::clicked, this, [this](){ if(this->onUpdate()) { this->accept(); } }); actionBar->addWidget(okButton); } cancelButton = new QPushButton(QMESSAGE(cancel), this); connect(cancelButton, &QPushButton::clicked, [this]() { reject(); }); actionBar->addWidget(cancelButton); } void display::GenericDialog::setOkButtonDisabled(bool disabled) { okButton->setDisabled(disabled); }