Commit 7149e064 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

qt4 - Mousewheel (2)

parent 9f2f3e7e
...@@ -986,16 +986,13 @@ KeyInputDialog::KeyInputDialog( QList<module_config_t*>& _values, ...@@ -986,16 +986,13 @@ KeyInputDialog::KeyInputDialog( QList<module_config_t*>& _values,
l->addLayout( l2 ); l->addLayout( l2 );
} }
void KeyInputDialog::keyPressEvent( QKeyEvent *e ) void KeyInputDialog::checkForConflicts( int i_vlckey )
{ {
if( e->key() == Qt::Key_Tab ) return;
int i_vlck = qtEventToVLCKey( e );
selected->setText( VLCKeyToString( i_vlck ) );
conflicts = false; conflicts = false;
module_config_t *p_current = NULL; module_config_t *p_current = NULL;
foreach( p_current, values ) foreach( p_current, values )
{ {
if( p_current->value.i == i_vlck && strcmp( p_current->psz_text, if( p_current->value.i == i_vlckey && strcmp( p_current->psz_text,
keyToChange ) ) keyToChange ) )
{ {
p_current->value.i = 0; p_current->value.i = 0;
...@@ -1010,5 +1007,21 @@ void KeyInputDialog::keyPressEvent( QKeyEvent *e ) ...@@ -1010,5 +1007,21 @@ void KeyInputDialog::keyPressEvent( QKeyEvent *e )
QString( p_current->psz_text ) + "\"" ); QString( p_current->psz_text ) + "\"" );
} }
else warning->setText( "" ); else warning->setText( "" );
}
void KeyInputDialog::keyPressEvent( QKeyEvent *e )
{
if( e->key() == Qt::Key_Tab ) return;
int i_vlck = qtEventToVLCKey( e );
selected->setText( VLCKeyToString( i_vlck ) );
checkForConflicts( i_vlck );
keyValue = i_vlck;
}
void KeyInputDialog::wheelEvent( QWheelEvent *e )
{
int i_vlck = qtWheelEventToVLCKey( e );
selected->setText( VLCKeyToString( i_vlck ) );
checkForConflicts( i_vlck );
keyValue = i_vlck; keyValue = i_vlck;
} }
...@@ -393,7 +393,9 @@ public: ...@@ -393,7 +393,9 @@ public:
int keyValue; int keyValue;
bool conflicts; bool conflicts;
private: private:
void checkForConflicts( int i_vlckey );
void keyPressEvent( QKeyEvent *); void keyPressEvent( QKeyEvent *);
void wheelEvent( QWheelEvent *);
QLabel *selected; QLabel *selected;
QLabel *warning; QLabel *warning;
const char * keyToChange; const char * keyToChange;
......
...@@ -553,15 +553,7 @@ void MainInterface::keyPressEvent( QKeyEvent *e ) ...@@ -553,15 +553,7 @@ void MainInterface::keyPressEvent( QKeyEvent *e )
void MainInterface::wheelEvent( QWheelEvent *e ) void MainInterface::wheelEvent( QWheelEvent *e )
{ {
int i_vlckey = 0; int i_vlckey = qtWheelEventToVLCKey( e );
if ( e->delta() > 0 )
i_vlckey = KEY_MOUSEWHEELUP;
else
i_vlckey = KEY_MOUSEWHEELDOWN;
/* Handle modifiers */
i_vlckey |= qtKeyModifiersToVLC( e );
var_SetInteger( p_intf->p_libvlc, "key-pressed", i_vlckey ); var_SetInteger( p_intf->p_libvlc, "key-pressed", i_vlckey );
e->accept(); e->accept();
} }
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <QColorGroup> #include <QColorGroup>
#include <QRect> #include <QRect>
#include <QKeyEvent> #include <QKeyEvent>
#include <QWheelEvent>
#include <vlc_keys.h> #include <vlc_keys.h>
...@@ -157,6 +158,18 @@ int qtEventToVLCKey( QKeyEvent *e ) ...@@ -157,6 +158,18 @@ int qtEventToVLCKey( QKeyEvent *e )
return i_vlck; return i_vlck;
} }
int qtWheelEventToVLCKey( QWheelEvent *e )
{
int i_vlck = 0;
/* Handle modifiers */
i_vlck |= qtKeyModifiersToVLC( e );
if ( e->delta() > 0 )
i_vlck |= KEY_MOUSEWHEELUP;
else
i_vlck |= KEY_MOUSEWHEELDOWN;
return i_vlck;
}
QString VLCKeyToString( int val ) QString VLCKeyToString( int val )
{ {
QString r = ""; QString r = "";
......
...@@ -86,8 +86,10 @@ signals: ...@@ -86,8 +86,10 @@ signals:
}; };
class QKeyEvent; class QKeyEvent;
class QWheelEvent;
int qtKeyModifiersToVLC( QInputEvent* e );
int qtEventToVLCKey( QKeyEvent *e ); int qtEventToVLCKey( QKeyEvent *e );
int qtWheelEventToVLCKey( QWheelEvent *e );
QString VLCKeyToString( int val ); QString VLCKeyToString( int val );
int qtKeyModifiersToVLC( QInputEvent* e );
#endif #endif
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