Chris@62
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@62
|
2
|
Chris@62
|
3 /*
|
Chris@62
|
4 Sonic Visualiser
|
Chris@62
|
5 An audio file viewer and annotation editor.
|
Chris@62
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@182
|
7 This file copyright 2006 Chris Cannam and QMUL.
|
Chris@62
|
8
|
Chris@62
|
9 This program is free software; you can redistribute it and/or
|
Chris@62
|
10 modify it under the terms of the GNU General Public License as
|
Chris@62
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@62
|
12 License, or (at your option) any later version. See the file
|
Chris@62
|
13 COPYING included with this distribution for more information.
|
Chris@62
|
14 */
|
Chris@62
|
15
|
Chris@62
|
16 #include "PluginParameterDialog.h"
|
Chris@62
|
17
|
Chris@62
|
18 #include "PluginParameterBox.h"
|
Chris@140
|
19 #include "WindowTypeSelector.h"
|
Chris@62
|
20
|
Chris@376
|
21 #include "TextAbbrev.h"
|
Chris@440
|
22 #include "IconLoader.h"
|
Chris@294
|
23
|
Chris@442
|
24 #include <vamp-hostsdk/Plugin.h>
|
Chris@442
|
25 #include <vamp-hostsdk/PluginHostAdapter.h>
|
Chris@442
|
26 #include <vamp-hostsdk/PluginWrapper.h>
|
Chris@106
|
27
|
Chris@62
|
28 #include <QGridLayout>
|
Chris@62
|
29 #include <QLabel>
|
Chris@62
|
30 #include <QGroupBox>
|
Chris@62
|
31 #include <QHBoxLayout>
|
Chris@143
|
32 #include <QVBoxLayout>
|
Chris@149
|
33 #include <QScrollArea>
|
Chris@62
|
34 #include <QPushButton>
|
Chris@69
|
35 #include <QMessageBox>
|
Chris@69
|
36 #include <QComboBox>
|
Chris@302
|
37 #include <QCheckBox>
|
Chris@143
|
38 #include <QSettings>
|
Chris@282
|
39 #include <QDialogButtonBox>
|
Chris@440
|
40 #include <QDesktopServices>
|
Chris@440
|
41 #include <QUrl>
|
Chris@62
|
42
|
Chris@682
|
43 #include "base/Debug.h"
|
Chris@682
|
44
|
Chris@71
|
45 PluginParameterDialog::PluginParameterDialog(Vamp::PluginBase *plugin,
|
Chris@1266
|
46 QWidget *parent) :
|
Chris@62
|
47 QDialog(parent),
|
Chris@62
|
48 m_plugin(plugin),
|
Chris@163
|
49 m_channel(-1),
|
Chris@145
|
50 m_stepSize(0),
|
Chris@145
|
51 m_blockSize(0),
|
Chris@145
|
52 m_windowType(HanningWindow),
|
Chris@302
|
53 m_parameterBox(0),
|
Chris@807
|
54 m_currentSelectionOnly(false)
|
Chris@62
|
55 {
|
Chris@122
|
56 setWindowTitle(tr("Plugin Parameters"));
|
Chris@122
|
57
|
Chris@62
|
58 QGridLayout *grid = new QGridLayout;
|
Chris@62
|
59 setLayout(grid);
|
Chris@62
|
60
|
Chris@62
|
61 QGroupBox *pluginBox = new QGroupBox;
|
Chris@208
|
62 pluginBox->setTitle(plugin->getType().c_str());
|
Chris@62
|
63 grid->addWidget(pluginBox, 0, 0);
|
Chris@62
|
64
|
Chris@62
|
65 QGridLayout *subgrid = new QGridLayout;
|
Chris@62
|
66 pluginBox->setLayout(subgrid);
|
Chris@62
|
67
|
Chris@63
|
68 subgrid->setSpacing(0);
|
Chris@63
|
69 subgrid->setMargin(10);
|
Chris@63
|
70
|
Chris@208
|
71 QFont boldFont(pluginBox->font());
|
Chris@208
|
72 boldFont.setBold(true);
|
Chris@208
|
73
|
Chris@208
|
74 QFont italicFont(pluginBox->font());
|
Chris@208
|
75 italicFont.setItalic(true);
|
Chris@62
|
76
|
Chris@207
|
77 QLabel *nameLabel = new QLabel(plugin->getName().c_str());
|
Chris@146
|
78 nameLabel->setWordWrap(true);
|
Chris@208
|
79 nameLabel->setFont(boldFont);
|
Chris@62
|
80
|
Chris@62
|
81 QLabel *makerLabel = new QLabel(plugin->getMaker().c_str());
|
Chris@146
|
82 makerLabel->setWordWrap(true);
|
Chris@62
|
83
|
Chris@441
|
84 int version = plugin->getPluginVersion();
|
Chris@441
|
85 QLabel *versionLabel = new QLabel(QString("%1").arg(version));
|
Chris@146
|
86 versionLabel->setWordWrap(true);
|
Chris@62
|
87
|
Chris@62
|
88 QLabel *copyrightLabel = new QLabel(plugin->getCopyright().c_str());
|
Chris@146
|
89 copyrightLabel->setWordWrap(true);
|
Chris@62
|
90
|
Chris@208
|
91 // QLabel *typeLabel = new QLabel(plugin->getType().c_str());
|
Chris@208
|
92 // typeLabel->setWordWrap(true);
|
Chris@208
|
93 // typeLabel->setFont(boldFont);
|
Chris@208
|
94
|
Chris@208
|
95 QLabel *descriptionLabel = 0;
|
Chris@208
|
96 if (plugin->getDescription() != "") {
|
Chris@208
|
97 descriptionLabel = new QLabel(plugin->getDescription().c_str());
|
Chris@208
|
98 descriptionLabel->setWordWrap(true);
|
Chris@208
|
99 descriptionLabel->setFont(italicFont);
|
Chris@208
|
100 }
|
Chris@63
|
101
|
Chris@163
|
102 int row = 0;
|
Chris@163
|
103
|
Chris@147
|
104 QLabel *label = new QLabel(tr("Name:"));
|
Chris@147
|
105 label->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
Chris@163
|
106 subgrid->addWidget(label, row, 0);
|
Chris@163
|
107 subgrid->addWidget(nameLabel, row, 1);
|
Chris@440
|
108
|
Chris@440
|
109 m_moreInfo = new QPushButton;
|
Chris@440
|
110 m_moreInfo->setIcon(IconLoader().load("info"));
|
Chris@440
|
111 m_moreInfo->setFixedSize(QSize(16, 16));
|
Chris@440
|
112 connect(m_moreInfo, SIGNAL(clicked()), this, SLOT(moreInfo()));
|
Chris@440
|
113 subgrid->addWidget(m_moreInfo, row, 2, Qt::AlignTop | Qt::AlignRight);
|
Chris@440
|
114 m_moreInfo->hide();
|
Chris@440
|
115
|
Chris@163
|
116 row++;
|
Chris@62
|
117
|
Chris@208
|
118 if (descriptionLabel) {
|
Chris@208
|
119 // label = new QLabel(tr("Description:"));
|
Chris@208
|
120 // label->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
Chris@208
|
121 // subgrid->addWidget(label, row, 0);
|
Chris@440
|
122 subgrid->addWidget(descriptionLabel, row, 1, 1, 2);
|
Chris@208
|
123 row++;
|
Chris@208
|
124 }
|
Chris@208
|
125
|
Chris@441
|
126 if (version >= 0) {
|
Chris@208
|
127 label = new QLabel(tr("Version:"));
|
Chris@208
|
128 label->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
Chris@208
|
129 subgrid->addWidget(label, row, 0);
|
Chris@208
|
130 subgrid->addWidget(versionLabel, row, 1);
|
Chris@208
|
131 row++;
|
Chris@208
|
132 }
|
Chris@208
|
133
|
Chris@208
|
134 // label = new QLabel(tr("Type:"));
|
Chris@208
|
135 // label->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
Chris@208
|
136 // subgrid->addWidget(label, row, 0);
|
Chris@208
|
137 // subgrid->addWidget(typeLabel, row, 1);
|
Chris@208
|
138 // row++;
|
Chris@62
|
139
|
Chris@147
|
140 label = new QLabel(tr("Maker:"));
|
Chris@147
|
141 label->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
Chris@163
|
142 subgrid->addWidget(label, row, 0);
|
Chris@163
|
143 subgrid->addWidget(makerLabel, row, 1);
|
Chris@163
|
144 row++;
|
Chris@63
|
145
|
Chris@147
|
146 label = new QLabel(tr("Copyright: "));
|
Chris@147
|
147 label->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
Chris@163
|
148 subgrid->addWidget(label, row, 0);
|
Chris@163
|
149 subgrid->addWidget(copyrightLabel, row, 1);
|
Chris@163
|
150 row++;
|
Chris@208
|
151
|
Chris@208
|
152 m_outputSpacer = new QLabel;
|
Chris@208
|
153 subgrid->addWidget(m_outputSpacer, row, 0);
|
Chris@208
|
154 m_outputSpacer->setFixedHeight(7);
|
Chris@208
|
155 m_outputSpacer->hide();
|
Chris@208
|
156 row++;
|
Chris@106
|
157
|
Chris@208
|
158 m_outputLabel = new QLabel(tr("Output:"));
|
Chris@208
|
159 m_outputLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
Chris@208
|
160 subgrid->addWidget(m_outputLabel, row, 0);
|
Chris@208
|
161 m_outputValue = new QLabel;
|
Chris@208
|
162 m_outputValue->setFont(boldFont);
|
Chris@208
|
163 subgrid->addWidget(m_outputValue, row, 1);
|
Chris@208
|
164 m_outputLabel->hide();
|
Chris@208
|
165 m_outputValue->hide();
|
Chris@208
|
166 row++;
|
Chris@208
|
167
|
Chris@208
|
168 m_outputDescription = new QLabel;
|
Chris@208
|
169 m_outputDescription->setFont(italicFont);
|
Chris@208
|
170 subgrid->addWidget(m_outputDescription, row, 1);
|
Chris@208
|
171 m_outputDescription->hide();
|
Chris@163
|
172 row++;
|
Chris@62
|
173
|
Chris@62
|
174 subgrid->setColumnStretch(1, 2);
|
Chris@62
|
175
|
Chris@164
|
176 m_inputModelBox = new QGroupBox;
|
Chris@302
|
177 m_inputModelBox->setTitle(tr("Input Material"));
|
Chris@164
|
178 grid->addWidget(m_inputModelBox, 1, 0);
|
Chris@164
|
179
|
Chris@164
|
180 m_inputModels = new QComboBox;
|
Chris@302
|
181 QVBoxLayout *inputLayout = new QVBoxLayout;
|
Chris@164
|
182 m_inputModelBox->setLayout(inputLayout);
|
Chris@164
|
183 inputLayout->addWidget(m_inputModels);
|
Chris@302
|
184 m_inputModels->hide();
|
Chris@302
|
185
|
Chris@302
|
186 m_selectionOnly = new QCheckBox(tr("Restrict to selection extents"));
|
Chris@302
|
187 inputLayout->addWidget(m_selectionOnly);
|
Chris@302
|
188 m_selectionOnly->hide();
|
Chris@302
|
189
|
Chris@164
|
190 m_inputModelBox->hide();
|
Chris@164
|
191
|
Chris@62
|
192 QGroupBox *paramBox = new QGroupBox;
|
Chris@62
|
193 paramBox->setTitle(tr("Plugin Parameters"));
|
Chris@164
|
194 grid->addWidget(paramBox, 2, 0);
|
Chris@164
|
195 grid->setRowStretch(2, 10);
|
Chris@62
|
196
|
Chris@62
|
197 QHBoxLayout *paramLayout = new QHBoxLayout;
|
Chris@63
|
198 paramLayout->setMargin(0);
|
Chris@62
|
199 paramBox->setLayout(paramLayout);
|
Chris@62
|
200
|
Chris@149
|
201 QScrollArea *scroll = new QScrollArea;
|
Chris@149
|
202 scroll->setWidgetResizable(true);
|
Chris@149
|
203 scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
Chris@149
|
204 scroll->setFrameShape(QFrame::NoFrame);
|
Chris@149
|
205 paramLayout->addWidget(scroll);
|
Chris@149
|
206
|
Chris@62
|
207 m_parameterBox = new PluginParameterBox(m_plugin);
|
Chris@64
|
208 connect(m_parameterBox, SIGNAL(pluginConfigurationChanged(QString)),
|
Chris@64
|
209 this, SIGNAL(pluginConfigurationChanged(QString)));
|
Chris@149
|
210 scroll->setWidget(m_parameterBox);
|
Chris@62
|
211
|
Chris@143
|
212 m_advanced = new QFrame;
|
Chris@143
|
213 QVBoxLayout *advancedLayout = new QVBoxLayout;
|
Chris@143
|
214 advancedLayout->setMargin(0);
|
Chris@143
|
215 m_advanced->setLayout(advancedLayout);
|
Chris@164
|
216 grid->addWidget(m_advanced, 3, 0);
|
Chris@143
|
217
|
Chris@163
|
218 m_channelBox = new QGroupBox;
|
Chris@163
|
219 m_channelBox->setTitle(tr("Channels"));
|
Chris@163
|
220 advancedLayout->addWidget(m_channelBox);
|
Chris@163
|
221 m_channelBox->setVisible(false);
|
Chris@163
|
222 m_haveChannelBoxData = false;
|
Chris@163
|
223
|
Chris@163
|
224 m_windowBox = new QGroupBox;
|
Chris@163
|
225 m_windowBox->setTitle(tr("Processing"));
|
Chris@163
|
226 advancedLayout->addWidget(m_windowBox);
|
Chris@163
|
227 m_windowBox->setVisible(false);
|
Chris@163
|
228 m_haveWindowBoxData = false;
|
Chris@163
|
229
|
Chris@163
|
230 QHBoxLayout *hbox = new QHBoxLayout;
|
Chris@163
|
231 grid->addLayout(hbox, 4, 0);
|
Chris@163
|
232
|
Chris@163
|
233 m_advancedVisible = false;
|
Chris@163
|
234
|
Chris@163
|
235 m_advancedButton = new QPushButton(tr("Advanced >>"));
|
Chris@163
|
236 m_advancedButton->setCheckable(true);
|
Chris@163
|
237 connect(m_advancedButton, SIGNAL(clicked()), this, SLOT(advancedToggled()));
|
Chris@163
|
238
|
Chris@163
|
239 QSettings settings;
|
Chris@163
|
240 settings.beginGroup("PluginParameterDialog");
|
Chris@163
|
241 m_advancedVisible = settings.value("advancedvisible", false).toBool();
|
Chris@163
|
242 settings.endGroup();
|
Chris@163
|
243
|
Chris@456
|
244 m_advanced->hide();
|
Chris@163
|
245
|
Chris@163
|
246 hbox->addWidget(m_advancedButton);
|
Chris@163
|
247 m_advancedButton->hide();
|
Chris@163
|
248
|
Chris@282
|
249 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok |
|
Chris@282
|
250 QDialogButtonBox::Cancel);
|
Chris@282
|
251 hbox->addWidget(bb);
|
Chris@294
|
252 connect(bb, SIGNAL(accepted()), this, SLOT(dialogAccepted()));
|
Chris@282
|
253 connect(bb, SIGNAL(rejected()), this, SLOT(reject()));
|
Chris@460
|
254 bb->button(QDialogButtonBox::Ok)->setDefault(true);
|
Chris@163
|
255
|
Chris@163
|
256 setAdvancedVisible(m_advancedVisible);
|
Chris@163
|
257 }
|
Chris@163
|
258
|
Chris@163
|
259 PluginParameterDialog::~PluginParameterDialog()
|
Chris@163
|
260 {
|
Chris@163
|
261 }
|
Chris@163
|
262
|
Chris@456
|
263 int
|
Chris@456
|
264 PluginParameterDialog::exec()
|
Chris@456
|
265 {
|
Chris@456
|
266 show();
|
Chris@456
|
267 setAdvancedVisible(m_advancedVisible);
|
Chris@456
|
268 return QDialog::exec();
|
Chris@456
|
269 }
|
Chris@456
|
270
|
Chris@163
|
271
|
Chris@163
|
272 void
|
Chris@208
|
273 PluginParameterDialog::setOutputLabel(QString text,
|
Chris@208
|
274 QString description)
|
Chris@163
|
275 {
|
Chris@163
|
276 if (text == "") {
|
Chris@208
|
277 m_outputSpacer->hide();
|
Chris@163
|
278 m_outputLabel->hide();
|
Chris@163
|
279 m_outputValue->hide();
|
Chris@208
|
280 m_outputDescription->hide();
|
Chris@163
|
281 } else {
|
Chris@208
|
282 m_outputSpacer->show();
|
Chris@163
|
283 m_outputValue->setText(text);
|
Chris@163
|
284 m_outputValue->setWordWrap(true);
|
Chris@208
|
285 m_outputDescription->setText(description);
|
Chris@309
|
286 m_outputDescription->setWordWrap(true);
|
Chris@163
|
287 m_outputLabel->show();
|
Chris@163
|
288 m_outputValue->show();
|
Chris@208
|
289 if (description != "") {
|
Chris@208
|
290 m_outputDescription->show();
|
Chris@208
|
291 } else {
|
Chris@208
|
292 m_outputDescription->hide();
|
Chris@208
|
293 }
|
Chris@163
|
294 }
|
Chris@163
|
295 }
|
Chris@163
|
296
|
Chris@163
|
297 void
|
Chris@440
|
298 PluginParameterDialog::setMoreInfoUrl(QString moreInfoUrl)
|
Chris@440
|
299 {
|
Chris@440
|
300 m_moreInfoUrl = moreInfoUrl;
|
Chris@440
|
301 if (m_moreInfoUrl != "") {
|
Chris@440
|
302 m_moreInfo->show();
|
Chris@440
|
303 } else {
|
Chris@440
|
304 m_moreInfo->hide();
|
Chris@440
|
305 }
|
Chris@440
|
306 }
|
Chris@440
|
307
|
Chris@440
|
308 void
|
Chris@163
|
309 PluginParameterDialog::setChannelArrangement(int sourceChannels,
|
Chris@163
|
310 int targetChannels,
|
Chris@163
|
311 int defaultChannel)
|
Chris@163
|
312 {
|
Chris@163
|
313 m_channel = defaultChannel;
|
Chris@163
|
314
|
Chris@69
|
315 if (sourceChannels != targetChannels) {
|
Chris@69
|
316
|
Chris@69
|
317 // At the moment we can only cope with the case where
|
Chris@69
|
318 // sourceChannels > targetChannels and targetChannels == 1
|
Chris@69
|
319
|
Chris@69
|
320 if (sourceChannels < targetChannels) {
|
Chris@69
|
321
|
Chris@69
|
322 QMessageBox::warning
|
Chris@163
|
323 (parentWidget(),
|
Chris@69
|
324 tr("Channel mismatch"),
|
Chris@69
|
325 tr("This plugin requires at least %1 input channels, but only %2 %3 available. The plugin probably will not work correctly.").arg(targetChannels).arg(sourceChannels).arg(sourceChannels != 1 ? tr("are") : tr("is")),
|
Chris@69
|
326 QMessageBox::Ok,
|
Chris@69
|
327 QMessageBox::NoButton);
|
Chris@69
|
328
|
Chris@69
|
329 } else {
|
Chris@69
|
330
|
Chris@163
|
331 if (m_haveChannelBoxData) {
|
Chris@682
|
332 cerr << "WARNING: PluginParameterDialog::setChannelArrangement: Calling more than once on same dialog is not currently implemented" << endl;
|
Chris@163
|
333 return;
|
Chris@163
|
334 }
|
Chris@69
|
335
|
Chris@69
|
336 QVBoxLayout *channelLayout = new QVBoxLayout;
|
Chris@163
|
337 m_channelBox->setLayout(channelLayout);
|
Chris@69
|
338
|
Chris@69
|
339 if (targetChannels != 1) {
|
Chris@69
|
340
|
Chris@69
|
341 channelLayout->addWidget
|
Chris@69
|
342 (new QLabel(tr("This plugin accepts no more than %1 input channels,\nbut %2 are available. Only the first %3 will be used.\n")
|
Chris@69
|
343 .arg(targetChannels)
|
Chris@69
|
344 .arg(sourceChannels)
|
Chris@69
|
345 .arg(targetChannels)));
|
Chris@69
|
346
|
Chris@69
|
347 } else {
|
Chris@69
|
348
|
Chris@69
|
349 channelLayout->addWidget(new QLabel(tr("This plugin only has a single channel input,\nbut the source has %1 channels.").arg(sourceChannels)));
|
Chris@69
|
350
|
Chris@69
|
351 QComboBox *channelCombo = new QComboBox;
|
Chris@76
|
352 channelCombo->addItem(tr("Use mean of source channels"));
|
Chris@69
|
353 for (int i = 0; i < sourceChannels; ++i) {
|
Chris@69
|
354 channelCombo->addItem(tr("Use channel %1 only").arg(i + 1));
|
Chris@69
|
355 }
|
Chris@69
|
356
|
Chris@69
|
357 connect(channelCombo, SIGNAL(activated(int)),
|
Chris@69
|
358 this, SLOT(channelComboChanged(int)));
|
Chris@69
|
359
|
Chris@69
|
360 channelLayout->addWidget(channelCombo);
|
Chris@69
|
361 }
|
Chris@163
|
362
|
Chris@163
|
363 m_channelBox->setVisible(true);
|
Chris@163
|
364 m_haveChannelBoxData = true;
|
Chris@163
|
365 m_advancedButton->show();
|
Chris@69
|
366 }
|
Chris@69
|
367 }
|
Chris@69
|
368
|
Chris@163
|
369 setAdvancedVisible(m_advancedVisible);
|
Chris@163
|
370 }
|
Chris@163
|
371
|
Chris@163
|
372 void
|
Chris@163
|
373 PluginParameterDialog::setShowProcessingOptions(bool showWindowSize,
|
Chris@163
|
374 bool showFrequencyDomainOptions)
|
Chris@163
|
375 {
|
Chris@163
|
376 if (m_haveWindowBoxData) {
|
Chris@682
|
377 cerr << "WARNING: PluginParameterDialog::setShowProcessingOptions: Calling more than once on same dialog is not currently implemented" << endl;
|
Chris@163
|
378 return;
|
Chris@163
|
379 }
|
Chris@163
|
380
|
Chris@140
|
381 if (showWindowSize) {
|
Chris@140
|
382
|
Chris@309
|
383 Vamp::Plugin *fePlugin = dynamic_cast<Vamp::Plugin *>(m_plugin);
|
Chris@309
|
384 if (!fePlugin) fePlugin = dynamic_cast<Vamp::PluginHostAdapter *>(m_plugin);
|
Chris@309
|
385 if (!fePlugin) fePlugin = dynamic_cast<Vamp::HostExt::PluginWrapper *>(m_plugin);
|
Chris@140
|
386 int size = 1024;
|
Chris@140
|
387 int increment = 1024;
|
Chris@140
|
388 if (fePlugin) {
|
Chris@908
|
389 size = int(fePlugin->getPreferredBlockSize());
|
Chris@682
|
390 cerr << "Feature extraction plugin \"" << fePlugin->getName() << "\" reports preferred block size as " << size << endl;
|
Chris@140
|
391 if (size == 0) size = 1024;
|
Chris@908
|
392 increment = int(fePlugin->getPreferredStepSize());
|
Chris@146
|
393 if (increment == 0) {
|
Chris@146
|
394 if (fePlugin->getInputDomain() == Vamp::Plugin::TimeDomain) {
|
Chris@146
|
395 increment = size;
|
Chris@146
|
396 } else {
|
Chris@146
|
397 increment = size/2;
|
Chris@146
|
398 }
|
Chris@146
|
399 }
|
Chris@140
|
400 }
|
Chris@140
|
401
|
Chris@140
|
402 QGridLayout *windowLayout = new QGridLayout;
|
Chris@163
|
403 m_windowBox->setLayout(windowLayout);
|
Chris@140
|
404
|
Chris@140
|
405 if (showFrequencyDomainOptions) {
|
Chris@140
|
406 windowLayout->addWidget(new QLabel(tr("Window size:")), 0, 0);
|
Chris@140
|
407 } else {
|
Chris@140
|
408 windowLayout->addWidget(new QLabel(tr("Audio frames per block:")), 0, 0);
|
Chris@140
|
409 }
|
Chris@140
|
410
|
Chris@682
|
411 cerr << "size: " << size << ", increment: " << increment << endl;
|
Chris@143
|
412
|
Chris@140
|
413 QComboBox *blockSizeCombo = new QComboBox;
|
Chris@140
|
414 blockSizeCombo->setEditable(true);
|
Chris@147
|
415 bool found = false;
|
Chris@143
|
416 for (int i = 0; i < 14; ++i) {
|
Chris@249
|
417 int val = 1 << (i + 3);
|
Chris@140
|
418 blockSizeCombo->addItem(QString("%1").arg(val));
|
Chris@147
|
419 if (val == size) {
|
Chris@147
|
420 blockSizeCombo->setCurrentIndex(i);
|
Chris@147
|
421 found = true;
|
Chris@147
|
422 }
|
Chris@147
|
423 }
|
Chris@147
|
424 if (!found) {
|
Chris@147
|
425 blockSizeCombo->addItem(QString("%1").arg(size));
|
Chris@147
|
426 blockSizeCombo->setCurrentIndex(blockSizeCombo->count() - 1);
|
Chris@140
|
427 }
|
Chris@545
|
428 blockSizeCombo->setValidator(new QIntValidator(1, int(pow(2., 18)), this));
|
Chris@155
|
429 connect(blockSizeCombo, SIGNAL(editTextChanged(const QString &)),
|
Chris@155
|
430 this, SLOT(blockSizeComboChanged(const QString &)));
|
Chris@140
|
431 windowLayout->addWidget(blockSizeCombo, 0, 1);
|
Chris@140
|
432
|
Chris@148
|
433 windowLayout->addWidget(new QLabel(tr("Window increment:")), 1, 0);
|
Chris@148
|
434
|
Chris@148
|
435 QComboBox *incrementCombo = new QComboBox;
|
Chris@148
|
436 incrementCombo->setEditable(true);
|
Chris@148
|
437 found = false;
|
Chris@148
|
438 for (int i = 0; i < 14; ++i) {
|
Chris@249
|
439 int val = 1 << (i + 3);
|
Chris@148
|
440 incrementCombo->addItem(QString("%1").arg(val));
|
Chris@148
|
441 if (val == increment) {
|
Chris@148
|
442 incrementCombo->setCurrentIndex(i);
|
Chris@148
|
443 found = true;
|
Chris@148
|
444 }
|
Chris@148
|
445 }
|
Chris@148
|
446 if (!found) {
|
Chris@148
|
447 incrementCombo->addItem(QString("%1").arg(increment));
|
Chris@148
|
448 incrementCombo->setCurrentIndex(incrementCombo->count() - 1);
|
Chris@148
|
449 }
|
Chris@545
|
450 incrementCombo->setValidator(new QIntValidator(1, int(pow(2., 18)), this));
|
Chris@155
|
451 connect(incrementCombo, SIGNAL(editTextChanged(const QString &)),
|
Chris@155
|
452 this, SLOT(incrementComboChanged(const QString &)));
|
Chris@148
|
453 windowLayout->addWidget(incrementCombo, 1, 1);
|
Chris@148
|
454
|
Chris@140
|
455 if (showFrequencyDomainOptions) {
|
Chris@140
|
456
|
Chris@140
|
457 windowLayout->addWidget(new QLabel(tr("Window shape:")), 2, 0);
|
Chris@140
|
458 WindowTypeSelector *windowTypeSelector = new WindowTypeSelector;
|
Chris@171
|
459 connect(windowTypeSelector, SIGNAL(windowTypeChanged(WindowType)),
|
Chris@171
|
460 this, SLOT(windowTypeChanged(WindowType)));
|
Chris@140
|
461 windowLayout->addWidget(windowTypeSelector, 2, 1);
|
Chris@140
|
462 }
|
Chris@163
|
463
|
Chris@163
|
464 m_windowBox->setVisible(true);
|
Chris@163
|
465 m_haveWindowBoxData = true;
|
Chris@163
|
466 m_advancedButton->show();
|
Chris@140
|
467 }
|
Chris@140
|
468
|
Chris@163
|
469 setAdvancedVisible(m_advancedVisible);
|
Chris@62
|
470 }
|
Chris@62
|
471
|
Chris@69
|
472 void
|
Chris@336
|
473 PluginParameterDialog::setCandidateInputModels(const QStringList &models,
|
Chris@336
|
474 QString defaultModel)
|
Chris@164
|
475 {
|
Chris@164
|
476 m_inputModels->clear();
|
Chris@294
|
477
|
Chris@294
|
478 QSettings settings;
|
Chris@294
|
479 settings.beginGroup("PluginParameterDialog");
|
Chris@294
|
480 QString lastModel = settings.value("lastinputmodel").toString();
|
Chris@294
|
481 settings.endGroup();
|
Chris@294
|
482
|
Chris@336
|
483 if (defaultModel == "") defaultModel = lastModel;
|
Chris@336
|
484
|
Chris@302
|
485 m_inputModels->show();
|
Chris@302
|
486
|
Chris@294
|
487 m_inputModelList = models;
|
Chris@294
|
488 m_inputModels->addItems(TextAbbrev::abbreviate(models, 80));
|
Chris@296
|
489 m_inputModels->setCurrentIndex(0);
|
Chris@294
|
490
|
Chris@336
|
491 if (defaultModel != "") {
|
Chris@294
|
492 for (int i = 0; i < models.size(); ++i) {
|
Chris@336
|
493 if (defaultModel == models[i]) {
|
Chris@294
|
494 m_inputModels->setCurrentIndex(i);
|
Chris@296
|
495 m_currentInputModel = models[i];
|
Chris@294
|
496 break;
|
Chris@294
|
497 }
|
Chris@294
|
498 }
|
Chris@294
|
499 }
|
Chris@294
|
500
|
Chris@294
|
501 connect(m_inputModels, SIGNAL(activated(int)),
|
Chris@294
|
502 this, SLOT(inputModelComboChanged(int)));
|
Chris@164
|
503 m_inputModelBox->show();
|
Chris@164
|
504 }
|
Chris@164
|
505
|
Chris@302
|
506 void
|
Chris@302
|
507 PluginParameterDialog::setShowSelectionOnlyOption(bool show)
|
Chris@302
|
508 {
|
Chris@302
|
509 if (!show) {
|
Chris@302
|
510 m_selectionOnly->hide();
|
Chris@302
|
511 if (!m_inputModels->isVisible()) m_inputModelBox->hide();
|
Chris@302
|
512 return;
|
Chris@302
|
513 }
|
Chris@302
|
514
|
Chris@302
|
515 QSettings settings;
|
Chris@302
|
516 settings.beginGroup("PluginParameterDialog");
|
Chris@302
|
517 bool lastSelectionOnly = settings.value("lastselectiononly", false).toBool();
|
Chris@302
|
518 settings.endGroup();
|
Chris@302
|
519
|
Chris@302
|
520 m_selectionOnly->setChecked(lastSelectionOnly);
|
Chris@309
|
521 m_currentSelectionOnly = lastSelectionOnly;
|
Chris@302
|
522
|
Chris@302
|
523 connect(m_selectionOnly, SIGNAL(stateChanged(int)),
|
Chris@302
|
524 this, SLOT(selectionOnlyChanged(int)));
|
Chris@302
|
525
|
Chris@302
|
526 m_selectionOnly->show();
|
Chris@302
|
527 m_inputModelBox->show();
|
Chris@302
|
528 }
|
Chris@302
|
529
|
Chris@164
|
530 QString
|
Chris@164
|
531 PluginParameterDialog::getInputModel() const
|
Chris@164
|
532 {
|
Chris@296
|
533 return m_currentInputModel;
|
Chris@164
|
534 }
|
Chris@164
|
535
|
Chris@302
|
536 bool
|
Chris@302
|
537 PluginParameterDialog::getSelectionOnly() const
|
Chris@302
|
538 {
|
Chris@309
|
539 return m_currentSelectionOnly;
|
Chris@302
|
540 }
|
Chris@302
|
541
|
Chris@164
|
542 void
|
Chris@807
|
543 PluginParameterDialog::getProcessingParameters(int &blockSize) const
|
Chris@145
|
544 {
|
Chris@145
|
545 blockSize = m_blockSize;
|
Chris@145
|
546 return;
|
Chris@145
|
547 }
|
Chris@145
|
548
|
Chris@145
|
549 void
|
Chris@807
|
550 PluginParameterDialog::getProcessingParameters(int &stepSize,
|
Chris@807
|
551 int &blockSize,
|
Chris@145
|
552 WindowType &windowType) const
|
Chris@145
|
553 {
|
Chris@145
|
554 stepSize = m_stepSize;
|
Chris@145
|
555 blockSize = m_blockSize;
|
Chris@145
|
556 windowType = m_windowType;
|
Chris@146
|
557 return;
|
Chris@145
|
558 }
|
Chris@145
|
559
|
Chris@145
|
560 void
|
Chris@155
|
561 PluginParameterDialog::blockSizeComboChanged(const QString &text)
|
Chris@145
|
562 {
|
Chris@145
|
563 m_blockSize = text.toInt();
|
Chris@682
|
564 cerr << "Block size changed to " << m_blockSize << endl;
|
Chris@145
|
565 }
|
Chris@145
|
566
|
Chris@145
|
567 void
|
Chris@155
|
568 PluginParameterDialog::incrementComboChanged(const QString &text)
|
Chris@145
|
569 {
|
Chris@145
|
570 m_stepSize = text.toInt();
|
Chris@146
|
571 //!!! rename increment to step size throughout
|
Chris@682
|
572 cerr << "Increment changed to " << m_stepSize << endl;
|
Chris@145
|
573 }
|
Chris@145
|
574
|
Chris@145
|
575 void
|
Chris@145
|
576 PluginParameterDialog::windowTypeChanged(WindowType type)
|
Chris@145
|
577 {
|
Chris@145
|
578 m_windowType = type;
|
Chris@145
|
579 }
|
Chris@145
|
580
|
Chris@145
|
581 void
|
Chris@440
|
582 PluginParameterDialog::moreInfo()
|
Chris@440
|
583 {
|
Chris@440
|
584 if (m_moreInfoUrl != "") {
|
Chris@440
|
585 QDesktopServices::openUrl(QUrl(m_moreInfoUrl));
|
Chris@440
|
586 }
|
Chris@440
|
587 }
|
Chris@440
|
588
|
Chris@440
|
589 void
|
Chris@143
|
590 PluginParameterDialog::advancedToggled()
|
Chris@143
|
591 {
|
Chris@163
|
592 setAdvancedVisible(!m_advancedVisible);
|
Chris@163
|
593 }
|
Chris@143
|
594
|
Chris@163
|
595 void
|
Chris@163
|
596 PluginParameterDialog::setAdvancedVisible(bool visible)
|
Chris@163
|
597 {
|
Chris@456
|
598 // m_advanced->setVisible(visible);
|
Chris@143
|
599
|
Chris@163
|
600 if (visible) {
|
Chris@163
|
601 m_advancedButton->setText(tr("Advanced <<"));
|
Chris@163
|
602 m_advancedButton->setChecked(true);
|
Chris@456
|
603 m_advanced->show();
|
Chris@163
|
604 } else {
|
Chris@456
|
605 m_advanced->hide();
|
Chris@163
|
606 m_advancedButton->setText(tr("Advanced >>"));
|
Chris@163
|
607 m_advancedButton->setChecked(false);
|
Chris@163
|
608 }
|
Chris@143
|
609
|
Chris@682
|
610 // cerr << "resize to " << sizeHint().width() << " x " << sizeHint().height() << endl;
|
Chris@456
|
611
|
Chris@456
|
612 // setMinimumHeight(sizeHint().height());
|
Chris@456
|
613 adjustSize();
|
Chris@456
|
614
|
Chris@456
|
615 // (sizeHint());
|
Chris@456
|
616
|
Chris@456
|
617 m_advancedVisible = visible;
|
Chris@456
|
618
|
Chris@143
|
619 QSettings settings;
|
Chris@143
|
620 settings.beginGroup("PluginParameterDialog");
|
Chris@143
|
621 settings.setValue("advancedvisible", visible);
|
Chris@143
|
622 settings.endGroup();
|
Chris@143
|
623
|
Chris@163
|
624 // if (visible) setMaximumHeight(sizeHint().height());
|
Chris@163
|
625 // adjustSize();
|
Chris@143
|
626 }
|
Chris@143
|
627
|
Chris@143
|
628 void
|
Chris@69
|
629 PluginParameterDialog::channelComboChanged(int index)
|
Chris@69
|
630 {
|
Chris@69
|
631 m_channel = index - 1;
|
Chris@69
|
632 }
|
Chris@69
|
633
|
Chris@294
|
634 void
|
Chris@294
|
635 PluginParameterDialog::inputModelComboChanged(int index)
|
Chris@294
|
636 {
|
Chris@294
|
637 if (index >= m_inputModelList.size()) return;
|
Chris@296
|
638 m_currentInputModel = m_inputModelList[index];
|
Chris@296
|
639 emit inputModelChanged(m_currentInputModel);
|
Chris@294
|
640 }
|
Chris@294
|
641
|
Chris@294
|
642 void
|
Chris@302
|
643 PluginParameterDialog::selectionOnlyChanged(int state)
|
Chris@302
|
644 {
|
Chris@302
|
645 if (state == Qt::Checked) {
|
Chris@302
|
646 m_currentSelectionOnly = true;
|
Chris@302
|
647 } else {
|
Chris@302
|
648 m_currentSelectionOnly = false;
|
Chris@302
|
649 }
|
Chris@302
|
650 }
|
Chris@302
|
651
|
Chris@302
|
652 void
|
Chris@294
|
653 PluginParameterDialog::dialogAccepted()
|
Chris@294
|
654 {
|
Chris@294
|
655 QSettings settings;
|
Chris@294
|
656 settings.beginGroup("PluginParameterDialog");
|
Chris@302
|
657
|
Chris@302
|
658 if (m_inputModels->isVisible()) {
|
Chris@302
|
659 settings.setValue("lastinputmodel", getInputModel());
|
Chris@302
|
660 }
|
Chris@302
|
661
|
Chris@302
|
662 if (m_selectionOnly->isVisible()) {
|
Chris@302
|
663 settings.setValue("lastselectiononly", getSelectionOnly());
|
Chris@302
|
664 }
|
Chris@302
|
665
|
Chris@294
|
666 settings.endGroup();
|
Chris@294
|
667
|
Chris@294
|
668 accept();
|
Chris@294
|
669 }
|
Chris@294
|
670
|