ladspa_browser.cpp 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. /*
  2. * ladspa_browser.cpp - dialog to display information about installed LADSPA
  3. * plugins
  4. *
  5. * Copyright (c) 2006-2008 Danny McRae <khjklujn/at/users.sourceforge.net>
  6. * Copyright (c) 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 "ladspa_browser.h"
  27. #include <QHBoxLayout>
  28. #include <QLabel>
  29. #include "gui_templates.h"
  30. #include "ladspa_description.h"
  31. #include "ladspa_port_dialog.h"
  32. #include "TabBar.h"
  33. #include "TabButton.h"
  34. #include "embed.cpp"
  35. extern "C"
  36. {
  37. Plugin::Descriptor PLUGIN_EXPORT ladspabrowser_plugin_descriptor =
  38. {
  39. STRINGIFY( PLUGIN_NAME ),
  40. "LADSPA Plugin Browser",
  41. QT_TRANSLATE_NOOP( "pluginBrowser",
  42. "List installed LADSPA plugins" ),
  43. "Danny McRae <khjklujn/at/users.sourceforge.net>",
  44. 0x0100,
  45. Plugin::Tool,
  46. new PluginPixmapLoader( "logo" ),
  47. NULL,
  48. NULL
  49. } ;
  50. // necessary for getting instance out of shared lib
  51. Plugin * PLUGIN_EXPORT lmms_plugin_main( Model * _parent, void * _data )
  52. {
  53. return new ladspaBrowser;
  54. }
  55. }
  56. ladspaBrowser::ladspaBrowser() :
  57. ToolPlugin( &ladspabrowser_plugin_descriptor, NULL )
  58. {
  59. }
  60. ladspaBrowser::~ladspaBrowser()
  61. {
  62. }
  63. QString ladspaBrowser::nodeName() const
  64. {
  65. return ladspabrowser_plugin_descriptor.name;
  66. }
  67. ladspaBrowserView::ladspaBrowserView( ToolPlugin * _tool ) :
  68. ToolPluginView( _tool )
  69. {
  70. QHBoxLayout * hlayout = new QHBoxLayout( this );
  71. hlayout->setSpacing( 0 );
  72. hlayout->setMargin( 0 );
  73. m_tabBar = new TabBar( this, QBoxLayout::TopToBottom );
  74. m_tabBar->setExclusive( true );
  75. m_tabBar->setFixedWidth( 72 );
  76. QWidget * ws = new QWidget( this );
  77. ws->setFixedSize( 500, 480 );
  78. QWidget * available = createTab( ws, tr( "Available Effects" ), VALID );
  79. QWidget * unavailable = createTab( ws, tr( "Unavailable Effects" ),
  80. INVALID );
  81. QWidget * instruments = createTab( ws, tr( "Instruments" ), SOURCE );
  82. QWidget * analysis = createTab( ws, tr( "Analysis Tools" ), SINK );
  83. QWidget * other = createTab( ws, tr( "Don't know" ), OTHER );
  84. m_tabBar->addTab( available, tr( "Available Effects" ),
  85. 0, false, true
  86. )->setIcon( embed::getIconPixmap( "setup_audio" ) );
  87. m_tabBar->addTab( unavailable, tr( "Unavailable Effects" ),
  88. 1, false, true
  89. )->setIcon( embed::getIconPixmap(
  90. "unavailable_sound" ) );
  91. m_tabBar->addTab( instruments, tr( "Instruments" ),
  92. 2, false, true
  93. )->setIcon( embed::getIconPixmap(
  94. "setup_midi" ) );
  95. m_tabBar->addTab( analysis, tr( "Analysis Tools" ),
  96. 3, false, true
  97. )->setIcon( embed::getIconPixmap( "analysis" ) );
  98. m_tabBar->addTab( other, tr( "Don't know" ),
  99. 4, true, true
  100. )->setIcon( embed::getIconPixmap( "uhoh" ) );
  101. m_tabBar->setActiveTab( 0 );
  102. hlayout->addWidget( m_tabBar );
  103. hlayout->addSpacing( 10 );
  104. hlayout->addWidget( ws );
  105. hlayout->addSpacing( 10 );
  106. hlayout->addStretch();
  107. setWhatsThis( tr(
  108. "This dialog displays information on all of the LADSPA plugins LMMS was "
  109. "able to locate. The plugins are divided into five categories based "
  110. "upon an interpretation of the port types and names.\n\n"
  111. "Available Effects are those that can be used by LMMS. In order for LMMS "
  112. "to be able to use an effect, it must, first and foremost, be an effect, "
  113. "which is to say, it has to have both input channels and output channels. "
  114. "LMMS identifies an input channel as an audio rate port containing 'in' in "
  115. "the name. Output channels are identified by the letters 'out'. Furthermore, "
  116. "the effect must have the same number of inputs and outputs and be real time "
  117. "capable.\n\n"
  118. "Unavailable Effects are those that were identified as effects, but either "
  119. "didn't have the same number of input and output channels or weren't real "
  120. "time capable.\n\n"
  121. "Instruments are plugins for which only output channels were identified.\n\n"
  122. "Analysis Tools are plugins for which only input channels were identified.\n\n"
  123. "Don't Knows are plugins for which no input or output channels were "
  124. "identified.\n\n"
  125. "Double clicking any of the plugins will bring up information on the "
  126. "ports." ) );
  127. hide();
  128. if( parentWidget() )
  129. {
  130. parentWidget()->hide();
  131. parentWidget()->layout()->setSizeConstraint(
  132. QLayout::SetFixedSize );
  133. Qt::WindowFlags flags = parentWidget()->windowFlags();
  134. flags |= Qt::MSWindowsFixedSizeDialogHint;
  135. flags &= ~Qt::WindowMaximizeButtonHint;
  136. parentWidget()->setWindowFlags( flags );
  137. }
  138. }
  139. ladspaBrowserView::~ladspaBrowserView()
  140. {
  141. }
  142. QWidget * ladspaBrowserView::createTab( QWidget * _parent, const QString & _txt,
  143. ladspaPluginType _type )
  144. {
  145. QWidget * tab = new QWidget( _parent );
  146. tab->setFixedSize( 500, 400 );
  147. QVBoxLayout * layout = new QVBoxLayout( tab );
  148. layout->setSpacing( 0 );
  149. layout->setMargin( 0 );
  150. const QString type = "<b>" + tr( "Type:" ) + "</b> ";
  151. QLabel * title = new QLabel( type + _txt, tab );
  152. QFont f = title->font();
  153. f.setBold( true );
  154. title->setFont( pointSize<12>( f ) );
  155. layout->addSpacing( 5 );
  156. layout->addWidget( title );
  157. layout->addSpacing( 10 );
  158. ladspaDescription * description = new ladspaDescription( tab, _type );
  159. connect( description, SIGNAL( doubleClicked( const ladspa_key_t & ) ),
  160. SLOT( showPorts( const ladspa_key_t & ) ) );
  161. layout->addWidget( description, 1 );
  162. return tab;
  163. }
  164. void ladspaBrowserView::showPorts( const ladspa_key_t & _key )
  165. {
  166. ladspaPortDialog ports( _key );
  167. ports.exec();
  168. }