From c0ca8f2c79c9b0e9f6db47dd86a1434d4e3de5bb Mon Sep 17 00:00:00 2001 From: Ismael Asensio Date: Sat, 21 Sep 2019 16:15:04 +0200 Subject: [dolphin] Animate gifs on preview Summary: Adds the capability to view animated images on the preview in the information panel. This was a request from a user back in 2009 (https://bugs.kde.org/show_bug.cgi?id=182257), but I think nowadays with stickers/memes and what not, it's even more useful. It keeps the size default transition of the preview viewer before starting the animation, so that the visual integration is smoother. {F7289110} FEATURE: 182257 FIXED-IN: 19.11.80 Test Plan: Open the information panel and hover over some animated images (gif/webp/mng) Reviewers: #dolphin, #vdg, ngraham, elvisangelaccio Reviewed By: #vdg, ngraham Subscribers: pino, fuksitter, meven, broulik, kfm-devel Tags: #dolphin Differential Revision: https://phabricator.kde.org/D23538 --- src/panels/information/pixmapviewer.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/panels/information/pixmapviewer.h') diff --git a/src/panels/information/pixmapviewer.h b/src/panels/information/pixmapviewer.h index 46e5cf5fc..37071045f 100644 --- a/src/panels/information/pixmapviewer.h +++ b/src/panels/information/pixmapviewer.h @@ -26,6 +26,7 @@ #include class QPaintEvent; +class QMovie; /** * @brief Widget which shows a pixmap centered inside the boundaries. @@ -73,20 +74,33 @@ public: void setSizeHint(const QSize& size); QSize sizeHint() const override; + void setAnimatedImageFileName(const QString& fileName); + QString animatedImageFileName() const; + + void stopAnimatedImage(); + + /** + * Checks if \a fileName contains an animated image supported by QMovie. + */ + static bool isAnimatedImage(const QString &fileName); + protected: void paintEvent(QPaintEvent* event) override; private Q_SLOTS: void checkPendingPixmaps(); + void updateAnimatedImageFrame(); private: QPixmap m_pixmap; QPixmap m_oldPixmap; + QMovie* m_animatedImage; QQueue m_pendingPixmaps; QTimeLine m_animation; Transition m_transition; int m_animationStep; QSize m_sizeHint; + bool m_hasAnimatedImage; }; inline QPixmap PixmapViewer::pixmap() const -- cgit v1.3