-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #127 from ModOrganizer2/use-clang-format-v2
Clang Format + Github Workflows
- Loading branch information
Showing
113 changed files
with
14,171 additions
and
13,942 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
218607a6ce4d41112bd3995ba319255aec3c5c2e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: Build UIBase | ||
on: | ||
push: | ||
branches: master | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
jobs: | ||
build: | ||
runs-on: windows-2022 | ||
steps: | ||
- name: Checkout mob | ||
uses: actions/checkout@master | ||
with: | ||
repository: modorganizer2/mob | ||
path: ./mob | ||
- name: Cache mob | ||
id: cache-mob | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
./mob/mob.exe | ||
key: ${{ runner.OS }}-mob-cache-${{ hashFiles('mob/.git/refs/heads/master') }} | ||
restore-keys: | | ||
${{ runner.OS }}-mob-cache- | ||
- if: ${{ steps.cache-mob.outputs.cache-hit != 'true' }} | ||
name: Build mob | ||
run: .\mob\bootstrap.ps1 | ||
- name: Install Qt | ||
uses: jurplel/install-qt-action@v3 | ||
with: | ||
version: 6.5.1 | ||
modules: qtpositioning qtwebchannel qtwebengine qtwebsockets | ||
cache: true | ||
- name: Add Qt bins to PATH | ||
run: echo "${QT_ROOT_DIR }/msvc2019_64/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | ||
- name: Cache dependencies | ||
id: cache-dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
./build | ||
!./build/modorganizer_super | ||
key: ${{ runner.OS }}-mo2-dependencies-${{ hashFiles('mob/.git/refs/heads/master') }} | ||
restore-keys: | | ||
${{ runner.OS }}-mo2-dependencies- | ||
- if: ${{ steps.cache-dependencies.outputs.cache-hit != 'true' }} | ||
name: Build dependencies with mob | ||
run: .\mob\mob.exe -l 4 -d . build fmt gtest spdlog boost | ||
- name: Build dependencies log | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: build-dependencies-log | ||
path: | | ||
mob.log | ||
- name: Build cmake_common | ||
run: .\mob\mob.exe -l 4 -d . build | ||
--ignore-uncommitted-changes | ||
--redownload --reextract --reconfigure --rebuild | ||
cmake_common | ||
- uses: actions/checkout@v3 | ||
with: | ||
path: ./build/modorganizer_super/uibase | ||
- name: Build UIBase | ||
run: .\mob\mob.exe -l 5 -d . build --no-fetch-task --no-pull uibase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: Lint UIBase | ||
on: [push] | ||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Run clang-format | ||
uses: jidicula/[email protected] | ||
with: | ||
clang-format-version: "15" | ||
check-path: "." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,49 @@ | ||
#include "delayedfilewriter.h" | ||
#include "log.h" | ||
|
||
|
||
using namespace MOBase; | ||
|
||
|
||
DelayedFileWriterBase::DelayedFileWriterBase(int delay) | ||
: m_TimerDelay(delay) | ||
, m_Timer() | ||
{ | ||
QObject::connect(&m_Timer, &QTimer::timeout, this, &DelayedFileWriter::timerExpired); | ||
m_Timer.setSingleShot(true); | ||
} | ||
|
||
DelayedFileWriterBase::~DelayedFileWriterBase() | ||
{ | ||
if (m_Timer.isActive()) { | ||
log::error("delayed file save timer active at shutdown"); | ||
} | ||
} | ||
|
||
void DelayedFileWriterBase::write() | ||
{ | ||
m_Timer.start(m_TimerDelay); | ||
} | ||
|
||
void DelayedFileWriterBase::cancel() | ||
{ | ||
m_Timer.stop(); | ||
} | ||
|
||
void DelayedFileWriterBase::writeImmediately(bool ifOnTimer) | ||
{ | ||
if (!ifOnTimer || m_Timer.isActive()) { | ||
m_Timer.stop(); | ||
doWrite(); | ||
} | ||
} | ||
|
||
void DelayedFileWriterBase::timerExpired() | ||
{ | ||
doWrite(); | ||
} | ||
|
||
|
||
|
||
DelayedFileWriter::DelayedFileWriter(DelayedFileWriter::WriterFunc func | ||
, int delay) | ||
: DelayedFileWriterBase(delay) | ||
, m_Func(func) | ||
{ | ||
} | ||
|
||
void DelayedFileWriter::doWrite() | ||
{ | ||
m_Func(); | ||
} | ||
#include "delayedfilewriter.h" | ||
#include "log.h" | ||
|
||
using namespace MOBase; | ||
|
||
DelayedFileWriterBase::DelayedFileWriterBase(int delay) : m_TimerDelay(delay), m_Timer() | ||
{ | ||
QObject::connect(&m_Timer, &QTimer::timeout, this, &DelayedFileWriter::timerExpired); | ||
m_Timer.setSingleShot(true); | ||
} | ||
|
||
DelayedFileWriterBase::~DelayedFileWriterBase() | ||
{ | ||
if (m_Timer.isActive()) { | ||
log::error("delayed file save timer active at shutdown"); | ||
} | ||
} | ||
|
||
void DelayedFileWriterBase::write() | ||
{ | ||
m_Timer.start(m_TimerDelay); | ||
} | ||
|
||
void DelayedFileWriterBase::cancel() | ||
{ | ||
m_Timer.stop(); | ||
} | ||
|
||
void DelayedFileWriterBase::writeImmediately(bool ifOnTimer) | ||
{ | ||
if (!ifOnTimer || m_Timer.isActive()) { | ||
m_Timer.stop(); | ||
doWrite(); | ||
} | ||
} | ||
|
||
void DelayedFileWriterBase::timerExpired() | ||
{ | ||
doWrite(); | ||
} | ||
|
||
DelayedFileWriter::DelayedFileWriter(DelayedFileWriter::WriterFunc func, int delay) | ||
: DelayedFileWriterBase(delay), m_Func(func) | ||
{} | ||
|
||
void DelayedFileWriter::doWrite() | ||
{ | ||
m_Func(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,74 @@ | ||
#ifndef DELAYEDFILEWRITER_H | ||
#define DELAYEDFILEWRITER_H | ||
|
||
|
||
#include "dllimport.h" | ||
#include <QString> | ||
#include <QTimer> | ||
#include <functional> | ||
|
||
|
||
namespace MOBase { | ||
|
||
/** | ||
* The purpose of this class is to aggregate changes to a file before writing it out | ||
*/ | ||
class QDLLEXPORT DelayedFileWriterBase : public QObject { | ||
|
||
Q_OBJECT | ||
|
||
public: | ||
/** | ||
* @brief constructor | ||
* @param fileName | ||
* @param delay delay (in milliseconds) before we call the actual write function | ||
*/ | ||
DelayedFileWriterBase(int delay = 200); | ||
~DelayedFileWriterBase(); | ||
|
||
public slots: | ||
/** | ||
* @brief write with delay | ||
*/ | ||
void write(); | ||
|
||
/** | ||
* @brief cancel a scheduled write (does nothing if no write is scheduled) | ||
*/ | ||
void cancel(); | ||
|
||
/** | ||
* @brief write immediately without waiting for the timer to expire | ||
* @param ifOnTimer only write if the timer is running | ||
*/ | ||
void writeImmediately(bool ifOnTimer); | ||
|
||
private slots: | ||
void timerExpired(); | ||
|
||
private: | ||
virtual void doWrite() = 0; | ||
|
||
private: | ||
int m_TimerDelay; | ||
QTimer m_Timer; | ||
}; | ||
|
||
|
||
class QDLLEXPORT DelayedFileWriter : public DelayedFileWriterBase { | ||
public: | ||
typedef std::function<void()> WriterFunc; | ||
public: | ||
DelayedFileWriter(WriterFunc func, int delay = 200); | ||
private: | ||
void doWrite(); | ||
private: | ||
WriterFunc m_Func; | ||
}; | ||
|
||
} | ||
|
||
#endif // DELAYEDFILEWRITER_H | ||
#ifndef DELAYEDFILEWRITER_H | ||
#define DELAYEDFILEWRITER_H | ||
|
||
#include "dllimport.h" | ||
#include <QString> | ||
#include <QTimer> | ||
#include <functional> | ||
|
||
namespace MOBase | ||
{ | ||
|
||
/** | ||
* The purpose of this class is to aggregate changes to a file before writing it out | ||
*/ | ||
class QDLLEXPORT DelayedFileWriterBase : public QObject | ||
{ | ||
|
||
Q_OBJECT | ||
|
||
public: | ||
/** | ||
* @brief constructor | ||
* @param fileName | ||
* @param delay delay (in milliseconds) before we call the actual write function | ||
*/ | ||
DelayedFileWriterBase(int delay = 200); | ||
~DelayedFileWriterBase(); | ||
|
||
public slots: | ||
/** | ||
* @brief write with delay | ||
*/ | ||
void write(); | ||
|
||
/** | ||
* @brief cancel a scheduled write (does nothing if no write is scheduled) | ||
*/ | ||
void cancel(); | ||
|
||
/** | ||
* @brief write immediately without waiting for the timer to expire | ||
* @param ifOnTimer only write if the timer is running | ||
*/ | ||
void writeImmediately(bool ifOnTimer); | ||
|
||
private slots: | ||
void timerExpired(); | ||
|
||
private: | ||
virtual void doWrite() = 0; | ||
|
||
private: | ||
int m_TimerDelay; | ||
QTimer m_Timer; | ||
}; | ||
|
||
class QDLLEXPORT DelayedFileWriter : public DelayedFileWriterBase | ||
{ | ||
public: | ||
typedef std::function<void()> WriterFunc; | ||
|
||
public: | ||
DelayedFileWriter(WriterFunc func, int delay = 200); | ||
|
||
private: | ||
void doWrite(); | ||
|
||
private: | ||
WriterFunc m_Func; | ||
}; | ||
|
||
} // namespace MOBase | ||
|
||
#endif // DELAYEDFILEWRITER_H |
Oops, something went wrong.