Mercurial > hg > svgui
comparison widgets/PluginParameterDialog.cpp @ 302:e9549ea3f825
* Change WaveFileModel API from getValues(start,end) to getData(start,count).
It's much less error-prone to pass in frame counts instead of start/end
locations. Should have done this ages ago. This closes #1794563.
* Add option to apply a transform to only the selection region, instead of
the whole audio.
* (to make the above work properly) Add start frame offset to wave models
author | Chris Cannam |
---|---|
date | Mon, 01 Oct 2007 13:48:38 +0000 |
parents | ea37c229a578 |
children | b7d45fed8146 |
comparison
equal
deleted
inserted
replaced
301:5636eeacc467 | 302:e9549ea3f825 |
---|---|
30 #include <QVBoxLayout> | 30 #include <QVBoxLayout> |
31 #include <QScrollArea> | 31 #include <QScrollArea> |
32 #include <QPushButton> | 32 #include <QPushButton> |
33 #include <QMessageBox> | 33 #include <QMessageBox> |
34 #include <QComboBox> | 34 #include <QComboBox> |
35 #include <QCheckBox> | |
35 #include <QSettings> | 36 #include <QSettings> |
36 #include <QDialogButtonBox> | 37 #include <QDialogButtonBox> |
37 | 38 |
38 PluginParameterDialog::PluginParameterDialog(Vamp::PluginBase *plugin, | 39 PluginParameterDialog::PluginParameterDialog(Vamp::PluginBase *plugin, |
39 QWidget *parent) : | 40 QWidget *parent) : |
41 m_plugin(plugin), | 42 m_plugin(plugin), |
42 m_channel(-1), | 43 m_channel(-1), |
43 m_stepSize(0), | 44 m_stepSize(0), |
44 m_blockSize(0), | 45 m_blockSize(0), |
45 m_windowType(HanningWindow), | 46 m_windowType(HanningWindow), |
46 m_parameterBox(0) | 47 m_parameterBox(0), |
48 m_selectionOnly(false) | |
47 { | 49 { |
48 setWindowTitle(tr("Plugin Parameters")); | 50 setWindowTitle(tr("Plugin Parameters")); |
49 | 51 |
50 QGridLayout *grid = new QGridLayout; | 52 QGridLayout *grid = new QGridLayout; |
51 setLayout(grid); | 53 setLayout(grid); |
159 row++; | 161 row++; |
160 | 162 |
161 subgrid->setColumnStretch(1, 2); | 163 subgrid->setColumnStretch(1, 2); |
162 | 164 |
163 m_inputModelBox = new QGroupBox; | 165 m_inputModelBox = new QGroupBox; |
164 m_inputModelBox->setTitle(tr("Input Source")); | 166 m_inputModelBox->setTitle(tr("Input Material")); |
165 grid->addWidget(m_inputModelBox, 1, 0); | 167 grid->addWidget(m_inputModelBox, 1, 0); |
166 | 168 |
167 m_inputModels = new QComboBox; | 169 m_inputModels = new QComboBox; |
168 QHBoxLayout *inputLayout = new QHBoxLayout; | 170 QVBoxLayout *inputLayout = new QVBoxLayout; |
169 m_inputModelBox->setLayout(inputLayout); | 171 m_inputModelBox->setLayout(inputLayout); |
170 inputLayout->addWidget(m_inputModels); | 172 inputLayout->addWidget(m_inputModels); |
173 m_inputModels->hide(); | |
174 | |
175 m_selectionOnly = new QCheckBox(tr("Restrict to selection extents")); | |
176 inputLayout->addWidget(m_selectionOnly); | |
177 m_selectionOnly->hide(); | |
178 | |
171 m_inputModelBox->hide(); | 179 m_inputModelBox->hide(); |
172 | 180 |
173 QGroupBox *paramBox = new QGroupBox; | 181 QGroupBox *paramBox = new QGroupBox; |
174 paramBox->setTitle(tr("Plugin Parameters")); | 182 paramBox->setTitle(tr("Plugin Parameters")); |
175 grid->addWidget(paramBox, 2, 0); | 183 grid->addWidget(paramBox, 2, 0); |
435 QSettings settings; | 443 QSettings settings; |
436 settings.beginGroup("PluginParameterDialog"); | 444 settings.beginGroup("PluginParameterDialog"); |
437 QString lastModel = settings.value("lastinputmodel").toString(); | 445 QString lastModel = settings.value("lastinputmodel").toString(); |
438 settings.endGroup(); | 446 settings.endGroup(); |
439 | 447 |
448 m_inputModels->show(); | |
449 | |
440 m_inputModelList = models; | 450 m_inputModelList = models; |
441 m_inputModels->addItems(TextAbbrev::abbreviate(models, 80)); | 451 m_inputModels->addItems(TextAbbrev::abbreviate(models, 80)); |
442 m_inputModels->setCurrentIndex(0); | 452 m_inputModels->setCurrentIndex(0); |
443 | 453 |
444 if (lastModel != "") { | 454 if (lastModel != "") { |
454 connect(m_inputModels, SIGNAL(activated(int)), | 464 connect(m_inputModels, SIGNAL(activated(int)), |
455 this, SLOT(inputModelComboChanged(int))); | 465 this, SLOT(inputModelComboChanged(int))); |
456 m_inputModelBox->show(); | 466 m_inputModelBox->show(); |
457 } | 467 } |
458 | 468 |
469 void | |
470 PluginParameterDialog::setShowSelectionOnlyOption(bool show) | |
471 { | |
472 if (!show) { | |
473 m_selectionOnly->hide(); | |
474 if (!m_inputModels->isVisible()) m_inputModelBox->hide(); | |
475 return; | |
476 } | |
477 | |
478 QSettings settings; | |
479 settings.beginGroup("PluginParameterDialog"); | |
480 bool lastSelectionOnly = settings.value("lastselectiononly", false).toBool(); | |
481 settings.endGroup(); | |
482 | |
483 m_selectionOnly->setChecked(lastSelectionOnly); | |
484 | |
485 connect(m_selectionOnly, SIGNAL(stateChanged(int)), | |
486 this, SLOT(selectionOnlyChanged(int))); | |
487 | |
488 m_selectionOnly->show(); | |
489 m_inputModelBox->show(); | |
490 } | |
491 | |
459 QString | 492 QString |
460 PluginParameterDialog::getInputModel() const | 493 PluginParameterDialog::getInputModel() const |
461 { | 494 { |
462 return m_currentInputModel; | 495 return m_currentInputModel; |
496 } | |
497 | |
498 bool | |
499 PluginParameterDialog::getSelectionOnly() const | |
500 { | |
501 return m_selectionOnly; | |
463 } | 502 } |
464 | 503 |
465 void | 504 void |
466 PluginParameterDialog::getProcessingParameters(size_t &blockSize) const | 505 PluginParameterDialog::getProcessingParameters(size_t &blockSize) const |
467 { | 506 { |
549 m_currentInputModel = m_inputModelList[index]; | 588 m_currentInputModel = m_inputModelList[index]; |
550 emit inputModelChanged(m_currentInputModel); | 589 emit inputModelChanged(m_currentInputModel); |
551 } | 590 } |
552 | 591 |
553 void | 592 void |
593 PluginParameterDialog::selectionOnlyChanged(int state) | |
594 { | |
595 if (state == Qt::Checked) { | |
596 m_currentSelectionOnly = true; | |
597 } else { | |
598 m_currentSelectionOnly = false; | |
599 } | |
600 } | |
601 | |
602 void | |
554 PluginParameterDialog::dialogAccepted() | 603 PluginParameterDialog::dialogAccepted() |
555 { | 604 { |
556 if (!m_inputModels || !m_inputModels->isVisible()) { | |
557 accept(); | |
558 return; | |
559 } | |
560 | |
561 QSettings settings; | 605 QSettings settings; |
562 settings.beginGroup("PluginParameterDialog"); | 606 settings.beginGroup("PluginParameterDialog"); |
563 settings.setValue("lastinputmodel", getInputModel()); | 607 |
608 if (m_inputModels->isVisible()) { | |
609 settings.setValue("lastinputmodel", getInputModel()); | |
610 } | |
611 | |
612 if (m_selectionOnly->isVisible()) { | |
613 settings.setValue("lastselectiononly", getSelectionOnly()); | |
614 } | |
615 | |
564 settings.endGroup(); | 616 settings.endGroup(); |
565 | 617 |
566 accept(); | 618 accept(); |
567 } | 619 } |
568 | 620 |