aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/pages/modplatform
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/ui/pages/modplatform')
-rw-r--r--launcher/ui/pages/modplatform/CustomPage.cpp85
-rw-r--r--launcher/ui/pages/modplatform/CustomPage.h46
-rw-r--r--launcher/ui/pages/modplatform/ImportPage.cpp68
-rw-r--r--launcher/ui/pages/modplatform/ImportPage.h45
-rw-r--r--launcher/ui/pages/modplatform/ResourcePackPage.cpp6
-rw-r--r--launcher/ui/pages/modplatform/ResourcePackPage.h2
-rw-r--r--launcher/ui/pages/modplatform/ResourcePage.cpp1
-rw-r--r--launcher/ui/pages/modplatform/TexturePackPage.h5
-rw-r--r--launcher/ui/pages/modplatform/atlauncher/AtlFilterModel.cpp16
-rw-r--r--launcher/ui/pages/modplatform/atlauncher/AtlFilterModel.h16
-rw-r--r--launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.cpp134
-rw-r--r--launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.h39
-rw-r--r--launcher/ui/pages/modplatform/atlauncher/AtlPage.cpp36
-rw-r--r--launcher/ui/pages/modplatform/atlauncher/AtlPage.h48
-rw-r--r--launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.cpp18
-rw-r--r--launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.h2
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameModel.cpp8
-rw-r--r--launcher/ui/pages/modplatform/flame/FlamePage.cpp11
-rw-r--r--launcher/ui/pages/modplatform/flame/FlamePage.h48
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameResourcePages.cpp28
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameResourcePages.h29
-rw-r--r--launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.cpp104
-rw-r--r--launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.h67
-rw-r--r--launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.ui28
-rw-r--r--launcher/ui/pages/modplatform/import_ftb/ListModel.cpp88
-rw-r--r--launcher/ui/pages/modplatform/import_ftb/ListModel.h46
-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
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp30
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthModel.h11
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp2
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthPage.h2
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthResourceModels.cpp2
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthResourceModels.h2
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthResourcePages.cpp32
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthResourcePages.h32
-rw-r--r--launcher/ui/pages/modplatform/technic/TechnicData.h4
-rw-r--r--launcher/ui/pages/modplatform/technic/TechnicModel.cpp2
-rw-r--r--launcher/ui/pages/modplatform/technic/TechnicModel.h2
-rw-r--r--launcher/ui/pages/modplatform/technic/TechnicPage.cpp100
-rw-r--r--launcher/ui/pages/modplatform/technic/TechnicPage.h46
43 files changed, 852 insertions, 703 deletions
diff --git a/launcher/ui/pages/modplatform/CustomPage.cpp b/launcher/ui/pages/modplatform/CustomPage.cpp
index e164171a..4ac21b01 100644
--- a/launcher/ui/pages/modplatform/CustomPage.cpp
+++ b/launcher/ui/pages/modplatform/CustomPage.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>
*
* This program is free software: you can redistribute it and/or modify
@@ -46,8 +46,7 @@
#include "minecraft/VanillaInstanceCreationTask.h"
#include "ui/dialogs/NewInstanceDialog.h"
-CustomPage::CustomPage(NewInstanceDialog *dialog, QWidget *parent)
- : QWidget(parent), dialog(dialog), ui(new Ui::CustomPage)
+CustomPage::CustomPage(NewInstanceDialog* dialog, QWidget* parent) : QWidget(parent), dialog(dialog), ui(new Ui::CustomPage)
{
ui->setupUi(this);
ui->tabWidget->tabBar()->hide();
@@ -68,19 +67,15 @@ CustomPage::CustomPage(NewInstanceDialog *dialog, QWidget *parent)
connect(ui->quiltFilter, &QRadioButton::toggled, this, &CustomPage::loaderFilterChanged);
connect(ui->liteLoaderFilter, &QRadioButton::toggled, this, &CustomPage::loaderFilterChanged);
connect(ui->loaderRefreshBtn, &QPushButton::clicked, this, &CustomPage::loaderRefresh);
-
}
void CustomPage::openedImpl()
{
- if(!initialized)
- {
+ if (!initialized) {
auto vlist = APPLICATION->metadataIndex()->get("net.minecraft");
ui->versionList->initialize(vlist.get());
initialized = true;
- }
- else
- {
+ } else {
suggestCurrent();
}
}
@@ -92,7 +87,7 @@ void CustomPage::refresh()
void CustomPage::loaderRefresh()
{
- if(ui->noneFilter->isChecked())
+ if (ui->noneFilter->isChecked())
return;
ui->loaderVersionList->loadList();
}
@@ -100,17 +95,17 @@ void CustomPage::loaderRefresh()
void CustomPage::filterChanged()
{
QStringList out;
- if(ui->alphaFilter->isChecked())
+ if (ui->alphaFilter->isChecked())
out << "(old_alpha)";
- if(ui->betaFilter->isChecked())
+ if (ui->betaFilter->isChecked())
out << "(old_beta)";
- if(ui->snapshotFilter->isChecked())
+ if (ui->snapshotFilter->isChecked())
out << "(snapshot)";
- if(ui->oldSnapshotFilter->isChecked())
+ if (ui->oldSnapshotFilter->isChecked())
out << "(old_snapshot)";
- if(ui->releaseFilter->isChecked())
+ if (ui->releaseFilter->isChecked())
out << "(release)";
- if(ui->experimentsFilter->isChecked())
+ if (ui->experimentsFilter->isChecked())
out << "(experiment)";
auto regexp = out.join('|');
ui->versionList->setFilter(BaseVersionList::TypeRole, new RegexpFilter(regexp, false));
@@ -119,49 +114,37 @@ void CustomPage::filterChanged()
void CustomPage::loaderFilterChanged()
{
QString minecraftVersion;
- if (m_selectedVersion)
- {
+ if (m_selectedVersion) {
minecraftVersion = m_selectedVersion->descriptor();
- }
- else
- {
- ui->loaderVersionList->setExactFilter(BaseVersionList::ParentVersionRole, "AAA"); // empty list
+ } else {
+ ui->loaderVersionList->setExactFilter(BaseVersionList::ParentVersionRole, "AAA"); // empty list
ui->loaderVersionList->setEmptyString(tr("No Minecraft version is selected."));
ui->loaderVersionList->setEmptyMode(VersionListView::String);
return;
}
- if(ui->noneFilter->isChecked())
- {
- ui->loaderVersionList->setExactFilter(BaseVersionList::ParentVersionRole, "AAA"); // empty list
+ if (ui->noneFilter->isChecked()) {
+ ui->loaderVersionList->setExactFilter(BaseVersionList::ParentVersionRole, "AAA"); // empty list
ui->loaderVersionList->setEmptyString(tr("No mod loader is selected."));
ui->loaderVersionList->setEmptyMode(VersionListView::String);
return;
- }
- else if(ui->forgeFilter->isChecked())
- {
+ } else if (ui->forgeFilter->isChecked()) {
ui->loaderVersionList->setExactFilter(BaseVersionList::ParentVersionRole, minecraftVersion);
m_selectedLoader = "net.minecraftforge";
- }
- else if(ui->fabricFilter->isChecked())
- {
+ } else if (ui->fabricFilter->isChecked()) {
// FIXME: dirty hack because the launcher is unaware of Fabric's dependencies
- if (Version(minecraftVersion) >= Version("1.14")) // Fabric/Quilt supported
+ if (Version(minecraftVersion) >= Version("1.14")) // Fabric/Quilt supported
ui->loaderVersionList->setExactFilter(BaseVersionList::ParentVersionRole, "");
- else // Fabric/Quilt unsupported
- ui->loaderVersionList->setExactFilter(BaseVersionList::ParentVersionRole, "AAA"); // clear list
+ else // Fabric/Quilt unsupported
+ ui->loaderVersionList->setExactFilter(BaseVersionList::ParentVersionRole, "AAA"); // clear list
m_selectedLoader = "net.fabricmc.fabric-loader";
- }
- else if(ui->quiltFilter->isChecked())
- {
+ } else if (ui->quiltFilter->isChecked()) {
// FIXME: dirty hack because the launcher is unaware of Quilt's dependencies (same as Fabric)
- if (Version(minecraftVersion) >= Version("1.14")) // Fabric/Quilt supported
+ if (Version(minecraftVersion) >= Version("1.14")) // Fabric/Quilt supported
ui->loaderVersionList->setExactFilter(BaseVersionList::ParentVersionRole, "");
- else // Fabric/Quilt unsupported
- ui->loaderVersionList->setExactFilter(BaseVersionList::ParentVersionRole, "AAA"); // clear list
+ else // Fabric/Quilt unsupported
+ ui->loaderVersionList->setExactFilter(BaseVersionList::ParentVersionRole, "AAA"); // clear list
m_selectedLoader = "org.quiltmc.quilt-loader";
- }
- else if(ui->liteLoaderFilter->isChecked())
- {
+ } else if (ui->liteLoaderFilter->isChecked()) {
ui->loaderVersionList->setExactFilter(BaseVersionList::ParentVersionRole, minecraftVersion);
m_selectedLoader = "com.mumfrey.liteloader";
}
@@ -204,25 +187,21 @@ QString CustomPage::selectedLoader() const
void CustomPage::suggestCurrent()
{
- if (!isOpened)
- {
+ if (!isOpened) {
return;
}
-
- if(!m_selectedVersion)
- {
+
+ if (!m_selectedVersion) {
dialog->setSuggestedPack();
return;
}
// There isn't a selected version if the version list is empty
- if(ui->loaderVersionList->selectedVersion() == nullptr)
+ if (ui->loaderVersionList->selectedVersion() == nullptr)
dialog->setSuggestedPack(m_selectedVersion->descriptor(), new VanillaCreationTask(m_selectedVersion));
- else
- {
+ else {
dialog->setSuggestedPack(m_selectedVersion->descriptor(),
- new VanillaCreationTask(m_selectedVersion, m_selectedLoader,
- m_selectedLoaderVersion));
+ new VanillaCreationTask(m_selectedVersion, m_selectedLoader, m_selectedLoaderVersion));
}
dialog->setSuggestedIcon("default");
}
diff --git a/launcher/ui/pages/modplatform/CustomPage.h b/launcher/ui/pages/modplatform/CustomPage.h
index 8b5a5011..c5d6d5af 100644
--- a/launcher/ui/pages/modplatform/CustomPage.h
+++ b/launcher/ui/pages/modplatform/CustomPage.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
@@ -37,40 +37,26 @@
#include <QWidget>
-#include "ui/pages/BasePage.h"
#include <Application.h>
#include "tasks/Task.h"
+#include "ui/pages/BasePage.h"
-namespace Ui
-{
+namespace Ui {
class CustomPage;
}
class NewInstanceDialog;
-class CustomPage : public QWidget, public BasePage
-{
+class CustomPage : public QWidget, public BasePage {
Q_OBJECT
-public:
- explicit CustomPage(NewInstanceDialog *dialog, QWidget *parent = 0);
+ public:
+ explicit CustomPage(NewInstanceDialog* dialog, QWidget* parent = 0);
virtual ~CustomPage();
- virtual QString displayName() const override
- {
- return tr("Custom");
- }
- virtual QIcon icon() const override
- {
- return APPLICATION->getThemedIcon("minecraft");
- }
- virtual QString id() const override
- {
- return "vanilla";
- }
- virtual QString helpPage() const override
- {
- return "Vanilla-platform";
- }
+ virtual QString displayName() const override { return tr("Custom"); }
+ virtual QIcon icon() const override { return APPLICATION->getThemedIcon("minecraft"); }
+ virtual QString id() const override { return "vanilla"; }
+ virtual QString helpPage() const override { return "Vanilla-platform"; }
virtual bool shouldDisplay() const override;
void retranslate() override;
@@ -80,23 +66,23 @@ public:
BaseVersion::Ptr selectedLoaderVersion() const;
QString selectedLoader() const;
-public slots:
+ public slots:
void setSelectedVersion(BaseVersion::Ptr version);
void setSelectedLoaderVersion(BaseVersion::Ptr version);
-private slots:
+ private slots:
void filterChanged();
void loaderFilterChanged();
-private:
+ private:
void refresh();
void loaderRefresh();
void suggestCurrent();
-private:
+ private:
bool initialized = false;
- NewInstanceDialog *dialog = nullptr;
- Ui::CustomPage *ui = nullptr;
+ NewInstanceDialog* dialog = nullptr;
+ Ui::CustomPage* ui = nullptr;
bool m_versionSetByUser = false;
BaseVersion::Ptr m_selectedVersion;
BaseVersion::Ptr m_selectedLoaderVersion;
diff --git a/launcher/ui/pages/modplatform/ImportPage.cpp b/launcher/ui/pages/modplatform/ImportPage.cpp
index 30196aad..ba53d033 100644
--- a/launcher/ui/pages/modplatform/ImportPage.cpp
+++ b/launcher/ui/pages/modplatform/ImportPage.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,32 +44,24 @@
#include "InstanceImportTask.h"
-
-class UrlValidator : public QValidator
-{
-public:
+class UrlValidator : public QValidator {
+ public:
using QValidator::QValidator;
- State validate(QString &in, int &pos) const
+ State validate(QString& in, int& pos) const
{
const QUrl url(in);
- if (url.isValid() && !url.isRelative() && !url.isEmpty())
- {
+ if (url.isValid() && !url.isRelative() && !url.isEmpty()) {
return Acceptable;
- }
- else if (QFile::exists(in))
- {
+ } else if (QFile::exists(in)) {
return Acceptable;
- }
- else
- {
+ } else {
return Intermediate;
}
}
};
-ImportPage::ImportPage(NewInstanceDialog* dialog, QWidget *parent)
- : QWidget(parent), ui(new Ui::ImportPage), dialog(dialog)
+ImportPage::ImportPage(NewInstanceDialog* dialog, QWidget* parent) : QWidget(parent), ui(new Ui::ImportPage), dialog(dialog)
{
ui->setupUi(this);
ui->modpackEdit->setValidator(new UrlValidator(ui->modpackEdit));
@@ -98,16 +90,13 @@ void ImportPage::openedImpl()
void ImportPage::updateState()
{
- if(!isOpened)
- {
+ if (!isOpened) {
return;
}
- if(ui->modpackEdit->hasAcceptableInput())
- {
+ if (ui->modpackEdit->hasAcceptableInput()) {
QString input = ui->modpackEdit->text();
auto url = QUrl::fromUserInput(input);
- if(url.isLocalFile())
- {
+ if (url.isLocalFile()) {
// FIXME: actually do some validation of what's inside here... this is fake AF
QFileInfo fi(input);
@@ -116,28 +105,23 @@ void ImportPage::updateState()
// mrpack is a modrinth pack
bool isMRPack = fi.suffix() == "mrpack";
- if(fi.exists() && (isZip || isMRPack))
- {
+ if (fi.exists() && (isZip || isMRPack)) {
QFileInfo fi(url.fileName());
- dialog->setSuggestedPack(fi.completeBaseName(), new InstanceImportTask(url,this));
+ dialog->setSuggestedPack(fi.completeBaseName(), new InstanceImportTask(url, this));
dialog->setSuggestedIcon("default");
}
- }
- else
- {
- if(input.endsWith("?client=y")) {
+ } else {
+ if (input.endsWith("?client=y")) {
input.chop(9);
input.append("/file");
url = QUrl::fromUserInput(input);
}
// hook, line and sinker.
QFileInfo fi(url.fileName());
- dialog->setSuggestedPack(fi.completeBaseName(), new InstanceImportTask(url,this));
+ dialog->setSuggestedPack(fi.completeBaseName(), new InstanceImportTask(url, this));
dialog->setSuggestedIcon("default");
}
- }
- else
- {
+ } else {
dialog->setSuggestedPack();
}
}
@@ -154,29 +138,21 @@ void ImportPage::on_modpackBtn_clicked()
//: Option for filtering for *.mrpack files when importing
filter += ";;" + tr("Modrinth pack") + " (*.mrpack)";
const QUrl url = QFileDialog::getOpenFileUrl(this, tr("Choose modpack"), modpackUrl(), filter);
- if (url.isValid())
- {
- if (url.isLocalFile())
- {
+ if (url.isValid()) {
+ if (url.isLocalFile()) {
ui->modpackEdit->setText(url.toLocalFile());
- }
- else
- {
+ } else {
ui->modpackEdit->setText(url.toString());
}
}
}
-
QUrl ImportPage::modpackUrl() const
{
const QUrl url(ui->modpackEdit->text());
- if (url.isValid() && !url.isRelative() && !url.host().isEmpty())
- {
+ if (url.isValid() && !url.isRelative() && !url.host().isEmpty()) {
return url;
- }
- else
- {
+ } else {
return QUrl::fromLocalFile(ui->modpackEdit->text());
}
}
diff --git a/launcher/ui/pages/modplatform/ImportPage.h b/launcher/ui/pages/modplatform/ImportPage.h
index c2acb92d..d846d566 100644
--- a/launcher/ui/pages/modplatform/ImportPage.h
+++ b/launcher/ui/pages/modplatform/ImportPage.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
@@ -37,55 +37,40 @@
#include <QWidget>
-#include "ui/pages/BasePage.h"
#include <Application.h>
#include "tasks/Task.h"
+#include "ui/pages/BasePage.h"
-namespace Ui
-{
+namespace Ui {
class ImportPage;
}
class NewInstanceDialog;
-class ImportPage : public QWidget, public BasePage
-{
+class ImportPage : public QWidget, public BasePage {
Q_OBJECT
-public:
- explicit ImportPage(NewInstanceDialog* dialog, QWidget *parent = 0);
+ public:
+ explicit ImportPage(NewInstanceDialog* dialog, QWidget* parent = 0);
virtual ~ImportPage();
- virtual QString displayName() const override
- {
- return tr("Import");
- }
- virtual QIcon icon() const override
- {
- return APPLICATION->getThemedIcon("viewfolder");
- }
- virtual QString id() const override
- {
- return "import";
- }
- virtual QString helpPage() const override
- {
- return "Zip-import";
- }
+ virtual QString displayName() const override { return tr("Import"); }
+ virtual QIcon icon() const override { return APPLICATION->getThemedIcon("viewfolder"); }
+ virtual QString id() const override { return "import"; }
+ virtual QString helpPage() const override { return "Zip-import"; }
virtual bool shouldDisplay() const override;
void retranslate() override;
- void setUrl(const QString & url);
+ void setUrl(const QString& url);
void openedImpl() override;
-private slots:
+ private slots:
void on_modpackBtn_clicked();
void updateState();
-private:
+ private:
QUrl modpackUrl() const;
-private:
- Ui::ImportPage *ui = nullptr;
+ private:
+ Ui::ImportPage* ui = nullptr;
NewInstanceDialog* dialog = nullptr;
};
-
diff --git a/launcher/ui/pages/modplatform/ResourcePackPage.cpp b/launcher/ui/pages/modplatform/ResourcePackPage.cpp
index 52fb4802..2a4d0281 100644
--- a/launcher/ui/pages/modplatform/ResourcePackPage.cpp
+++ b/launcher/ui/pages/modplatform/ResourcePackPage.cpp
@@ -13,8 +13,7 @@
namespace ResourceDownload {
-ResourcePackResourcePage::ResourcePackResourcePage(ResourceDownloadDialog* dialog, BaseInstance& instance)
- : ResourcePage(dialog, instance)
+ResourcePackResourcePage::ResourcePackResourcePage(ResourceDownloadDialog* dialog, BaseInstance& instance) : ResourcePage(dialog, instance)
{
connect(m_ui->searchButton, &QPushButton::clicked, this, &ResourcePackResourcePage::triggerSearch);
connect(m_ui->packView, &QListView::doubleClicked, this, &ResourcePackResourcePage::onResourceSelected);
@@ -38,7 +37,8 @@ QMap<QString, QString> ResourcePackResourcePage::urlHandlers() const
{
QMap<QString, QString> map;
map.insert(QRegularExpression::anchoredPattern("(?:www\\.)?modrinth\\.com\\/resourcepack\\/([^\\/]+)\\/?"), "modrinth");
- map.insert(QRegularExpression::anchoredPattern("(?:www\\.)?curseforge\\.com\\/minecraft\\/texture-packs\\/([^\\/]+)\\/?"), "curseforge");
+ map.insert(QRegularExpression::anchoredPattern("(?:www\\.)?curseforge\\.com\\/minecraft\\/texture-packs\\/([^\\/]+)\\/?"),
+ "curseforge");
map.insert(QRegularExpression::anchoredPattern("minecraft\\.curseforge\\.com\\/projects\\/([^\\/]+)\\/?"), "curseforge");
return map;
}
diff --git a/launcher/ui/pages/modplatform/ResourcePackPage.h b/launcher/ui/pages/modplatform/ResourcePackPage.h
index 8c5cf08b..6015aec0 100644
--- a/launcher/ui/pages/modplatform/ResourcePackPage.h
+++ b/launcher/ui/pages/modplatform/ResourcePackPage.h
@@ -4,8 +4,8 @@
#pragma once
-#include "ui/pages/modplatform/ResourcePage.h"
#include "ui/pages/modplatform/ResourcePackModel.h"
+#include "ui/pages/modplatform/ResourcePage.h"
namespace Ui {
class ResourcePage;
diff --git a/launcher/ui/pages/modplatform/ResourcePage.cpp b/launcher/ui/pages/modplatform/ResourcePage.cpp
index aab2ee89..48afbd90 100644
--- a/launcher/ui/pages/modplatform/ResourcePage.cpp
+++ b/launcher/ui/pages/modplatform/ResourcePage.cpp
@@ -104,6 +104,7 @@ void ResourcePage::openedImpl()
updateSelectionButton();
triggerSearch();
+ m_ui->searchEdit->setFocus();
}
auto ResourcePage::eventFilter(QObject* watched, QEvent* event) -> bool
diff --git a/launcher/ui/pages/modplatform/TexturePackPage.h b/launcher/ui/pages/modplatform/TexturePackPage.h
index 0bdce2f9..948e5286 100644
--- a/launcher/ui/pages/modplatform/TexturePackPage.h
+++ b/launcher/ui/pages/modplatform/TexturePackPage.h
@@ -4,10 +4,10 @@
#pragma once
-#include "ui_ResourcePage.h"
#include "ui/dialogs/ResourceDownloadDialog.h"
#include "ui/pages/modplatform/ResourcePackPage.h"
#include "ui/pages/modplatform/TexturePackModel.h"
+#include "ui_ResourcePage.h"
namespace Ui {
class ResourcePage;
@@ -39,8 +39,7 @@ class TexturePackResourcePage : public ResourcePackResourcePage {
[[nodiscard]] inline QString resourceString() const override { return tr("texture pack"); }
protected:
- TexturePackResourcePage(TexturePackDownloadDialog* dialog, BaseInstance& instance)
- : ResourcePackResourcePage(dialog, instance)
+ TexturePackResourcePage(TexturePackDownloadDialog* dialog, BaseInstance& instance) : ResourcePackResourcePage(dialog, instance)
{
connect(m_ui->searchButton, &QPushButton::clicked, this, &TexturePackResourcePage::triggerSearch);
connect(m_ui->packView, &QListView::doubleClicked, this, &TexturePackResourcePage::onResourceSelected);
diff --git a/launcher/ui/pages/modplatform/atlauncher/AtlFilterModel.cpp b/launcher/ui/pages/modplatform/atlauncher/AtlFilterModel.cpp
index 0887ebee..9cd5eed5 100644
--- a/launcher/ui/pages/modplatform/atlauncher/AtlFilterModel.cpp
+++ b/launcher/ui/pages/modplatform/atlauncher/AtlFilterModel.cpp
@@ -18,14 +18,14 @@
#include <QDebug>
-#include <modplatform/atlauncher/ATLPackIndex.h>
#include <Version.h>
+#include <modplatform/atlauncher/ATLPackIndex.h>
#include "StringUtils.h"
namespace Atl {
-FilterModel::FilterModel(QObject *parent) : QSortFilterProxyModel(parent)
+FilterModel::FilterModel(QObject* parent) : QSortFilterProxyModel(parent)
{
currentSorting = Sorting::ByPopularity;
sortings.insert(tr("Sort by Popularity"), Sorting::ByPopularity);
@@ -62,7 +62,7 @@ void FilterModel::setSearchTerm(const QString term)
invalidate();
}
-bool FilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
+bool FilterModel::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const
{
if (searchTerm.isEmpty()) {
return true;
@@ -73,20 +73,18 @@ bool FilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParen
return pack.name.contains(searchTerm, Qt::CaseInsensitive);
}
-bool FilterModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
+bool FilterModel::lessThan(const QModelIndex& left, const QModelIndex& right) const
{
ATLauncher::IndexedPack leftPack = sourceModel()->data(left, Qt::UserRole).value<ATLauncher::IndexedPack>();
ATLauncher::IndexedPack rightPack = sourceModel()->data(right, Qt::UserRole).value<ATLauncher::IndexedPack>();
if (currentSorting == ByPopularity) {
return leftPack.position > rightPack.position;
- }
- else if (currentSorting == ByGameVersion) {
+ } else if (currentSorting == ByGameVersion) {
Version lv(leftPack.versions.at(0).minecraft);
Version rv(rightPack.versions.at(0).minecraft);
return lv < rv;
- }
- else if (currentSorting == ByName) {
+ } else if (currentSorting == ByName) {
return StringUtils::naturalCompare(leftPack.name, rightPack.name, Qt::CaseSensitive) >= 0;
}
@@ -95,4 +93,4 @@ bool FilterModel::lessThan(const QModelIndex &left, const QModelIndex &right) co
return true;
}
-}
+} // namespace Atl
diff --git a/launcher/ui/pages/modplatform/atlauncher/AtlFilterModel.h b/launcher/ui/pages/modplatform/atlauncher/AtlFilterModel.h
index 5235ccdb..0ab46ed2 100644
--- a/launcher/ui/pages/modplatform/atlauncher/AtlFilterModel.h
+++ b/launcher/ui/pages/modplatform/atlauncher/AtlFilterModel.h
@@ -20,10 +20,9 @@
namespace Atl {
-class FilterModel : public QSortFilterProxyModel
-{
+class FilterModel : public QSortFilterProxyModel {
Q_OBJECT
-public:
+ public:
FilterModel(QObject* parent = Q_NULLPTR);
enum Sorting {
ByPopularity,
@@ -36,15 +35,14 @@ public:
Sorting getCurrentSorting();
void setSearchTerm(QString term);
-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;
QString searchTerm;
-
};
-}
+} // namespace Atl
diff --git a/launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.cpp b/launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.cpp
index 7b61daa7..62e406d3 100644
--- a/launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.cpp
+++ b/launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.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>
*
* This program is free software: you can redistribute it and/or modify
@@ -38,15 +38,13 @@
#include <QInputDialog>
#include <QMessageBox>
+#include "Application.h"
#include "BuildConfig.h"
#include "Json.h"
#include "modplatform/atlauncher/ATLShareCode.h"
-#include "Application.h"
AtlOptionalModListModel::AtlOptionalModListModel(QWidget* parent, ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods)
- : QAbstractListModel(parent)
- , m_version(version)
- , m_mods(mods)
+ : QAbstractListModel(parent), m_version(version), m_mods(mods)
{
// fill mod index
for (int i = 0; i < m_mods.size(); i++) {
@@ -62,7 +60,8 @@ AtlOptionalModListModel::AtlOptionalModListModel(QWidget* parent, ATLauncher::Pa
}
}
-QVector<QString> AtlOptionalModListModel::getResult() {
+QVector<QString> AtlOptionalModListModel::getResult()
+{
QVector<QString> result;
for (const auto& mod : m_mods) {
@@ -74,16 +73,19 @@ QVector<QString> AtlOptionalModListModel::getResult() {
return result;
}
-int AtlOptionalModListModel::rowCount(const QModelIndex &parent) const {
+int AtlOptionalModListModel::rowCount(const QModelIndex& parent) const
+{
return parent.isValid() ? 0 : m_mods.size();
}
-int AtlOptionalModListModel::columnCount(const QModelIndex &parent) const {
+int AtlOptionalModListModel::columnCount(const QModelIndex& parent) const
+{
// Enabled, Name, Description
return parent.isValid() ? 0 : 3;
}
-QVariant AtlOptionalModListModel::data(const QModelIndex &index, int role) const {
+QVariant AtlOptionalModListModel::data(const QModelIndex& index, int role) const
+{
auto row = index.row();
auto mod = m_mods.at(row);
@@ -94,18 +96,15 @@ QVariant AtlOptionalModListModel::data(const QModelIndex &index, int role) const
if (index.column() == DescriptionColumn) {
return mod.description;
}
- }
- else if (role == Qt::ToolTipRole) {
+ } else if (role == Qt::ToolTipRole) {
if (index.column() == DescriptionColumn) {
return mod.description;
}
- }
- else if (role == Qt::ForegroundRole) {
+ } else if (role == Qt::ForegroundRole) {
if (!mod.colour.isEmpty() && m_version.colours.contains(mod.colour)) {
return QColor(QString("#%1").arg(m_version.colours[mod.colour]));
}
- }
- else if (role == Qt::CheckStateRole) {
+ } else if (role == Qt::CheckStateRole) {
if (index.column() == EnabledColumn) {
return m_selection[mod.name] ? Qt::Checked : Qt::Unchecked;
}
@@ -114,7 +113,8 @@ QVariant AtlOptionalModListModel::data(const QModelIndex &index, int role) const
return {};
}
-bool AtlOptionalModListModel::setData(const QModelIndex &index, const QVariant &value, int role) {
+bool AtlOptionalModListModel::setData(const QModelIndex& index, const QVariant& value, int role)
+{
if (role == Qt::CheckStateRole) {
auto row = index.row();
auto mod = m_mods.at(row);
@@ -126,7 +126,8 @@ bool AtlOptionalModListModel::setData(const QModelIndex &index, const QVariant &
return false;
}
-QVariant AtlOptionalModListModel::headerData(int section, Qt::Orientation orientation, int role) const {
+QVariant AtlOptionalModListModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
switch (section) {
case EnabledColumn:
@@ -141,7 +142,8 @@ QVariant AtlOptionalModListModel::headerData(int section, Qt::Orientation orient
return {};
}
-Qt::ItemFlags AtlOptionalModListModel::flags(const QModelIndex &index) const {
+Qt::ItemFlags AtlOptionalModListModel::flags(const QModelIndex& index) const
+{
auto flags = QAbstractListModel::flags(index);
if (index.isValid() && index.column() == EnabledColumn) {
flags |= Qt::ItemIsUserCheckable;
@@ -149,23 +151,23 @@ Qt::ItemFlags AtlOptionalModListModel::flags(const QModelIndex &index) const {
return flags;
}
-void AtlOptionalModListModel::useShareCode(const QString& code) {
+void AtlOptionalModListModel::useShareCode(const QString& code)
+{
m_jobPtr.reset(new NetJob("Atl::Request", APPLICATION->network()));
auto url = QString(BuildConfig.ATL_API_BASE_URL + "share-codes/" + code);
m_jobPtr->addNetAction(Net::Download::makeByteArray(QUrl(url), m_response));
- connect(m_jobPtr.get(), &NetJob::succeeded,
- this, &AtlOptionalModListModel::shareCodeSuccess);
- connect(m_jobPtr.get(), &NetJob::failed,
- this, &AtlOptionalModListModel::shareCodeFailure);
+ connect(m_jobPtr.get(), &NetJob::succeeded, this, &AtlOptionalModListModel::shareCodeSuccess);
+ connect(m_jobPtr.get(), &NetJob::failed, this, &AtlOptionalModListModel::shareCodeFailure);
m_jobPtr->start();
}
-void AtlOptionalModListModel::shareCodeSuccess() {
+void AtlOptionalModListModel::shareCodeSuccess()
+{
m_jobPtr.reset();
- QJsonParseError parse_error {};
+ QJsonParseError parse_error{};
auto doc = QJsonDocument::fromJson(*m_response, &parse_error);
if (parse_error.error != QJsonParseError::NoError) {
qWarning() << "Error while parsing JSON response from ATL at " << parse_error.offset << " reason: " << parse_error.errorString();
@@ -177,8 +179,7 @@ void AtlOptionalModListModel::shareCodeSuccess() {
ATLauncher::ShareCodeResponse response;
try {
ATLauncher::loadShareCodeResponse(response, obj);
- }
- catch (const JSONValidationError& e) {
+ } catch (const JSONValidationError& e) {
qDebug() << QString::fromUtf8(*m_response);
qWarning() << "Error while reading response from ATLauncher: " << e.cause();
return;
@@ -202,44 +203,44 @@ void AtlOptionalModListModel::shareCodeSuccess() {
m_selection[mod.name] = mod.selected;
}
- emit dataChanged(AtlOptionalModListModel::index(0, EnabledColumn),
- AtlOptionalModListModel::index(m_mods.size() - 1, EnabledColumn));
+ emit dataChanged(AtlOptionalModListModel::index(0, EnabledColumn), AtlOptionalModListModel::index(m_mods.size() - 1, EnabledColumn));
}
-void AtlOptionalModListModel::shareCodeFailure(const QString& reason) {
+void AtlOptionalModListModel::shareCodeFailure(const QString& reason)
+{
m_jobPtr.reset();
// fixme: plumb in an error message
}
-void AtlOptionalModListModel::selectRecommended() {
+void AtlOptionalModListModel::selectRecommended()
+{
for (const auto& mod : m_mods) {
m_selection[mod.name] = mod.recommended;
}
- emit dataChanged(AtlOptionalModListModel::index(0, EnabledColumn),
- AtlOptionalModListModel::index(m_mods.size() - 1, EnabledColumn));
+ emit dataChanged(AtlOptionalModListModel::index(0, EnabledColumn), AtlOptionalModListModel::index(m_mods.size() - 1, EnabledColumn));
}
-void AtlOptionalModListModel::clearAll() {
+void AtlOptionalModListModel::clearAll()
+{
for (const auto& mod : m_mods) {
m_selection[mod.name] = false;
}
- emit dataChanged(AtlOptionalModListModel::index(0, EnabledColumn),
- AtlOptionalModListModel::index(m_mods.size() - 1, EnabledColumn));
+ emit dataChanged(AtlOptionalModListModel::index(0, EnabledColumn), AtlOptionalModListModel::index(m_mods.size() - 1, EnabledColumn));
}
-void AtlOptionalModListModel::toggleMod(ATLauncher::VersionMod mod, int index) {
+void AtlOptionalModListModel::toggleMod(ATLauncher::VersionMod mod, int index)
+{
auto enable = !m_selection[mod.name];
// If there is a warning for the mod, display that first (if we would be enabling the mod)
if (enable && !mod.warning.isEmpty() && m_version.warnings.contains(mod.warning)) {
- auto message = QString("%1<br><br>%2")
- .arg(m_version.warnings[mod.warning], tr("Are you sure that you want to enable this mod?"));
+ auto message = QString("%1<br><br>%2").arg(m_version.warnings[mod.warning], tr("Are you sure that you want to enable this mod?"));
// fixme: avoid casting here
- auto result = QMessageBox::warning((QWidget*) this->parent(), tr("Warning"), message, QMessageBox::Yes | QMessageBox::No);
+ auto result = QMessageBox::warning((QWidget*)this->parent(), tr("Warning"), message, QMessageBox::Yes | QMessageBox::No);
if (result != QMessageBox::Yes) {
return;
}
@@ -248,15 +249,18 @@ void AtlOptionalModListModel::toggleMod(ATLauncher::VersionMod mod, int index) {
setMod(mod, index, enable);
}
-void AtlOptionalModListModel::setMod(ATLauncher::VersionMod mod, int index, bool enable, bool shouldEmit) {
- if (m_selection[mod.name] == enable) return;
+void AtlOptionalModListModel::setMod(ATLauncher::VersionMod mod, int index, bool enable, bool shouldEmit)
+{
+ if (m_selection[mod.name] == enable)
+ return;
m_selection[mod.name] = enable;
// disable other mods in the group, if applicable
if (enable && !mod.group.isEmpty()) {
for (int i = 0; i < m_mods.size(); i++) {
- if (index == i) continue;
+ if (index == i)
+ continue;
auto other = m_mods.at(i);
if (mod.group == other.group) {
@@ -281,8 +285,7 @@ void AtlOptionalModListModel::setMod(ATLauncher::VersionMod mod, int index, bool
if (enable) {
dependants.append(mod.name);
- }
- else {
+ } else {
dependants.removeAll(mod.name);
// if there are no longer any dependents, let's disable the mod
@@ -304,14 +307,12 @@ void AtlOptionalModListModel::setMod(ATLauncher::VersionMod mod, int index, bool
}
if (shouldEmit) {
- emit dataChanged(AtlOptionalModListModel::index(index, EnabledColumn),
- AtlOptionalModListModel::index(index, EnabledColumn));
+ emit dataChanged(AtlOptionalModListModel::index(index, EnabledColumn), AtlOptionalModListModel::index(index, EnabledColumn));
}
}
AtlOptionalModDialog::AtlOptionalModDialog(QWidget* parent, ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods)
- : QDialog(parent)
- , ui(new Ui::AtlOptionalModDialog)
+ : QDialog(parent), ui(new Ui::AtlOptionalModDialog)
{
ui->setupUi(this);
@@ -319,35 +320,24 @@ AtlOptionalModDialog::AtlOptionalModDialog(QWidget* parent, ATLauncher::PackVers
ui->treeView->setModel(listModel);
ui->treeView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- ui->treeView->header()->setSectionResizeMode(
- AtlOptionalModListModel::NameColumn, QHeaderView::ResizeToContents);
- ui->treeView->header()->setSectionResizeMode(
- AtlOptionalModListModel::DescriptionColumn, QHeaderView::Stretch);
-
- connect(ui->shareCodeButton, &QPushButton::clicked,
- this, &AtlOptionalModDialog::useShareCode);
- connect(ui->selectRecommendedButton, &QPushButton::clicked,
- listModel, &AtlOptionalModListModel::selectRecommended);
- connect(ui->clearAllButton, &QPushButton::clicked,
- listModel, &AtlOptionalModListModel::clearAll);
- connect(ui->installButton, &QPushButton::clicked,
- this, &QDialog::accept);
+ ui->treeView->header()->setSectionResizeMode(AtlOptionalModListModel::NameColumn, QHeaderView::ResizeToContents);
+ ui->treeView->header()->setSectionResizeMode(AtlOptionalModListModel::DescriptionColumn, QHeaderView::Stretch);
+
+ connect(ui->shareCodeButton, &QPushButton::clicked, this, &AtlOptionalModDialog::useShareCode);
+ connect(ui->selectRecommendedButton, &QPushButton::clicked, listModel, &AtlOptionalModListModel::selectRecommended);
+ connect(ui->clearAllButton, &QPushButton::clicked, listModel, &AtlOptionalModListModel::clearAll);
+ connect(ui->installButton, &QPushButton::clicked, this, &QDialog::accept);
}
-AtlOptionalModDialog::~AtlOptionalModDialog() {
+AtlOptionalModDialog::~AtlOptionalModDialog()
+{
delete ui;
}
-void AtlOptionalModDialog::useShareCode() {
+void AtlOptionalModDialog::useShareCode()
+{
bool ok;
- auto shareCode = QInputDialog::getText(
- this,
- tr("Select a share code"),
- tr("Share code:"),
- QLineEdit::Normal,
- "",
- &ok
- );
+ auto shareCode = QInputDialog::getText(this, tr("Select a share code"), tr("Share code:"), QLineEdit::Normal, "", &ok);
if (!ok) {
// If the user cancels the dialog, we don't need to show any error dialogs.
diff --git a/launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.h b/launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.h
index 639f0d48..72a946da 100644
--- a/launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.h
+++ b/launcher/ui/pages/modplatform/atlauncher/AtlOptionalModDialog.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,8 +35,8 @@
#pragma once
-#include <QDialog>
#include <QAbstractListModel>
+#include <QDialog>
#include "modplatform/atlauncher/ATLPackIndex.h"
#include "net/NetJob.h"
@@ -48,37 +48,36 @@ class AtlOptionalModDialog;
class AtlOptionalModListModel : public QAbstractListModel {
Q_OBJECT
-public:
- enum Columns
- {
+ public:
+ enum Columns {
EnabledColumn = 0,
NameColumn,
DescriptionColumn,
};
- AtlOptionalModListModel(QWidget *parent, ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods);
+ AtlOptionalModListModel(QWidget* parent, ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods);
QVector<QString> getResult();
- int rowCount(const QModelIndex &parent) const override;
- int columnCount(const QModelIndex &parent) 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;
- bool setData(const QModelIndex &index, const QVariant &value, int role) override;
+ QVariant data(const QModelIndex& index, int role) const override;
+ bool setData(const QModelIndex& index, const QVariant& value, int role) override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
- Qt::ItemFlags flags(const QModelIndex &index) const override;
+ Qt::ItemFlags flags(const QModelIndex& index) const override;
void useShareCode(const QString& code);
-public slots:
+ public slots:
void shareCodeSuccess();
void shareCodeFailure(const QString& reason);
void selectRecommended();
void clearAll();
-private:
+ private:
void toggleMod(ATLauncher::VersionMod mod, int index);
void setMod(ATLauncher::VersionMod mod, int index, bool enable, bool shouldEmit = true);
@@ -97,18 +96,16 @@ private:
class AtlOptionalModDialog : public QDialog {
Q_OBJECT
-public:
- AtlOptionalModDialog(QWidget *parent, ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods);
+ public:
+ AtlOptionalModDialog(QWidget* parent, ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods);
~AtlOptionalModDialog() override;
- QVector<QString> getResult() {
- return listModel->getResult();
- }
+ QVector<QString> getResult() { return listModel->getResult(); }
void useShareCode();
-private:
- Ui::AtlOptionalModDialog *ui;
+ private:
+ Ui::AtlOptionalModDialog* ui;
- AtlOptionalModListModel *listModel;
+ AtlOptionalModListModel* listModel;
};
diff --git a/launcher/ui/pages/modplatform/atlauncher/AtlPage.cpp b/launcher/ui/pages/modplatform/atlauncher/AtlPage.cpp
index 87544445..4c9dec58 100644
--- a/launcher/ui/pages/modplatform/atlauncher/AtlPage.cpp
+++ b/launcher/ui/pages/modplatform/atlauncher/AtlPage.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>
*
* This program is free software: you can redistribute it and/or modify
@@ -46,10 +46,7 @@
#include <QMessageBox>
-AtlPage::AtlPage(NewInstanceDialog* dialog, QWidget* parent)
- : QWidget(parent)
- , ui(new Ui::AtlPage)
- , dialog(dialog)
+AtlPage::AtlPage(NewInstanceDialog* dialog, QWidget* parent) : QWidget(parent), ui(new Ui::AtlPage), dialog(dialog)
{
ui->setupUi(this);
@@ -65,8 +62,7 @@ AtlPage::AtlPage(NewInstanceDialog* dialog, QWidget* parent)
ui->versionSelectionBox->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
ui->versionSelectionBox->view()->parentWidget()->setMaximumHeight(300);
- for(int i = 0; i < filterModel->getAvailableSortings().size(); i++)
- {
+ for (int i = 0; i < filterModel->getAvailableSortings().size(); i++) {
ui->sortByBox->addItem(filterModel->getAvailableSortings().keys().at(i));
}
ui->sortByBox->setCurrentText(filterModel->translateCurrentSorting());
@@ -94,8 +90,7 @@ void AtlPage::retranslate()
void AtlPage::openedImpl()
{
- if(!initialized)
- {
+ if (!initialized) {
listModel->request();
initialized = true;
}
@@ -105,13 +100,11 @@ void AtlPage::openedImpl()
void AtlPage::suggestCurrent()
{
- if(!isOpened)
- {
+ if (!isOpened) {
return;
}
- if (selectedVersion.isEmpty())
- {
+ if (selectedVersion.isEmpty()) {
dialog->setSuggestedPack();
return;
}
@@ -121,10 +114,8 @@ void AtlPage::suggestCurrent()
auto editedLogoName = selected.safeName;
auto url = QString(BuildConfig.ATL_DOWNLOAD_SERVER_URL + "launcher/images/%1.png").arg(selected.safeName.toLower());
- listModel->getLogo(selected.safeName, url, [this, editedLogoName](QString logo)
- {
- dialog->setSuggestedIconFromFile(logo, editedLogoName);
- });
+ listModel->getLogo(selected.safeName, url,
+ [this, editedLogoName](QString logo) { dialog->setSuggestedIconFromFile(logo, editedLogoName); });
}
void AtlPage::triggerSearch()
@@ -142,10 +133,8 @@ void AtlPage::onSelectionChanged(QModelIndex first, QModelIndex second)
{
ui->versionSelectionBox->clear();
- if(!first.isValid())
- {
- if(isOpened)
- {
+ if (!first.isValid()) {
+ if (isOpened) {
dialog->setSuggestedPack();
}
return;
@@ -155,7 +144,7 @@ void AtlPage::onSelectionChanged(QModelIndex first, QModelIndex second)
ui->packDescription->setHtml(selected.description.replace("\n", "<br>"));
- for(const auto& version : selected.versions) {
+ for (const auto& version : selected.versions) {
ui->versionSelectionBox->addItem(version.version);
}
@@ -164,8 +153,7 @@ void AtlPage::onSelectionChanged(QModelIndex first, QModelIndex second)
void AtlPage::onVersionSelectionChanged(QString data)
{
- if(data.isNull() || data.isEmpty())
- {
+ if (data.isNull() || data.isEmpty()) {
selectedVersion = "";
return;
}
diff --git a/launcher/ui/pages/modplatform/atlauncher/AtlPage.h b/launcher/ui/pages/modplatform/atlauncher/AtlPage.h
index 1b3b15c1..6bc44964 100644
--- a/launcher/ui/pages/modplatform/atlauncher/AtlPage.h
+++ b/launcher/ui/pages/modplatform/atlauncher/AtlPage.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
@@ -38,52 +38,38 @@
#include "AtlFilterModel.h"
#include "AtlListModel.h"
-#include <QWidget>
#include <modplatform/atlauncher/ATLPackInstallTask.h>
+#include <QWidget>
#include "Application.h"
-#include "ui/pages/BasePage.h"
#include "tasks/Task.h"
+#include "ui/pages/BasePage.h"
-namespace Ui
-{
- class AtlPage;
+namespace Ui {
+class AtlPage;
}
class NewInstanceDialog;
-class AtlPage : public QWidget, public BasePage
-{
-Q_OBJECT
+class AtlPage : public QWidget, public BasePage {
+ Q_OBJECT
-public:
- explicit AtlPage(NewInstanceDialog* dialog, QWidget *parent = 0);
+ public:
+ explicit AtlPage(NewInstanceDialog* dialog, QWidget* parent = 0);
virtual ~AtlPage();
- virtual QString displayName() const override
- {
- return "ATLauncher";
- }
- virtual QIcon icon() const override
- {
- return APPLICATION->getThemedIcon("atlauncher");
- }
- virtual QString id() const override
- {
- return "atl";
- }
- virtual QString helpPage() const override
- {
- return "ATL-platform";
- }
+ virtual QString displayName() const override { return "ATLauncher"; }
+ virtual QIcon icon() const override { return APPLICATION->getThemedIcon("atlauncher"); }
+ virtual QString id() const override { return "atl"; }
+ virtual QString helpPage() const override { return "ATL-platform"; }
virtual bool shouldDisplay() const override;
void retranslate() override;
void openedImpl() override;
-private:
+ private:
void suggestCurrent();
-private slots:
+ private slots:
void triggerSearch();
void onSortingSelectionChanged(QString data);
@@ -91,8 +77,8 @@ private slots:
void onSelectionChanged(QModelIndex first, QModelIndex second);
void onVersionSelectionChanged(QString data);
-private:
- Ui::AtlPage *ui = nullptr;
+ private:
+ Ui::AtlPage* ui = nullptr;
NewInstanceDialog* dialog = nullptr;
Atl::ListModel* listModel = nullptr;
Atl::FilterModel* filterModel = nullptr;
diff --git a/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.cpp b/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.cpp
index 3d2d568a..0c725785 100644
--- a/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.cpp
+++ b/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.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>
*
* This program is free software: you can redistribute it and/or modify
@@ -33,17 +33,16 @@
* limitations under the License.
*/
-#include <QMessageBox>
#include "AtlUserInteractionSupportImpl.h"
+#include <QMessageBox>
#include "AtlOptionalModDialog.h"
#include "ui/dialogs/VersionSelectDialog.h"
-AtlUserInteractionSupportImpl::AtlUserInteractionSupportImpl(QWidget *parent) : m_parent(parent)
-{
-}
+AtlUserInteractionSupportImpl::AtlUserInteractionSupportImpl(QWidget* parent) : m_parent(parent) {}
-std::optional<QVector<QString>> AtlUserInteractionSupportImpl::chooseOptionalMods(ATLauncher::PackVersion version, QVector<ATLauncher::VersionMod> mods)
+std::optional<QVector<QString>> AtlUserInteractionSupportImpl::chooseOptionalMods(ATLauncher::PackVersion version,
+ QVector<ATLauncher::VersionMod> mods)
{
AtlOptionalModDialog optionalModDialog(m_parent, version, mods);
auto result = optionalModDialog.exec();
@@ -59,8 +58,7 @@ QString AtlUserInteractionSupportImpl::chooseVersion(Meta::VersionList::Ptr vlis
if (minecraftVersion != nullptr) {
vselect.setExactFilter(BaseVersionList::ParentVersionRole, minecraftVersion);
vselect.setEmptyString(tr("No versions are currently available for Minecraft %1").arg(minecraftVersion));
- }
- else {
+ } else {
vselect.setEmptyString(tr("No versions are currently available"));
}
vselect.setEmptyErrorString(tr("Couldn't load or download the version lists!"));
@@ -72,9 +70,7 @@ QString AtlUserInteractionSupportImpl::chooseVersion(Meta::VersionList::Ptr vlis
// filter by minecraft version, if the loader depends on a certain version.
if (minecraftVersion != nullptr) {
- auto iter = std::find_if(reqs.begin(), reqs.end(), [](const Meta::Require& req) {
- return req.uid == "net.minecraft";
- });
+ auto iter = std::find_if(reqs.begin(), reqs.end(), [](const Meta::Require& req) { return req.uid == "net.minecraft"; });
if (iter == reqs.end())
continue;
if (iter->equalsVersion != minecraftVersion)
diff --git a/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.h b/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.h
index adeb53cb..52ced261 100644
--- a/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.h
+++ b/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.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
diff --git a/launcher/ui/pages/modplatform/flame/FlameModel.cpp b/launcher/ui/pages/modplatform/flame/FlameModel.cpp
index fa55aa68..83c1270b 100644
--- a/launcher/ui/pages/modplatform/flame/FlameModel.cpp
+++ b/launcher/ui/pages/modplatform/flame/FlameModel.cpp
@@ -40,14 +40,16 @@ QVariant ListModel::data(const QModelIndex& index, int role) const
return edit;
}
return pack.description;
- } case Qt::DecorationRole: {
+ }
+ case Qt::DecorationRole: {
if (m_logoMap.contains(pack.logoName)) {
return (m_logoMap.value(pack.logoName));
}
QIcon icon = APPLICATION->getThemedIcon("screenshot-placeholder");
((ListModel*)this)->requestLogo(pack.logoName, pack.logoUrl);
return icon;
- } case Qt::UserRole: {
+ }
+ case Qt::UserRole: {
QVariant v;
v.setValue(pack);
return v;
@@ -68,7 +70,7 @@ QVariant ListModel::data(const QModelIndex& index, int role) const
return QVariant();
}
-bool ListModel::setData(const QModelIndex &index, const QVariant &value, int role)
+bool ListModel::setData(const QModelIndex& index, const QVariant& value, int role)
{
int pos = index.row();
if (pos >= modpacks.size() || pos < 0 || !index.isValid())
diff --git a/launcher/ui/pages/modplatform/flame/FlamePage.cpp b/launcher/ui/pages/modplatform/flame/FlamePage.cpp
index cef26bb6..b676cad9 100644
--- a/launcher/ui/pages/modplatform/flame/FlamePage.cpp
+++ b/launcher/ui/pages/modplatform/flame/FlamePage.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>
*
* This program is free software: you can redistribute it and/or modify
@@ -42,9 +42,9 @@
#include "FlameModel.h"
#include "InstanceImportTask.h"
#include "Json.h"
+#include "modplatform/flame/FlameAPI.h"
#include "ui/dialogs/NewInstanceDialog.h"
#include "ui/widgets/ProjectItem.h"
-#include "modplatform/flame/FlameAPI.h"
static FlameAPI api;
@@ -252,10 +252,8 @@ void FlamePage::updateUi()
text += "<br>" + tr(" by ") + authorStrs.join(", ");
}
- if(current.extraInfoLoaded) {
- if (!current.extra.issuesUrl.isEmpty()
- || !current.extra.sourceUrl.isEmpty()
- || !current.extra.wikiUrl.isEmpty()) {
+ if (current.extraInfoLoaded) {
+ if (!current.extra.issuesUrl.isEmpty() || !current.extra.sourceUrl.isEmpty() || !current.extra.wikiUrl.isEmpty()) {
text += "<br><br>" + tr("External links:") + "<br>";
}
@@ -267,7 +265,6 @@ void FlamePage::updateUi()
text += "- " + tr("Source code: <a href=%1>%1</a>").arg(current.extra.sourceUrl) + "<br>";
}
-
text += "<hr>";
text += api.getModDescription(current.addonId).toUtf8();
diff --git a/launcher/ui/pages/modplatform/flame/FlamePage.h b/launcher/ui/pages/modplatform/flame/FlamePage.h
index 8bdca38e..ff5c7975 100644
--- a/launcher/ui/pages/modplatform/flame/FlamePage.h
+++ b/launcher/ui/pages/modplatform/flame/FlamePage.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
@@ -37,45 +37,31 @@
#include <QWidget>
-#include "ui/pages/BasePage.h"
#include <Application.h>
-#include "tasks/Task.h"
#include <modplatform/flame/FlamePackIndex.h>
+#include "tasks/Task.h"
+#include "ui/pages/BasePage.h"
-namespace Ui
-{
+namespace Ui {
class FlamePage;
}
class NewInstanceDialog;
namespace Flame {
- class ListModel;
+class ListModel;
}
-class FlamePage : public QWidget, public BasePage
-{
+class FlamePage : public QWidget, public BasePage {
Q_OBJECT
-public:
- explicit FlamePage(NewInstanceDialog* dialog, QWidget *parent = 0);
+ public:
+ explicit FlamePage(NewInstanceDialog* dialog, QWidget* parent = 0);
virtual ~FlamePage();
- virtual QString displayName() const override
- {
- return "CurseForge";
- }
- virtual QIcon icon() const override
- {
- return APPLICATION->getThemedIcon("flame");
- }
- virtual QString id() const override
- {
- return "flame";
- }
- virtual QString helpPage() const override
- {
- return "Flame-platform";
- }
+ virtual QString displayName() const override { return "CurseForge"; }
+ virtual QIcon icon() const override { return APPLICATION->getThemedIcon("flame"); }
+ virtual QString id() const override { return "flame"; }
+ virtual QString helpPage() const override { return "Flame-platform"; }
virtual bool shouldDisplay() const override;
void retranslate() override;
@@ -83,18 +69,18 @@ public:
void openedImpl() override;
- bool eventFilter(QObject * watched, QEvent * event) override;
+ bool eventFilter(QObject* watched, QEvent* event) override;
-private:
+ private:
void suggestCurrent();
-private slots:
+ private slots:
void triggerSearch();
void onSelectionChanged(QModelIndex first, QModelIndex second);
void onVersionSelectionChanged(QString data);
-private:
- Ui::FlamePage *ui = nullptr;
+ private:
+ Ui::FlamePage* ui = nullptr;
NewInstanceDialog* dialog = nullptr;
Flame::ListModel* listModel = nullptr;
Flame::IndexedPack current;
diff --git a/launcher/ui/pages/modplatform/flame/FlameResourcePages.cpp b/launcher/ui/pages/modplatform/flame/FlameResourcePages.cpp
index f93e27e6..dc17e705 100644
--- a/launcher/ui/pages/modplatform/flame/FlameResourcePages.cpp
+++ b/launcher/ui/pages/modplatform/flame/FlameResourcePages.cpp
@@ -49,8 +49,7 @@ static bool isOptedOut(ModPlatform::IndexedVersion const& ver)
return ver.downloadUrl.isEmpty();
}
-FlameModPage::FlameModPage(ModDownloadDialog* dialog, BaseInstance& instance)
- : ModPage(dialog, instance)
+FlameModPage::FlameModPage(ModDownloadDialog* dialog, BaseInstance& instance) : ModPage(dialog, instance)
{
m_model = new FlameModModel(instance);
m_ui->packView->setModel(m_model);
@@ -67,7 +66,9 @@ FlameModPage::FlameModPage(ModDownloadDialog* dialog, BaseInstance& instance)
m_ui->packDescription->setMetaEntry(metaEntryBase());
}
-auto FlameModPage::validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, std::optional<ResourceAPI::ModLoaderTypes> loaders) const -> bool
+auto FlameModPage::validateVersion(ModPlatform::IndexedVersion& ver,
+ QString mineVer,
+ std::optional<ResourceAPI::ModLoaderTypes> loaders) const -> bool
{
Q_UNUSED(loaders);
return ver.mcVersion.contains(mineVer) && !ver.downloadUrl.isEmpty();
@@ -86,7 +87,7 @@ void FlameModPage::openUrl(const QUrl& url)
if (query.startsWith("remoteUrl=")) {
// attempt to resolve url from warning page
query.remove(0, 10);
- ModPage::openUrl({QUrl::fromPercentEncoding(query.toUtf8())}); // double decoding is necessary
+ ModPage::openUrl({ QUrl::fromPercentEncoding(query.toUtf8()) }); // double decoding is necessary
return;
}
}
@@ -125,7 +126,7 @@ void FlameResourcePackPage::openUrl(const QUrl& url)
if (query.startsWith("remoteUrl=")) {
// attempt to resolve url from warning page
query.remove(0, 10);
- ResourcePackResourcePage::openUrl({QUrl::fromPercentEncoding(query.toUtf8())}); // double decoding is necessary
+ ResourcePackResourcePage::openUrl({ QUrl::fromPercentEncoding(query.toUtf8()) }); // double decoding is necessary
return;
}
}
@@ -164,7 +165,7 @@ void FlameTexturePackPage::openUrl(const QUrl& url)
if (query.startsWith("remoteUrl=")) {
// attempt to resolve url from warning page
query.remove(0, 10);
- ResourcePackResourcePage::openUrl({QUrl::fromPercentEncoding(query.toUtf8())}); // double decoding is necessary
+ ResourcePackResourcePage::openUrl({ QUrl::fromPercentEncoding(query.toUtf8()) }); // double decoding is necessary
return;
}
}
@@ -175,8 +176,17 @@ void FlameTexturePackPage::openUrl(const QUrl& url)
// I don't know why, but doing this on the parent class makes it so that
// other mod providers start loading before being selected, at least with
// my Qt, so we need to implement this in every derived class...
-auto FlameModPage::shouldDisplay() const -> bool { return true; }
-auto FlameResourcePackPage::shouldDisplay() const -> bool { return true; }
-auto FlameTexturePackPage::shouldDisplay() const -> bool { return true; }
+auto FlameModPage::shouldDisplay() const -> bool
+{
+ return true;
+}
+auto FlameResourcePackPage::shouldDisplay() const -> bool
+{
+ return true;
+}
+auto FlameTexturePackPage::shouldDisplay() const -> bool
+{
+ return true;
+}
} // namespace ResourceDownload
diff --git a/launcher/ui/pages/modplatform/flame/FlameResourcePages.h b/launcher/ui/pages/modplatform/flame/FlameResourcePages.h
index 103a6bb9..c6ebc1ea 100644
--- a/launcher/ui/pages/modplatform/flame/FlameResourcePages.h
+++ b/launcher/ui/pages/modplatform/flame/FlameResourcePages.h
@@ -49,12 +49,27 @@
namespace ResourceDownload {
namespace Flame {
-static inline QString displayName() { return "CurseForge"; }
-static inline QIcon icon() { return APPLICATION->getThemedIcon("flame"); }
-static inline QString id() { return "curseforge"; }
-static inline QString debugName() { return "Flame"; }
-static inline QString metaEntryBase() { return "FlameMods"; }
+static inline QString displayName()
+{
+ return "CurseForge";
}
+static inline QIcon icon()
+{
+ return APPLICATION->getThemedIcon("flame");
+}
+static inline QString id()
+{
+ return "curseforge";
+}
+static inline QString debugName()
+{
+ return "Flame";
+}
+static inline QString metaEntryBase()
+{
+ return "FlameMods";
+}
+} // namespace Flame
class FlameModPage : public ModPage {
Q_OBJECT
@@ -78,7 +93,9 @@ class FlameModPage : public ModPage {
[[nodiscard]] inline auto helpPage() const -> QString override { return "Mod-platform"; }
- bool validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, std::optional<ResourceAPI::ModLoaderTypes> loaders = {}) const override;
+ bool validateVersion(ModPlatform::IndexedVersion& ver,
+ QString mineVer,
+ std::optional<ResourceAPI::ModLoaderTypes> loaders = {}) const override;
bool optedOut(ModPlatform::IndexedVersion& ver) const override;
void openUrl(const QUrl& url) override;
diff --git a/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.cpp b/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.cpp
new file mode 100644
index 00000000..5c9ff63b
--- /dev/null
+++ b/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.cpp
@@ -0,0 +1,104 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (c) 2023 Trial97 <alexandru.tripon97@gmail.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 <https://www.gnu.org/licenses/>.
+ */
+
+#include "ImportFTBPage.h"
+#include "ui_ImportFTBPage.h"
+
+#include <QWidget>
+#include "FileSystem.h"
+#include "ListModel.h"
+#include "modplatform/import_ftb/PackInstallTask.h"
+#include "ui/dialogs/NewInstanceDialog.h"
+
+namespace FTBImportAPP {
+
+ImportFTBPage::ImportFTBPage(NewInstanceDialog* dialog, QWidget* parent) : QWidget(parent), dialog(dialog), ui(new Ui::ImportFTBPage)
+{
+ ui->setupUi(this);
+
+ {
+ listModel = new ListModel(this);
+
+ ui->modpackList->setModel(listModel);
+ ui->modpackList->setSortingEnabled(true);
+ ui->modpackList->header()->hide();
+ ui->modpackList->setIndentation(0);
+ ui->modpackList->setIconSize(QSize(42, 42));
+ }
+
+ connect(ui->modpackList->selectionModel(), &QItemSelectionModel::currentChanged, this, &ImportFTBPage::onPublicPackSelectionChanged);
+
+ ui->modpackList->selectionModel()->reset();
+}
+
+ImportFTBPage::~ImportFTBPage()
+{
+ delete ui;
+}
+
+void ImportFTBPage::openedImpl()
+{
+ if (!initialized) {
+ listModel->update();
+ initialized = true;
+ }
+ suggestCurrent();
+}
+
+void ImportFTBPage::retranslate()
+{
+ ui->retranslateUi(this);
+}
+
+void ImportFTBPage::suggestCurrent()
+{
+ if (!isOpened)
+ return;
+
+ if (selected.path.isEmpty()) {
+ dialog->setSuggestedPack();
+ return;
+ }
+
+ dialog->setSuggestedPack(selected.name, new PackInstallTask(selected));
+ QString editedLogoName = QString("ftb_%1").arg(selected.id);
+ dialog->setSuggestedIconFromFile(FS::PathCombine(selected.path, "folder.jpg"), editedLogoName);
+}
+
+void ImportFTBPage::onPublicPackSelectionChanged(QModelIndex now, QModelIndex prev)
+{
+ if (!now.isValid()) {
+ onPackSelectionChanged();
+ return;
+ }
+ Modpack selectedPack = listModel->data(now, Qt::UserRole).value<Modpack>();
+ onPackSelectionChanged(&selectedPack);
+}
+
+void ImportFTBPage::onPackSelectionChanged(Modpack* pack)
+{
+ if (pack) {
+ selected = *pack;
+ suggestCurrent();
+ return;
+ }
+ if (isOpened)
+ dialog->setSuggestedPack();
+}
+
+} // namespace FTBImportAPP
diff --git a/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.h b/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.h
new file mode 100644
index 00000000..54c49f7b
--- /dev/null
+++ b/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.h
@@ -0,0 +1,67 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (c) 2023 Trial97 <alexandru.tripon97@gmail.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 <https://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <QDialog>
+#include <QTextBrowser>
+#include <QTreeView>
+#include <QWidget>
+
+#include <Application.h>
+#include "modplatform/import_ftb/PackHelpers.h"
+#include "ui/pages/BasePage.h"
+#include "ui/pages/modplatform/import_ftb/ListModel.h"
+
+class NewInstanceDialog;
+
+namespace FTBImportAPP {
+namespace Ui {
+class ImportFTBPage;
+}
+
+class ImportFTBPage : public QWidget, public BasePage {
+ Q_OBJECT
+
+ public:
+ explicit ImportFTBPage(NewInstanceDialog* dialog, QWidget* parent = 0);
+ virtual ~ImportFTBPage();
+ QString displayName() const override { return tr("FTB App Import"); }
+ QIcon icon() const override { return APPLICATION->getThemedIcon("ftb_logo"); }
+ QString id() const override { return "import_ftb"; }
+ QString helpPage() const override { return "FTB-platform"; }
+ bool shouldDisplay() const override { return true; }
+ void openedImpl() override;
+ void retranslate() override;
+
+ private:
+ void suggestCurrent();
+ void onPackSelectionChanged(Modpack* pack = nullptr);
+ private slots:
+ void onPublicPackSelectionChanged(QModelIndex first, QModelIndex second);
+
+ private:
+ bool initialized = false;
+ Modpack selected;
+ ListModel* listModel = nullptr;
+
+ NewInstanceDialog* dialog = nullptr;
+ Ui::ImportFTBPage* ui = nullptr;
+};
+
+} // namespace FTBImportAPP
diff --git a/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.ui b/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.ui
new file mode 100644
index 00000000..32d548b0
--- /dev/null
+++ b/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.ui
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>FTBImportAPP::ImportFTBPage</class>
+ <widget class="QWidget" name="FTBImportAPP::ImportFTBPage">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>1461</width>
+ <height>1011</height>
+ </rect>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QTreeView" name="modpackList">
+ <property name="maximumSize">
+ <size>
+ <width>16777215</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/launcher/ui/pages/modplatform/import_ftb/ListModel.cpp b/launcher/ui/pages/modplatform/import_ftb/ListModel.cpp
new file mode 100644
index 00000000..dc78f451
--- /dev/null
+++ b/launcher/ui/pages/modplatform/import_ftb/ListModel.cpp
@@ -0,0 +1,88 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (c) 2023 Trial97 <alexandru.tripon97@gmail.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 <https://www.gnu.org/licenses/>.
+ */
+
+#include "ListModel.h"
+#include <QDir>
+#include <QDirIterator>
+#include <QFileInfo>
+#include <QIcon>
+#include <QProcessEnvironment>
+#include "FileSystem.h"
+#include "modplatform/import_ftb/PackHelpers.h"
+
+namespace FTBImportAPP {
+
+QString getPath()
+{
+ QString partialPath;
+#if defined(Q_OS_OSX)
+ partialPath = FS::PathCombine(QDir::homePath(), "Library/Application Support");
+#elif defined(Q_OS_WIN32)
+ partialPath = QProcessEnvironment::systemEnvironment().value("LOCALAPPDATA", "");
+#else
+ partialPath = QDir::homePath();
+#endif
+ return FS::PathCombine(partialPath, ".ftba");
+}
+
+const QString ListModel::FTB_APP_PATH = getPath();
+
+void ListModel::update()
+{
+ beginResetModel();
+ modpacks.clear();
+
+ QString instancesPath = FS::PathCombine(FTB_APP_PATH, "instances");
+ if (auto instancesInfo = QFileInfo(instancesPath); instancesInfo.exists() && instancesInfo.isDir()) {
+ QDirIterator directoryIterator(instancesPath, QDir::Dirs | QDir::NoDotAndDotDot | QDir::Readable | QDir::Hidden,
+ QDirIterator::FollowSymlinks);
+ while (directoryIterator.hasNext()) {
+ auto modpack = parseDirectory(directoryIterator.next());
+ if (!modpack.path.isEmpty())
+ modpacks.append(modpack);
+ }
+ } else {
+ qDebug() << "Couldn't find ftb instances folder: " << instancesPath;
+ }
+
+ endResetModel();
+}
+
+QVariant ListModel::data(const QModelIndex& index, int role) const
+{
+ int pos = index.row();
+ if (pos >= modpacks.size() || pos < 0 || !index.isValid()) {
+ return QVariant();
+ }
+
+ auto pack = modpacks.at(pos);
+ if (role == Qt::DisplayRole) {
+ return pack.name;
+ } else if (role == Qt::DecorationRole) {
+ return pack.icon;
+ } else if (role == Qt::UserRole) {
+ QVariant v;
+ v.setValue(pack);
+ return v;
+ } else if (role == Qt::ToolTipRole) {
+ return tr("Minecraft %1").arg(pack.mcVersion);
+ }
+
+ return QVariant();
+}
+} // namespace FTBImportAPP \ No newline at end of file
diff --git a/launcher/ui/pages/modplatform/import_ftb/ListModel.h b/launcher/ui/pages/modplatform/import_ftb/ListModel.h
new file mode 100644
index 00000000..c67aa896
--- /dev/null
+++ b/launcher/ui/pages/modplatform/import_ftb/ListModel.h
@@ -0,0 +1,46 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * Prism Launcher - Minecraft Launcher
+ * Copyright (c) 2023 Trial97 <alexandru.tripon97@gmail.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 <https://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <QAbstractListModel>
+#include <QIcon>
+#include <QVariant>
+#include "modplatform/import_ftb/PackHelpers.h"
+
+namespace FTBImportAPP {
+
+class ListModel : public QAbstractListModel {
+ Q_OBJECT
+
+ public:
+ ListModel(QObject* parent) : QAbstractListModel(parent) {}
+ virtual ~ListModel() = default;
+
+ int rowCount(const QModelIndex& parent) const { return modpacks.size(); }
+ int columnCount(const QModelIndex& parent) const { return 1; }
+ QVariant data(const QModelIndex& index, int role) const;
+
+ void update();
+
+ static const QString FTB_APP_PATH;
+
+ private:
+ ModpackList modpacks;
+};
+} // namespace FTBImportAPP \ No newline at end of file
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
diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp b/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp
index e0046d88..761e265d 100644
--- a/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp
+++ b/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
*
@@ -115,7 +115,7 @@ auto ModpackListModel::data(const QModelIndex& index, int role) const -> QVarian
return {};
}
-bool ModpackListModel::setData(const QModelIndex &index, const QVariant &value, int role)
+bool ModpackListModel::setData(const QModelIndex& index, const QVariant& value, int role)
{
int pos = index.row();
if (pos >= modpacks.size() || pos < 0 || !index.isValid())
@@ -181,18 +181,18 @@ void ModpackListModel::refresh()
static auto sortFromIndex(int index) -> QString
{
- switch(index){
- default:
- case 0:
- return "relevance";
- case 1:
- return "downloads";
- case 2:
- return "follows";
- case 3:
- return "newest";
- case 4:
- return "updated";
+ switch (index) {
+ default:
+ case 0:
+ return "relevance";
+ case 1:
+ return "downloads";
+ case 2:
+ return "follows";
+ case 3:
+ return "newest";
+ case 4:
+ return "updated";
}
return {};
@@ -200,7 +200,7 @@ static auto sortFromIndex(int index) -> QString
void ModpackListModel::searchWithTerm(const QString& term, const int sort)
{
- if(sort > 5 || sort < 0)
+ if (sort > 5 || sort < 0)
return;
auto sort_str = sortFromIndex(sort);
diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthModel.h b/launcher/ui/pages/modplatform/modrinth/ModrinthModel.h
index b9e9c3da..721c69f5 100644
--- a/launcher/ui/pages/modplatform/modrinth/ModrinthModel.h
+++ b/launcher/ui/pages/modplatform/modrinth/ModrinthModel.h
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
@@ -47,7 +47,7 @@ class Version;
namespace Modrinth {
using LogoMap = QMap<QString, QIcon>;
-using LogoCallback = std::function<void (QString)>;
+using LogoCallback = std::function<void(QString)>;
class ModpackListModel : public QAbstractListModel {
Q_OBJECT
@@ -64,7 +64,7 @@ class ModpackListModel : public QAbstractListModel {
/* Retrieve information from the model at a given index with the given role */
auto data(const QModelIndex& index, int role) const -> QVariant override;
- bool setData(const QModelIndex &index, const QVariant &value, int role) override;
+ bool setData(const QModelIndex& index, const QVariant& value, int role) override;
inline void setActiveJob(NetJob::Ptr ptr) { jobPtr = ptr; }
@@ -75,7 +75,10 @@ class ModpackListModel : public QAbstractListModel {
void getLogo(const QString& logo, const QString& logoUrl, LogoCallback callback);
- inline auto canFetchMore(const QModelIndex& parent) const -> bool override { return parent.isValid() ? false : searchState == CanPossiblyFetchMore; };
+ inline auto canFetchMore(const QModelIndex& parent) const -> bool override
+ {
+ return parent.isValid() ? false : searchState == CanPossiblyFetchMore;
+ };
public slots:
void searchRequestFinished(QJsonDocument& doc_all);
diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp
index c71dd903..31b05030 100644
--- a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp
+++ b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.h b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.h
index db5e1a3d..b7054c88 100644
--- a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.h
+++ b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.h
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthResourceModels.cpp b/launcher/ui/pages/modplatform/modrinth/ModrinthResourceModels.cpp
index 8aa64989..00a0108a 100644
--- a/launcher/ui/pages/modplatform/modrinth/ModrinthResourceModels.cpp
+++ b/launcher/ui/pages/modplatform/modrinth/ModrinthResourceModels.cpp
@@ -2,7 +2,7 @@
//
// 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/modrinth/ModrinthResourceModels.h b/launcher/ui/pages/modplatform/modrinth/ModrinthResourceModels.h
index d7c858f8..15cd5854 100644
--- a/launcher/ui/pages/modplatform/modrinth/ModrinthResourceModels.h
+++ b/launcher/ui/pages/modplatform/modrinth/ModrinthResourceModels.h
@@ -2,7 +2,7 @@
//
// 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/modrinth/ModrinthResourcePages.cpp b/launcher/ui/pages/modplatform/modrinth/ModrinthResourcePages.cpp
index dd143700..616c1a81 100644
--- a/launcher/ui/pages/modplatform/modrinth/ModrinthResourcePages.cpp
+++ b/launcher/ui/pages/modplatform/modrinth/ModrinthResourcePages.cpp
@@ -2,7 +2,7 @@
//
// 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
@@ -46,8 +46,7 @@
namespace ResourceDownload {
-ModrinthModPage::ModrinthModPage(ModDownloadDialog* dialog, BaseInstance& instance)
- : ModPage(dialog, instance)
+ModrinthModPage::ModrinthModPage(ModDownloadDialog* dialog, BaseInstance& instance) : ModPage(dialog, instance)
{
m_model = new ModrinthModModel(instance);
m_ui->packView->setModel(m_model);
@@ -64,14 +63,15 @@ ModrinthModPage::ModrinthModPage(ModDownloadDialog* dialog, BaseInstance& instan
m_ui->packDescription->setMetaEntry(metaEntryBase());
}
-auto ModrinthModPage::validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, std::optional<ResourceAPI::ModLoaderTypes> loaders) const -> bool
+auto ModrinthModPage::validateVersion(ModPlatform::IndexedVersion& ver,
+ QString mineVer,
+ std::optional<ResourceAPI::ModLoaderTypes> loaders) const -> bool
{
auto loaderCompatible = !loaders.has_value();
if (!loaderCompatible) {
auto loaderStrings = ModrinthAPI::getModLoaderStrings(loaders.value());
- for (auto remoteLoader : ver.loaders)
- {
+ for (auto remoteLoader : ver.loaders) {
if (loaderStrings.contains(remoteLoader)) {
loaderCompatible = true;
break;
@@ -139,9 +139,21 @@ ModrinthShaderPackPage::ModrinthShaderPackPage(ShaderPackDownloadDialog* dialog,
// I don't know why, but doing this on the parent class makes it so that
// other mod providers start loading before being selected, at least with
// my Qt, so we need to implement this in every derived class...
-auto ModrinthModPage::shouldDisplay() const -> bool { return true; }
-auto ModrinthResourcePackPage::shouldDisplay() const -> bool { return true; }
-auto ModrinthTexturePackPage::shouldDisplay() const -> bool { return true; }
-auto ModrinthShaderPackPage::shouldDisplay() const -> bool { return true; }
+auto ModrinthModPage::shouldDisplay() const -> bool
+{
+ return true;
+}
+auto ModrinthResourcePackPage::shouldDisplay() const -> bool
+{
+ return true;
+}
+auto ModrinthTexturePackPage::shouldDisplay() const -> bool
+{
+ return true;
+}
+auto ModrinthShaderPackPage::shouldDisplay() const -> bool
+{
+ return true;
+}
} // namespace ResourceDownload
diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthResourcePages.h b/launcher/ui/pages/modplatform/modrinth/ModrinthResourcePages.h
index f4eb5ce0..86ba1ccb 100644
--- a/launcher/ui/pages/modplatform/modrinth/ModrinthResourcePages.h
+++ b/launcher/ui/pages/modplatform/modrinth/ModrinthResourcePages.h
@@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: GPL-3.0-only AND Apache-2.0
/*
- * 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
@@ -43,18 +43,33 @@
#include "ui/pages/modplatform/ModPage.h"
#include "ui/pages/modplatform/ResourcePackPage.h"
-#include "ui/pages/modplatform/TexturePackPage.h"
#include "ui/pages/modplatform/ShaderPackPage.h"
+#include "ui/pages/modplatform/TexturePackPage.h"
namespace ResourceDownload {
namespace Modrinth {
-static inline QString displayName() { return "Modrinth"; }
-static inline QIcon icon() { return APPLICATION->getThemedIcon("modrinth"); }
-static inline QString id() { return "modrinth"; }
-static inline QString debugName() { return "Modrinth"; }
-static inline QString metaEntryBase() { return "ModrinthPacks"; }
+static inline QString displayName()
+{
+ return "Modrinth";
+}
+static inline QIcon icon()
+{
+ return APPLICATION->getThemedIcon("modrinth");
+}
+static inline QString id()
+{
+ return "modrinth";
+}
+static inline QString debugName()
+{
+ return "Modrinth";
+}
+static inline QString metaEntryBase()
+{
+ return "ModrinthPacks";
}
+} // namespace Modrinth
class ModrinthModPage : public ModPage {
Q_OBJECT
@@ -78,7 +93,8 @@ class ModrinthModPage : public ModPage {
[[nodiscard]] inline auto helpPage() const -> QString override { return "Mod-platform"; }
- auto validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, std::optional<ResourceAPI::ModLoaderTypes> loaders = {}) const -> bool override;
+ auto validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, std::optional<ResourceAPI::ModLoaderTypes> loaders = {}) const
+ -> bool override;
};
class ModrinthResourcePackPage : public ResourcePackResourcePage {
diff --git a/launcher/ui/pages/modplatform/technic/TechnicData.h b/launcher/ui/pages/modplatform/technic/TechnicData.h
index cd2ea8e1..fc7fa4d3 100644
--- a/launcher/ui/pages/modplatform/technic/TechnicData.h
+++ b/launcher/ui/pages/modplatform/technic/TechnicData.h
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2021-2022 Jamie Mansfield <jmansfield@cadixdev.org>
*
* This program is free software: you can redistribute it and/or modify
@@ -63,6 +63,6 @@ struct Modpack {
QString recommended;
QVector<QString> versions;
};
-}
+} // namespace Technic
Q_DECLARE_METATYPE(Technic::Modpack)
diff --git a/launcher/ui/pages/modplatform/technic/TechnicModel.cpp b/launcher/ui/pages/modplatform/technic/TechnicModel.cpp
index f08eb289..02d7fd5b 100644
--- a/launcher/ui/pages/modplatform/technic/TechnicModel.cpp
+++ b/launcher/ui/pages/modplatform/technic/TechnicModel.cpp
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2021 Jamie Mansfield <jmansfield@cadixdev.org>
*
* This program is free software: you can redistribute it and/or modify
diff --git a/launcher/ui/pages/modplatform/technic/TechnicModel.h b/launcher/ui/pages/modplatform/technic/TechnicModel.h
index 0f1a814e..d7a635d4 100644
--- a/launcher/ui/pages/modplatform/technic/TechnicModel.h
+++ b/launcher/ui/pages/modplatform/technic/TechnicModel.h
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2021 Jamie Mansfield <jmansfield@cadixdev.org>
*
* This program is free software: you can redistribute it and/or modify
diff --git a/launcher/ui/pages/modplatform/technic/TechnicPage.cpp b/launcher/ui/pages/modplatform/technic/TechnicPage.cpp
index fc678fa2..88132754 100644
--- a/launcher/ui/pages/modplatform/technic/TechnicPage.cpp
+++ b/launcher/ui/pages/modplatform/technic/TechnicPage.cpp
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2021-2022 Jamie Mansfield <jmansfield@cadixdev.org>
*
* This program is free software: you can redistribute it and/or modify
@@ -41,16 +41,15 @@
#include "ui/dialogs/NewInstanceDialog.h"
#include "BuildConfig.h"
+#include "Json.h"
#include "TechnicModel.h"
#include "modplatform/technic/SingleZipPackInstallTask.h"
#include "modplatform/technic/SolderPackInstallTask.h"
-#include "Json.h"
#include "Application.h"
#include "modplatform/technic/SolderPackManifest.h"
-TechnicPage::TechnicPage(NewInstanceDialog* dialog, QWidget *parent)
- : QWidget(parent), ui(new Ui::TechnicPage), dialog(dialog)
+TechnicPage::TechnicPage(NewInstanceDialog* dialog, QWidget* parent) : QWidget(parent), ui(new Ui::TechnicPage), dialog(dialog)
{
ui->setupUi(this);
connect(ui->searchButton, &QPushButton::clicked, this, &TechnicPage::triggerSearch);
@@ -96,7 +95,8 @@ void TechnicPage::openedImpl()
triggerSearch();
}
-void TechnicPage::triggerSearch() {
+void TechnicPage::triggerSearch()
+{
model->searchWithTerm(ui->searchEdit->text());
}
@@ -104,10 +104,8 @@ void TechnicPage::onSelectionChanged(QModelIndex first, QModelIndex second)
{
ui->versionSelectionBox->clear();
- if(!first.isValid())
- {
- if(isOpened)
- {
+ if (!first.isValid()) {
+ if (isOpened) {
dialog->setSuggestedPack();
}
return;
@@ -119,74 +117,60 @@ void TechnicPage::onSelectionChanged(QModelIndex first, QModelIndex second)
void TechnicPage::suggestCurrent()
{
- if (!isOpened)
- {
+ if (!isOpened) {
return;
}
- if (current.broken)
- {
+ if (current.broken) {
dialog->setSuggestedPack();
return;
}
QString editedLogoName = "technic_" + current.logoName.section(".", 0, 0);
- model->getLogo(current.logoName, current.logoUrl, [this, editedLogoName](QString logo)
- {
- dialog->setSuggestedIconFromFile(logo, editedLogoName);
- });
+ model->getLogo(current.logoName, current.logoUrl,
+ [this, editedLogoName](QString logo) { dialog->setSuggestedIconFromFile(logo, editedLogoName); });
- if (current.metadataLoaded)
- {
+ if (current.metadataLoaded) {
metadataLoaded();
return;
}
auto netJob = makeShared<NetJob>(QString("Technic::PackMeta(%1)").arg(current.name), APPLICATION->network());
QString slug = current.slug;
- netJob->addNetAction(Net::Download::makeByteArray(QString("%1modpack/%2?build=%3").arg(BuildConfig.TECHNIC_API_BASE_URL, slug, BuildConfig.TECHNIC_API_BUILD), response));
- QObject::connect(netJob.get(), &NetJob::succeeded, this, [this, slug]
- {
+ netJob->addNetAction(Net::Download::makeByteArray(
+ QString("%1modpack/%2?build=%3").arg(BuildConfig.TECHNIC_API_BASE_URL, slug, BuildConfig.TECHNIC_API_BUILD), response));
+ QObject::connect(netJob.get(), &NetJob::succeeded, this, [this, slug] {
jobPtr.reset();
- if (current.slug != slug)
- {
+ if (current.slug != slug) {
return;
}
- QJsonParseError parse_error {};
+ QJsonParseError parse_error{};
QJsonDocument doc = QJsonDocument::fromJson(*response, &parse_error);
QJsonObject obj = doc.object();
- if(parse_error.error != QJsonParseError::NoError)
- {
- qWarning() << "Error while parsing JSON response from Technic at " << parse_error.offset << " reason: " << parse_error.errorString();
+ if (parse_error.error != QJsonParseError::NoError) {
+ qWarning() << "Error while parsing JSON response from Technic at " << parse_error.offset
+ << " reason: " << parse_error.errorString();
qWarning() << *response;
return;
}
- if (!obj.contains("url"))
- {
+ if (!obj.contains("url")) {
qWarning() << "Json doesn't contain an url key";
return;
}
QJsonValueRef url = obj["url"];
- if (url.isString())
- {
+ if (url.isString()) {
current.url = url.toString();
- }
- else
- {
- if (!obj.contains("solder"))
- {
+ } else {
+ if (!obj.contains("solder")) {
qWarning() << "Json doesn't contain a valid url or solder key";
return;
}
QJsonValueRef solderUrl = obj["solder"];
- if (solderUrl.isString())
- {
+ if (solderUrl.isString()) {
current.url = solderUrl.toString();
current.isSolder = true;
- }
- else
- {
+ } else {
qWarning() << "Json doesn't contain a valid url or solder key";
return;
}
@@ -227,22 +211,21 @@ void TechnicPage::metadataLoaded()
// Strip trailing forward-slashes from Solder URL's
if (current.isSolder) {
- while (current.url.endsWith('/')) current.url.chop(1);
+ while (current.url.endsWith('/'))
+ current.url.chop(1);
}
// Display versions from Solder
if (!current.isSolder) {
// If the pack isn't a Solder pack, it only has the single version
ui->versionSelectionBox->addItem(current.currentVersion);
- }
- else if (current.versionsLoaded) {
+ } else if (current.versionsLoaded) {
// reverse foreach, so that the newest versions are first
for (auto i = current.versions.size(); i--;) {
ui->versionSelectionBox->addItem(current.versions.at(i));
}
ui->versionSelectionBox->setCurrentText(current.recommended);
- }
- else {
+ } else {
// For now, until the versions are pulled from the Solder instance, display the current
// version so we can display something quicker
ui->versionSelectionBox->addItem(current.currentVersion);
@@ -260,7 +243,8 @@ void TechnicPage::metadataLoaded()
selectVersion();
}
-void TechnicPage::selectVersion() {
+void TechnicPage::selectVersion()
+{
if (!isOpened) {
return;
}
@@ -269,17 +253,18 @@ void TechnicPage::selectVersion() {
return;
}
- if (!current.isSolder)
- {
- dialog->setSuggestedPack(current.name, selectedVersion, new Technic::SingleZipPackInstallTask(current.url, current.minecraftVersion));
- }
- else
- {
- dialog->setSuggestedPack(current.name, selectedVersion, new Technic::SolderPackInstallTask(APPLICATION->network(), current.url, current.slug, selectedVersion, current.minecraftVersion));
+ if (!current.isSolder) {
+ dialog->setSuggestedPack(current.name, selectedVersion,
+ new Technic::SingleZipPackInstallTask(current.url, current.minecraftVersion));
+ } else {
+ dialog->setSuggestedPack(current.name, selectedVersion,
+ new Technic::SolderPackInstallTask(APPLICATION->network(), current.url, current.slug, selectedVersion,
+ current.minecraftVersion));
}
}
-void TechnicPage::onSolderLoaded() {
+void TechnicPage::onSolderLoaded()
+{
jobPtr.reset();
auto fallback = [this]() {
@@ -319,7 +304,8 @@ void TechnicPage::onSolderLoaded() {
metadataLoaded();
}
-void TechnicPage::onVersionSelectionChanged(QString data) {
+void TechnicPage::onVersionSelectionChanged(QString data)
+{
if (data.isNull() || data.isEmpty()) {
selectedVersion = "";
return;
diff --git a/launcher/ui/pages/modplatform/technic/TechnicPage.h b/launcher/ui/pages/modplatform/technic/TechnicPage.h
index 753261b3..91b61eaf 100644
--- a/launcher/ui/pages/modplatform/technic/TechnicPage.h
+++ b/launcher/ui/pages/modplatform/technic/TechnicPage.h
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
- * PolyMC - Minecraft Launcher
+ * Prism Launcher - Minecraft Launcher
* Copyright (c) 2021-2022 Jamie Mansfield <jmansfield@cadixdev.org>
*
* This program is free software: you can redistribute it and/or modify
@@ -37,46 +37,32 @@
#include <QWidget>
-#include "ui/pages/BasePage.h"
#include <Application.h>
+#include "TechnicData.h"
#include "net/NetJob.h"
#include "tasks/Task.h"
-#include "TechnicData.h"
+#include "ui/pages/BasePage.h"
-namespace Ui
-{
+namespace Ui {
class TechnicPage;
}
class NewInstanceDialog;
namespace Technic {
- class ListModel;
+class ListModel;
}
-class TechnicPage : public QWidget, public BasePage
-{
+class TechnicPage : public QWidget, public BasePage {
Q_OBJECT
-public:
- explicit TechnicPage(NewInstanceDialog* dialog, QWidget *parent = 0);
+ public:
+ explicit TechnicPage(NewInstanceDialog* dialog, QWidget* parent = 0);
virtual ~TechnicPage();
- virtual QString displayName() const override
- {
- return "Technic";
- }
- virtual QIcon icon() const override
- {
- return APPLICATION->getThemedIcon("technic");
- }
- virtual QString id() const override
- {
- return "technic";
- }
- virtual QString helpPage() const override
- {
- return "Technic-platform";
- }
+ virtual QString displayName() const override { return "Technic"; }
+ virtual QIcon icon() const override { return APPLICATION->getThemedIcon("technic"); }
+ virtual QString id() const override { return "technic"; }
+ virtual QString helpPage() const override { return "Technic-platform"; }
virtual bool shouldDisplay() const override;
void retranslate() override;
@@ -84,19 +70,19 @@ public:
bool eventFilter(QObject* watched, QEvent* event) override;
-private:
+ private:
void suggestCurrent();
void metadataLoaded();
void selectVersion();
-private slots:
+ private slots:
void triggerSearch();
void onSelectionChanged(QModelIndex first, QModelIndex second);
void onSolderLoaded();
void onVersionSelectionChanged(QString data);
-private:
- Ui::TechnicPage *ui = nullptr;
+ private:
+ Ui::TechnicPage* ui = nullptr;
NewInstanceDialog* dialog = nullptr;
Technic::ListModel* model = nullptr;