[vlc-commits] commit: Qt: Correctly close the player when alt+f4 is pressed ( Jean-Baptiste Kempf )

git at videolan.org git at videolan.org
Tue May 4 19:40:37 CEST 2010


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Tue May  4 19:39:50 2010 +0200| [965c64221f5d91443e9ee2993b758beb132d00d5] | committer: Jean-Baptiste Kempf 

Qt: Correctly close the player when alt+f4 is pressed

even when in fullscreen. Close #3602

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=965c64221f5d91443e9ee2993b758beb132d00d5
---

 modules/gui/qt4/components/interface_widgets.cpp |   39 +++++++++++++++++----
 modules/gui/qt4/components/interface_widgets.hpp |    2 +-
 2 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/modules/gui/qt4/components/interface_widgets.cpp b/modules/gui/qt4/components/interface_widgets.cpp
index 7cfb19c..efe02f6 100644
--- a/modules/gui/qt4/components/interface_widgets.cpp
+++ b/modules/gui/qt4/components/interface_widgets.cpp
@@ -29,6 +29,8 @@
 #endif
 
 #include "components/interface_widgets.hpp"
+#include "dialogs_provider.hpp"
+#include "util/customwidgets.hpp"               // qtEventToVLCKey, QVLCStackedWidget
 
 #include "menus.hpp"             /* Popup menu on bgWidget */
 
@@ -37,6 +39,7 @@
 #include <QLabel>
 #include <QToolButton>
 #include <QPalette>
+#include <QEvent>
 #include <QResizeEvent>
 #include <QDate>
 #include <QMenu>
@@ -70,14 +73,7 @@ private:
     VideoWidget *owner;
 public:
     ReparentableWidget( VideoWidget *owner ) : owner( owner )
-    {
-    }
-
-protected:
-    void keyPressEvent( QKeyEvent *e )
-    {
-        emit owner->keyPressed( e );
-    }
+    {}
 };
 
 /**********************************************************************
@@ -130,6 +126,7 @@ WId VideoWidget::request( int *pi_x, int *pi_y,
      * mode, and within the root window (NULL parent) in full-screen mode.
      */
     reparentable = new ReparentableWidget( this );
+    reparentable->installEventFilter(this );
     QLayout *innerLayout = new QHBoxLayout( reparentable );
     innerLayout->setContentsMargins( 0, 0, 0, 0 );
 
@@ -245,6 +242,32 @@ void VideoWidget::release( void )
     hide();
 }
 
+#undef KeyPress
+bool VideoWidget::eventFilter(QObject *obj, QEvent *event)
+{
+    if( obj == reparentable )
+    {
+        if (event->type() == QEvent::Close)
+        {
+            THEDP->quit();
+            return true;
+        }
+        else if( event->type() == QEvent::KeyPress )
+        {
+            emit keyPressed( static_cast<QKeyEvent *>(event) );
+            return true;
+        }
+        else if( event->type() == QEvent::Wheel )
+        {
+            int i_vlckey = qtWheelEventToVLCKey( static_cast<QWheelEvent *>( event) );
+            var_SetInteger( p_intf->p_libvlc, "key-pressed", i_vlckey );
+            msg_Dbg( p_intf, "Here: %i", i_vlckey );
+            return true;
+        }
+    }
+    return false;
+}
+
 /**********************************************************************
  * Background Widget. Show a simple image background. Currently,
  * it's album art if present or cone.
diff --git a/modules/gui/qt4/components/interface_widgets.hpp b/modules/gui/qt4/components/interface_widgets.hpp
index 7cd3cfd..c3fcd3a 100644
--- a/modules/gui/qt4/components/interface_widgets.hpp
+++ b/modules/gui/qt4/components/interface_widgets.hpp
@@ -73,7 +73,7 @@ private:
 
     QWidget *reparentable;
     QLayout *layout;
-
+    virtual bool eventFilter ( QObject * watched, QEvent * event );
 signals:
     void keyPressed( QKeyEvent * );
     void sizeChanged( int, int );



More information about the vlc-commits mailing list