1
#ifndef SINGLE_SOURCE_COMPILE
4
* effect_select_dialog.cpp - dialog to choose effect plugin
6
* Copyright (c) 2006-2007 Tobias Doerffel <tobydox/at/users.sourceforge.net>
8
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
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.
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.
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.
28
#include "qt3support.h"
32
#include <QtGui/QGroupBox>
33
#include <QtGui/QLayout>
34
#include <QtGui/QPushButton>
35
#include <QtGui/QScrollArea>
39
#include <qgroupbox.h>
41
#include <qpushbutton.h>
46
#include "effect_select_dialog.h"
48
#include "gui_templates.h"
52
effectSelectDialog::effectSelectDialog( QWidget * _parent ) :
55
setWindowIcon( embed::getIconPixmap( "setup_audio" ) );
56
setWindowTitle( tr( "Effects Selector" ) );
59
QVBoxLayout * vlayout = new QVBoxLayout( this );
60
vlayout->setSpacing( 10 );
61
vlayout->setMargin( 10 );
63
effectList * elist = new effectList( this );
64
elist->setMinimumSize( 500, 400 );
65
connect( elist, SIGNAL( doubleClicked( const effectKey & ) ),
66
this, SLOT( selectPlugin() ) );
67
connect( elist, SIGNAL( highlighted( const effectKey & ) ),
68
this, SLOT( setSelection( const effectKey & ) ) );
69
m_currentSelection = elist->getSelected();
71
QWidget * buttons = new QWidget( this );
72
QHBoxLayout * btn_layout = new QHBoxLayout( buttons );
73
btn_layout->setSpacing( 0 );
74
btn_layout->setMargin( 0 );
77
QPushButton * select_btn = new QPushButton(
78
embed::getIconPixmap( "add" ),
79
tr( "Add" ), buttons );
80
connect( select_btn, SIGNAL( clicked() ),
81
this, SLOT( selectPlugin() ) );
83
/* QPushButton * ports_btn = new QPushButton(
84
embed::getIconPixmap("ports" ),
85
tr( "Ports" ), buttons );
86
connect( ports_btn, SIGNAL( clicked() ),
87
this, SLOT( showPorts() ) );
89
QPushButton * cancel_btn = new QPushButton(
90
embed::getIconPixmap( "cancel" ),
91
tr( "Cancel" ), buttons );
92
connect( cancel_btn, SIGNAL( clicked() ),
93
this, SLOT( reject() ) );
95
btn_layout->addStretch();
96
btn_layout->addSpacing( 10 );
97
btn_layout->addWidget( select_btn );
98
/* btn_layout->addSpacing( 10 );
99
btn_layout->addWidget( ports_btn );*/
100
btn_layout->addSpacing( 10 );
101
btn_layout->addWidget( cancel_btn );
102
btn_layout->addSpacing( 10 );
104
vlayout->addWidget( elist );
105
vlayout->addSpacing( 10 );
106
vlayout->addWidget( buttons );
107
vlayout->addSpacing( 10 );
108
//vlayout->addStretch();
116
effectSelectDialog::~effectSelectDialog()
123
effect * effectSelectDialog::instantiateSelectedPlugin( void )
125
if( !m_currentSelection.name.isEmpty() && m_currentSelection.desc )
127
return( effect::instantiate( m_currentSelection.desc->name,
128
&m_currentSelection ) );
136
void effectSelectDialog::showPorts( void )
138
/* ladspaPortDialog ports( m_currentSelection );
145
void effectSelectDialog::setSelection( const effectKey & _selection )
147
m_currentSelection = _selection;
153
void effectSelectDialog::selectPlugin( void )
164
effectList::effectList( QWidget * _parent ) :
167
plugin::getDescriptorsOfAvailPlugins( m_pluginDescriptors );
169
for( vvector<plugin::descriptor>::iterator it =
170
m_pluginDescriptors.begin();
171
it != m_pluginDescriptors.end(); ++it )
173
if( it->type != plugin::Effect )
177
if( it->sub_plugin_features )
179
it->sub_plugin_features->listSubPluginKeys(
180
// as iterators are always stated to be not
181
// equal with pointers, we dereference the
182
// iterator and take the address of the item,
183
// so we're on the safe side and the compiler
184
// likely will reduce that to just "it"
190
m_effectKeys << effectKey( &( *it ), it->name );
195
QStringList plugin_names;
196
for( effectKeyList::const_iterator it = m_effectKeys.begin();
197
it != m_effectKeys.end(); ++it )
199
plugin_names += QString( ( *it ).desc->public_name ) +
200
( ( ( *it ).desc->sub_plugin_features != NULL ) ?
206
m_pluginList = new Q3ListBox( this );
207
m_pluginList->insertStringList( plugin_names );
208
connect( m_pluginList, SIGNAL( highlighted( int ) ),
209
SLOT( onHighlighted( int ) ) );
210
connect( m_pluginList, SIGNAL( doubleClicked( QListBoxItem * ) ),
211
SLOT( onDoubleClicked( QListBoxItem * ) ) );
214
QGroupBox * groupbox = new QGroupBox( tr( "Description" ), this );
216
QGroupBox * groupbox = new QGroupBox( 1, Qt::Vertical,
217
tr( "Description" ), this );
219
groupbox->setFixedHeight( 200 );
221
groupbox->setInsideMargin( 2 );
224
QScrollArea * scrollArea = new QScrollArea( groupbox );
225
scrollArea->setFrameStyle( 0 );
227
scrollArea->setMargin( 10 );
230
m_descriptionWidget = new QWidget;
231
QVBoxLayout * l = new QVBoxLayout( m_descriptionWidget );
235
scrollArea->setWidget( m_descriptionWidget );
236
m_descriptionWidget->show();
237
m_descriptionWidget->setFixedSize( 200, 200 );
239
m_descriptionWidget = new QVBox( scrollArea->viewport() );
240
scrollArea->addChild( m_descriptionWidget );
243
QVBoxLayout * vboxl = new QVBoxLayout( this );
244
vboxl->setMargin( 0 );
245
vboxl->setSpacing( 10 );
246
vboxl->addWidget( m_pluginList );
247
vboxl->addWidget( groupbox );
249
if( m_pluginList->numRows() > 0 )
251
m_pluginList->setSelected( 0, true );
259
effectList::~effectList()
266
void effectList::onHighlighted( int _pluginIndex )
270
while( ( i = m_descriptionWidget->layout() ) != 0 )
275
QLayoutIterator it = m_descriptionWidget->layout()->iterator();
276
while( it.current() )
281
m_descriptionWidget->hide();
283
m_currentSelection = m_effectKeys[_pluginIndex];
284
if( m_currentSelection.desc &&
285
m_currentSelection.desc->sub_plugin_features )
287
m_currentSelection.desc->sub_plugin_features->
288
fillDescriptionWidget( m_descriptionWidget,
289
&m_currentSelection );
290
m_descriptionWidget->show();
292
emit( highlighted( m_currentSelection ) );
298
void effectList::onDoubleClicked( QListBoxItem * _item )
300
emit( doubleClicked( m_currentSelection ) );
306
void effectList::onAddButtonReleased()
308
emit( addPlugin( m_currentSelection ) );
314
void effectList::resizeEvent( QResizeEvent * )
316
m_descriptionWidget->setFixedWidth( width() - 40 );
322
#include "effect_select_dialog.moc"