diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index ecdeaac0..384f72f6 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -834,8 +834,8 @@ SET(LAUNCHER_SOURCES ui/dialogs/SkinUploadDialog.h ui/dialogs/ModDownloadDialog.cpp ui/dialogs/ModDownloadDialog.h - ui/dialogs/ScrollMessageBox.cpp - ui/dialogs/ScrollMessageBox.h + ui/dialogs/BlockedModsDialog.cpp + ui/dialogs/BlockedModsDialog.h # GUI - widgets ui/widgets/Common.cpp @@ -940,7 +940,7 @@ qt_wrap_ui(LAUNCHER_UI ui/dialogs/LoginDialog.ui ui/dialogs/EditAccountDialog.ui ui/dialogs/ReviewMessageBox.ui - ui/dialogs/ScrollMessageBox.ui + ui/dialogs/BlockedModsDialog.ui ) qt_add_resources(LAUNCHER_RESOURCES diff --git a/launcher/InstanceImportTask.cpp b/launcher/InstanceImportTask.cpp index 14e1cd47..de0afc96 100644 --- a/launcher/InstanceImportTask.cpp +++ b/launcher/InstanceImportTask.cpp @@ -60,7 +60,7 @@ #include "net/ChecksumValidator.h" #include "ui/dialogs/CustomMessageBox.h" -#include "ui/dialogs/ScrollMessageBox.h" +#include "ui/dialogs/BlockedModsDialog.h" #include @@ -396,21 +396,24 @@ void InstanceImportTask::processFlame() auto results = m_modIdResolver->getResults(); //first check for blocked mods QString text; + QList urls; auto anyBlocked = false; for(const auto& result: results.files.values()) { if (!result.resolved || result.url.isEmpty()) { text += QString("%1: %2
").arg(result.fileName, result.websiteUrl); + urls.append(QUrl(result.websiteUrl)); anyBlocked = true; } } if(anyBlocked) { qWarning() << "Blocked mods found, displaying mod list"; - auto message_dialog = new ScrollMessageBox(m_parent, + auto message_dialog = new BlockedModsDialog(m_parent, tr("Blocked mods found"), tr("The following mods were blocked on third party launchers.
" "You will need to manually download them and add them to the modpack"), - text); + text, + urls); message_dialog->setModal(true); if (message_dialog->exec()) { diff --git a/launcher/ui/dialogs/BlockedModsDialog.cpp b/launcher/ui/dialogs/BlockedModsDialog.cpp new file mode 100644 index 00000000..de698509 --- /dev/null +++ b/launcher/ui/dialogs/BlockedModsDialog.cpp @@ -0,0 +1,28 @@ +#include "BlockedModsDialog.h" +#include "ui_BlockedModsDialog.h" +#include "qpushbutton.h" +#include +#include + + +BlockedModsDialog::BlockedModsDialog(QWidget *parent, const QString &title, const QString &text, const QString &body, const QList &urls) : + QDialog(parent), ui(new Ui::BlockedModsDialog), urls(urls) { + ui->setupUi(this); + + auto openAllButton = ui->buttonBox->addButton(tr("Open All"), QDialogButtonBox::ActionRole); + connect(openAllButton, &QPushButton::clicked, this, &BlockedModsDialog::openAll); + + this->setWindowTitle(title); + ui->label->setText(text); + ui->textBrowser->setText(body); +} + +BlockedModsDialog::~BlockedModsDialog() { + delete ui; +} + +void BlockedModsDialog::openAll() { + for(auto &url : urls) { + QDesktopServices::openUrl(url); + } +} diff --git a/launcher/ui/dialogs/BlockedModsDialog.h b/launcher/ui/dialogs/BlockedModsDialog.h new file mode 100644 index 00000000..5f5bd61b --- /dev/null +++ b/launcher/ui/dialogs/BlockedModsDialog.h @@ -0,0 +1,22 @@ +#pragma once + +#include + + +QT_BEGIN_NAMESPACE +namespace Ui { class BlockedModsDialog; } +QT_END_NAMESPACE + +class BlockedModsDialog : public QDialog { +Q_OBJECT + +public: + BlockedModsDialog(QWidget *parent, const QString &title, const QString &text, const QString &body, const QList &urls); + + ~BlockedModsDialog() override; + +private: + Ui::BlockedModsDialog *ui; + const QList &urls; + void openAll(); +}; diff --git a/launcher/ui/dialogs/ScrollMessageBox.ui b/launcher/ui/dialogs/BlockedModsDialog.ui similarity index 89% rename from launcher/ui/dialogs/ScrollMessageBox.ui rename to launcher/ui/dialogs/BlockedModsDialog.ui index 299d2ecc..f4ae95b6 100644 --- a/launcher/ui/dialogs/ScrollMessageBox.ui +++ b/launcher/ui/dialogs/BlockedModsDialog.ui @@ -1,7 +1,7 @@ - ScrollMessageBox - + BlockedModsDialog + 0 @@ -11,7 +11,7 @@ - ScrollMessageBox + BlockedModsDialog @@ -51,7 +51,7 @@ buttonBox accepted() - ScrollMessageBox + BlockedModsDialog accept() @@ -67,7 +67,7 @@ buttonBox rejected() - ScrollMessageBox + BlockedModsDialog reject() diff --git a/launcher/ui/dialogs/ScrollMessageBox.cpp b/launcher/ui/dialogs/ScrollMessageBox.cpp deleted file mode 100644 index afdc4bae..00000000 --- a/launcher/ui/dialogs/ScrollMessageBox.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "ScrollMessageBox.h" -#include "ui_ScrollMessageBox.h" - - -ScrollMessageBox::ScrollMessageBox(QWidget *parent, const QString &title, const QString &text, const QString &body) : - QDialog(parent), ui(new Ui::ScrollMessageBox) { - ui->setupUi(this); - this->setWindowTitle(title); - ui->label->setText(text); - ui->textBrowser->setText(body); -} - -ScrollMessageBox::~ScrollMessageBox() { - delete ui; -} diff --git a/launcher/ui/dialogs/ScrollMessageBox.h b/launcher/ui/dialogs/ScrollMessageBox.h deleted file mode 100644 index 84aa253a..00000000 --- a/launcher/ui/dialogs/ScrollMessageBox.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include - - -QT_BEGIN_NAMESPACE -namespace Ui { class ScrollMessageBox; } -QT_END_NAMESPACE - -class ScrollMessageBox : public QDialog { -Q_OBJECT - -public: - ScrollMessageBox(QWidget *parent, const QString &title, const QString &text, const QString &body); - - ~ScrollMessageBox() override; - -private: - Ui::ScrollMessageBox *ui; -};