[vlc-devel] [PATCH 3/3] Added focus events
Vinicius Steffens Pazzini
pazzinivinicius at gmail.com
Tue Mar 5 03:25:27 CET 2013
---
modules/gui/qt4/main_interface.cpp | 61 +++++++++++++++++++++++++++++++++++-
modules/gui/qt4/main_interface.hpp | 4 +++
2 files changed, 64 insertions(+), 1 deletion(-)
diff --git a/modules/gui/qt4/main_interface.cpp b/modules/gui/qt4/main_interface.cpp
index d6a8590..5c44cbd 100644
--- a/modules/gui/qt4/main_interface.cpp
+++ b/modules/gui/qt4/main_interface.cpp
@@ -63,6 +63,8 @@
#include <vlc_keys.h> /* Wheel event */
#include <vlc_vout_display.h> /* vout_thread_t and VOUT_ events */
+#include <iostream>
+
// #define DEBUG_INTF
/* Callback prototypes */
@@ -136,6 +138,9 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
/* */
b_pauseOnMinimize = var_InheritBool( p_intf, "qt-pause-minimized" );
+ b_pauseOnLoseFocus = var_InheritBool( p_intf, "qt-pause-lose-focus" );
+ b_muteOnLoseFocus = var_InheritBool( p_intf, "qt-mute-lose-focus" );
+
/* Set the other interface settings */
settings = getSettings();
@@ -1217,6 +1222,60 @@ void MainInterface::updateSystrayTooltipStatus( int i_status )
VLCMenuBar::updateSystrayMenu( this, p_intf );
}
+void MainInterface::focusInEvent(QFocusEvent *event)
+{
+ if (event->reason() == Qt::ActiveWindowFocusReason)
+ {
+ if( THEMIM->getIM()->playingStatus() == PAUSE_S &&
+ b_pauseOnLoseFocus && b_playingInFocus)
+ {
+ THEMIM->play();
+ }
+ /*
+ if ( THEMIM->isMuted() ){
+ b_mutedInFocus = false;
+ }else{
+ b_mutedInFocus = true;
+ }*/
+ if ( !b_mutedInFocus && b_muteOnLoseFocus )
+ {
+ THEMIM->toggleMute();
+ }
+ }
+ QWidget::focusInEvent(event);
+}
+
+void MainInterface::focusOutEvent(QFocusEvent *event)
+{
+ if (event->reason() == Qt::ActiveWindowFocusReason)
+ {
+
+ if( THEMIM->getIM()->playingStatus() == PLAYING_S &&
+ THEMIM->getIM()->hasVideo() && !THEMIM->getIM()->hasVisualisation() &&
+ b_pauseOnLoseFocus )
+ {
+ THEMIM->pause();
+ b_playingInFocus = true;
+ } else {
+ b_playingInFocus = false;
+ }
+
+ if ( THEMIM->isMuted() ){
+ b_mutedInFocus = true;
+ }else{
+ b_mutedInFocus = false;
+ }
+
+ if ( !b_mutedInFocus && b_muteOnLoseFocus )
+ {
+ //std::cout << "OI" << std::endl;
+ THEMIM->toggleMute();
+ b_mutedInFocus = false;
+ }
+ }
+ QWidget::focusOutEvent(event);
+}
+
void MainInterface::changeEvent(QEvent *event)
{
if( event->type() == QEvent::WindowStateChange )
@@ -1228,7 +1287,7 @@ void MainInterface::changeEvent(QEvent *event)
if( newState & Qt::WindowMinimized )
{
b_hasPausedWhenMinimized = false;
-
+
if( THEMIM->getIM()->playingStatus() == PLAYING_S &&
THEMIM->getIM()->hasVideo() && !THEMIM->getIM()->hasVisualisation() &&
b_pauseOnMinimize )
diff --git a/modules/gui/qt4/main_interface.hpp b/modules/gui/qt4/main_interface.hpp
index 0f11d10..a3cdf63 100644
--- a/modules/gui/qt4/main_interface.hpp
+++ b/modules/gui/qt4/main_interface.hpp
@@ -96,6 +96,10 @@ protected:
#ifdef WIN32
virtual bool winEvent( MSG *, long * );
#endif
+
+ virtual void focusInEvent(QFocusEvent *);
+ virtual void focusOutEvent(QFocusEvent *);
+
virtual void changeEvent( QEvent * );
virtual void dropEvent( QDropEvent *);
virtual void dragEnterEvent( QDragEnterEvent * );
--
1.7.9.5
More information about the vlc-devel
mailing list