From 55dc9e6a84ee1a4b3d92a01ea79fe5b24d26a0b7 Mon Sep 17 00:00:00 2001 From: Dylan Schooner Date: Mon, 10 Nov 2025 03:24:00 -0500 Subject: [PATCH] Add optionCheckBox to ScrollMessageBox ui Add 'Disable unavailable mods' option on check update failure Signed-off-by: Dylan Schooner --- launcher/CMakeLists.txt | 2 ++ launcher/ui/dialogs/ResourceUpdateDialog.cpp | 14 ++++++--- launcher/ui/dialogs/ScrollMessageBox.cpp | 5 ++++ launcher/ui/dialogs/ScrollMessageBox.h | 4 ++- launcher/ui/dialogs/ScrollMessageBox.ui | 29 +++++++++++++------ .../ui/dialogs/UpdateCheckFailedDialog.cpp | 13 +++++++++ launcher/ui/dialogs/UpdateCheckFailedDialog.h | 10 +++++++ 7 files changed, 63 insertions(+), 14 deletions(-) create mode 100644 launcher/ui/dialogs/UpdateCheckFailedDialog.cpp create mode 100644 launcher/ui/dialogs/UpdateCheckFailedDialog.h diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index 6d6e2ae7f..7654ff29d 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -1073,6 +1073,8 @@ SET(LAUNCHER_SOURCES ui/dialogs/ResourceDownloadDialog.h ui/dialogs/ScrollMessageBox.cpp ui/dialogs/ScrollMessageBox.h + ui/dialogs/UpdateCheckFailedDialog.cpp + ui/dialogs/UpdateCheckFailedDialog.h ui/dialogs/BlockedModsDialog.cpp ui/dialogs/BlockedModsDialog.h ui/dialogs/ChooseProviderDialog.h diff --git a/launcher/ui/dialogs/ResourceUpdateDialog.cpp b/launcher/ui/dialogs/ResourceUpdateDialog.cpp index eeaf6b3d0..39fedc5d7 100644 --- a/launcher/ui/dialogs/ResourceUpdateDialog.cpp +++ b/launcher/ui/dialogs/ResourceUpdateDialog.cpp @@ -5,6 +5,7 @@ #include "ProgressDialog.h" #include "ScrollMessageBox.h" #include "StringUtils.h" +#include "UpdateCheckFailedDialog.h" #include "minecraft/mod/tasks/GetModDependenciesTask.h" #include "modplatform/ModIndex.h" #include "modplatform/flame/FlameAPI.h" @@ -175,16 +176,21 @@ void ResourceUpdateDialog::checkCandidates() text += "
"; } - ScrollMessageBox message_dialog(m_parent, tr("Failed to check for updates"), - tr("Could not check or get the following resources for updates:
" - "Do you wish to proceed without those resources?"), - text); + UpdateCheckFailedDialog message_dialog(m_parent, text); message_dialog.setModal(true); if (message_dialog.exec() == QDialog::Rejected) { m_aborted = true; QMetaObject::invokeMethod(this, "reject", Qt::QueuedConnection); return; } + + // Disable incompatible mods + if (message_dialog.isOptionChecked()) { + for (const auto& failed : m_failedCheckUpdate) { + const auto& mod = std::get<0>(failed); + mod->enable(EnableAction::DISABLE); + } + } } if (m_includeDeps && !APPLICATION->settings()->get("ModDependenciesDisabled").toBool()) { // dependencies diff --git a/launcher/ui/dialogs/ScrollMessageBox.cpp b/launcher/ui/dialogs/ScrollMessageBox.cpp index 1cfb848f4..d2652b0c9 100644 --- a/launcher/ui/dialogs/ScrollMessageBox.cpp +++ b/launcher/ui/dialogs/ScrollMessageBox.cpp @@ -18,3 +18,8 @@ ScrollMessageBox::~ScrollMessageBox() { delete ui; } + +bool ScrollMessageBox::isOptionChecked() const +{ + return ui->optionCheckBox->isChecked(); +} diff --git a/launcher/ui/dialogs/ScrollMessageBox.h b/launcher/ui/dialogs/ScrollMessageBox.h index 8fd6769c4..774dd2cbc 100644 --- a/launcher/ui/dialogs/ScrollMessageBox.h +++ b/launcher/ui/dialogs/ScrollMessageBox.h @@ -16,6 +16,8 @@ class ScrollMessageBox : public QDialog { ~ScrollMessageBox() override; - private: + bool isOptionChecked() const; + + protected: Ui::ScrollMessageBox* ui; }; diff --git a/launcher/ui/dialogs/ScrollMessageBox.ui b/launcher/ui/dialogs/ScrollMessageBox.ui index e684185f2..2ebe86074 100644 --- a/launcher/ui/dialogs/ScrollMessageBox.ui +++ b/launcher/ui/dialogs/ScrollMessageBox.ui @@ -25,14 +25,25 @@ - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - + + + + + false + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + @@ -81,4 +92,4 @@ - + \ No newline at end of file diff --git a/launcher/ui/dialogs/UpdateCheckFailedDialog.cpp b/launcher/ui/dialogs/UpdateCheckFailedDialog.cpp new file mode 100644 index 000000000..7b97fad21 --- /dev/null +++ b/launcher/ui/dialogs/UpdateCheckFailedDialog.cpp @@ -0,0 +1,13 @@ +#include "UpdateCheckFailedDialog.h" +#include "ui_ScrollMessageBox.h" + +UpdateCheckFailedDialog::UpdateCheckFailedDialog(QWidget* parent, const QString& body) + : ScrollMessageBox(parent, + tr("Failed to check for updates"), + tr("Could not check or get the following resources for updates:
" + "Do you wish to proceed without those resources?"), + body) +{ + ui->optionCheckBox->setVisible(true); + ui->optionCheckBox->setText(tr("Disable unavailable mods")); +} \ No newline at end of file diff --git a/launcher/ui/dialogs/UpdateCheckFailedDialog.h b/launcher/ui/dialogs/UpdateCheckFailedDialog.h new file mode 100644 index 000000000..570821c5b --- /dev/null +++ b/launcher/ui/dialogs/UpdateCheckFailedDialog.h @@ -0,0 +1,10 @@ +#pragma once + +#include "ScrollMessageBox.h" + +class UpdateCheckFailedDialog final : public ScrollMessageBox { + Q_OBJECT + + public: + explicit UpdateCheckFailedDialog(QWidget* parent, const QString& body); +}; \ No newline at end of file