summaryrefslogtreecommitdiff
path: root/plugin/src/Caelestia/cutils.hpp
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-08-31 14:34:22 +1000
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-08-31 14:34:22 +1000
commitd66f4ca0f37d585a86145c0a27e79e89c3a815c8 (patch)
treeb5cebc4457e9c02f4eb20ff23abbe0613375b21e /plugin/src/Caelestia/cutils.hpp
parent[CI] chore: update flake (diff)
downloadcaelestia-shell-d66f4ca0f37d585a86145c0a27e79e89c3a815c8.tar.gz
caelestia-shell-d66f4ca0f37d585a86145c0a27e79e89c3a815c8.tar.bz2
caelestia-shell-d66f4ca0f37d585a86145c0a27e79e89c3a815c8.zip
plugin/cutils: add getAverageLuminance
Fixes stutters in wallpaper list Also fix crash when saveItem target doesn't have a window
Diffstat (limited to 'plugin/src/Caelestia/cutils.hpp')
-rw-r--r--plugin/src/Caelestia/cutils.hpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/plugin/src/Caelestia/cutils.hpp b/plugin/src/Caelestia/cutils.hpp
index 08fad41..048a2ff 100644
--- a/plugin/src/Caelestia/cutils.hpp
+++ b/plugin/src/Caelestia/cutils.hpp
@@ -20,6 +20,17 @@ public:
Q_INVOKABLE bool copyFile(const QUrl& source, const QUrl& target) const;
Q_INVOKABLE bool copyFile(const QUrl& source, const QUrl& target, bool overwrite) const;
- Q_INVOKABLE void getDominantColour(QQuickItem* item, QJSValue callback) const;
- Q_INVOKABLE void getDominantColour(QQuickItem* item, int width, int height, QJSValue callback) const;
+ Q_INVOKABLE void getDominantColour(QQuickItem* item, QJSValue callback);
+ Q_INVOKABLE void getDominantColour(QQuickItem* item, int rescaleSize, QJSValue callback);
+ Q_INVOKABLE void getDominantColour(const QString& path, QJSValue callback);
+ Q_INVOKABLE void getDominantColour(const QString& path, int rescaleSize, QJSValue callback);
+
+ Q_INVOKABLE void getAverageLuminance(QQuickItem* item, QJSValue callback);
+ Q_INVOKABLE void getAverageLuminance(QQuickItem* item, int rescaleSize, QJSValue callback);
+ Q_INVOKABLE void getAverageLuminance(const QString& path, QJSValue callback);
+ Q_INVOKABLE void getAverageLuminance(const QString& path, int rescaleSize, QJSValue callback);
+
+private:
+ QColor findDominantColour(const QImage& image, int rescaleSize) const;
+ qreal findAverageLuminance(const QImage& image, int rescaleSize) const;
};