diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-08-27 20:32:51 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-08-27 20:32:51 +1000 |
| commit | 4f60c07e0540f89654b469d134095c37e238d3e8 (patch) | |
| tree | 6853439cce6933475898c608d4d846fd91fde6f5 /plugin/src/Caelestia/cachingimagemanager.hpp | |
| parent | internal: move notif icon lower (diff) | |
| download | caelestia-shell-4f60c07e0540f89654b469d134095c37e238d3e8.tar.gz caelestia-shell-4f60c07e0540f89654b469d134095c37e238d3e8.tar.bz2 caelestia-shell-4f60c07e0540f89654b469d134095c37e238d3e8.zip | |
plugin: create caching image manager
No need for external proc
Diffstat (limited to 'plugin/src/Caelestia/cachingimagemanager.hpp')
| -rw-r--r-- | plugin/src/Caelestia/cachingimagemanager.hpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/plugin/src/Caelestia/cachingimagemanager.hpp b/plugin/src/Caelestia/cachingimagemanager.hpp new file mode 100644 index 0000000..e2cbd41 --- /dev/null +++ b/plugin/src/Caelestia/cachingimagemanager.hpp @@ -0,0 +1,57 @@ +#pragma once + +#include <qobject.h> +#include <qqmlintegration.h> +#include <QtQuick/QQuickItem> + +class CachingImageManager : public QObject { + 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(QString path READ path WRITE setPath NOTIFY pathChanged); + Q_PROPERTY(QUrl cachePath READ cachePath NOTIFY cachePathChanged); + Q_PROPERTY(bool usingCache READ usingCache NOTIFY usingCacheChanged); + +public: + explicit CachingImageManager(QObject* parent = nullptr): QObject(parent) {}; + + [[nodiscard]] QQuickItem* item() const; + void setItem(QQuickItem* item); + + [[nodiscard]] QUrl cacheDir() const; + void setCacheDir(const QUrl& cacheDir); + + [[nodiscard]] QString path() const; + void setPath(const QString& path); + + [[nodiscard]] QUrl cachePath() const; + [[nodiscard]] bool usingCache() const; + +signals: + void itemChanged(); + void cacheDirChanged(); + + void pathChanged(); + void cachePathChanged(); + void usingCacheChanged(); + +private slots: + void handleStatusChanged(); + +private: + QQuickItem* m_item; + QUrl m_cacheDir; + + QString m_path; + QUrl m_cachePath; + bool m_usingCache; + + [[nodiscard]] qreal effectiveScale() const; + int effectiveWidth() const; + int effectiveHeight() const; + + [[nodiscard]] QString sha256sum(const QString& path) const; +}; |