┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/panels/information/informationpanelcontent.cpp
diff options
context:
space:
mode:
authorMéven Car <[email protected]>2019-04-14 16:54:54 +0200
committerMéven Car <[email protected]>2019-06-23 16:38:09 +0200
commite6c1b97d67f6b6c6d4ad935db14241b041b3fca4 (patch)
treef0325a8b9ce9836b9e2149fcfd90ac23b0f044f5 /src/panels/information/informationpanelcontent.cpp
parentcdad6a513e2cbd4376dd03bb4fa63681076eb18b (diff)
Allow dolphin to auto-play previewed media file, click on preview to play/pause videos or audio
Summary: It is based on D19844. I did my best to avoid glitches hence the amount of code touched. Retry after @pekkah D7539 Moved the setting to the information panel context menu, no more timer Settings screenshot : {F6700220} This would mach the same feature in the open/save dialog (although not equivalent) {F6696456} FEATURE: 378613 FIXED-IN: 19.08.0 GUI: New information panel context menu option Test Plan: Without auto play - in dolphin with the information panel opened, and the auto media play feature is disabled (right on the information panel) - hover over media files - the behavior is the same as before the patch With auto play - in dolphin with the information panel opened, and the auto media play feature is enabled - hover over media files - media is played automatically - hover over another media file, the new media is previewed Use audio or video file as media. Reviewers: #dolphin, elvisangelaccio, ngraham Reviewed By: #dolphin, elvisangelaccio, ngraham Subscribers: ngraham, broulik, kfm-devel, pekkah Tags: #dolphin Differential Revision: https://phabricator.kde.org/D19782
Diffstat (limited to 'src/panels/information/informationpanelcontent.cpp')
-rw-r--r--src/panels/information/informationpanelcontent.cpp33
1 files changed, 27 insertions, 6 deletions
diff --git a/src/panels/information/informationpanelcontent.cpp b/src/panels/information/informationpanelcontent.cpp
index 5b7dbbfe9..444261eff 100644
--- a/src/panels/information/informationpanelcontent.cpp
+++ b/src/panels/information/informationpanelcontent.cpp
@@ -86,6 +86,7 @@ InformationPanelContent::InformationPanelContent(QWidget* parent) :
m_phononWidget = new PhononWidget(parent);
m_phononWidget->hide();
m_phononWidget->setMinimumWidth(minPreviewWidth);
+ m_phononWidget->setAutoPlay(InformationPanelSettings::previewsAutoPlay());
connect(m_phononWidget, &PhononWidget::hasVideoChanged,
this, &InformationPanelContent::slotHasVideoChanged);
@@ -157,10 +158,12 @@ InformationPanelContent::~InformationPanelContent()
void InformationPanelContent::showItem(const KFileItem& item)
{
- m_item = item;
+ if (item != m_item) {
+ m_item = item;
- refreshPreview();
- refreshMetaData();
+ refreshPreview();
+ refreshMetaData();
+ }
}
void InformationPanelContent::refreshPreview()
@@ -173,11 +176,12 @@ void InformationPanelContent::refreshPreview()
setNameLabelText(m_item.text());
if (InformationPanelSettings::previewsShown()) {
- m_preview->show();
const QUrl itemUrl = m_item.url();
const bool isSearchUrl = itemUrl.scheme().contains(QStringLiteral("search")) && m_item.localPath().isEmpty();
if (isSearchUrl) {
+ m_preview->show();
+
// in the case of a search-URL the URL is not readable for humans
// (at least not useful to show in the Information Panel)
m_preview->setPixmap(
@@ -211,13 +215,26 @@ void InformationPanelContent::refreshPreview()
this, &InformationPanelContent::showIcon);
const QString mimeType = m_item.mimetype();
- const bool usePhonon = mimeType.startsWith(QLatin1String("audio/")) || mimeType.startsWith(QLatin1String("video/"));
+ const bool isVideo = mimeType.startsWith(QLatin1String("video/"));
+ const bool usePhonon = mimeType.startsWith(QLatin1String("audio/")) || isVideo;
+
if (usePhonon) {
+
+ if (InformationPanelSettings::previewsAutoPlay() && isVideo) {
+ // hides the preview now to avoid flickering when the autoplay video starts
+ m_preview->hide();
+ } else {
+ // the video won't play before the preview is displayed
+ m_preview->show();
+ }
+
m_phononWidget->show();
- m_phononWidget->setUrl(m_item.targetUrl());
+ m_phononWidget->setUrl(m_item.targetUrl(), isVideo ? PhononWidget::MediaKind::Video : PhononWidget::MediaKind::Audio);
m_phononWidget->setVideoSize(m_preview->size());
} else {
+ // When we don't need it, hide the phonon widget first to avoid flickering
m_phononWidget->hide();
+ m_preview->show();
}
}
} else {
@@ -328,6 +345,10 @@ void InformationPanelContent::slotHasVideoChanged(bool hasVideo)
m_preview->setVisible(InformationPanelSettings::previewsShown() && !hasVideo);
}
+void InformationPanelContent::setPreviewAutoPlay(bool autoPlay) {
+ m_phononWidget->setAutoPlay(autoPlay);
+}
+
void InformationPanelContent::setNameLabelText(const QString& text)
{
QTextOption textOption;