]> git.sesse.net Git - vlc/commitdiff
Qt4: forward video key presses to main interface for processing
authorRémi Denis-Courmont <remi@remlab.net>
Sun, 16 Aug 2009 17:22:58 +0000 (20:22 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Sun, 16 Aug 2009 17:27:24 +0000 (20:27 +0300)
modules/gui/qt4/components/interface_widgets.cpp
modules/gui/qt4/components/interface_widgets.hpp
modules/gui/qt4/main_interface.cpp
modules/gui/qt4/main_interface.hpp

index 5cf1a301abc1837eefcfc6f82b6317cb01e9c5f2..6f2c39076c65a47b8122b3e4a0ec55482aba7a15 100644 (file)
@@ -59,6 +59,22 @@ static void videoSync( void )
 
 #include <math.h>
 
+class ReparentableWidget : public QWidget
+{
+private:
+    VideoWidget *owner;
+public:
+    ReparentableWidget( VideoWidget *owner ) : owner( owner )
+    {
+    }
+
+protected:
+    void keyPressEvent( QKeyEvent *e )
+    {
+        emit owner->keyPressed( e );
+    }
+};
+
 /**********************************************************************
  * Video Widget. A simple frame on which video is drawn
  * This class handles resize issues
@@ -112,7 +128,7 @@ WId VideoWidget::request( int *pi_x, int *pi_y,
      * reparentable widget, that will be within the VideoWidget in windowed
      * mode, and within the root window (NULL parent) in full-screen mode.
      */
-    reparentable = new QWidget();
+    reparentable = new ReparentableWidget( this );
     QLayout *innerLayout = new QHBoxLayout( reparentable );
     innerLayout->setContentsMargins( 0, 0, 0, 0 );
 
index 3c49f542fcd17043085edcc7332399806bdf034e..37de1aff138ab2d1bd71a280e313481e009790ba 100644 (file)
@@ -48,12 +48,13 @@ class QPalette;
 class QPixmap;
 class QHBoxLayout;
 class QMenu;
+class ReparentableWidget;
 
 /******************** Video Widget ****************/
 class VideoWidget : public QFrame
 {
     Q_OBJECT
-friend class MainInterface;
+friend class ReparentableWidget;
 
 public:
     VideoWidget( intf_thread_t * );
@@ -79,6 +80,9 @@ private:
     QWidget *reparentable;
     QLayout *layout;
 
+signals:
+    void keyPressed( QKeyEvent * );
+
 public slots:
     void SetSizing( unsigned int, unsigned int );
     void SetFullScreen( bool );
index 151a10a4eb569612e5e703cdb6b709c739d2f274..72e84d511378d0b045924f33389d8436c6985975 100644 (file)
@@ -230,6 +230,8 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
                  videoWidget, SetSizing( unsigned int, unsigned int ) );
         CONNECT( this, askVideoSetFullScreen( bool ),
                  videoWidget, SetFullScreen( bool ) );
+        CONNECT( videoWidget, keyPressed( QKeyEvent * ),
+                 this, handleKeyPress( QKeyEvent * ) );
     }
 
     CONNECT( this, askUpdate(), this, doComponentsUpdate() );
@@ -1201,6 +1203,11 @@ void MainInterface::customEvent( QEvent *event )
 }
 
 void MainInterface::keyPressEvent( QKeyEvent *e )
+{
+    handleKeyPress( e );
+}
+
+void MainInterface::handleKeyPress( QKeyEvent *e )
 {
     if( ( e->modifiers() &  Qt::ControlModifier ) && ( e->key() == Qt::Key_H )
           && !menuBar()->isVisible() )
index 1e6ce55473bc506b43f891b2012e756e3d5790e4..34b88a307d7082fac921e5b25b04e985c59b6edd 100644 (file)
@@ -178,6 +178,9 @@ private slots:
     void updateSystrayTooltipStatus( int );
 
     void showCryptedLabel( bool );
+
+    void handleKeyPress( QKeyEvent * );
+
 signals:
     void askGetVideo( WId *p_id, int *pi_x, int *pi_y,
                       unsigned int *pi_width, unsigned int *pi_height );