Mercurial > hg > svgui
diff widgets/PluginParameterDialog.cpp @ 69:6dad2724f3aa
* 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)
author | Chris Cannam |
---|---|
date | Thu, 30 Mar 2006 13:18:11 +0000 |
parents | 7f608ec9a061 |
children | 72fa239a4880 |
line wrap: on
line diff
--- 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 <QGroupBox> #include <QHBoxLayout> #include <QPushButton> +#include <QMessageBox> +#include <QComboBox> 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; +} +