aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/pages/modplatform/legacy_ftb
diff options
context:
space:
mode:
authorTayou <31988415+TayouVR@users.noreply.github.com>2023-08-07 10:32:38 +0200
committerGitHub <noreply@github.com>2023-08-07 10:32:38 +0200
commit9afa7cc91fd889b146c609c6a59f7f7b3d995d9f (patch)
tree20ef3bd30beedca4995875485e468ee323d52096 /launcher/ui/pages/modplatform/legacy_ftb
parentb572f75dbaad61cf305f1fd4f60ba94d74bfa3fa (diff)
parent75c7df46a7022a46d447bb96fbde619e5d65db05 (diff)
downloadPrismLauncher-9afa7cc91fd889b146c609c6a59f7f7b3d995d9f.tar.gz
PrismLauncher-9afa7cc91fd889b146c609c6a59f7f7b3d995d9f.tar.bz2
PrismLauncher-9afa7cc91fd889b146c609c6a59f7f7b3d995d9f.zip
Merge branch 'develop' into icon-indexing
Signed-off-by: Tayou <31988415+TayouVR@users.noreply.github.com>
Diffstat (limited to 'launcher/ui/pages/modplatform/legacy_ftb')
-rw-r--r--launcher/ui/pages/modplatform/legacy_ftb/ListModel.cpp2
-rw-r--r--launcher/ui/pages/modplatform/legacy_ftb/ListModel.h49
-rw-r--r--launcher/ui/pages/modplatform/legacy_ftb/Page.cpp149
-rw-r--r--launcher/ui/pages/modplatform/legacy_ftb/Page.h64
4 files changed, 93 insertions, 171 deletions
diff --git a/launcher/ui/pages/modplatform/legacy_ftb/ListModel.cpp b/launcher/ui/pages/modplatform/legacy_ftb/ListModel.cpp
index 330dd4fb..1731ff2c 100644
--- a/launcher/ui/pages/modplatform/legacy_ftb/ListModel.cpp
+++ b/launcher/ui/pages/modplatform/legacy_ftb/ListModel.cpp
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
*
* This program is free software: you can redistribute it and/or modify
diff --git a/launcher/ui/pages/modplatform/legacy_ftb/ListModel.h b/launcher/ui/pages/modplatform/legacy_ftb/ListModel.h
index c55df000..51a58d99 100644
--- a/launcher/ui/pages/modplatform/legacy_ftb/ListModel.h
+++ b/launcher/ui/pages/modplatform/legacy_ftb/ListModel.h
@@ -1,13 +1,13 @@
#pragma once
-#include <modplatform/legacy_ftb/PackHelpers.h>
#include <RWStorage.h>
+#include <modplatform/legacy_ftb/PackHelpers.h>
#include <QAbstractListModel>
-#include <QSortFilterProxyModel>
-#include <QThreadPool>
#include <QIcon>
+#include <QSortFilterProxyModel>
#include <QStyledItemDelegate>
+#include <QThreadPool>
#include <functional>
@@ -16,34 +16,28 @@ namespace LegacyFTB {
typedef QMap<QString, QIcon> FTBLogoMap;
typedef std::function<void(QString)> LogoCallback;
-class FilterModel : public QSortFilterProxyModel
-{
+class FilterModel : public QSortFilterProxyModel {
Q_OBJECT
-public:
+ public:
FilterModel(QObject* parent = Q_NULLPTR);
- enum Sorting {
- ByName,
- ByGameVersion
- };
+ enum Sorting { ByName, ByGameVersion };
const QMap<QString, Sorting> getAvailableSortings();
QString translateCurrentSorting();
void setSorting(Sorting sorting);
Sorting getCurrentSorting();
-protected:
- bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
- bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
+ protected:
+ bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const override;
+ bool lessThan(const QModelIndex& left, const QModelIndex& right) const override;
-private:
+ private:
QMap<QString, Sorting> sortings;
Sorting currentSorting;
-
};
-class ListModel : public QAbstractListModel
-{
+class ListModel : public QAbstractListModel {
Q_OBJECT
-private:
+ private:
ModpackList modpacks;
QStringList m_failedLogos;
QStringList m_loadingLogos;
@@ -53,18 +47,17 @@ private:
void requestLogo(QString file);
QString translatePackType(PackType type) const;
-
-private slots:
+ private slots:
void logoFailed(QString logo);
void logoLoaded(QString logo, QIcon out);
-public:
- ListModel(QObject *parent);
+ public:
+ ListModel(QObject* parent);
~ListModel();
- int rowCount(const QModelIndex &parent) const override;
- int columnCount(const QModelIndex &parent) const override;
- QVariant data(const QModelIndex &index, int role) const override;
- Qt::ItemFlags flags(const QModelIndex &index) const override;
+ int rowCount(const QModelIndex& parent) const override;
+ int columnCount(const QModelIndex& parent) const override;
+ QVariant data(const QModelIndex& index, int role) const override;
+ Qt::ItemFlags flags(const QModelIndex& index) const override;
void fill(ModpackList modpacks);
void addPack(Modpack modpack);
@@ -72,7 +65,7 @@ public:
void remove(int row);
Modpack at(int row);
- void getLogo(const QString &logo, LogoCallback callback);
+ void getLogo(const QString& logo, LogoCallback callback);
};
-}
+} // namespace LegacyFTB
diff --git a/launcher/ui/pages/modplatform/legacy_ftb/Page.cpp b/launcher/ui/pages/modplatform/legacy_ftb/Page.cpp
index b3f6261f..ef8e9892 100644
--- a/launcher/ui/pages/modplatform/legacy_ftb/Page.cpp
+++ b/launcher/ui/pages/modplatform/legacy_ftb/Page.cpp
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
*
@@ -44,15 +44,14 @@
#include "ui/dialogs/CustomMessageBox.h"
#include "ui/dialogs/NewInstanceDialog.h"
+#include "ListModel.h"
#include "modplatform/legacy_ftb/PackFetchTask.h"
#include "modplatform/legacy_ftb/PackInstallTask.h"
#include "modplatform/legacy_ftb/PrivatePackManager.h"
-#include "ListModel.h"
namespace LegacyFTB {
-Page::Page(NewInstanceDialog* dialog, QWidget *parent)
- : QWidget(parent), dialog(dialog), ui(new Ui::Page)
+Page::Page(NewInstanceDialog* dialog, QWidget* parent) : QWidget(parent), dialog(dialog), ui(new Ui::Page)
{
ftbFetchTask.reset(new PackFetchTask(APPLICATION->network()));
ftbPrivatePacks.reset(new PrivatePackManager());
@@ -70,8 +69,7 @@ Page::Page(NewInstanceDialog* dialog, QWidget *parent)
ui->publicPackList->setIndentation(0);
ui->publicPackList->setIconSize(QSize(42, 42));
- for(int i = 0; i < publicFilterModel->getAvailableSortings().size(); i++)
- {
+ for (int i = 0; i < publicFilterModel->getAvailableSortings().size(); i++) {
ui->sortByBox->addItem(publicFilterModel->getAvailableSortings().keys().at(i));
}
@@ -142,8 +140,7 @@ bool Page::shouldDisplay() const
void Page::openedImpl()
{
- if(!initialized)
- {
+ if (!initialized) {
connect(ftbFetchTask.get(), &PackFetchTask::finished, this, &Page::ftbPackDataDownloadSuccessfully);
connect(ftbFetchTask.get(), &PackFetchTask::failed, this, &Page::ftbPackDataDownloadFailed);
connect(ftbFetchTask.get(), &PackFetchTask::aborted, this, &Page::ftbPackDataDownloadAborted);
@@ -166,50 +163,34 @@ void Page::retranslate()
void Page::suggestCurrent()
{
- if(!isOpened)
- {
+ if (!isOpened) {
return;
}
- if(selected.broken || selectedVersion.isEmpty())
- {
+ if (selected.broken || selectedVersion.isEmpty()) {
dialog->setSuggestedPack();
return;
}
dialog->setSuggestedPack(selected.name, selectedVersion, new PackInstallTask(APPLICATION->network(), selected, selectedVersion));
QString editedLogoName;
- if(selected.logo.toLower().startsWith("ftb"))
- {
+ if (selected.logo.toLower().startsWith("ftb")) {
editedLogoName = selected.logo;
- }
- else
- {
+ } else {
editedLogoName = "ftb_" + selected.logo;
}
editedLogoName = editedLogoName.left(editedLogoName.lastIndexOf(".png"));
- if(selected.type == PackType::Public)
- {
- publicListModel->getLogo(selected.logo, [this, editedLogoName](QString logo)
- {
- dialog->setSuggestedIconFromFile(logo, editedLogoName);
- });
- }
- else if (selected.type == PackType::ThirdParty)
- {
- thirdPartyModel->getLogo(selected.logo, [this, editedLogoName](QString logo)
- {
- dialog->setSuggestedIconFromFile(logo, editedLogoName);
- });
- }
- else if (selected.type == PackType::Private)
- {
- privateListModel->getLogo(selected.logo, [this, editedLogoName](QString logo)
- {
- dialog->setSuggestedIconFromFile(logo, editedLogoName);
- });
+ if (selected.type == PackType::Public) {
+ publicListModel->getLogo(selected.logo,
+ [this, editedLogoName](QString logo) { dialog->setSuggestedIconFromFile(logo, editedLogoName); });
+ } else if (selected.type == PackType::ThirdParty) {
+ thirdPartyModel->getLogo(selected.logo,
+ [this, editedLogoName](QString logo) { dialog->setSuggestedIconFromFile(logo, editedLogoName); });
+ } else if (selected.type == PackType::Private) {
+ privateListModel->getLogo(selected.logo,
+ [this, editedLogoName](QString logo) { dialog->setSuggestedIconFromFile(logo, editedLogoName); });
}
}
@@ -236,21 +217,16 @@ void Page::ftbPrivatePackDataDownloadSuccessfully(Modpack pack)
void Page::ftbPrivatePackDataDownloadFailed(QString reason, QString packCode)
{
- auto reply = QMessageBox::question(
- this,
- tr("FTB private packs"),
- tr("Failed to download pack information for code %1.\nShould it be removed now?").arg(packCode)
- );
- if(reply == QMessageBox::Yes)
- {
+ auto reply = QMessageBox::question(this, tr("FTB private packs"),
+ tr("Failed to download pack information for code %1.\nShould it be removed now?").arg(packCode));
+ if (reply == QMessageBox::Yes) {
ftbPrivatePacks->remove(packCode);
}
}
void Page::onPublicPackSelectionChanged(QModelIndex now, QModelIndex prev)
{
- if(!now.isValid())
- {
+ if (!now.isValid()) {
onPackSelectionChanged();
return;
}
@@ -260,8 +236,7 @@ void Page::onPublicPackSelectionChanged(QModelIndex now, QModelIndex prev)
void Page::onThirdPartyPackSelectionChanged(QModelIndex now, QModelIndex prev)
{
- if(!now.isValid())
- {
+ if (!now.isValid()) {
onPackSelectionChanged();
return;
}
@@ -271,8 +246,7 @@ void Page::onThirdPartyPackSelectionChanged(QModelIndex now, QModelIndex prev)
void Page::onPrivatePackSelectionChanged(QModelIndex now, QModelIndex prev)
{
- if(!now.isValid())
- {
+ if (!now.isValid()) {
onPackSelectionChanged();
return;
}
@@ -283,34 +257,26 @@ void Page::onPrivatePackSelectionChanged(QModelIndex now, QModelIndex prev)
void Page::onPackSelectionChanged(Modpack* pack)
{
ui->versionSelectionBox->clear();
- if(pack)
- {
- currentModpackInfo->setHtml("Pack by <b>" + pack->author + "</b>" +
- "<br>Minecraft " + pack->mcVersion + "<br>" + "<br>" + pack->description + "<ul><li>" + pack->mods.replace(";", "</li><li>")
- + "</li></ul>");
+ if (pack) {
+ currentModpackInfo->setHtml("Pack by <b>" + pack->author + "</b>" + "<br>Minecraft " + pack->mcVersion + "<br>" + "<br>" +
+ pack->description + "<ul><li>" + pack->mods.replace(";", "</li><li>") + "</li></ul>");
bool currentAdded = false;
- for(int i = 0; i < pack->oldVersions.size(); i++)
- {
- if(pack->currentVersion == pack->oldVersions.at(i))
- {
+ for (int i = 0; i < pack->oldVersions.size(); i++) {
+ if (pack->currentVersion == pack->oldVersions.at(i)) {
currentAdded = true;
}
ui->versionSelectionBox->addItem(pack->oldVersions.at(i));
}
- if(!currentAdded)
- {
+ if (!currentAdded) {
ui->versionSelectionBox->addItem(pack->currentVersion);
}
selected = *pack;
- }
- else
- {
+ } else {
currentModpackInfo->setHtml("");
ui->versionSelectionBox->clear();
- if(isOpened)
- {
+ if (isOpened) {
dialog->setSuggestedPack();
}
return;
@@ -320,8 +286,7 @@ void Page::onPackSelectionChanged(Modpack* pack)
void Page::onVersionSelectionItemChanged(QString data)
{
- if(data.isNull() || data.isEmpty())
- {
+ if (data.isNull() || data.isEmpty()) {
selectedVersion = "";
return;
}
@@ -340,20 +305,15 @@ void Page::onSortingSelectionChanged(QString data)
void Page::onTabChanged(int tab)
{
- if(tab == 1)
- {
+ if (tab == 1) {
currentModel = thirdPartyFilterModel;
currentList = ui->thirdPartyPackList;
currentModpackInfo = ui->thirdPartyPackDescription;
- }
- else if(tab == 2)
- {
+ } else if (tab == 2) {
currentModel = privateFilterModel;
currentList = ui->privatePackList;
currentModpackInfo = ui->privatePackDescription;
- }
- else
- {
+ } else {
currentModel = publicFilterModel;
currentList = ui->publicPackList;
currentModpackInfo = ui->publicPackDescription;
@@ -361,13 +321,10 @@ void Page::onTabChanged(int tab)
currentList->selectionModel()->reset();
QModelIndex idx = currentList->currentIndex();
- if(idx.isValid())
- {
+ if (idx.isValid()) {
auto pack = currentModel->data(idx, Qt::UserRole).value<Modpack>();
onPackSelectionChanged(&pack);
- }
- else
- {
+ } else {
onPackSelectionChanged();
}
}
@@ -375,38 +332,24 @@ void Page::onTabChanged(int tab)
void Page::onAddPackClicked()
{
bool ok;
- QString text = QInputDialog::getText(
- this,
- tr("Add FTB pack"),
- tr("Enter pack code:"),
- QLineEdit::Normal,
- QString(),
- &ok
- );
- if(ok && !text.isEmpty())
- {
+ QString text = QInputDialog::getText(this, tr("Add FTB pack"), tr("Enter pack code:"), QLineEdit::Normal, QString(), &ok);
+ if (ok && !text.isEmpty()) {
ftbPrivatePacks->add(text);
- ftbFetchTask->fetchPrivate({text});
+ ftbFetchTask->fetchPrivate({ text });
}
}
void Page::onRemovePackClicked()
{
auto index = ui->privatePackList->currentIndex();
- if(!index.isValid())
- {
+ if (!index.isValid()) {
return;
}
auto row = index.row();
Modpack pack = privateListModel->at(row);
- auto answer = QMessageBox::question(
- this,
- tr("Remove pack"),
- tr("Are you sure you want to remove pack %1?").arg(pack.name),
- QMessageBox::Yes | QMessageBox::No
- );
- if(answer != QMessageBox::Yes)
- {
+ auto answer = QMessageBox::question(this, tr("Remove pack"), tr("Are you sure you want to remove pack %1?").arg(pack.name),
+ QMessageBox::Yes | QMessageBox::No);
+ if (answer != QMessageBox::Yes) {
return;
}
@@ -415,4 +358,4 @@ void Page::onRemovePackClicked()
onPackSelectionChanged();
}
-}
+} // namespace LegacyFTB
diff --git a/launcher/ui/pages/modplatform/legacy_ftb/Page.h b/launcher/ui/pages/modplatform/legacy_ftb/Page.h
index 1de8b40a..a12b0745 100644
--- a/launcher/ui/pages/modplatform/legacy_ftb/Page.h
+++ b/launcher/ui/pages/modplatform/legacy_ftb/Page.h
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
*
* This program is free software: you can redistribute it and/or modify
@@ -35,23 +35,22 @@
#pragma once
-#include <QWidget>
-#include <QTreeView>
#include <QTextBrowser>
+#include <QTreeView>
+#include <QWidget>
-#include "ui/pages/BasePage.h"
#include <Application.h>
-#include "tasks/Task.h"
-#include "modplatform/legacy_ftb/PackHelpers.h"
-#include "modplatform/legacy_ftb/PackFetchTask.h"
#include "QObjectPtr.h"
+#include "modplatform/legacy_ftb/PackFetchTask.h"
+#include "modplatform/legacy_ftb/PackHelpers.h"
+#include "tasks/Task.h"
+#include "ui/pages/BasePage.h"
class NewInstanceDialog;
namespace LegacyFTB {
-namespace Ui
-{
+namespace Ui {
class Page;
}
@@ -61,38 +60,25 @@ class PrivatePackListModel;
class PrivatePackFilterModel;
class PrivatePackManager;
-class Page : public QWidget, public BasePage
-{
+class Page : public QWidget, public BasePage {
Q_OBJECT
-public:
- explicit Page(NewInstanceDialog * dialog, QWidget *parent = 0);
+ public:
+ explicit Page(NewInstanceDialog* dialog, QWidget* parent = 0);
virtual ~Page();
- QString displayName() const override
- {
- return "FTB Legacy";
- }
- QIcon icon() const override
- {
- return APPLICATION->getThemedIcon("ftb_logo");
- }
- QString id() const override
- {
- return "legacy_ftb";
- }
- QString helpPage() const override
- {
- return "FTB-platform";
- }
+ QString displayName() const override { return "FTB Legacy"; }
+ QIcon icon() const override { return APPLICATION->getThemedIcon("ftb_logo"); }
+ QString id() const override { return "legacy_ftb"; }
+ QString helpPage() const override { return "FTB-platform"; }
bool shouldDisplay() const override;
void openedImpl() override;
void retranslate() override;
-private:
+ private:
void suggestCurrent();
- void onPackSelectionChanged(Modpack *pack = nullptr);
+ void onPackSelectionChanged(Modpack* pack = nullptr);
-private slots:
+ private slots:
void ftbPackDataDownloadSuccessfully(ModpackList publicPacks, ModpackList thirdPartyPacks);
void ftbPackDataDownloadFailed(QString reason);
void ftbPackDataDownloadAborted();
@@ -112,7 +98,7 @@ private slots:
void onAddPackClicked();
void onRemovePackClicked();
-private:
+ private:
FilterModel* currentModel = nullptr;
QTreeView* currentList = nullptr;
QTextBrowser* currentModpackInfo = nullptr;
@@ -124,18 +110,18 @@ private:
ListModel* publicListModel = nullptr;
FilterModel* publicFilterModel = nullptr;
- ListModel *thirdPartyModel = nullptr;
- FilterModel *thirdPartyFilterModel = nullptr;
+ ListModel* thirdPartyModel = nullptr;
+ FilterModel* thirdPartyFilterModel = nullptr;
- ListModel *privateListModel = nullptr;
- FilterModel *privateFilterModel = nullptr;
+ ListModel* privateListModel = nullptr;
+ FilterModel* privateFilterModel = nullptr;
unique_qobject_ptr<PackFetchTask> ftbFetchTask;
std::unique_ptr<PrivatePackManager> ftbPrivatePacks;
NewInstanceDialog* dialog = nullptr;
- Ui::Page *ui = nullptr;
+ Ui::Page* ui = nullptr;
};
-}
+} // namespace LegacyFTB