[vlc-commits] commit: Add an option to pause the playback on minimizing the window. http: //trac.videolan.org/vlc/ticket/2234 (Jakub Wieczorek )
git at videolan.org
git at videolan.org
Sun Dec 26 13:32:54 CET 2010
vlc | branch: master | Jakub Wieczorek <fawek at fawek.net> | Sat Dec 25 23:08:23 2010 +0100| [588c2528c476cd2a249a549c592467cfbae990a2] | committer: Jean-Baptiste Kempf
Add an option to pause the playback on minimizing the window. http://trac.videolan.org/vlc/ticket/2234
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=588c2528c476cd2a249a549c592467cfbae990a2
---
modules/gui/qt4/input_manager.cpp | 17 +++++++++++++++++
modules/gui/qt4/input_manager.hpp | 1 +
modules/gui/qt4/main_interface.cpp | 35 +++++++++++++++++++++++++++++++++++
modules/gui/qt4/main_interface.hpp | 2 ++
modules/gui/qt4/qt4.cpp | 8 ++++++++
5 files changed, 63 insertions(+), 0 deletions(-)
diff --git a/modules/gui/qt4/input_manager.cpp b/modules/gui/qt4/input_manager.cpp
index 539279c..749ec5a 100644
--- a/modules/gui/qt4/input_manager.cpp
+++ b/modules/gui/qt4/input_manager.cpp
@@ -514,6 +514,23 @@ bool InputManager::hasAudio()
return false;
}
+bool InputManager::hasVisualisation()
+{
+ if( !p_input )
+ return false;
+
+ aout_instance_t *aout = input_GetAout( p_input );
+ if( !aout )
+ return false;
+
+ char *visual = var_InheritString( aout, "visual" );
+ if( !visual )
+ return false;
+
+ free( visual );
+ return true;
+}
+
void InputManager::UpdateTeletext()
{
if( hasInput() )
diff --git a/modules/gui/qt4/input_manager.hpp b/modules/gui/qt4/input_manager.hpp
index e56eca5..fde6ae0 100644
--- a/modules/gui/qt4/input_manager.hpp
+++ b/modules/gui/qt4/input_manager.hpp
@@ -133,6 +133,7 @@ public:
int playingStatus();
bool hasAudio();
bool hasVideo() { return hasInput() && b_video; }
+ bool hasVisualisation();
void requestArtUpdate();
QString getName() { return oldName; }
diff --git a/modules/gui/qt4/main_interface.cpp b/modules/gui/qt4/main_interface.cpp
index 4444ad1..139ce17 100644
--- a/modules/gui/qt4/main_interface.cpp
+++ b/modules/gui/qt4/main_interface.cpp
@@ -259,6 +259,8 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
/* Switch to minimal view if needed, must be called after the show() */
if( b_minimalView )
toggleMinimalView( true );
+
+ b_hasPausedWhenMinimized = false;
}
MainInterface::~MainInterface()
@@ -1090,6 +1092,39 @@ void MainInterface::updateSystrayTooltipStatus( int i_status )
}
#endif
+void MainInterface::changeEvent(QEvent *event)
+{
+ if( event->type() == QEvent::WindowStateChange )
+ {
+ QWindowStateChangeEvent *windowStateChangeEvent = static_cast<QWindowStateChangeEvent*>(event);
+ Qt::WindowStates newState = windowState();
+ Qt::WindowStates oldState = windowStateChangeEvent->oldState();
+
+ if( newState & Qt::WindowMinimized )
+ {
+ b_hasPausedWhenMinimized = false;
+
+ if( THEMIM->getIM()->playingStatus() == PLAYING_S &&
+ THEMIM->getIM()->hasVideo() &&
+ !THEMIM->getIM()->hasVisualisation() &&
+ var_InheritBool( p_intf, "qt-pause-minimized" ) )
+ {
+ b_hasPausedWhenMinimized = true;
+ THEMIM->pause();
+ }
+ }
+ else if( oldState & Qt::WindowMinimized && !( newState & Qt::WindowMinimized ) )
+ {
+ if( b_hasPausedWhenMinimized )
+ {
+ THEMIM->play();
+ }
+ }
+ }
+
+ QWidget::changeEvent(event);
+}
+
/************************************************************************
* D&D Events
************************************************************************/
diff --git a/modules/gui/qt4/main_interface.hpp b/modules/gui/qt4/main_interface.hpp
index 4f7304e..11afb39 100644
--- a/modules/gui/qt4/main_interface.hpp
+++ b/modules/gui/qt4/main_interface.hpp
@@ -93,6 +93,7 @@ protected:
#ifdef WIN32
virtual bool winEvent( MSG *, long * );
#endif
+ virtual void changeEvent( QEvent * );
virtual void dropEvent( QDropEvent *);
virtual void dragEnterEvent( QDragEnterEvent * );
virtual void dragMoveEvent( QDragMoveEvent * );
@@ -168,6 +169,7 @@ private:
// bool b_visualSelectorEnabled;
bool b_plDocked; ///< Is the playlist docked ?
+ bool b_hasPausedWhenMinimized;
#ifdef WIN32
HIMAGELIST himl;
diff --git a/modules/gui/qt4/qt4.cpp b/modules/gui/qt4/qt4.cpp
index 64cc348..ecfb769 100644
--- a/modules/gui/qt4/qt4.cpp
+++ b/modules/gui/qt4/qt4.cpp
@@ -178,6 +178,11 @@ static void ShowDialog ( intf_thread_t *, int, int, intf_dialog_args_t * );
"keyboard will always change your system volume. With this option unchecked, the " \
"volume buttons will change VLC's volume when VLC is selected and change the " \
"system volume when VLC is not selected." )
+
+#define QT_PAUSE_MINIMIZED_TEXT N_( "Pause the video playback when minimized" )
+#define QT_PAUSE_MINIMIZED_LONGTEXT N_( \
+ "With this option enabled, the playback will be automatically paused when minimizing the window." )
+
/**********************************************************************/
vlc_module_begin ()
set_shortname( "Qt" )
@@ -263,6 +268,9 @@ vlc_module_begin ()
false /* advanced mode only */)
#endif
+ add_bool( "qt-pause-minimized", true, QT_PAUSE_MINIMIZED_TEXT,
+ QT_PAUSE_MINIMIZED_LONGTEXT, false )
+
add_obsolete_bool( "qt-blingbling" ) /* Suppressed since 1.0.0 */
add_obsolete_integer( "qt-display-mode" ) /* Suppressed since 1.1.0 */
More information about the vlc-commits
mailing list