mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 01:54:20 +03:00
clang-tidy: clang-analyzer-* (#5103)
This commit is contained in:
commit
64abd37e05
11 changed files with 50 additions and 62 deletions
|
|
@ -578,16 +578,14 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
bool migrated = false;
|
auto migrated = handleDataMigration(
|
||||||
|
|
||||||
if (!migrated)
|
|
||||||
migrated = handleDataMigration(
|
|
||||||
dataPath, FS::PathCombine(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation), "../../PolyMC"), "PolyMC",
|
dataPath, FS::PathCombine(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation), "../../PolyMC"), "PolyMC",
|
||||||
"polymc.cfg");
|
"polymc.cfg");
|
||||||
if (!migrated)
|
if (!migrated) {
|
||||||
migrated = handleDataMigration(
|
handleDataMigration(dataPath,
|
||||||
dataPath, FS::PathCombine(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation), "../../multimc"), "MultiMC",
|
FS::PathCombine(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation), "../../multimc"),
|
||||||
"multimc.cfg");
|
"MultiMC", "multimc.cfg");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -14,26 +14,26 @@
|
||||||
else \
|
else \
|
||||||
type = Qt::DirectConnection;
|
type = Qt::DirectConnection;
|
||||||
|
|
||||||
#define DEFINE_FUNC_NO_PARAM(NAME, RET_TYPE) \
|
#define DEFINE_FUNC_NO_PARAM(NAME, RET_TYPE, RET_DEF) \
|
||||||
static RET_TYPE NAME() \
|
static RET_TYPE NAME() \
|
||||||
{ \
|
{ \
|
||||||
RET_TYPE ret; \
|
RET_TYPE ret = RET_DEF; \
|
||||||
GET_TYPE() \
|
GET_TYPE() \
|
||||||
QMetaObject::invokeMethod(s_instance, "_" #NAME, type, Q_RETURN_ARG(RET_TYPE, ret)); \
|
QMetaObject::invokeMethod(s_instance, "_" #NAME, type, Q_RETURN_ARG(RET_TYPE, ret)); \
|
||||||
return ret; \
|
return ret; \
|
||||||
}
|
}
|
||||||
#define DEFINE_FUNC_ONE_PARAM(NAME, RET_TYPE, PARAM_1_TYPE) \
|
#define DEFINE_FUNC_ONE_PARAM(NAME, RET_TYPE, RET_DEF, PARAM_1_TYPE) \
|
||||||
static RET_TYPE NAME(PARAM_1_TYPE p1) \
|
static RET_TYPE NAME(PARAM_1_TYPE p1) \
|
||||||
{ \
|
{ \
|
||||||
RET_TYPE ret; \
|
RET_TYPE ret = RET_DEF; \
|
||||||
GET_TYPE() \
|
GET_TYPE() \
|
||||||
QMetaObject::invokeMethod(s_instance, "_" #NAME, type, Q_RETURN_ARG(RET_TYPE, ret), Q_ARG(PARAM_1_TYPE, p1)); \
|
QMetaObject::invokeMethod(s_instance, "_" #NAME, type, Q_RETURN_ARG(RET_TYPE, ret), Q_ARG(PARAM_1_TYPE, p1)); \
|
||||||
return ret; \
|
return ret; \
|
||||||
}
|
}
|
||||||
#define DEFINE_FUNC_TWO_PARAM(NAME, RET_TYPE, PARAM_1_TYPE, PARAM_2_TYPE) \
|
#define DEFINE_FUNC_TWO_PARAM(NAME, RET_TYPE, RET_DEF, PARAM_1_TYPE, PARAM_2_TYPE) \
|
||||||
static RET_TYPE NAME(PARAM_1_TYPE p1, PARAM_2_TYPE p2) \
|
static RET_TYPE NAME(PARAM_1_TYPE p1, PARAM_2_TYPE p2) \
|
||||||
{ \
|
{ \
|
||||||
RET_TYPE ret; \
|
RET_TYPE ret = RET_DEF; \
|
||||||
GET_TYPE() \
|
GET_TYPE() \
|
||||||
QMetaObject::invokeMethod(s_instance, "_" #NAME, type, Q_RETURN_ARG(RET_TYPE, ret), Q_ARG(PARAM_1_TYPE, p1), \
|
QMetaObject::invokeMethod(s_instance, "_" #NAME, type, Q_RETURN_ARG(RET_TYPE, ret), Q_ARG(PARAM_1_TYPE, p1), \
|
||||||
Q_ARG(PARAM_2_TYPE, p2)); \
|
Q_ARG(PARAM_2_TYPE, p2)); \
|
||||||
|
|
@ -53,18 +53,18 @@ class PixmapCache final : public QObject {
|
||||||
static void setInstance(PixmapCache* i) { s_instance = i; }
|
static void setInstance(PixmapCache* i) { s_instance = i; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DEFINE_FUNC_NO_PARAM(cacheLimit, int)
|
DEFINE_FUNC_NO_PARAM(cacheLimit, int, -1)
|
||||||
DEFINE_FUNC_NO_PARAM(clear, bool)
|
DEFINE_FUNC_NO_PARAM(clear, bool, false)
|
||||||
DEFINE_FUNC_TWO_PARAM(find, bool, const QString&, QPixmap*)
|
DEFINE_FUNC_TWO_PARAM(find, bool, false, const QString&, QPixmap*)
|
||||||
DEFINE_FUNC_TWO_PARAM(find, bool, const QPixmapCache::Key&, QPixmap*)
|
DEFINE_FUNC_TWO_PARAM(find, bool, false, const QPixmapCache::Key&, QPixmap*)
|
||||||
DEFINE_FUNC_TWO_PARAM(insert, bool, const QString&, const QPixmap&)
|
DEFINE_FUNC_TWO_PARAM(insert, bool, false, const QString&, const QPixmap&)
|
||||||
DEFINE_FUNC_ONE_PARAM(insert, QPixmapCache::Key, const QPixmap&)
|
DEFINE_FUNC_ONE_PARAM(insert, QPixmapCache::Key, {}, const QPixmap&)
|
||||||
DEFINE_FUNC_ONE_PARAM(remove, bool, const QString&)
|
DEFINE_FUNC_ONE_PARAM(remove, bool, false, const QString&)
|
||||||
DEFINE_FUNC_ONE_PARAM(remove, bool, const QPixmapCache::Key&)
|
DEFINE_FUNC_ONE_PARAM(remove, bool, false, const QPixmapCache::Key&)
|
||||||
DEFINE_FUNC_TWO_PARAM(replace, bool, const QPixmapCache::Key&, const QPixmap&)
|
DEFINE_FUNC_TWO_PARAM(replace, bool, false, const QPixmapCache::Key&, const QPixmap&)
|
||||||
DEFINE_FUNC_ONE_PARAM(setCacheLimit, bool, int)
|
DEFINE_FUNC_ONE_PARAM(setCacheLimit, bool, false, int)
|
||||||
DEFINE_FUNC_NO_PARAM(markCacheMissByEviciton, bool)
|
DEFINE_FUNC_NO_PARAM(markCacheMissByEviciton, bool, false)
|
||||||
DEFINE_FUNC_ONE_PARAM(setFastEvictionThreshold, bool, int)
|
DEFINE_FUNC_ONE_PARAM(setFastEvictionThreshold, bool, false, int)
|
||||||
|
|
||||||
// NOTE: Every function returns something non-void to simplify the macros.
|
// NOTE: Every function returns something non-void to simplify the macros.
|
||||||
private slots:
|
private slots:
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ class QIODevice;
|
||||||
namespace ModPlatform {
|
namespace ModPlatform {
|
||||||
|
|
||||||
enum class ModLoaderType : std::uint16_t {
|
enum class ModLoaderType : std::uint16_t {
|
||||||
|
None = 0U,
|
||||||
NeoForge = 1U << 0U,
|
NeoForge = 1U << 0U,
|
||||||
Forge = 1U << 1U,
|
Forge = 1U << 1U,
|
||||||
Cauldron = 1U << 2U,
|
Cauldron = 1U << 2U,
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,7 @@ class FlameAPI : public ResourceAPI {
|
||||||
case ModPlatform::LegacyFabric:
|
case ModPlatform::LegacyFabric:
|
||||||
case ModPlatform::Ornithe:
|
case ModPlatform::Ornithe:
|
||||||
case ModPlatform::Rift:
|
case ModPlatform::Rift:
|
||||||
|
case ModPlatform::None:
|
||||||
break; // not supported
|
break; // not supported
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,9 @@
|
||||||
namespace ExportToModList {
|
namespace ExportToModList {
|
||||||
|
|
||||||
enum Formats { HTML, MARKDOWN, PLAINTXT, JSON, CSV, CUSTOM };
|
enum Formats { HTML, MARKDOWN, PLAINTXT, JSON, CSV, CUSTOM };
|
||||||
enum OptionalData { Authors = 1 << 0, Url = 1 << 1, Version = 1 << 2, FileName = 1 << 3 };
|
enum OptionalDataValue { None = 0, Authors = 1 << 0, Url = 1 << 1, Version = 1 << 2, FileName = 1 << 3 };
|
||||||
|
Q_DECLARE_FLAGS(OptionalData, OptionalDataValue)
|
||||||
|
|
||||||
QString exportToModList(QList<Mod*> mods, Formats format, OptionalData extraData);
|
QString exportToModList(QList<Mod*> mods, Formats format, OptionalData extraData);
|
||||||
QString exportToModList(QList<Mod*> mods, QString lineTemplate);
|
QString exportToModList(QList<Mod*> mods, QString lineTemplate);
|
||||||
} // namespace ExportToModList
|
} // namespace ExportToModList
|
||||||
|
|
|
||||||
|
|
@ -63,12 +63,12 @@ void PackInstallTask::copySettings()
|
||||||
instance.settings()->set("JvmArgs", m_pack.jvmArgs.toString());
|
instance.settings()->set("JvmArgs", m_pack.jvmArgs.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
auto components = instance.getPackProfile();
|
auto* components = instance.getPackProfile();
|
||||||
components->buildingFromScratch();
|
components->buildingFromScratch();
|
||||||
components->setComponentVersion("net.minecraft", m_pack.mcVersion, true);
|
components->setComponentVersion("net.minecraft", m_pack.mcVersion, true);
|
||||||
|
|
||||||
auto modloader = m_pack.loaderType;
|
auto modloader = m_pack.loaderType;
|
||||||
if (modloader.has_value())
|
if (modloader.has_value()) {
|
||||||
switch (modloader.value()) {
|
switch (modloader.value()) {
|
||||||
case ModPlatform::NeoForge: {
|
case ModPlatform::NeoForge: {
|
||||||
components->setComponentVersion("net.neoforged", m_pack.loaderVersion, true);
|
components->setComponentVersion("net.neoforged", m_pack.loaderVersion, true);
|
||||||
|
|
@ -86,28 +86,16 @@ void PackInstallTask::copySettings()
|
||||||
components->setComponentVersion("org.quiltmc.quilt-loader", m_pack.loaderVersion, true);
|
components->setComponentVersion("org.quiltmc.quilt-loader", m_pack.loaderVersion, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ModPlatform::Cauldron:
|
default:
|
||||||
break;
|
|
||||||
case ModPlatform::LiteLoader:
|
|
||||||
break;
|
|
||||||
case ModPlatform::DataPack:
|
|
||||||
break;
|
|
||||||
case ModPlatform::Babric:
|
|
||||||
break;
|
|
||||||
case ModPlatform::BTA:
|
|
||||||
break;
|
|
||||||
case ModPlatform::LegacyFabric:
|
|
||||||
break;
|
|
||||||
case ModPlatform::Ornithe:
|
|
||||||
break;
|
|
||||||
case ModPlatform::Rift:
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
components->saveNow();
|
components->saveNow();
|
||||||
|
|
||||||
instance.setName(name());
|
instance.setName(name());
|
||||||
if (m_instIcon == "default")
|
if (m_instIcon == "default") {
|
||||||
m_instIcon = "ftb_logo";
|
m_instIcon = "ftb_logo";
|
||||||
|
}
|
||||||
instance.setIconKey(m_instIcon);
|
instance.setIconKey(m_instIcon);
|
||||||
}
|
}
|
||||||
emitSucceeded();
|
emitSucceeded();
|
||||||
|
|
|
||||||
|
|
@ -183,8 +183,7 @@ void POTranslatorPrivate::reload()
|
||||||
nextFuzzy = true;
|
nextFuzzy = true;
|
||||||
}
|
}
|
||||||
} else if (line.startsWith('"')) {
|
} else if (line.startsWith('"')) {
|
||||||
QByteArray temp;
|
QByteArray* out = nullptr;
|
||||||
QByteArray* out = &temp;
|
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case Mode::First:
|
case Mode::First:
|
||||||
|
|
|
||||||
|
|
@ -214,6 +214,8 @@ void ExportToModListDialog::addExtra(ExportToModList::OptionalData option)
|
||||||
case ExportToModList::FileName:
|
case ExportToModList::FileName:
|
||||||
ui->templateText->insertPlainText("{filename}");
|
ui->templateText->insertPlainText("{filename}");
|
||||||
break;
|
break;
|
||||||
|
case ExportToModList::None:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void ExportToModListDialog::enableCustom(bool enabled)
|
void ExportToModListDialog::enableCustom(bool enabled)
|
||||||
|
|
|
||||||
|
|
@ -511,8 +511,7 @@ void InstanceView::paintEvent([[maybe_unused]] QPaintEvent* event)
|
||||||
|
|
||||||
int wpWidth = viewport()->width();
|
int wpWidth = viewport()->width();
|
||||||
option.rect.setWidth(wpWidth);
|
option.rect.setWidth(wpWidth);
|
||||||
for (int i = 0; i < m_groups.size(); ++i) {
|
for (auto* category : m_groups) {
|
||||||
VisualGroup* category = m_groups.at(i);
|
|
||||||
int y = category->verticalPosition();
|
int y = category->verticalPosition();
|
||||||
y -= verticalOffset();
|
y -= verticalOffset();
|
||||||
QRect backup = option.rect;
|
QRect backup = option.rect;
|
||||||
|
|
@ -522,7 +521,6 @@ void InstanceView::paintEvent([[maybe_unused]] QPaintEvent* event)
|
||||||
option.rect.setLeft(m_leftMargin);
|
option.rect.setLeft(m_leftMargin);
|
||||||
option.rect.setRight(wpWidth - m_rightMargin);
|
option.rect.setRight(wpWidth - m_rightMargin);
|
||||||
category->drawHeader(&painter, option);
|
category->drawHeader(&painter, option);
|
||||||
y += category->totalHeight() + m_categoryMargin;
|
|
||||||
option.rect = backup;
|
option.rect = backup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,9 +56,7 @@ class QGridLayout;
|
||||||
class PageContainer : public QWidget, public BasePageContainer {
|
class PageContainer : public QWidget, public BasePageContainer {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit PageContainer(BasePageProvider* pageProvider,
|
explicit PageContainer(BasePageProvider* pageProvider, QString defaultId = QString(), QWidget* parent = nullptr);
|
||||||
QString defaultId = QString(),
|
|
||||||
QWidget* parent = nullptr);
|
|
||||||
~PageContainer() override = default;
|
~PageContainer() override = default;
|
||||||
|
|
||||||
void addButtons(QWidget* buttons);
|
void addButtons(QWidget* buttons);
|
||||||
|
|
|
||||||
|
|
@ -47,31 +47,32 @@ void ProjectItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o
|
||||||
painter->setOpacity(0.4); // Fade out the entire item
|
painter->setOpacity(0.4); // Fade out the entire item
|
||||||
}
|
}
|
||||||
// The default icon size will be a square (and height is usually the lower value).
|
// The default icon size will be a square (and height is usually the lower value).
|
||||||
auto icon_width = rect.height(), icon_height = rect.height();
|
auto icon_width = rect.height();
|
||||||
int icon_x_margin = (rect.height() - icon_width) / 2;
|
int icon_x_margin = (rect.height() - icon_width) / 2;
|
||||||
int icon_y_margin = (rect.height() - icon_height) / 2;
|
|
||||||
|
|
||||||
if (!opt.icon.isNull()) { // Icon painting
|
if (!opt.icon.isNull()) { // Icon painting
|
||||||
|
auto icon_height = 0;
|
||||||
{
|
{
|
||||||
auto icon_size = opt.decorationSize;
|
auto icon_size = opt.decorationSize;
|
||||||
icon_width = icon_size.width();
|
icon_width = icon_size.width();
|
||||||
icon_height = icon_size.height();
|
icon_height = icon_size.height();
|
||||||
|
|
||||||
icon_y_margin = (rect.height() - icon_height) / 2;
|
icon_x_margin = (rect.height() - icon_height) / 2; // use same margins for consistency
|
||||||
icon_x_margin = icon_y_margin; // use same margins for consistency
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Centralize icon with a margin to separate from the other elements
|
// Centralize icon with a margin to separate from the other elements
|
||||||
int x = rect.x() + icon_x_margin;
|
int x = rect.x() + icon_x_margin;
|
||||||
int y = rect.y() + icon_y_margin;
|
int y = rect.y() + icon_x_margin;
|
||||||
|
|
||||||
if (opt.features & QStyleOptionViewItem::HasCheckIndicator)
|
if (opt.features & QStyleOptionViewItem::HasCheckIndicator) {
|
||||||
rect.translate(icon_x_margin / 2, 0);
|
rect.translate(icon_x_margin / 2, 0);
|
||||||
|
}
|
||||||
|
|
||||||
// Prevent 'scaling null pixmap' warnings
|
// Prevent 'scaling null pixmap' warnings
|
||||||
if (icon_width > 0 && icon_height > 0)
|
if (icon_width > 0 && icon_height > 0) {
|
||||||
opt.icon.paint(painter, x, y, icon_width, icon_height);
|
opt.icon.paint(painter, x, y, icon_width, icon_height);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Change the rect so that funther painting is easier
|
// Change the rect so that funther painting is easier
|
||||||
auto remaining_width = rect.width() - icon_width - 2 * icon_x_margin;
|
auto remaining_width = rect.width() - icon_width - 2 * icon_x_margin;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue