fix: warn before trashing instances

Signed-off-by: Ryan Cao <70191398+ryanccn@users.noreply.github.com>
This commit is contained in:
Ryan Cao 2022-12-03 21:54:41 +08:00
parent 93707560cb
commit fa3caf091a
No known key found for this signature in database

View File

@ -2088,27 +2088,25 @@ void MainWindow::on_actionAbout_triggered()
void MainWindow::on_actionDeleteInstance_triggered() void MainWindow::on_actionDeleteInstance_triggered()
{ {
if (!m_selectedInstance) if (!m_selectedInstance) {
{
return; return;
} }
auto id = m_selectedInstance->id(); auto id = m_selectedInstance->id();
if (APPLICATION->instances()->trashInstance(id)) {
ui->actionUndoTrashInstance->setEnabled(APPLICATION->instances()->trashedSomething()); auto response =
return; CustomMessageBox::selectable(this, tr("CAREFUL!"),
} tr("About to delete: %1\nThis may be permanent and will completely delete the instance.\n\nAre you sure?")
.arg(m_selectedInstance->name()),
auto response = CustomMessageBox::selectable( QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
this, ->exec();
tr("CAREFUL!"),
tr("About to delete: %1\nThis is permanent and will completely delete the instance.\n\nAre you sure?").arg(m_selectedInstance->name()), if (response == QMessageBox::Yes) {
QMessageBox::Warning, if (APPLICATION->instances()->trashInstance(id)) {
QMessageBox::Yes | QMessageBox::No, ui->actionUndoTrashInstance->setEnabled(APPLICATION->instances()->trashedSomething());
QMessageBox::No return;
)->exec(); }
if (response == QMessageBox::Yes)
{
APPLICATION->instances()->deleteInstance(id); APPLICATION->instances()->deleteInstance(id);
} }
} }