# HG changeset patch # User Chris Cannam # Date 1143724691 0 # Node ID 6dad2724f3aadce7b22b60049294256d7af910d7 # Parent 193b569a975fb26965aa3c7d49ad16b751b8de4f * Ensure plugin parameters for a transform are saved in the .sv file and restored in case the plugin has to be run again * Make plugin dialog offer options for mixdown/single-channel use if the file has more than one channels but the plugin only accepts one * Fix incorrect samplerate playback for second file loaded if its samplerate differed from first * Add Zoom to Fit and Select Visible Range menu options, split out Import Audio into main model and secondary model options * Add stubs for cut, copy and paste operations (not implemented yet) diff -r 193b569a975f -r 6dad2724f3aa layer/WaveformLayer.cpp --- a/layer/WaveformLayer.cpp Wed Mar 29 16:24:25 2006 +0000 +++ b/layer/WaveformLayer.cpp Thu Mar 30 13:18:11 2006 +0000 @@ -56,6 +56,20 @@ void WaveformLayer::setModel(const RangeSummarisableTimeValueModel *model) { + bool channelsChanged = false; + if (m_channel == -1) { + if (!m_model) { + if (model) { + channelsChanged = true; + } + } else { + if (model && + m_model->getChannelCount() != model->getChannelCount()) { + channelsChanged = true; + } + } + } + m_model = model; m_cacheValid = false; if (!m_model || !m_model->isOK()) return; @@ -68,6 +82,8 @@ this, SIGNAL(modelCompletionChanged())); emit modelReplaced(); + + if (channelsChanged) emit layerParametersChanged(); } Layer::PropertyList diff -r 193b569a975f -r 6dad2724f3aa widgets/PluginParameterDialog.cpp --- a/widgets/PluginParameterDialog.cpp Wed Mar 29 16:24:25 2006 +0000 +++ b/widgets/PluginParameterDialog.cpp Thu Mar 30 13:18:11 2006 +0000 @@ -22,11 +22,17 @@ #include #include #include +#include +#include PluginParameterDialog::PluginParameterDialog(PluginInstance *plugin, + int sourceChannels, + int targetChannels, + int defaultChannel, QWidget *parent) : QDialog(parent), m_plugin(plugin), + m_channel(defaultChannel), m_parameterBox(0) { QGridLayout *grid = new QGridLayout; @@ -49,14 +55,11 @@ nameLabel->setFont(font); QLabel *makerLabel = new QLabel(plugin->getMaker().c_str()); -// makerLabel->setFont(font); QLabel *versionLabel = new QLabel(QString("%1") .arg(plugin->getPluginVersion())); -// versionLabel->setFont(font); QLabel *copyrightLabel = new QLabel(plugin->getCopyright().c_str()); -// copyrightLabel->setFont(font); QLabel *typeLabel = new QLabel(plugin->getType().c_str()); typeLabel->setFont(font); @@ -92,8 +95,57 @@ this, SIGNAL(pluginConfigurationChanged(QString))); paramLayout->addWidget(m_parameterBox); + if (sourceChannels != targetChannels) { + + // At the moment we can only cope with the case where + // sourceChannels > targetChannels and targetChannels == 1 + + if (sourceChannels < targetChannels) { + + QMessageBox::warning + (parent, + tr("Channel mismatch"), + 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")), + QMessageBox::Ok, + QMessageBox::NoButton); + + } else { + + QGroupBox *channelBox = new QGroupBox; + channelBox->setTitle(tr("Channels")); + grid->addWidget(channelBox, 2, 0); + + QVBoxLayout *channelLayout = new QVBoxLayout; + channelBox->setLayout(channelLayout); + + if (targetChannels != 1) { + + channelLayout->addWidget + (new QLabel(tr("This plugin accepts no more than %1 input channels,\nbut %2 are available. Only the first %3 will be used.\n") + .arg(targetChannels) + .arg(sourceChannels) + .arg(targetChannels))); + + } else { + + channelLayout->addWidget(new QLabel(tr("This plugin only has a single channel input,\nbut the source has %1 channels.").arg(sourceChannels))); + + QComboBox *channelCombo = new QComboBox; + channelCombo->addItem(tr("Use sum of source channels").arg(sourceChannels)); + for (int i = 0; i < sourceChannels; ++i) { + channelCombo->addItem(tr("Use channel %1 only").arg(i + 1)); + } + + connect(channelCombo, SIGNAL(activated(int)), + this, SLOT(channelComboChanged(int))); + + channelLayout->addWidget(channelCombo); + } + } + } + QHBoxLayout *hbox = new QHBoxLayout; - grid->addLayout(hbox, 2, 0); + grid->addLayout(hbox, 3, 0); QPushButton *ok = new QPushButton(tr("OK")); QPushButton *cancel = new QPushButton(tr("Cancel")); @@ -108,3 +160,9 @@ { } +void +PluginParameterDialog::channelComboChanged(int index) +{ + m_channel = index - 1; +} + diff -r 193b569a975f -r 6dad2724f3aa widgets/PluginParameterDialog.h --- a/widgets/PluginParameterDialog.h Wed Mar 29 16:24:25 2006 +0000 +++ b/widgets/PluginParameterDialog.h Thu Mar 30 13:18:11 2006 +0000 @@ -34,16 +34,26 @@ Q_OBJECT public: - PluginParameterDialog(PluginInstance *, QWidget *parent = 0); + PluginParameterDialog(PluginInstance *, + int sourceChannels, + int targetChannels, + int defaultChannel, + QWidget *parent = 0); ~PluginParameterDialog(); PluginInstance *getPlugin() { return m_plugin; } + int getChannel() const { return m_channel; } + signals: void pluginConfigurationChanged(QString); +protected slots: + void channelComboChanged(int); + protected: PluginInstance *m_plugin; + int m_channel; PluginParameterBox *m_parameterBox; }; diff -r 193b569a975f -r 6dad2724f3aa widgets/PropertyBox.cpp --- a/widgets/PropertyBox.cpp Wed Mar 29 16:24:25 2006 +0000 +++ b/widgets/PropertyBox.cpp Thu Mar 30 13:18:11 2006 +0000 @@ -487,7 +487,7 @@ instance->setParametersFromXml(configurationXml); - PluginParameterDialog *dialog = new PluginParameterDialog(instance); + PluginParameterDialog *dialog = new PluginParameterDialog(instance, -1, -1, -1); connect(dialog, SIGNAL(pluginConfigurationChanged(QString)), this, SLOT(pluginConfigurationChanged(QString)));