schema_editor/comdel/display/name_dialog.h

46 lines
1.0 KiB
C++

#ifndef NAME_DIALOG_H
#define NAME_DIALOG_H
#include <QDialog>
#include <QLabel>
#include <QVBoxLayout>
#include <QLineEdit>
#include <QPushButton>
#include <comdel/domain/instance.h>
namespace display {
class NameDialog: public QDialog {
QLineEdit *edit;
domain::ComponentInstance *instance;
public:
NameDialog(domain::ComponentInstance *instance): instance(instance) {
auto *layout = new QVBoxLayout(this);
layout->addWidget(new QLabel("Izmjeni ime", this));
edit = new QLineEdit(this);
edit->insert(instance->name.c_str());
layout->addWidget(edit);
this->setWindowTitle("Izmjeni ime");
auto *button = new QPushButton("Ažuriraj", this);
connect(button, &QPushButton::clicked, this, &NameDialog::onNameChange);
layout->addWidget(button);
this->setLayout(layout);
}
public slots:
void onNameChange() {
instance->name = this->edit->text().toStdString();
this->close();
}
};
}
#endif //NAME_DIALOG_H