diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..6098e1f --- /dev/null +++ b/.clang-format @@ -0,0 +1,41 @@ +--- +# We'll use defaults from the LLVM style, but with 4 columns indentation. +BasedOnStyle: LLVM +IndentWidth: 2 +--- +Language: Cpp +DeriveLineEnding: false +UseCRLF: true +DerivePointerAlignment: false +PointerAlignment: Left +AlignConsecutiveAssignments: true +AllowShortFunctionsOnASingleLine: Inline +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: Empty +AlwaysBreakTemplateDeclarations: Yes +AccessModifierOffset: -2 +AlignTrailingComments: true +SpacesBeforeTrailingComments: 2 +NamespaceIndentation: Inner +MaxEmptyLinesToKeep: 1 +BreakBeforeBraces: Custom +BraceWrapping: + AfterCaseLabel: false + AfterClass: true + AfterControlStatement: false + AfterEnum: true + AfterFunction: true + AfterNamespace: true + AfterStruct: true + AfterUnion: true + AfterExternBlock: true + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: false + SplitEmptyRecord: false + SplitEmptyNamespace: true +ColumnLimit: 88 +ForEachMacros: ['Q_FOREACH', 'foreach'] diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..f869712 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,7 @@ +# Set the default behavior, in case people don't have core.autocrlf set. +* text=auto + +# Explicitly declare text files you want to always be normalized and converted +# to native line endings on checkout. +*.cpp text eol=crlf +*.h text eol=crlf diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..3103a1f --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,20 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-merge-conflict + - id: check-case-conflict + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v19.1.5 + hooks: + - id: clang-format + 'types_or': [c++, c] + +ci: + autofix_commit_msg: "[pre-commit.ci] Auto fixes from pre-commit.com hooks." + autofix_prs: true + autoupdate_commit_msg: "[pre-commit.ci] Pre-commit autoupdate." + autoupdate_schedule: quarterly + submodules: false diff --git a/src/inibakery.cpp b/src/inibakery.cpp index 05fc336..9db4b2b 100644 --- a/src/inibakery.cpp +++ b/src/inibakery.cpp @@ -2,25 +2,25 @@ #include -#include #include +#include #include #include -#include -#include #include #include - +#include +#include using namespace MOBase; - -bool IniBakery::init(MOBase::IOrganizer *moInfo) +bool IniBakery::init(MOBase::IOrganizer* moInfo) { using namespace std::placeholders; m_MOInfo = moInfo; - m_MOInfo->onAboutToRun([this](const auto& binary) { return prepareIni(binary); }); + m_MOInfo->onAboutToRun([this](const auto& binary) { + return prepareIni(binary); + }); return true; } @@ -77,20 +77,19 @@ bool IniBakery::prepareIni(const QString&) return true; } - MappingType IniBakery::mappings() const { MappingType result; - const IPluginGame *game = m_MOInfo->managedGame(); + const IPluginGame* game = m_MOInfo->managedGame(); - IProfile *profile = m_MOInfo->profile(); + IProfile* profile = m_MOInfo->profile(); if (profile->localSettingsEnabled()) { - for (const QString &iniFile : iniFileNames()) { + for (const QString& iniFile : iniFileNames()) { result.push_back({m_MOInfo->profilePath() + "/" + QFileInfo(iniFile).fileName(), - game->documentsDirectory().absoluteFilePath(iniFile), - false, false}); + game->documentsDirectory().absoluteFilePath(iniFile), false, + false}); } } diff --git a/src/inibakery.h b/src/inibakery.h index f5012a2..21db29b 100644 --- a/src/inibakery.h +++ b/src/inibakery.h @@ -20,9 +20,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #pragma once -#include -#include #include +#include +#include #include #include @@ -30,13 +30,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /** * @brief The IniBakery class */ -class IniBakery : public QObject, public MOBase::IPlugin, public MOBase::IPluginFileMapper { +class IniBakery : public QObject, + public MOBase::IPlugin, + public MOBase::IPluginFileMapper +{ Q_OBJECT Q_INTERFACES(MOBase::IPlugin MOBase::IPluginFileMapper) Q_PLUGIN_METADATA(IID "org.tannin.IniBakey") public: - virtual bool init(MOBase::IOrganizer *moInfo); + virtual bool init(MOBase::IOrganizer* moInfo); virtual QString name() const; virtual QString localizedName() const; virtual QString author() const; @@ -47,13 +50,9 @@ public: virtual MappingType mappings() const; private: - QStringList iniFileNames() const; - bool prepareIni(const QString &executable); + bool prepareIni(const QString& executable); private: - - MOBase::IOrganizer *m_MOInfo; - + MOBase::IOrganizer* m_MOInfo; }; -