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/informationpanelcontent.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/panels/information/informationpanelcontent.cpp') diff --git a/src/panels/information/informationpanelcontent.cpp b/src/panels/information/informationpanelcontent.cpp index b051603fd..2a8682a12 100644 --- a/src/panels/information/informationpanelcontent.cpp +++ b/src/panels/information/informationpanelcontent.cpp @@ -169,6 +169,7 @@ void InformationPanelContent::showItem(const KFileItem& item) if (item != m_item) { m_item = item; + m_preview->stopAnimatedImage(); refreshMetaData(); } refreshPreview(); @@ -237,7 +238,8 @@ void InformationPanelContent::refreshPreview() refreshPixmapView(); const QString mimeType = m_item.mimetype(); - m_isVideo = mimeType.startsWith(QLatin1String("video/")); + const bool isAnimatedImage = m_preview->isAnimatedImage(itemUrl.toLocalFile()); + m_isVideo = !isAnimatedImage && mimeType.startsWith(QLatin1String("video/")); usePhonon = m_isVideo || mimeType.startsWith(QLatin1String("audio/")); if (usePhonon) { @@ -268,6 +270,9 @@ void InformationPanelContent::refreshPreview() adjustWidgetSizes(parentWidget()->width()); } } else { + if (isAnimatedImage) { + m_preview->setAnimatedImageFileName(itemUrl.toLocalFile()); + } // When we don't need it, hide the phonon widget first to avoid flickering m_phononWidget->hide(); m_preview->show(); @@ -276,6 +281,7 @@ void InformationPanelContent::refreshPreview() } } } else { + m_preview->stopAnimatedImage(); m_preview->hide(); m_phononWidget->hide(); } @@ -303,6 +309,8 @@ void InformationPanelContent::showItems(const KFileItemList& items) m_previewJob->kill(); } + m_preview->stopAnimatedImage(); + m_preview->setPixmap( QIcon::fromTheme(QStringLiteral("dialog-information")).pixmap(KIconLoader::SizeEnormous, KIconLoader::SizeEnormous) ); -- cgit v1.3