mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-07-05 04:46:57 +03:00
chore(clang-tidy): fix clang tidy warnings
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
9f175a4a4d
commit
21b74dd6d1
14 changed files with 411 additions and 507 deletions
|
|
@ -46,13 +46,10 @@
|
|||
#include "Application.h"
|
||||
#include "Json.h"
|
||||
#include "launch/LaunchTask.h"
|
||||
#include "settings/INISettingsObject.h"
|
||||
#include "settings/OverrideSetting.h"
|
||||
#include "settings/Setting.h"
|
||||
|
||||
#include "BuildConfig.h"
|
||||
#include "Commandline.h"
|
||||
#include "FileSystem.h"
|
||||
|
||||
int getConsoleMaxLines(SettingsObject* settings)
|
||||
{
|
||||
|
|
@ -71,20 +68,18 @@ bool shouldStopOnConsoleOverflow(SettingsObject* settings)
|
|||
return settings->get("ConsoleOverflowStop").toBool();
|
||||
}
|
||||
|
||||
BaseInstance::BaseInstance(SettingsObject* globalSettings, std::unique_ptr<SettingsObject> settings, const QString& rootDir) : QObject()
|
||||
BaseInstance::BaseInstance(SettingsObject* globalSettings, std::unique_ptr<SettingsObject> settings, const QString& rootDir)
|
||||
: m_rootDir(rootDir), m_settings(std::move(settings)), m_global_settings(globalSettings)
|
||||
{
|
||||
m_settings = std::move(settings);
|
||||
m_global_settings = globalSettings;
|
||||
m_rootDir = rootDir;
|
||||
|
||||
m_settings->registerSetting("name", "Unnamed Instance");
|
||||
m_settings->registerSetting("iconKey", "default");
|
||||
m_settings->registerSetting("notes", "");
|
||||
|
||||
m_settings->registerSetting("lastLaunchTime", 0);
|
||||
m_settings->registerSetting("totalTimePlayed", 0);
|
||||
if (m_settings->get("totalTimePlayed").toLongLong() < 0)
|
||||
if (m_settings->get("totalTimePlayed").toLongLong() < 0) {
|
||||
m_settings->reset("totalTimePlayed");
|
||||
}
|
||||
m_settings->registerSetting("lastTimePlayed", 0);
|
||||
|
||||
m_settings->registerSetting("linkedInstances", "[]");
|
||||
|
|
@ -97,8 +92,9 @@ BaseInstance::BaseInstance(SettingsObject* globalSettings, std::unique_ptr<Setti
|
|||
|
||||
// NOTE: Sometimees InstanceType is already registered, as it was used to identify the type of
|
||||
// a locally stored instance
|
||||
if (!m_settings->getSetting("InstanceType"))
|
||||
if (!m_settings->getSetting("InstanceType")) {
|
||||
m_settings->registerSetting("InstanceType", "");
|
||||
}
|
||||
|
||||
// Custom Commands
|
||||
auto commandSetting = m_settings->registerSetting({ "OverrideCommands", "OverrideLaunchCmd" }, false);
|
||||
|
|
@ -128,8 +124,6 @@ BaseInstance::BaseInstance(SettingsObject* globalSettings, std::unique_ptr<Setti
|
|||
m_settings->registerSetting("Profiler", "");
|
||||
}
|
||||
|
||||
BaseInstance::~BaseInstance() {}
|
||||
|
||||
QString BaseInstance::getPreLaunchCommand()
|
||||
{
|
||||
return settings()->get("PreLaunchCommand").toString();
|
||||
|
|
@ -210,7 +204,7 @@ void BaseInstance::addLinkedInstanceId(const QString& id)
|
|||
bool BaseInstance::removeLinkedInstanceId(const QString& id)
|
||||
{
|
||||
auto linkedInstances = getLinkedInstances();
|
||||
int numRemoved = linkedInstances.removeAll(id);
|
||||
auto numRemoved = linkedInstances.removeAll(id);
|
||||
setLinkedInstances(linkedInstances);
|
||||
return numRemoved > 0;
|
||||
}
|
||||
|
|
@ -221,7 +215,7 @@ bool BaseInstance::isLinkedToInstanceId(const QString& id) const
|
|||
return linkedInstances.contains(id);
|
||||
}
|
||||
|
||||
void BaseInstance::iconUpdated(QString key)
|
||||
void BaseInstance::iconUpdated(const QString& key)
|
||||
{
|
||||
if (iconKey() == key) {
|
||||
emit propertiesChanged(this);
|
||||
|
|
@ -260,8 +254,9 @@ bool BaseInstance::isRunning() const
|
|||
|
||||
void BaseInstance::setRunning(bool running)
|
||||
{
|
||||
if (running == m_isRunning)
|
||||
if (running == m_isRunning) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_isRunning = running;
|
||||
|
||||
|
|
@ -352,7 +347,7 @@ void BaseInstance::setLastLaunch(qint64 val)
|
|||
emit propertiesChanged(this);
|
||||
}
|
||||
|
||||
void BaseInstance::setNotes(QString val)
|
||||
void BaseInstance::setNotes(const QString& val)
|
||||
{
|
||||
// FIXME: if no change, do not set. setting involves saving a file.
|
||||
m_settings->set("notes", val);
|
||||
|
|
@ -363,7 +358,7 @@ QString BaseInstance::notes() const
|
|||
return m_settings->get("notes").toString();
|
||||
}
|
||||
|
||||
void BaseInstance::setIconKey(QString val)
|
||||
void BaseInstance::setIconKey(const QString& val)
|
||||
{
|
||||
// FIXME: if no change, do not set. setting involves saving a file.
|
||||
m_settings->set("iconKey", val);
|
||||
|
|
@ -375,7 +370,7 @@ QString BaseInstance::iconKey() const
|
|||
return m_settings->get("iconKey").toString();
|
||||
}
|
||||
|
||||
void BaseInstance::setName(QString val)
|
||||
void BaseInstance::setName(const QString& val)
|
||||
{
|
||||
// FIXME: if no change, do not set. setting involves saving a file.
|
||||
m_settings->set("name", val);
|
||||
|
|
@ -414,19 +409,23 @@ QList<ShortcutData> BaseInstance::shortcuts() const
|
|||
auto data = m_settings->get("shortcuts").toString().toUtf8();
|
||||
QJsonParseError parseError;
|
||||
auto document = QJsonDocument::fromJson(data, &parseError);
|
||||
if (parseError.error != QJsonParseError::NoError || !document.isArray())
|
||||
if (parseError.error != QJsonParseError::NoError || !document.isArray()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
QList<ShortcutData> results;
|
||||
for (const auto& elem : document.array()) {
|
||||
if (!elem.isObject())
|
||||
if (!elem.isObject()) {
|
||||
continue;
|
||||
}
|
||||
auto dict = elem.toObject();
|
||||
if (!dict.contains("name") || !dict.contains("filePath") || !dict.contains("target"))
|
||||
if (!dict.contains("name") || !dict.contains("filePath") || !dict.contains("target")) {
|
||||
continue;
|
||||
}
|
||||
int value = dict["target"].toInt(-1);
|
||||
if (!dict["name"].isString() || !dict["filePath"].isString() || value < 0 || value >= 3)
|
||||
if (!dict["name"].isString() || !dict["filePath"].isString() || value < 0 || value >= 3) {
|
||||
continue;
|
||||
}
|
||||
|
||||
QString shortcutName = dict["name"].toString();
|
||||
QString filePath = dict["filePath"].toString();
|
||||
|
|
@ -465,7 +464,7 @@ void BaseInstance::updateRuntimeContext()
|
|||
// NOOP
|
||||
}
|
||||
|
||||
bool BaseInstance::isLegacy()
|
||||
bool BaseInstance::isLegacy() const
|
||||
{
|
||||
return traits().contains("legacyLaunch") || traits().contains("alphaLaunch");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue