Add optionCheckBox to ScrollMessageBox ui

Add 'Disable unavailable mods' option on check update failure

Signed-off-by: Dylan Schooner <dschooner05@gmail.com>
This commit is contained in:
Dylan Schooner 2025-11-10 03:24:00 -05:00
parent b070ffaf72
commit 55dc9e6a84
7 changed files with 63 additions and 14 deletions

View file

@ -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

View file

@ -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 += "<br>";
}
ScrollMessageBox message_dialog(m_parent, tr("Failed to check for updates"),
tr("Could not check or get the following resources for updates:<br>"
"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

View file

@ -18,3 +18,8 @@ ScrollMessageBox::~ScrollMessageBox()
{
delete ui;
}
bool ScrollMessageBox::isOptionChecked() const
{
return ui->optionCheckBox->isChecked();
}

View file

@ -16,6 +16,8 @@ class ScrollMessageBox : public QDialog {
~ScrollMessageBox() override;
private:
bool isOptionChecked() const;
protected:
Ui::ScrollMessageBox* ui;
};

View file

@ -25,14 +25,25 @@
</widget>
</item>
<item row="2" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<layout class="QHBoxLayout" name="bottomHBoxLayout">
<item>
<widget class="QCheckBox" name="optionCheckBox">
<property name="visible">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QTextBrowser" name="textBrowser">
@ -81,4 +92,4 @@
</hints>
</connection>
</connections>
</ui>
</ui>

View file

@ -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:<br>"
"Do you wish to proceed without those resources?"),
body)
{
ui->optionCheckBox->setVisible(true);
ui->optionCheckBox->setText(tr("Disable unavailable mods"));
}

View file

@ -0,0 +1,10 @@
#pragma once
#include "ScrollMessageBox.h"
class UpdateCheckFailedDialog final : public ScrollMessageBox {
Q_OBJECT
public:
explicit UpdateCheckFailedDialog(QWidget* parent, const QString& body);
};