Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into resource_size

This commit is contained in:
Trial97 2023-11-23 17:14:50 +02:00
commit b47ec7f2dc
No known key found for this signature in database
GPG Key ID: 55EF5DA53DB36318
48 changed files with 113 additions and 75 deletions

View File

@ -1,4 +1,5 @@
Checks: Checks:
- modernize-use-using - modernize-use-using
- readability-avoid-const-params-in-decls
SystemHeaders: false SystemHeaders: false

View File

@ -68,6 +68,8 @@ function(
/w14906 # string literal cast to 'LPWSTR' /w14906 # string literal cast to 'LPWSTR'
/w14928 # illegal copy-initialization; more than one user-defined conversion has been implicitly applied /w14928 # illegal copy-initialization; more than one user-defined conversion has been implicitly applied
/permissive- # standards conformance mode for MSVC compiler. /permissive- # standards conformance mode for MSVC compiler.
/we4062 # forbid omitting a possible value of an enum in a switch statement
) )
endif() endif()
@ -93,6 +95,8 @@ function(
# in a lot of noise. This warning is only notifying us that clang is emulating the GCC behaviour # in a lot of noise. This warning is only notifying us that clang is emulating the GCC behaviour
# instead of the exact standard wording so we can safely ignore it # instead of the exact standard wording so we can safely ignore it
-Wno-gnu-zero-variadic-macro-arguments -Wno-gnu-zero-variadic-macro-arguments
-Werror=switch # forbid omitting a possible value of an enum in a switch statement
) )
endif() endif()
@ -104,6 +108,8 @@ function(
-Wduplicated-branches # warn if if / else branches have duplicated code -Wduplicated-branches # warn if if / else branches have duplicated code
-Wlogical-op # warn about logical operations being used where bitwise were probably wanted -Wlogical-op # warn about logical operations being used where bitwise were probably wanted
-Wuseless-cast # warn if you perform a cast to the same type -Wuseless-cast # warn if you perform a cast to the same type
-Werror=switch # forbid omitting a possible value of an enum in a switch statement
) )
endif() endif()
@ -128,6 +134,8 @@ function(
-Woverloaded-virtual -Woverloaded-virtual
-Wuseless-cast -Wuseless-cast
-Wextra-semi -Wextra-semi
-Werror=switch # forbid omitting a possible value of an enum in a switch statement
) )
target_compile_options( target_compile_options(

View File

@ -18,7 +18,7 @@
class DataMigrationTask : public Task { class DataMigrationTask : public Task {
Q_OBJECT Q_OBJECT
public: public:
explicit DataMigrationTask(QObject* parent, const QString& sourcePath, const QString& targetPath, const IPathMatcher::Ptr pathmatcher); explicit DataMigrationTask(QObject* parent, const QString& sourcePath, const QString& targetPath, IPathMatcher::Ptr pathmatcher);
~DataMigrationTask() override = default; ~DataMigrationTask() override = default;
protected: protected:

View File

@ -59,7 +59,7 @@
#include <quazip/quazipdir.h> #include <quazip/quazipdir.h>
InstanceImportTask::InstanceImportTask(const QUrl sourceUrl, QWidget* parent, QMap<QString, QString>&& extra_info) InstanceImportTask::InstanceImportTask(const QUrl& sourceUrl, QWidget* parent, QMap<QString, QString>&& extra_info)
: m_sourceUrl(sourceUrl), m_extra_info(extra_info), m_parent(parent) : m_sourceUrl(sourceUrl), m_extra_info(extra_info), m_parent(parent)
{} {}

View File

@ -54,7 +54,7 @@ class FileResolvingTask;
class InstanceImportTask : public InstanceTask { class InstanceImportTask : public InstanceTask {
Q_OBJECT Q_OBJECT
public: public:
explicit InstanceImportTask(const QUrl sourceUrl, QWidget* parent = nullptr, QMap<QString, QString>&& extra_info = {}); explicit InstanceImportTask(const QUrl& sourceUrl, QWidget* parent = nullptr, QMap<QString, QString>&& extra_info = {});
bool abort() override; bool abort() override;
const QVector<Flame::File>& getBlockedFiles() const { return m_blockedMods; } const QVector<Flame::File>& getBlockedFiles() const { return m_blockedMods; }

View File

@ -823,6 +823,9 @@ void InstanceList::on_InstFolderChanged([[maybe_unused]] const Setting& setting,
} }
m_instDir = newInstDir; m_instDir = newInstDir;
m_groupsLoaded = false; m_groupsLoaded = false;
beginRemoveRows(QModelIndex(), 0, count());
m_instances.erase(m_instances.begin(), m_instances.end());
endRemoveRows();
emit instancesChanged(); emit instancesChanged();
} }
} }

View File

@ -36,6 +36,7 @@
#include "LaunchController.h" #include "LaunchController.h"
#include "Application.h" #include "Application.h"
#include "minecraft/auth/AccountData.h"
#include "minecraft/auth/AccountList.h" #include "minecraft/auth/AccountList.h"
#include "ui/InstanceWindow.h" #include "ui/InstanceWindow.h"
@ -161,7 +162,7 @@ void LaunchController::login()
m_accountToUse->fillSession(m_session); m_accountToUse->fillSession(m_session);
// Launch immediately in true offline mode // Launch immediately in true offline mode
if (m_accountToUse->isOffline()) { if (m_accountToUse->accountType() == AccountType::Offline) {
launchInstance(); launchInstance();
return; return;
} }

View File

@ -50,7 +50,7 @@
namespace MMCZip { namespace MMCZip {
// ours // ours
bool mergeZipFiles(QuaZip* into, QFileInfo from, QSet<QString>& contained, const FilterFunction filter) bool mergeZipFiles(QuaZip* into, QFileInfo from, QSet<QString>& contained, const FilterFunction& filter)
{ {
QuaZip modZip(from.filePath()); QuaZip modZip(from.filePath());
modZip.open(QuaZip::mdUnzip); modZip.open(QuaZip::mdUnzip);

View File

@ -60,7 +60,7 @@ using FilterFunction = std::function<bool(const QString&)>;
/** /**
* Merge two zip files, using a filter function * Merge two zip files, using a filter function
*/ */
bool mergeZipFiles(QuaZip* into, QFileInfo from, QSet<QString>& contained, const FilterFunction filter = nullptr); bool mergeZipFiles(QuaZip* into, QFileInfo from, QSet<QString>& contained, const FilterFunction& filter = nullptr);
/** /**
* Compress directory, by providing a list of files to compress * Compress directory, by providing a list of files to compress

View File

@ -13,7 +13,7 @@ class RecursiveFileSystemWatcher : public QObject {
QDir rootDir() const { return m_root; } QDir rootDir() const { return m_root; }
// WARNING: setting this to true may be bad for performance // WARNING: setting this to true may be bad for performance
void setWatchFiles(const bool watchFiles); void setWatchFiles(bool watchFiles);
bool watchFiles() const { return m_watchFiles; } bool watchFiles() const { return m_watchFiles; }
void setMatcher(IPathMatcher::Ptr matcher) { m_matcher = matcher; } void setMatcher(IPathMatcher::Ptr matcher) { m_matcher = matcher; }

View File

@ -32,7 +32,7 @@ class ResourceDownloadTask : public SequentialTask {
public: public:
explicit ResourceDownloadTask(ModPlatform::IndexedPack::Ptr pack, explicit ResourceDownloadTask(ModPlatform::IndexedPack::Ptr pack,
ModPlatform::IndexedVersion version, ModPlatform::IndexedVersion version,
const std::shared_ptr<ResourceFolderModel> packs, std::shared_ptr<ResourceFolderModel> packs,
bool is_indexed = true, bool is_indexed = true,
QString custom_target_folder = {}); QString custom_target_folder = {});
const QString& getFilename() const { return m_pack_version.fileName; } const QString& getFilename() const { return m_pack_version.fileName; }

View File

@ -28,7 +28,7 @@ class VersionProxyModel : public QAbstractProxyModel {
const FilterMap& filters() const; const FilterMap& filters() const;
const QString& search() const; const QString& search() const;
void setFilter(const BaseVersionList::ModelRoles column, Filter* filter); void setFilter(BaseVersionList::ModelRoles column, Filter* filter);
void setSearch(const QString& search); void setSearch(const QString& search);
void clearFilters(); void clearFilters();
QModelIndex getRecommended() const; QModelIndex getRecommended() const;

View File

@ -67,7 +67,7 @@ class IconList : public QAbstractListModel {
virtual Qt::ItemFlags flags(const QModelIndex& index) const override; virtual Qt::ItemFlags flags(const QModelIndex& index) const override;
bool addThemeIcon(const QString& key); bool addThemeIcon(const QString& key);
bool addIcon(const QString& key, const QString& name, const QString& path, const IconType type); bool addIcon(const QString& key, const QString& name, const QString& path, IconType type);
void saveIcon(const QString& key, const QString& path, const char* format) const; void saveIcon(const QString& key, const QString& path, const char* format) const;
bool deleteIcon(const QString& key); bool deleteIcon(const QString& key);
bool trashIcon(const QString& key); bool trashIcon(const QString& key);

View File

@ -55,6 +55,6 @@ class Index : public QAbstractListModel, public BaseEntity {
QVector<VersionList::Ptr> m_lists; QVector<VersionList::Ptr> m_lists;
QHash<QString, VersionList::Ptr> m_uids; QHash<QString, VersionList::Ptr> m_uids;
void connectVersionList(const int row, const VersionList::Ptr& list); void connectVersionList(int row, const VersionList::Ptr& list);
}; };
} // namespace Meta } // namespace Meta

View File

@ -64,7 +64,7 @@ class Version : public QObject, public BaseVersion, public BaseEntity {
public: // for usage by format parsers only public: // for usage by format parsers only
void setType(const QString& type); void setType(const QString& type);
void setTime(const qint64 time); void setTime(qint64 time);
void setRequires(const Meta::RequireSet& reqs, const Meta::RequireSet& conflicts); void setRequires(const Meta::RequireSet& reqs, const Meta::RequireSet& conflicts);
void setVolatile(bool volatile_); void setVolatile(bool volatile_);
void setRecommended(bool recommended); void setRecommended(bool recommended);

View File

@ -79,7 +79,7 @@ class VersionList : public BaseVersionList, public BaseEntity {
Version::Ptr m_recommended; Version::Ptr m_recommended;
void setupAddedVersion(const int row, const Version::Ptr& version); void setupAddedVersion(int row, const Version::Ptr& version);
}; };
} // namespace Meta } // namespace Meta
Q_DECLARE_METATYPE(Meta::VersionList::Ptr) Q_DECLARE_METATYPE(Meta::VersionList::Ptr)

View File

@ -601,11 +601,17 @@ QProcessEnvironment MinecraftInstance::createLaunchEnvironment()
auto mangoHudLibString = MangoHud::getLibraryString(); auto mangoHudLibString = MangoHud::getLibraryString();
if (!mangoHudLibString.isEmpty()) { if (!mangoHudLibString.isEmpty()) {
QFileInfo mangoHudLib(mangoHudLibString); QFileInfo mangoHudLib(mangoHudLibString);
QString libPath = mangoHudLib.absolutePath();
auto appendLib = [libPath, &preloadList](QString fileName) {
if (QFileInfo(FS::PathCombine(libPath, fileName)).exists())
preloadList << fileName;
};
// dlsym variant is only needed for OpenGL and not included in the vulkan layer // dlsym variant is only needed for OpenGL and not included in the vulkan layer
preloadList << "libMangoHud_dlsym.so" appendLib("libMangoHud_dlsym.so");
<< "libMangoHud_opengl.so" << mangoHudLib.fileName(); appendLib("libMangoHud_opengl.so");
libPaths << mangoHudLib.absolutePath(); appendLib(mangoHudLib.fileName());
libPaths << libPath;
} }
env.insert("LD_PRELOAD", preloadList.join(QLatin1String(":"))); env.insert("LD_PRELOAD", preloadList.join(QLatin1String(":")));

View File

@ -9,7 +9,7 @@
class OneSixVersionFormat { class OneSixVersionFormat {
public: public:
// version files / profile patches // version files / profile patches
static VersionFilePtr versionFileFromJson(const QJsonDocument& doc, const QString& filename, const bool requireOrder); static VersionFilePtr versionFileFromJson(const QJsonDocument& doc, const QString& filename, bool requireOrder);
static QJsonDocument versionFileToJson(const VersionFilePtr& patch); static QJsonDocument versionFileToJson(const VersionFilePtr& patch);
// libraries // libraries

View File

@ -430,7 +430,7 @@ bool PackProfile::remove(const int index)
return true; return true;
} }
bool PackProfile::remove(const QString id) bool PackProfile::remove(const QString& id)
{ {
int i = 0; int i = 0;
for (auto patch : d->components) { for (auto patch : d->components) {

View File

@ -89,13 +89,13 @@ class PackProfile : public QAbstractListModel {
enum MoveDirection { MoveUp, MoveDown }; enum MoveDirection { MoveUp, MoveDown };
/// move component file # up or down the list /// move component file # up or down the list
void move(const int index, const MoveDirection direction); void move(int index, MoveDirection direction);
/// remove component file # - including files/records /// remove component file # - including files/records
bool remove(const int index); bool remove(int index);
/// remove component file by id - including files/records /// remove component file by id - including files/records
bool remove(const QString id); bool remove(const QString& id);
bool customize(int index); bool customize(int index);

View File

@ -140,7 +140,7 @@ VersionFilePtr parseJsonFile(const QFileInfo& fileInfo, const bool requireOrder)
return guardedParseJson(doc, fileInfo.completeBaseName(), fileInfo.absoluteFilePath(), requireOrder); return guardedParseJson(doc, fileInfo.completeBaseName(), fileInfo.absoluteFilePath(), requireOrder);
} }
bool saveJsonFile(const QJsonDocument doc, const QString& filename) bool saveJsonFile(const QJsonDocument& doc, const QString& filename)
{ {
auto data = doc.toJson(); auto data = doc.toJson();
QSaveFile jsonFile(filename); QSaveFile jsonFile(filename);

View File

@ -47,10 +47,10 @@ bool readOverrideOrders(QString path, PatchOrder& order);
bool writeOverrideOrders(QString path, const PatchOrder& order); bool writeOverrideOrders(QString path, const PatchOrder& order);
/// Parse a version file in JSON format /// Parse a version file in JSON format
VersionFilePtr parseJsonFile(const QFileInfo& fileInfo, const bool requireOrder); VersionFilePtr parseJsonFile(const QFileInfo& fileInfo, bool requireOrder);
/// Save a JSON file (in any format) /// Save a JSON file (in any format)
bool saveJsonFile(const QJsonDocument doc, const QString& filename); bool saveJsonFile(const QJsonDocument& doc, const QString& filename);
/// Remove LWJGL from a patch file. This is applied to all Mojang-like profile files. /// Remove LWJGL from a patch file. This is applied to all Mojang-like profile files.
void removeLwjglFromPatch(VersionFilePtr patch); void removeLwjglFromPatch(VersionFilePtr patch);

View File

@ -283,9 +283,15 @@ QVariant AccountList::data(const QModelIndex& index, int role) const
return account->accountDisplayString(); return account->accountDisplayString();
case TypeColumn: { case TypeColumn: {
auto typeStr = account->typeString(); switch (account->accountType()) {
typeStr[0] = typeStr[0].toUpper(); case AccountType::MSA: {
return typeStr; return tr("MSA", "Account type");
}
case AccountType::Offline: {
return tr("Offline", "Account type");
}
}
return tr("Unknown", "Account type");
} }
case StatusColumn: { case StatusColumn: {

View File

@ -75,7 +75,7 @@ class AccountList : public QAbstractListModel {
virtual Qt::ItemFlags flags(const QModelIndex& index) const override; virtual Qt::ItemFlags flags(const QModelIndex& index) const override;
virtual bool setData(const QModelIndex& index, const QVariant& value, int role) override; virtual bool setData(const QModelIndex& index, const QVariant& value, int role) override;
void addAccount(const MinecraftAccountPtr account); void addAccount(MinecraftAccountPtr account);
void removeAccount(QModelIndex index); void removeAccount(QModelIndex index);
int findAccountByProfileId(const QString& profileId) const; int findAccountByProfileId(const QString& profileId) const;
MinecraftAccountPtr getAccountByProfileName(const QString& profileName) const; MinecraftAccountPtr getAccountByProfileName(const QString& profileName) const;

View File

@ -52,6 +52,7 @@
#include "flows/MSA.h" #include "flows/MSA.h"
#include "flows/Offline.h" #include "flows/Offline.h"
#include "minecraft/auth/AccountData.h"
MinecraftAccount::MinecraftAccount(QObject* parent) : QObject(parent) MinecraftAccount::MinecraftAccount(QObject* parent) : QObject(parent)
{ {
@ -185,7 +186,7 @@ void MinecraftAccount::authFailed(QString reason)
// NOTE: this doesn't do much. There was an error of some sort. // NOTE: this doesn't do much. There was an error of some sort.
} break; } break;
case AccountTaskState::STATE_FAILED_HARD: { case AccountTaskState::STATE_FAILED_HARD: {
if (isMSA()) { if (accountType() == AccountType::MSA) {
data.msaToken.token = QString(); data.msaToken.token = QString();
data.msaToken.refresh_token = QString(); data.msaToken.refresh_token = QString();
data.msaToken.validity = Katabasis::Validity::None; data.msaToken.validity = Katabasis::Validity::None;

View File

@ -118,9 +118,7 @@ class MinecraftAccount : public QObject, public Usable {
bool isActive() const; bool isActive() const;
bool isMSA() const { return data.type == AccountType::MSA; } [[nodiscard]] AccountType accountType() const noexcept { return data.type; }
bool isOffline() const { return data.type == AccountType::Offline; }
bool ownsMinecraft() const { return data.minecraftEntitlement.ownsMinecraft; } bool ownsMinecraft() const { return data.minecraftEntitlement.ownsMinecraft; }

View File

@ -47,7 +47,7 @@ ResourceFolderModel::~ResourceFolderModel()
QCoreApplication::processEvents(); QCoreApplication::processEvents();
} }
bool ResourceFolderModel::startWatching(const QStringList paths) bool ResourceFolderModel::startWatching(const QStringList& paths)
{ {
if (m_is_watching) if (m_is_watching)
return false; return false;
@ -66,7 +66,7 @@ bool ResourceFolderModel::startWatching(const QStringList paths)
return m_is_watching; return m_is_watching;
} }
bool ResourceFolderModel::stopWatching(const QStringList paths) bool ResourceFolderModel::stopWatching(const QStringList& paths)
{ {
if (!m_is_watching) if (!m_is_watching)
return false; return false;
@ -464,9 +464,9 @@ bool ResourceFolderModel::setData(const QModelIndex& index, [[maybe_unused]] con
if (role == Qt::CheckStateRole) { if (role == Qt::CheckStateRole) {
if (m_instance != nullptr && m_instance->isRunning()) { if (m_instance != nullptr && m_instance->isRunning()) {
auto response = auto response =
CustomMessageBox::selectable(nullptr, "Confirm toggle", CustomMessageBox::selectable(nullptr, tr("Confirm toggle"),
"If you enable/disable this resource while the game is running it may crash your game.\n" tr("If you enable/disable this resource while the game is running it may crash your game.\n"
"Are you sure you want to do this?", "Are you sure you want to do this?"),
QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
->exec(); ->exec();

View File

@ -39,14 +39,14 @@ class ResourceFolderModel : public QAbstractListModel {
* Returns whether starting to watch all the paths was successful. * Returns whether starting to watch all the paths was successful.
* If one or more fails, it returns false. * If one or more fails, it returns false.
*/ */
bool startWatching(const QStringList paths); bool startWatching(const QStringList& paths);
/** Stops watching the paths for changes. /** Stops watching the paths for changes.
* *
* Returns whether stopping to watch all the paths was successful. * Returns whether stopping to watch all the paths was successful.
* If one or more fails, it returns false. * If one or more fails, it returns false.
*/ */
bool stopWatching(const QStringList paths); bool stopWatching(const QStringList& paths);
/* Helper methods for subclasses, using a predetermined list of paths. */ /* Helper methods for subclasses, using a predetermined list of paths. */
virtual bool startWatching() { return startWatching({ m_dir.absolutePath() }); } virtual bool startWatching() { return startWatching({ m_dir.absolutePath() }); }

View File

@ -137,10 +137,11 @@ Task::Ptr GetModDependenciesTask::getProjectInfoTask(std::shared_ptr<PackDepende
auto provider = pDep->pack->provider == m_flame_provider.name ? m_flame_provider : m_modrinth_provider; auto provider = pDep->pack->provider == m_flame_provider.name ? m_flame_provider : m_modrinth_provider;
auto responseInfo = std::make_shared<QByteArray>(); auto responseInfo = std::make_shared<QByteArray>();
auto info = provider.api->getProject(pDep->pack->addonId.toString(), responseInfo); auto info = provider.api->getProject(pDep->pack->addonId.toString(), responseInfo);
QObject::connect(info.get(), &NetJob::succeeded, [responseInfo, provider, pDep] { QObject::connect(info.get(), &NetJob::succeeded, [this, responseInfo, provider, pDep] {
QJsonParseError parse_error{}; QJsonParseError parse_error{};
QJsonDocument doc = QJsonDocument::fromJson(*responseInfo, &parse_error); QJsonDocument doc = QJsonDocument::fromJson(*responseInfo, &parse_error);
if (parse_error.error != QJsonParseError::NoError) { if (parse_error.error != QJsonParseError::NoError) {
removePack(pDep->pack->addonId);
qWarning() << "Error while parsing JSON response for mod info at " << parse_error.offset qWarning() << "Error while parsing JSON response for mod info at " << parse_error.offset
<< " reason: " << parse_error.errorString(); << " reason: " << parse_error.errorString();
qDebug() << *responseInfo; qDebug() << *responseInfo;
@ -151,6 +152,7 @@ Task::Ptr GetModDependenciesTask::getProjectInfoTask(std::shared_ptr<PackDepende
: Json::requireObject(doc); : Json::requireObject(doc);
provider.mod->loadIndexedPack(*pDep->pack, obj); provider.mod->loadIndexedPack(*pDep->pack, obj);
} catch (const JSONValidationError& e) { } catch (const JSONValidationError& e) {
removePack(pDep->pack->addonId);
qDebug() << doc; qDebug() << doc;
qWarning() << "Error while reading mod info: " << e.cause(); qWarning() << "Error while reading mod info: " << e.cause();
} }
@ -211,11 +213,13 @@ Task::Ptr GetModDependenciesTask::prepareDependencyTask(const ModPlatform::Depen
pDep->pack->versionsLoaded = true; pDep->pack->versionsLoaded = true;
} catch (const JSONValidationError& e) { } catch (const JSONValidationError& e) {
removePack(dep.addonId);
qDebug() << doc; qDebug() << doc;
qWarning() << "Error while reading mod version: " << e.cause(); qWarning() << "Error while reading mod version: " << e.cause();
return; return;
} }
if (level == 0) { if (level == 0) {
removePack(dep.addonId);
qWarning() << "Dependency cycle exceeded"; qWarning() << "Dependency cycle exceeded";
return; return;
} }
@ -238,7 +242,7 @@ Task::Ptr GetModDependenciesTask::prepareDependencyTask(const ModPlatform::Depen
return tasks; return tasks;
} }
void GetModDependenciesTask::removePack(const QVariant addonId) void GetModDependenciesTask::removePack(const QVariant& addonId)
{ {
auto pred = [addonId](const std::shared_ptr<PackDependency>& v) { return v->pack->addonId == addonId; }; auto pred = [addonId](const std::shared_ptr<PackDependency>& v) { return v->pack->addonId == addonId; };
#if QT_VERSION >= QT_VERSION_CHECK(6, 1, 0) #if QT_VERSION >= QT_VERSION_CHECK(6, 1, 0)

View File

@ -65,13 +65,13 @@ class GetModDependenciesTask : public SequentialTask {
QHash<QString, QStringList> getRequiredBy(); QHash<QString, QStringList> getRequiredBy();
protected slots: protected slots:
Task::Ptr prepareDependencyTask(const ModPlatform::Dependency&, const ModPlatform::ResourceProvider, int); Task::Ptr prepareDependencyTask(const ModPlatform::Dependency&, ModPlatform::ResourceProvider, int);
QList<ModPlatform::Dependency> getDependenciesForVersion(const ModPlatform::IndexedVersion&, QList<ModPlatform::Dependency> getDependenciesForVersion(const ModPlatform::IndexedVersion&,
const ModPlatform::ResourceProvider providerName); ModPlatform::ResourceProvider providerName);
void prepare(); void prepare();
Task::Ptr getProjectInfoTask(std::shared_ptr<PackDependency> pDep); Task::Ptr getProjectInfoTask(std::shared_ptr<PackDependency> pDep);
ModPlatform::Dependency getOverride(const ModPlatform::Dependency&, const ModPlatform::ResourceProvider providerName); ModPlatform::Dependency getOverride(const ModPlatform::Dependency&, ModPlatform::ResourceProvider providerName);
void removePack(const QVariant addonId); void removePack(const QVariant& addonId);
private: private:
QList<std::shared_ptr<PackDependency>> m_pack_dependencies; QList<std::shared_ptr<PackDependency>> m_pack_dependencies;

View File

@ -68,7 +68,7 @@ class ModrinthPackExportTask : public Task {
void collectFiles(); void collectFiles();
void collectHashes(); void collectHashes();
void makeApiRequest(); void makeApiRequest();
void parseApiResponse(const std::shared_ptr<QByteArray> response); void parseApiResponse(std::shared_ptr<QByteArray> response);
void buildZip(); void buildZip();
QByteArray generateIndex(); QByteArray generateIndex();

View File

@ -33,6 +33,6 @@ class TechnicPackProcessor : public QObject {
const QString& instIcon, const QString& instIcon,
const QString& stagingPath, const QString& stagingPath,
const QString& minecraftVersion = QString(), const QString& minecraftVersion = QString(),
const bool isSolder = false); bool isSolder = false);
}; };
} // namespace Technic } // namespace Technic

View File

@ -16,9 +16,10 @@ class ConcurrentTask;
class ModUpdateDialog final : public ReviewMessageBox { class ModUpdateDialog final : public ReviewMessageBox {
Q_OBJECT Q_OBJECT
public: public:
explicit ModUpdateDialog(QWidget* parent, BaseInstance* instance, std::shared_ptr<ModFolderModel> mod_model, QList<Mod*>& search_for);
explicit ModUpdateDialog(QWidget* parent, explicit ModUpdateDialog(QWidget* parent,
BaseInstance* instance, BaseInstance* instance,
const std::shared_ptr<ModFolderModel> mod_model, std::shared_ptr<ModFolderModel> mod_model,
QList<Mod*>& search_for, QList<Mod*>& search_for,
bool includeDeps); bool includeDeps);

View File

@ -50,7 +50,7 @@ class ResourceDownloadDialog : public QDialog, public BasePageProvider {
public: public:
using DownloadTaskPtr = shared_qobject_ptr<ResourceDownloadTask>; using DownloadTaskPtr = shared_qobject_ptr<ResourceDownloadTask>;
ResourceDownloadDialog(QWidget* parent, const std::shared_ptr<ResourceFolderModel> base_model); ResourceDownloadDialog(QWidget* parent, std::shared_ptr<ResourceFolderModel> base_model);
void initializeContainer(); void initializeContainer();
void connectButtons(); void connectButtons();

View File

@ -65,7 +65,7 @@ class InstanceView : public QAbstractItemView {
/// get the model index at the specified visual point /// get the model index at the specified visual point
virtual QModelIndex indexAt(const QPoint& point) const override; virtual QModelIndex indexAt(const QPoint& point) const override;
QString groupNameAt(const QPoint& point); QString groupNameAt(const QPoint& point);
void setSelection(const QRect& rect, const QItemSelectionModel::SelectionFlags commands) override; void setSelection(const QRect& rect, QItemSelectionModel::SelectionFlags commands) override;
virtual int horizontalOffset() const override; virtual int horizontalOffset() const override;
virtual int verticalOffset() const override; virtual int verticalOffset() const override;

View File

@ -35,6 +35,7 @@
*/ */
#include "AccountListPage.h" #include "AccountListPage.h"
#include "minecraft/auth/AccountData.h"
#include "ui_AccountListPage.h" #include "ui_AccountListPage.h"
#include <QItemSelectionModel> #include <QItemSelectionModel>
@ -216,7 +217,7 @@ void AccountListPage::updateButtonStates()
QModelIndex selected = selection.first(); QModelIndex selected = selection.first();
MinecraftAccountPtr account = selected.data(AccountList::PointerRole).value<MinecraftAccountPtr>(); MinecraftAccountPtr account = selected.data(AccountList::PointerRole).value<MinecraftAccountPtr>();
accountIsReady = !account->isActive(); accountIsReady = !account->isActive();
accountIsOnline = !account->isOffline(); accountIsOnline = account->accountType() != AccountType::Offline;
} }
ui->actionRemove->setEnabled(accountIsReady); ui->actionRemove->setEnabled(accountIsReady);
ui->actionSetDefault->setEnabled(accountIsReady); ui->actionSetDefault->setEnabled(accountIsReady);

View File

@ -254,9 +254,9 @@ void ExternalResourcesPage::removeItem()
void ExternalResourcesPage::removeItems(const QItemSelection& selection) void ExternalResourcesPage::removeItems(const QItemSelection& selection)
{ {
if (m_instance != nullptr && m_instance->isRunning()) { if (m_instance != nullptr && m_instance->isRunning()) {
auto response = CustomMessageBox::selectable(this, "Confirm Delete", auto response = CustomMessageBox::selectable(this, tr("Confirm Delete"),
"If you remove this resource while the game is running it may crash your game.\n" tr("If you remove this resource while the game is running it may crash your game.\n"
"Are you sure you want to do this?", "Are you sure you want to do this?"),
QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
->exec(); ->exec();
@ -275,9 +275,9 @@ void ExternalResourcesPage::enableItem()
void ExternalResourcesPage::disableItem() void ExternalResourcesPage::disableItem()
{ {
if (m_instance != nullptr && m_instance->isRunning()) { if (m_instance != nullptr && m_instance->isRunning()) {
auto response = CustomMessageBox::selectable(this, "Confirm disable", auto response = CustomMessageBox::selectable(this, tr("Confirm disable"),
"If you disable this resource while the game is running it may crash your game.\n" tr("If you disable this resource while the game is running it may crash your game.\n"
"Are you sure you want to do this?", "Are you sure you want to do this?"),
QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
->exec(); ->exec();

View File

@ -171,9 +171,9 @@ bool ModFolderPage::onSelectionChanged(const QModelIndex& current, [[maybe_unuse
void ModFolderPage::removeItems(const QItemSelection& selection) void ModFolderPage::removeItems(const QItemSelection& selection)
{ {
if (m_instance != nullptr && m_instance->isRunning()) { if (m_instance != nullptr && m_instance->isRunning()) {
auto response = CustomMessageBox::selectable(this, "Confirm Delete", auto response = CustomMessageBox::selectable(this, tr("Confirm Delete"),
"If you remove mods while the game is running it may crash your game.\n" tr("If you remove mods while the game is running it may crash your game.\n"
"Are you sure you want to do this?", "Are you sure you want to do this?"),
QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
->exec(); ->exec();
@ -239,6 +239,18 @@ void ModFolderPage::updateMods(bool includeDeps)
QMessageBox::critical(this, tr("Error"), tr("Mod updates are unavailable when metadata is disabled!")); QMessageBox::critical(this, tr("Error"), tr("Mod updates are unavailable when metadata is disabled!"));
return; return;
} }
if (m_instance != nullptr && m_instance->isRunning()) {
auto response =
CustomMessageBox::selectable(this, tr("Confirm Update"),
tr("If you update mods while the game is running may cause mod duplication and game crashes.\n"
"The old files may not be deleted as they are in use.\n"
"Are you sure you want to do this?"),
QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
->exec();
if (response != QMessageBox::Yes)
return;
}
auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes(); auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes();
auto mods_list = m_model->selectedMods(selection); auto mods_list = m_model->selectedMods(selection);

View File

@ -65,7 +65,7 @@ class OtherLogsPage : public QWidget, public BasePage {
private slots: private slots:
void populateSelectLogBox(); void populateSelectLogBox();
void on_selectLogBox_currentIndexChanged(const int index); void on_selectLogBox_currentIndexChanged(int index);
void on_btnReload_clicked(); void on_btnReload_clicked();
void on_btnPaste_clicked(); void on_btnPaste_clicked();
void on_btnCopy_clicked(); void on_btnCopy_clicked();
@ -78,7 +78,7 @@ class OtherLogsPage : public QWidget, public BasePage {
void findPreviousActivated(); void findPreviousActivated();
private: private:
void setControlsEnabled(const bool enabled); void setControlsEnabled(bool enabled);
private: private:
Ui::OtherLogsPage* ui; Ui::OtherLogsPage* ui;

View File

@ -49,9 +49,7 @@ class ModPage : public ResourcePage {
[[nodiscard]] QMap<QString, QString> urlHandlers() const override; [[nodiscard]] QMap<QString, QString> urlHandlers() const override;
void addResourceToPage(ModPlatform::IndexedPack::Ptr, void addResourceToPage(ModPlatform::IndexedPack::Ptr, ModPlatform::IndexedVersion&, std::shared_ptr<ResourceFolderModel>) override;
ModPlatform::IndexedVersion&,
const std::shared_ptr<ResourceFolderModel>) override;
virtual auto validateVersion(ModPlatform::IndexedVersion& ver, virtual auto validateVersion(ModPlatform::IndexedVersion& ver,
QString mineVer, QString mineVer,

View File

@ -88,7 +88,7 @@ class ResourceModel : public QAbstractListModel {
void addPack(ModPlatform::IndexedPack::Ptr pack, void addPack(ModPlatform::IndexedPack::Ptr pack,
ModPlatform::IndexedVersion& version, ModPlatform::IndexedVersion& version,
const std::shared_ptr<ResourceFolderModel> packs, std::shared_ptr<ResourceFolderModel> packs,
bool is_indexed = false, bool is_indexed = false,
QString custom_target_folder = {}); QString custom_target_folder = {});
void removePack(const QString& rem); void removePack(const QString& rem);

View File

@ -78,7 +78,7 @@ class ResourcePage : public QWidget, public BasePage {
void addResourceToDialog(ModPlatform::IndexedPack::Ptr, ModPlatform::IndexedVersion&); void addResourceToDialog(ModPlatform::IndexedPack::Ptr, ModPlatform::IndexedVersion&);
void removeResourceFromDialog(const QString& pack_name); void removeResourceFromDialog(const QString& pack_name);
virtual void removeResourceFromPage(const QString& name); virtual void removeResourceFromPage(const QString& name);
virtual void addResourceToPage(ModPlatform::IndexedPack::Ptr, ModPlatform::IndexedVersion&, const std::shared_ptr<ResourceFolderModel>); virtual void addResourceToPage(ModPlatform::IndexedPack::Ptr, ModPlatform::IndexedVersion&, std::shared_ptr<ResourceFolderModel>);
QList<DownloadTaskPtr> selectedPacks() { return m_model->selectedPacks(); } QList<DownloadTaskPtr> selectedPacks() { return m_model->selectedPacks(); }
bool hasSelectedPacks() { return !(m_model->selectedPacks().isEmpty()); } bool hasSelectedPacks() { return !(m_model->selectedPacks().isEmpty()); }

View File

@ -38,9 +38,7 @@ class ShaderPackResourcePage : public ResourcePage {
[[nodiscard]] bool supportsFiltering() const override { return false; }; [[nodiscard]] bool supportsFiltering() const override { return false; };
void addResourceToPage(ModPlatform::IndexedPack::Ptr, void addResourceToPage(ModPlatform::IndexedPack::Ptr, ModPlatform::IndexedVersion&, std::shared_ptr<ResourceFolderModel>) override;
ModPlatform::IndexedVersion&,
const std::shared_ptr<ResourceFolderModel>) override;
[[nodiscard]] QMap<QString, QString> urlHandlers() const override; [[nodiscard]] QMap<QString, QString> urlHandlers() const override;

View File

@ -38,7 +38,7 @@ class ListModel : public QAbstractListModel {
void fetchMore(const QModelIndex& parent) override; void fetchMore(const QModelIndex& parent) override;
void getLogo(const QString& logo, const QString& logoUrl, LogoCallback callback); void getLogo(const QString& logo, const QString& logoUrl, LogoCallback callback);
void searchWithTerm(const QString& term, const int sort); void searchWithTerm(const QString& term, int sort);
[[nodiscard]] bool hasActiveSearchJob() const { return jobPtr && jobPtr->isRunning(); } [[nodiscard]] bool hasActiveSearchJob() const { return jobPtr && jobPtr->isRunning(); }
[[nodiscard]] Task::Ptr activeSearchJob() { return hasActiveSearchJob() ? jobPtr : nullptr; } [[nodiscard]] Task::Ptr activeSearchJob() { return hasActiveSearchJob() ? jobPtr : nullptr; }

View File

@ -71,7 +71,7 @@ class ModpackListModel : public QAbstractListModel {
/* Ask the API for more information */ /* Ask the API for more information */
void fetchMore(const QModelIndex& parent) override; void fetchMore(const QModelIndex& parent) override;
void refresh(); void refresh();
void searchWithTerm(const QString& term, const int sort); void searchWithTerm(const QString& term, int sort);
[[nodiscard]] bool hasActiveSearchJob() const { return jobPtr && jobPtr->isRunning(); } [[nodiscard]] bool hasActiveSearchJob() const { return jobPtr && jobPtr->isRunning(); }
[[nodiscard]] Task::Ptr activeSearchJob() { return hasActiveSearchJob() ? jobPtr : nullptr; } [[nodiscard]] Task::Ptr activeSearchJob() { return hasActiveSearchJob() ? jobPtr : nullptr; }

View File

@ -43,7 +43,7 @@
QString BasicCatPack::path() QString BasicCatPack::path()
{ {
const auto now = QDate::currentDate(); const auto now = QDate::currentDate();
const auto birthday = QDate(now.year(), 11, 30); const auto birthday = QDate(now.year(), 11, 1);
const auto xmas = QDate(now.year(), 12, 25); const auto xmas = QDate(now.year(), 12, 25);
const auto halloween = QDate(now.year(), 10, 31); const auto halloween = QDate(now.year(), 10, 31);

View File

@ -76,7 +76,7 @@ void LanguageSelectionWidget::languageRowChanged(const QModelIndex& current, con
translations->updateLanguage(key); translations->updateLanguage(key);
} }
void LanguageSelectionWidget::languageSettingChanged(const Setting&, const QVariant) void LanguageSelectionWidget::languageSettingChanged(const Setting&, const QVariant&)
{ {
auto translations = APPLICATION->translations(); auto translations = APPLICATION->translations();
auto index = translations->selectedIndex(); auto index = translations->selectedIndex();

View File

@ -34,7 +34,7 @@ class LanguageSelectionWidget : public QWidget {
protected slots: protected slots:
void languageRowChanged(const QModelIndex& current, const QModelIndex& previous); void languageRowChanged(const QModelIndex& current, const QModelIndex& previous);
void languageSettingChanged(const Setting&, const QVariant); void languageSettingChanged(const Setting&, const QVariant&);
private: private:
QVBoxLayout* verticalLayout = nullptr; QVBoxLayout* verticalLayout = nullptr;