From d61323aa6d34d3414bbee75c40c5957327874625 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Wed, 23 Nov 2022 13:25:17 +0100 Subject: [PATCH 1/6] fix: improve resize behavior of BlockedModsDialog Signed-off-by: Sefa Eyeoglu --- launcher/ui/dialogs/BlockedModsDialog.cpp | 9 +----- launcher/ui/dialogs/BlockedModsDialog.ui | 38 ++++++----------------- 2 files changed, 11 insertions(+), 36 deletions(-) diff --git a/launcher/ui/dialogs/BlockedModsDialog.cpp b/launcher/ui/dialogs/BlockedModsDialog.cpp index 214eeeaa..60561049 100644 --- a/launcher/ui/dialogs/BlockedModsDialog.cpp +++ b/launcher/ui/dialogs/BlockedModsDialog.cpp @@ -34,15 +34,8 @@ BlockedModsDialog::BlockedModsDialog(QWidget* parent, const QString& title, cons this->setWindowTitle(title); ui->labelDescription->setText(text); - ui->labelExplain->setText( - QString(tr("Your configured global mods folder and default downloads folder " - "are automatically checked for the downloaded mods and they will be copied to the instance if found.
" - "Optionally, you may drag and drop the downloaded mods onto this dialog or add a folder to watch " - "if you did not download the mods to a default location.")) - .arg(APPLICATION->settings()->get("CentralModsDir").toString(), - QStandardPaths::writableLocation(QStandardPaths::DownloadLocation))); - // force all URL handeling as external + // force all URL handling as external connect(ui->textBrowserWatched, &QTextBrowser::anchorClicked, this, [](const QUrl url) { QDesktopServices::openUrl(url); }); setAcceptDrops(true); diff --git a/launcher/ui/dialogs/BlockedModsDialog.ui b/launcher/ui/dialogs/BlockedModsDialog.ui index 88105178..e352611a 100644 --- a/launcher/ui/dialogs/BlockedModsDialog.ui +++ b/launcher/ui/dialogs/BlockedModsDialog.ui @@ -7,17 +7,23 @@ 0 0 400 - 455 + 400 + + + 0 + 350 + + BlockedModsDialog - + - + Placeholder description Qt::RichText @@ -30,7 +36,7 @@ - + <html><head/><body><p>Your configured global mods folder and default downloads folder are automatically checked for the downloaded mods and they will be copied to the instance if found.</p><p>Optionally, you may drag and drop the downloaded mods onto this dialog or add a folder to watch if you did not download the mods to a default location.</p></body></html> true @@ -42,12 +48,6 @@ - - - 0 - 165 - - true @@ -58,12 +58,6 @@ - - - 0 - 1 - - Watched Folders: @@ -71,18 +65,6 @@ - - - 0 - 0 - - - - - 0 - 16 - - 0 From e08d97825d827d9e232e8487dbdddefc4f9764e3 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Wed, 23 Nov 2022 13:54:50 +0100 Subject: [PATCH 2/6] feat: implement lax filename match in BlockedModsDialog Signed-off-by: Sefa Eyeoglu --- launcher/ui/dialogs/BlockedModsDialog.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/launcher/ui/dialogs/BlockedModsDialog.cpp b/launcher/ui/dialogs/BlockedModsDialog.cpp index 60561049..ffcf6e5f 100644 --- a/launcher/ui/dialogs/BlockedModsDialog.cpp +++ b/launcher/ui/dialogs/BlockedModsDialog.cpp @@ -236,14 +236,24 @@ void BlockedModsDialog::checkMatchHash(QString hash, QString path) /// @return boolean: did the path match the name of a blocked mod? bool BlockedModsDialog::checkValidPath(QString path) { - QFileInfo file = QFileInfo(path); - QString filename = file.fileName(); + const QFileInfo file = QFileInfo(path); + const QString filename = file.fileName(); + QString laxFilename(filename); + laxFilename.replace('+', ' '); + + auto compare = [](QString fsfilename, QString metadataFilename) { + return metadataFilename.compare(fsfilename, Qt::CaseInsensitive) == 0; + }; for (auto& mod : m_mods) { - if (mod.name.compare(filename, Qt::CaseInsensitive) == 0) { + if (compare(filename, mod.name)) { qDebug() << "[Blocked Mods Dialog] Name match found:" << mod.name << "| From path:" << path; return true; } + if (compare(laxFilename, mod.name)) { + qDebug() << "[Blocked Mods Dialog] Lax name match found:" << mod.name << "| From path:" << path; + return true; + } } return false; From c06abd9b6b1e3414e239e7695de0ce65274ebc85 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Wed, 23 Nov 2022 14:29:23 +0100 Subject: [PATCH 3/6] refactor: replace Open All with Open Missing Signed-off-by: Sefa Eyeoglu --- launcher/ui/dialogs/BlockedModsDialog.cpp | 22 ++++++++++++++-------- launcher/ui/dialogs/BlockedModsDialog.h | 7 ++++--- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/launcher/ui/dialogs/BlockedModsDialog.cpp b/launcher/ui/dialogs/BlockedModsDialog.cpp index ffcf6e5f..de6b7cac 100644 --- a/launcher/ui/dialogs/BlockedModsDialog.cpp +++ b/launcher/ui/dialogs/BlockedModsDialog.cpp @@ -1,14 +1,16 @@ #include "BlockedModsDialog.h" -#include -#include -#include -#include "Application.h" #include "ui_BlockedModsDialog.h" +#include "Application.h" +#include "modplatform/helpers/HashUtils.h" + #include +#include +#include #include #include #include +#include #include BlockedModsDialog::BlockedModsDialog(QWidget* parent, const QString& title, const QString& text, QList& mods) @@ -19,8 +21,8 @@ BlockedModsDialog::BlockedModsDialog(QWidget* parent, const QString& title, cons ui->setupUi(this); - auto openAllButton = ui->buttonBox->addButton(tr("Open All"), QDialogButtonBox::ActionRole); - connect(openAllButton, &QPushButton::clicked, this, &BlockedModsDialog::openAll); + m_openMissingButton = ui->buttonBox->addButton(tr("Open Missing"), QDialogButtonBox::ActionRole); + connect(m_openMissingButton, &QPushButton::clicked, this, [this]() { openAll(true); }); auto downloadFolderButton = ui->buttonBox->addButton(tr("Add Download Folder"), QDialogButtonBox::ActionRole); connect(downloadFolderButton, &QPushButton::clicked, this, &BlockedModsDialog::addDownloadFolder); @@ -78,10 +80,12 @@ void BlockedModsDialog::done(int r) disconnect(&m_watcher, &QFileSystemWatcher::directoryChanged, this, &BlockedModsDialog::directoryChanged); } -void BlockedModsDialog::openAll() +void BlockedModsDialog::openAll(bool missingOnly) { for (auto& mod : m_mods) { - QDesktopServices::openUrl(mod.websiteUrl); + if (!missingOnly || !mod.matched) { + QDesktopServices::openUrl(mod.websiteUrl); + } } } @@ -124,8 +128,10 @@ void BlockedModsDialog::update() if (allModsMatched()) { ui->labelModsFound->setText("" + tr("All mods found")); + m_openMissingButton->setDisabled(true); } else { ui->labelModsFound->setText(tr("Please download the missing mods.")); + m_openMissingButton->setDisabled(false); } } diff --git a/launcher/ui/dialogs/BlockedModsDialog.h b/launcher/ui/dialogs/BlockedModsDialog.h index f5aef8bf..51109aa5 100644 --- a/launcher/ui/dialogs/BlockedModsDialog.h +++ b/launcher/ui/dialogs/BlockedModsDialog.h @@ -6,10 +6,10 @@ #include -#include "modplatform/helpers/HashUtils.h" - #include "tasks/ConcurrentTask.h" +class QPushButton; + struct BlockedMod { QString name; QString websiteUrl; @@ -46,8 +46,9 @@ class BlockedModsDialog : public QDialog { shared_qobject_ptr m_hashing_task; QSet m_pending_hash_paths; bool m_rehash_pending; + QPushButton *m_openMissingButton; - void openAll(); + void openAll(bool missingOnly); void addDownloadFolder(); void update(); void directoryChanged(QString path); From 5cedfcbfaf93d42e598a3339acea1284028babaf Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Wed, 23 Nov 2022 14:54:04 +0100 Subject: [PATCH 4/6] chore: add license headers Signed-off-by: Sefa Eyeoglu --- launcher/ui/dialogs/BlockedModsDialog.cpp | 25 +++++++++++++++++++++++ launcher/ui/dialogs/BlockedModsDialog.h | 25 +++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/launcher/ui/dialogs/BlockedModsDialog.cpp b/launcher/ui/dialogs/BlockedModsDialog.cpp index de6b7cac..346ceff2 100644 --- a/launcher/ui/dialogs/BlockedModsDialog.cpp +++ b/launcher/ui/dialogs/BlockedModsDialog.cpp @@ -1,3 +1,28 @@ +// SPDX-FileCopyrightText: 2022 Sefa Eyeoglu +// SPDX-FileCopyrightText: 2022 Rachel Powers <508861+Ryex@users.noreply.github.com> +// SPDX-FileCopyrightText: 2022 kumquat-ir <66188216+kumquat-ir@users.noreply.github.com> +// +// SPDX-License-Identifier: GPL-3.0-only + +/* + * Prism Launcher - Minecraft Launcher + * Copyright (C) 2022 Sefa Eyeoglu + * Copyright (C) 2022 Rachel Powers <508861+Ryex@users.noreply.github.com> + * Copyright (C) 2022 kumquat-ir <66188216+kumquat-ir@users.noreply.github.com> + * + * 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 + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #include "BlockedModsDialog.h" #include "ui_BlockedModsDialog.h" diff --git a/launcher/ui/dialogs/BlockedModsDialog.h b/launcher/ui/dialogs/BlockedModsDialog.h index 51109aa5..3fe2da10 100644 --- a/launcher/ui/dialogs/BlockedModsDialog.h +++ b/launcher/ui/dialogs/BlockedModsDialog.h @@ -1,3 +1,28 @@ +// SPDX-FileCopyrightText: 2022 Sefa Eyeoglu +// SPDX-FileCopyrightText: 2022 Rachel Powers <508861+Ryex@users.noreply.github.com> +// SPDX-FileCopyrightText: 2022 kumquat-ir <66188216+kumquat-ir@users.noreply.github.com> +// +// SPDX-License-Identifier: GPL-3.0-only + +/* + * Prism Launcher - Minecraft Launcher + * Copyright (C) 2022 Sefa Eyeoglu + * Copyright (C) 2022 Rachel Powers <508861+Ryex@users.noreply.github.com> + * Copyright (C) 2022 kumquat-ir <66188216+kumquat-ir@users.noreply.github.com> + * + * 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 + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #pragma once #include From 5cab4d886453f8a9efa68438b4bd1c40398b7c9f Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Wed, 23 Nov 2022 14:55:43 +0100 Subject: [PATCH 5/6] chore: reformat code Signed-off-by: Sefa Eyeoglu --- launcher/ui/dialogs/BlockedModsDialog.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/ui/dialogs/BlockedModsDialog.h b/launcher/ui/dialogs/BlockedModsDialog.h index 3fe2da10..f63d04b4 100644 --- a/launcher/ui/dialogs/BlockedModsDialog.h +++ b/launcher/ui/dialogs/BlockedModsDialog.h @@ -71,7 +71,7 @@ class BlockedModsDialog : public QDialog { shared_qobject_ptr m_hashing_task; QSet m_pending_hash_paths; bool m_rehash_pending; - QPushButton *m_openMissingButton; + QPushButton* m_openMissingButton; void openAll(bool missingOnly); void addDownloadFolder(); From 746f6945da9d9bdb0c9fbdbe8f86810410b4172b Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Sat, 26 Nov 2022 13:57:31 +0100 Subject: [PATCH 6/6] fix: remove rogue notr Signed-off-by: Sefa Eyeoglu --- launcher/ui/dialogs/BlockedModsDialog.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/ui/dialogs/BlockedModsDialog.ui b/launcher/ui/dialogs/BlockedModsDialog.ui index e352611a..2292b99c 100644 --- a/launcher/ui/dialogs/BlockedModsDialog.ui +++ b/launcher/ui/dialogs/BlockedModsDialog.ui @@ -36,7 +36,7 @@ - <html><head/><body><p>Your configured global mods folder and default downloads folder are automatically checked for the downloaded mods and they will be copied to the instance if found.</p><p>Optionally, you may drag and drop the downloaded mods onto this dialog or add a folder to watch if you did not download the mods to a default location.</p></body></html> + <html><head/><body><p>Your configured global mods folder and default downloads folder are automatically checked for the downloaded mods and they will be copied to the instance if found.</p><p>Optionally, you may drag and drop the downloaded mods onto this dialog or add a folder to watch if you did not download the mods to a default location.</p></body></html> true