diff --git a/.clang-format b/.clang-format index f8001db5afae43eac049e21960e74360892e3ad6..e7fd784dccff38f5515e53349eb2c918c770770e 100644 --- a/.clang-format +++ b/.clang-format @@ -5,19 +5,22 @@ AlignConsecutiveAssignments: true AlignConsecutiveBitFields: true AlignConsecutiveDeclarations: false AlignConsecutiveMacros: true -AlignEscapedNewlines: Right +AlignEscapedNewlines: Left AlignOperands: true AlignTrailingComments: true +AllowAllArgumentsOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: false -AllowShortBlocksOnASingleLine: false -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: None +AllowShortBlocksOnASingleLine: Empty +AllowShortCaseLabelsOnASingleLine: true +AllowShortEnumsOnASingleLine: true +AllowShortFunctionsOnASingleLine: All AllowShortIfStatementsOnASingleLine: false AllowShortLoopsOnASingleLine: false +AllowShortLambdasOnASingleLine: All AlwaysBreakAfterDefinitionReturnType: TopLevel AlwaysBreakAfterReturnType: None AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: false +AlwaysBreakTemplateDeclarations: No BinPackArguments: true BinPackParameters: true BraceWrapping: @@ -61,6 +64,7 @@ ForEachMacros: - 'for_ever' - 'parallel_for' - 'script_class' + - 'function_class' IncludeCategories: - Regex: '.*' diff --git a/src/Lib/AbstractDocument.hh b/src/Lib/AbstractDocument.hh index e24a0d90b788a781d617adf0e777404eb7d74ba1..12780daa2c307d0f9c1fd32bdcd2bb56ba56e3ef 100644 --- a/src/Lib/AbstractDocument.hh +++ b/src/Lib/AbstractDocument.hh @@ -51,14 +51,8 @@ protected: public: virtual bool rename(const QString &) noexcept = 0; - QString getName() const noexcept - { - return name; - } - Uuid getUuid() const noexcept - { - return uuid; - } + QString getName() const noexcept { return name; } + Uuid getUuid() const noexcept { return uuid; } signals: void documentChanged(); diff --git a/src/Lib/CRTPStore.hh b/src/Lib/CRTPStore.hh index 8614380f81b85b1eef73f767d95ca2dc5bb42438..94b03353c2fd1c9ed525109d4981374ad2a910ae 100644 --- a/src/Lib/CRTPStore.hh +++ b/src/Lib/CRTPStore.hh @@ -10,8 +10,8 @@ #include <QMap> #include <memory> -#define VIVY_STORAGE_CLASS(theClassName, theDocumentName) \ - VIVY_UNMOVABLE_OBJECT(theClassName) \ +#define VIVY_STORAGE_CLASS(theClassName, theDocumentName) \ + VIVY_UNMOVABLE_OBJECT(theClassName) \ friend CRTPStore<theClassName, theDocumentName>; namespace Vivy diff --git a/src/Lib/Document/CRTPSubDocument.hh b/src/Lib/Document/CRTPSubDocument.hh index 715ec6bfbdd765cc8d7bffc1aaaf12dc083950c9..43c7871a6423687119b6555e12f5fbad6d6141e6 100644 --- a/src/Lib/Document/CRTPSubDocument.hh +++ b/src/Lib/Document/CRTPSubDocument.hh @@ -48,15 +48,9 @@ public: return ret; } - inline Type getType() const noexcept - { - return fileType; - } + inline Type getType() const noexcept { return fileType; } - inline QString getFilePath() const noexcept - { - return filePath; - } + inline QString getFilePath() const noexcept { return filePath; } }; // Audio document diff --git a/src/Lib/Script/CRTPLuaScriptObject.cc b/src/Lib/Script/CRTPLuaScriptObject.cc index 25ec7757954d47de3740f4cb9563d3799d355b84..f720dff6032a5d69f86645ecc5340202dd98fae2 100644 --- a/src/Lib/Script/CRTPLuaScriptObject.cc +++ b/src/Lib/Script/CRTPLuaScriptObject.cc @@ -4,15 +4,9 @@ // SampleObject implementation using namespace Vivy::Script; -SampleObject::SampleObject() noexcept -{ - fprintf(stderr, "CREATE SampleObject\n"); -} +SampleObject::SampleObject() noexcept { fprintf(stderr, "CREATE SampleObject\n"); } -SampleObject::~SampleObject() noexcept -{ - fprintf(stderr, "DESTROY SampleObject\n"); -} +SampleObject::~SampleObject() noexcept { fprintf(stderr, "DESTROY SampleObject\n"); } int SampleObject::foo(lua_State *L) noexcept diff --git a/src/Lib/Script/LuaContext.cc b/src/Lib/Script/LuaContext.cc index 01ef2141bd9a80f11d5a7e739d285924e59de8a3..e9e546c6ffe4d964a36a1418c20a278b87c21249 100644 --- a/src/Lib/Script/LuaContext.cc +++ b/src/Lib/Script/LuaContext.cc @@ -22,10 +22,7 @@ LuaContext::LuaContext() noexcept SampleObject::Register(L); // Load the C++ objects } -LuaContext::~LuaContext() noexcept -{ - lua_close(L); -} +LuaContext::~LuaContext() noexcept { lua_close(L); } LuaContext::Code LuaContext::loadDocument(std::shared_ptr<ScriptDocument> doc) noexcept diff --git a/src/Lib/Script/LuaContext.hh b/src/Lib/Script/LuaContext.hh index f0d846cfba52958bb3e63b55b6f89ceff685cb00..146c0e5f8d6c71bb17c2678be1aece7b37bd6ee9 100644 --- a/src/Lib/Script/LuaContext.hh +++ b/src/Lib/Script/LuaContext.hh @@ -28,10 +28,7 @@ public: QString getLastError() noexcept; - operator lua_State *() noexcept - { - return L; - } + operator lua_State *() noexcept { return L; } private: // Exec all loaded strings and files diff --git a/src/Lib/Script/ScriptStore.cc b/src/Lib/Script/ScriptStore.cc index 27e345b27926dee19dfcba991c915fb6883bb19f..12408a70d5ca0cdea7d6e9770d9a0ae8375c273d 100644 --- a/src/Lib/Script/ScriptStore.cc +++ b/src/Lib/Script/ScriptStore.cc @@ -4,10 +4,7 @@ using namespace Vivy; using namespace std::string_literals; -ScriptStore::ScriptStore() noexcept -{ - resetLoadedScripts(); -} +ScriptStore::ScriptStore() noexcept { resetLoadedScripts(); } void ScriptStore::loadScriptFolder(const QString &folderPath) diff --git a/src/Lib/Utils.hh b/src/Lib/Utils.hh index ac421be7dd692377f98eb204e1485634734c7efe..20c60e04cb7ab4498c176a8c3edc101b2617cfe0 100644 --- a/src/Lib/Utils.hh +++ b/src/Lib/Utils.hh @@ -20,14 +20,14 @@ namespace chrono = std::chrono; // Prety define for OpenMP's parallel for loop with indentation not fucked up // by clang-format. -#define parallel_for \ +#define parallel_for \ _Pragma("omp parallel for") for // Don't move this object, create it in one place and never move it again. -#define VIVY_UNMOVABLE_OBJECT(classname) \ - classname(const classname &) = delete; /* Copy */ \ - classname(classname &&) = delete; /* Move */ \ - classname &operator=(const classname &) = delete; /* Copy assign */ \ +#define VIVY_UNMOVABLE_OBJECT(classname) \ + classname(const classname &) = delete; /* Copy */ \ + classname(classname &&) = delete; /* Move */ \ + classname &operator=(const classname &) = delete; /* Copy assign */ \ classname &operator=(classname &&) = delete; /* Move assign */ // QStringLiteral but for regexes @@ -96,8 +96,7 @@ enum class DocumentType : quint64 { Video = (MKV | MP4 | MOV | AVI | AV1 | M4V | FLV), }; -template <typename E> -constexpr auto +template <typename E> constexpr auto toUnderlying(E e) noexcept { return static_cast<std::underlying_type_t<E>>(e); diff --git a/src/Lib/Uuid.hh b/src/Lib/Uuid.hh index 02e0801b19eecf10adc8144280aa61d1c98cc30d..a45b43700e293f3d52bdcdb95b532887c8ed291d 100644 --- a/src/Lib/Uuid.hh +++ b/src/Lib/Uuid.hh @@ -11,9 +11,6 @@ public: { } - QString toString() const noexcept - { - return QUuid::toString(Uuid::WithoutBraces); - } + QString toString() const noexcept { return QUuid::toString(Uuid::WithoutBraces); } }; } diff --git a/src/UI/AboutWindow.cc b/src/UI/AboutWindow.cc index af1c3df3e758c43a17640d4bf1af0e36f8b665d6..fb916a803bfa4c78d420bb342a583a173cd1bbfc 100644 --- a/src/UI/AboutWindow.cc +++ b/src/UI/AboutWindow.cc @@ -68,16 +68,11 @@ AboutWindow::LicenceLabel::LicenceLabel(QWidget *parent, const QString &url, switch (format) { case Qt::PlainText: - case Qt::RichText: - setText(content.readAll()); - break; + case Qt::RichText: setText(content.readAll()); break; - case Qt::MarkdownText: - setMarkdown(content.readAll()); - break; + case Qt::MarkdownText: setMarkdown(content.readAll()); break; - case Qt::AutoText: - qCritical() << "Invalid text format for LicenceLabel" << format; + case Qt::AutoText: qCritical() << "Invalid text format for LicenceLabel" << format; } } diff --git a/src/UI/DocumentViews/AssLinesModel.cc b/src/UI/DocumentViews/AssLinesModel.cc index 99cbc42e322449684b824a3c7bedafeb09c92bc1..58616e134ffdde48daf4af9baa09c6f56544910b 100644 --- a/src/UI/DocumentViews/AssLinesModel.cc +++ b/src/UI/DocumentViews/AssLinesModel.cc @@ -54,10 +54,7 @@ AssLinesModel::AssLinesModel(const QVector<Ass::LinePtr> &lines) noexcept childs.append(new Item(Ass::LineWeakPtr{ line })); } -AssLinesModel::~AssLinesModel() noexcept -{ - qDeleteAll(childs); -} +AssLinesModel::~AssLinesModel() noexcept { qDeleteAll(childs); } QVariant AssLinesModel::data(const QModelIndex &index, int role) const noexcept @@ -71,12 +68,10 @@ AssLinesModel::data(const QModelIndex &index, int role) const noexcept // Display role if (Qt::DisplayRole == role) { switch (column) { - case Item::Field::Text: - return line->getLineText(); + case Item::Field::Text: return line->getLineText(); // We want a warning when adding a field so don"t use "default" - case Item::Field::TotalFieldCount: - qFatal("Unreachable"); + case Item::Field::TotalFieldCount: qFatal("Unreachable"); } } diff --git a/src/UI/DocumentViews/MpvContainer.cc b/src/UI/DocumentViews/MpvContainer.cc index 375b9f949828eced98bcf7ae71cf75f5215951c8..388e57a01a5a343a19bd7991a46c0b6f4c1f7a65 100644 --- a/src/UI/DocumentViews/MpvContainer.cc +++ b/src/UI/DocumentViews/MpvContainer.cc @@ -74,10 +74,7 @@ MpvContainer::closeMpv() noexcept } } -MpvContainer::~MpvContainer() noexcept -{ - closeMpv(); -} +MpvContainer::~MpvContainer() noexcept { closeMpv(); } void MpvContainer::handleMpvEvent(mpv_event *event) noexcept @@ -97,9 +94,7 @@ MpvContainer::handleMpvEvent(mpv_event *event) noexcept }; switch (event->event_id) { - case MPV_EVENT_SHUTDOWN: - closeMpv(); - break; + case MPV_EVENT_SHUTDOWN: closeMpv(); break; case MPV_EVENT_VIDEO_RECONFIG: // TODO: Those are sync calls, prefer async calls @@ -149,13 +144,9 @@ MpvContainer::handleMpvEvent(mpv_event *event) noexcept qDebug() << "MPV -> set to play"; break; - case MPV_EVENT_START_FILE: - qDebug() << "MPV: Begin of file"; - break; + case MPV_EVENT_START_FILE: qDebug() << "MPV: Begin of file"; break; - case MPV_EVENT_END_FILE: - qDebug() << "MPV: Reached end of file!"; - break; + case MPV_EVENT_END_FILE: qDebug() << "MPV: Reached end of file!"; break; case MPV_EVENT_COMMAND_REPLY: qDebug() << "Got return of" << event->reply_userdata; @@ -179,8 +170,7 @@ MpvContainer::handleMpvEvent(mpv_event *event) noexcept case MPV_EVENT_PLAYBACK_RESTART: case MPV_EVENT_CHAPTER_CHANGE: case MPV_EVENT_QUEUE_OVERFLOW: - case MPV_EVENT_HOOK: - break; + case MPV_EVENT_HOOK: break; } } @@ -197,8 +187,7 @@ void MpvContainer::handleMpvEventCommandReply(const AsyncCmdType type) noexcept { switch (type) { - case AsyncCmdType::None: - break; + case AsyncCmdType::None: break; case AsyncCmdType::LoadAssFile: case AsyncCmdType::ReloadAss: @@ -221,13 +210,9 @@ MpvContainer::handleMpvEventCommandReply(const AsyncCmdType type) noexcept unloadAssFile(); break; - case AsyncCmdType::SeekTime: - qDebug() << "MPV - CMD: Seeked playback"; - break; + case AsyncCmdType::SeekTime: qDebug() << "MPV - CMD: Seeked playback"; break; - case AsyncCmdType::TogglePlayback: - qDebug() << "MPV - CMD: Playback was toggled"; - break; + case AsyncCmdType::TogglePlayback: qDebug() << "MPV - CMD: Playback was toggled"; break; } } diff --git a/src/UI/DocumentViews/MpvControls.cc b/src/UI/DocumentViews/MpvControls.cc index 5c490dca4cbb1b12228f4b81e61d7e31b14849cf..696ea6bb716952f0202f79e9294a9415dbc401f3 100644 --- a/src/UI/DocumentViews/MpvControls.cc +++ b/src/UI/DocumentViews/MpvControls.cc @@ -48,8 +48,7 @@ MpvControls::MpvControls(MpvContainer *passedContainer, QWidget *parent) noexcep case QAbstractSlider::SliderAction::SliderMove: case QAbstractSlider::SliderNoAction: case QAbstractSlider::SliderToMinimum: - case QAbstractSlider::SliderToMaximum: - break; + case QAbstractSlider::SliderToMaximum: break; } }); diff --git a/src/UI/MainWindow.cc b/src/UI/MainWindow.cc index 6944ebed495c71372feb9833e2ef5665e8328b97..939d3a3cac5e41babefa2ed52c5019c676a9c3ce 100644 --- a/src/UI/MainWindow.cc +++ b/src/UI/MainWindow.cc @@ -29,10 +29,10 @@ #define DCL_MENU(menu, name) [[maybe_unused]] QMenu *menu##Menu = menuBar()->addMenu(name); -#define DCL_ACTION(method, name, tip, menu) \ - [[maybe_unused]] QAction *method##Act = new QAction(tr(name), this); \ - method##Act->setStatusTip(tr(tip)); \ - menu##Menu->addAction(method##Act); \ +#define DCL_ACTION(method, name, tip, menu) \ + [[maybe_unused]] QAction *method##Act = new QAction(tr(name), this); \ + method##Act->setStatusTip(tr(tip)); \ + menu##Menu->addAction(method##Act); \ connect(method##Act, &QAction::triggered, this, &MainWindow::method); #define ACTION_ADD_ICON(action, icon) action##Act->setIcon(QIcon(icon)); @@ -122,7 +122,7 @@ MainWindow::MainWindow() noexcept }; { -#define CONNECT_ENABLE(act, func) \ +#define CONNECT_ENABLE(act, func) \ connect(documents, &QTabWidget::currentChanged, act, std::bind_front(func, act)); connect(documents, &QTabWidget::currentChanged, this, diff --git a/src/UI/PropertyModel.cc b/src/UI/PropertyModel.cc index d80604ca44e28994fd8797e6afeba3ed5a1e59f4..cadec56e0d0749326d54d0de2bceda71d3005297 100644 --- a/src/UI/PropertyModel.cc +++ b/src/UI/PropertyModel.cc @@ -8,10 +8,7 @@ PropertyModel::Item::Item(Item *theParent) noexcept { } -PropertyModel::Item::~Item() noexcept -{ - qDeleteAll(childs); -} +PropertyModel::Item::~Item() noexcept { qDeleteAll(childs); } void PropertyModel::Item::appendChild(PropertyModel::Item *item) noexcept diff --git a/src/VivyApplication.cc b/src/VivyApplication.cc index 70c84396b458884121d7e91e561e57687ba8868f..b9c0dbfea0ae9086172ec5cdf0897512276dde84 100644 --- a/src/VivyApplication.cc +++ b/src/VivyApplication.cc @@ -80,11 +80,9 @@ VivyApplication::getApplicationFont(Font id) const noexcept case Font::DefaultBoldItalic: return QFont(QFontDatabase::applicationFontFamilies(fontIdBoldItalic).at(0)); - case Font::DefaultBold: - return QFont(QFontDatabase::applicationFontFamilies(fontIdBold).at(0)); + case Font::DefaultBold: return QFont(QFontDatabase::applicationFontFamilies(fontIdBold).at(0)); - case Font::Default: - return QFont(QFontDatabase::applicationFontFamilies(fontIdRegular).at(0)); + case Font::Default: return QFont(QFontDatabase::applicationFontFamilies(fontIdRegular).at(0)); } // Let the program crash