Mercurial > hg > svgui
changeset 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 | 15b8a4bfe855 |
children | 5804703450d8 |
files | layer/SingleColourLayer.cpp layer/SingleColourLayer.h view/Pane.cpp widgets/PluginParameterDialog.cpp widgets/PluginParameterDialog.h |
diffstat | 5 files changed, 75 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/layer/SingleColourLayer.cpp Thu Aug 09 14:40:03 2007 +0000 +++ b/layer/SingleColourLayer.cpp Fri Aug 10 16:36:50 2007 +0000 @@ -25,7 +25,8 @@ SingleColourLayer::m_colourRefCount; SingleColourLayer::SingleColourLayer() : - m_colour(0) + m_colour(0), + m_colourExplicitlySet(false) { setDefaultColourFor(0); } @@ -117,6 +118,8 @@ void SingleColourLayer::setDefaultColourFor(View *v) { + if (m_colourExplicitlySet) return; + bool dark = false; if (v) { dark = !v->hasLightBackground(); @@ -185,6 +188,8 @@ void SingleColourLayer::setBaseColour(int colour) { + m_colourExplicitlySet = true; + if (m_colour == colour) return; if (m_colourRefCount.find(m_colour) != m_colourRefCount.end() && @@ -270,5 +275,12 @@ QString darkbg = attributes.value("darkBackground"); m_colour = ColourDatabase::getInstance()->putStringValues (colourName, colourSpec, darkbg); + if (m_colourRefCount.find(m_colour) == m_colourRefCount.end()) { + m_colourRefCount[m_colour] = 1; + } else { + m_colourRefCount[m_colour]++; + } + m_colourExplicitlySet = true; + flagBaseColourChanged(); }
--- a/layer/SingleColourLayer.h Thu Aug 09 14:40:03 2007 +0000 +++ b/layer/SingleColourLayer.h Fri Aug 10 16:36:50 2007 +0000 @@ -67,6 +67,7 @@ static ColourRefCount m_colourRefCount; int m_colour; + bool m_colourExplicitlySet; }; #endif
--- a/view/Pane.cpp Thu Aug 09 14:40:03 2007 +0000 +++ b/view/Pane.cpp Fri Aug 10 16:36:50 2007 +0000 @@ -21,6 +21,7 @@ #include "base/Profiler.h" #include "ViewManager.h" #include "base/CommandHistory.h" +#include "base/TextAbbrev.h" #include "layer/WaveformLayer.h" #include <QPaintEvent> @@ -714,31 +715,14 @@ return; } - std::vector<QString> texts; - int maxTextWidth = 0; + QStringList texts; + for (LayerList::iterator i = m_layers.begin(); i != m_layers.end(); ++i) { + texts.push_back((*i)->getLayerPresentationName()); + } - for (LayerList::iterator i = m_layers.begin(); i != m_layers.end(); ++i) { - - QString text = (*i)->getLayerPresentationName(); - int tw = paint.fontMetrics().width(text); - bool reduced = false; - while (tw > width() / 3 && text.length() > 4) { - if (!reduced && text.length() > 8) { - text = text.left(text.length() - 4); - } else { - text = text.left(text.length() - 2); - } - reduced = true; - tw = paint.fontMetrics().width(text + "..."); - } - if (reduced) { - texts.push_back(text + "..."); - } else { - texts.push_back(text); - } - if (tw > maxTextWidth) maxTextWidth = tw; - } - + int maxTextWidth = width() / 3; + texts = TextAbbrev::abbreviate(texts, paint.fontMetrics(), maxTextWidth); + int lly = height() - 6; int llx = width() - maxTextWidth - 5;
--- 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(); +} +
--- a/widgets/PluginParameterDialog.h Thu Aug 09 14:40:03 2007 +0000 +++ b/widgets/PluginParameterDialog.h Fri Aug 10 16:36:50 2007 +0000 @@ -78,6 +78,8 @@ void windowTypeChanged(WindowType type); void advancedToggled(); void setAdvancedVisible(bool); + void inputModelComboChanged(int); + void dialogAccepted(); protected: Vamp::PluginBase *m_plugin; @@ -102,6 +104,7 @@ QGroupBox *m_inputModelBox; QComboBox *m_inputModels; + QStringList m_inputModelList; QPushButton *m_advancedButton; QWidget *m_advanced;