diff --git a/src/panels/information/informationpanelcontent.cpp b/src/panels/information/informationpanelcontent.cpp --- a/src/panels/information/informationpanelcontent.cpp +++ b/src/panels/information/informationpanelcontent.cpp @@ -226,6 +226,7 @@ } else { // the video won't play before the preview is displayed m_preview->show(); + m_preview->installEventFilter(m_phononWidget); } m_phononWidget->show(); @@ -235,6 +236,7 @@ // When we don't need it, hide the phonon widget first to avoid flickering m_phononWidget->hide(); m_preview->show(); + m_preview->removeEventFilter(m_phononWidget); } } } else { diff --git a/src/panels/information/phononwidget.h b/src/panels/information/phononwidget.h --- a/src/panels/information/phononwidget.h +++ b/src/panels/information/phononwidget.h @@ -58,6 +58,7 @@ QSize videoSize() const; void setAutoPlay(bool autoPlay); + bool eventFilter(QObject *object, QEvent *event) override; signals: /** diff --git a/src/panels/information/phononwidget.cpp b/src/panels/information/phononwidget.cpp --- a/src/panels/information/phononwidget.cpp +++ b/src/panels/information/phononwidget.cpp @@ -95,6 +95,23 @@ return m_url; } +bool PhononWidget::eventFilter(QObject *object, QEvent *event) { + Q_UNUSED(object); + if (event->type() == QEvent::MouseButtonPress){ + QMouseEvent *mouseEvent = static_cast(event); + if (mouseEvent->button() == Qt::LeftButton) { + // toggle playback + if (m_media && m_media->state() == Phonon::State::PlayingState) { + m_media->pause(); + } else { + play(); + } + return true; + } + } + return false; +} + void PhononWidget::setVideoSize(const QSize& size) { if (m_videoSize != size) { @@ -172,8 +189,8 @@ switch (newstate) { case Phonon::PlayingState: case Phonon::BufferingState: - m_stopButton->show(); m_playButton->hide(); + m_stopButton->show(); break; default: m_stopButton->hide();