annotate widgets/PropertyBox.cpp @ 101:0f36cdf407a6 sv1-v0.9rc1

* Make vertical scale alignment modes work in note layer as well as time-value layer, and several significant fixes to it * Make it possible to draw notes properly on the note layer * Show units (and frequencies etc in note layer's case) in the time-value and note layer description boxes * Minor fix to item edit dialog layout * Some minor menu rearrangement * Comment out a lot of debug output * Add SV website and reference URLs to Help menu, and add code to (attempt to) open them in the user's preferred browser
author Chris Cannam
date Fri, 12 May 2006 14:40:43 +0000
parents 0db5e7492ce8
children bf196d6e8998
rev   line source
Chris@58 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@0 2
Chris@0 3 /*
Chris@59 4 Sonic Visualiser
Chris@59 5 An audio file viewer and annotation editor.
Chris@59 6 Centre for Digital Music, Queen Mary, University of London.
Chris@59 7 This file copyright 2006 Chris Cannam.
Chris@0 8
Chris@59 9 This program is free software; you can redistribute it and/or
Chris@59 10 modify it under the terms of the GNU General Public License as
Chris@59 11 published by the Free Software Foundation; either version 2 of the
Chris@59 12 License, or (at your option) any later version. See the file
Chris@59 13 COPYING included with this distribution for more information.
Chris@0 14 */
Chris@0 15
Chris@0 16 #include "PropertyBox.h"
Chris@63 17 #include "PluginParameterDialog.h"
Chris@0 18
Chris@0 19 #include "base/PropertyContainer.h"
Chris@33 20 #include "base/PlayParameters.h"
Chris@33 21 #include "base/Layer.h"
Chris@100 22 #include "base/UnitDatabase.h"
Chris@0 23
Chris@63 24 #include "plugin/RealTimePluginFactory.h"
Chris@63 25 #include "plugin/RealTimePluginInstance.h"
Chris@71 26 #include "plugin/PluginXml.h"
Chris@63 27
Chris@0 28 #include "AudioDial.h"
Chris@33 29 #include "LEDButton.h"
Chris@0 30
Chris@0 31 #include <QGridLayout>
Chris@0 32 #include <QHBoxLayout>
Chris@33 33 #include <QVBoxLayout>
Chris@0 34 #include <QCheckBox>
Chris@0 35 #include <QComboBox>
Chris@63 36 #include <QPushButton>
Chris@0 37 #include <QLabel>
Chris@33 38 #include <QFrame>
Chris@0 39
Chris@0 40 #include <cassert>
Chris@0 41 #include <iostream>
Martin@46 42 #include <cmath>
Chris@0 43
Chris@0 44 //#define DEBUG_PROPERTY_BOX 1
Chris@0 45
Chris@0 46 PropertyBox::PropertyBox(PropertyContainer *container) :
Chris@0 47 m_container(container)
Chris@0 48 {
Chris@0 49 #ifdef DEBUG_PROPERTY_BOX
Chris@0 50 std::cerr << "PropertyBox[" << this << "(\"" <<
Chris@0 51 container->getPropertyContainerName().toStdString() << "\")]::PropertyBox" << std::endl;
Chris@0 52 #endif
Chris@0 53
Chris@34 54 m_mainBox = new QVBoxLayout;
Chris@34 55 setLayout(m_mainBox);
Chris@33 56
Chris@34 57 m_mainWidget = new QWidget;
Chris@34 58 m_mainBox->addWidget(m_mainWidget);
Chris@34 59 m_mainBox->insertStretch(1, 10);
Chris@33 60
Chris@34 61 m_viewPlayFrame = 0;
Chris@34 62 populateViewPlayFrame();
Chris@33 63
Chris@0 64 m_layout = new QGridLayout;
Chris@34 65 m_layout->setMargin(0);
Chris@33 66 m_mainWidget->setLayout(m_layout);
Chris@0 67
Chris@34 68 PropertyContainer::PropertyList properties = m_container->getProperties();
Chris@0 69
Chris@0 70 blockSignals(true);
Chris@0 71
Chris@0 72 size_t i;
Chris@0 73
Chris@0 74 for (i = 0; i < properties.size(); ++i) {
Chris@0 75 updatePropertyEditor(properties[i]);
Chris@0 76 }
Chris@0 77
Chris@0 78 blockSignals(false);
Chris@0 79
Chris@0 80 m_layout->setRowStretch(m_layout->rowCount(), 10);
Chris@0 81
Chris@100 82 connect(UnitDatabase::getInstance(), SIGNAL(unitDatabaseChanged()),
Chris@100 83 this, SLOT(unitDatabaseChanged()));
Chris@100 84
Chris@0 85 #ifdef DEBUG_PROPERTY_BOX
Chris@0 86 std::cerr << "PropertyBox[" << this << "]::PropertyBox returning" << std::endl;
Chris@0 87 #endif
Chris@0 88 }
Chris@0 89
Chris@0 90 PropertyBox::~PropertyBox()
Chris@0 91 {
Chris@0 92 #ifdef DEBUG_PROPERTY_BOX
Chris@33 93 std::cerr << "PropertyBox[" << this << "]::~PropertyBox" << std::endl;
Chris@0 94 #endif
Chris@0 95 }
Chris@0 96
Chris@0 97 void
Chris@34 98 PropertyBox::populateViewPlayFrame()
Chris@33 99 {
Chris@36 100 #ifdef DEBUG_PROPERTY_BOX
Chris@34 101 std::cerr << "PropertyBox(" << m_container << ")::populateViewPlayFrame" << std::endl;
Chris@36 102 #endif
Chris@34 103
Chris@34 104 if (m_viewPlayFrame) {
Chris@34 105 delete m_viewPlayFrame;
Chris@34 106 m_viewPlayFrame = 0;
Chris@34 107 }
Chris@34 108
Chris@34 109 if (!m_container) return;
Chris@34 110
Chris@34 111 Layer *layer = dynamic_cast<Layer *>(m_container);
Chris@34 112 if (layer) {
Chris@34 113 connect(layer, SIGNAL(modelReplaced()),
Chris@34 114 this, SLOT(populateViewPlayFrame()));
Chris@34 115 }
Chris@34 116
Chris@34 117 PlayParameters *params = m_container->getPlayParameters();
Chris@33 118 if (!params && !layer) return;
Chris@33 119
Chris@34 120 m_viewPlayFrame = new QFrame;
Chris@34 121 m_viewPlayFrame->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
Chris@34 122 m_mainBox->addWidget(m_viewPlayFrame);
Chris@34 123
Chris@34 124 QHBoxLayout *layout = new QHBoxLayout;
Chris@34 125 m_viewPlayFrame->setLayout(layout);
Chris@34 126
Chris@34 127 layout->setMargin(layout->margin() / 2);
Chris@34 128
Chris@36 129 #ifdef DEBUG_PROPERTY_BOX
Chris@34 130 std::cerr << "PropertyBox::populateViewPlayFrame: container " << m_container << " (name " << m_container->getPropertyContainerName().toStdString() << ") params " << params << std::endl;
Chris@36 131 #endif
Chris@36 132
Chris@33 133 if (layer) {
Chris@34 134 QLabel *showLabel = new QLabel(tr("Show"));
Chris@34 135 layout->addWidget(showLabel);
Chris@34 136 layout->setAlignment(showLabel, Qt::AlignVCenter);
Chris@34 137
Chris@33 138 LEDButton *showButton = new LEDButton(Qt::blue);
Chris@33 139 layout->addWidget(showButton);
Chris@47 140 connect(showButton, SIGNAL(stateChanged(bool)),
Chris@47 141 this, SIGNAL(showLayer(bool)));
Chris@34 142 layout->setAlignment(showButton, Qt::AlignVCenter);
Chris@33 143 }
Chris@33 144
Chris@33 145 if (params) {
Chris@34 146
Chris@34 147 QLabel *playLabel = new QLabel(tr("Play"));
Chris@34 148 layout->addWidget(playLabel);
Chris@34 149 layout->setAlignment(playLabel, Qt::AlignVCenter);
Chris@34 150
Chris@33 151 LEDButton *playButton = new LEDButton(Qt::darkGreen);
Chris@33 152 layout->addWidget(playButton);
Chris@33 153 connect(playButton, SIGNAL(stateChanged(bool)),
Chris@33 154 params, SLOT(setPlayAudible(bool)));
Chris@34 155 connect(params, SIGNAL(playAudibleChanged(bool)),
Chris@34 156 playButton, SLOT(setState(bool)));
Chris@34 157 layout->setAlignment(playButton, Qt::AlignVCenter);
Chris@34 158
Chris@34 159 layout->insertStretch(-1, 10);
Chris@34 160
Chris@63 161 if (params->getPlayPluginId() != "") {
Chris@64 162 QPushButton *pluginButton = new QPushButton(QIcon(":icons/faders.png"), "");
Chris@64 163 pluginButton->setFixedWidth(24);
Chris@64 164 pluginButton->setFixedHeight(24);
Chris@63 165 layout->addWidget(pluginButton);
Chris@63 166 connect(pluginButton, SIGNAL(clicked()),
Chris@63 167 this, SLOT(editPlugin()));
Chris@63 168 }
Chris@63 169
Chris@34 170 AudioDial *gainDial = new AudioDial;
Chris@34 171 layout->addWidget(gainDial);
Chris@34 172 gainDial->setMeterColor(Qt::darkRed);
Chris@34 173 gainDial->setMinimum(-50);
Chris@34 174 gainDial->setMaximum(50);
Chris@34 175 gainDial->setPageStep(1);
Chris@34 176 gainDial->setFixedWidth(24);
Chris@34 177 gainDial->setFixedHeight(24);
Chris@34 178 gainDial->setNotchesVisible(false);
Chris@57 179 gainDial->setToolTip(tr("Playback Level"));
Chris@34 180 gainDial->setDefaultValue(0);
Chris@34 181 connect(gainDial, SIGNAL(valueChanged(int)),
Chris@34 182 this, SLOT(playGainDialChanged(int)));
Chris@34 183 connect(params, SIGNAL(playGainChanged(float)),
Chris@34 184 this, SLOT(playGainChanged(float)));
Chris@34 185 connect(this, SIGNAL(changePlayGain(float)),
Chris@34 186 params, SLOT(setPlayGain(float)));
Chris@34 187 connect(this, SIGNAL(changePlayGainDial(int)),
Chris@34 188 gainDial, SLOT(setValue(int)));
Chris@34 189 layout->setAlignment(gainDial, Qt::AlignVCenter);
Chris@34 190
Chris@34 191 AudioDial *panDial = new AudioDial;
Chris@34 192 layout->addWidget(panDial);
Chris@34 193 panDial->setMeterColor(Qt::darkGreen);
Chris@34 194 panDial->setMinimum(-50);
Chris@34 195 panDial->setMaximum(50);
Chris@34 196 panDial->setPageStep(1);
Chris@34 197 panDial->setFixedWidth(24);
Chris@34 198 panDial->setFixedHeight(24);
Chris@34 199 panDial->setNotchesVisible(false);
Chris@57 200 panDial->setToolTip(tr("Playback Pan / Balance"));
Chris@34 201 panDial->setDefaultValue(0);
Chris@34 202 connect(panDial, SIGNAL(valueChanged(int)),
Chris@34 203 this, SLOT(playPanDialChanged(int)));
Chris@34 204 connect(params, SIGNAL(playPanChanged(float)),
Chris@34 205 this, SLOT(playPanChanged(float)));
Chris@34 206 connect(this, SIGNAL(changePlayPan(float)),
Chris@34 207 params, SLOT(setPlayPan(float)));
Chris@34 208 connect(this, SIGNAL(changePlayPanDial(int)),
Chris@34 209 panDial, SLOT(setValue(int)));
Chris@34 210 layout->setAlignment(panDial, Qt::AlignVCenter);
Chris@34 211
Chris@34 212 } else {
Chris@34 213
Chris@34 214 layout->insertStretch(-1, 10);
Chris@33 215 }
Chris@33 216 }
Chris@33 217
Chris@33 218 void
Chris@0 219 PropertyBox::updatePropertyEditor(PropertyContainer::PropertyName name)
Chris@0 220 {
Chris@0 221 PropertyContainer::PropertyType type = m_container->getPropertyType(name);
Chris@0 222 int row = m_layout->rowCount();
Chris@0 223
Chris@0 224 int min = 0, max = 0, value = 0;
Chris@0 225 value = m_container->getPropertyRangeAndValue(name, &min, &max);
Chris@0 226
Chris@0 227 bool have = (m_propertyControllers.find(name) !=
Chris@0 228 m_propertyControllers.end());
Chris@0 229
Chris@0 230 QString groupName = m_container->getPropertyGroupName(name);
Chris@87 231 QString propertyLabel = m_container->getPropertyLabel(name);
Chris@0 232
Chris@0 233 #ifdef DEBUG_PROPERTY_BOX
Chris@0 234 std::cerr << "PropertyBox[" << this
Chris@0 235 << "(\"" << m_container->getPropertyContainerName().toStdString()
Chris@0 236 << "\")]";
Chris@0 237 std::cerr << "::updatePropertyEditor(\"" << name.toStdString() << "\"):";
Chris@0 238 std::cerr << " value " << value << ", have " << have << ", group \""
Chris@0 239 << groupName.toStdString() << "\"" << std::endl;
Chris@0 240 #endif
Chris@0 241
Chris@0 242 bool inGroup = (groupName != QString());
Chris@0 243
Chris@0 244 if (!have) {
Chris@0 245 if (inGroup) {
Chris@0 246 if (m_groupLayouts.find(groupName) == m_groupLayouts.end()) {
Chris@0 247 #ifdef DEBUG_PROPERTY_BOX
Chris@0 248 std::cerr << "PropertyBox: adding label \"" << groupName.toStdString() << "\" and frame for group for \"" << name.toStdString() << "\"" << std::endl;
Chris@0 249 #endif
Chris@33 250 m_layout->addWidget(new QLabel(groupName, m_mainWidget), row, 0);
Chris@33 251 QFrame *frame = new QFrame(m_mainWidget);
Chris@0 252 m_layout->addWidget(frame, row, 1, 1, 2);
Chris@0 253 m_groupLayouts[groupName] = new QHBoxLayout;
Chris@0 254 m_groupLayouts[groupName]->setMargin(0);
Chris@0 255 frame->setLayout(m_groupLayouts[groupName]);
Chris@0 256 }
Chris@0 257 } else {
Chris@0 258 #ifdef DEBUG_PROPERTY_BOX
Chris@87 259 std::cerr << "PropertyBox: adding label \"" << propertyLabel.toStdString() << "\"" << std::endl;
Chris@0 260 #endif
Chris@87 261 m_layout->addWidget(new QLabel(propertyLabel, m_mainWidget), row, 0);
Chris@0 262 }
Chris@0 263 }
Chris@0 264
Chris@0 265 switch (type) {
Chris@0 266
Chris@0 267 case PropertyContainer::ToggleProperty:
Chris@0 268 {
Chris@0 269 QCheckBox *cb;
Chris@0 270
Chris@0 271 if (have) {
Chris@0 272 cb = dynamic_cast<QCheckBox *>(m_propertyControllers[name]);
Chris@0 273 assert(cb);
Chris@0 274 } else {
Chris@0 275 #ifdef DEBUG_PROPERTY_BOX
Chris@0 276 std::cerr << "PropertyBox: creating new checkbox" << std::endl;
Chris@0 277 #endif
Chris@0 278 cb = new QCheckBox();
Chris@0 279 cb->setObjectName(name);
Chris@0 280 connect(cb, SIGNAL(stateChanged(int)),
Chris@0 281 this, SLOT(propertyControllerChanged(int)));
Chris@0 282 if (inGroup) {
Chris@0 283 cb->setToolTip(name);
Chris@0 284 m_groupLayouts[groupName]->addWidget(cb);
Chris@0 285 } else {
Chris@0 286 m_layout->addWidget(cb, row, 1, 1, 2);
Chris@0 287 }
Chris@0 288 m_propertyControllers[name] = cb;
Chris@0 289 }
Chris@0 290
Chris@55 291 if (cb->isChecked() != (value > 0)) {
Chris@55 292 cb->blockSignals(true);
Chris@55 293 cb->setChecked(value > 0);
Chris@55 294 cb->blockSignals(false);
Chris@55 295 }
Chris@0 296 break;
Chris@0 297 }
Chris@0 298
Chris@0 299 case PropertyContainer::RangeProperty:
Chris@0 300 {
Chris@0 301 AudioDial *dial;
Chris@0 302
Chris@0 303 if (have) {
Chris@0 304 dial = dynamic_cast<AudioDial *>(m_propertyControllers[name]);
Chris@0 305 assert(dial);
Chris@0 306 } else {
Chris@0 307 #ifdef DEBUG_PROPERTY_BOX
Chris@0 308 std::cerr << "PropertyBox: creating new dial" << std::endl;
Chris@0 309 #endif
Chris@0 310 dial = new AudioDial();
Chris@0 311 dial->setObjectName(name);
Chris@0 312 dial->setMinimum(min);
Chris@0 313 dial->setMaximum(max);
Chris@0 314 dial->setPageStep(1);
Chris@34 315 dial->setNotchesVisible((max - min) <= 12);
Chris@34 316 dial->setDefaultValue(value);
Chris@0 317 connect(dial, SIGNAL(valueChanged(int)),
Chris@0 318 this, SLOT(propertyControllerChanged(int)));
Chris@0 319
Chris@0 320 if (inGroup) {
Chris@0 321 dial->setFixedWidth(24);
Chris@0 322 dial->setFixedHeight(24);
Chris@0 323 dial->setToolTip(name);
Chris@0 324 m_groupLayouts[groupName]->addWidget(dial);
Chris@0 325 } else {
Chris@0 326 dial->setFixedWidth(32);
Chris@0 327 dial->setFixedHeight(32);
Chris@0 328 m_layout->addWidget(dial, row, 1);
Chris@33 329 QLabel *label = new QLabel(m_mainWidget);
Chris@0 330 connect(dial, SIGNAL(valueChanged(int)),
Chris@0 331 label, SLOT(setNum(int)));
Chris@0 332 label->setNum(value);
Chris@0 333 m_layout->addWidget(label, row, 2);
Chris@0 334 }
Chris@0 335
Chris@0 336 m_propertyControllers[name] = dial;
Chris@0 337 }
Chris@0 338
Chris@55 339 if (dial->value() != value) {
Chris@55 340 dial->blockSignals(true);
Chris@55 341 dial->setValue(value);
Chris@55 342 dial->blockSignals(false);
Chris@55 343 }
Chris@0 344 break;
Chris@0 345 }
Chris@0 346
Chris@0 347 case PropertyContainer::ValueProperty:
Chris@100 348 case PropertyContainer::UnitsProperty:
Chris@0 349 {
Chris@0 350 QComboBox *cb;
Chris@0 351
Chris@0 352 if (have) {
Chris@0 353 cb = dynamic_cast<QComboBox *>(m_propertyControllers[name]);
Chris@0 354 assert(cb);
Chris@0 355 } else {
Chris@0 356 #ifdef DEBUG_PROPERTY_BOX
Chris@0 357 std::cerr << "PropertyBox: creating new combobox" << std::endl;
Chris@0 358 #endif
Chris@0 359
Chris@0 360 cb = new QComboBox();
Chris@0 361 cb->setObjectName(name);
Chris@100 362 cb->setDuplicatesEnabled(false);
Chris@100 363
Chris@100 364 if (type == PropertyContainer::ValueProperty) {
Chris@100 365 for (int i = min; i <= max; ++i) {
Chris@100 366 cb->addItem(m_container->getPropertyValueLabel(name, i));
Chris@100 367 }
Chris@100 368 cb->setEditable(false);
Chris@100 369 } else {
Chris@100 370 QStringList units = UnitDatabase::getInstance()->getKnownUnits();
Chris@100 371 for (int i = 0; i < units.size(); ++i) {
Chris@100 372 cb->addItem(units[i]);
Chris@100 373 }
Chris@100 374 cb->setEditable(true);
Chris@100 375 }
Chris@100 376
Chris@0 377 connect(cb, SIGNAL(activated(int)),
Chris@0 378 this, SLOT(propertyControllerChanged(int)));
Chris@100 379
Chris@0 380 if (inGroup) {
Chris@0 381 cb->setToolTip(name);
Chris@0 382 m_groupLayouts[groupName]->addWidget(cb);
Chris@0 383 } else {
Chris@0 384 m_layout->addWidget(cb, row, 1, 1, 2);
Chris@0 385 }
Chris@0 386 m_propertyControllers[name] = cb;
Chris@0 387 }
Chris@0 388
Chris@100 389 cb->blockSignals(true);
Chris@100 390 if (type == PropertyContainer::ValueProperty) {
Chris@100 391 if (cb->currentIndex() != value) {
Chris@100 392 cb->setCurrentIndex(value);
Chris@100 393 }
Chris@100 394 } else {
Chris@100 395 QString unit = UnitDatabase::getInstance()->getUnitById(value);
Chris@100 396 if (cb->currentText() != unit) {
Chris@100 397 for (int i = 0; i < cb->count(); ++i) {
Chris@100 398 if (cb->itemText(i) == unit) {
Chris@100 399 cb->setCurrentIndex(i);
Chris@100 400 break;
Chris@100 401 }
Chris@100 402 }
Chris@100 403 }
Chris@100 404 }
Chris@100 405 cb->blockSignals(false);
Chris@0 406
Chris@0 407 #ifdef Q_WS_MAC
Chris@0 408 // Crashes on startup without this, for some reason
Chris@0 409 cb->setMinimumSize(QSize(10, 10));
Chris@0 410 #endif
Chris@0 411
Chris@0 412 break;
Chris@0 413 }
Chris@0 414
Chris@0 415 default:
Chris@0 416 break;
Chris@0 417 }
Chris@0 418 }
Chris@0 419
Chris@0 420 void
Chris@0 421 PropertyBox::propertyContainerPropertyChanged(PropertyContainer *pc)
Chris@0 422 {
Chris@0 423 if (pc != m_container) return;
Chris@0 424
Chris@55 425 #ifdef DEBUG_PROPERTY_BOX
Chris@55 426 std::cerr << "PropertyBox::propertyContainerPropertyChanged" << std::endl;
Chris@55 427 #endif
Chris@55 428
Chris@0 429 PropertyContainer::PropertyList properties = m_container->getProperties();
Chris@0 430 size_t i;
Chris@0 431
Chris@0 432 blockSignals(true);
Chris@0 433
Chris@0 434 for (i = 0; i < properties.size(); ++i) {
Chris@0 435 updatePropertyEditor(properties[i]);
Chris@0 436 }
Chris@0 437
Chris@0 438 blockSignals(false);
Chris@0 439 }
Chris@0 440
Chris@0 441 void
Chris@100 442 PropertyBox::unitDatabaseChanged()
Chris@100 443 {
Chris@100 444 blockSignals(true);
Chris@100 445
Chris@100 446 PropertyContainer::PropertyList properties = m_container->getProperties();
Chris@100 447 for (size_t i = 0; i < properties.size(); ++i) {
Chris@100 448 updatePropertyEditor(properties[i]);
Chris@100 449 }
Chris@100 450
Chris@100 451 blockSignals(false);
Chris@100 452 }
Chris@100 453
Chris@100 454 void
Chris@0 455 PropertyBox::propertyControllerChanged(int value)
Chris@0 456 {
Chris@0 457 QObject *obj = sender();
Chris@0 458 QString name = obj->objectName();
Chris@0 459
Chris@34 460 #ifdef DEBUG_PROPERTY_BOX
Chris@33 461 std::cerr << "PropertyBox::propertyControllerChanged(" << name.toStdString()
Chris@33 462 << ", " << value << ")" << std::endl;
Chris@34 463 #endif
Chris@0 464
Chris@0 465 PropertyContainer::PropertyType type = m_container->getPropertyType(name);
Chris@100 466
Chris@100 467 if (type == PropertyContainer::UnitsProperty) {
Chris@100 468 QComboBox *cb = dynamic_cast<QComboBox *>(obj);
Chris@100 469 if (cb) {
Chris@100 470 QString unit = cb->currentText();
Chris@100 471 m_container->setPropertyWithCommand
Chris@100 472 (name, UnitDatabase::getInstance()->getUnitId(unit));
Chris@100 473 }
Chris@100 474 } else if (type != PropertyContainer::InvalidProperty) {
Chris@55 475 m_container->setPropertyWithCommand(name, value);
Chris@0 476 }
Chris@0 477
Chris@0 478 if (type == PropertyContainer::RangeProperty) {
Chris@0 479 AudioDial *dial = dynamic_cast<AudioDial *>(m_propertyControllers[name]);
Chris@0 480 if (dial) {
Chris@0 481 dial->setToolTip(QString("%1: %2").arg(name).arg(value));
Chris@0 482 //!!! unfortunately this doesn't update an already-visible tooltip
Chris@0 483 }
Chris@0 484 }
Chris@0 485 }
Chris@0 486
Chris@34 487 void
Chris@34 488 PropertyBox::playGainChanged(float gain)
Chris@34 489 {
Chris@34 490 int dialValue = lrint(log10(gain) * 20.0);
Chris@34 491 if (dialValue < -50) dialValue = -50;
Chris@34 492 if (dialValue > 50) dialValue = 50;
Chris@34 493 emit changePlayGainDial(dialValue);
Chris@34 494 }
Chris@34 495
Chris@34 496 void
Chris@34 497 PropertyBox::playGainDialChanged(int dialValue)
Chris@34 498 {
Chris@34 499 float gain = pow(10, float(dialValue) / 20.0);
Chris@34 500 emit changePlayGain(gain);
Chris@34 501 }
Chris@34 502
Chris@34 503 void
Chris@34 504 PropertyBox::playPanChanged(float pan)
Chris@34 505 {
Chris@34 506 int dialValue = lrint(pan * 50.0);
Chris@34 507 if (dialValue < -50) dialValue = -50;
Chris@34 508 if (dialValue > 50) dialValue = 50;
Chris@34 509 emit changePlayPanDial(dialValue);
Chris@34 510 }
Chris@34 511
Chris@34 512 void
Chris@34 513 PropertyBox::playPanDialChanged(int dialValue)
Chris@34 514 {
Chris@34 515 float pan = float(dialValue) / 50.0;
Chris@34 516 if (pan < -1.0) pan = -1.0;
Chris@34 517 if (pan > 1.0) pan = 1.0;
Chris@34 518 emit changePlayPan(pan);
Chris@34 519 }
Chris@0 520
Chris@63 521 void
Chris@63 522 PropertyBox::editPlugin()
Chris@63 523 {
Chris@63 524 //!!! should probably just emit and let something else do this
Chris@63 525
Chris@63 526 PlayParameters *params = m_container->getPlayParameters();
Chris@63 527 if (!params) return;
Chris@63 528
Chris@63 529 QString pluginId = params->getPlayPluginId();
Chris@63 530 QString configurationXml = params->getPlayPluginConfiguration();
Chris@63 531
Chris@63 532 RealTimePluginFactory *factory =
Chris@63 533 RealTimePluginFactory::instanceFor(pluginId);
Chris@63 534 if (!factory) return;
Chris@63 535
Chris@63 536 RealTimePluginInstance *instance =
Chris@63 537 factory->instantiatePlugin(pluginId, 0, 0, 48000, 1024, 1);
Chris@63 538 if (!instance) return;
Chris@63 539
Chris@71 540 PluginXml(instance).setParametersFromXml(configurationXml);
Chris@63 541
Chris@69 542 PluginParameterDialog *dialog = new PluginParameterDialog(instance, -1, -1, -1);
Chris@64 543 connect(dialog, SIGNAL(pluginConfigurationChanged(QString)),
Chris@64 544 this, SLOT(pluginConfigurationChanged(QString)));
Chris@64 545
Chris@63 546 if (dialog->exec() == QDialog::Accepted) {
Chris@71 547 params->setPlayPluginConfiguration(PluginXml(instance).toXmlString());
Chris@64 548 } else {
Chris@64 549 // restore in case we mucked about with the configuration
Chris@64 550 // as a consequence of signals from the dialog
Chris@64 551 params->setPlayPluginConfiguration(configurationXml);
Chris@63 552 }
Chris@63 553
Chris@63 554 delete dialog;
Chris@63 555 delete instance;
Chris@63 556 }
Chris@63 557
Chris@64 558 void
Chris@64 559 PropertyBox::pluginConfigurationChanged(QString configurationXml)
Chris@64 560 {
Chris@64 561 PlayParameters *params = m_container->getPlayParameters();
Chris@64 562 if (!params) return;
Chris@64 563
Chris@64 564 params->setPlayPluginConfiguration(configurationXml);
Chris@64 565 }
Chris@64 566
Chris@64 567
Chris@64 568
Chris@0 569 #ifdef INCLUDE_MOCFILES
Chris@0 570 #include "PropertyBox.moc.cpp"
Chris@0 571 #endif
Chris@0 572