Mercurial > hg > svgui
comparison widgets/PluginParameterDialog.cpp @ 294:919740b20cc9
* Better abbreviation modes for layer names in pane (and input model combo
of plugin parameter dialog)
* Avoid crash when loading SV file containing model derived from nonexistent
model (shouldn't happen of course, but see bug #1771769)
* Remember last-used input model in plugin parameter dialog
* Don't override a layer colour loaded from a session file with the generated
default colour when attaching it to a view
author | Chris Cannam |
---|---|
date | Fri, 10 Aug 2007 16:36:50 +0000 |
parents | 4edaff85875d |
children | ea37c229a578 |
comparison
equal
deleted
inserted
replaced
293:15b8a4bfe855 | 294:919740b20cc9 |
---|---|
16 #include "PluginParameterDialog.h" | 16 #include "PluginParameterDialog.h" |
17 | 17 |
18 #include "PluginParameterBox.h" | 18 #include "PluginParameterBox.h" |
19 #include "WindowTypeSelector.h" | 19 #include "WindowTypeSelector.h" |
20 | 20 |
21 #include "base/TextAbbrev.h" | |
22 | |
21 #include "vamp-sdk/Plugin.h" | 23 #include "vamp-sdk/Plugin.h" |
22 #include "vamp-sdk/PluginHostAdapter.h" | 24 #include "vamp-sdk/PluginHostAdapter.h" |
23 | 25 |
24 #include <QGridLayout> | 26 #include <QGridLayout> |
25 #include <QLabel> | 27 #include <QLabel> |
226 m_advancedButton->hide(); | 228 m_advancedButton->hide(); |
227 | 229 |
228 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok | | 230 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok | |
229 QDialogButtonBox::Cancel); | 231 QDialogButtonBox::Cancel); |
230 hbox->addWidget(bb); | 232 hbox->addWidget(bb); |
231 connect(bb, SIGNAL(accepted()), this, SLOT(accept())); | 233 connect(bb, SIGNAL(accepted()), this, SLOT(dialogAccepted())); |
232 connect(bb, SIGNAL(rejected()), this, SLOT(reject())); | 234 connect(bb, SIGNAL(rejected()), this, SLOT(reject())); |
233 | 235 |
234 setAdvancedVisible(m_advancedVisible); | 236 setAdvancedVisible(m_advancedVisible); |
235 } | 237 } |
236 | 238 |
427 | 429 |
428 void | 430 void |
429 PluginParameterDialog::setCandidateInputModels(const QStringList &models) | 431 PluginParameterDialog::setCandidateInputModels(const QStringList &models) |
430 { | 432 { |
431 m_inputModels->clear(); | 433 m_inputModels->clear(); |
432 m_inputModels->insertItems(0, models); | 434 |
433 connect(m_inputModels, SIGNAL(activated(const QString &)), | 435 QSettings settings; |
434 this, SIGNAL(inputModelChanged(QString))); | 436 settings.beginGroup("PluginParameterDialog"); |
437 QString lastModel = settings.value("lastinputmodel").toString(); | |
438 settings.endGroup(); | |
439 | |
440 m_inputModelList = models; | |
441 m_inputModels->addItems(TextAbbrev::abbreviate(models, 80)); | |
442 | |
443 if (lastModel != "") { | |
444 for (int i = 0; i < models.size(); ++i) { | |
445 if (lastModel == models[i]) { | |
446 m_inputModels->setCurrentIndex(i); | |
447 break; | |
448 } | |
449 } | |
450 } | |
451 | |
452 connect(m_inputModels, SIGNAL(activated(int)), | |
453 this, SLOT(inputModelComboChanged(int))); | |
435 m_inputModelBox->show(); | 454 m_inputModelBox->show(); |
436 } | 455 } |
437 | 456 |
438 QString | 457 QString |
439 PluginParameterDialog::getInputModel() const | 458 PluginParameterDialog::getInputModel() const |
440 { | 459 { |
441 return m_inputModels->currentText(); | 460 if (!m_inputModels || !m_inputModels->isVisible()) return ""; |
461 int i = m_inputModels->currentIndex(); | |
462 if (i >= m_inputModelList.size()) return ""; | |
463 return m_inputModelList[i]; | |
442 } | 464 } |
443 | 465 |
444 void | 466 void |
445 PluginParameterDialog::getProcessingParameters(size_t &blockSize) const | 467 PluginParameterDialog::getProcessingParameters(size_t &blockSize) const |
446 { | 468 { |
519 PluginParameterDialog::channelComboChanged(int index) | 541 PluginParameterDialog::channelComboChanged(int index) |
520 { | 542 { |
521 m_channel = index - 1; | 543 m_channel = index - 1; |
522 } | 544 } |
523 | 545 |
546 void | |
547 PluginParameterDialog::inputModelComboChanged(int index) | |
548 { | |
549 if (index >= m_inputModelList.size()) return; | |
550 emit inputModelChanged(m_inputModelList[index]); | |
551 } | |
552 | |
553 void | |
554 PluginParameterDialog::dialogAccepted() | |
555 { | |
556 if (!m_inputModels || !m_inputModels->isVisible()) { | |
557 accept(); | |
558 return; | |
559 } | |
560 | |
561 QSettings settings; | |
562 settings.beginGroup("PluginParameterDialog"); | |
563 settings.setValue("lastinputmodel", getInputModel()); | |
564 settings.endGroup(); | |
565 | |
566 accept(); | |
567 } | |
568 |