From bd51ed60a647964112176529ed7fc539b7734dc2 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Thu, 25 Sep 2008 21:28:00 +0000 Subject: [PATCH] replaced X11-specific parts by platform independent code but still does not work properly git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1712 0778d3d1-df1d-0410-868b-ea421aaaa00d --- ChangeLog | 5 +++ plugins/live_tool/live_tool.cpp | 63 ++++++++++++++++++--------------- plugins/live_tool/live_tool.h | 9 ++--- 3 files changed, 41 insertions(+), 36 deletions(-) diff --git a/ChangeLog b/ChangeLog index 947b96c5c..4154d69fc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2008-09-25 Tobias Doerffel + * plugins/live_tool/live_tool.h: + * plugins/live_tool/live_tool.cpp: + replaced X11-specific parts by platform independent code but still + does not work properly + * src/gui/piano_roll.cpp: play preview notes also while playing (closes #2089399) diff --git a/plugins/live_tool/live_tool.cpp b/plugins/live_tool/live_tool.cpp index 1f138b6af..804ae9895 100644 --- a/plugins/live_tool/live_tool.cpp +++ b/plugins/live_tool/live_tool.cpp @@ -23,19 +23,13 @@ */ -#include -#include - #include "live_tool.h" #include "bb_track_container.h" #include "engine.h" #include "song.h" -#ifdef Q_WS_X11 - -#include - -#endif +#include +#include #undef SINGLE_SOURCE_COMPILE #include "embed.cpp" @@ -119,6 +113,8 @@ liveToolView::liveToolView( tool * _tool ) : parentWidget()->hide(); parentWidget()->layout()->setSizeConstraint( QLayout::SetFixedSize ); + + installEventFilter( this ); } @@ -151,7 +147,21 @@ void liveToolView::keyPressEvent( QKeyEvent * _ke ) engine::getSong()->play(); } break; - + case Qt::Key_F1: + case Qt::Key_F2: + case Qt::Key_F3: + case Qt::Key_F4: + case Qt::Key_F5: + case Qt::Key_F6: + case Qt::Key_F7: + case Qt::Key_F8: + case Qt::Key_F9: + case Qt::Key_F10: + case Qt::Key_F11: + case Qt::Key_F12: + toggleInstrument( _ke->key() - Qt::Key_F1 ); + _ke->accept(); + break; default: _ke->ignore(); break; @@ -161,36 +171,31 @@ void liveToolView::keyPressEvent( QKeyEvent * _ke ) +bool liveToolView::eventFilter ( QObject * watched, QEvent * event ) +{ + if( event->type() == QEvent::KeyPress ) + { + QKeyEvent * ke = static_cast( event ); + keyPressEvent( ke ); + return true; + } + return toolView::eventFilter( watched, event ); +} + + + + void liveToolView::mousePressEvent( QMouseEvent * _me ) { // MDI window gets focus otherwise setFocus(); _me->accept(); + // somehow need to grab keyboard for also grabbing global shortcuts } -#ifdef Q_WS_X11 -bool liveToolView::x11Event( XEvent * _xe ) -{ - if( _xe->type == KeyPress ) - { - unsigned keycode = _xe->xkey.keycode; - // F1 to F10 - if( 67 <= keycode && keycode <= 76 ) - { - toggleInstrument( keycode - 67 ); - return( TRUE ); - } - } - return( FALSE ); -} -#endif - - - - void liveToolView::toggleInstrument( int _n ) { if( _n < engine::getBBTrackContainer()->tracks().count() ) diff --git a/plugins/live_tool/live_tool.h b/plugins/live_tool/live_tool.h index b2296193e..1afa1ac52 100644 --- a/plugins/live_tool/live_tool.h +++ b/plugins/live_tool/live_tool.h @@ -1,7 +1,7 @@ /* * live_tool.h - declaration of class liveTool, for live performance * - * Copyright (c) 2006-2007 Javier Serrano Polo + * Copyright (c) 2006-2008 Javier Serrano Polo * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -30,21 +30,16 @@ #include "tool.h" - class liveToolView : public toolView { public: liveToolView( tool * _tool ); virtual ~liveToolView(); - +virtual bool eventFilter ( QObject * watched, QEvent * event ); protected: virtual void keyPressEvent( QKeyEvent * _ke ); virtual void mousePressEvent( QMouseEvent * _me ); -#ifdef Q_WS_X11 - virtual bool x11Event( XEvent * _xe ); -#endif - private: void toggleInstrument( int _n );