ladspa_browser.cpp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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.h"
  35. #include "plugin_export.h"
  36. extern "C"
  37. {
  38. Plugin::Descriptor PLUGIN_EXPORT ladspabrowser_plugin_descriptor =
  39. {
  40. STRINGIFY( PLUGIN_NAME ),
  41. "LADSPA Plugin Browser",
  42. QT_TRANSLATE_NOOP( "PluginBrowser",
  43. "List installed LADSPA plugins" ),
  44. "Danny McRae <khjklujn/at/users.sourceforge.net>",
  45. 0x0100,
  46. Plugin::Tool,
  47. new PluginPixmapLoader("logo"),
  48. NULL,
  49. NULL
  50. } ;
  51. // necessary for getting instance out of shared lib
  52. PLUGIN_EXPORT Plugin * lmms_plugin_main( Model * _parent, void * _data )
  53. {
  54. return new ladspaBrowser;
  55. }
  56. }
  57. ladspaBrowser::ladspaBrowser() :
  58. ToolPlugin( &ladspabrowser_plugin_descriptor, NULL )
  59. {
  60. }
  61. ladspaBrowser::~ladspaBrowser()
  62. {
  63. }
  64. QString ladspaBrowser::nodeName() const
  65. {
  66. return ladspabrowser_plugin_descriptor.name;
  67. }
  68. ladspaBrowserView::ladspaBrowserView( ToolPlugin * _tool ) :
  69. ToolPluginView( _tool )
  70. {
  71. QHBoxLayout * hlayout = new QHBoxLayout( this );
  72. hlayout->setSpacing( 0 );
  73. hlayout->setMargin( 0 );
  74. m_tabBar = new TabBar( this, QBoxLayout::TopToBottom );
  75. m_tabBar->setExclusive( true );
  76. m_tabBar->setFixedWidth( 72 );
  77. QWidget * ws = new QWidget( this );
  78. ws->setFixedSize( 500, 480 );
  79. QWidget * available = createTab( ws, tr( "Available Effects" ), VALID );
  80. QWidget * unavailable = createTab( ws, tr( "Unavailable Effects" ),
  81. INVALID );
  82. QWidget * instruments = createTab( ws, tr( "Instruments" ), SOURCE );
  83. QWidget * analysis = createTab( ws, tr( "Analysis Tools" ), SINK );
  84. QWidget * other = createTab( ws, tr( "Don't know" ), OTHER );
  85. m_tabBar->addTab( available, tr( "Available Effects" ),
  86. 0, false, true
  87. )->setIcon( embed::getIconPixmap( "setup_audio" ) );
  88. m_tabBar->addTab( unavailable, tr( "Unavailable Effects" ),
  89. 1, false, true
  90. )->setIcon( embed::getIconPixmap(
  91. "unavailable_sound" ) );
  92. m_tabBar->addTab( instruments, tr( "Instruments" ),
  93. 2, false, true
  94. )->setIcon( embed::getIconPixmap(
  95. "setup_midi" ) );
  96. m_tabBar->addTab( analysis, tr( "Analysis Tools" ),
  97. 3, false, true
  98. )->setIcon( embed::getIconPixmap( "analysis" ) );
  99. m_tabBar->addTab( other, tr( "Don't know" ),
  100. 4, true, true
  101. )->setIcon( embed::getIconPixmap( "uhoh" ) );
  102. m_tabBar->setActiveTab( 0 );
  103. hlayout->addWidget( m_tabBar );
  104. hlayout->addSpacing( 10 );
  105. hlayout->addWidget( ws );
  106. hlayout->addSpacing( 10 );
  107. hlayout->addStretch();
  108. hide();
  109. if( parentWidget() )
  110. {
  111. parentWidget()->hide();
  112. parentWidget()->layout()->setSizeConstraint(
  113. QLayout::SetFixedSize );
  114. Qt::WindowFlags flags = parentWidget()->windowFlags();
  115. flags |= Qt::MSWindowsFixedSizeDialogHint;
  116. flags &= ~Qt::WindowMaximizeButtonHint;
  117. parentWidget()->setWindowFlags( flags );
  118. }
  119. }
  120. ladspaBrowserView::~ladspaBrowserView()
  121. {
  122. }
  123. QWidget * ladspaBrowserView::createTab( QWidget * _parent, const QString & _txt,
  124. ladspaPluginType _type )
  125. {
  126. QWidget * tab = new QWidget( _parent );
  127. tab->setFixedSize( 500, 400 );
  128. QVBoxLayout * layout = new QVBoxLayout( tab );
  129. layout->setSpacing( 0 );
  130. layout->setMargin( 0 );
  131. const QString type = "<b>" + tr( "Type:" ) + "</b> ";
  132. QLabel * title = new QLabel( type + _txt, tab );
  133. QFont f = title->font();
  134. f.setBold( true );
  135. title->setFont( pointSize<12>( f ) );
  136. layout->addSpacing( 5 );
  137. layout->addWidget( title );
  138. layout->addSpacing( 10 );
  139. ladspaDescription * description = new ladspaDescription( tab, _type );
  140. connect( description, SIGNAL( doubleClicked( const ladspa_key_t & ) ),
  141. SLOT( showPorts( const ladspa_key_t & ) ) );
  142. layout->addWidget( description, 1 );
  143. return tab;
  144. }
  145. void ladspaBrowserView::showPorts( const ladspa_key_t & _key )
  146. {
  147. ladspaPortDialog ports( _key );
  148. ports.exec();
  149. }