Commit 98de0c4b authored by Clément Stenac's avatar Clément Stenac

Start grabbing hotkeys in Qt. Unfinished

parent 9dcb15a1
...@@ -70,7 +70,6 @@ struct playlist_item_t ...@@ -70,7 +70,6 @@ struct playlist_item_t
#define PLAYLIST_RO_FLAG 0x0008 /**< Write-enabled ? */ #define PLAYLIST_RO_FLAG 0x0008 /**< Write-enabled ? */
#define PLAYLIST_REMOVE_FLAG 0x0010 /**< Remove this item at the end */ #define PLAYLIST_REMOVE_FLAG 0x0010 /**< Remove this item at the end */
#define PLAYLIST_EXPANDED_FLAG 0x0020 /**< Expanded node */ #define PLAYLIST_EXPANDED_FLAG 0x0020 /**< Expanded node */
#define PLAYLIST_PREFCAT_FLAG 0x0040 /**< Prefer category */
/** /**
* Playlist status * Playlist status
......
...@@ -31,7 +31,9 @@ ...@@ -31,7 +31,9 @@
#include <assert.h> #include <assert.h>
#include <QPushButton> #include <QPushButton>
#include <QStatusBar> #include <QStatusBar>
#include <QKeyEvent>
#include "menus.hpp" #include "menus.hpp"
#include <vlc_keys.h>
#ifdef WIN32 #ifdef WIN32
#define PREF_W 410 #define PREF_W 410
...@@ -52,6 +54,8 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -52,6 +54,8 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
setWindowTitle( QString::fromUtf8( _("VLC media player") ) ); setWindowTitle( QString::fromUtf8( _("VLC media player") ) );
ui.setupUi( centralWidget() ); ui.setupUi( centralWidget() );
setFocusPolicy( Qt::StrongFocus );
slider = new InputSlider( Qt::Horizontal, NULL ); slider = new InputSlider( Qt::Horizontal, NULL );
ui.hboxLayout->insertWidget( 0, slider ); ui.hboxLayout->insertWidget( 0, slider );
ui.prevButton->setText( "" ); ui.prevButton->setText( "" );
...@@ -164,6 +168,48 @@ void MainInterface::resizeEvent( QResizeEvent *e ) ...@@ -164,6 +168,48 @@ void MainInterface::resizeEvent( QResizeEvent *e )
p_intf->p_sys->p_video->updateGeometry() ; 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() void MainInterface::stop()
{ {
playlist_Stop( THEPL ); playlist_Stop( THEPL );
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "util/qvlcframe.hpp" #include "util/qvlcframe.hpp"
class QCloseEvent; class QCloseEvent;
class QKeyEvent;
class QLabel; class QLabel;
class InputManager; class InputManager;
class InputSlider; class InputSlider;
...@@ -50,6 +51,7 @@ protected: ...@@ -50,6 +51,7 @@ protected:
Ui::MainInterfaceUI ui; Ui::MainInterfaceUI ui;
friend class VolumeClickHandler; friend class VolumeClickHandler;
private: private:
virtual void keyPressEvent( QKeyEvent *);
VideoWidget *videoWidget; VideoWidget *videoWidget;
InputManager *main_input_manager; InputManager *main_input_manager;
QLabel *timeLabel; QLabel *timeLabel;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment