Mercurial > hg > svgui
comparison widgets/PluginParameterDialog.cpp @ 143:bcb6d71be63c
* Put channel and windowing parameters on an "advanced" bit of the plugin
parameter window
author | Chris Cannam |
---|---|
date | Fri, 15 Sep 2006 13:50:22 +0000 |
parents | b9235b62fe31 |
children | 4d132a06db9b |
comparison
equal
deleted
inserted
replaced
142:40a47de69559 | 143:bcb6d71be63c |
---|---|
22 | 22 |
23 #include <QGridLayout> | 23 #include <QGridLayout> |
24 #include <QLabel> | 24 #include <QLabel> |
25 #include <QGroupBox> | 25 #include <QGroupBox> |
26 #include <QHBoxLayout> | 26 #include <QHBoxLayout> |
27 #include <QVBoxLayout> | |
27 #include <QPushButton> | 28 #include <QPushButton> |
28 #include <QMessageBox> | 29 #include <QMessageBox> |
29 #include <QComboBox> | 30 #include <QComboBox> |
31 #include <QSettings> | |
30 | 32 |
31 PluginParameterDialog::PluginParameterDialog(Vamp::PluginBase *plugin, | 33 PluginParameterDialog::PluginParameterDialog(Vamp::PluginBase *plugin, |
32 int sourceChannels, | 34 int sourceChannels, |
33 int targetChannels, | 35 int targetChannels, |
34 int defaultChannel, | 36 int defaultChannel, |
131 m_parameterBox = new PluginParameterBox(m_plugin); | 133 m_parameterBox = new PluginParameterBox(m_plugin); |
132 connect(m_parameterBox, SIGNAL(pluginConfigurationChanged(QString)), | 134 connect(m_parameterBox, SIGNAL(pluginConfigurationChanged(QString)), |
133 this, SIGNAL(pluginConfigurationChanged(QString))); | 135 this, SIGNAL(pluginConfigurationChanged(QString))); |
134 paramLayout->addWidget(m_parameterBox); | 136 paramLayout->addWidget(m_parameterBox); |
135 | 137 |
138 m_advanced = new QFrame; | |
139 QVBoxLayout *advancedLayout = new QVBoxLayout; | |
140 advancedLayout->setMargin(0); | |
141 m_advanced->setLayout(advancedLayout); | |
142 grid->addWidget(m_advanced, 2, 0); | |
143 | |
144 bool haveAdvanced = false; | |
145 | |
136 if (sourceChannels != targetChannels) { | 146 if (sourceChannels != targetChannels) { |
137 | 147 |
138 // At the moment we can only cope with the case where | 148 // At the moment we can only cope with the case where |
139 // sourceChannels > targetChannels and targetChannels == 1 | 149 // sourceChannels > targetChannels and targetChannels == 1 |
140 | 150 |
149 | 159 |
150 } else { | 160 } else { |
151 | 161 |
152 QGroupBox *channelBox = new QGroupBox; | 162 QGroupBox *channelBox = new QGroupBox; |
153 channelBox->setTitle(tr("Channels")); | 163 channelBox->setTitle(tr("Channels")); |
154 grid->addWidget(channelBox, 2, 0); | 164 advancedLayout->addWidget(channelBox); |
165 haveAdvanced = true; | |
155 | 166 |
156 QVBoxLayout *channelLayout = new QVBoxLayout; | 167 QVBoxLayout *channelLayout = new QVBoxLayout; |
157 channelBox->setLayout(channelLayout); | 168 channelBox->setLayout(channelLayout); |
158 | 169 |
159 if (targetChannels != 1) { | 170 if (targetChannels != 1) { |
194 if (increment == 0) increment = size; | 205 if (increment == 0) increment = size; |
195 } | 206 } |
196 | 207 |
197 QGroupBox *windowBox = new QGroupBox; | 208 QGroupBox *windowBox = new QGroupBox; |
198 windowBox->setTitle(tr("Processing")); | 209 windowBox->setTitle(tr("Processing")); |
199 grid->addWidget(windowBox, 3, 0); | 210 advancedLayout->addWidget(windowBox); |
211 haveAdvanced = true; | |
200 | 212 |
201 QGridLayout *windowLayout = new QGridLayout; | 213 QGridLayout *windowLayout = new QGridLayout; |
202 windowBox->setLayout(windowLayout); | 214 windowBox->setLayout(windowLayout); |
203 | 215 |
204 if (showFrequencyDomainOptions) { | 216 if (showFrequencyDomainOptions) { |
205 windowLayout->addWidget(new QLabel(tr("Window size:")), 0, 0); | 217 windowLayout->addWidget(new QLabel(tr("Window size:")), 0, 0); |
206 } else { | 218 } else { |
207 windowLayout->addWidget(new QLabel(tr("Audio frames per block:")), 0, 0); | 219 windowLayout->addWidget(new QLabel(tr("Audio frames per block:")), 0, 0); |
208 } | 220 } |
209 | 221 |
222 std::cerr << "size: " << size << ", increment: " << increment << std::endl; | |
223 | |
210 QComboBox *blockSizeCombo = new QComboBox; | 224 QComboBox *blockSizeCombo = new QComboBox; |
211 blockSizeCombo->setEditable(true); | 225 blockSizeCombo->setEditable(true); |
212 //!!! integer validator | 226 for (int i = 0; i < 14; ++i) { |
213 for (int i = 0; i < 12; ++i) { | |
214 int val = pow(2, i + 3); | 227 int val = pow(2, i + 3); |
215 blockSizeCombo->addItem(QString("%1").arg(val)); | 228 blockSizeCombo->addItem(QString("%1").arg(val)); |
216 if (val == size) blockSizeCombo->setCurrentIndex(i); | 229 if (val == size) blockSizeCombo->setCurrentIndex(i); |
217 } | 230 } |
231 blockSizeCombo->setValidator(new QIntValidator(1, pow(2, 18), this)); | |
218 windowLayout->addWidget(blockSizeCombo, 0, 1); | 232 windowLayout->addWidget(blockSizeCombo, 0, 1); |
219 | 233 |
220 if (showFrequencyDomainOptions) { | 234 if (showFrequencyDomainOptions) { |
221 | 235 |
222 windowLayout->addWidget(new QLabel(tr("Window increment:")), 1, 0); | 236 windowLayout->addWidget(new QLabel(tr("Window increment:")), 1, 0); |
223 | 237 |
224 QComboBox *incrementCombo = new QComboBox; | 238 QComboBox *incrementCombo = new QComboBox; |
225 incrementCombo->setEditable(true); | 239 incrementCombo->setEditable(true); |
226 //!!! integer validator | 240 for (int i = 0; i < 14; ++i) { |
227 for (int i = 0; i < 12; ++i) { | |
228 int val = pow(2, i + 3); | 241 int val = pow(2, i + 3); |
229 incrementCombo->addItem(QString("%1").arg(val)); | 242 incrementCombo->addItem(QString("%1").arg(val)); |
230 if (val == increment) blockSizeCombo->setCurrentIndex(i); | 243 if (val == increment) incrementCombo->setCurrentIndex(i); |
231 } | 244 } |
245 incrementCombo->setValidator(new QIntValidator(1, pow(2, 18), this)); | |
232 windowLayout->addWidget(incrementCombo, 1, 1); | 246 windowLayout->addWidget(incrementCombo, 1, 1); |
233 | 247 |
234 windowLayout->addWidget(new QLabel(tr("Window shape:")), 2, 0); | 248 windowLayout->addWidget(new QLabel(tr("Window shape:")), 2, 0); |
235 WindowTypeSelector *windowTypeSelector = new WindowTypeSelector; | 249 WindowTypeSelector *windowTypeSelector = new WindowTypeSelector; |
236 windowLayout->addWidget(windowTypeSelector, 2, 1); | 250 windowLayout->addWidget(windowTypeSelector, 2, 1); |
240 //!!! We lack a comfortable way of passing around the channel and | 254 //!!! We lack a comfortable way of passing around the channel and |
241 //blocksize data | 255 //blocksize data |
242 | 256 |
243 QHBoxLayout *hbox = new QHBoxLayout; | 257 QHBoxLayout *hbox = new QHBoxLayout; |
244 grid->addLayout(hbox, 4, 0); | 258 grid->addLayout(hbox, 4, 0); |
245 | 259 |
260 bool advancedVisible = false; | |
261 | |
262 if (haveAdvanced) { | |
263 | |
264 m_advancedButton = new QPushButton(tr("Advanced >>")); | |
265 m_advancedButton->setCheckable(true); | |
266 connect(m_advancedButton, SIGNAL(clicked()), this, SLOT(advancedToggled())); | |
267 | |
268 QSettings settings; | |
269 settings.beginGroup("PluginParameterDialog"); | |
270 advancedVisible = settings.value("advancedvisible", false).toBool(); | |
271 settings.endGroup(); | |
272 | |
273 m_advanced->setVisible(false); | |
274 | |
275 hbox->addWidget(m_advancedButton); | |
276 } | |
277 | |
246 QPushButton *ok = new QPushButton(tr("OK")); | 278 QPushButton *ok = new QPushButton(tr("OK")); |
247 QPushButton *cancel = new QPushButton(tr("Cancel")); | 279 QPushButton *cancel = new QPushButton(tr("Cancel")); |
248 hbox->addStretch(10); | 280 hbox->addStretch(10); |
249 hbox->addWidget(ok); | 281 hbox->addWidget(ok); |
250 hbox->addWidget(cancel); | 282 hbox->addWidget(cancel); |
251 connect(ok, SIGNAL(clicked()), this, SLOT(accept())); | 283 connect(ok, SIGNAL(clicked()), this, SLOT(accept())); |
252 connect(cancel, SIGNAL(clicked()), this, SLOT(reject())); | 284 connect(cancel, SIGNAL(clicked()), this, SLOT(reject())); |
285 | |
286 if (advancedVisible) { | |
287 m_advancedButton->setChecked(true); | |
288 advancedToggled(); | |
289 } | |
253 } | 290 } |
254 | 291 |
255 PluginParameterDialog::~PluginParameterDialog() | 292 PluginParameterDialog::~PluginParameterDialog() |
256 { | 293 { |
294 } | |
295 | |
296 void | |
297 PluginParameterDialog::advancedToggled() | |
298 { | |
299 bool visible = !m_advanced->isVisible(); | |
300 | |
301 m_advanced->setVisible(visible); | |
302 | |
303 if (visible) m_advancedButton->setText(tr("Advanced <<")); | |
304 else m_advancedButton->setText(tr("Advanced >>")); | |
305 | |
306 QSettings settings; | |
307 settings.beginGroup("PluginParameterDialog"); | |
308 settings.setValue("advancedvisible", visible); | |
309 settings.endGroup(); | |
310 | |
311 std::cerr << "resize to " << sizeHint().width() << " x " << sizeHint().height() << std::endl; | |
312 | |
313 setMaximumSize(sizeHint()); | |
257 } | 314 } |
258 | 315 |
259 void | 316 void |
260 PluginParameterDialog::channelComboChanged(int index) | 317 PluginParameterDialog::channelComboChanged(int index) |
261 { | 318 { |