annotate widgets/PluginParameterDialog.cpp @ 297:860f9ada4327

...
author Chris Cannam
date Tue, 14 Aug 2007 19:37:10 +0000
parents ea37c229a578
children e9549ea3f825
rev   line source
Chris@62 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@62 2
Chris@62 3 /*
Chris@62 4 Sonic Visualiser
Chris@62 5 An audio file viewer and annotation editor.
Chris@62 6 Centre for Digital Music, Queen Mary, University of London.
Chris@182 7 This file copyright 2006 Chris Cannam and QMUL.
Chris@62 8
Chris@62 9 This program is free software; you can redistribute it and/or
Chris@62 10 modify it under the terms of the GNU General Public License as
Chris@62 11 published by the Free Software Foundation; either version 2 of the
Chris@62 12 License, or (at your option) any later version. See the file
Chris@62 13 COPYING included with this distribution for more information.
Chris@62 14 */
Chris@62 15
Chris@62 16 #include "PluginParameterDialog.h"
Chris@62 17
Chris@62 18 #include "PluginParameterBox.h"
Chris@140 19 #include "WindowTypeSelector.h"
Chris@62 20
Chris@294 21 #include "base/TextAbbrev.h"
Chris@294 22
Chris@106 23 #include "vamp-sdk/Plugin.h"
Chris@147 24 #include "vamp-sdk/PluginHostAdapter.h"
Chris@106 25
Chris@62 26 #include <QGridLayout>
Chris@62 27 #include <QLabel>
Chris@62 28 #include <QGroupBox>
Chris@62 29 #include <QHBoxLayout>
Chris@143 30 #include <QVBoxLayout>
Chris@149 31 #include <QScrollArea>
Chris@62 32 #include <QPushButton>
Chris@69 33 #include <QMessageBox>
Chris@69 34 #include <QComboBox>
Chris@143 35 #include <QSettings>
Chris@282 36 #include <QDialogButtonBox>
Chris@62 37
Chris@71 38 PluginParameterDialog::PluginParameterDialog(Vamp::PluginBase *plugin,
Chris@62 39 QWidget *parent) :
Chris@62 40 QDialog(parent),
Chris@62 41 m_plugin(plugin),
Chris@163 42 m_channel(-1),
Chris@145 43 m_stepSize(0),
Chris@145 44 m_blockSize(0),
Chris@145 45 m_windowType(HanningWindow),
Chris@62 46 m_parameterBox(0)
Chris@62 47 {
Chris@122 48 setWindowTitle(tr("Plugin Parameters"));
Chris@122 49
Chris@62 50 QGridLayout *grid = new QGridLayout;
Chris@62 51 setLayout(grid);
Chris@62 52
Chris@62 53 QGroupBox *pluginBox = new QGroupBox;
Chris@208 54 pluginBox->setTitle(plugin->getType().c_str());
Chris@62 55 grid->addWidget(pluginBox, 0, 0);
Chris@62 56
Chris@62 57 QGridLayout *subgrid = new QGridLayout;
Chris@62 58 pluginBox->setLayout(subgrid);
Chris@62 59
Chris@63 60 subgrid->setSpacing(0);
Chris@63 61 subgrid->setMargin(10);
Chris@63 62
Chris@208 63 QFont boldFont(pluginBox->font());
Chris@208 64 boldFont.setBold(true);
Chris@208 65
Chris@208 66 QFont italicFont(pluginBox->font());
Chris@208 67 italicFont.setItalic(true);
Chris@62 68
Chris@207 69 QLabel *nameLabel = new QLabel(plugin->getName().c_str());
Chris@146 70 nameLabel->setWordWrap(true);
Chris@208 71 nameLabel->setFont(boldFont);
Chris@62 72
Chris@62 73 QLabel *makerLabel = new QLabel(plugin->getMaker().c_str());
Chris@146 74 makerLabel->setWordWrap(true);
Chris@62 75
Chris@62 76 QLabel *versionLabel = new QLabel(QString("%1")
Chris@62 77 .arg(plugin->getPluginVersion()));
Chris@146 78 versionLabel->setWordWrap(true);
Chris@62 79
Chris@62 80 QLabel *copyrightLabel = new QLabel(plugin->getCopyright().c_str());
Chris@146 81 copyrightLabel->setWordWrap(true);
Chris@62 82
Chris@208 83 // QLabel *typeLabel = new QLabel(plugin->getType().c_str());
Chris@208 84 // typeLabel->setWordWrap(true);
Chris@208 85 // typeLabel->setFont(boldFont);
Chris@208 86
Chris@208 87 QLabel *descriptionLabel = 0;
Chris@208 88 if (plugin->getDescription() != "") {
Chris@208 89 descriptionLabel = new QLabel(plugin->getDescription().c_str());
Chris@208 90 descriptionLabel->setWordWrap(true);
Chris@208 91 descriptionLabel->setFont(italicFont);
Chris@208 92 }
Chris@63 93
Chris@163 94 int row = 0;
Chris@163 95
Chris@147 96 QLabel *label = new QLabel(tr("Name:"));
Chris@147 97 label->setAlignment(Qt::AlignTop | Qt::AlignLeft);
Chris@163 98 subgrid->addWidget(label, row, 0);
Chris@163 99 subgrid->addWidget(nameLabel, row, 1);
Chris@163 100 row++;
Chris@62 101
Chris@208 102 if (descriptionLabel) {
Chris@208 103 // label = new QLabel(tr("Description:"));
Chris@208 104 // label->setAlignment(Qt::AlignTop | Qt::AlignLeft);
Chris@208 105 // subgrid->addWidget(label, row, 0);
Chris@208 106 subgrid->addWidget(descriptionLabel, row, 1);
Chris@208 107 row++;
Chris@208 108 }
Chris@208 109
Chris@208 110 Vamp::PluginHostAdapter *fePlugin =
Chris@208 111 dynamic_cast<Vamp::PluginHostAdapter *>(m_plugin);
Chris@208 112
Chris@208 113 if (fePlugin) {
Chris@208 114 label = new QLabel(tr("Version:"));
Chris@208 115 label->setAlignment(Qt::AlignTop | Qt::AlignLeft);
Chris@208 116 subgrid->addWidget(label, row, 0);
Chris@208 117 subgrid->addWidget(versionLabel, row, 1);
Chris@208 118 row++;
Chris@208 119 }
Chris@208 120
Chris@208 121 // label = new QLabel(tr("Type:"));
Chris@208 122 // label->setAlignment(Qt::AlignTop | Qt::AlignLeft);
Chris@208 123 // subgrid->addWidget(label, row, 0);
Chris@208 124 // subgrid->addWidget(typeLabel, row, 1);
Chris@208 125 // row++;
Chris@62 126
Chris@147 127 label = new QLabel(tr("Maker:"));
Chris@147 128 label->setAlignment(Qt::AlignTop | Qt::AlignLeft);
Chris@163 129 subgrid->addWidget(label, row, 0);
Chris@163 130 subgrid->addWidget(makerLabel, row, 1);
Chris@163 131 row++;
Chris@63 132
Chris@147 133 label = new QLabel(tr("Copyright: "));
Chris@147 134 label->setAlignment(Qt::AlignTop | Qt::AlignLeft);
Chris@163 135 subgrid->addWidget(label, row, 0);
Chris@163 136 subgrid->addWidget(copyrightLabel, row, 1);
Chris@163 137 row++;
Chris@208 138
Chris@208 139 m_outputSpacer = new QLabel;
Chris@208 140 subgrid->addWidget(m_outputSpacer, row, 0);
Chris@208 141 m_outputSpacer->setFixedHeight(7);
Chris@208 142 m_outputSpacer->hide();
Chris@208 143 row++;
Chris@106 144
Chris@208 145 m_outputLabel = new QLabel(tr("Output:"));
Chris@208 146 m_outputLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft);
Chris@208 147 subgrid->addWidget(m_outputLabel, row, 0);
Chris@208 148 m_outputValue = new QLabel;
Chris@208 149 m_outputValue->setFont(boldFont);
Chris@208 150 subgrid->addWidget(m_outputValue, row, 1);
Chris@208 151 m_outputLabel->hide();
Chris@208 152 m_outputValue->hide();
Chris@208 153 row++;
Chris@208 154
Chris@208 155 m_outputDescription = new QLabel;
Chris@208 156 m_outputDescription->setFont(italicFont);
Chris@208 157 subgrid->addWidget(m_outputDescription, row, 1);
Chris@208 158 m_outputDescription->hide();
Chris@163 159 row++;
Chris@62 160
Chris@62 161 subgrid->setColumnStretch(1, 2);
Chris@62 162
Chris@164 163 m_inputModelBox = new QGroupBox;
Chris@164 164 m_inputModelBox->setTitle(tr("Input Source"));
Chris@164 165 grid->addWidget(m_inputModelBox, 1, 0);
Chris@164 166
Chris@164 167 m_inputModels = new QComboBox;
Chris@164 168 QHBoxLayout *inputLayout = new QHBoxLayout;
Chris@164 169 m_inputModelBox->setLayout(inputLayout);
Chris@164 170 inputLayout->addWidget(m_inputModels);
Chris@164 171 m_inputModelBox->hide();
Chris@164 172
Chris@62 173 QGroupBox *paramBox = new QGroupBox;
Chris@62 174 paramBox->setTitle(tr("Plugin Parameters"));
Chris@164 175 grid->addWidget(paramBox, 2, 0);
Chris@164 176 grid->setRowStretch(2, 10);
Chris@62 177
Chris@62 178 QHBoxLayout *paramLayout = new QHBoxLayout;
Chris@63 179 paramLayout->setMargin(0);
Chris@62 180 paramBox->setLayout(paramLayout);
Chris@62 181
Chris@149 182 QScrollArea *scroll = new QScrollArea;
Chris@149 183 scroll->setWidgetResizable(true);
Chris@149 184 scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
Chris@149 185 scroll->setFrameShape(QFrame::NoFrame);
Chris@149 186 paramLayout->addWidget(scroll);
Chris@149 187
Chris@62 188 m_parameterBox = new PluginParameterBox(m_plugin);
Chris@64 189 connect(m_parameterBox, SIGNAL(pluginConfigurationChanged(QString)),
Chris@64 190 this, SIGNAL(pluginConfigurationChanged(QString)));
Chris@149 191 scroll->setWidget(m_parameterBox);
Chris@62 192
Chris@143 193 m_advanced = new QFrame;
Chris@143 194 QVBoxLayout *advancedLayout = new QVBoxLayout;
Chris@143 195 advancedLayout->setMargin(0);
Chris@143 196 m_advanced->setLayout(advancedLayout);
Chris@164 197 grid->addWidget(m_advanced, 3, 0);
Chris@143 198
Chris@163 199 m_channelBox = new QGroupBox;
Chris@163 200 m_channelBox->setTitle(tr("Channels"));
Chris@163 201 advancedLayout->addWidget(m_channelBox);
Chris@163 202 m_channelBox->setVisible(false);
Chris@163 203 m_haveChannelBoxData = false;
Chris@163 204
Chris@163 205 m_windowBox = new QGroupBox;
Chris@163 206 m_windowBox->setTitle(tr("Processing"));
Chris@163 207 advancedLayout->addWidget(m_windowBox);
Chris@163 208 m_windowBox->setVisible(false);
Chris@163 209 m_haveWindowBoxData = false;
Chris@163 210
Chris@163 211 QHBoxLayout *hbox = new QHBoxLayout;
Chris@163 212 grid->addLayout(hbox, 4, 0);
Chris@163 213
Chris@163 214 m_advancedVisible = false;
Chris@163 215
Chris@163 216 m_advancedButton = new QPushButton(tr("Advanced >>"));
Chris@163 217 m_advancedButton->setCheckable(true);
Chris@163 218 connect(m_advancedButton, SIGNAL(clicked()), this, SLOT(advancedToggled()));
Chris@163 219
Chris@163 220 QSettings settings;
Chris@163 221 settings.beginGroup("PluginParameterDialog");
Chris@163 222 m_advancedVisible = settings.value("advancedvisible", false).toBool();
Chris@163 223 settings.endGroup();
Chris@163 224
Chris@163 225 m_advanced->setVisible(false);
Chris@163 226
Chris@163 227 hbox->addWidget(m_advancedButton);
Chris@163 228 m_advancedButton->hide();
Chris@163 229
Chris@282 230 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok |
Chris@282 231 QDialogButtonBox::Cancel);
Chris@282 232 hbox->addWidget(bb);
Chris@294 233 connect(bb, SIGNAL(accepted()), this, SLOT(dialogAccepted()));
Chris@282 234 connect(bb, SIGNAL(rejected()), this, SLOT(reject()));
Chris@163 235
Chris@163 236 setAdvancedVisible(m_advancedVisible);
Chris@163 237 }
Chris@163 238
Chris@163 239 PluginParameterDialog::~PluginParameterDialog()
Chris@163 240 {
Chris@163 241 }
Chris@163 242
Chris@163 243
Chris@163 244 void
Chris@208 245 PluginParameterDialog::setOutputLabel(QString text,
Chris@208 246 QString description)
Chris@163 247 {
Chris@163 248 if (text == "") {
Chris@208 249 m_outputSpacer->hide();
Chris@163 250 m_outputLabel->hide();
Chris@163 251 m_outputValue->hide();
Chris@208 252 m_outputDescription->hide();
Chris@163 253 } else {
Chris@208 254 m_outputSpacer->show();
Chris@163 255 m_outputValue->setText(text);
Chris@163 256 m_outputValue->setWordWrap(true);
Chris@208 257 m_outputDescription->setText(description);
Chris@163 258 m_outputLabel->show();
Chris@163 259 m_outputValue->show();
Chris@208 260 if (description != "") {
Chris@208 261 m_outputDescription->show();
Chris@208 262 } else {
Chris@208 263 m_outputDescription->hide();
Chris@208 264 }
Chris@163 265 }
Chris@163 266 }
Chris@163 267
Chris@163 268 void
Chris@163 269 PluginParameterDialog::setChannelArrangement(int sourceChannels,
Chris@163 270 int targetChannels,
Chris@163 271 int defaultChannel)
Chris@163 272 {
Chris@163 273 m_channel = defaultChannel;
Chris@163 274
Chris@69 275 if (sourceChannels != targetChannels) {
Chris@69 276
Chris@69 277 // At the moment we can only cope with the case where
Chris@69 278 // sourceChannels > targetChannels and targetChannels == 1
Chris@69 279
Chris@69 280 if (sourceChannels < targetChannels) {
Chris@69 281
Chris@69 282 QMessageBox::warning
Chris@163 283 (parentWidget(),
Chris@69 284 tr("Channel mismatch"),
Chris@69 285 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")),
Chris@69 286 QMessageBox::Ok,
Chris@69 287 QMessageBox::NoButton);
Chris@69 288
Chris@69 289 } else {
Chris@69 290
Chris@163 291 if (m_haveChannelBoxData) {
Chris@163 292 std::cerr << "WARNING: PluginParameterDialog::setChannelArrangement: Calling more than once on same dialog is not currently implemented" << std::endl;
Chris@163 293 return;
Chris@163 294 }
Chris@69 295
Chris@69 296 QVBoxLayout *channelLayout = new QVBoxLayout;
Chris@163 297 m_channelBox->setLayout(channelLayout);
Chris@69 298
Chris@69 299 if (targetChannels != 1) {
Chris@69 300
Chris@69 301 channelLayout->addWidget
Chris@69 302 (new QLabel(tr("This plugin accepts no more than %1 input channels,\nbut %2 are available. Only the first %3 will be used.\n")
Chris@69 303 .arg(targetChannels)
Chris@69 304 .arg(sourceChannels)
Chris@69 305 .arg(targetChannels)));
Chris@69 306
Chris@69 307 } else {
Chris@69 308
Chris@69 309 channelLayout->addWidget(new QLabel(tr("This plugin only has a single channel input,\nbut the source has %1 channels.").arg(sourceChannels)));
Chris@69 310
Chris@69 311 QComboBox *channelCombo = new QComboBox;
Chris@76 312 channelCombo->addItem(tr("Use mean of source channels"));
Chris@69 313 for (int i = 0; i < sourceChannels; ++i) {
Chris@69 314 channelCombo->addItem(tr("Use channel %1 only").arg(i + 1));
Chris@69 315 }
Chris@69 316
Chris@69 317 connect(channelCombo, SIGNAL(activated(int)),
Chris@69 318 this, SLOT(channelComboChanged(int)));
Chris@69 319
Chris@69 320 channelLayout->addWidget(channelCombo);
Chris@69 321 }
Chris@163 322
Chris@163 323 m_channelBox->setVisible(true);
Chris@163 324 m_haveChannelBoxData = true;
Chris@163 325 m_advancedButton->show();
Chris@69 326 }
Chris@69 327 }
Chris@69 328
Chris@163 329 setAdvancedVisible(m_advancedVisible);
Chris@163 330 }
Chris@163 331
Chris@163 332 void
Chris@163 333 PluginParameterDialog::setShowProcessingOptions(bool showWindowSize,
Chris@163 334 bool showFrequencyDomainOptions)
Chris@163 335 {
Chris@163 336 if (m_haveWindowBoxData) {
Chris@163 337 std::cerr << "WARNING: PluginParameterDialog::setShowProcessingOptions: Calling more than once on same dialog is not currently implemented" << std::endl;
Chris@163 338 return;
Chris@163 339 }
Chris@163 340
Chris@140 341 if (showWindowSize) {
Chris@140 342
Chris@147 343 Vamp::PluginHostAdapter *fePlugin = dynamic_cast<Vamp::PluginHostAdapter *>(m_plugin);
Chris@140 344 int size = 1024;
Chris@140 345 int increment = 1024;
Chris@140 346 if (fePlugin) {
Chris@140 347 size = fePlugin->getPreferredBlockSize();
Chris@207 348 std::cerr << "Feature extraction plugin \"" << fePlugin->getName() << "\" reports preferred block size as " << size << std::endl;
Chris@140 349 if (size == 0) size = 1024;
Chris@140 350 increment = fePlugin->getPreferredStepSize();
Chris@146 351 if (increment == 0) {
Chris@146 352 if (fePlugin->getInputDomain() == Vamp::Plugin::TimeDomain) {
Chris@146 353 increment = size;
Chris@146 354 } else {
Chris@146 355 increment = size/2;
Chris@146 356 }
Chris@146 357 }
Chris@140 358 }
Chris@140 359
Chris@140 360 QGridLayout *windowLayout = new QGridLayout;
Chris@163 361 m_windowBox->setLayout(windowLayout);
Chris@140 362
Chris@140 363 if (showFrequencyDomainOptions) {
Chris@140 364 windowLayout->addWidget(new QLabel(tr("Window size:")), 0, 0);
Chris@140 365 } else {
Chris@140 366 windowLayout->addWidget(new QLabel(tr("Audio frames per block:")), 0, 0);
Chris@140 367 }
Chris@140 368
Chris@143 369 std::cerr << "size: " << size << ", increment: " << increment << std::endl;
Chris@143 370
Chris@140 371 QComboBox *blockSizeCombo = new QComboBox;
Chris@140 372 blockSizeCombo->setEditable(true);
Chris@147 373 bool found = false;
Chris@143 374 for (int i = 0; i < 14; ++i) {
Chris@249 375 int val = 1 << (i + 3);
Chris@140 376 blockSizeCombo->addItem(QString("%1").arg(val));
Chris@147 377 if (val == size) {
Chris@147 378 blockSizeCombo->setCurrentIndex(i);
Chris@147 379 found = true;
Chris@147 380 }
Chris@147 381 }
Chris@147 382 if (!found) {
Chris@147 383 blockSizeCombo->addItem(QString("%1").arg(size));
Chris@147 384 blockSizeCombo->setCurrentIndex(blockSizeCombo->count() - 1);
Chris@140 385 }
Chris@282 386 blockSizeCombo->setValidator(new QIntValidator(1, int(pow(2, 18)), this));
Chris@155 387 connect(blockSizeCombo, SIGNAL(editTextChanged(const QString &)),
Chris@155 388 this, SLOT(blockSizeComboChanged(const QString &)));
Chris@140 389 windowLayout->addWidget(blockSizeCombo, 0, 1);
Chris@140 390
Chris@148 391 windowLayout->addWidget(new QLabel(tr("Window increment:")), 1, 0);
Chris@148 392
Chris@148 393 QComboBox *incrementCombo = new QComboBox;
Chris@148 394 incrementCombo->setEditable(true);
Chris@148 395 found = false;
Chris@148 396 for (int i = 0; i < 14; ++i) {
Chris@249 397 int val = 1 << (i + 3);
Chris@148 398 incrementCombo->addItem(QString("%1").arg(val));
Chris@148 399 if (val == increment) {
Chris@148 400 incrementCombo->setCurrentIndex(i);
Chris@148 401 found = true;
Chris@148 402 }
Chris@148 403 }
Chris@148 404 if (!found) {
Chris@148 405 incrementCombo->addItem(QString("%1").arg(increment));
Chris@148 406 incrementCombo->setCurrentIndex(incrementCombo->count() - 1);
Chris@148 407 }
Chris@282 408 incrementCombo->setValidator(new QIntValidator(1, int(pow(2, 18)), this));
Chris@155 409 connect(incrementCombo, SIGNAL(editTextChanged(const QString &)),
Chris@155 410 this, SLOT(incrementComboChanged(const QString &)));
Chris@148 411 windowLayout->addWidget(incrementCombo, 1, 1);
Chris@148 412
Chris@140 413 if (showFrequencyDomainOptions) {
Chris@140 414
Chris@140 415 windowLayout->addWidget(new QLabel(tr("Window shape:")), 2, 0);
Chris@140 416 WindowTypeSelector *windowTypeSelector = new WindowTypeSelector;
Chris@171 417 connect(windowTypeSelector, SIGNAL(windowTypeChanged(WindowType)),
Chris@171 418 this, SLOT(windowTypeChanged(WindowType)));
Chris@140 419 windowLayout->addWidget(windowTypeSelector, 2, 1);
Chris@140 420 }
Chris@163 421
Chris@163 422 m_windowBox->setVisible(true);
Chris@163 423 m_haveWindowBoxData = true;
Chris@163 424 m_advancedButton->show();
Chris@140 425 }
Chris@140 426
Chris@163 427 setAdvancedVisible(m_advancedVisible);
Chris@62 428 }
Chris@62 429
Chris@69 430 void
Chris@164 431 PluginParameterDialog::setCandidateInputModels(const QStringList &models)
Chris@164 432 {
Chris@164 433 m_inputModels->clear();
Chris@294 434
Chris@294 435 QSettings settings;
Chris@294 436 settings.beginGroup("PluginParameterDialog");
Chris@294 437 QString lastModel = settings.value("lastinputmodel").toString();
Chris@294 438 settings.endGroup();
Chris@294 439
Chris@294 440 m_inputModelList = models;
Chris@294 441 m_inputModels->addItems(TextAbbrev::abbreviate(models, 80));
Chris@296 442 m_inputModels->setCurrentIndex(0);
Chris@294 443
Chris@294 444 if (lastModel != "") {
Chris@294 445 for (int i = 0; i < models.size(); ++i) {
Chris@294 446 if (lastModel == models[i]) {
Chris@294 447 m_inputModels->setCurrentIndex(i);
Chris@296 448 m_currentInputModel = models[i];
Chris@294 449 break;
Chris@294 450 }
Chris@294 451 }
Chris@294 452 }
Chris@294 453
Chris@294 454 connect(m_inputModels, SIGNAL(activated(int)),
Chris@294 455 this, SLOT(inputModelComboChanged(int)));
Chris@164 456 m_inputModelBox->show();
Chris@164 457 }
Chris@164 458
Chris@164 459 QString
Chris@164 460 PluginParameterDialog::getInputModel() const
Chris@164 461 {
Chris@296 462 return m_currentInputModel;
Chris@164 463 }
Chris@164 464
Chris@164 465 void
Chris@145 466 PluginParameterDialog::getProcessingParameters(size_t &blockSize) const
Chris@145 467 {
Chris@145 468 blockSize = m_blockSize;
Chris@145 469 return;
Chris@145 470 }
Chris@145 471
Chris@145 472 void
Chris@145 473 PluginParameterDialog::getProcessingParameters(size_t &stepSize,
Chris@145 474 size_t &blockSize,
Chris@145 475 WindowType &windowType) const
Chris@145 476 {
Chris@145 477 stepSize = m_stepSize;
Chris@145 478 blockSize = m_blockSize;
Chris@145 479 windowType = m_windowType;
Chris@146 480 return;
Chris@145 481 }
Chris@145 482
Chris@145 483 void
Chris@155 484 PluginParameterDialog::blockSizeComboChanged(const QString &text)
Chris@145 485 {
Chris@145 486 m_blockSize = text.toInt();
Chris@146 487 std::cerr << "Block size changed to " << m_blockSize << std::endl;
Chris@145 488 }
Chris@145 489
Chris@145 490 void
Chris@155 491 PluginParameterDialog::incrementComboChanged(const QString &text)
Chris@145 492 {
Chris@145 493 m_stepSize = text.toInt();
Chris@146 494 //!!! rename increment to step size throughout
Chris@147 495 std::cerr << "Increment changed to " << m_stepSize << std::endl;
Chris@145 496 }
Chris@145 497
Chris@145 498 void
Chris@145 499 PluginParameterDialog::windowTypeChanged(WindowType type)
Chris@145 500 {
Chris@145 501 m_windowType = type;
Chris@145 502 }
Chris@145 503
Chris@145 504 void
Chris@143 505 PluginParameterDialog::advancedToggled()
Chris@143 506 {
Chris@163 507 setAdvancedVisible(!m_advancedVisible);
Chris@163 508 }
Chris@143 509
Chris@163 510 void
Chris@163 511 PluginParameterDialog::setAdvancedVisible(bool visible)
Chris@163 512 {
Chris@143 513 m_advanced->setVisible(visible);
Chris@143 514
Chris@163 515 if (visible) {
Chris@163 516 m_advancedButton->setText(tr("Advanced <<"));
Chris@163 517 m_advancedButton->setChecked(true);
Chris@163 518 } else {
Chris@163 519 m_advancedButton->setText(tr("Advanced >>"));
Chris@163 520 m_advancedButton->setChecked(false);
Chris@163 521 }
Chris@143 522
Chris@143 523 QSettings settings;
Chris@143 524 settings.beginGroup("PluginParameterDialog");
Chris@143 525 settings.setValue("advancedvisible", visible);
Chris@143 526 settings.endGroup();
Chris@143 527
Chris@213 528 // std::cerr << "resize to " << sizeHint().width() << " x " << sizeHint().height() << std::endl;
Chris@143 529
Chris@149 530 setMinimumHeight(sizeHint().height());
Chris@163 531 adjustSize();
Chris@163 532
Chris@163 533 m_advancedVisible = visible;
Chris@163 534
Chris@163 535 // if (visible) setMaximumHeight(sizeHint().height());
Chris@163 536 // adjustSize();
Chris@143 537 }
Chris@143 538
Chris@143 539 void
Chris@69 540 PluginParameterDialog::channelComboChanged(int index)
Chris@69 541 {
Chris@69 542 m_channel = index - 1;
Chris@69 543 }
Chris@69 544
Chris@294 545 void
Chris@294 546 PluginParameterDialog::inputModelComboChanged(int index)
Chris@294 547 {
Chris@294 548 if (index >= m_inputModelList.size()) return;
Chris@296 549 m_currentInputModel = m_inputModelList[index];
Chris@296 550 emit inputModelChanged(m_currentInputModel);
Chris@294 551 }
Chris@294 552
Chris@294 553 void
Chris@294 554 PluginParameterDialog::dialogAccepted()
Chris@294 555 {
Chris@294 556 if (!m_inputModels || !m_inputModels->isVisible()) {
Chris@294 557 accept();
Chris@294 558 return;
Chris@294 559 }
Chris@294 560
Chris@294 561 QSettings settings;
Chris@294 562 settings.beginGroup("PluginParameterDialog");
Chris@294 563 settings.setValue("lastinputmodel", getInputModel());
Chris@294 564 settings.endGroup();
Chris@294 565
Chris@294 566 accept();
Chris@294 567 }
Chris@294 568