aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/pages/modplatform/modrinth
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/ui/pages/modplatform/modrinth')
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp28
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthModel.h9
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthResourcePages.cpp30
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthResourcePages.h30
4 files changed, 64 insertions, 33 deletions
diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp b/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp
index e0046d88..9c392fca 100644
--- a/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp
+++ b/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp
@@ -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..47c2d55b 100644
--- a/launcher/ui/pages/modplatform/modrinth/ModrinthModel.h
+++ b/launcher/ui/pages/modplatform/modrinth/ModrinthModel.h
@@ -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/ModrinthResourcePages.cpp b/launcher/ui/pages/modplatform/modrinth/ModrinthResourcePages.cpp
index dd143700..ff809c7b 100644
--- a/launcher/ui/pages/modplatform/modrinth/ModrinthResourcePages.cpp
+++ b/launcher/ui/pages/modplatform/modrinth/ModrinthResourcePages.cpp
@@ -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..26037f0c 100644
--- a/launcher/ui/pages/modplatform/modrinth/ModrinthResourcePages.h
+++ b/launcher/ui/pages/modplatform/modrinth/ModrinthResourcePages.h
@@ -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 {