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).
This commit is contained in:
Tobias Doerffel
2009-04-18 23:52:42 +02:00
parent 232c1de404
commit d38d437349
2 changed files with 49 additions and 0 deletions

View File

@@ -27,6 +27,7 @@
#include <Qt/QtXml>
#include <QtCore/QTemporaryFile>
#include <QtGui/QDropEvent>
#include <QtGui/QPushButton>
#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<zynAddSubFx>()->loadFile( value );
_de->accept();
return;
}
_de->ignore();
}
void zynAddSubFxView::modelChanged( void )
{
toggleUI();

View File

@@ -96,6 +96,11 @@ public:
virtual ~zynAddSubFxView();
protected:
virtual void dragEnterEvent( QDragEnterEvent * _dee );
virtual void dropEvent( QDropEvent * _de );
private:
void modelChanged( void );