[vlc-commits] Qt: really close ExtensionDialog when user presses ESC

Jean-Philippe André git at videolan.org
Sat Jan 22 00:56:49 CET 2011


vlc | branch: master | Jean-Philippe André <jpeg at videolan.org> | Sat Jan 22 00:56:11 2011 +0100| [ae06612ff21d175e09c82203e5ad3d026fd6a527] | committer: Jean-Philippe André

Qt: really close ExtensionDialog when user presses ESC

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

 modules/gui/qt4/dialogs/extensions.cpp |   16 ++++++++++++++++
 modules/gui/qt4/dialogs/extensions.hpp |    2 ++
 2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/modules/gui/qt4/dialogs/extensions.cpp b/modules/gui/qt4/dialogs/extensions.cpp
index 48da03c..0d3655f 100644
--- a/modules/gui/qt4/dialogs/extensions.cpp
+++ b/modules/gui/qt4/dialogs/extensions.cpp
@@ -38,6 +38,7 @@
 #include <QComboBox>
 #include <QCloseEvent>
 #include <QCoreApplication>
+#include <QKeyEvent>
 #include "util/customwidgets.hpp"
 
 ExtensionsDialogProvider *ExtensionsDialogProvider::instance = NULL;
@@ -681,6 +682,21 @@ void ExtensionDialog::closeEvent( QCloseEvent *event )
     extension_DialogClosed( p_dialog );
 }
 
+/** Grab some keyboard input (ESC, ...) and handle actions manually */
+void ExtensionDialog::keyPressEvent( QKeyEvent *event )
+{
+    assert( p_dialog != NULL );
+    switch( event->key() )
+    {
+    case Qt::Key_Escape:
+        close();
+        return;
+    default:
+        QDialog::keyPressEvent( event );
+        return;
+    }
+}
+
 void ExtensionDialog::parentDestroyed()
 {
     msg_Dbg( p_intf, "About to destroy dialog '%s'", p_dialog->psz_title );
diff --git a/modules/gui/qt4/dialogs/extensions.hpp b/modules/gui/qt4/dialogs/extensions.hpp
index dafb12e..48ca9c3 100644
--- a/modules/gui/qt4/dialogs/extensions.hpp
+++ b/modules/gui/qt4/dialogs/extensions.hpp
@@ -34,6 +34,7 @@ class QObject;
 class QGridLayout;
 class QSignalMapper;
 class QCloseEvent;
+class QKeyEvent;
 
 class ExtensionsDialogProvider;
 class ExtensionDialog;
@@ -106,6 +107,7 @@ private:
 
 protected:
     virtual void closeEvent( QCloseEvent* );
+    virtual void keyPressEvent( QKeyEvent* );
 
 private slots:
     int TriggerClick( QObject *object );



More information about the vlc-commits mailing list