]> git.sesse.net Git - vlc/commitdiff
qt4 - Mousewheel (2)
authorJean-Baptiste Kempf <jb@videolan.org>
Fri, 13 Apr 2007 07:14:48 +0000 (07:14 +0000)
committerJean-Baptiste Kempf <jb@videolan.org>
Fri, 13 Apr 2007 07:14:48 +0000 (07:14 +0000)
modules/gui/qt4/components/preferences_widgets.cpp
modules/gui/qt4/components/preferences_widgets.hpp
modules/gui/qt4/main_interface.cpp
modules/gui/qt4/util/customwidgets.cpp
modules/gui/qt4/util/customwidgets.hpp

index 9006cb768a024ac3b8ea5963ca22ddf21dd3fb2a..90bc37917b94723d28cb1f8bd8f082045d3bd09d 100644 (file)
@@ -986,16 +986,13 @@ KeyInputDialog::KeyInputDialog( QList<module_config_t*>& _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;
 }
index 76e5b5b5f3760b333de478b13edc24b29c604447..2a9dfb423e798d2de115897e387222d7e15e36b6 100644 (file)
@@ -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;
index 0d944690faed7fda44f0624c0ff77b5f117a7379..c4920c0cb901ad4b95838445ce58654c84cb4255 100644 (file)
@@ -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();
 }
index cd30fb547406d8ab5b61aa8c49aaa120e17133f2..437cde045f8ae61f0b46ca6bba0bfc61277fa9e3 100644 (file)
@@ -30,6 +30,7 @@
 #include <QColorGroup>
 #include <QRect>
 #include <QKeyEvent>
+#include <QWheelEvent>
 
 #include <vlc_keys.h>
 
@@ -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 = "";
index 7c137edc969828e60c89912396832ef84c6753ef..4b12ff3e1cc64b24874371adba271324454f9c5f 100644 (file)
@@ -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