]> git.sesse.net Git - vlc/commitdiff
Start grabbing hotkeys in Qt. Unfinished
authorClément Stenac <zorglub@videolan.org>
Sun, 3 Sep 2006 21:53:38 +0000 (21:53 +0000)
committerClément Stenac <zorglub@videolan.org>
Sun, 3 Sep 2006 21:53:38 +0000 (21:53 +0000)
include/vlc_playlist.h
modules/gui/qt4/main_interface.cpp
modules/gui/qt4/main_interface.hpp

index 7ace610fda8d547588f6f9f7888feddbfdb5f319..2d161d8d669911538ad271a1e9cdc1deaa31f56c 100644 (file)
@@ -70,7 +70,6 @@ struct playlist_item_t
 #define PLAYLIST_RO_FLAG        0x0008    /**< Write-enabled ? */
 #define PLAYLIST_REMOVE_FLAG    0x0010    /**< Remove this item at the end */
 #define PLAYLIST_EXPANDED_FLAG  0x0020    /**< Expanded node */
-#define PLAYLIST_PREFCAT_FLAG   0x0040    /**< Prefer category */
 
 /**
  * Playlist status
index 51a2bda4f9e64d6bd31c32fccb6037161714509c..5e082a7e018da2d5bb5e85aaa36ee0ae5a0abf2b 100644 (file)
@@ -31,7 +31,9 @@
 #include <assert.h>
 #include <QPushButton>
 #include <QStatusBar>
+#include <QKeyEvent>
 #include "menus.hpp"
+#include <vlc_keys.h>
 
 #ifdef WIN32
     #define PREF_W 410
@@ -52,6 +54,8 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     setWindowTitle( QString::fromUtf8( _("VLC media player") ) );
     ui.setupUi( centralWidget() );
 
+    setFocusPolicy( Qt::StrongFocus );
+
     slider = new InputSlider( Qt::Horizontal, NULL );
     ui.hboxLayout->insertWidget( 0, slider );
     ui.prevButton->setText( "" );
@@ -164,6 +168,48 @@ void MainInterface::resizeEvent( QResizeEvent *e )
     p_intf->p_sys->p_video->updateGeometry() ;
 }
 
+void MainInterface::keyPressEvent( QKeyEvent *e )
+{
+    int i_vlck = 0;
+    if( e->modifiers()& Qt::ShiftModifier ) i_vlck |= KEY_MODIFIER_SHIFT;
+    if( e->modifiers()& Qt::AltModifier ) i_vlck |= KEY_MODIFIER_ALT;
+    if( e->modifiers()& Qt::ControlModifier ) i_vlck |= KEY_MODIFIER_CTRL;
+    if( e->modifiers()& Qt::MetaModifier ) i_vlck |= KEY_MODIFIER_META;
+
+    fprintf( stderr, "After modifiers %x\n", i_vlck );
+    bool found = false;
+    fprintf( stderr, "Qt %x\n", e->key() );
+    switch( e->key() )
+    {
+        case Qt::Key_Left: i_vlck |= KEY_LEFT;found=true;;break;
+        case Qt::Key_Right: i_vlck |= KEY_RIGHT;found = true;break;
+    }
+    fprintf( stderr, "After keys %x\n", i_vlck );
+    if( !found )
+    {
+        fprintf( stderr, "Not found\n" );
+        if( e->key() >= Qt::Key_A && e->key() <= Qt::Key_Z )
+        {
+            fprintf( stderr, "Alphabet\n" );
+            i_vlck += e->key() + 32;
+        }
+        /* Rest of the ascii range */
+        else if( e->key() >= Qt::Key_Space && e->key() <= Qt::Key_AsciiTilde )
+        {
+            fprintf( stderr, "Yeh !\n" );
+            i_vlck += e->key();
+        }
+    }
+    if( i_vlck >= 0 )
+    {
+        fprintf( stderr, "Setting key-pressed %i\n", i_vlck );
+        var_SetInteger( p_intf->p_vlc, "key-pressed", i_vlck );
+        e->accept();
+    }
+    else
+        e->ignore();
+}
+
 void MainInterface::stop()
 {
     playlist_Stop( THEPL );
index 1c26716f3d3e40e46ff3a060b4ef06ff20bb472e..15eef9a0c9e56effae48802b5f76429f0867e368 100644 (file)
@@ -29,6 +29,7 @@
 #include "util/qvlcframe.hpp"
 
 class QCloseEvent;
+class QKeyEvent;
 class QLabel;
 class InputManager;
 class InputSlider;
@@ -50,6 +51,7 @@ protected:
     Ui::MainInterfaceUI ui;
     friend class VolumeClickHandler;
 private:
+    virtual void keyPressEvent( QKeyEvent *);
     VideoWidget *videoWidget;
     InputManager *main_input_manager;
     QLabel *timeLabel;