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