ladspa_description.cpp 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. /*
  2. * ladspa_description.cpp - LADSPA plugin description
  3. *
  4. * Copyright (c) 2007 Javier Serrano Polo <jasp00/at/users.sourceforge.net>
  5. *
  6. * This file is part of LMMS - https://lmms.io
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2 of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public
  19. * License along with this program (see COPYING); if not, write to the
  20. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  21. * Boston, MA 02110-1301 USA.
  22. *
  23. */
  24. #include "ladspa_description.h"
  25. #include <QGroupBox>
  26. #include <QLabel>
  27. #include <QListWidget>
  28. #include <QScrollArea>
  29. #include <QVBoxLayout>
  30. #include "AudioDevice.h"
  31. #include "Engine.h"
  32. #include "Ladspa2LMMS.h"
  33. #include "Mixer.h"
  34. ladspaDescription::ladspaDescription( QWidget * _parent,
  35. ladspaPluginType _type ) :
  36. QWidget( _parent )
  37. {
  38. Ladspa2LMMS * manager = Engine::getLADSPAManager();
  39. l_sortable_plugin_t plugins;
  40. switch( _type )
  41. {
  42. case SOURCE:
  43. plugins = manager->getInstruments();
  44. break;
  45. case TRANSFER:
  46. plugins = manager->getValidEffects();
  47. break;
  48. case VALID:
  49. plugins = manager->getValidEffects();
  50. break;
  51. case INVALID:
  52. plugins = manager->getInvalidEffects();
  53. break;
  54. case SINK:
  55. plugins = manager->getAnalysisTools();
  56. break;
  57. case OTHER:
  58. plugins = manager->getOthers();
  59. break;
  60. default:
  61. break;
  62. }
  63. QList<QString> pluginNames;
  64. for( l_sortable_plugin_t::iterator it = plugins.begin();
  65. it != plugins.end(); ++it )
  66. {
  67. if( _type != VALID ||
  68. manager->getDescription( ( *it ).second )->inputChannels
  69. <= Engine::mixer()->audioDev()->channels() )
  70. {
  71. pluginNames.push_back( ( *it ).first );
  72. m_pluginKeys.push_back( ( *it ).second );
  73. }
  74. }
  75. QGroupBox * pluginsBox = new QGroupBox( tr( "Plugins" ), this );
  76. QListWidget * pluginList = new QListWidget( pluginsBox );
  77. pluginList->addItems( pluginNames );
  78. connect( pluginList, SIGNAL( currentRowChanged( int ) ),
  79. SLOT( rowChanged( int ) ) );
  80. connect( pluginList, SIGNAL( itemDoubleClicked( QListWidgetItem * ) ),
  81. SLOT( onDoubleClicked( QListWidgetItem * ) ) );
  82. ( new QVBoxLayout( pluginsBox ) )->addWidget( pluginList );
  83. QGroupBox * descriptionBox = new QGroupBox( tr( "Description" ), this );
  84. QVBoxLayout * descriptionLayout = new QVBoxLayout( descriptionBox );
  85. descriptionLayout->setSpacing( 0 );
  86. descriptionLayout->setMargin( 0 );
  87. m_scrollArea = new QScrollArea( descriptionBox );
  88. descriptionLayout->addWidget( m_scrollArea );
  89. QVBoxLayout * layout = new QVBoxLayout( this );
  90. layout->addWidget( pluginsBox );
  91. layout->addWidget( descriptionBox );
  92. if( pluginList->count() > 0 )
  93. {
  94. pluginList->setCurrentRow( 0 );
  95. m_currentSelection = m_pluginKeys[0];
  96. update( m_currentSelection );
  97. }
  98. }
  99. ladspaDescription::~ladspaDescription()
  100. {
  101. }
  102. void ladspaDescription::update( const ladspa_key_t & _key )
  103. {
  104. QWidget * description = new QWidget;
  105. m_scrollArea->setWidget( description );
  106. QVBoxLayout * layout = new QVBoxLayout( description );
  107. layout->setSizeConstraint( QLayout::SetFixedSize );
  108. Ladspa2LMMS * manager = Engine::getLADSPAManager();
  109. QLabel * name = new QLabel( description );
  110. name->setText( QWidget::tr( "Name: " ) + manager->getName( _key ) );
  111. layout->addWidget( name );
  112. QWidget * maker = new QWidget( description );
  113. QHBoxLayout * makerLayout = new QHBoxLayout( maker );
  114. makerLayout->setMargin( 0 );
  115. makerLayout->setSpacing( 0 );
  116. layout->addWidget( maker );
  117. QLabel * maker_label = new QLabel( maker );
  118. maker_label->setText( QWidget::tr( "Maker: " ) );
  119. maker_label->setAlignment( Qt::AlignTop );
  120. QLabel * maker_content = new QLabel( maker );
  121. maker_content->setText( manager->getMaker( _key ) );
  122. maker_content->setWordWrap( true );
  123. makerLayout->addWidget( maker_label );
  124. makerLayout->addWidget( maker_content, 1 );
  125. QWidget * copyright = new QWidget( description );
  126. QHBoxLayout * copyrightLayout = new QHBoxLayout( copyright );
  127. copyrightLayout->setMargin( 0 );
  128. copyrightLayout->setSpacing( 0 );
  129. layout->addWidget( copyright );
  130. QLabel * copyright_label = new QLabel( copyright );
  131. copyright_label->setText( QWidget::tr( "Copyright: " ) );
  132. copyright_label->setAlignment( Qt::AlignTop );
  133. QLabel * copyright_content = new QLabel( copyright );
  134. copyright_content->setText( manager->getCopyright( _key ) );
  135. copyright_content->setWordWrap( true );
  136. copyrightLayout->addWidget( copyright_label );
  137. copyrightLayout->addWidget( copyright_content, 1 );
  138. QLabel * requiresRealTime = new QLabel( description );
  139. requiresRealTime->setText( QWidget::tr( "Requires Real Time: " ) +
  140. ( manager->hasRealTimeDependency( _key ) ?
  141. QWidget::tr( "Yes" ) :
  142. QWidget::tr( "No" ) ) );
  143. layout->addWidget( requiresRealTime );
  144. QLabel * realTimeCapable = new QLabel( description );
  145. realTimeCapable->setText( QWidget::tr( "Real Time Capable: " ) +
  146. ( manager->isRealTimeCapable( _key ) ?
  147. QWidget::tr( "Yes" ) :
  148. QWidget::tr( "No" ) ) );
  149. layout->addWidget( realTimeCapable );
  150. QLabel * inplaceBroken = new QLabel( description );
  151. inplaceBroken->setText( QWidget::tr( "In Place Broken: " ) +
  152. ( manager->isInplaceBroken( _key ) ?
  153. QWidget::tr( "Yes" ) :
  154. QWidget::tr( "No" ) ) );
  155. layout->addWidget( inplaceBroken );
  156. QLabel * channelsIn = new QLabel( description );
  157. channelsIn->setText( QWidget::tr( "Channels In: " ) + QString::number(
  158. manager->getDescription( _key )->inputChannels ) );
  159. layout->addWidget( channelsIn );
  160. QLabel * channelsOut = new QLabel( description );
  161. channelsOut->setText( QWidget::tr( "Channels Out: " ) + QString::number(
  162. manager->getDescription( _key )->outputChannels ) );
  163. layout->addWidget( channelsOut );
  164. }
  165. void ladspaDescription::rowChanged( int _pluginIndex )
  166. {
  167. m_currentSelection = m_pluginKeys[_pluginIndex];
  168. update( m_currentSelection );
  169. }
  170. void ladspaDescription::onDoubleClicked( QListWidgetItem * _item )
  171. {
  172. emit( doubleClicked( m_currentSelection ) );
  173. }