diff --git a/src/ui/prefab.cpp b/src/ui/prefab.cpp index 3a48cb01..c135831c 100644 --- a/src/ui/prefab.cpp +++ b/src/ui/prefab.cpp @@ -14,6 +14,7 @@ #include #include #include +#include using OrderedJson = poryjson::Json; using OrderedJsonDoc = poryjson::JsonDoc; @@ -184,9 +185,23 @@ void Prefab::updatePrefabUi(Map *map) { QObject::connect(frame->ui->pushButton_DeleteItem, &QPushButton::clicked, [this, item, map](){ for (int i = 0; i < this->items.size(); i++) { if (this->items[i].id == item.id) { - this->items.removeAt(i); - this->savePrefabs(); - this->updatePrefabUi(map); + QMessageBox msgBox; + msgBox.setText("Confirm Prefab Deletion"); + if (this->items[i].name.isEmpty()) { + msgBox.setInformativeText("Are you sure you want to delete this prefab?"); + } else { + msgBox.setInformativeText(QString("Are you sure you want to delete prefab \"%1\"?").arg(this->items[i].name)); + } + + QPushButton *deleteButton = msgBox.addButton("Delete", QMessageBox::DestructiveRole); + msgBox.addButton(QMessageBox::Cancel); + msgBox.setDefaultButton(QMessageBox::Cancel); + msgBox.exec(); + if (msgBox.clickedButton() == deleteButton) { + this->items.removeAt(i); + this->savePrefabs(); + this->updatePrefabUi(map); + } break; } }