schema_editor/comdel/display/dialog/generic_dialog.cpp

30 lines
1.0 KiB
C++
Raw Normal View History

2022-06-13 22:53:46 +00:00
#include <QVBoxLayout>
#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);
}