From: Jean-Baptiste Kempf Date: Fri, 13 Apr 2007 07:14:48 +0000 (+0000) Subject: qt4 - Mousewheel (2) X-Git-Tag: 0.9.0-test0~7759 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=7149e064c3172d1e0c5b45bfb36807003f1f00f7;p=vlc qt4 - Mousewheel (2) --- diff --git a/modules/gui/qt4/components/preferences_widgets.cpp b/modules/gui/qt4/components/preferences_widgets.cpp index 9006cb768a..90bc37917b 100644 --- a/modules/gui/qt4/components/preferences_widgets.cpp +++ b/modules/gui/qt4/components/preferences_widgets.cpp @@ -986,16 +986,13 @@ KeyInputDialog::KeyInputDialog( QList& _values, 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; module_config_t *p_current = NULL; 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 ) ) { p_current->value.i = 0; @@ -1010,5 +1007,21 @@ void KeyInputDialog::keyPressEvent( QKeyEvent *e ) QString( p_current->psz_text ) + "\"" ); } 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; } diff --git a/modules/gui/qt4/components/preferences_widgets.hpp b/modules/gui/qt4/components/preferences_widgets.hpp index 76e5b5b5f3..2a9dfb423e 100644 --- a/modules/gui/qt4/components/preferences_widgets.hpp +++ b/modules/gui/qt4/components/preferences_widgets.hpp @@ -393,7 +393,9 @@ public: int keyValue; bool conflicts; private: + void checkForConflicts( int i_vlckey ); void keyPressEvent( QKeyEvent *); + void wheelEvent( QWheelEvent *); QLabel *selected; QLabel *warning; const char * keyToChange; diff --git a/modules/gui/qt4/main_interface.cpp b/modules/gui/qt4/main_interface.cpp index 0d944690fa..c4920c0cb9 100644 --- a/modules/gui/qt4/main_interface.cpp +++ b/modules/gui/qt4/main_interface.cpp @@ -553,15 +553,7 @@ void MainInterface::keyPressEvent( QKeyEvent *e ) void MainInterface::wheelEvent( QWheelEvent *e ) { - int i_vlckey = 0; - - if ( e->delta() > 0 ) - i_vlckey = KEY_MOUSEWHEELUP; - else - i_vlckey = KEY_MOUSEWHEELDOWN; - - /* Handle modifiers */ - i_vlckey |= qtKeyModifiersToVLC( e ); + int i_vlckey = qtWheelEventToVLCKey( e ); var_SetInteger( p_intf->p_libvlc, "key-pressed", i_vlckey ); e->accept(); } diff --git a/modules/gui/qt4/util/customwidgets.cpp b/modules/gui/qt4/util/customwidgets.cpp index cd30fb5474..437cde045f 100644 --- a/modules/gui/qt4/util/customwidgets.cpp +++ b/modules/gui/qt4/util/customwidgets.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include @@ -157,6 +158,18 @@ int qtEventToVLCKey( QKeyEvent *e ) 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 r = ""; diff --git a/modules/gui/qt4/util/customwidgets.hpp b/modules/gui/qt4/util/customwidgets.hpp index 7c137edc96..4b12ff3e1c 100644 --- a/modules/gui/qt4/util/customwidgets.hpp +++ b/modules/gui/qt4/util/customwidgets.hpp @@ -86,8 +86,10 @@ signals: }; class QKeyEvent; +class QWheelEvent; +int qtKeyModifiersToVLC( QInputEvent* e ); int qtEventToVLCKey( QKeyEvent *e ); +int qtWheelEventToVLCKey( QWheelEvent *e ); QString VLCKeyToString( int val ); -int qtKeyModifiersToVLC( QInputEvent* e ); #endif