diff --git a/launcher/minecraft/mod/DataPack.cpp b/launcher/minecraft/mod/DataPack.cpp index c2b477d45..e9dee5f77 100644 --- a/launcher/minecraft/mod/DataPack.cpp +++ b/launcher/minecraft/mod/DataPack.cpp @@ -279,7 +279,7 @@ QString DataPack::packFormatStr() const auto min_version = min_bound.first; auto max_version = max_bound.second; if (min_version.isEmpty() || max_version.isEmpty()) { - return tr("Unrecognized"); + return QObject::tr("Unrecognized"); } auto str = QString("[") + QString::number(m_min_format.first); if (m_min_format.second != 0) { diff --git a/launcher/minecraft/mod/DataPack.h b/launcher/minecraft/mod/DataPack.h index 89da0178a..fd4184fd0 100644 --- a/launcher/minecraft/mod/DataPack.h +++ b/launcher/minecraft/mod/DataPack.h @@ -35,9 +35,7 @@ class Version; * */ class DataPack : public Resource { - Q_OBJECT public: - DataPack(QObject* parent = nullptr) : Resource(parent) {} DataPack(QFileInfo file_info) : Resource(file_info) {} /** Gets the numerical ID of the pack format. */ diff --git a/launcher/minecraft/mod/Mod.h b/launcher/minecraft/mod/Mod.h index 0d24409bf..84b1726db 100644 --- a/launcher/minecraft/mod/Mod.h +++ b/launcher/minecraft/mod/Mod.h @@ -48,12 +48,7 @@ #include "Resource.h" class Mod : public Resource { - Q_OBJECT public: - using Ptr = shared_qobject_ptr; - using WeakPtr = QPointer; - - Mod() = default; Mod(const QFileInfo& file); Mod(QString file_path) : Mod(QFileInfo(file_path)) {} diff --git a/launcher/minecraft/mod/Resource.cpp b/launcher/minecraft/mod/Resource.cpp index 06d9a0af7..aa5543cb0 100644 --- a/launcher/minecraft/mod/Resource.cpp +++ b/launcher/minecraft/mod/Resource.cpp @@ -1,7 +1,9 @@ #include "Resource.h" +#include #include #include +#include #include #include #include @@ -11,9 +13,7 @@ #include "minecraft/MinecraftInstance.h" #include "minecraft/PackProfile.h" -Resource::Resource(QObject* parent) : QObject(parent), m_size_info(0) {} - -Resource::Resource(QFileInfo fileInfo) : m_size_info(0) +Resource::Resource(QFileInfo file_info) { setFile(fileInfo); } @@ -102,7 +102,7 @@ auto Resource::provider() const -> QString return ModPlatform::ProviderCapabilities::readableName(metadata()->provider); } - return tr("Unknown"); + return QObject::tr("Unknown"); } auto Resource::homepage() const -> QString @@ -129,7 +129,7 @@ QStringList Resource::issues() const result.reserve(m_issues.length()); for (const char* issue : m_issues) { - result.append(tr(issue)); + result.append(QObject::tr(issue)); } return result; diff --git a/launcher/minecraft/mod/Resource.h b/launcher/minecraft/mod/Resource.h index 694d74ec0..d1a70b757 100644 --- a/launcher/minecraft/mod/Resource.h +++ b/launcher/minecraft/mod/Resource.h @@ -39,9 +39,9 @@ #include #include #include +#include #include "MetadataHandler.h" -#include "QObjectPtr.h" class BaseInstance; @@ -88,17 +88,17 @@ enum class EnableAction : std::uint8_t { ENABLE, DISABLE, TOGGLE }; * * Subclass it to add additional data / behavior, such as Mods or Resource packs. */ -class Resource : public QObject { - Q_OBJECT - Q_DISABLE_COPY(Resource) +class Resource { + Resource(const Resource&) = delete; + Resource& operator=(const Resource&) = delete; + public: - using Ptr = shared_qobject_ptr; + using Ptr = std::shared_ptr; - Resource(QObject* parent = nullptr); - Resource(QFileInfo fileInfo); - Resource(const QString& filePath) : Resource(QFileInfo(filePath)) {} + Resource(QFileInfo file_info); + Resource(QString file_path) : Resource(QFileInfo(file_path)) {} - ~Resource() override = default; + virtual ~Resource() = default; void setFile(QFileInfo fileInfo); void parseFile(); diff --git a/launcher/minecraft/mod/ResourceFolderModel.cpp b/launcher/minecraft/mod/ResourceFolderModel.cpp index ddc132089..2e85cb76d 100644 --- a/launcher/minecraft/mod/ResourceFolderModel.cpp +++ b/launcher/minecraft/mod/ResourceFolderModel.cpp @@ -890,7 +890,7 @@ void ResourceFolderModel::applyUpdates(QSet& currentSet, QSet& } } - m_resources[row].reset(newResource); + m_resources[row].swap(newResource); newResource->updateIssues(m_instance); resolveResource(m_resources.at(row)); diff --git a/launcher/minecraft/mod/ResourcePack.h b/launcher/minecraft/mod/ResourcePack.h index 43aa5e1da..f1cf60a30 100644 --- a/launcher/minecraft/mod/ResourcePack.h +++ b/launcher/minecraft/mod/ResourcePack.h @@ -1,6 +1,5 @@ #pragma once -#include "Resource.h" #include "minecraft/mod/DataPack.h" #include @@ -16,9 +15,7 @@ class Version; * */ class ResourcePack : public DataPack { - Q_OBJECT public: - ResourcePack(QObject* parent = nullptr) : DataPack(parent) {} ResourcePack(QFileInfo file_info) : DataPack(file_info) {} /** Gets, respectively, the lower and upper versions supported by the set pack format. */ diff --git a/launcher/minecraft/mod/ShaderPack.h b/launcher/minecraft/mod/ShaderPack.h index 9275ebed8..aa57060d1 100644 --- a/launcher/minecraft/mod/ShaderPack.h +++ b/launcher/minecraft/mod/ShaderPack.h @@ -41,13 +41,9 @@ enum class ShaderPackFormat { VALID, INVALID }; class ShaderPack : public Resource { - Q_OBJECT public: - using Ptr = shared_qobject_ptr; - ShaderPackFormat packFormat() const { return m_pack_format; } - ShaderPack(QObject* parent = nullptr) : Resource(parent) {} ShaderPack(QFileInfo file_info) : Resource(file_info) {} /** Thread-safe. */ diff --git a/launcher/minecraft/mod/TexturePack.h b/launcher/minecraft/mod/TexturePack.h index 1327e2f61..d3e1c27ef 100644 --- a/launcher/minecraft/mod/TexturePack.h +++ b/launcher/minecraft/mod/TexturePack.h @@ -29,11 +29,7 @@ class Version; class TexturePack : public Resource { - Q_OBJECT public: - using Ptr = shared_qobject_ptr; - - TexturePack(QObject* parent = nullptr) : Resource(parent) {} TexturePack(QFileInfo file_info) : Resource(file_info) {} /** Gets the description of the texture pack. */ diff --git a/launcher/minecraft/mod/WorldSave.h b/launcher/minecraft/mod/WorldSave.h index 702a3edf6..b8ace49d1 100644 --- a/launcher/minecraft/mod/WorldSave.h +++ b/launcher/minecraft/mod/WorldSave.h @@ -30,11 +30,7 @@ class Version; enum class WorldSaveFormat { SINGLE, MULTI, INVALID }; class WorldSave : public Resource { - Q_OBJECT public: - using Ptr = shared_qobject_ptr; - - WorldSave(QObject* parent = nullptr) : Resource(parent) {} WorldSave(QFileInfo file_info) : Resource(file_info) {} /** Gets the format of the save. */ diff --git a/launcher/minecraft/mod/tasks/ResourceFolderLoadTask.cpp b/launcher/minecraft/mod/tasks/ResourceFolderLoadTask.cpp index a90e9ca5e..b8000f4ac 100644 --- a/launcher/minecraft/mod/tasks/ResourceFolderLoadTask.cpp +++ b/launcher/minecraft/mod/tasks/ResourceFolderLoadTask.cpp @@ -125,10 +125,6 @@ void ResourceFolderLoadTask::executeTask() } } - for (const auto& mod : m_result->resources) { - mod->moveToThread(m_thread_to_spawn_into); - } - if (m_aborted) { emit finished(); } else { diff --git a/launcher/modplatform/modrinth/ModrinthAPI.h b/launcher/modplatform/modrinth/ModrinthAPI.h index 5f81384c2..0d25758fc 100644 --- a/launcher/modplatform/modrinth/ModrinthAPI.h +++ b/launcher/modplatform/modrinth/ModrinthAPI.h @@ -31,7 +31,7 @@ class ModrinthAPI : public ResourceAPI { std::pair getProjects(QStringList addonIds) const override; std::pair getModCategories() override; - static QList loadCategories(const QByteArray& response, QString projectType); + static QList loadCategories(const QByteArray& response, const QString& projectType); QList loadModCategories(const QByteArray& response) override; public: