Commit 588c2528 authored by Jakub Wieczorek's avatar Jakub Wieczorek Committed by Jean-Baptiste Kempf

Add an option to pause the playback on minimizing the window....

Add an option to pause the playback on minimizing the window. http://trac.videolan.org/vlc/ticket/2234Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 627feeb6
...@@ -514,6 +514,23 @@ bool InputManager::hasAudio() ...@@ -514,6 +514,23 @@ bool InputManager::hasAudio()
return false; 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() void InputManager::UpdateTeletext()
{ {
if( hasInput() ) if( hasInput() )
......
...@@ -133,6 +133,7 @@ public: ...@@ -133,6 +133,7 @@ public:
int playingStatus(); int playingStatus();
bool hasAudio(); bool hasAudio();
bool hasVideo() { return hasInput() && b_video; } bool hasVideo() { return hasInput() && b_video; }
bool hasVisualisation();
void requestArtUpdate(); void requestArtUpdate();
QString getName() { return oldName; } QString getName() { return oldName; }
......
...@@ -259,6 +259,8 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -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() */ /* Switch to minimal view if needed, must be called after the show() */
if( b_minimalView ) if( b_minimalView )
toggleMinimalView( true ); toggleMinimalView( true );
b_hasPausedWhenMinimized = false;
} }
MainInterface::~MainInterface() MainInterface::~MainInterface()
...@@ -1090,6 +1092,39 @@ void MainInterface::updateSystrayTooltipStatus( int i_status ) ...@@ -1090,6 +1092,39 @@ void MainInterface::updateSystrayTooltipStatus( int i_status )
} }
#endif #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 * D&D Events
************************************************************************/ ************************************************************************/
......
...@@ -93,6 +93,7 @@ protected: ...@@ -93,6 +93,7 @@ protected:
#ifdef WIN32 #ifdef WIN32
virtual bool winEvent( MSG *, long * ); virtual bool winEvent( MSG *, long * );
#endif #endif
virtual void changeEvent( QEvent * );
virtual void dropEvent( QDropEvent *); virtual void dropEvent( QDropEvent *);
virtual void dragEnterEvent( QDragEnterEvent * ); virtual void dragEnterEvent( QDragEnterEvent * );
virtual void dragMoveEvent( QDragMoveEvent * ); virtual void dragMoveEvent( QDragMoveEvent * );
...@@ -168,6 +169,7 @@ private: ...@@ -168,6 +169,7 @@ private:
// bool b_visualSelectorEnabled; // bool b_visualSelectorEnabled;
bool b_plDocked; ///< Is the playlist docked ? bool b_plDocked; ///< Is the playlist docked ?
bool b_hasPausedWhenMinimized;
#ifdef WIN32 #ifdef WIN32
HIMAGELIST himl; HIMAGELIST himl;
......
...@@ -178,6 +178,11 @@ static void ShowDialog ( intf_thread_t *, int, int, intf_dialog_args_t * ); ...@@ -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 " \ "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 " \ "volume buttons will change VLC's volume when VLC is selected and change the " \
"system volume when VLC is not selected." ) "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 () vlc_module_begin ()
set_shortname( "Qt" ) set_shortname( "Qt" )
...@@ -263,6 +268,9 @@ vlc_module_begin () ...@@ -263,6 +268,9 @@ vlc_module_begin ()
false /* advanced mode only */) false /* advanced mode only */)
#endif #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_bool( "qt-blingbling" ) /* Suppressed since 1.0.0 */
add_obsolete_integer( "qt-display-mode" ) /* Suppressed since 1.1.0 */ add_obsolete_integer( "qt-display-mode" ) /* Suppressed since 1.1.0 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment