// // Created by bbr on 18. 04. 2022.. // #include #include "name_dialog.h" display::NameDialog::NameDialog(std::string currentName, std::set &names): currentName(currentName) { usedNames.erase(currentName); auto *layout = new QVBoxLayout(this); layout->addWidget(new QLabel("Izmjeni ime", this)); edit = new QLineEdit(this); edit->insert(currentName.c_str()); connect(edit, &QLineEdit::textChanged, this, &NameDialog::onNameUpdate); layout->addWidget(edit); setWindowTitle("Izmjeni ime"); button = new QPushButton("Ažuriraj", this); connect(button, &QPushButton::clicked, this, &NameDialog::onNameChange); layout->addWidget(button); setLayout(layout); } void display::NameDialog::onNameUpdate(const QString &text) { if(usedNames.find(text.toStdString()) == usedNames.end()) { button->setDisabled(false); } else { button->setDisabled(true); } } void display::NameDialog::onNameChange() { currentName = edit->text().toStdString(); close(); } std::string display::NameDialog::getName() { return currentName; }