From b880e4d85caf17e43eb3bd4c9f358ca6f181a790 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Wed, 11 Nov 2009 15:39:27 +0100 Subject: Pause playback on small screens when popping up dialogs. Only done for small screens. Patch simplified by Gareth. Task-number: QTBUG-5307 Reviewed-by: Gareth Stockwell --- demos/qmediaplayer/mediaplayer.cpp | 19 +++++++++++++++++++ demos/qmediaplayer/mediaplayer.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/demos/qmediaplayer/mediaplayer.cpp b/demos/qmediaplayer/mediaplayer.cpp index 8a5420f..267a225 100644 --- a/demos/qmediaplayer/mediaplayer.cpp +++ b/demos/qmediaplayer/mediaplayer.cpp @@ -471,6 +471,8 @@ void MediaPlayer::effectChanged() void MediaPlayer::showSettingsDialog() { + playPauseForDialog(); + if (!settingsDialog) initSettingsDialog(); @@ -516,6 +518,8 @@ void MediaPlayer::showSettingsDialog() m_videoWidget->setScaleMode(oldScale); ui->audioEffectsCombo->setCurrentIndex(currentEffect); } + + playPauseForDialog(); } void MediaPlayer::initVideoWindow() @@ -652,10 +656,25 @@ void MediaPlayer::setFile(const QString &fileName) m_MediaObject.play(); } +void MediaPlayer::playPauseForDialog() +{ + // If we're running on a small screen, we want to pause the video + // when popping up dialogs. + if (m_hasSmallScreen && + (Phonon::PlayingState == m_MediaObject.state() || + Phonon::PausedState == m_MediaObject.state())) + playPause(); +} + void MediaPlayer::openFile() { + playPauseForDialog(); + QStringList fileNames = QFileDialog::getOpenFileNames(this, QString(), QDesktopServices::storageLocation(QDesktopServices::MusicLocation)); + + playPauseForDialog(); + m_MediaObject.clearQueue(); if (fileNames.size() > 0) { QString fileName = fileNames[0]; diff --git a/demos/qmediaplayer/mediaplayer.h b/demos/qmediaplayer/mediaplayer.h index 08db0e5..a1c3d92 100644 --- a/demos/qmediaplayer/mediaplayer.h +++ b/demos/qmediaplayer/mediaplayer.h @@ -111,6 +111,8 @@ private slots: void hasVideoChanged(bool); private: + void playPauseForDialog(); + QIcon playIcon; QIcon pauseIcon; QMenu *fileMenu; -- cgit v0.12