Commit e3511f67 authored by Francois Cartegnie's avatar Francois Cartegnie

Qt: handle special mouse buttons

parent aeb250f7
...@@ -1614,3 +1614,11 @@ void KeyInputDialog::wheelEvent( QWheelEvent *e ) ...@@ -1614,3 +1614,11 @@ void KeyInputDialog::wheelEvent( QWheelEvent *e )
keyValue = i_vlck; keyValue = i_vlck;
} }
void KeyInputDialog::mousePressEvent( QMouseEvent *e )
{
int i_vlck = qtMouseEventToVLCKey( e );
selected->setText( qtr( "Key: " ) + VLCKeyToString( i_vlck ) );
checkForConflicts( i_vlck );
keyValue = i_vlck;
}
...@@ -485,6 +485,7 @@ private: ...@@ -485,6 +485,7 @@ private:
void checkForConflicts( int i_vlckey ); void checkForConflicts( int i_vlckey );
void keyPressEvent( QKeyEvent *); void keyPressEvent( QKeyEvent *);
void wheelEvent( QWheelEvent *); void wheelEvent( QWheelEvent *);
void mousePressEvent( QMouseEvent * );
bool b_global; bool b_global;
}; };
#endif #endif
...@@ -1314,6 +1314,18 @@ void MainInterface::wheelEvent( QWheelEvent *e ) ...@@ -1314,6 +1314,18 @@ void MainInterface::wheelEvent( QWheelEvent *e )
e->accept(); e->accept();
} }
void MainInterface::mousePressEvent( QMouseEvent *e )
{
int i_vlckey = qtMouseEventToVLCKey( e );
if( i_vlckey > 0 )
{
var_SetInteger( p_intf->p_libvlc, "key-pressed", i_vlckey );
e->accept();
}
else
e->ignore();
}
void MainInterface::closeEvent( QCloseEvent *e ) void MainInterface::closeEvent( QCloseEvent *e )
{ {
// hide(); // hide();
......
...@@ -101,6 +101,7 @@ protected: ...@@ -101,6 +101,7 @@ protected:
virtual void closeEvent( QCloseEvent *); virtual void closeEvent( QCloseEvent *);
virtual void keyPressEvent( QKeyEvent *); virtual void keyPressEvent( QKeyEvent *);
virtual void wheelEvent( QWheelEvent * ); virtual void wheelEvent( QWheelEvent * );
virtual void mousePressEvent( QMouseEvent * );
private: private:
/* Main Widgets Creation */ /* Main Widgets Creation */
......
...@@ -286,6 +286,26 @@ int qtWheelEventToVLCKey( QWheelEvent *e ) ...@@ -286,6 +286,26 @@ int qtWheelEventToVLCKey( QWheelEvent *e )
return i_vlck; return i_vlck;
} }
int qtMouseEventToVLCKey( QMouseEvent *e )
{
int i_vlck = 0;
switch( e->button() )
{
case Qt::MidButton:
i_vlck |= KEY_MOUSEBUTTON_MID;
break;
case Qt::XButton1:
i_vlck |= KEY_MOUSEBUTTON_X1;
break;
case Qt::XButton2:
i_vlck |= KEY_MOUSEBUTTON_X2;
default:
break;
}
if ( i_vlck > 0 ) i_vlck |= qtKeyModifiersToVLC( e );
return i_vlck;
}
QString VLCKeyToString( unsigned val ) QString VLCKeyToString( unsigned val )
{ {
char *base = vlc_keycode2str (val); char *base = vlc_keycode2str (val);
......
...@@ -179,6 +179,7 @@ class QInputEvent; ...@@ -179,6 +179,7 @@ class QInputEvent;
int qtKeyModifiersToVLC( QInputEvent* e ); int qtKeyModifiersToVLC( QInputEvent* e );
int qtEventToVLCKey( QKeyEvent *e ); int qtEventToVLCKey( QKeyEvent *e );
int qtWheelEventToVLCKey( QWheelEvent *e ); int qtWheelEventToVLCKey( QWheelEvent *e );
int qtMouseEventToVLCKey( QMouseEvent *e );
QString VLCKeyToString( unsigned val ); QString VLCKeyToString( unsigned val );
#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