From 53acc609831b0bf1a3aa5059a29d2511281a66ae Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 9 Jan 2026 22:28:25 +0200 Subject: [PATCH] format the code Signed-off-by: Trial97 --- launcher/Application.cpp | 2 +- launcher/macsandbox/SecurityBookmarkFileAccess.h | 5 +++-- launcher/minecraft/MinecraftInstance.cpp | 6 ++---- launcher/minecraft/launch/LauncherPartLaunch.cpp | 16 ++++++++-------- launcher/minecraft/mod/ResourceFolderModel.cpp | 2 +- launcher/minecraft/mod/ShaderPackFolderModel.cpp | 2 +- launcher/modplatform/ModIndex.cpp | 14 +++++++------- launcher/modplatform/ModIndex.h | 4 +--- launcher/modplatform/flame/FlameModIndex.cpp | 2 +- launcher/modplatform/import_ftb/PackHelpers.cpp | 9 +++------ launcher/settings/SettingsObject.cpp | 5 +++-- launcher/translations/TranslationsModel.cpp | 3 +-- launcher/ui/ToolTipFilter.cpp | 3 ++- launcher/ui/ToolTipFilter.h | 11 +++++------ launcher/ui/ViewLogWindow.cpp | 4 ++-- launcher/ui/dialogs/ChooseOfflineNameDialog.cpp | 3 ++- launcher/ui/pages/global/AccountListPage.cpp | 2 +- launcher/ui/pages/instance/ModFolderPage.cpp | 11 ++++++----- .../ui/pages/modplatform/flame/FlameModel.cpp | 4 ++-- .../pages/modplatform/modrinth/ModrinthModel.cpp | 4 ++-- launcher/ui/widgets/PageContainer.cpp | 3 ++- 21 files changed, 56 insertions(+), 59 deletions(-) diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 71a04502f..ae44d3238 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -50,8 +50,8 @@ #include "tools/GenericProfiler.h" #include "ui/InstanceWindow.h" #include "ui/MainWindow.h" -#include "ui/ViewLogWindow.h" #include "ui/ToolTipFilter.h" +#include "ui/ViewLogWindow.h" #include "ui/dialogs/ProgressDialog.h" #include "ui/instanceview/AccessibleInstanceView.h" diff --git a/launcher/macsandbox/SecurityBookmarkFileAccess.h b/launcher/macsandbox/SecurityBookmarkFileAccess.h index 5bddf0e31..69b344af9 100644 --- a/launcher/macsandbox/SecurityBookmarkFileAccess.h +++ b/launcher/macsandbox/SecurityBookmarkFileAccess.h @@ -42,7 +42,8 @@ class SecurityBookmarkFileAccess { bool m_readOnly; NSURL* securityScopedBookmarkToNSURL(QByteArray& bookmark, bool& isStale); -public: + + public: /// \param readOnly A boolean indicating whether the bookmark should be read-only. SecurityBookmarkFileAccess(bool readOnly = false); ~SecurityBookmarkFileAccess(); @@ -86,4 +87,4 @@ public: bool isAccessingPath(const QString& path); }; -#endif //FILEACCESS_H +#endif // FILEACCESS_H diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index cdf670b0f..6904ed0bc 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -484,7 +484,7 @@ QStringList MinecraftInstance::getNativeJars() return nativeJars; } -static QString replaceTokensIn(const QString &text, const QMap &with) +static QString replaceTokensIn(const QString& text, const QMap& with) { // TODO: does this still work?? QString result; @@ -506,7 +506,6 @@ static QString replaceTokensIn(const QString &text, const QMap return result; } - QStringList MinecraftInstance::extraArguments() { auto list = BaseInstance::extraArguments(); @@ -521,7 +520,7 @@ QStringList MinecraftInstance::extraArguments() if (!addn.isEmpty()) { QMap tokenMapping = makeProfileVarMapping(m_components->getProfile()); - for (const QString &item : addn) { + for (const QString& item : addn) { list.append(replaceTokensIn(item, tokenMapping)); } } @@ -764,7 +763,6 @@ QStringList MinecraftInstance::processMinecraftArgs(AuthSessionPtr session, Mine } } - QMap tokenMapping = makeProfileVarMapping(profile); // yggdrasil! diff --git a/launcher/minecraft/launch/LauncherPartLaunch.cpp b/launcher/minecraft/launch/LauncherPartLaunch.cpp index ee754dc85..d966287af 100644 --- a/launcher/minecraft/launch/LauncherPartLaunch.cpp +++ b/launcher/minecraft/launch/LauncherPartLaunch.cpp @@ -55,14 +55,14 @@ LauncherPartLaunch::LauncherPartLaunch(LaunchTask* parent) if (parent->instance()->settings()->get("CloseAfterLaunch").toBool()) { static const QRegularExpression s_settingUser(".*Setting user.+", QRegularExpression::CaseInsensitiveOption); std::shared_ptr connection{ new QMetaObject::Connection }; - *connection = connect(&m_process, &LoggedProcess::log, this, - [connection](const QStringList& lines, [[maybe_unused]] MessageLevel level) { - qDebug() << lines; - if (lines.filter(s_settingUser).length() != 0) { - APPLICATION->closeAllWindows(); - disconnect(*connection); - } - }); + *connection = + connect(&m_process, &LoggedProcess::log, this, [connection](const QStringList& lines, [[maybe_unused]] MessageLevel level) { + qDebug() << lines; + if (lines.filter(s_settingUser).length() != 0) { + APPLICATION->closeAllWindows(); + disconnect(*connection); + } + }); } connect(&m_process, &LoggedProcess::log, this, &LauncherPartLaunch::logLines); diff --git a/launcher/minecraft/mod/ResourceFolderModel.cpp b/launcher/minecraft/mod/ResourceFolderModel.cpp index 273a469d9..38ae6c026 100644 --- a/launcher/minecraft/mod/ResourceFolderModel.cpp +++ b/launcher/minecraft/mod/ResourceFolderModel.cpp @@ -335,7 +335,7 @@ bool ResourceFolderModel::update() }, Qt::ConnectionType::QueuedConnection); - Task::Ptr preUpdate{createPreUpdateTask()}; + Task::Ptr preUpdate{ createPreUpdateTask() }; if (preUpdate != nullptr) { auto task = new SequentialTask("ResourceFolderModel::update"); diff --git a/launcher/minecraft/mod/ShaderPackFolderModel.cpp b/launcher/minecraft/mod/ShaderPackFolderModel.cpp index 5cf5d2eb1..ea68e0257 100644 --- a/launcher/minecraft/mod/ShaderPackFolderModel.cpp +++ b/launcher/minecraft/mod/ShaderPackFolderModel.cpp @@ -1,5 +1,5 @@ -#include "FileSystem.h" #include "ShaderPackFolderModel.h" +#include "FileSystem.h" namespace { class ShaderPackIndexMigrateTask : public Task { diff --git a/launcher/modplatform/ModIndex.cpp b/launcher/modplatform/ModIndex.cpp index 7d2c18d03..7b20d37ec 100644 --- a/launcher/modplatform/ModIndex.cpp +++ b/launcher/modplatform/ModIndex.cpp @@ -25,11 +25,9 @@ namespace ModPlatform { -static const QMap s_indexed_version_type_names = { - { "release", IndexedVersionType::Release }, - { "beta", IndexedVersionType::Beta }, - { "alpha", IndexedVersionType::Alpha } -}; +static const QMap s_indexed_version_type_names = { { "release", IndexedVersionType::Release }, + { "beta", IndexedVersionType::Beta }, + { "alpha", IndexedVersionType::Alpha } }; static const QList loaderList = { NeoForge, Forge, Cauldron, LiteLoader, Quilt, Fabric, Babric, BTA, LegacyFabric, Ornithe, Rift }; @@ -45,11 +43,13 @@ QList modLoaderTypesToList(ModLoaderTypes flags) return flagList; } -QString IndexedVersionType::toString() const { +QString IndexedVersionType::toString() const +{ return s_indexed_version_type_names.key(m_type, "unknown"); } -IndexedVersionType IndexedVersionType::fromString(const QString& type) { +IndexedVersionType IndexedVersionType::fromString(const QString& type) +{ return s_indexed_version_type_names.value(type, IndexedVersionType::Unknown); } diff --git a/launcher/modplatform/ModIndex.h b/launcher/modplatform/ModIndex.h index fc0f9780e..5cde2274f 100644 --- a/launcher/modplatform/ModIndex.h +++ b/launcher/modplatform/ModIndex.h @@ -91,7 +91,6 @@ struct IndexedVersionType { Enum m_type; }; - struct Dependency { QVariant addonId; DependencyType type; @@ -121,8 +120,7 @@ struct IndexedVersion { QString getVersionDisplayString() const { - auto release_type = - version_type.isValid() ? QString(" [%1]").arg(version_type.toString()) : ""; + auto release_type = version_type.isValid() ? QString(" [%1]").arg(version_type.toString()) : ""; auto versionStr = !version.contains(version_number) ? version_number : ""; QString gameVersion = ""; for (auto v : mcVersion) { diff --git a/launcher/modplatform/flame/FlameModIndex.cpp b/launcher/modplatform/flame/FlameModIndex.cpp index 122f23bd0..3b0f7f6ae 100644 --- a/launcher/modplatform/flame/FlameModIndex.cpp +++ b/launcher/modplatform/flame/FlameModIndex.cpp @@ -156,7 +156,7 @@ auto FlameMod::loadIndexedPackVersion(QJsonObject& obj, bool load_changelog) -> break; default: ver_type = ModPlatform::IndexedVersionType::Unknown; - break; + break; } file.version_type = ver_type; diff --git a/launcher/modplatform/import_ftb/PackHelpers.cpp b/launcher/modplatform/import_ftb/PackHelpers.cpp index ec2229138..15140b088 100644 --- a/launcher/modplatform/import_ftb/PackHelpers.cpp +++ b/launcher/modplatform/import_ftb/PackHelpers.cpp @@ -91,14 +91,14 @@ Modpack parseDirectory(QString path) modpack.loaderType = ModPlatform::Quilt; } } - } else { + } else { legacyInstanceParsing(path, &modpack.loaderType, &modpack.loaderVersion); } } catch (const Exception& e) { qDebug() << "Couldn't load ftb instance json: " << e.cause(); return {}; } - + auto iconFile = QFileInfo(FS::PathCombine(path, "folder.jpg")); if (iconFile.exists() && iconFile.isFile()) { modpack.icon = QIcon(iconFile.absoluteFilePath()); @@ -145,12 +145,9 @@ void legacyInstanceParsing(QString path, std::optional #include +#include #include #ifdef Q_OS_MACOS @@ -127,7 +127,8 @@ QString SettingsObject::getPathFromBookmark(const QString& id) } // there is no need to use bookmarks if the default value is used or the directory is within the data directory (already can access) - if (setting->get() == setting->defValue() || QDir(setting->get().toString()).absolutePath().startsWith(QDir::current().absolutePath())) { + if (setting->get() == setting->defValue() || + QDir(setting->get().toString()).absolutePath().startsWith(QDir::current().absolutePath())) { return setting->get().toString(); } diff --git a/launcher/translations/TranslationsModel.cpp b/launcher/translations/TranslationsModel.cpp index 6d5609077..ee2e240ab 100644 --- a/launcher/translations/TranslationsModel.cpp +++ b/launcher/translations/TranslationsModel.cpp @@ -251,8 +251,7 @@ void readIndex(const QString& path, QMap& languages) Language lang(iter.key()); auto langObj = Json::requireObject(iter.value()); - lang.setTranslationStats(langObj["translated"].toInt(), langObj["untranslated"].toInt(), - langObj["fuzzy"].toInt()); + lang.setTranslationStats(langObj["translated"].toInt(), langObj["untranslated"].toInt(), langObj["fuzzy"].toInt()); lang.file_name = Json::requireString(langObj, "file"); lang.file_sha1 = Json::requireString(langObj, "sha1"); lang.file_size = Json::requireInteger(langObj, "size"); diff --git a/launcher/ui/ToolTipFilter.cpp b/launcher/ui/ToolTipFilter.cpp index 0a95356c1..367c39230 100644 --- a/launcher/ui/ToolTipFilter.cpp +++ b/launcher/ui/ToolTipFilter.cpp @@ -19,7 +19,8 @@ #include "ToolTipFilter.h" -bool ToolTipFilter::eventFilter(QObject* obj, QEvent* ev) { +bool ToolTipFilter::eventFilter(QObject* obj, QEvent* ev) +{ if (ev->type() == QEvent::ToolTip) { return true; } else { diff --git a/launcher/ui/ToolTipFilter.h b/launcher/ui/ToolTipFilter.h index 3cbb1f1d6..c5ab66206 100644 --- a/launcher/ui/ToolTipFilter.h +++ b/launcher/ui/ToolTipFilter.h @@ -18,12 +18,11 @@ #pragma once -#include -#include +#include +#include -class ToolTipFilter : public QObject -{ +class ToolTipFilter : public QObject { Q_OBJECT -protected: - bool eventFilter(QObject *obj, QEvent *event); + protected: + bool eventFilter(QObject* obj, QEvent* event); }; diff --git a/launcher/ui/ViewLogWindow.cpp b/launcher/ui/ViewLogWindow.cpp index 028b44def..9d7d7821f 100644 --- a/launcher/ui/ViewLogWindow.cpp +++ b/launcher/ui/ViewLogWindow.cpp @@ -12,8 +12,8 @@ ViewLogWindow::ViewLogWindow(QWidget* parent) setWindowTitle(tr("View Launcher Logs")); setCentralWidget(m_page); setMinimumSize(m_page->size()); - setContentsMargins(6, 6, 0, 6); // the "Other Logs" instance page has 6px padding on the right, - // to have equal padding in all directions in the dialog we add it to all other sides. + setContentsMargins(6, 6, 0, 6); // the "Other Logs" instance page has 6px padding on the right, + // to have equal padding in all directions in the dialog we add it to all other sides. m_page->opened(); show(); } diff --git a/launcher/ui/dialogs/ChooseOfflineNameDialog.cpp b/launcher/ui/dialogs/ChooseOfflineNameDialog.cpp index 79a567404..35b8faffb 100644 --- a/launcher/ui/dialogs/ChooseOfflineNameDialog.cpp +++ b/launcher/ui/dialogs/ChooseOfflineNameDialog.cpp @@ -23,7 +23,8 @@ #include "ui_ChooseOfflineNameDialog.h" -ChooseOfflineNameDialog::ChooseOfflineNameDialog(const QString& message, QWidget* parent) : QDialog(parent), ui(new Ui::ChooseOfflineNameDialog) +ChooseOfflineNameDialog::ChooseOfflineNameDialog(const QString& message, QWidget* parent) + : QDialog(parent), ui(new Ui::ChooseOfflineNameDialog) { ui->setupUi(this); ui->label->setText(message); diff --git a/launcher/ui/pages/global/AccountListPage.cpp b/launcher/ui/pages/global/AccountListPage.cpp index ff250888a..7e7490d34 100644 --- a/launcher/ui/pages/global/AccountListPage.cpp +++ b/launcher/ui/pages/global/AccountListPage.cpp @@ -44,8 +44,8 @@ #include -#include "ui/dialogs/CustomMessageBox.h" #include "ui/dialogs/ChooseOfflineNameDialog.h" +#include "ui/dialogs/CustomMessageBox.h" #include "ui/dialogs/MSALoginDialog.h" #include "Application.h" diff --git a/launcher/ui/pages/instance/ModFolderPage.cpp b/launcher/ui/pages/instance/ModFolderPage.cpp index 7aee9e105..e3fa9bf6b 100644 --- a/launcher/ui/pages/instance/ModFolderPage.cpp +++ b/launcher/ui/pages/instance/ModFolderPage.cpp @@ -393,9 +393,10 @@ bool NilModFolderPage::shouldDisplay() const // Helper function so this doesn't need to be duplicated 3 times inline bool ModFolderPage::handleNoModLoader() { - int resp = QMessageBox::question(this, this->tr("Missing Mod Loader"), - this->tr("You need to install a compatible mod loader before installing mods. Would you like to do so?"), - QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); + int resp = + QMessageBox::question(this, this->tr("Missing Mod Loader"), + this->tr("You need to install a compatible mod loader before installing mods. Would you like to do so?"), + QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); switch (resp) { case QMessageBox::Yes: { // Should be safe @@ -403,8 +404,8 @@ inline bool ModFolderPage::handleNoModLoader() InstallLoaderDialog dialog(profile, QString(), this); bool ret = dialog.exec(); this->m_container->refreshContainer(); - - // returning negation of dialog.exec which'll be true if the install loader dialog got canceled/closed + + // returning negation of dialog.exec which'll be true if the install loader dialog got canceled/closed // and false if the user went through and installed a loader return !ret; } diff --git a/launcher/ui/pages/modplatform/flame/FlameModel.cpp b/launcher/ui/pages/modplatform/flame/FlameModel.cpp index 3ae700fb4..5d968d65a 100644 --- a/launcher/ui/pages/modplatform/flame/FlameModel.cpp +++ b/launcher/ui/pages/modplatform/flame/FlameModel.cpp @@ -193,8 +193,8 @@ void ListModel::performPaginatedSearch() callbacks.on_succeed = [this](auto& doc) { searchRequestFinished(doc); }; callbacks.on_fail = [this](QString reason, int) { searchRequestFailed(reason); }; callbacks.on_abort = [this] { - qCritical() << "Search task aborted by an unknown reason!"; - searchRequestFailed("Aborted"); + qCritical() << "Search task aborted by an unknown reason!"; + searchRequestFailed("Aborted"); }; auto netJob = api.searchProjects({ ModPlatform::ResourceType::Modpack, m_nextSearchOffset, m_currentSearchTerm, sort, m_filter->loaders, diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp b/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp index 33aeb494e..05cd2970c 100644 --- a/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp +++ b/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp @@ -163,8 +163,8 @@ void ModpackListModel::performPaginatedSearch() callbacks.on_succeed = [this](auto& doc) { searchRequestFinished(doc); }; callbacks.on_fail = [this](QString reason, int) { searchRequestFailed(reason); }; callbacks.on_abort = [this] { - qCritical() << "Search task aborted by an unknown reason!"; - searchRequestFailed("Aborted"); + qCritical() << "Search task aborted by an unknown reason!"; + searchRequestFailed("Aborted"); }; auto netJob = api.searchProjects({ ModPlatform::ResourceType::Modpack, m_nextSearchOffset, m_currentSearchTerm, sort, m_filter->loaders, diff --git a/launcher/ui/widgets/PageContainer.cpp b/launcher/ui/widgets/PageContainer.cpp index 4fd8ceb9b..58b092275 100644 --- a/launcher/ui/widgets/PageContainer.cpp +++ b/launcher/ui/widgets/PageContainer.cpp @@ -207,7 +207,8 @@ void PageContainer::addButtons(QLayout* buttons) m_layout->addLayout(buttons, 2, 1, 1, 2); } -void PageContainer::useSidebarStyle(bool sidebar) { +void PageContainer::useSidebarStyle(bool sidebar) +{ m_pageList->setProperty("_kde_side_panel_view", sidebar); }