aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/pages/instance/VersionPage.cpp
diff options
context:
space:
mode:
authorSefa Eyeoglu <contact@scrumplex.net>2022-12-26 17:48:43 +0100
committerGitHub <noreply@github.com>2022-12-26 17:48:43 +0100
commit6ea1234a3bb9787a77680ff528f21bdf1e40989c (patch)
tree1385918c5819df035dd5bd7b8f6bab7fc534c396 /launcher/ui/pages/instance/VersionPage.cpp
parentdd3848d7b161e415c34c3c1c393985b644a88f1c (diff)
parent434f639b0c9af355703d6c64cfe5bbe9a28d0b9b (diff)
downloadPrismLauncher-6ea1234a3bb9787a77680ff528f21bdf1e40989c.tar.gz
PrismLauncher-6ea1234a3bb9787a77680ff528f21bdf1e40989c.tar.bz2
PrismLauncher-6ea1234a3bb9787a77680ff528f21bdf1e40989c.zip
Merge pull request #618 from TheKodeToad/safer-destructive-actions
Fixes https://github.com/PolyMC/PolyMC/issues/948
Diffstat (limited to 'launcher/ui/pages/instance/VersionPage.cpp')
-rw-r--r--launcher/ui/pages/instance/VersionPage.cpp41
1 files changed, 35 insertions, 6 deletions
diff --git a/launcher/ui/pages/instance/VersionPage.cpp b/launcher/ui/pages/instance/VersionPage.cpp
index c8a65f10..d200652a 100644
--- a/launcher/ui/pages/instance/VersionPage.cpp
+++ b/launcher/ui/pages/instance/VersionPage.cpp
@@ -318,13 +318,29 @@ void VersionPage::on_actionReload_triggered()
void VersionPage::on_actionRemove_triggered()
{
- if (ui->packageView->currentIndex().isValid())
+ if (!ui->packageView->currentIndex().isValid())
{
- // FIXME: use actual model, not reloading.
- if (!m_profile->remove(ui->packageView->currentIndex().row()))
- {
- QMessageBox::critical(this, tr("Error"), tr("Couldn't remove file"));
- }
+ return;
+ }
+ int index = ui->packageView->currentIndex().row();
+ auto component = m_profile->getComponent(index);
+ if (component->isCustom())
+ {
+ auto response = CustomMessageBox::selectable(this, tr("Confirm Removal"),
+ tr("You are about to remove \"%1\".\n"
+ "This is permanent and will completely remove the custom component.\n\n"
+ "Are you sure?")
+ .arg(component->getName()),
+ QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
+ ->exec();
+
+ if (response != QMessageBox::Yes)
+ return;
+ }
+ // FIXME: use actual model, not reloading.
+ if (!m_profile->remove(index))
+ {
+ QMessageBox::critical(this, tr("Error"), tr("Couldn't remove file"));
}
updateButtons();
reloadPackProfile();
@@ -707,6 +723,19 @@ void VersionPage::on_actionRevert_triggered()
{
return;
}
+ auto component = m_profile->getComponent(version);
+
+ auto response = CustomMessageBox::selectable(this, tr("Confirm Reversion"),
+ tr("You are about to revert \"%1\".\n"
+ "This is permanent and will completely revert your customizations.\n\n"
+ "Are you sure?")
+ .arg(component->getName()),
+ QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
+ ->exec();
+
+ if (response != QMessageBox::Yes)
+ return;
+
if(!m_profile->revertToBase(version))
{
// TODO: some error box here