From b4716d25c097979446fb26ca426a174be0ffc3f5 Mon Sep 17 00:00:00 2001 From: zach Date: Thu, 4 Jun 2026 22:57:45 +0200 Subject: [PATCH] nodiscard --- Plugins/ZShell/Blobs/blobgroup.hpp | 8 +- Plugins/ZShell/Blobs/blobinvertedrect.hpp | 10 +- Plugins/ZShell/Blobs/blobmaterial.hpp | 4 +- Plugins/ZShell/Blobs/blobrect.hpp | 14 +- Plugins/ZShell/Blobs/blobshape.hpp | 21 +- Plugins/ZShell/Components/lazylistview.hpp | 2 +- Plugins/ZShell/Internal/arcgauge.hpp | 4 +- .../ZShell/Internal/cachingimagemanager.hpp | 71 +++---- Plugins/ZShell/Internal/circularbuffer.hpp | 2 +- .../Internal/circularindicatormanager.hpp | 5 +- Plugins/ZShell/Internal/hyprdevices.hpp | 82 ++++---- Plugins/ZShell/Internal/hyprextras.hpp | 2 +- Plugins/ZShell/Internal/lidwatcher.hpp | 2 +- Plugins/ZShell/Internal/sparklineitem.hpp | 2 +- Plugins/ZShell/Internal/wallpaperimage.hpp | 2 +- Plugins/ZShell/Models/filesystemmodel.hpp | 193 +++++++++--------- Plugins/ZShell/Services/audiocollector.hpp | 4 +- Plugins/ZShell/Services/audioprovider.hpp | 7 +- Plugins/ZShell/Services/beattracker.hpp | 2 +- Plugins/ZShell/Services/cavaprovider.hpp | 2 +- Plugins/ZShell/Services/desktopmodel.hpp | 13 +- .../ZShell/Services/desktopstatemanager.hpp | 4 +- Plugins/ZShell/Services/hyprsunsetmanager.hpp | 2 +- Plugins/ZShell/Services/service.hpp | 2 +- Plugins/ZShell/appdb.hpp | 128 ++++++------ Plugins/ZShell/imageanalyser.hpp | 62 +++--- Plugins/ZShell/qalculator.hpp | 2 +- Plugins/ZShell/toaster.hpp | 3 +- Plugins/ZShell/writefile.hpp | 6 +- 29 files changed, 332 insertions(+), 329 deletions(-) diff --git a/Plugins/ZShell/Blobs/blobgroup.hpp b/Plugins/ZShell/Blobs/blobgroup.hpp index ce5d933..e917804 100644 --- a/Plugins/ZShell/Blobs/blobgroup.hpp +++ b/Plugins/ZShell/Blobs/blobgroup.hpp @@ -18,13 +18,13 @@ public: explicit BlobGroup(QObject* parent = nullptr); ~BlobGroup() override; -qreal smoothing() const { +[[nodiscard]] qreal smoothing() const { return m_smoothing; } void setSmoothing(qreal s); -QColor color() const { +[[nodiscard]] QColor color() const { return m_color; } @@ -36,11 +36,11 @@ void removeShape(BlobShape* shape); void setInvertedRect(BlobInvertedRect* rect); void clearInvertedRect(BlobInvertedRect* rect); -const QList& shapes() const { +[[nodiscard]] const QList& shapes() const { return m_shapes; } -BlobInvertedRect* invertedRect() const { +[[nodiscard]] BlobInvertedRect* invertedRect() const { return m_invertedRect; } diff --git a/Plugins/ZShell/Blobs/blobinvertedrect.hpp b/Plugins/ZShell/Blobs/blobinvertedrect.hpp index d85913e..0a36ef8 100644 --- a/Plugins/ZShell/Blobs/blobinvertedrect.hpp +++ b/Plugins/ZShell/Blobs/blobinvertedrect.hpp @@ -16,25 +16,25 @@ public: explicit BlobInvertedRect(QQuickItem* parent = nullptr); ~BlobInvertedRect() override; -qreal borderLeft() const { +[[nodiscard]] qreal borderLeft() const { return m_borderLeft; } void setBorderLeft(qreal v); -qreal borderRight() const { +[[nodiscard]] qreal borderRight() const { return m_borderRight; } void setBorderRight(qreal v); -qreal borderTop() const { +[[nodiscard]] qreal borderTop() const { return m_borderTop; } void setBorderTop(qreal v); -qreal borderBottom() const { +[[nodiscard]] qreal borderBottom() const { return m_borderBottom; } @@ -47,7 +47,7 @@ void borderTopChanged(); void borderBottomChanged(); protected: -bool isInvertedRect() const override { +[[nodiscard]] bool isInvertedRect() const override { return true; } diff --git a/Plugins/ZShell/Blobs/blobmaterial.hpp b/Plugins/ZShell/Blobs/blobmaterial.hpp index 0a11f10..0d49d9f 100644 --- a/Plugins/ZShell/Blobs/blobmaterial.hpp +++ b/Plugins/ZShell/Blobs/blobmaterial.hpp @@ -21,8 +21,8 @@ struct BlobRectData { class BlobMaterial : public QSGMaterial { public: -QSGMaterialType* type() const override; -QSGMaterialShader* createShader(QSGRendererInterface::RenderMode) const override; +[[nodiscard]] QSGMaterialType* type() const override; +[[nodiscard]] QSGMaterialShader* createShader(QSGRendererInterface::RenderMode) const override; int compare(const QSGMaterial* other) const override; float m_paddedX = 0; diff --git a/Plugins/ZShell/Blobs/blobrect.hpp b/Plugins/ZShell/Blobs/blobrect.hpp index ce8abaf..11d9910 100644 --- a/Plugins/ZShell/Blobs/blobrect.hpp +++ b/Plugins/ZShell/Blobs/blobrect.hpp @@ -24,7 +24,7 @@ public: explicit BlobRect(QQuickItem* parent = nullptr); ~BlobRect() override; -qreal stiffness() const { +[[nodiscard]] qreal stiffness() const { return m_stiffness; } @@ -35,7 +35,7 @@ void setStiffness(qreal s) { } } -qreal damping() const { +[[nodiscard]] qreal damping() const { return m_damping; } @@ -46,7 +46,7 @@ void setDamping(qreal d) { } } -qreal deformScale() const { +[[nodiscard]] qreal deformScale() const { return m_deformScale; } @@ -62,25 +62,25 @@ QQmlListProperty exclude(); bool isExcluded(const BlobShape* other) const override; void cornerRadii(float out[4]) const override; -qreal topLeftRadius() const { +[[nodiscard]] qreal topLeftRadius() const { return m_topLeftRadius; } void setTopLeftRadius(qreal r); -qreal topRightRadius() const { +[[nodiscard]] qreal topRightRadius() const { return m_topRightRadius; } void setTopRightRadius(qreal r); -qreal bottomLeftRadius() const { +[[nodiscard]] qreal bottomLeftRadius() const { return m_bottomLeftRadius; } void setBottomLeftRadius(qreal r); -qreal bottomRightRadius() const { +[[nodiscard]] qreal bottomRightRadius() const { return m_bottomRightRadius; } diff --git a/Plugins/ZShell/Blobs/blobshape.hpp b/Plugins/ZShell/Blobs/blobshape.hpp index cfb60f4..12c8747 100644 --- a/Plugins/ZShell/Blobs/blobshape.hpp +++ b/Plugins/ZShell/Blobs/blobshape.hpp @@ -21,23 +21,23 @@ public: explicit BlobShape(QQuickItem* parent = nullptr); ~BlobShape() override = default; -BlobGroup* group() const { +[[nodiscard]] BlobGroup* group() const { return m_group; } void setGroup(BlobGroup* g); -qreal radius() const { +[[nodiscard]] qreal radius() const { return m_radius; } void setRadius(qreal r); -QMatrix4x4 deformMatrix() const { +[[nodiscard]] QMatrix4x4 deformMatrix() const { return m_centeredDeformMatrix; } -QMatrix4x4 rawDeformMatrix() const { +[[nodiscard]] QMatrix4x4 rawDeformMatrix() const { return m_deformMatrix; } @@ -53,7 +53,7 @@ void geometryChange(const QRectF& newGeometry, const QRectF& oldGeometry) overri void updatePolish() override; QSGNode* updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData*) override; -virtual bool isInvertedRect() const { +[[nodiscard]] virtual bool isInvertedRect() const { return false; } @@ -72,10 +72,9 @@ void updateCenteredDeformMatrix(); BlobGroup* m_group = nullptr; qreal m_radius = 0; -QMatrix4x4 m_deformMatrix; // identity by default +QMatrix4x4 m_deformMatrix; QMatrix4x4 m_centeredDeformMatrix; -// Cached data from updatePolish float m_cachedPaddedX = 0; float m_cachedPaddedY = 0; float m_cachedPaddedW = 0; @@ -84,10 +83,10 @@ QRectF m_localPaddedRect; QVector m_cachedRects; int m_cachedMyIndex = -2; float m_pendingDx = 0; - float m_pendingDy = 0; - float m_pendingDw = 0; - float m_pendingDh = 0; - bool m_cachedHasInverted = false; +float m_pendingDy = 0; +float m_pendingDw = 0; +float m_pendingDh = 0; +bool m_cachedHasInverted = false; float m_cachedInvertedRadius = 0; float m_cachedInvertedOuter[4] = {}; float m_cachedInvertedInner[4] = {}; diff --git a/Plugins/ZShell/Components/lazylistview.hpp b/Plugins/ZShell/Components/lazylistview.hpp index c1bc987..ca6a051 100644 --- a/Plugins/ZShell/Components/lazylistview.hpp +++ b/Plugins/ZShell/Components/lazylistview.hpp @@ -9,7 +9,7 @@ #include #include -namespace ZShell::components { +namespace ZShell::Components { class LazyListViewAttached : public QObject { Q_OBJECT diff --git a/Plugins/ZShell/Internal/arcgauge.hpp b/Plugins/ZShell/Internal/arcgauge.hpp index 453fd59..3946947 100644 --- a/Plugins/ZShell/Internal/arcgauge.hpp +++ b/Plugins/ZShell/Internal/arcgauge.hpp @@ -5,7 +5,7 @@ #include #include -namespace ZShell::internal { +namespace ZShell::Internal { class ArcGauge : public QQuickPaintedItem { Q_OBJECT @@ -58,4 +58,4 @@ qreal m_sweepAngle = 1.5 * M_PI; qreal m_lineWidth = 10.0; }; -} // namespace ZShell::internal +} // namespace ZShell::Internal diff --git a/Plugins/ZShell/Internal/cachingimagemanager.hpp b/Plugins/ZShell/Internal/cachingimagemanager.hpp index 242f92b..01c3d86 100644 --- a/Plugins/ZShell/Internal/cachingimagemanager.hpp +++ b/Plugins/ZShell/Internal/cachingimagemanager.hpp @@ -4,62 +4,63 @@ #include #include -namespace ZShell::internal { +namespace ZShell::Internal { class CachingImageManager : public QObject { - Q_OBJECT - QML_ELEMENT +Q_OBJECT +QML_ELEMENT - Q_PROPERTY(QQuickItem* item READ item WRITE setItem NOTIFY itemChanged REQUIRED) - Q_PROPERTY(QUrl cacheDir READ cacheDir WRITE setCacheDir NOTIFY cacheDirChanged REQUIRED) +Q_PROPERTY(QQuickItem* item READ item WRITE setItem NOTIFY itemChanged REQUIRED) +Q_PROPERTY(QUrl cacheDir READ cacheDir WRITE setCacheDir NOTIFY cacheDirChanged REQUIRED) - Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged) - Q_PROPERTY(QUrl cachePath READ cachePath NOTIFY cachePathChanged) +Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged) +Q_PROPERTY(QUrl cachePath READ cachePath NOTIFY cachePathChanged) public: - explicit CachingImageManager(QObject* parent = nullptr) - : QObject(parent) - , m_item(nullptr) {} +explicit CachingImageManager(QObject* parent = nullptr) + : QObject(parent) + , m_item(nullptr) { +} - [[nodiscard]] QQuickItem* item() const; - void setItem(QQuickItem* item); +[[nodiscard]] QQuickItem* item() const; +void setItem(QQuickItem* item); - [[nodiscard]] QUrl cacheDir() const; - void setCacheDir(const QUrl& cacheDir); +[[nodiscard]] QUrl cacheDir() const; +void setCacheDir(const QUrl& cacheDir); - [[nodiscard]] QString path() const; - void setPath(const QString& path); +[[nodiscard]] QString path() const; +void setPath(const QString& path); - [[nodiscard]] QUrl cachePath() const; +[[nodiscard]] QUrl cachePath() const; - Q_INVOKABLE void updateSource(); - Q_INVOKABLE void updateSource(const QString& path); +Q_INVOKABLE void updateSource(); +Q_INVOKABLE void updateSource(const QString& path); signals: - void itemChanged(); - void cacheDirChanged(); +void itemChanged(); +void cacheDirChanged(); - void pathChanged(); - void cachePathChanged(); - void usingCacheChanged(); +void pathChanged(); +void cachePathChanged(); +void usingCacheChanged(); private: - QString m_shaPath; +QString m_shaPath; - QQuickItem* m_item; - QUrl m_cacheDir; +QQuickItem* m_item; +QUrl m_cacheDir; - QString m_path; - QUrl m_cachePath; +QString m_path; +QUrl m_cachePath; - QMetaObject::Connection m_widthConn; - QMetaObject::Connection m_heightConn; +QMetaObject::Connection m_widthConn; +QMetaObject::Connection m_heightConn; - [[nodiscard]] qreal effectiveScale() const; - [[nodiscard]] QSize effectiveSize() const; +[[nodiscard]] qreal effectiveScale() const; +[[nodiscard]] QSize effectiveSize() const; - void createCache(const QString& path, const QString& cache, const QString& fillMode, const QSize& size) const; - [[nodiscard]] static QString sha256sum(const QString& path); +void createCache(const QString& path, const QString& cache, const QString& fillMode, const QSize& size) const; +[[nodiscard]] static QString sha256sum(const QString& path); }; } // namespace ZShell::internal diff --git a/Plugins/ZShell/Internal/circularbuffer.hpp b/Plugins/ZShell/Internal/circularbuffer.hpp index 763500e..e552d51 100644 --- a/Plugins/ZShell/Internal/circularbuffer.hpp +++ b/Plugins/ZShell/Internal/circularbuffer.hpp @@ -4,7 +4,7 @@ #include #include -namespace ZShell::internal { +namespace ZShell::Internal { class CircularBuffer : public QObject { Q_OBJECT diff --git a/Plugins/ZShell/Internal/circularindicatormanager.hpp b/Plugins/ZShell/Internal/circularindicatormanager.hpp index c119c53..6241336 100644 --- a/Plugins/ZShell/Internal/circularindicatormanager.hpp +++ b/Plugins/ZShell/Internal/circularindicatormanager.hpp @@ -1,10 +1,11 @@ #pragma once +#include #include #include #include -namespace ZShell::internal { +namespace ZShell::Internal { class CircularIndicatorManager : public QObject { Q_OBJECT @@ -24,7 +25,7 @@ Q_PROPERTY(IndeterminateAnimationType indeterminateAnimationType READ indetermin public: explicit CircularIndicatorManager(QObject* parent = nullptr); -enum IndeterminateAnimationType { +enum IndeterminateAnimationType: std::uint8_t { Advance = 0, Retreat }; diff --git a/Plugins/ZShell/Internal/hyprdevices.hpp b/Plugins/ZShell/Internal/hyprdevices.hpp index 4d1d342..8c70387 100644 --- a/Plugins/ZShell/Internal/hyprdevices.hpp +++ b/Plugins/ZShell/Internal/hyprdevices.hpp @@ -5,70 +5,70 @@ #include #include -namespace ZShell::internal::hypr { +namespace ZShell::Internal::Hypr { class HyprKeyboard : public QObject { - Q_OBJECT - QML_ELEMENT - QML_UNCREATABLE("HyprKeyboard instances can only be retrieved from a HyprDevices") +Q_OBJECT +QML_ELEMENT + QML_UNCREATABLE("HyprKeyboard instances can only be retrieved from a HyprDevices") - Q_PROPERTY(QVariantHash lastIpcObject READ lastIpcObject NOTIFY lastIpcObjectChanged) - Q_PROPERTY(QString address READ address NOTIFY addressChanged) - Q_PROPERTY(QString name READ name NOTIFY nameChanged) - Q_PROPERTY(QString layout READ layout NOTIFY layoutChanged) - Q_PROPERTY(QString activeKeymap READ activeKeymap NOTIFY activeKeymapChanged) - Q_PROPERTY(bool capsLock READ capsLock NOTIFY capsLockChanged) - Q_PROPERTY(bool numLock READ numLock NOTIFY numLockChanged) - Q_PROPERTY(bool main READ main NOTIFY mainChanged) +Q_PROPERTY(QVariantHash lastIpcObject READ lastIpcObject NOTIFY lastIpcObjectChanged) +Q_PROPERTY(QString address READ address NOTIFY addressChanged) +Q_PROPERTY(QString name READ name NOTIFY nameChanged) +Q_PROPERTY(QString layout READ layout NOTIFY layoutChanged) +Q_PROPERTY(QString activeKeymap READ activeKeymap NOTIFY activeKeymapChanged) +Q_PROPERTY(bool capsLock READ capsLock NOTIFY capsLockChanged) +Q_PROPERTY(bool numLock READ numLock NOTIFY numLockChanged) +Q_PROPERTY(bool main READ main NOTIFY mainChanged) public: - explicit HyprKeyboard(QJsonObject ipcObject, QObject* parent = nullptr); +explicit HyprKeyboard(QJsonObject ipcObject, QObject* parent = nullptr); - [[nodiscard]] QVariantHash lastIpcObject() const; - [[nodiscard]] QString address() const; - [[nodiscard]] QString name() const; - [[nodiscard]] QString layout() const; - [[nodiscard]] QString activeKeymap() const; - [[nodiscard]] bool capsLock() const; - [[nodiscard]] bool numLock() const; - [[nodiscard]] bool main() const; +[[nodiscard]] QVariantHash lastIpcObject() const; +[[nodiscard]] QString address() const; +[[nodiscard]] QString name() const; +[[nodiscard]] QString layout() const; +[[nodiscard]] QString activeKeymap() const; +[[nodiscard]] bool capsLock() const; +[[nodiscard]] bool numLock() const; +[[nodiscard]] bool main() const; - bool updateLastIpcObject(QJsonObject object); +bool updateLastIpcObject(QJsonObject object); signals: - void lastIpcObjectChanged(); - void addressChanged(); - void nameChanged(); - void layoutChanged(); - void activeKeymapChanged(); - void capsLockChanged(); - void numLockChanged(); - void mainChanged(); +void lastIpcObjectChanged(); +void addressChanged(); +void nameChanged(); +void layoutChanged(); +void activeKeymapChanged(); +void capsLockChanged(); +void numLockChanged(); +void mainChanged(); private: - QJsonObject m_lastIpcObject; +QJsonObject m_lastIpcObject; }; class HyprDevices : public QObject { - Q_OBJECT - QML_ELEMENT - QML_UNCREATABLE("HyprDevices instances can only be retrieved from a HyprExtras") +Q_OBJECT +QML_ELEMENT + QML_UNCREATABLE("HyprDevices instances can only be retrieved from a HyprExtras") - Q_PROPERTY( - QQmlListProperty keyboards READ keyboards NOTIFY keyboardsChanged) +Q_PROPERTY( + QQmlListProperty keyboards READ keyboards NOTIFY keyboardsChanged) public: - explicit HyprDevices(QObject* parent = nullptr); +explicit HyprDevices(QObject* parent = nullptr); - [[nodiscard]] QQmlListProperty keyboards(); +[[nodiscard]] QQmlListProperty keyboards(); - bool updateLastIpcObject(QJsonObject object); +bool updateLastIpcObject(QJsonObject object); signals: - void keyboardsChanged(); +void keyboardsChanged(); private: - QList m_keyboards; +QList m_keyboards; }; } // namespace ZShell::internal::hypr diff --git a/Plugins/ZShell/Internal/hyprextras.hpp b/Plugins/ZShell/Internal/hyprextras.hpp index afcac8d..583665e 100644 --- a/Plugins/ZShell/Internal/hyprextras.hpp +++ b/Plugins/ZShell/Internal/hyprextras.hpp @@ -10,7 +10,7 @@ #include #include -namespace ZShell::internal::hypr { +namespace ZShell::Internal::Hypr { class HyprDevices; diff --git a/Plugins/ZShell/Internal/lidwatcher.hpp b/Plugins/ZShell/Internal/lidwatcher.hpp index 4016f16..4f6ebac 100644 --- a/Plugins/ZShell/Internal/lidwatcher.hpp +++ b/Plugins/ZShell/Internal/lidwatcher.hpp @@ -3,7 +3,7 @@ #include #include -namespace ZShell::internal { +namespace ZShell::Internal { class LidWatcher : public QObject { Q_OBJECT diff --git a/Plugins/ZShell/Internal/sparklineitem.hpp b/Plugins/ZShell/Internal/sparklineitem.hpp index 0583da8..551ca18 100644 --- a/Plugins/ZShell/Internal/sparklineitem.hpp +++ b/Plugins/ZShell/Internal/sparklineitem.hpp @@ -7,7 +7,7 @@ #include "circularbuffer.hpp" -namespace ZShell::internal { +namespace ZShell::Internal { class SparklineItem : public QQuickPaintedItem { Q_OBJECT diff --git a/Plugins/ZShell/Internal/wallpaperimage.hpp b/Plugins/ZShell/Internal/wallpaperimage.hpp index 04cb4ed..ae4ff12 100644 --- a/Plugins/ZShell/Internal/wallpaperimage.hpp +++ b/Plugins/ZShell/Internal/wallpaperimage.hpp @@ -7,7 +7,7 @@ #include #include -namespace ZShell::internal { +namespace ZShell::Internal { class WallpaperImage : public QQuickItem { Q_OBJECT diff --git a/Plugins/ZShell/Models/filesystemmodel.hpp b/Plugins/ZShell/Models/filesystemmodel.hpp index f2bbfcd..0287f28 100644 --- a/Plugins/ZShell/Models/filesystemmodel.hpp +++ b/Plugins/ZShell/Models/filesystemmodel.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -10,139 +11,139 @@ #include #include -namespace ZShell::models { +namespace ZShell::Models { class FileSystemEntry : public QObject { - Q_OBJECT - QML_ELEMENT - QML_UNCREATABLE("FileSystemEntry instances can only be retrieved from a FileSystemModel") +Q_OBJECT +QML_ELEMENT + QML_UNCREATABLE("FileSystemEntry instances can only be retrieved from a FileSystemModel") - Q_PROPERTY(QString path READ path CONSTANT) - Q_PROPERTY(QString relativePath READ relativePath NOTIFY relativePathChanged) - Q_PROPERTY(QString name READ name CONSTANT) - Q_PROPERTY(QString baseName READ baseName CONSTANT) - Q_PROPERTY(QString parentDir READ parentDir CONSTANT) - Q_PROPERTY(QString suffix READ suffix CONSTANT) - Q_PROPERTY(qint64 size READ size CONSTANT) - Q_PROPERTY(bool isDir READ isDir CONSTANT) - Q_PROPERTY(bool isImage READ isImage CONSTANT) - Q_PROPERTY(QString mimeType READ mimeType CONSTANT) +Q_PROPERTY(QString path READ path CONSTANT) +Q_PROPERTY(QString relativePath READ relativePath NOTIFY relativePathChanged) +Q_PROPERTY(QString name READ name CONSTANT) +Q_PROPERTY(QString baseName READ baseName CONSTANT) +Q_PROPERTY(QString parentDir READ parentDir CONSTANT) +Q_PROPERTY(QString suffix READ suffix CONSTANT) +Q_PROPERTY(qint64 size READ size CONSTANT) +Q_PROPERTY(bool isDir READ isDir CONSTANT) +Q_PROPERTY(bool isImage READ isImage CONSTANT) +Q_PROPERTY(QString mimeType READ mimeType CONSTANT) public: - explicit FileSystemEntry(const QString& path, const QString& relativePath, QObject* parent = nullptr); +explicit FileSystemEntry(const QString& path, const QString& relativePath, QObject* parent = nullptr); - [[nodiscard]] QString path() const; - [[nodiscard]] QString relativePath() const; - [[nodiscard]] QString name() const; - [[nodiscard]] QString baseName() const; - [[nodiscard]] QString parentDir() const; - [[nodiscard]] QString suffix() const; - [[nodiscard]] qint64 size() const; - [[nodiscard]] bool isDir() const; - [[nodiscard]] bool isImage() const; - [[nodiscard]] QString mimeType() const; +[[nodiscard]] QString path() const; +[[nodiscard]] QString relativePath() const; +[[nodiscard]] QString name() const; +[[nodiscard]] QString baseName() const; +[[nodiscard]] QString parentDir() const; +[[nodiscard]] QString suffix() const; +[[nodiscard]] qint64 size() const; +[[nodiscard]] bool isDir() const; +[[nodiscard]] bool isImage() const; +[[nodiscard]] QString mimeType() const; - void updateRelativePath(const QDir& dir); +void updateRelativePath(const QDir& dir); signals: - void relativePathChanged(); +void relativePathChanged(); private: - const QFileInfo m_fileInfo; +const QFileInfo m_fileInfo; - const QString m_path; - QString m_relativePath; +const QString m_path; +QString m_relativePath; - mutable bool m_isImage; - mutable bool m_isImageInitialised; +mutable bool m_isImage; +mutable bool m_isImageInitialised; - mutable QString m_mimeType; - mutable bool m_mimeTypeInitialised; +mutable QString m_mimeType; +mutable bool m_mimeTypeInitialised; }; class FileSystemModel : public QAbstractListModel { - Q_OBJECT - QML_ELEMENT +Q_OBJECT +QML_ELEMENT - Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged) - Q_PROPERTY(bool recursive READ recursive WRITE setRecursive NOTIFY recursiveChanged) - Q_PROPERTY(bool watchChanges READ watchChanges WRITE setWatchChanges NOTIFY watchChangesChanged) - Q_PROPERTY(bool showHidden READ showHidden WRITE setShowHidden NOTIFY showHiddenChanged) - Q_PROPERTY(bool sortReverse READ sortReverse WRITE setSortReverse NOTIFY sortReverseChanged) - Q_PROPERTY(Filter filter READ filter WRITE setFilter NOTIFY filterChanged) - Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters NOTIFY nameFiltersChanged) +Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged) +Q_PROPERTY(bool recursive READ recursive WRITE setRecursive NOTIFY recursiveChanged) +Q_PROPERTY(bool watchChanges READ watchChanges WRITE setWatchChanges NOTIFY watchChangesChanged) +Q_PROPERTY(bool showHidden READ showHidden WRITE setShowHidden NOTIFY showHiddenChanged) +Q_PROPERTY(bool sortReverse READ sortReverse WRITE setSortReverse NOTIFY sortReverseChanged) +Q_PROPERTY(Filter filter READ filter WRITE setFilter NOTIFY filterChanged) +Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters NOTIFY nameFiltersChanged) - Q_PROPERTY(QQmlListProperty entries READ entries NOTIFY entriesChanged) +Q_PROPERTY(QQmlListProperty entries READ entries NOTIFY entriesChanged) public: - enum Filter { - NoFilter, - Images, - Files, - Dirs - }; - Q_ENUM(Filter) +enum Filter: std::uint8_t { + NoFilter, + Images, + Files, + Dirs +}; +Q_ENUM(Filter) - explicit FileSystemModel(QObject* parent = nullptr); +explicit FileSystemModel(QObject* parent = nullptr); - int rowCount(const QModelIndex& parent = QModelIndex()) const override; - QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; - QHash roleNames() const override; +[[nodiscard]] int rowCount(const QModelIndex& parent = QModelIndex()) const override; +[[nodiscard]] QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; +[[nodiscard]] QHash roleNames() const override; - [[nodiscard]] QString path() const; - void setPath(const QString& path); +[[nodiscard]] QString path() const; +void setPath(const QString& path); - [[nodiscard]] bool recursive() const; - void setRecursive(bool recursive); +[[nodiscard]] bool recursive() const; +void setRecursive(bool recursive); - [[nodiscard]] bool watchChanges() const; - void setWatchChanges(bool watchChanges); +[[nodiscard]] bool watchChanges() const; +void setWatchChanges(bool watchChanges); - [[nodiscard]] bool showHidden() const; - void setShowHidden(bool showHidden); +[[nodiscard]] bool showHidden() const; +void setShowHidden(bool showHidden); - [[nodiscard]] bool sortReverse() const; - void setSortReverse(bool sortReverse); +[[nodiscard]] bool sortReverse() const; +void setSortReverse(bool sortReverse); - [[nodiscard]] Filter filter() const; - void setFilter(Filter filter); +[[nodiscard]] Filter filter() const; +void setFilter(Filter filter); - [[nodiscard]] QStringList nameFilters() const; - void setNameFilters(const QStringList& nameFilters); +[[nodiscard]] QStringList nameFilters() const; +void setNameFilters(const QStringList& nameFilters); - [[nodiscard]] QQmlListProperty entries(); +[[nodiscard]] QQmlListProperty entries(); signals: - void pathChanged(); - void recursiveChanged(); - void watchChangesChanged(); - void showHiddenChanged(); - void sortReverseChanged(); - void filterChanged(); - void nameFiltersChanged(); - void entriesChanged(); +void pathChanged(); +void recursiveChanged(); +void watchChangesChanged(); +void showHiddenChanged(); +void sortReverseChanged(); +void filterChanged(); +void nameFiltersChanged(); +void entriesChanged(); private: - QDir m_dir; - QFileSystemWatcher m_watcher; - QList m_entries; - QHash, QSet>>> m_futures; +QDir m_dir; +QFileSystemWatcher m_watcher; +QList m_entries; +QHash, QSet > > > m_futures; - QString m_path; - bool m_recursive; - bool m_watchChanges; - bool m_showHidden; - bool m_sortReverse; - Filter m_filter; - QStringList m_nameFilters; +QString m_path; +bool m_recursive; +bool m_watchChanges; +bool m_showHidden; +bool m_sortReverse; +Filter m_filter; +QStringList m_nameFilters; - void watchDirIfRecursive(const QString& path); - void update(); - void updateWatcher(); - void updateEntries(); - void updateEntriesForDir(const QString& dir); - void applyChanges(const QSet& removedPaths, const QSet& addedPaths); - [[nodiscard]] bool compareEntries(const FileSystemEntry* a, const FileSystemEntry* b) const; +void watchDirIfRecursive(const QString& path); +void update(); +void updateWatcher(); +void updateEntries(); +void updateEntriesForDir(const QString& dir); +void applyChanges(const QSet& removedPaths, const QSet& addedPaths); +[[nodiscard]] bool compareEntries(const FileSystemEntry* a, const FileSystemEntry* b) const; }; } // namespace ZShell::models diff --git a/Plugins/ZShell/Services/audiocollector.hpp b/Plugins/ZShell/Services/audiocollector.hpp index d3f3ce1..bb5e60e 100644 --- a/Plugins/ZShell/Services/audiocollector.hpp +++ b/Plugins/ZShell/Services/audiocollector.hpp @@ -10,7 +10,7 @@ #include #include -namespace ZShell::services { +namespace ZShell::Services { namespace ac { @@ -59,7 +59,7 @@ quint32 readChunk(double* out, quint32 count = 0); private: explicit AudioCollector(QObject* parent = nullptr); -~AudioCollector(); +~AudioCollector() override; std::jthread m_thread; std::vector m_buffer1; diff --git a/Plugins/ZShell/Services/audioprovider.hpp b/Plugins/ZShell/Services/audioprovider.hpp index 32f95cb..03d9ea7 100644 --- a/Plugins/ZShell/Services/audioprovider.hpp +++ b/Plugins/ZShell/Services/audioprovider.hpp @@ -4,18 +4,17 @@ #include #include -namespace ZShell::services { +namespace ZShell::Services { class AudioProcessor : public QObject { Q_OBJECT public: explicit AudioProcessor(QObject* parent = nullptr); -~AudioProcessor(); +~AudioProcessor() override; void init(); -public slots: void start(); void stop(); @@ -31,7 +30,7 @@ Q_OBJECT public: explicit AudioProvider(QObject* parent = nullptr); -~AudioProvider(); +~AudioProvider() override; protected: AudioProcessor* m_processor; diff --git a/Plugins/ZShell/Services/beattracker.hpp b/Plugins/ZShell/Services/beattracker.hpp index 301a962..4982572 100644 --- a/Plugins/ZShell/Services/beattracker.hpp +++ b/Plugins/ZShell/Services/beattracker.hpp @@ -11,7 +11,7 @@ Q_OBJECT public: explicit BeatProcessor(QObject* parent = nullptr); -~BeatProcessor(); +~BeatProcessor() override; signals: void beat(smpl_t bpm); diff --git a/Plugins/ZShell/Services/cavaprovider.hpp b/Plugins/ZShell/Services/cavaprovider.hpp index 88dc18e..5bfd8e9 100644 --- a/Plugins/ZShell/Services/cavaprovider.hpp +++ b/Plugins/ZShell/Services/cavaprovider.hpp @@ -11,7 +11,7 @@ Q_OBJECT public: explicit CavaProcessor(QObject* parent = nullptr); -~CavaProcessor(); +~CavaProcessor() override; void setBars(int bars); diff --git a/Plugins/ZShell/Services/desktopmodel.hpp b/Plugins/ZShell/Services/desktopmodel.hpp index d04dcd2..2674c78 100644 --- a/Plugins/ZShell/Services/desktopmodel.hpp +++ b/Plugins/ZShell/Services/desktopmodel.hpp @@ -4,8 +4,9 @@ #include #include #include +#include -namespace ZShell::services { +namespace ZShell::Services { struct DesktopItem { QString fileName; @@ -20,7 +21,7 @@ Q_OBJECT QML_ELEMENT public: -enum DesktopRoles { +enum DesktopRoles: std::uint16_t { FileNameRole = Qt::UserRole + 1, FilePathRole, IsDirRole, @@ -30,9 +31,9 @@ enum DesktopRoles { explicit DesktopModel(QObject *parent = nullptr); -int rowCount(const QModelIndex &parent = QModelIndex()) const override; -QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; -QHash roleNames() const override; +[[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override; +[[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; +[[nodiscard]] QHash roleNames() const override; Q_INVOKABLE void loadDirectory(const QString &path); Q_INVOKABLE void moveIcon(int index, int newX, int newY); @@ -43,4 +44,4 @@ QList m_items; void saveCurrentLayout(); }; -} // namespace ZShell::services +} // namespace ZShell::Services diff --git a/Plugins/ZShell/Services/desktopstatemanager.hpp b/Plugins/ZShell/Services/desktopstatemanager.hpp index 004b7bb..d7cb24d 100644 --- a/Plugins/ZShell/Services/desktopstatemanager.hpp +++ b/Plugins/ZShell/Services/desktopstatemanager.hpp @@ -4,7 +4,7 @@ #include #include -namespace ZShell::services { +namespace ZShell::Services { class DesktopStateManager : public QObject { Q_OBJECT @@ -18,7 +18,7 @@ Q_INVOKABLE void saveLayout(const QVariantMap& layout); Q_INVOKABLE QVariantMap getLayout(); private: -QString getConfigFilePath() const; +[[nodiscard]] QString getConfigFilePath() const; }; } // namespace ZShell::services diff --git a/Plugins/ZShell/Services/hyprsunsetmanager.hpp b/Plugins/ZShell/Services/hyprsunsetmanager.hpp index ebdbda9..37ba758 100644 --- a/Plugins/ZShell/Services/hyprsunsetmanager.hpp +++ b/Plugins/ZShell/Services/hyprsunsetmanager.hpp @@ -7,7 +7,7 @@ #include #include -namespace ZShell::services { +namespace ZShell::Services { class HyprsunsetManager : public QObject { Q_OBJECT diff --git a/Plugins/ZShell/Services/service.hpp b/Plugins/ZShell/Services/service.hpp index 3bb47b9..87b2d15 100644 --- a/Plugins/ZShell/Services/service.hpp +++ b/Plugins/ZShell/Services/service.hpp @@ -3,7 +3,7 @@ #include #include -namespace ZShell::services { +namespace ZShell::Services { class Service : public QObject { Q_OBJECT diff --git a/Plugins/ZShell/appdb.hpp b/Plugins/ZShell/appdb.hpp index cf1b257..48c7187 100644 --- a/Plugins/ZShell/appdb.hpp +++ b/Plugins/ZShell/appdb.hpp @@ -9,98 +9,98 @@ namespace ZShell { class AppEntry : public QObject { - Q_OBJECT - QML_ELEMENT - QML_UNCREATABLE("AppEntry instances can only be retrieved from an AppDb") +Q_OBJECT +QML_ELEMENT + QML_UNCREATABLE("AppEntry instances can only be retrieved from an AppDb") - // The actual DesktopEntry, but we don't have access to the type so it's a QObject - Q_PROPERTY(QObject* entry READ entry CONSTANT) +// The actual DesktopEntry, but we don't have access to the type so it's a QObject +Q_PROPERTY(QObject* entry READ entry CONSTANT) - Q_PROPERTY(quint32 frequency READ frequency NOTIFY frequencyChanged) - Q_PROPERTY(QString id READ id CONSTANT) - Q_PROPERTY(QString name READ name NOTIFY nameChanged) - Q_PROPERTY(QString comment READ comment NOTIFY commentChanged) - Q_PROPERTY(QString execString READ execString NOTIFY execStringChanged) - Q_PROPERTY(QString startupClass READ startupClass NOTIFY startupClassChanged) - Q_PROPERTY(QString genericName READ genericName NOTIFY genericNameChanged) - Q_PROPERTY(QString categories READ categories NOTIFY categoriesChanged) - Q_PROPERTY(QString keywords READ keywords NOTIFY keywordsChanged) +Q_PROPERTY(quint32 frequency READ frequency NOTIFY frequencyChanged) +Q_PROPERTY(QString id READ id CONSTANT) +Q_PROPERTY(QString name READ name NOTIFY nameChanged) +Q_PROPERTY(QString comment READ comment NOTIFY commentChanged) +Q_PROPERTY(QString execString READ execString NOTIFY execStringChanged) +Q_PROPERTY(QString startupClass READ startupClass NOTIFY startupClassChanged) +Q_PROPERTY(QString genericName READ genericName NOTIFY genericNameChanged) +Q_PROPERTY(QString categories READ categories NOTIFY categoriesChanged) +Q_PROPERTY(QString keywords READ keywords NOTIFY keywordsChanged) public: - explicit AppEntry(QObject* entry, quint32 frequency, QObject* parent = nullptr); +explicit AppEntry(QObject* entry, quint32 frequency, QObject* parent = nullptr); - [[nodiscard]] QObject* entry() const; +[[nodiscard]] QObject* entry() const; - [[nodiscard]] quint32 frequency() const; - void setFrequency(quint32 frequency); - void incrementFrequency(); +[[nodiscard]] quint32 frequency() const; +void setFrequency(quint32 frequency); +void incrementFrequency(); - [[nodiscard]] QString id() const; - [[nodiscard]] QString name() const; - [[nodiscard]] QString comment() const; - [[nodiscard]] QString execString() const; - [[nodiscard]] QString startupClass() const; - [[nodiscard]] QString genericName() const; - [[nodiscard]] QString categories() const; - [[nodiscard]] QString keywords() const; +[[nodiscard]] QString id() const; +[[nodiscard]] QString name() const; +[[nodiscard]] QString comment() const; +[[nodiscard]] QString execString() const; +[[nodiscard]] QString startupClass() const; +[[nodiscard]] QString genericName() const; +[[nodiscard]] QString categories() const; +[[nodiscard]] QString keywords() const; signals: - void frequencyChanged(); - void nameChanged(); - void commentChanged(); - void execStringChanged(); - void startupClassChanged(); - void genericNameChanged(); - void categoriesChanged(); - void keywordsChanged(); +void frequencyChanged(); +void nameChanged(); +void commentChanged(); +void execStringChanged(); +void startupClassChanged(); +void genericNameChanged(); +void categoriesChanged(); +void keywordsChanged(); private: - QObject* m_entry; - quint32 m_frequency; +QObject* m_entry; +quint32 m_frequency; }; class AppDb : public QObject { - Q_OBJECT - QML_ELEMENT +Q_OBJECT +QML_ELEMENT - Q_PROPERTY(QString uuid READ uuid CONSTANT) - Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged REQUIRED) - Q_PROPERTY(QObjectList entries READ entries WRITE setEntries NOTIFY entriesChanged REQUIRED) - Q_PROPERTY(QQmlListProperty apps READ apps NOTIFY appsChanged) +Q_PROPERTY(QString uuid READ uuid CONSTANT) +Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged REQUIRED) +Q_PROPERTY(QObjectList entries READ entries WRITE setEntries NOTIFY entriesChanged REQUIRED) +Q_PROPERTY(QQmlListProperty apps READ apps NOTIFY appsChanged) public: - explicit AppDb(QObject* parent = nullptr); +explicit AppDb(QObject* parent = nullptr); - [[nodiscard]] QString uuid() const; +[[nodiscard]] QString uuid() const; - [[nodiscard]] QString path() const; - void setPath(const QString& path); +[[nodiscard]] QString path() const; +void setPath(const QString& path); - [[nodiscard]] QObjectList entries() const; - void setEntries(const QObjectList& entries); +[[nodiscard]] QObjectList entries() const; +void setEntries(const QObjectList& entries); - [[nodiscard]] QQmlListProperty apps(); +[[nodiscard]] QQmlListProperty apps(); - Q_INVOKABLE void incrementFrequency(const QString& id); +Q_INVOKABLE void incrementFrequency(const QString& id); signals: - void pathChanged(); - void entriesChanged(); - void appsChanged(); +void pathChanged(); +void entriesChanged(); +void appsChanged(); private: - QTimer* m_timer; +QTimer* m_timer; - const QString m_uuid; - QString m_path; - QObjectList m_entries; - QHash m_apps; - mutable QList m_sortedApps; +const QString m_uuid; +QString m_path; +QObjectList m_entries; +QHash m_apps; +mutable QList m_sortedApps; - QList& getSortedApps() const; - quint32 getFrequency(const QString& id) const; - void updateAppFrequencies(); - void updateApps(); +QList& getSortedApps() const; +quint32 getFrequency(const QString& id) const; +void updateAppFrequencies(); +void updateApps(); }; } // namespace ZShell diff --git a/Plugins/ZShell/imageanalyser.hpp b/Plugins/ZShell/imageanalyser.hpp index 829669e..8871617 100644 --- a/Plugins/ZShell/imageanalyser.hpp +++ b/Plugins/ZShell/imageanalyser.hpp @@ -9,53 +9,53 @@ namespace ZShell { class ImageAnalyser : public QObject { - Q_OBJECT - QML_ELEMENT +Q_OBJECT +QML_ELEMENT - Q_PROPERTY(QString source READ source WRITE setSource NOTIFY sourceChanged) - Q_PROPERTY(QQuickItem* sourceItem READ sourceItem WRITE setSourceItem NOTIFY sourceItemChanged) - Q_PROPERTY(int rescaleSize READ rescaleSize WRITE setRescaleSize NOTIFY rescaleSizeChanged) - Q_PROPERTY(QColor dominantColour READ dominantColour NOTIFY dominantColourChanged) - Q_PROPERTY(qreal luminance READ luminance NOTIFY luminanceChanged) +Q_PROPERTY(QString source READ source WRITE setSource NOTIFY sourceChanged) +Q_PROPERTY(QQuickItem* sourceItem READ sourceItem WRITE setSourceItem NOTIFY sourceItemChanged) +Q_PROPERTY(int rescaleSize READ rescaleSize WRITE setRescaleSize NOTIFY rescaleSizeChanged) +Q_PROPERTY(QColor dominantColour READ dominantColour NOTIFY dominantColourChanged) +Q_PROPERTY(qreal luminance READ luminance NOTIFY luminanceChanged) public: - explicit ImageAnalyser(QObject* parent = nullptr); +explicit ImageAnalyser(QObject* parent = nullptr); - [[nodiscard]] QString source() const; - void setSource(const QString& source); +[[nodiscard]] QString source() const; +void setSource(const QString& source); - [[nodiscard]] QQuickItem* sourceItem() const; - void setSourceItem(QQuickItem* sourceItem); +[[nodiscard]] QQuickItem* sourceItem() const; +void setSourceItem(QQuickItem* sourceItem); - [[nodiscard]] int rescaleSize() const; - void setRescaleSize(int rescaleSize); +[[nodiscard]] int rescaleSize() const; +void setRescaleSize(int rescaleSize); - [[nodiscard]] QColor dominantColour() const; - [[nodiscard]] qreal luminance() const; +[[nodiscard]] QColor dominantColour() const; +[[nodiscard]] qreal luminance() const; - Q_INVOKABLE void requestUpdate(); +Q_INVOKABLE void requestUpdate(); signals: - void sourceChanged(); - void sourceItemChanged(); - void rescaleSizeChanged(); - void dominantColourChanged(); - void luminanceChanged(); +void sourceChanged(); +void sourceItemChanged(); +void rescaleSizeChanged(); +void dominantColourChanged(); +void luminanceChanged(); private: - using AnalyseResult = QPair; +using AnalyseResult = QPair; - QFutureWatcher* const m_futureWatcher; +QFutureWatcher* const m_futureWatcher; - QString m_source; - QQuickItem* m_sourceItem; - int m_rescaleSize; +QString m_source; +QQuickItem* m_sourceItem; +int m_rescaleSize; - QColor m_dominantColour; - qreal m_luminance; +QColor m_dominantColour; +qreal m_luminance; - void update(); - static void analyse(QPromise& promise, const QImage& image, int rescaleSize); +void update(); +static void analyse(QPromise& promise, const QImage& image, int rescaleSize); }; } // namespace ZShell diff --git a/Plugins/ZShell/qalculator.hpp b/Plugins/ZShell/qalculator.hpp index 348a4b7..67051a6 100644 --- a/Plugins/ZShell/qalculator.hpp +++ b/Plugins/ZShell/qalculator.hpp @@ -13,7 +13,7 @@ QML_SINGLETON public: explicit Qalculator(QObject* parent = nullptr); -Q_INVOKABLE QString eval(const QString& expr, bool printExpr = true) const; +Q_INVOKABLE [[nodiscard]] QString eval(const QString& expr, bool printExpr = true) const; }; } // namespace ZShell diff --git a/Plugins/ZShell/toaster.hpp b/Plugins/ZShell/toaster.hpp index 0fb0d53..cb50042 100644 --- a/Plugins/ZShell/toaster.hpp +++ b/Plugins/ZShell/toaster.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -20,7 +21,7 @@ Q_PROPERTY(int timeout READ timeout CONSTANT) Q_PROPERTY(Type type READ type CONSTANT) public: -enum class Type { +enum class Type: std::uint8_t { Info = 0, Success, Warning, diff --git a/Plugins/ZShell/writefile.hpp b/Plugins/ZShell/writefile.hpp index a74d897..458d4d9 100644 --- a/Plugins/ZShell/writefile.hpp +++ b/Plugins/ZShell/writefile.hpp @@ -29,9 +29,9 @@ Q_INVOKABLE void cacheImage(const QUrl& source, const QString& cacheDir, QJSValu Q_INVOKABLE void cacheImage(const QUrl& source, const QString& cacheDir, QJSValue onSaved, QJSValue onFailed); // clang-format on -Q_INVOKABLE bool copyFile(const QUrl& source, const QUrl& target, bool overwrite = true) const; -Q_INVOKABLE bool deleteFile(const QUrl& path) const; -Q_INVOKABLE QString toLocalFile(const QUrl& url) const; +Q_INVOKABLE [[nodiscard]] bool copyFile(const QUrl& source, const QUrl& target, bool overwrite = true) const; +Q_INVOKABLE [[nodiscard]] bool deleteFile(const QUrl& path) const; +Q_INVOKABLE [[nodiscard]] QString toLocalFile(const QUrl& url) const; private: bool loadSourceImage(const QUrl& source, QImage& image) const;