[vlc-devel] commit: Qt4: forward video key presses to main interface for processing ( Rémi Denis-Courmont )
git version control
git at videolan.org
Sun Aug 16 19:27:28 CEST 2009
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Aug 16 20:22:58 2009 +0300| [6ad5c698ce4c619388c84bed59feecd44c9191c7] | committer: Rémi Denis-Courmont
Qt4: forward video key presses to main interface for processing
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6ad5c698ce4c619388c84bed59feecd44c9191c7
---
modules/gui/qt4/components/interface_widgets.cpp | 18 +++++++++++++++++-
modules/gui/qt4/components/interface_widgets.hpp | 6 +++++-
modules/gui/qt4/main_interface.cpp | 7 +++++++
modules/gui/qt4/main_interface.hpp | 3 +++
4 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/modules/gui/qt4/components/interface_widgets.cpp b/modules/gui/qt4/components/interface_widgets.cpp
index 5cf1a30..6f2c390 100644
--- a/modules/gui/qt4/components/interface_widgets.cpp
+++ b/modules/gui/qt4/components/interface_widgets.cpp
@@ -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 );
diff --git a/modules/gui/qt4/components/interface_widgets.hpp b/modules/gui/qt4/components/interface_widgets.hpp
index 3c49f54..37de1af 100644
--- a/modules/gui/qt4/components/interface_widgets.hpp
+++ b/modules/gui/qt4/components/interface_widgets.hpp
@@ -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 );
diff --git a/modules/gui/qt4/main_interface.cpp b/modules/gui/qt4/main_interface.cpp
index 151a10a..72e84d5 100644
--- a/modules/gui/qt4/main_interface.cpp
+++ b/modules/gui/qt4/main_interface.cpp
@@ -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() );
@@ -1202,6 +1204,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() )
{
diff --git a/modules/gui/qt4/main_interface.hpp b/modules/gui/qt4/main_interface.hpp
index 1e6ce55..34b88a3 100644
--- a/modules/gui/qt4/main_interface.hpp
+++ b/modules/gui/qt4/main_interface.hpp
@@ -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 );
More information about the vlc-devel
mailing list