VstSubPluginFeatures.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * VstSubPluginFeatures.cpp - derivation from
  3. * Plugin::Descriptor::SubPluginFeatures for
  4. * hosting VST-plugins
  5. *
  6. * Copyright (c) 2006-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
  7. *
  8. * This file is part of LMMS - https://lmms.io
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public
  12. * License as published by the Free Software Foundation; either
  13. * version 2 of the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public
  21. * License along with this program (see COPYING); if not, write to the
  22. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  23. * Boston, MA 02110-1301 USA.
  24. *
  25. */
  26. #include <QDir>
  27. #include <QLabel>
  28. #include "VstSubPluginFeatures.h"
  29. #include "ConfigManager.h"
  30. VstSubPluginFeatures::VstSubPluginFeatures( Plugin::PluginTypes _type ) :
  31. SubPluginFeatures( _type )
  32. {
  33. }
  34. void VstSubPluginFeatures::fillDescriptionWidget( QWidget * _parent,
  35. const Key * _key ) const
  36. {
  37. new QLabel( QWidget::tr( "Name: " ) + _key->name, _parent );
  38. new QLabel( QWidget::tr( "File: " ) + _key->attributes["file"], _parent );
  39. }
  40. void VstSubPluginFeatures::listSubPluginKeys( const Plugin::Descriptor * _desc,
  41. KeyList & _kl ) const
  42. {
  43. QStringList *dlls = new QStringList();
  44. const QString path = QString("");
  45. addPluginsFromDir(dlls, path );
  46. // TODO: eval m_type
  47. for( QStringList::ConstIterator it = dlls->begin();
  48. it != dlls->end(); ++it )
  49. {
  50. EffectKey::AttributeMap am;
  51. am["file"] = *it;
  52. _kl.push_back( Key( _desc, QFileInfo( *it ).baseName(), am ) );
  53. }
  54. delete dlls;
  55. }
  56. void VstSubPluginFeatures::addPluginsFromDir( QStringList* filenames, QString path ) const
  57. {
  58. QStringList dirs = QDir ( ConfigManager::inst()->vstDir() + path ).
  59. entryList( QStringList() << "*" ,
  60. QDir::Dirs, QDir::Name );
  61. for( int i = 0; i < dirs.size(); i++ )
  62. {
  63. if( dirs.at( i )[0] != '.' )
  64. {
  65. addPluginsFromDir( filenames, path+QDir::separator() + dirs.at( i ) );
  66. }
  67. }
  68. QStringList dlls = QDir( ConfigManager::inst()->vstDir() + path ).
  69. entryList( QStringList() << "*.dll",
  70. QDir::Files, QDir::Name );
  71. for( int i = 0; i < dlls.size(); i++ )
  72. {
  73. QString fName = path + QDir::separator() + dlls.at( i );
  74. fName.remove( 0, 1 );
  75. filenames->append( fName );
  76. }
  77. }