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,
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;
}
......@@ -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;
......
......@@ -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();
}
......
......@@ -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 = "";
......
......@@ -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
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