summaryrefslogtreecommitdiff
path: root/plugin/src/Caelestia/cachingimagemanager.cpp
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-08-30 17:05:49 +1000
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-08-30 17:05:49 +1000
commit95bf6e3f52e539e4883d30beed5b9044c39c0127 (patch)
treecdc13d20a10ca6e7272a162564ae3c7be6855774 /plugin/src/Caelestia/cachingimagemanager.cpp
parentplugin/cim: respect image fill mode (diff)
downloadcaelestia-shell-95bf6e3f52e539e4883d30beed5b9044c39c0127.tar.gz
caelestia-shell-95bf6e3f52e539e4883d30beed5b9044c39c0127.tar.bz2
caelestia-shell-95bf6e3f52e539e4883d30beed5b9044c39c0127.zip
plugin/cim: fix cache path
Different cache paths for different fill modes
Diffstat (limited to 'plugin/src/Caelestia/cachingimagemanager.cpp')
-rw-r--r--plugin/src/Caelestia/cachingimagemanager.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/plugin/src/Caelestia/cachingimagemanager.cpp b/plugin/src/Caelestia/cachingimagemanager.cpp
index bbfadff..320b195 100644
--- a/plugin/src/Caelestia/cachingimagemanager.cpp
+++ b/plugin/src/Caelestia/cachingimagemanager.cpp
@@ -111,7 +111,10 @@ void CachingImageManager::updateSource(const QString& path) {
int width = effectiveWidth();
int height = effectiveHeight();
- const QString filename = QString("%1@%2x%3.png").arg(sha).arg(width).arg(height);
+ const QString fillMode = m_item->property("fillMode").toString();
+ const QString filename = QString("%1@%2x%3-%4.png")
+ .arg(sha).arg(width).arg(height)
+ .arg(fillMode == "PreserveAspectCrop" ? "crop" : fillMode == "PreserveAspectFit" ? "fit" : "stretch");
const QUrl cache = m_cacheDir.resolved(QUrl(filename));
if (m_cachePath == cache) {
@@ -132,7 +135,7 @@ void CachingImageManager::updateSource(const QString& path) {
m_item->setProperty("source", cache);
} else {
m_item->setProperty("source", QUrl::fromLocalFile(path));
- createCache(path, cache.toLocalFile(), QSize(width, height));
+ createCache(path, cache.toLocalFile(), fillMode, QSize(width, height));
}
// Clear current running sha if same
@@ -147,10 +150,8 @@ QUrl CachingImageManager::cachePath() const {
return m_cachePath;
}
-void CachingImageManager::createCache(const QString& path, const QString& cache, const QSize& size) const {
- QString fillMode = m_item->property("fillMode").toString();
-
- QThreadPool::globalInstance()->start([fillMode, path, cache, size] {
+void CachingImageManager::createCache(const QString& path, const QString& cache, const QString& fillMode, const QSize& size) const {
+ QThreadPool::globalInstance()->start([path, cache, fillMode, size] {
QImage image(path);
if (image.isNull()) {