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