mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-07-02 19:36:57 +03:00
Resource should not be QObject
because it has no signals Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
f00903d6e3
commit
2b0b9824a3
12 changed files with 17 additions and 43 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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. */
|
||||
|
|
|
|||
|
|
@ -48,12 +48,7 @@
|
|||
#include "Resource.h"
|
||||
|
||||
class Mod : public Resource {
|
||||
Q_OBJECT
|
||||
public:
|
||||
using Ptr = shared_qobject_ptr<Mod>;
|
||||
using WeakPtr = QPointer<Mod>;
|
||||
|
||||
Mod() = default;
|
||||
Mod(const QFileInfo& file);
|
||||
Mod(QString file_path) : Mod(QFileInfo(file_path)) {}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
#include "Resource.h"
|
||||
#include <qobject.h>
|
||||
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
#include <QObject>
|
||||
#include <QRegularExpression>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -39,9 +39,9 @@
|
|||
#include <QFileInfo>
|
||||
#include <QObject>
|
||||
#include <QPointer>
|
||||
#include <memory>
|
||||
|
||||
#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<Resource>;
|
||||
using Ptr = std::shared_ptr<Resource>;
|
||||
|
||||
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();
|
||||
|
|
|
|||
|
|
@ -890,7 +890,7 @@ void ResourceFolderModel::applyUpdates(QSet<QString>& currentSet, QSet<QString>&
|
|||
}
|
||||
}
|
||||
|
||||
m_resources[row].reset(newResource);
|
||||
m_resources[row].swap(newResource);
|
||||
newResource->updateIssues(m_instance);
|
||||
|
||||
resolveResource(m_resources.at(row));
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include "Resource.h"
|
||||
#include "minecraft/mod/DataPack.h"
|
||||
|
||||
#include <QImage>
|
||||
|
|
@ -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. */
|
||||
|
|
|
|||
|
|
@ -41,13 +41,9 @@
|
|||
enum class ShaderPackFormat { VALID, INVALID };
|
||||
|
||||
class ShaderPack : public Resource {
|
||||
Q_OBJECT
|
||||
public:
|
||||
using Ptr = shared_qobject_ptr<Resource>;
|
||||
|
||||
ShaderPackFormat packFormat() const { return m_pack_format; }
|
||||
|
||||
ShaderPack(QObject* parent = nullptr) : Resource(parent) {}
|
||||
ShaderPack(QFileInfo file_info) : Resource(file_info) {}
|
||||
|
||||
/** Thread-safe. */
|
||||
|
|
|
|||
|
|
@ -29,11 +29,7 @@
|
|||
class Version;
|
||||
|
||||
class TexturePack : public Resource {
|
||||
Q_OBJECT
|
||||
public:
|
||||
using Ptr = shared_qobject_ptr<Resource>;
|
||||
|
||||
TexturePack(QObject* parent = nullptr) : Resource(parent) {}
|
||||
TexturePack(QFileInfo file_info) : Resource(file_info) {}
|
||||
|
||||
/** Gets the description of the texture pack. */
|
||||
|
|
|
|||
|
|
@ -30,11 +30,7 @@ class Version;
|
|||
enum class WorldSaveFormat { SINGLE, MULTI, INVALID };
|
||||
|
||||
class WorldSave : public Resource {
|
||||
Q_OBJECT
|
||||
public:
|
||||
using Ptr = shared_qobject_ptr<Resource>;
|
||||
|
||||
WorldSave(QObject* parent = nullptr) : Resource(parent) {}
|
||||
WorldSave(QFileInfo file_info) : Resource(file_info) {}
|
||||
|
||||
/** Gets the format of the save. */
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class ModrinthAPI : public ResourceAPI {
|
|||
std::pair<Task::Ptr, QByteArray*> getProjects(QStringList addonIds) const override;
|
||||
|
||||
std::pair<Task::Ptr, QByteArray*> getModCategories() override;
|
||||
static QList<ModPlatform::Category> loadCategories(const QByteArray& response, QString projectType);
|
||||
static QList<ModPlatform::Category> loadCategories(const QByteArray& response, const QString& projectType);
|
||||
QList<ModPlatform::Category> loadModCategories(const QByteArray& response) override;
|
||||
|
||||
public:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue