comparison 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
comparison
equal deleted inserted replaced
68:193b569a975f 69:6dad2724f3aa
20 #include <QGridLayout> 20 #include <QGridLayout>
21 #include <QLabel> 21 #include <QLabel>
22 #include <QGroupBox> 22 #include <QGroupBox>
23 #include <QHBoxLayout> 23 #include <QHBoxLayout>
24 #include <QPushButton> 24 #include <QPushButton>
25 #include <QMessageBox>
26 #include <QComboBox>
25 27
26 PluginParameterDialog::PluginParameterDialog(PluginInstance *plugin, 28 PluginParameterDialog::PluginParameterDialog(PluginInstance *plugin,
29 int sourceChannels,
30 int targetChannels,
31 int defaultChannel,
27 QWidget *parent) : 32 QWidget *parent) :
28 QDialog(parent), 33 QDialog(parent),
29 m_plugin(plugin), 34 m_plugin(plugin),
35 m_channel(defaultChannel),
30 m_parameterBox(0) 36 m_parameterBox(0)
31 { 37 {
32 QGridLayout *grid = new QGridLayout; 38 QGridLayout *grid = new QGridLayout;
33 setLayout(grid); 39 setLayout(grid);
34 40
47 53
48 QLabel *nameLabel = new QLabel(plugin->getDescription().c_str()); 54 QLabel *nameLabel = new QLabel(plugin->getDescription().c_str());
49 nameLabel->setFont(font); 55 nameLabel->setFont(font);
50 56
51 QLabel *makerLabel = new QLabel(plugin->getMaker().c_str()); 57 QLabel *makerLabel = new QLabel(plugin->getMaker().c_str());
52 // makerLabel->setFont(font);
53 58
54 QLabel *versionLabel = new QLabel(QString("%1") 59 QLabel *versionLabel = new QLabel(QString("%1")
55 .arg(plugin->getPluginVersion())); 60 .arg(plugin->getPluginVersion()));
56 // versionLabel->setFont(font);
57 61
58 QLabel *copyrightLabel = new QLabel(plugin->getCopyright().c_str()); 62 QLabel *copyrightLabel = new QLabel(plugin->getCopyright().c_str());
59 // copyrightLabel->setFont(font);
60 63
61 QLabel *typeLabel = new QLabel(plugin->getType().c_str()); 64 QLabel *typeLabel = new QLabel(plugin->getType().c_str());
62 typeLabel->setFont(font); 65 typeLabel->setFont(font);
63 66
64 subgrid->addWidget(new QLabel(tr("Name:")), 0, 0); 67 subgrid->addWidget(new QLabel(tr("Name:")), 0, 0);
90 m_parameterBox = new PluginParameterBox(m_plugin); 93 m_parameterBox = new PluginParameterBox(m_plugin);
91 connect(m_parameterBox, SIGNAL(pluginConfigurationChanged(QString)), 94 connect(m_parameterBox, SIGNAL(pluginConfigurationChanged(QString)),
92 this, SIGNAL(pluginConfigurationChanged(QString))); 95 this, SIGNAL(pluginConfigurationChanged(QString)));
93 paramLayout->addWidget(m_parameterBox); 96 paramLayout->addWidget(m_parameterBox);
94 97
98 if (sourceChannels != targetChannels) {
99
100 // At the moment we can only cope with the case where
101 // sourceChannels > targetChannels and targetChannels == 1
102
103 if (sourceChannels < targetChannels) {
104
105 QMessageBox::warning
106 (parent,
107 tr("Channel mismatch"),
108 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")),
109 QMessageBox::Ok,
110 QMessageBox::NoButton);
111
112 } else {
113
114 QGroupBox *channelBox = new QGroupBox;
115 channelBox->setTitle(tr("Channels"));
116 grid->addWidget(channelBox, 2, 0);
117
118 QVBoxLayout *channelLayout = new QVBoxLayout;
119 channelBox->setLayout(channelLayout);
120
121 if (targetChannels != 1) {
122
123 channelLayout->addWidget
124 (new QLabel(tr("This plugin accepts no more than %1 input channels,\nbut %2 are available. Only the first %3 will be used.\n")
125 .arg(targetChannels)
126 .arg(sourceChannels)
127 .arg(targetChannels)));
128
129 } else {
130
131 channelLayout->addWidget(new QLabel(tr("This plugin only has a single channel input,\nbut the source has %1 channels.").arg(sourceChannels)));
132
133 QComboBox *channelCombo = new QComboBox;
134 channelCombo->addItem(tr("Use sum of source channels").arg(sourceChannels));
135 for (int i = 0; i < sourceChannels; ++i) {
136 channelCombo->addItem(tr("Use channel %1 only").arg(i + 1));
137 }
138
139 connect(channelCombo, SIGNAL(activated(int)),
140 this, SLOT(channelComboChanged(int)));
141
142 channelLayout->addWidget(channelCombo);
143 }
144 }
145 }
146
95 QHBoxLayout *hbox = new QHBoxLayout; 147 QHBoxLayout *hbox = new QHBoxLayout;
96 grid->addLayout(hbox, 2, 0); 148 grid->addLayout(hbox, 3, 0);
97 149
98 QPushButton *ok = new QPushButton(tr("OK")); 150 QPushButton *ok = new QPushButton(tr("OK"));
99 QPushButton *cancel = new QPushButton(tr("Cancel")); 151 QPushButton *cancel = new QPushButton(tr("Cancel"));
100 hbox->addStretch(10); 152 hbox->addStretch(10);
101 hbox->addWidget(ok); 153 hbox->addWidget(ok);
106 158
107 PluginParameterDialog::~PluginParameterDialog() 159 PluginParameterDialog::~PluginParameterDialog()
108 { 160 {
109 } 161 }
110 162
163 void
164 PluginParameterDialog::channelComboChanged(int index)
165 {
166 m_channel = index - 1;
167 }
168