diff --git a/cmake/modules/BuildPlugin.cmake b/cmake/modules/BuildPlugin.cmake index 3add7866188..438eebb90e3 100644 --- a/cmake/modules/BuildPlugin.cmake +++ b/cmake/modules/BuildPlugin.cmake @@ -57,7 +57,7 @@ MACRO(BUILD_PLUGIN PLUGIN_NAME) ENDIF(LMMS_BUILD_APPLE) IF(LMMS_BUILD_WIN32) SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES PREFIX "") - ADD_CUSTOM_COMMAND(TARGET ${PLUGIN_NAME} POST_BUILD COMMAND ${STRIP} ${CMAKE_CURRENT_BINARY_DIR}/${PLUGIN_NAME}.dll) + ADD_CUSTOM_COMMAND(TARGET ${PLUGIN_NAME} POST_BUILD COMMAND ${STRIP} $) ENDIF(LMMS_BUILD_WIN32) SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${ER_H} ${plugin_MOC_out}") diff --git a/include/ConfigManager.h b/include/ConfigManager.h index f0d8996e0fe..9e2b172595c 100644 --- a/include/ConfigManager.h +++ b/include/ConfigManager.h @@ -165,11 +165,6 @@ class EXPORT ConfigManager return m_sf2Dir; } - const QString & pluginDir() const - { - return m_pluginDir; - } - const QString & vstDir() const { return m_vstDir; @@ -257,7 +252,6 @@ class EXPORT ConfigManager QString m_workingDir; QString m_dataDir; QString m_artworkDir; - QString m_pluginDir; QString m_vstDir; QString m_flDir; QString m_ladDir; diff --git a/include/EffectSelectDialog.h b/include/EffectSelectDialog.h index 658966bdf0a..995f14fb159 100644 --- a/include/EffectSelectDialog.h +++ b/include/EffectSelectDialog.h @@ -55,7 +55,6 @@ protected slots: private: Ui::EffectSelectDialog * ui; - Plugin::DescriptorList m_pluginDescriptors; EffectKeyList m_effectKeys; EffectKey m_currentSelection; diff --git a/include/Engine.h b/include/Engine.h index 659c1ee1a74..2d61dceacdc 100644 --- a/include/Engine.h +++ b/include/Engine.h @@ -49,6 +49,8 @@ class EXPORT Engine : public QObject static void init(); static void destroy(); + // TODO: Remove me. Replace calls like `if( Engine::hasGUI() )` with + // `if (gui)` (gui defined in "GuiApplication.h" static bool hasGUI(); // core @@ -93,11 +95,6 @@ class EXPORT Engine : public QObject } static void updateFramesPerTick(); - static const QMap & pluginFileHandling() - { - return s_pluginFileHandling; - } - static inline Engine * inst() { if( s_instanceOfMe == NULL ) @@ -134,13 +131,9 @@ class EXPORT Engine : public QObject static Ladspa2LMMS * s_ladspaManager; - static QMap s_pluginFileHandling; - // even though most methods are static, an instance is needed for Qt slots/signals static Engine * s_instanceOfMe; - static void initPluginFileHandling(); - friend class GuiApplication; }; diff --git a/include/Plugin.h b/include/Plugin.h index 4bed7307da5..a182acea1cb 100644 --- a/include/Plugin.h +++ b/include/Plugin.h @@ -137,9 +137,8 @@ class EXPORT Plugin : public Model, public JournallingObject SubPluginFeatures * subPluginFeatures; } ; - // typedef a list so we can easily work with list of plugin descriptors - typedef QList DescriptorList; + typedef QList DescriptorList; // contructor of a plugin Plugin( const Descriptor * descriptor, Model * parent ); @@ -177,9 +176,6 @@ class EXPORT Plugin : public Model, public JournallingObject // if specified plugin couldn't be loaded, it creates a dummy-plugin static Plugin * instantiate( const QString& pluginName, Model * parent, void * data ); - // fills given list with descriptors of all available plugins - static void getDescriptorsOfAvailPlugins( DescriptorList & pluginDescriptors ); - // create a view for the model PluginView * createView( QWidget * parent ); diff --git a/include/PluginBrowser.h b/include/PluginBrowser.h index ee399e25a36..9f54d86ec9d 100644 --- a/include/PluginBrowser.h +++ b/include/PluginBrowser.h @@ -55,9 +55,6 @@ class PluginDescList : public QWidget Q_OBJECT public: PluginDescList(QWidget* parent); - -private: - Plugin::DescriptorList m_pluginDescriptors; }; diff --git a/include/PluginFactory.h b/include/PluginFactory.h new file mode 100644 index 00000000000..7cf4806e21e --- /dev/null +++ b/include/PluginFactory.h @@ -0,0 +1,92 @@ +/* + * PluginFactory.h + * + * Copyright (c) 2015 Lukas W + * + * This file is part of LMMS - http://lmms.io + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + +#ifndef PLUGINFACTORY_H +#define PLUGINFACTORY_H + +#include +#include + +#include "export.h" +#include "Plugin.h" + +class QLibrary; + +class EXPORT PluginFactory +{ +public: + struct PluginInfo + { + PluginInfo() : library(nullptr), descriptor(nullptr) {} + const QString name() const; + QFileInfo file; + QLibrary* library; + Plugin::Descriptor* descriptor; + + bool isNull() const {return library == 0;} + }; + typedef QList PluginInfoList; + typedef QMultiMap DescriptorMap; + + PluginFactory(); + ~PluginFactory(); + + /// Returns the singleton instance of PluginFactory. You won't need to call + /// this directly, use pluginFactory instead. + static PluginFactory* instance(); + + /// Returns a list of all found plugins' descriptors. + const Plugin::DescriptorList descriptors() const; + const Plugin::DescriptorList descriptors(Plugin::PluginTypes type) const; + + /// Returns a list of all found plugins' PluginFactory::PluginInfo objects. + const PluginInfoList& pluginInfos() const; + /// Returns a plugin that support the given file extension + const PluginInfo pluginSupportingExtension(const QString& ext); + + /// Returns the PluginInfo object of the plugin with the given name. + /// If the plugin is not found, an empty PluginInfo is returned (use + /// PluginInfo::isNull() to check this). + const PluginInfo pluginInfo(const char* name) const; + + /// When loading a library fails during discovery, the error string is saved. + /// It can be retrieved by calling this function. + QString errorString(QString pluginName) const; + +public slots: + void discoverPlugins(); + +private: + DescriptorMap m_descriptors; + PluginInfoList m_pluginInfos; + QMap m_pluginByExt; + + QHash m_errors; + + static PluginFactory* s_instance; +}; + +#define pluginFactory PluginFactory::instance() + +#endif // PLUGINFACTORY_H diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 92709423e84..86e53b01bea 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -1,3 +1,6 @@ +SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + INCLUDE_DIRECTORIES( ${SAMPLERATE_INCLUDE_DIRS} ) diff --git a/plugins/LadspaEffect/CMakeLists.txt b/plugins/LadspaEffect/CMakeLists.txt index 80802ec35e0..37a32ff24c0 100644 --- a/plugins/LadspaEffect/CMakeLists.txt +++ b/plugins/LadspaEffect/CMakeLists.txt @@ -1,3 +1,5 @@ +SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/ladspa") + IF(WANT_CAPS) ADD_SUBDIRECTORY(caps) ENDIF(WANT_CAPS) diff --git a/plugins/LadspaEffect/calf/CMakeLists.txt b/plugins/LadspaEffect/calf/CMakeLists.txt index d685f530202..3bd4ae0f8f6 100644 --- a/plugins/LadspaEffect/calf/CMakeLists.txt +++ b/plugins/LadspaEffect/calf/CMakeLists.txt @@ -13,7 +13,7 @@ ENDIF() SET_TARGET_PROPERTIES(calf PROPERTIES COMPILE_FLAGS "-O2 -finline-functions ${INLINE_FLAGS}") IF(LMMS_BUILD_WIN32) - ADD_CUSTOM_COMMAND(TARGET calf POST_BUILD COMMAND "${STRIP}" "\"${CMAKE_CURRENT_BINARY_DIR}/calf.dll\"") + ADD_CUSTOM_COMMAND(TARGET calf POST_BUILD COMMAND "${STRIP}" "$") ENDIF(LMMS_BUILD_WIN32) IF(NOT LMMS_BUILD_APPLE) SET_TARGET_PROPERTIES(calf PROPERTIES LINK_FLAGS "${LINK_FLAGS} -shared -Wl,-no-undefined") diff --git a/plugins/LadspaEffect/caps/CMakeLists.txt b/plugins/LadspaEffect/caps/CMakeLists.txt index 4576a5c4ad9..415908e2b42 100644 --- a/plugins/LadspaEffect/caps/CMakeLists.txt +++ b/plugins/LadspaEffect/caps/CMakeLists.txt @@ -9,7 +9,7 @@ SET_TARGET_PROPERTIES(caps PROPERTIES PREFIX "") SET_TARGET_PROPERTIES(caps PROPERTIES COMPILE_FLAGS "-O2 -funroll-loops -Wno-write-strings") IF(LMMS_BUILD_WIN32) - ADD_CUSTOM_COMMAND(TARGET caps POST_BUILD COMMAND "${STRIP}" "\"${CMAKE_CURRENT_BINARY_DIR}/caps.dll\"") + ADD_CUSTOM_COMMAND(TARGET caps POST_BUILD COMMAND "${STRIP}" \"$\") ENDIF(LMMS_BUILD_WIN32) IF(NOT LMMS_BUILD_APPLE) SET_TARGET_PROPERTIES(caps PROPERTIES LINK_FLAGS "${LINK_FLAGS} -shared -Wl,-no-undefined") diff --git a/plugins/LadspaEffect/cmt/CMakeLists.txt b/plugins/LadspaEffect/cmt/CMakeLists.txt index 382bfc4c4c7..81bb13dc267 100644 --- a/plugins/LadspaEffect/cmt/CMakeLists.txt +++ b/plugins/LadspaEffect/cmt/CMakeLists.txt @@ -7,7 +7,7 @@ SET_TARGET_PROPERTIES(cmt PROPERTIES PREFIX "") SET_TARGET_PROPERTIES(cmt PROPERTIES COMPILE_FLAGS "-Wall -O3 -fno-strict-aliasing") IF(LMMS_BUILD_WIN32) - ADD_CUSTOM_COMMAND(TARGET cmt POST_BUILD COMMAND "${STRIP}" "\"${CMAKE_CURRENT_BINARY_DIR}/cmt.dll\"") + ADD_CUSTOM_COMMAND(TARGET cmt POST_BUILD COMMAND "${STRIP}" \"$\") ELSE(LMMS_BUILD_WIN32) SET_TARGET_PROPERTIES(cmt PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -fPIC") ENDIF(LMMS_BUILD_WIN32) diff --git a/plugins/LadspaEffect/swh/CMakeLists.txt b/plugins/LadspaEffect/swh/CMakeLists.txt index 64d67bd5fa4..623da38bcaf 100644 --- a/plugins/LadspaEffect/swh/CMakeLists.txt +++ b/plugins/LadspaEffect/swh/CMakeLists.txt @@ -15,7 +15,7 @@ FOREACH(_item ${PLUGIN_SOURCES}) SET_TARGET_PROPERTIES("${_plugin}" PROPERTIES PREFIX "") SET_TARGET_PROPERTIES("${_plugin}" PROPERTIES COMPILE_FLAGS "-O3 -Wall -fomit-frame-pointer -fstrength-reduce -funroll-loops -ffast-math -c -fno-strict-aliasing") IF(LMMS_BUILD_WIN32) - ADD_CUSTOM_COMMAND(TARGET "${_plugin}" POST_BUILD COMMAND "${STRIP}" "\"${CMAKE_CURRENT_BINARY_DIR}/${_plugin}.dll\"") + ADD_CUSTOM_COMMAND(TARGET "${_plugin}" POST_BUILD COMMAND "${STRIP}" \"$\") ELSE(LMMS_BUILD_WIN32) SET_TARGET_PROPERTIES("${_plugin}" PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -fPIC -DPIC") ENDIF(LMMS_BUILD_WIN32) diff --git a/plugins/LadspaEffect/tap/CMakeLists.txt b/plugins/LadspaEffect/tap/CMakeLists.txt index b747f853b82..d9fdc386152 100644 --- a/plugins/LadspaEffect/tap/CMakeLists.txt +++ b/plugins/LadspaEffect/tap/CMakeLists.txt @@ -7,7 +7,7 @@ FOREACH(_item ${PLUGIN_SOURCES}) INSTALL(TARGETS "${_plugin}" LIBRARY DESTINATION "${PLUGIN_DIR}/ladspa") SET_TARGET_PROPERTIES("${_plugin}" PROPERTIES PREFIX "") IF(LMMS_BUILD_WIN32) - ADD_CUSTOM_COMMAND(TARGET "${_plugin}" POST_BUILD COMMAND "${STRIP}" "\"${CMAKE_CURRENT_BINARY_DIR}/${_plugin}.dll\"") + ADD_CUSTOM_COMMAND(TARGET "${_plugin}" POST_BUILD COMMAND "${STRIP}" \"$\") ENDIF(LMMS_BUILD_WIN32) IF(LMMS_BUILD_APPLE) SET_TARGET_PROPERTIES("${_plugin}" PROPERTIES LINK_FLAGS "${LINK_FLAGS} -Bsymbolic -lm") diff --git a/plugins/flp_import/CMakeLists.txt b/plugins/flp_import/CMakeLists.txt index 1a2c2c7e4d5..e4bfed8a706 100644 --- a/plugins/flp_import/CMakeLists.txt +++ b/plugins/flp_import/CMakeLists.txt @@ -2,4 +2,5 @@ INCLUDE(BuildPlugin) INCLUDE_DIRECTORIES(unrtf) +ADD_DEFINITIONS(--std=c++0x) BUILD_PLUGIN(flpimport FlpImport.cpp unrtf.cpp FlpImport.h) diff --git a/plugins/flp_import/FlpImport.cpp b/plugins/flp_import/FlpImport.cpp index c23097d2c89..312dfb0a778 100644 --- a/plugins/flp_import/FlpImport.cpp +++ b/plugins/flp_import/FlpImport.cpp @@ -51,6 +51,7 @@ #include "Oscillator.h" #include "Pattern.h" #include "Piano.h" +#include "PluginFactory.h" #include "ProjectJournal.h" #include "ProjectNotes.h" #include "Song.h" @@ -1637,22 +1638,15 @@ p->putValue( jt->pos, value, false ); // process all effects EffectKeyList effKeys; - Plugin::DescriptorList pluginDescs; - Plugin::getDescriptorsOfAvailPlugins( pluginDescs ); - for( Plugin::DescriptorList::ConstIterator it = pluginDescs.begin(); - it != pluginDescs.end(); ++it ) + for (const Plugin::Descriptor* desc : pluginFactory->descriptors(Plugin::Effect)) { - if( it->type != Plugin::Effect ) + if( desc->subPluginFeatures ) { - continue; - } - if( it->subPluginFeatures ) - { - it->subPluginFeatures->listSubPluginKeys( &( *it ), effKeys ); + desc->subPluginFeatures->listSubPluginKeys( desc, effKeys ); } else { - effKeys << EffectKey( &( *it ), it->name ); + effKeys << EffectKey( desc, desc->name ); } } diff --git a/plugins/vst_base/CMakeLists.txt b/plugins/vst_base/CMakeLists.txt index 94604eccc5e..11ef8279374 100644 --- a/plugins/vst_base/CMakeLists.txt +++ b/plugins/vst_base/CMakeLists.txt @@ -13,8 +13,7 @@ IF(LMMS_BUILD_WIN32) ENDIF() TARGET_LINK_LIBRARIES(RemoteVstPlugin -lpthread -lgdi32 -lws2_32) SET_TARGET_PROPERTIES(RemoteVstPlugin PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -O0") - - ADD_CUSTOM_COMMAND(TARGET RemoteVstPlugin POST_BUILD COMMAND "${STRIP}" "${CMAKE_CURRENT_BINARY_DIR}/RemoteVstPlugin.exe") + ADD_CUSTOM_COMMAND(TARGET RemoteVstPlugin POST_BUILD COMMAND "${STRIP}" "$") INSTALL(TARGETS RemoteVstPlugin RUNTIME DESTINATION "${PLUGIN_DIR}") IF(LMMS_BUILD_WIN64) diff --git a/plugins/vst_base/Win64/CMakeLists.txt b/plugins/vst_base/Win64/CMakeLists.txt index 814c86667f5..a815e9c5f54 100644 --- a/plugins/vst_base/Win64/CMakeLists.txt +++ b/plugins/vst_base/Win64/CMakeLists.txt @@ -4,7 +4,7 @@ SET(CMAKE_CXX_COMPILER "${CMAKE_CXX_COMPILER32}") ADD_EXECUTABLE(RemoteVstPlugin32 "${CMAKE_CURRENT_SOURCE_DIR}/../RemoteVstPlugin.cpp") TARGET_LINK_LIBRARIES(RemoteVstPlugin32 -lQtCore4 -lpthread -lgdi32 -lws2_32) -ADD_CUSTOM_COMMAND(TARGET RemoteVstPlugin32 POST_BUILD COMMAND "${STRIP}" "\"${CMAKE_CURRENT_BINARY_DIR}/RemoteVstPlugin32.exe\"") +ADD_CUSTOM_COMMAND(TARGET RemoteVstPlugin32 POST_BUILD COMMAND "${STRIP}" "$") SET_TARGET_PROPERTIES(RemoteVstPlugin32 PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} -O0") INSTALL(TARGETS RemoteVstPlugin32 RUNTIME DESTINATION "${PLUGIN_DIR}/32") diff --git a/plugins/zynaddsubfx/CMakeLists.txt b/plugins/zynaddsubfx/CMakeLists.txt index 264b5f81c5e..227e32d99d2 100644 --- a/plugins/zynaddsubfx/CMakeLists.txt +++ b/plugins/zynaddsubfx/CMakeLists.txt @@ -152,6 +152,6 @@ ENDIF(LMMS_BUILD_LINUX) IF(LMMS_BUILD_WIN32) - ADD_CUSTOM_COMMAND(TARGET ZynAddSubFxCore POST_BUILD COMMAND "${STRIP}" "\"${CMAKE_CURRENT_BINARY_DIR}/libZynAddSubFxCore.dll\"") - ADD_CUSTOM_COMMAND(TARGET RemoteZynAddSubFx POST_BUILD COMMAND "${STRIP}" "\"${CMAKE_CURRENT_BINARY_DIR}/RemoteZynAddSubFx.exe\"") + ADD_CUSTOM_COMMAND(TARGET ZynAddSubFxCore POST_BUILD COMMAND "${STRIP}" \"$\") + ADD_CUSTOM_COMMAND(TARGET RemoteZynAddSubFx POST_BUILD COMMAND "${STRIP}" \"$\") ENDIF(LMMS_BUILD_WIN32) diff --git a/src/core/BandLimitedWave.cpp b/src/core/BandLimitedWave.cpp index de608ba1d9c..b60cbd633a4 100644 --- a/src/core/BandLimitedWave.cpp +++ b/src/core/BandLimitedWave.cpp @@ -67,7 +67,7 @@ void BandLimitedWave::generateWaves() int i; // set wavetable directory - s_wavetableDir = ConfigManager::inst()->dataDir() + "wavetables/"; + s_wavetableDir = "data:wavetables/"; // set wavetable files QFile saw_file( s_wavetableDir + "saw.bin" ); diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index ae23ae6d9a0..e974d151f0f 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -45,6 +45,7 @@ set(LMMS_SRCS core/Piano.cpp core/PlayHandle.cpp core/Plugin.cpp + core/PluginFactory.cpp core/PresetPreviewPlayHandle.cpp core/ProjectJournal.cpp core/ProjectRenderer.cpp diff --git a/src/core/ConfigManager.cpp b/src/core/ConfigManager.cpp index fd9dcc31ffc..200767e5edd 100644 --- a/src/core/ConfigManager.cpp +++ b/src/core/ConfigManager.cpp @@ -59,18 +59,15 @@ ConfigManager::ConfigManager() : #endif ), m_artworkDir( defaultArtworkDir() ), -#ifdef LMMS_BUILD_WIN32 - m_pluginDir( qApp->applicationDirPath() - + QDir::separator() + "plugins" + QDir::separator() ), -#else - m_pluginDir( qApp->applicationDirPath() + '/' + PLUGIN_DIR ), -#endif m_vstDir( m_workingDir + "vst" + QDir::separator() ), m_flDir( QDir::home().absolutePath() ), m_gigDir( m_workingDir + GIG_PATH ), m_sf2Dir( m_workingDir + SF2_PATH ), m_version( defaultVersion() ) { + if (! qgetenv("LMMS_DATA_DIR").isEmpty()) + QDir::addSearchPath("data", QString::fromLocal8Bit(qgetenv("LMMS_DATA_DIR"))); + QDir::addSearchPath("data", m_dataDir); } @@ -372,7 +369,7 @@ void ConfigManager::loadConfigFile() ( !m_ladDir.contains( ':' ) && !QDir( m_ladDir ).exists() ) ) { #if defined(LMMS_BUILD_WIN32) - m_ladDir = m_pluginDir + "ladspa" + QDir::separator(); + m_ladDir = qApp->applicationDirPath() + "/plugins/ladspa" + QDir::separator(); #elif defined(LMMS_BUILD_APPLE) m_ladDir = qApp->applicationDirPath() + "/../lib/lmms/ladspa/"; #else @@ -395,9 +392,11 @@ void ConfigManager::loadConfigFile() } #endif - - QDir::setSearchPaths( "resources", QStringList() << artworkDir() - << defaultArtworkDir() ); + QStringList searchPaths; + if(! qgetenv("LMMS_THEME_PATH").isNull()) + searchPaths << qgetenv("LMMS_THEME_PATH"); + searchPaths << artworkDir() << defaultArtworkDir(); + QDir::setSearchPaths( "resources", searchPaths); if( !QDir( m_workingDir ).exists() && QApplication::type() == QApplication::GuiClient && diff --git a/src/core/DataFile.cpp b/src/core/DataFile.cpp index ccd5d07c031..d2e76aab747 100644 --- a/src/core/DataFile.cpp +++ b/src/core/DataFile.cpp @@ -36,6 +36,7 @@ #include "ConfigManager.h" +#include "PluginFactory.h" #include "ProjectVersion.h" #include "ProjectVersion.h" #include "SongEditor.h" @@ -188,7 +189,7 @@ bool DataFile::validate( QString extension ) case Type::UnknownType: if (! ( extension == "mmp" || extension == "mpt" || extension == "mmpz" || extension == "xpf" || extension == "xml" || - ( extension == "xiz" && Engine::pluginFileHandling().contains( extension ) ) || + ( extension == "xiz" && ! pluginFactory->pluginSupportingExtension(extension).isNull()) || extension == "sf2" || extension == "pat" || extension == "mid" || extension == "flp" || extension == "dll" ) ) diff --git a/src/core/EffectChain.cpp b/src/core/EffectChain.cpp index f310f94dc45..0a2d1d71031 100644 --- a/src/core/EffectChain.cpp +++ b/src/core/EffectChain.cpp @@ -57,17 +57,17 @@ void EffectChain::saveSettings( QDomDocument & _doc, QDomElement & _this ) _this.setAttribute( "enabled", m_enabledModel.value() ); _this.setAttribute( "numofeffects", m_effects.count() ); - for( EffectList::Iterator it = m_effects.begin(); it != m_effects.end(); it++ ) + for( Effect* effect : m_effects) { - if( dynamic_cast( *it ) ) + if( DummyEffect* dummy = dynamic_cast(effect) ) { - _this.appendChild( dynamic_cast( *it )->originalPluginData() ); + _this.appendChild( dummy->originalPluginData() ); } else { - QDomElement ef = ( *it )->saveState( _doc, _this ); - ef.setAttribute( "name", ( *it )->descriptor()->name ); - ef.appendChild( ( *it )->key().saveXML( _doc ) ); + QDomElement ef = effect->saveState( _doc, _this ); + ef.setAttribute( "name", QString::fromUtf8( effect->descriptor()->name ) ); + ef.appendChild( effect->key().saveXML( _doc ) ); } } } @@ -94,7 +94,7 @@ void EffectChain::loadSettings( const QDomElement & _this ) const QString name = effectData.attribute( "name" ); EffectKey key( effectData.elementsByTagName( "key" ).item( 0 ).toElement() ); - Effect* e = Effect::instantiate( name, this, &key ); + Effect* e = Effect::instantiate( name.toUtf8(), this, &key ); if( e != NULL && e->isOkay() && e->nodeName() == node.nodeName() ) { diff --git a/src/core/Engine.cpp b/src/core/Engine.cpp index 8e5d85139ed..348009eb243 100644 --- a/src/core/Engine.cpp +++ b/src/core/Engine.cpp @@ -32,6 +32,7 @@ #include "PresetPreviewPlayHandle.h" #include "ProjectJournal.h" #include "Plugin.h" +#include "PluginFactory.h" #include "Song.h" #include "BandLimitedWave.h" @@ -45,7 +46,6 @@ Song * Engine::s_song = NULL; ProjectJournal * Engine::s_projectJournal = NULL; Ladspa2LMMS * Engine::s_ladspaManager = NULL; DummyTrackContainer * Engine::s_dummyTC = NULL; -QMap Engine::s_pluginFileHandling; @@ -58,9 +58,6 @@ void Engine::init() // generate (load from file) bandlimited wavetables BandLimitedWave::generateWaves(); - emit engine->initProgress(tr("Locating plugins")); - initPluginFileHandling(); - emit engine->initProgress(tr("Initializing data structures")); s_projectJournal = new ProjectJournal; s_mixer = new Mixer; @@ -124,29 +121,4 @@ void Engine::updateFramesPerTick() DefaultTicksPerTact / s_song->getTempo(); } - - - -void Engine::initPluginFileHandling() -{ - Plugin::DescriptorList pluginDescriptors; - Plugin::getDescriptorsOfAvailPlugins( pluginDescriptors ); - for( Plugin::DescriptorList::ConstIterator it = pluginDescriptors.begin(); - it != pluginDescriptors.end(); ++it ) - { - if( it->type == Plugin::Instrument ) - { - const QStringList & ext = - QString( it->supportedFileTypes ). - split( QChar( ',' ) ); - for( QStringList::const_iterator itExt = ext.begin(); - itExt != ext.end(); ++itExt ) - { - s_pluginFileHandling[*itExt] = it->name; - } - } - } -} - - Engine * Engine::s_instanceOfMe = NULL; diff --git a/src/core/ImportFilter.cpp b/src/core/ImportFilter.cpp index e126de51251..7b5644721d0 100644 --- a/src/core/ImportFilter.cpp +++ b/src/core/ImportFilter.cpp @@ -2,7 +2,7 @@ * ImportFilter.cpp - base-class for all import-filters (MIDI, FLP etc) * * Copyright (c) 2006-2014 Tobias Doerffel - * + * * This file is part of LMMS - http://lmms.io * * This program is free software; you can redistribute it and/or @@ -28,10 +28,10 @@ #include "ImportFilter.h" #include "Engine.h" #include "TrackContainer.h" +#include "PluginFactory.h" #include "ProjectJournal.h" - ImportFilter::ImportFilter( const QString & _file_name, const Descriptor * _descriptor ) : Plugin( _descriptor, NULL ), @@ -52,9 +52,6 @@ ImportFilter::~ImportFilter() void ImportFilter::import( const QString & _file_to_import, TrackContainer* tc ) { - DescriptorList d; - Plugin::getDescriptorsOfAvailPlugins( d ); - bool successful = false; char * s = qstrdup( _file_to_import.toUtf8().constData() ); @@ -63,21 +60,17 @@ void ImportFilter::import( const QString & _file_to_import, const bool j = Engine::projectJournal()->isJournalling(); Engine::projectJournal()->setJournalling( false ); - for( Plugin::DescriptorList::ConstIterator it = d.begin(); - it != d.end(); ++it ) + for (const Plugin::Descriptor* desc : pluginFactory->descriptors(Plugin::ImportFilter)) { - if( it->type == Plugin::ImportFilter ) + Plugin * p = Plugin::instantiate( desc->name, NULL, s ); + if( dynamic_cast( p ) != NULL && + dynamic_cast( p )->tryImport( tc ) == true ) { - Plugin * p = Plugin::instantiate( it->name, NULL, s ); - if( dynamic_cast( p ) != NULL && - dynamic_cast( p )->tryImport( tc ) == true ) - { - delete p; - successful = true; - break; - } delete p; + successful = true; + break; } + delete p; } Engine::projectJournal()->setJournalling( j ); diff --git a/src/core/LadspaManager.cpp b/src/core/LadspaManager.cpp index 8dcb2015862..a397efc8648 100644 --- a/src/core/LadspaManager.cpp +++ b/src/core/LadspaManager.cpp @@ -43,7 +43,7 @@ LadspaManager::LadspaManager() split( LADSPA_PATH_SEPERATOR ); ladspaDirectories += ConfigManager::inst()->ladspaDir().split( ',' ); - ladspaDirectories.push_back( ConfigManager::inst()->pluginDir() + "ladspa" ); + ladspaDirectories.push_back( "plugins:ladspa" ); #ifndef LMMS_BUILD_WIN32 ladspaDirectories.push_back( qApp->applicationDirPath() + '/' + LIB_DIR + "ladspa" ); ladspaDirectories.push_back( "/usr/lib/ladspa" ); diff --git a/src/core/Plugin.cpp b/src/core/Plugin.cpp index 49aa41e25bb..f6409ef2dab 100644 --- a/src/core/Plugin.cpp +++ b/src/core/Plugin.cpp @@ -91,25 +91,25 @@ AutomatableModel * Plugin::childModel( const QString & ) - -Plugin * Plugin::instantiate( const QString & pluginName, Model * parent, +#include "PluginFactory.h" +Plugin * Plugin::instantiate( const QString& pluginName, Model * parent, void * data ) { - QLibrary pluginLibrary( ConfigManager::inst()->pluginDir() + pluginName ); - if( pluginLibrary.load() == false ) + const PluginFactory::PluginInfo& pi = pluginFactory->pluginInfo(pluginName.toUtf8()); + if( pi.isNull() ) { if( Engine::hasGUI() ) { QMessageBox::information( NULL, tr( "Plugin not found" ), tr( "The plugin \"%1\" wasn't found or could not be loaded!\nReason: \"%2\"" ). - arg( pluginName ).arg( pluginLibrary.errorString() ), + arg( pluginName ).arg( pluginFactory->errorString(pluginName) ), QMessageBox::Ok | QMessageBox::Default ); } return new DummyPlugin(); } - InstantiationHook instantiationHook = ( InstantiationHook )pluginLibrary.resolve( "lmms_plugin_main" ); + InstantiationHook instantiationHook = ( InstantiationHook ) pi.library->resolve( "lmms_plugin_main" ); if( instantiationHook == NULL ) { if( Engine::hasGUI() ) @@ -137,50 +137,6 @@ void Plugin::collectErrorForUI( QString errMsg ) -void Plugin::getDescriptorsOfAvailPlugins( DescriptorList& pluginDescriptors ) -{ - QDir directory( ConfigManager::inst()->pluginDir() ); -#ifdef LMMS_BUILD_WIN32 - QFileInfoList list = directory.entryInfoList( QStringList( "*.dll" ) ); -#else - QFileInfoList list = directory.entryInfoList( QStringList( "lib*.so" ) ); -#endif - foreach( const QFileInfo& f, list ) - { - QLibrary( f.absoluteFilePath() ).load(); - } - - foreach( const QFileInfo& f, list ) - { - QLibrary pluginLibrary( f.absoluteFilePath() ); - if( pluginLibrary.load() == false || - pluginLibrary.resolve( "lmms_plugin_main" ) == NULL ) - { - continue; - } - - QString descriptorName = f.baseName() + "_plugin_descriptor"; - if( descriptorName.left( 3 ) == "lib" ) - { - descriptorName = descriptorName.mid( 3 ); - } - - Descriptor* pluginDescriptor = (Descriptor *) pluginLibrary.resolve( descriptorName.toUtf8().constData() ); - if( pluginDescriptor == NULL ) - { - qWarning() << tr( "LMMS plugin %1 does not have a plugin descriptor named %2!" ). - arg( f.absoluteFilePath() ).arg( descriptorName ); - continue; - } - - pluginDescriptors += *pluginDescriptor; - } - -} - - - - PluginView * Plugin::createView( QWidget * parent ) { PluginView * pv = instantiateView( parent ); diff --git a/src/core/PluginFactory.cpp b/src/core/PluginFactory.cpp new file mode 100644 index 00000000000..43083164f06 --- /dev/null +++ b/src/core/PluginFactory.cpp @@ -0,0 +1,197 @@ +/* + * PluginFactory.cpp + * + * Copyright (c) 2015 Lukas W + * + * This file is part of LMMS - http://lmms.io + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + +#include "PluginFactory.h" + +#include +#include +#include +#include +#include + +#include "Plugin.h" + +#ifdef LMMS_BUILD_WIN32 + QStringList nameFilters("*.dll"); +#else + QStringList nameFilters("lib*.so"); +#endif + +PluginFactory* PluginFactory::s_instance = nullptr; + +PluginFactory::PluginFactory() +{ + // Adds a search path relative to the main executable to if the path exists. + auto addRelativeIfExists = [this] (const QString& path) { + QDir dir(qApp->applicationDirPath()); + if (!path.isEmpty() && dir.cd(path)) { + QDir::addSearchPath("plugins", dir.absolutePath()); + } + }; + + // We're either running LMMS installed on an Unixoid or we're running a + // portable version like we do on Windows. + // We want to find our plugins in both cases: + // (a) Installed (Unix): + // e.g. binary at /usr/bin/lmms - plugin dir at /usr/lib/lmms/ + // (b) Portable: + // e.g. binary at "C:/Program Files/LMMS/lmms.exe" + // plugins at "C:/Program Files/LMMS/plugins/" + +#ifndef LMMS_BUILD_WIN32 + addRelativeIfExists("../lib/lmms"); // Installed +#endif + addRelativeIfExists("plugins"); // Portable +#ifdef PLUGIN_DIR // We may also have received a relative directory via a define + addRelativeIfExists(PLUGIN_DIR); +#endif + // Or via an environment variable: + QString env_path; + if (!(env_path = qgetenv("LMMS_PLUGIN_DIR")).isEmpty()) + QDir::addSearchPath("plugins", env_path); + + discoverPlugins(); +} + +PluginFactory::~PluginFactory() +{ + +} + +PluginFactory* PluginFactory::instance() +{ + if (s_instance == nullptr) + s_instance = new PluginFactory(); + + return s_instance; +} + +const Plugin::DescriptorList PluginFactory::descriptors() const +{ + return m_descriptors.values(); +} + +const Plugin::DescriptorList PluginFactory::descriptors(Plugin::PluginTypes type) const +{ + return m_descriptors.values(type); +} + +const PluginFactory::PluginInfoList& PluginFactory::pluginInfos() const +{ + return m_pluginInfos; +} + +const PluginFactory::PluginInfo PluginFactory::pluginSupportingExtension(const QString& ext) +{ + PluginInfo* info = m_pluginByExt.value(ext, nullptr); + return info == nullptr ? PluginInfo() : *info; +} + +const PluginFactory::PluginInfo PluginFactory::pluginInfo(const char* name) const +{ + for (const PluginInfo* info : m_pluginInfos) + { + if (qstrcmp(info->descriptor->name, name) == 0) + return *info; + } + return PluginInfo(); +} + +QString PluginFactory::errorString(QString pluginName) const +{ + static QString notfound = qApp->translate("PluginFactory", "Plugin not found."); + return m_errors.value(pluginName, notfound); +} + +void PluginFactory::discoverPlugins() +{ + DescriptorMap descriptors; + PluginInfoList pluginInfos; + m_pluginByExt.clear(); + + const QFileInfoList& files = QDir("plugins:").entryInfoList(nameFilters); + + // Cheap dependency handling: zynaddsubfx needs ZynAddSubFxCore. By loading + // all libraries twice we ensure that libZynAddSubFxCore is found. + for (const QFileInfo& file : files) + { + QLibrary(file.absoluteFilePath()).load(); + } + + for (const QFileInfo& file : files) + { + QLibrary* library = new QLibrary(file.absoluteFilePath()); + + if (! library->load()) { + m_errors[file.baseName()] = library->errorString(); + continue; + } + if (library->resolve("lmms_plugin_main") == nullptr) { + continue; + } + + QString descriptorName = file.baseName() + "_plugin_descriptor"; + if( descriptorName.left(3) == "lib" ) + { + descriptorName = descriptorName.mid(3); + } + + Plugin::Descriptor* pluginDescriptor = (Plugin::Descriptor*) library->resolve(descriptorName.toUtf8().constData()); + if(pluginDescriptor == nullptr) + { + qWarning() << qApp->translate("PluginFactory", "LMMS plugin %1 does not have a plugin descriptor named %2!"). + arg(file.absoluteFilePath()).arg(descriptorName); + continue; + } + + PluginInfo* info = new PluginInfo; + info->file = file; + info->library = library; + info->descriptor = pluginDescriptor; + pluginInfos << info; + + for (const QString& ext : QString(info->descriptor->supportedFileTypes).split(',')) + { + m_pluginByExt.insert(ext, info); + } + + descriptors.insert(info->descriptor->type, info->descriptor); + } + + + for (PluginInfo* info : m_pluginInfos) + { + delete info->library; + delete info; + } + m_pluginInfos = pluginInfos; + m_descriptors = descriptors; +} + + + +const QString PluginFactory::PluginInfo::name() const +{ + return descriptor ? descriptor->name : QString(); +} diff --git a/src/core/PresetPreviewPlayHandle.cpp b/src/core/PresetPreviewPlayHandle.cpp index a91681758b5..4b8b4997044 100644 --- a/src/core/PresetPreviewPlayHandle.cpp +++ b/src/core/PresetPreviewPlayHandle.cpp @@ -33,6 +33,7 @@ #include "MidiPort.h" #include "DataFile.h" #include "NotePlayHandle.h" +#include "PluginFactory.h" #include "ProjectJournal.h" #include "TrackContainer.h" @@ -134,8 +135,7 @@ PresetPreviewPlayHandle::PresetPreviewPlayHandle( const QString & _preset_file, if( i == NULL || !i->descriptor()->supportsFileType( ext ) ) { i = s_previewTC->previewInstrumentTrack()-> - loadInstrument( - Engine::pluginFileHandling()[ext] ); + loadInstrument(pluginFactory->pluginSupportingExtension(ext).name()); } if( i != NULL ) { diff --git a/src/core/RemotePlugin.cpp b/src/core/RemotePlugin.cpp index 84555fb3c20..a9c02c0dcdd 100644 --- a/src/core/RemotePlugin.cpp +++ b/src/core/RemotePlugin.cpp @@ -130,8 +130,7 @@ bool RemotePlugin::init( const QString &pluginExecutable, reset( new shmFifo(), new shmFifo() ); m_failed = false; } - QString exec = ConfigManager::inst()->pluginDir() + - pluginExecutable; + QString exec = QFileInfo(QDir("plugins:"), pluginExecutable).absoluteFilePath(); QStringList args; // swap in and out for bidirectional communication diff --git a/src/gui/EffectSelectDialog.cpp b/src/gui/EffectSelectDialog.cpp index 9249116846a..b1a0c3fb3a9 100644 --- a/src/gui/EffectSelectDialog.cpp +++ b/src/gui/EffectSelectDialog.cpp @@ -28,6 +28,7 @@ #include "gui_templates.h" #include "embed.h" +#include "PluginFactory.h" #include @@ -44,31 +45,25 @@ EffectSelectDialog::EffectSelectDialog( QWidget * _parent ) : setWindowIcon( embed::getIconPixmap( "setup_audio" ) ); // query effects - Plugin::getDescriptorsOfAvailPlugins( m_pluginDescriptors ); EffectKeyList subPluginEffectKeys; - for( Plugin::DescriptorList::ConstIterator it = m_pluginDescriptors.begin(); - it != m_pluginDescriptors.end(); ++it ) + for (const Plugin::Descriptor* desc: pluginFactory->descriptors(Plugin::Effect)) { - if( it->type != Plugin::Effect ) + if( desc->subPluginFeatures ) { - continue; - } - if( it->subPluginFeatures ) - { - it->subPluginFeatures->listSubPluginKeys( + desc->subPluginFeatures->listSubPluginKeys( // as iterators are always stated to be not // equal with pointers, we dereference the // iterator and take the address of the item, // so we're on the safe side and the compiler // likely will reduce that to just "it" - &( *it ), + desc, subPluginEffectKeys ); } else { - m_effectKeys << EffectKey( &( *it ), it->name ); + m_effectKeys << EffectKey( desc, desc->name ); } } diff --git a/src/gui/FileBrowser.cpp b/src/gui/FileBrowser.cpp index e213d801c4d..cd95e5a7d0e 100644 --- a/src/gui/FileBrowser.cpp +++ b/src/gui/FileBrowser.cpp @@ -47,6 +47,7 @@ #include "InstrumentTrack.h" #include "MainWindow.h" #include "DataFile.h" +#include "PluginFactory.h" #include "PresetPreviewPlayHandle.h" #include "SamplePlayHandle.h" #include "Song.h" @@ -471,7 +472,7 @@ void FileBrowserTreeWidget::mousePressEvent(QMouseEvent * me ) m_previewPlayHandle = s; delete tf; } - else if( f->extension ()== "xiz" && Engine::pluginFileHandling().contains( f->extension() ) ) + else if( f->extension ()== "xiz" && ! pluginFactory->pluginSupportingExtension(f->extension()).isNull() ) { m_previewPlayHandle = new PresetPreviewPlayHandle( f->fullName(), f->handling() == FileItem::LoadByPlugin ); } @@ -614,7 +615,7 @@ void FileBrowserTreeWidget::handleFile(FileItem * f, InstrumentTrack * it ) !i->descriptor()->supportsFileType( e ) ) { i = it->loadInstrument( - Engine::pluginFileHandling()[e] ); + pluginFactory->pluginSupportingExtension(e).name() ); } i->loadFile( f->fullName() ); break; @@ -1045,7 +1046,7 @@ void FileItem::determineFileType( void ) m_type = PresetFile; m_handling = LoadAsPreset; } - else if( ext == "xiz" && Engine::pluginFileHandling().contains( ext ) ) + else if( ext == "xiz" && ! pluginFactory->pluginSupportingExtension(ext).isNull() ) { m_type = PresetFile; m_handling = LoadByPlugin; @@ -1079,7 +1080,7 @@ void FileItem::determineFileType( void ) } if( m_handling == NotSupported && - !ext.isEmpty() && Engine::pluginFileHandling().contains( ext ) ) + !ext.isEmpty() && ! pluginFactory->pluginSupportingExtension(ext).isNull() ) { m_handling = LoadByPlugin; // classify as sample if not classified by anything yet but can diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index b837a3fa2a6..80406ec7c58 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -55,6 +55,7 @@ #include "SideBar.h" #include "ConfigManager.h" #include "Mixer.h" +#include "PluginFactory.h" #include "PluginView.h" #include "ProjectNotes.h" #include "SetupDialog.h" @@ -325,18 +326,11 @@ void MainWindow::finalize() m_toolsMenu = new QMenu( this ); - Plugin::DescriptorList pluginDescriptors; - Plugin::getDescriptorsOfAvailPlugins( pluginDescriptors ); - for( Plugin::DescriptorList::ConstIterator it = pluginDescriptors.begin(); - it != pluginDescriptors.end(); ++it ) + for( const Plugin::Descriptor* desc : pluginFactory->descriptors(Plugin::Tool) ) { - if( it->type == Plugin::Tool ) - { - m_toolsMenu->addAction( it->logo->pixmap(), - it->displayName ); - m_tools.push_back( ToolPlugin::instantiate( it->name, - /*this*/NULL )->createView( this ) ); - } + m_toolsMenu->addAction( desc->logo->pixmap(), desc->displayName ); + m_tools.push_back( ToolPlugin::instantiate( desc->name, /*this*/NULL ) + ->createView(this) ); } if( !m_toolsMenu->isEmpty() ) { diff --git a/src/gui/PluginBrowser.cpp b/src/gui/PluginBrowser.cpp index 96f33ae7501..549b20bf9db 100644 --- a/src/gui/PluginBrowser.cpp +++ b/src/gui/PluginBrowser.cpp @@ -22,25 +22,27 @@ * */ +#include "PluginBrowser.h" + +#include // for std::sort + #include #include #include #include #include -#include "PluginBrowser.h" -#include // for std::sort - #include "embed.h" #include "debug.h" #include "templates.h" #include "gui_templates.h" #include "StringPairDrag.h" +#include "PluginFactory.h" -bool pluginBefore( const Plugin::Descriptor& d1, const Plugin::Descriptor& d2 ) +bool pluginBefore( const Plugin::Descriptor* d1, const Plugin::Descriptor* d2 ) { - return qstricmp( d1.displayName, d2.displayName ) < 0 ? true : false; + return qstricmp( d1->displayName, d2->displayName ) < 0 ? true : false; } @@ -93,18 +95,13 @@ PluginDescList::PluginDescList(QWidget *parent) : { QVBoxLayout* layout = new QVBoxLayout(this); - Plugin::getDescriptorsOfAvailPlugins( m_pluginDescriptors ); - std::sort(m_pluginDescriptors.begin(), m_pluginDescriptors.end(), pluginBefore); - - for( Plugin::DescriptorList::const_iterator it = m_pluginDescriptors.constBegin(); - it != m_pluginDescriptors.constEnd(); ++it ) + QList descs = pluginFactory->descriptors(Plugin::Instrument); + std::sort(descs.begin(), descs.end(), pluginBefore); + for (const Plugin::Descriptor* desc : descs) { - if( it->type == Plugin::Instrument ) - { - PluginDescWidget* p = new PluginDescWidget( *it, this ); - p->show(); - layout->addWidget(p); - } + PluginDescWidget* p = new PluginDescWidget( *desc, this ); + p->show(); + layout->addWidget(p); } setLayout(layout); diff --git a/src/gui/TrackContainerView.cpp b/src/gui/TrackContainerView.cpp index 29abbfc7cbb..94f6e0de7c2 100644 --- a/src/gui/TrackContainerView.cpp +++ b/src/gui/TrackContainerView.cpp @@ -47,6 +47,7 @@ #include "StringPairDrag.h" #include "Track.h" #include "GuiApplication.h" +#include "PluginFactory.h" TrackContainerView::TrackContainerView( TrackContainer * _tc ) : @@ -385,8 +386,7 @@ void TrackContainerView::dropEvent( QDropEvent * _de ) Track::create( Track::InstrumentTrack, m_tc ) ); Instrument * i = it->loadInstrument( - Engine::pluginFileHandling()[FileItem::extension( - value )]); + pluginFactory->pluginSupportingExtension(FileItem::extension(value)).name()); i->loadFile( value ); //it->toggledInstrumentTrackButton( true ); _de->accept(); diff --git a/src/gui/embed.cpp b/src/gui/embed.cpp index 4e6ecaa13b7..7d99bb0f179 100644 --- a/src/gui/embed.cpp +++ b/src/gui/embed.cpp @@ -71,19 +71,12 @@ QPixmap getIconPixmap( const char * pixmapName, int width, int height ) #ifdef PLUGIN_NAME for ( i = 0; i < candidates.size() && pixmap.isNull(); ++i ) { name = candidates.at( i ); - pixmap = QPixmap( ConfigManager::inst()->artworkDir() + "plugins/" + - STRINGIFY( PLUGIN_NAME ) + "_" + name ); + pixmap = QPixmap( "resources:plugins/" STRINGIFY( PLUGIN_NAME ) "_" + name ); } #endif for ( i = 0; i < candidates.size() && pixmap.isNull(); ++i ) { name = candidates.at( i ); - pixmap = QPixmap( ConfigManager::inst()->artworkDir() + name ); - } - - // nothing found, so look in default-artwork-dir - for ( i = 0; i < candidates.size() && pixmap.isNull(); ++i ) { - name = candidates.at( i ); - pixmap = QPixmap( ConfigManager::inst()->defaultArtworkDir() + name ); + pixmap = QPixmap( "resources:" + name ); } for ( i = 0; i < candidates.size() && pixmap.isNull(); ++i ) { diff --git a/src/tracks/InstrumentTrack.cpp b/src/tracks/InstrumentTrack.cpp index 19d936a1f4d..eb6a4a2b7a3 100644 --- a/src/tracks/InstrumentTrack.cpp +++ b/src/tracks/InstrumentTrack.cpp @@ -74,6 +74,7 @@ #include "DataFile.h" #include "NotePlayHandle.h" #include "Pattern.h" +#include "PluginFactory.h" #include "PluginView.h" #include "SamplePlayHandle.h" #include "Song.h" @@ -1687,7 +1688,7 @@ void InstrumentTrackWindow::dropEvent( QDropEvent* event ) if( !i->descriptor()->supportsFileType( ext ) ) { - i = m_track->loadInstrument( Engine::pluginFileHandling()[ext] ); + i = m_track->loadInstrument( pluginFactory->pluginSupportingExtension(ext).name() ); } i->loadFile( value );