Merge pull request #541 from ryanccn/warn-before-trash-instance

Closes https://github.com/PrismLauncher/PrismLauncher/issues/192
closes https://github.com/PrismLauncher/PrismLauncher/issues/462
This commit is contained in:
Sefa Eyeoglu 2022-12-03 15:20:49 +01:00 committed by GitHub
commit 79d5beff8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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