From 127b094c4158f7a2315bb35cea05f5644a0db1c5 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Wed, 14 Dec 2022 15:02:04 +0000 Subject: Improve handling of destructive actions Signed-off-by: TheKodeToad --- launcher/ui/pages/instance/WorldListPage.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'launcher/ui/pages/instance/WorldListPage.cpp') diff --git a/launcher/ui/pages/instance/WorldListPage.cpp b/launcher/ui/pages/instance/WorldListPage.cpp index 93458ce4..74cb5a05 100644 --- a/launcher/ui/pages/instance/WorldListPage.cpp +++ b/launcher/ui/pages/instance/WorldListPage.cpp @@ -1,8 +1,9 @@ // SPDX-License-Identifier: GPL-3.0-only /* - * PolyMC - Minecraft Launcher + * Prism Launcher - Minecraft Launcher * Copyright (c) 2022 Jamie Mansfield * Copyright (C) 2022 Sefa Eyeoglu + * Copyright (C) 2022 TheKodeToad * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -35,6 +36,7 @@ */ #include "WorldListPage.h" +#include "ui/dialogs/CustomMessageBox.h" #include "ui_WorldListPage.h" #include "minecraft/WorldList.h" @@ -192,12 +194,14 @@ void WorldListPage::on_actionRemove_triggered() if(!proxiedIndex.isValid()) return; - auto result = QMessageBox::question(this, - tr("Are you sure?"), - tr("This will remove the selected world permenantly.\n" - "The world will be gone forever (A LONG TIME).\n" - "\n" - "Do you want to continue?")); + auto result = CustomMessageBox::selectable(this, tr("CAREFUL!"), + tr("About to delete: %1\n" + "The world may be gone forever (A LONG TIME).\n\n" + "Are you sure?") + .arg(m_worlds->allWorlds().at(proxiedIndex.row()).name()), + QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) + ->exec(); + if(result != QMessageBox::Yes) { return; -- cgit From cbe5af235ca2fc990efa0a2db9e4951f127f0131 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Sat, 17 Dec 2022 09:26:06 +0000 Subject: Make requested changes Signed-off-by: TheKodeToad --- launcher/ui/GuiUtil.cpp | 5 ++- launcher/ui/MainWindow.cpp | 2 +- .../ui/pages/instance/ExternalResourcesPage.cpp | 37 +++++++++++----------- launcher/ui/pages/instance/OtherLogsPage.cpp | 4 +-- launcher/ui/pages/instance/ScreenshotsPage.cpp | 2 +- launcher/ui/pages/instance/ServersPage.cpp | 2 +- launcher/ui/pages/instance/VersionPage.cpp | 4 +-- launcher/ui/pages/instance/WorldListPage.cpp | 2 +- 8 files changed, 29 insertions(+), 29 deletions(-) (limited to 'launcher/ui/pages/instance/WorldListPage.cpp') diff --git a/launcher/ui/GuiUtil.cpp b/launcher/ui/GuiUtil.cpp index 241354cb..6a22ec2f 100644 --- a/launcher/ui/GuiUtil.cpp +++ b/launcher/ui/GuiUtil.cpp @@ -64,13 +64,12 @@ QString GuiUtil::uploadPaste(const QString &name, const QString &text, QWidget * baseUrl = pasteCustomAPIBaseSetting; if (baseUrl.isValid()) { - auto response = CustomMessageBox::selectable(parentWidget, "Confirm Upload", + auto response = CustomMessageBox::selectable(parentWidget, QObject::tr("Confirm Upload"), QObject::tr("About to upload: %1\n" "Uploading to: %2\n" "You should double-check for personal information.\n\n" "Are you sure?") - .arg(name) - .arg(baseUrl.host()), + .arg(name, baseUrl.host()), QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) ->exec(); diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 4ddef6d4..7442b955 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -2094,7 +2094,7 @@ void MainWindow::on_actionDeleteInstance_triggered() auto id = m_selectedInstance->id(); - auto response = CustomMessageBox::selectable(this, tr("CAREFUL!"), + auto response = CustomMessageBox::selectable(this, tr("Confirm Deletion"), tr("About to delete: %1\n" "This may be permanent and will completely delete the instance.\n\n" "Are you sure?") diff --git a/launcher/ui/pages/instance/ExternalResourcesPage.cpp b/launcher/ui/pages/instance/ExternalResourcesPage.cpp index 41ccd1db..6f1abbff 100644 --- a/launcher/ui/pages/instance/ExternalResourcesPage.cpp +++ b/launcher/ui/pages/instance/ExternalResourcesPage.cpp @@ -162,7 +162,7 @@ void ExternalResourcesPage::removeItem() int count = 0; bool folder = false; - for (auto i : selection.indexes()) { + for (auto& i : selection.indexes()) { if (i.column() == 0) { count++; @@ -172,23 +172,24 @@ void ExternalResourcesPage::removeItem() } } - bool enough = count > 1; - - if (enough || folder) { - QString text; - if (enough) - text = tr("About to remove: %1 items\n" - "This may be permanent and they will be gone from the folder.\n\n" - "Are you sure?") - .arg(count); - else - text = tr("About to remove: %1 (folder)\n" - "This may be permanent and it will be gone from the parent folder.\n\n" - "Are you sure?") - .arg(m_model->at(selection.indexes().at(0).row()).fileinfo().fileName()); - - auto response = CustomMessageBox::selectable(this, tr("CAREFUL!"), text, QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, - QMessageBox::No) + QString text; + bool multiple = count > 1; + + if (multiple) { + text = tr("About to remove: %1 items\n" + "This may be permanent and they will be gone from the folder.\n\n" + "Are you sure?") + .arg(count); + } else if (folder) { + text = tr("About to remove: %1 (folder)\n" + "This may be permanent and it will be gone from the parent folder.\n\n" + "Are you sure?") + .arg(m_model->at(selection.indexes().at(0).row()).fileinfo().fileName()); + } + + if (!text.isEmpty()) { + auto response = CustomMessageBox::selectable(this, tr("Confirm Removal"), text, QMessageBox::Warning, + QMessageBox::Yes | QMessageBox::No, QMessageBox::No) ->exec(); if (response != QMessageBox::Yes) diff --git a/launcher/ui/pages/instance/OtherLogsPage.cpp b/launcher/ui/pages/instance/OtherLogsPage.cpp index ad444e6b..1be2a3f8 100644 --- a/launcher/ui/pages/instance/OtherLogsPage.cpp +++ b/launcher/ui/pages/instance/OtherLogsPage.cpp @@ -220,7 +220,7 @@ void OtherLogsPage::on_btnDelete_clicked() setControlsEnabled(false); return; } - if (QMessageBox::question(this, tr("CAREFUL!"), + if (QMessageBox::question(this, tr("Confirm Deletion"), tr("About to delete: %1\n" "This may be permanent and it will be gone from the logs folder.\n\n" "Are you sure?") @@ -252,7 +252,7 @@ void OtherLogsPage::on_btnClean_clicked() return; } QMessageBox *messageBox = new QMessageBox(this); - messageBox->setWindowTitle(tr("CAREFUL!")); + messageBox->setWindowTitle(tr("Confirm Cleanup")); if(toDelete.size() > 5) { messageBox->setText(tr("Are you sure you want to delete all log files?")); diff --git a/launcher/ui/pages/instance/ScreenshotsPage.cpp b/launcher/ui/pages/instance/ScreenshotsPage.cpp index fff21670..4b756766 100644 --- a/launcher/ui/pages/instance/ScreenshotsPage.cpp +++ b/launcher/ui/pages/instance/ScreenshotsPage.cpp @@ -526,7 +526,7 @@ void ScreenshotsPage::on_actionDelete_triggered() .arg(count); auto response = - CustomMessageBox::selectable(this, tr("CAREFUL!"), text, QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No)->exec(); + CustomMessageBox::selectable(this, tr("Confirm Deletion"), text, QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No)->exec(); if (response != QMessageBox::Yes) return; diff --git a/launcher/ui/pages/instance/ServersPage.cpp b/launcher/ui/pages/instance/ServersPage.cpp index c636b236..6925ffb4 100644 --- a/launcher/ui/pages/instance/ServersPage.cpp +++ b/launcher/ui/pages/instance/ServersPage.cpp @@ -801,7 +801,7 @@ void ServersPage::on_actionAdd_triggered() void ServersPage::on_actionRemove_triggered() { - auto response = CustomMessageBox::selectable(this, tr("CAREFUL!"), + auto response = CustomMessageBox::selectable(this, tr("Confirm Removal"), tr("About to remove: %1\n" "This is permanent and the server will be gone from your list forever (A LONG TIME).\n\n" "Are you sure?") diff --git a/launcher/ui/pages/instance/VersionPage.cpp b/launcher/ui/pages/instance/VersionPage.cpp index 413b2f85..08ab8641 100644 --- a/launcher/ui/pages/instance/VersionPage.cpp +++ b/launcher/ui/pages/instance/VersionPage.cpp @@ -326,7 +326,7 @@ void VersionPage::on_actionRemove_triggered() auto component = m_profile->getComponent(index); if (component->isCustom()) { - auto response = CustomMessageBox::selectable(this, tr("CAREFUL!"), + auto response = CustomMessageBox::selectable(this, tr("Confirm Removal"), tr("About to remove: %1\n" "This is permanent and will completely remove the custom component.\n\n" "Are you sure?") @@ -725,7 +725,7 @@ void VersionPage::on_actionRevert_triggered() } auto component = m_profile->getComponent(version); - auto response = CustomMessageBox::selectable(this, tr("CAREFUL!"), + auto response = CustomMessageBox::selectable(this, tr("Confirm Reversion"), tr("About to revert: %1\n" "This is permanent and will completely revert your customizations.\n\n" "Are you sure?") diff --git a/launcher/ui/pages/instance/WorldListPage.cpp b/launcher/ui/pages/instance/WorldListPage.cpp index 74cb5a05..c98f1e5a 100644 --- a/launcher/ui/pages/instance/WorldListPage.cpp +++ b/launcher/ui/pages/instance/WorldListPage.cpp @@ -194,7 +194,7 @@ void WorldListPage::on_actionRemove_triggered() if(!proxiedIndex.isValid()) return; - auto result = CustomMessageBox::selectable(this, tr("CAREFUL!"), + auto result = CustomMessageBox::selectable(this, tr("Confirm Deletion"), tr("About to delete: %1\n" "The world may be gone forever (A LONG TIME).\n\n" "Are you sure?") -- cgit From bf04becc9e05f147ca595868c9a51da14d1c0c34 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Mon, 26 Dec 2022 14:33:50 +0000 Subject: About to -> you are about to You're is used in some other places but im lazy Signed-off-by: TheKodeToad --- launcher/ui/GuiUtil.cpp | 3 +-- launcher/ui/MainWindow.cpp | 2 +- launcher/ui/pages/instance/ExternalResourcesPage.cpp | 4 ++-- launcher/ui/pages/instance/OtherLogsPage.cpp | 2 +- launcher/ui/pages/instance/ScreenshotsPage.cpp | 8 ++++---- launcher/ui/pages/instance/ServersPage.cpp | 2 +- launcher/ui/pages/instance/VersionPage.cpp | 4 ++-- launcher/ui/pages/instance/WorldListPage.cpp | 2 +- 8 files changed, 13 insertions(+), 14 deletions(-) (limited to 'launcher/ui/pages/instance/WorldListPage.cpp') diff --git a/launcher/ui/GuiUtil.cpp b/launcher/ui/GuiUtil.cpp index 6a22ec2f..855ab400 100644 --- a/launcher/ui/GuiUtil.cpp +++ b/launcher/ui/GuiUtil.cpp @@ -65,8 +65,7 @@ QString GuiUtil::uploadPaste(const QString &name, const QString &text, QWidget * if (baseUrl.isValid()) { auto response = CustomMessageBox::selectable(parentWidget, QObject::tr("Confirm Upload"), - QObject::tr("About to upload: %1\n" - "Uploading to: %2\n" + QObject::tr("You are about to upload \"%1\" to %2.\n" "You should double-check for personal information.\n\n" "Are you sure?") .arg(name, baseUrl.host()), diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 7442b955..c8a1fddc 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -2095,7 +2095,7 @@ void MainWindow::on_actionDeleteInstance_triggered() auto id = m_selectedInstance->id(); auto response = CustomMessageBox::selectable(this, tr("Confirm Deletion"), - tr("About to delete: %1\n" + tr("You are about to delete \"%1\".\n" "This may be permanent and will completely delete the instance.\n\n" "Are you sure?") .arg(m_selectedInstance->name()), diff --git a/launcher/ui/pages/instance/ExternalResourcesPage.cpp b/launcher/ui/pages/instance/ExternalResourcesPage.cpp index 6f1abbff..1115ddc3 100644 --- a/launcher/ui/pages/instance/ExternalResourcesPage.cpp +++ b/launcher/ui/pages/instance/ExternalResourcesPage.cpp @@ -176,12 +176,12 @@ void ExternalResourcesPage::removeItem() bool multiple = count > 1; if (multiple) { - text = tr("About to remove: %1 items\n" + text = tr("You are about to remove %1 items.\n" "This may be permanent and they will be gone from the folder.\n\n" "Are you sure?") .arg(count); } else if (folder) { - text = tr("About to remove: %1 (folder)\n" + text = tr("You are about to remove the folder \"%1\".\n" "This may be permanent and it will be gone from the parent folder.\n\n" "Are you sure?") .arg(m_model->at(selection.indexes().at(0).row()).fileinfo().fileName()); diff --git a/launcher/ui/pages/instance/OtherLogsPage.cpp b/launcher/ui/pages/instance/OtherLogsPage.cpp index 1be2a3f8..bbdd7324 100644 --- a/launcher/ui/pages/instance/OtherLogsPage.cpp +++ b/launcher/ui/pages/instance/OtherLogsPage.cpp @@ -221,7 +221,7 @@ void OtherLogsPage::on_btnDelete_clicked() return; } if (QMessageBox::question(this, tr("Confirm Deletion"), - tr("About to delete: %1\n" + tr("You are about to delete \"%1\".\n" "This may be permanent and it will be gone from the logs folder.\n\n" "Are you sure?") .arg(m_currentFile), diff --git a/launcher/ui/pages/instance/ScreenshotsPage.cpp b/launcher/ui/pages/instance/ScreenshotsPage.cpp index 4b756766..ca368d3b 100644 --- a/launcher/ui/pages/instance/ScreenshotsPage.cpp +++ b/launcher/ui/pages/instance/ScreenshotsPage.cpp @@ -383,12 +383,12 @@ void ScreenshotsPage::on_actionUpload_triggered() QString text; if (selection.size() > 1) - text = tr("About to upload: %1 screenshots\n\n" + text = tr("You are about to upload %1 screenshots.\n\n" "Are you sure?") .arg(selection.size()); else text = - tr("About to upload the selected screenshot.\n\n" + tr("You are about to upload the selected screenshot.\n\n" "Are you sure?"); auto response = CustomMessageBox::selectable(this, "Confirm Upload", text, QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, @@ -515,12 +515,12 @@ void ScreenshotsPage::on_actionDelete_triggered() int count = ui->listView->selectionModel()->selectedRows().size(); QString text; if (count > 1) - text = tr("About to delete: %1 screenshots\n" + text = tr("You are about to delete %1 screenshots.\n" "This may be permanent and they will be gone from the folder.\n\n" "Are you sure?") .arg(count); else - text = tr("About to delete the selected screenshot.\n" + text = tr("You are about to delete the selected screenshot.\n" "This may be permanent and it will be gone from the folder.\n\n" "Are you sure?") .arg(count); diff --git a/launcher/ui/pages/instance/ServersPage.cpp b/launcher/ui/pages/instance/ServersPage.cpp index 6925ffb4..6f8591a1 100644 --- a/launcher/ui/pages/instance/ServersPage.cpp +++ b/launcher/ui/pages/instance/ServersPage.cpp @@ -802,7 +802,7 @@ void ServersPage::on_actionAdd_triggered() void ServersPage::on_actionRemove_triggered() { auto response = CustomMessageBox::selectable(this, tr("Confirm Removal"), - tr("About to remove: %1\n" + tr("You are about to remove \"%1\".\n" "This is permanent and the server will be gone from your list forever (A LONG TIME).\n\n" "Are you sure?") .arg(m_model->at(currentServer)->m_name), diff --git a/launcher/ui/pages/instance/VersionPage.cpp b/launcher/ui/pages/instance/VersionPage.cpp index 08ab8641..d200652a 100644 --- a/launcher/ui/pages/instance/VersionPage.cpp +++ b/launcher/ui/pages/instance/VersionPage.cpp @@ -327,7 +327,7 @@ void VersionPage::on_actionRemove_triggered() if (component->isCustom()) { auto response = CustomMessageBox::selectable(this, tr("Confirm Removal"), - tr("About to remove: %1\n" + 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()), @@ -726,7 +726,7 @@ void VersionPage::on_actionRevert_triggered() auto component = m_profile->getComponent(version); auto response = CustomMessageBox::selectable(this, tr("Confirm Reversion"), - tr("About to revert: %1\n" + 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()), diff --git a/launcher/ui/pages/instance/WorldListPage.cpp b/launcher/ui/pages/instance/WorldListPage.cpp index c98f1e5a..0020c461 100644 --- a/launcher/ui/pages/instance/WorldListPage.cpp +++ b/launcher/ui/pages/instance/WorldListPage.cpp @@ -195,7 +195,7 @@ void WorldListPage::on_actionRemove_triggered() return; auto result = CustomMessageBox::selectable(this, tr("Confirm Deletion"), - tr("About to delete: %1\n" + tr("You are about to delete \"%1\".\n" "The world may be gone forever (A LONG TIME).\n\n" "Are you sure?") .arg(m_worlds->allWorlds().at(proxiedIndex.row()).name()), -- cgit