Mercurial > hg > svgui
diff 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 |
line wrap: on
line diff
--- a/widgets/PluginParameterDialog.cpp Thu Aug 09 14:40:03 2007 +0000 +++ b/widgets/PluginParameterDialog.cpp Fri Aug 10 16:36:50 2007 +0000 @@ -18,6 +18,8 @@ #include "PluginParameterBox.h" #include "WindowTypeSelector.h" +#include "base/TextAbbrev.h" + #include "vamp-sdk/Plugin.h" #include "vamp-sdk/PluginHostAdapter.h" @@ -228,7 +230,7 @@ QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); hbox->addWidget(bb); - connect(bb, SIGNAL(accepted()), this, SLOT(accept())); + connect(bb, SIGNAL(accepted()), this, SLOT(dialogAccepted())); connect(bb, SIGNAL(rejected()), this, SLOT(reject())); setAdvancedVisible(m_advancedVisible); @@ -429,16 +431,36 @@ PluginParameterDialog::setCandidateInputModels(const QStringList &models) { m_inputModels->clear(); - m_inputModels->insertItems(0, models); - connect(m_inputModels, SIGNAL(activated(const QString &)), - this, SIGNAL(inputModelChanged(QString))); + + QSettings settings; + settings.beginGroup("PluginParameterDialog"); + QString lastModel = settings.value("lastinputmodel").toString(); + settings.endGroup(); + + m_inputModelList = models; + m_inputModels->addItems(TextAbbrev::abbreviate(models, 80)); + + if (lastModel != "") { + for (int i = 0; i < models.size(); ++i) { + if (lastModel == models[i]) { + m_inputModels->setCurrentIndex(i); + break; + } + } + } + + connect(m_inputModels, SIGNAL(activated(int)), + this, SLOT(inputModelComboChanged(int))); m_inputModelBox->show(); } QString PluginParameterDialog::getInputModel() const { - return m_inputModels->currentText(); + if (!m_inputModels || !m_inputModels->isVisible()) return ""; + int i = m_inputModels->currentIndex(); + if (i >= m_inputModelList.size()) return ""; + return m_inputModelList[i]; } void @@ -521,3 +543,26 @@ m_channel = index - 1; } +void +PluginParameterDialog::inputModelComboChanged(int index) +{ + if (index >= m_inputModelList.size()) return; + emit inputModelChanged(m_inputModelList[index]); +} + +void +PluginParameterDialog::dialogAccepted() +{ + if (!m_inputModels || !m_inputModels->isVisible()) { + accept(); + return; + } + + QSettings settings; + settings.beginGroup("PluginParameterDialog"); + settings.setValue("lastinputmodel", getInputModel()); + settings.endGroup(); + + accept(); +} +