diff --git a/Plugins/ZShell/Blobs/blobgroup.cpp b/Plugins/ZShell/Blobs/blobgroup.cpp index 40d7487..c286650 100644 --- a/Plugins/ZShell/Blobs/blobgroup.cpp +++ b/Plugins/ZShell/Blobs/blobgroup.cpp @@ -26,8 +26,7 @@ void BlobGroup::setColor(const QColor& c) { } void BlobGroup::setCornerFill(bool e) { - if (m_cornerFill == e) - return; + if (m_cornerFill == e) return; m_cornerFill = e; emit cornerFillChanged(); markDirty(); diff --git a/Plugins/ZShell/Blobs/blobgroup.hpp b/Plugins/ZShell/Blobs/blobgroup.hpp index c8bebde..eb3ca35 100644 --- a/Plugins/ZShell/Blobs/blobgroup.hpp +++ b/Plugins/ZShell/Blobs/blobgroup.hpp @@ -9,11 +9,15 @@ class BlobShape; class BlobInvertedRect; class BlobGroup : public QObject { -Q_OBJECT -QML_ELEMENT -Q_PROPERTY(qreal smoothing READ smoothing WRITE setSmoothing NOTIFY smoothingChanged) -Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) -Q_PROPERTY(bool cornerFill READ cornerFill WRITE setCornerFill NOTIFY cornerFillChanged) + Q_OBJECT + QML_ELEMENT + Q_PROPERTY( + qreal smoothing READ smoothing WRITE setSmoothing NOTIFY + smoothingChanged) + Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) + Q_PROPERTY( + bool cornerFill READ cornerFill WRITE setCornerFill NOTIFY + cornerFillChanged) public: explicit BlobGroup(QObject* parent = nullptr); @@ -27,14 +31,12 @@ Q_PROPERTY(bool cornerFill READ cornerFill WRITE setCornerFill NOTIFY cornerFill void setColor(const QColor& c); -[[nodiscard]] bool cornerFill() const { - return m_cornerFill; -} + [[nodiscard]] bool cornerFill() const { return m_cornerFill; } -void setCornerFill(bool e); + void setCornerFill(bool e); -void addShape(BlobShape* shape); -void removeShape(BlobShape* shape); + void addShape(BlobShape* shape); + void removeShape(BlobShape* shape); void setInvertedRect(BlobInvertedRect* rect); void clearInvertedRect(BlobInvertedRect* rect); @@ -49,16 +51,16 @@ void removeShape(BlobShape* shape); void markShapeDirty(BlobShape* source); void ensurePhysicsUpdated(); -signals: -void smoothingChanged(); -void colorChanged(); -void cornerFillChanged(); + signals: + void smoothingChanged(); + void colorChanged(); + void cornerFillChanged(); -private: -qreal m_smoothing = 32.0; -QColor m_color{ 0x44, 0x88, 0xff }; -bool m_cornerFill = true; -QList m_shapes; -BlobInvertedRect* m_invertedRect = nullptr; -bool m_physicsUpdated = false; + private: + qreal m_smoothing = 32.0; + QColor m_color{0x44, 0x88, 0xff}; + bool m_cornerFill = true; + QList m_shapes; + BlobInvertedRect* m_invertedRect = nullptr; + bool m_physicsUpdated = false; }; diff --git a/Plugins/ZShell/Blobs/blobrect.cpp b/Plugins/ZShell/Blobs/blobrect.cpp index 6c87135..f7dc72c 100644 --- a/Plugins/ZShell/Blobs/blobrect.cpp +++ b/Plugins/ZShell/Blobs/blobrect.cpp @@ -32,11 +32,9 @@ void BlobRect::updatePolish() { QMetaObject::invokeMethod( this, [this]() { - if (m_group) - m_group->markDirty(); - }, - Qt::QueuedConnection - ); + if (m_group) m_group->markDirty(); + }, + Qt::QueuedConnection); } } else { QMetaObject::invokeMethod( @@ -184,8 +182,7 @@ bool BlobRect::isExcluded(const BlobShape* other) const { bool BlobRect::isCornerExcluded(const BlobShape* other) const { for (const auto& ptr : m_excludeCorners) { - if (ptr == other) - return true; + if (ptr == other) return true; } return false; } @@ -203,8 +200,15 @@ QQmlListProperty BlobRect::exclude() { } QQmlListProperty BlobRect::excludeCorners() { - return QQmlListProperty(this, nullptr, &excludeCornersAppend, &excludeCornersCount, &excludeCornersAt, - &excludeCornersClear, &excludeCornersReplace, &excludeCornersRemoveLast); + return QQmlListProperty( + this, + nullptr, + &excludeCornersAppend, + &excludeCornersCount, + &excludeCornersAt, + &excludeCornersClear, + &excludeCornersReplace, + &excludeCornersRemoveLast); } void BlobRect::excludeAppend(QQmlListProperty* prop, BlobRect* rect) { @@ -249,11 +253,11 @@ void BlobRect::excludeRemoveLast(QQmlListProperty* prop) { emit self->excludeChanged(); } -void BlobRect::excludeCornersAppend(QQmlListProperty* prop, BlobRect* rect) { +void BlobRect::excludeCornersAppend( + QQmlListProperty* prop, BlobRect* rect) { auto* self = static_cast(prop->object); self->m_excludeCorners.append(rect); - if (self->m_group) - self->m_group->markDirty(); + if (self->m_group) self->m_group->markDirty(); emit self->excludeCornersChanged(); } @@ -262,36 +266,33 @@ qsizetype BlobRect::excludeCornersCount(QQmlListProperty* prop) { return self->m_excludeCorners.size(); } -BlobRect* BlobRect::excludeCornersAt(QQmlListProperty* prop, qsizetype index) { +BlobRect* BlobRect::excludeCornersAt( + QQmlListProperty* prop, qsizetype index) { auto* self = static_cast(prop->object); return self->m_excludeCorners.at(index); } void BlobRect::excludeCornersClear(QQmlListProperty* prop) { auto* self = static_cast(prop->object); - if (self->m_excludeCorners.isEmpty()) - return; + if (self->m_excludeCorners.isEmpty()) return; self->m_excludeCorners.clear(); - if (self->m_group) - self->m_group->markDirty(); + if (self->m_group) self->m_group->markDirty(); emit self->excludeCornersChanged(); } -void BlobRect::excludeCornersReplace(QQmlListProperty* prop, qsizetype index, BlobRect* rect) { +void BlobRect::excludeCornersReplace( + QQmlListProperty* prop, qsizetype index, BlobRect* rect) { auto* self = static_cast(prop->object); self->m_excludeCorners[index] = rect; - if (self->m_group) - self->m_group->markDirty(); + if (self->m_group) self->m_group->markDirty(); emit self->excludeCornersChanged(); } void BlobRect::excludeCornersRemoveLast(QQmlListProperty* prop) { auto* self = static_cast(prop->object); - if (self->m_excludeCorners.isEmpty()) - return; + if (self->m_excludeCorners.isEmpty()) return; self->m_excludeCorners.removeLast(); - if (self->m_group) - self->m_group->markDirty(); + if (self->m_group) self->m_group->markDirty(); emit self->excludeCornersChanged(); } @@ -319,11 +320,9 @@ void BlobRect::checkAtRest(float speed) { QMetaObject::invokeMethod( this, [this]() { - if (m_group) - m_group->markDirty(); - }, - Qt::QueuedConnection - ); + if (m_group) m_group->markDirty(); + }, + Qt::QueuedConnection); } } } diff --git a/Plugins/ZShell/Blobs/blobrect.hpp b/Plugins/ZShell/Blobs/blobrect.hpp index f99aa20..51a6157 100644 --- a/Plugins/ZShell/Blobs/blobrect.hpp +++ b/Plugins/ZShell/Blobs/blobrect.hpp @@ -8,18 +8,32 @@ #include class BlobRect : public BlobShape { -Q_OBJECT -QML_ELEMENT -Q_PROPERTY(qreal stiffness READ stiffness WRITE setStiffness NOTIFY stiffnessChanged) -Q_PROPERTY(qreal damping READ damping WRITE setDamping NOTIFY dampingChanged) -Q_PROPERTY(qreal deformScale READ deformScale WRITE setDeformScale NOTIFY deformScaleChanged) -Q_PROPERTY(QQmlListProperty exclude READ exclude NOTIFY excludeChanged) -Q_PROPERTY(QQmlListProperty excludeCorners READ excludeCorners NOTIFY excludeCornersChanged) -Q_PROPERTY(qreal topLeftRadius READ topLeftRadius WRITE setTopLeftRadius NOTIFY topLeftRadiusChanged) -Q_PROPERTY(qreal topRightRadius READ topRightRadius WRITE setTopRightRadius NOTIFY topRightRadiusChanged) -Q_PROPERTY(qreal bottomLeftRadius READ bottomLeftRadius WRITE setBottomLeftRadius NOTIFY bottomLeftRadiusChanged) -Q_PROPERTY( - qreal bottomRightRadius READ bottomRightRadius WRITE setBottomRightRadius NOTIFY bottomRightRadiusChanged) + Q_OBJECT + QML_ELEMENT + Q_PROPERTY( + qreal stiffness READ stiffness WRITE setStiffness NOTIFY + stiffnessChanged) + Q_PROPERTY(qreal damping READ damping WRITE setDamping NOTIFY dampingChanged) + Q_PROPERTY( + qreal deformScale READ deformScale WRITE setDeformScale NOTIFY + deformScaleChanged) + Q_PROPERTY( + QQmlListProperty exclude READ exclude NOTIFY excludeChanged) + Q_PROPERTY( + QQmlListProperty excludeCorners READ excludeCorners NOTIFY + excludeCornersChanged) + Q_PROPERTY( + qreal topLeftRadius READ topLeftRadius WRITE setTopLeftRadius NOTIFY + topLeftRadiusChanged) + Q_PROPERTY( + qreal topRightRadius READ topRightRadius WRITE setTopRightRadius NOTIFY + topRightRadiusChanged) + Q_PROPERTY( + qreal bottomLeftRadius READ bottomLeftRadius WRITE setBottomLeftRadius + NOTIFY bottomLeftRadiusChanged) + Q_PROPERTY( + qreal bottomRightRadius READ bottomRightRadius WRITE + setBottomRightRadius NOTIFY bottomRightRadiusChanged) public: explicit BlobRect(QQuickItem* parent = nullptr); @@ -52,12 +66,12 @@ Q_PROPERTY( } } -QQmlListProperty exclude(); -QQmlListProperty excludeCorners(); + QQmlListProperty exclude(); + QQmlListProperty excludeCorners(); -bool isExcluded(const BlobShape* other) const override; -bool isCornerExcluded(const BlobShape* other) const override; -void cornerRadii(float out[4]) const override; + bool isExcluded(const BlobShape* other) const override; + bool isCornerExcluded(const BlobShape* other) const override; + void cornerRadii(float out[4]) const override; [[nodiscard]] qreal topLeftRadius() const { return m_topLeftRadius; } @@ -77,16 +91,16 @@ void cornerRadii(float out[4]) const override; void setBottomRightRadius(qreal r); -signals: -void stiffnessChanged(); -void dampingChanged(); -void deformScaleChanged(); -void excludeChanged(); -void excludeCornersChanged(); -void topLeftRadiusChanged(); -void topRightRadiusChanged(); -void bottomLeftRadiusChanged(); -void bottomRightRadiusChanged(); + signals: + void stiffnessChanged(); + void dampingChanged(); + void deformScaleChanged(); + void excludeChanged(); + void excludeCornersChanged(); + void topLeftRadiusChanged(); + void topRightRadiusChanged(); + void bottomLeftRadiusChanged(); + void bottomRightRadiusChanged(); protected: void updatePolish() override; @@ -121,20 +135,25 @@ void bottomRightRadiusChanged(); qreal m_bottomLeftRadius = -1; qreal m_bottomRightRadius = -1; -QList > m_exclude; -QList > m_excludeCorners; + QList> m_exclude; + QList> m_excludeCorners; -static void excludeAppend(QQmlListProperty* prop, BlobRect* rect); -static qsizetype excludeCount(QQmlListProperty* prop); -static BlobRect* excludeAt(QQmlListProperty* prop, qsizetype index); -static void excludeClear(QQmlListProperty* prop); -static void excludeReplace(QQmlListProperty* prop, qsizetype index, BlobRect* rect); -static void excludeRemoveLast(QQmlListProperty* prop); + static void excludeAppend(QQmlListProperty* prop, BlobRect* rect); + static qsizetype excludeCount(QQmlListProperty* prop); + static BlobRect* excludeAt( + QQmlListProperty* prop, qsizetype index); + static void excludeClear(QQmlListProperty* prop); + static void excludeReplace( + QQmlListProperty* prop, qsizetype index, BlobRect* rect); + static void excludeRemoveLast(QQmlListProperty* prop); -static void excludeCornersAppend(QQmlListProperty* prop, BlobRect* rect); -static qsizetype excludeCornersCount(QQmlListProperty* prop); -static BlobRect* excludeCornersAt(QQmlListProperty* prop, qsizetype index); -static void excludeCornersClear(QQmlListProperty* prop); -static void excludeCornersReplace(QQmlListProperty* prop, qsizetype index, BlobRect* rect); -static void excludeCornersRemoveLast(QQmlListProperty* prop); + static void excludeCornersAppend( + QQmlListProperty* prop, BlobRect* rect); + static qsizetype excludeCornersCount(QQmlListProperty* prop); + static BlobRect* excludeCornersAt( + QQmlListProperty* prop, qsizetype index); + static void excludeCornersClear(QQmlListProperty* prop); + static void excludeCornersReplace( + QQmlListProperty* prop, qsizetype index, BlobRect* rect); + static void excludeCornersRemoveLast(QQmlListProperty* prop); }; diff --git a/Plugins/ZShell/Blobs/blobshape.cpp b/Plugins/ZShell/Blobs/blobshape.cpp index 6d7cec2..99d4eec 100644 --- a/Plugins/ZShell/Blobs/blobshape.cpp +++ b/Plugins/ZShell/Blobs/blobshape.cpp @@ -38,8 +38,7 @@ static float cornerFillFactor(float sd, float smoothFactor) { return std::max(outside, inside); } -BlobShape::BlobShape(QQuickItem* parent) - : QQuickItem(parent) { +BlobShape::BlobShape(QQuickItem* parent) : QQuickItem(parent) { setFlag(ItemHasContents); } @@ -312,13 +311,10 @@ void BlobShape::updatePolish() { const float cTlX = ri.cx - ri.hw, cTlY = ri.cy - ri.hh; for (qsizetype j = 0; cornerFill && j < rectCount; ++j) { - if (j == i) - continue; - if (riExcludeMask & (1 << j)) - continue; + if (j == i) continue; + if (riExcludeMask & (1 << j)) continue; BlobShape* const sj = rectShapes[j]; - if (si->isCornerExcluded(sj) || sj->isCornerExcluded(si)) - continue; + if (si->isCornerExcluded(sj) || sj->isCornerExcluded(si)) continue; const auto& rj = m_cachedRects[j]; const float sdTr = cpuSdBox(cTrX, cTrY, rj.cx, rj.cy, rj.hw, rj.hh); const float sdBr = cpuSdBox(cBrX, cBrY, rj.cx, rj.cy, rj.hw, rj.hh); diff --git a/Plugins/ZShell/Blobs/blobshape.hpp b/Plugins/ZShell/Blobs/blobshape.hpp index e5a297c..8bdc4da 100644 --- a/Plugins/ZShell/Blobs/blobshape.hpp +++ b/Plugins/ZShell/Blobs/blobshape.hpp @@ -55,11 +55,11 @@ class BlobShape : public QQuickItem { virtual bool isExcluded(const BlobShape*) const { return false; } -virtual bool isCornerExcluded(const BlobShape* /*other*/) const { - return false; -} + virtual bool isCornerExcluded(const BlobShape* /*other*/) const { + return false; + } -virtual void cornerRadii(float out[4]) const; + virtual void cornerRadii(float out[4]) const; virtual void updatePhysics() {} @@ -67,25 +67,25 @@ virtual void cornerRadii(float out[4]) const; virtual void unregisterFromGroup(); void updateCenteredDeformMatrix(); -BlobGroup* m_group = nullptr; -qreal m_radius = 0; -QMatrix4x4 m_deformMatrix; // identity by default -QMatrix4x4 m_centeredDeformMatrix; + BlobGroup* m_group = nullptr; + qreal m_radius = 0; + QMatrix4x4 m_deformMatrix; // identity by default + QMatrix4x4 m_centeredDeformMatrix; -// Cached data from updatePolish -float m_cachedPaddedX = 0; -float m_cachedPaddedY = 0; -float m_cachedPaddedW = 0; -float m_cachedPaddedH = 0; -float m_pendingDw = 0; -float m_pendingDh = 0; -QRectF m_localPaddedRect; -QVector m_cachedRects; -int m_cachedMyIndex = -2; -float m_pendingDx = 0; -float m_pendingDy = 0; -bool m_cachedHasInverted = false; -float m_cachedInvertedRadius = 0; -float m_cachedInvertedOuter[4] = {}; -float m_cachedInvertedInner[4] = {}; + // Cached data from updatePolish + float m_cachedPaddedX = 0; + float m_cachedPaddedY = 0; + float m_cachedPaddedW = 0; + float m_cachedPaddedH = 0; + float m_pendingDw = 0; + float m_pendingDh = 0; + QRectF m_localPaddedRect; + QVector m_cachedRects; + int m_cachedMyIndex = -2; + float m_pendingDx = 0; + float m_pendingDy = 0; + bool m_cachedHasInverted = false; + float m_cachedInvertedRadius = 0; + float m_cachedInvertedOuter[4] = {}; + float m_cachedInvertedInner[4] = {}; }; diff --git a/Plugins/ZShell/appdb.cpp b/Plugins/ZShell/appdb.cpp index c66ac59..e095174 100644 --- a/Plugins/ZShell/appdb.cpp +++ b/Plugins/ZShell/appdb.cpp @@ -10,23 +10,28 @@ Q_LOGGING_CATEGORY(lcAppDb, "ZShell.appdb", QtInfoMsg) namespace ZShell { AppEntry::AppEntry(QObject* entry, unsigned int frequency, QObject* parent) - : QObject(parent) - , m_entry(entry) - , m_frequency(frequency) { + : QObject(parent), m_entry(entry), m_frequency(frequency) { const auto mo = m_entry->metaObject(); const auto tmo = &AppEntry::staticMetaObject; for (const auto& prop : - { "name", "comment", "execString", "startupClass", "genericName", "categories", "keywords" }) { + {"name", + "comment", + "execString", + "startupClass", + "genericName", + "categories", + "keywords"}) { const auto metaProp = mo->property(mo->indexOfProperty(prop)); const auto thisMetaProp = tmo->property(tmo->indexOfProperty(prop)); - QObject::connect(m_entry, metaProp.notifySignal(), this, thisMetaProp.notifySignal()); + QObject::connect( + m_entry, metaProp.notifySignal(), this, thisMetaProp.notifySignal()); } QObject::connect(m_entry, &QObject::destroyed, this, [this]() { - m_entry = nullptr; - deleteLater(); - }); + m_entry = nullptr; + deleteLater(); + }); } QObject* AppEntry::entry() const { @@ -118,7 +123,9 @@ AppDb::AppDb(QObject* parent) db.open(); QSqlQuery query(db); - query.exec("CREATE TABLE IF NOT EXISTS frequencies (id TEXT PRIMARY KEY, frequency INTEGER)"); + query.exec( + "CREATE TABLE IF NOT EXISTS frequencies (id TEXT PRIMARY KEY, " + "frequency INTEGER)"); } QString AppDb::uuid() const { @@ -145,7 +152,9 @@ void AppDb::setPath(const QString& path) { db.open(); QSqlQuery query(db); - query.exec("CREATE TABLE IF NOT EXISTS frequencies (id TEXT PRIMARY KEY, frequency INTEGER)"); + query.exec( + "CREATE TABLE IF NOT EXISTS frequencies (id TEXT PRIMARY KEY, " + "frequency INTEGER)"); updateAppFrequencies(); } @@ -183,7 +192,9 @@ void AppDb::setFavoriteApps(const QStringList& favApps) { if (re.isValid()) { m_favoriteAppsRegex << re; } else { - qCWarning(lcAppDb) << "setFavoriteApps: regular expression is not valid:" << re.pattern(); + qCWarning(lcAppDb) + << "setFavoriteApps: regular expression is not valid:" + << re.pattern(); } } @@ -191,8 +202,7 @@ void AppDb::setFavoriteApps(const QStringList& favApps) { } QString AppDb::regexifyString(const QString& original) const { - if (original.startsWith('^') && original.endsWith('$')) - return original; + if (original.startsWith('^') && original.endsWith('$')) return original; const QString escaped = QRegularExpression::escape(original); return QStringLiteral("^%1$").arg(escaped); @@ -206,9 +216,10 @@ void AppDb::incrementFrequency(const QString& id) { auto db = QSqlDatabase::database(m_uuid); QSqlQuery query(db); - query.prepare("INSERT INTO frequencies (id, frequency) " - "VALUES (:id, 1) " - "ON CONFLICT (id) DO UPDATE SET frequency = frequency + 1"); + query.prepare( + "INSERT INTO frequencies (id, frequency) " + "VALUES (:id, 1) " + "ON CONFLICT (id) DO UPDATE SET frequency = frequency + 1"); query.bindValue(":id", id); query.exec(); @@ -221,7 +232,8 @@ void AppDb::incrementFrequency(const QString& id) { emit appsChanged(); } } else { - qCWarning(lcAppDb) << "incrementFrequency: could not find app with id" << id; + qCWarning(lcAppDb) << "incrementFrequency: could not find app with id" + << id; } } @@ -232,15 +244,16 @@ QList& AppDb::getSortedApps() const { QSet favSet; favSet.reserve(m_sortedApps.size()); for (const auto* app : std::as_const(m_sortedApps)) { - if (isFavorite(app)) - favSet.insert(app->id()); + if (isFavorite(app)) favSet.insert(app->id()); } - std::sort(m_sortedApps.begin(), m_sortedApps.end(), [&favSet](AppEntry* a, AppEntry* b) { + std::sort( + m_sortedApps.begin(), + m_sortedApps.end(), + [&favSet](AppEntry* a, AppEntry* b) { const bool aIsFav = favSet.contains(a->id()); const bool bIsFav = favSet.contains(b->id()); - if (aIsFav != bIsFav) - return aIsFav; + if (aIsFav != bIsFav) return aIsFav; if (a->frequency() != b->frequency()) return a->frequency() > b->frequency(); return a->name().localeAwareCompare(b->name()) < 0; @@ -293,10 +306,10 @@ void AppDb::updateApps() { dirty = true; auto* const newEntry = new AppEntry(entry, getFrequency(id), this); QObject::connect(newEntry, &QObject::destroyed, this, [id, this]() { - if (m_apps.remove(id)) { - emit appsChanged(); - } - }); + if (m_apps.remove(id)) { + emit appsChanged(); + } + }); m_apps.insert(id, newEntry); } } diff --git a/Plugins/ZShell/appdb.hpp b/Plugins/ZShell/appdb.hpp index 2e2a723..f0f328f 100644 --- a/Plugins/ZShell/appdb.hpp +++ b/Plugins/ZShell/appdb.hpp @@ -65,11 +65,16 @@ class AppDb : public QObject { 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(QStringList favoriteApps READ favoriteApps WRITE setFavoriteApps NOTIFY favoriteAppsChanged 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( + QStringList favoriteApps READ favoriteApps WRITE setFavoriteApps NOTIFY + favoriteAppsChanged REQUIRED) + Q_PROPERTY( + QQmlListProperty apps READ apps NOTIFY appsChanged) public: explicit AppDb(QObject* parent = nullptr); @@ -82,36 +87,36 @@ Q_PROPERTY(QQmlListProperty apps READ apps NOTIFY appsChanged) [[nodiscard]] QObjectList entries() const; void setEntries(const QObjectList& entries); -[[nodiscard]] QStringList favoriteApps() const; -void setFavoriteApps(const QStringList& favApps); + [[nodiscard]] QStringList favoriteApps() const; + void setFavoriteApps(const QStringList& favApps); -[[nodiscard]] QQmlListProperty apps(); + [[nodiscard]] QQmlListProperty apps(); Q_INVOKABLE void incrementFrequency(const QString& id); -signals: -void pathChanged(); -void entriesChanged(); -void favoriteAppsChanged(); -void appsChanged(); + signals: + void pathChanged(); + void entriesChanged(); + void favoriteAppsChanged(); + void appsChanged(); private: QTimer* m_timer; -const QString m_uuid; -QString m_path; -QObjectList m_entries; -QStringList m_favoriteApps; -QList m_favoriteAppsRegex; -QHash m_apps; -mutable QList m_sortedApps; + const QString m_uuid; + QString m_path; + QObjectList m_entries; + QStringList m_favoriteApps; + QList m_favoriteAppsRegex; + QHash m_apps; + mutable QList m_sortedApps; -QString regexifyString(const QString& original) const; -QList& getSortedApps() const; -bool isFavorite(const AppEntry* app) const; -quint32 getFrequency(const QString& id) const; -void updateAppFrequencies(); -void updateApps(); + QString regexifyString(const QString& original) const; + QList& getSortedApps() const; + bool isFavorite(const AppEntry* app) const; + quint32 getFrequency(const QString& id) const; + void updateAppFrequencies(); + void updateApps(); }; } // namespace ZShell diff --git a/Plugins/ZShell/zutils.hpp b/Plugins/ZShell/zutils.hpp index 97bdaaf..1e037cf 100644 --- a/Plugins/ZShell/zutils.hpp +++ b/Plugins/ZShell/zutils.hpp @@ -12,18 +12,18 @@ class ZUtils : public QObject { QML_ELEMENT QML_SINGLETON -Q_PROPERTY(QString version READ version CONSTANT) -Q_PROPERTY(QString qtVersion READ qtVersion CONSTANT) + Q_PROPERTY(QString version READ version CONSTANT) + Q_PROPERTY(QString qtVersion READ qtVersion CONSTANT) -public: -// clang-format off -Q_INVOKABLE void saveItem(QQuickItem* target, const QUrl& path); -Q_INVOKABLE void saveItem(QQuickItem* target, const QUrl& path, const QRect& rect); -Q_INVOKABLE void saveItem(QQuickItem* target, const QUrl& path, QJSValue onSaved); -Q_INVOKABLE void saveItem(QQuickItem* target, const QUrl& path, QJSValue onSaved, QJSValue onFailed); -Q_INVOKABLE void saveItem(QQuickItem* target, const QUrl& path, const QRect& rect, QJSValue onSaved); -Q_INVOKABLE void saveItem(QQuickItem* target, const QUrl& path, const QRect& rect, QJSValue onSaved, QJSValue onFailed); -// clang-format on + public: + // clang-format off + Q_INVOKABLE void saveItem(QQuickItem* target, const QUrl& path); + Q_INVOKABLE void saveItem(QQuickItem* target, const QUrl& path, const QRect& rect); + Q_INVOKABLE void saveItem(QQuickItem* target, const QUrl& path, QJSValue onSaved); + Q_INVOKABLE void saveItem(QQuickItem* target, const QUrl& path, QJSValue onSaved, QJSValue onFailed); + Q_INVOKABLE void saveItem(QQuickItem* target, const QUrl& path, const QRect& rect, QJSValue onSaved); + Q_INVOKABLE void saveItem(QQuickItem* target, const QUrl& path, const QRect& rect, QJSValue onSaved, QJSValue onFailed); + // clang-format on Q_INVOKABLE static bool copyFile( const QUrl& source, const QUrl& target, bool overwrite = true);