From 744dcbe75d7171c2510fc2dcf19ca9f2f974df80 Mon Sep 17 00:00:00 2001
From: Kubat <mael.martin31@gmail.com>
Date: Tue, 17 Aug 2021 16:45:42 +0200
Subject: [PATCH] MISC: Apply new clang-format

---
 .clang-format                         | 14 +++++++-----
 src/Lib/AbstractDocument.hh           | 10 ++-------
 src/Lib/CRTPStore.hh                  |  4 ++--
 src/Lib/Document/CRTPSubDocument.hh   | 10 ++-------
 src/Lib/Script/CRTPLuaScriptObject.cc | 10 ++-------
 src/Lib/Script/LuaContext.cc          |  5 +----
 src/Lib/Script/LuaContext.hh          |  5 +----
 src/Lib/Script/ScriptStore.cc         |  5 +----
 src/Lib/Utils.hh                      | 13 ++++++-----
 src/Lib/Uuid.hh                       |  5 +----
 src/UI/AboutWindow.cc                 | 11 +++-------
 src/UI/DocumentViews/AssLinesModel.cc | 11 +++-------
 src/UI/DocumentViews/MpvContainer.cc  | 31 +++++++--------------------
 src/UI/DocumentViews/MpvControls.cc   |  3 +--
 src/UI/MainWindow.cc                  | 10 ++++-----
 src/UI/PropertyModel.cc               |  5 +----
 src/VivyApplication.cc                |  6 ++----
 17 files changed, 50 insertions(+), 108 deletions(-)

diff --git a/.clang-format b/.clang-format
index f8001db5..e7fd784d 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 e24a0d90..12780daa 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 8614380f..94b03353 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 715ec6bf..43c7871a 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 25ec7757..f720dff6 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 01ef2141..e9e546c6 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 f0d846cf..146c0e5f 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 27e345b2..12408a70 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 ac421be7..20c60e04 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 02e0801b..a45b4370 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 af1c3df3..fb916a80 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 99cbc42e..58616e13 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 375b9f94..388e57a0 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 5c490dca..696ea6bb 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 6944ebed..939d3a3c 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 d80604ca..cadec56e 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 70c84396..b9c0dbfe 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
-- 
GitLab