diff options
author | Ryan Cao <70191398+ryanccn@users.noreply.github.com> | 2022-12-03 21:54:41 +0800 |
---|---|---|
committer | Ryan Cao <70191398+ryanccn@users.noreply.github.com> | 2022-12-03 21:54:41 +0800 |
commit | fa3caf091aca8bc784464e3bdf2fe51a09f7d759 (patch) | |
tree | 15f38a9e19482832b271834c73dddf2756381736 /launcher/ui | |
parent | 93707560cb9334bea95f22461592fa437bbd06b0 (diff) | |
download | PrismLauncher-fa3caf091aca8bc784464e3bdf2fe51a09f7d759.tar.gz PrismLauncher-fa3caf091aca8bc784464e3bdf2fe51a09f7d759.tar.bz2 PrismLauncher-fa3caf091aca8bc784464e3bdf2fe51a09f7d759.zip |
fix: warn before trashing instances
Signed-off-by: Ryan Cao <70191398+ryanccn@users.noreply.github.com>
Diffstat (limited to 'launcher/ui')
-rw-r--r-- | launcher/ui/MainWindow.cpp | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index b626bbae..91cc5f29 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -2088,27 +2088,25 @@ void MainWindow::on_actionAbout_triggered() void MainWindow::on_actionDeleteInstance_triggered() { - if (!m_selectedInstance) - { + if (!m_selectedInstance) { return; } auto id = m_selectedInstance->id(); - if (APPLICATION->instances()->trashInstance(id)) { - ui->actionUndoTrashInstance->setEnabled(APPLICATION->instances()->trashedSomething()); - return; - } - - auto response = CustomMessageBox::selectable( - this, - tr("CAREFUL!"), - tr("About to delete: %1\nThis is permanent and will completely delete the instance.\n\nAre you sure?").arg(m_selectedInstance->name()), - QMessageBox::Warning, - QMessageBox::Yes | QMessageBox::No, - QMessageBox::No - )->exec(); - if (response == QMessageBox::Yes) - { + + auto response = + 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()), + QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) + ->exec(); + + if (response == QMessageBox::Yes) { + if (APPLICATION->instances()->trashInstance(id)) { + ui->actionUndoTrashInstance->setEnabled(APPLICATION->instances()->trashedSomething()); + return; + } + APPLICATION->instances()->deleteInstance(id); } } |