From d38d4373498bd657073db76920c3a3c7e4e89e22 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Sat, 18 Apr 2009 23:52:42 +0200 Subject: [PATCH] ZynAddSubFX: added support for d'n'd XIZ files onto ZASF plugin This commit allows the user to drag'n'drop DLL files onto ZynAddSubFX instrument (inside LMMS). --- plugins/zynaddsubfx/zynaddsubfx.cpp | 44 +++++++++++++++++++++++++++++ plugins/zynaddsubfx/zynaddsubfx.h | 5 ++++ 2 files changed, 49 insertions(+) diff --git a/plugins/zynaddsubfx/zynaddsubfx.cpp b/plugins/zynaddsubfx/zynaddsubfx.cpp index 1b33b41f6..ed77c7583 100644 --- a/plugins/zynaddsubfx/zynaddsubfx.cpp +++ b/plugins/zynaddsubfx/zynaddsubfx.cpp @@ -27,6 +27,7 @@ #include #include +#include #include #include "zynaddsubfx.h" @@ -35,6 +36,7 @@ #include "instrument_play_handle.h" #include "instrument_track.h" #include "gui_templates.h" +#include "string_pair_drag.h" #include "remote_zynaddsubfx.h" #undef SINGLE_SOURCE_COMPILE @@ -269,6 +271,8 @@ zynAddSubFxView::zynAddSubFxView( instrument * _instrument, QWidget * _parent ) m_toggleUIButton->setWhatsThis( tr( "Click here to show or hide the graphical user interface " "(GUI) of ZynAddSubFX." ) ); + + setAcceptDrops( true ); } @@ -281,6 +285,46 @@ zynAddSubFxView::~zynAddSubFxView() +void zynAddSubFxView::dragEnterEvent( QDragEnterEvent * _dee ) +{ + if( _dee->mimeData()->hasFormat( stringPairDrag::mimeType() ) ) + { + QString txt = _dee->mimeData()->data( + stringPairDrag::mimeType() ); + if( txt.section( ':', 0, 0 ) == "presetfile" ) + { + _dee->acceptProposedAction(); + } + else + { + _dee->ignore(); + } + } + else + { + _dee->ignore(); + } +} + + + + +void zynAddSubFxView::dropEvent( QDropEvent * _de ) +{ + const QString type = stringPairDrag::decodeKey( _de ); + const QString value = stringPairDrag::decodeValue( _de ); + if( type == "presetfile" ) + { + castModel()->loadFile( value ); + _de->accept(); + return; + } + _de->ignore(); +} + + + + void zynAddSubFxView::modelChanged( void ) { toggleUI(); diff --git a/plugins/zynaddsubfx/zynaddsubfx.h b/plugins/zynaddsubfx/zynaddsubfx.h index 184ff6c28..91e59146f 100644 --- a/plugins/zynaddsubfx/zynaddsubfx.h +++ b/plugins/zynaddsubfx/zynaddsubfx.h @@ -96,6 +96,11 @@ public: virtual ~zynAddSubFxView(); +protected: + virtual void dragEnterEvent( QDragEnterEvent * _dee ); + virtual void dropEvent( QDropEvent * _de ); + + private: void modelChanged( void );