From 2339ea9bb6010640de9c2992c97ca3c8b40dcf66 Mon Sep 17 00:00:00 2001 From: Fushan Wen Date: Thu, 30 Jun 2022 16:18:37 +0800 Subject: [PATCH] wallpapers/image: force reload wallpaper after target size changes When the target size changes while the provider type is single image or the current wallpaper is animated, the frontend is required to force update the wallpaper. --- wallpapers/image/imagepackage/contents/ui/main.qml | 1 + wallpapers/image/plugin/utils/mediaproxy.cpp | 5 +++++ wallpapers/image/plugin/utils/mediaproxy.h | 7 +++++++ 3 files changed, 13 insertions(+) diff --git a/wallpapers/image/imagepackage/contents/ui/main.qml b/wallpapers/image/imagepackage/contents/ui/main.qml index aa8b3ec21..a23a86999 100644 --- a/wallpapers/image/imagepackage/contents/ui/main.qml +++ b/wallpapers/image/imagepackage/contents/ui/main.qml @@ -89,6 +89,7 @@ QQC2.StackView { } targetSize: root.sourceSize + onActualSizeChanged: Qt.callLater(loadImage); onColorSchemeChanged: loadImageImmediately(); } diff --git a/wallpapers/image/plugin/utils/mediaproxy.cpp b/wallpapers/image/plugin/utils/mediaproxy.cpp index 27c2ce65d..6f4cb8661 100644 --- a/wallpapers/image/plugin/utils/mediaproxy.cpp +++ b/wallpapers/image/plugin/utils/mediaproxy.cpp @@ -91,8 +91,13 @@ void MediaProxy::setTargetSize(const QSize &size) Q_EMIT targetSizeChanged(size); if (m_providerType == Provider::Type::Package) { + determineBackgroundType(); // In case file format changes after size changes updateModelImage(); } + if (m_providerType == Provider::Type::Image || m_backgroundType == BackgroundType::Type::AnimatedImage) { + // When KPackage contains animated wallpapers, image provider is not used. + Q_EMIT actualSizeChanged(); + } } Provider::Type MediaProxy::providerType() const diff --git a/wallpapers/image/plugin/utils/mediaproxy.h b/wallpapers/image/plugin/utils/mediaproxy.h index b76c33eca..e21c7dd1a 100644 --- a/wallpapers/image/plugin/utils/mediaproxy.h +++ b/wallpapers/image/plugin/utils/mediaproxy.h @@ -77,6 +77,13 @@ Q_SIGNALS: void targetSizeChanged(const QSize &size); + /** + * Emitted when the target size changes while the provider type is single image + * or the current wallpaper is animated. + * The frontend is required to force update the wallpaper. + */ + void actualSizeChanged(); + /** * Emitted when system color scheme changes. The frontend is required to * reload the wallpaper even if the image path is not changed.