[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 23:59:18 CEST 2010


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

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

even when in fullscreen. Close #3602
(cherry picked from commit 965c64221f5d91443e9ee2993b758beb132d00d5)
(cherry picked from commit 308b6e6d8eab5bb2b4cfb8208f4504f54534273c)

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

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

diff --git a/modules/gui/qt4/components/interface_widgets.cpp b/modules/gui/qt4/components/interface_widgets.cpp
index 7cfb19c..c07f21f 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,25 @@ 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;
+        }
+    }
+    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