Mercurial > hg > svgui
comparison widgets/PropertyBox.cpp @ 771:a964151832a7
Merge from branch tony_integration
| author | Chris Cannam |
|---|---|
| date | Wed, 14 May 2014 09:54:34 +0100 |
| parents | 336ccf8fc3f8 |
| children | 037a7c22bec8 |
comparison
equal
deleted
inserted
replaced
| 768:8b614632568c | 771:a964151832a7 |
|---|---|
| 22 #include "layer/Layer.h" | 22 #include "layer/Layer.h" |
| 23 #include "layer/ColourDatabase.h" | 23 #include "layer/ColourDatabase.h" |
| 24 #include "base/UnitDatabase.h" | 24 #include "base/UnitDatabase.h" |
| 25 #include "base/RangeMapper.h" | 25 #include "base/RangeMapper.h" |
| 26 | 26 |
| 27 #include "plugin/RealTimePluginFactory.h" | |
| 28 #include "plugin/RealTimePluginInstance.h" | |
| 29 #include "plugin/PluginXml.h" | |
| 30 | |
| 31 #include "AudioDial.h" | 27 #include "AudioDial.h" |
| 32 #include "LEDButton.h" | 28 #include "LEDButton.h" |
| 33 #include "IconLoader.h" | 29 #include "IconLoader.h" |
| 34 | 30 |
| 35 #include "NotifyingCheckBox.h" | 31 #include "NotifyingCheckBox.h" |
| 44 #include <QLabel> | 40 #include <QLabel> |
| 45 #include <QFrame> | 41 #include <QFrame> |
| 46 #include <QApplication> | 42 #include <QApplication> |
| 47 #include <QColorDialog> | 43 #include <QColorDialog> |
| 48 #include <QInputDialog> | 44 #include <QInputDialog> |
| 45 #include <QDir> | |
| 49 | 46 |
| 50 #include <cassert> | 47 #include <cassert> |
| 51 #include <iostream> | 48 #include <iostream> |
| 52 #include <cmath> | 49 #include <cmath> |
| 53 | 50 |
| 186 this, SLOT(playAudibleChanged(bool))); | 183 this, SLOT(playAudibleChanged(bool))); |
| 187 layout->setAlignment(m_playButton, Qt::AlignVCenter); | 184 layout->setAlignment(m_playButton, Qt::AlignVCenter); |
| 188 | 185 |
| 189 layout->insertStretch(-1, 10); | 186 layout->insertStretch(-1, 10); |
| 190 | 187 |
| 191 if (params->getPlayPluginId() != "") { | 188 if (params->getPlayClipId() != "") { |
| 192 QPushButton *pluginButton = new QPushButton(QIcon(":icons/faders.png"), ""); | 189 QPushButton *playParamButton = |
| 193 pluginButton->setFixedWidth(24); | 190 new QPushButton(QIcon(":icons/faders.png"), ""); |
| 194 pluginButton->setFixedHeight(24); | 191 playParamButton->setFixedWidth(24); |
| 195 layout->addWidget(pluginButton); | 192 playParamButton->setFixedHeight(24); |
| 196 connect(pluginButton, SIGNAL(clicked()), | 193 layout->addWidget(playParamButton); |
| 197 this, SLOT(editPlugin())); | 194 connect(playParamButton, SIGNAL(clicked()), |
| 195 this, SLOT(editPlayParameters())); | |
| 198 } | 196 } |
| 199 | 197 |
| 200 AudioDial *gainDial = new AudioDial; | 198 AudioDial *gainDial = new AudioDial; |
| 201 layout->addWidget(gainDial); | 199 layout->addWidget(gainDial); |
| 202 gainDial->setMeterColor(Qt::darkRed); | 200 gainDial->setMeterColor(Qt::darkRed); |
| 459 | 457 |
| 460 //!!! should be a proper colour combobox class that | 458 //!!! should be a proper colour combobox class that |
| 461 // manages its own Add New Colour entry... | 459 // manages its own Add New Colour entry... |
| 462 | 460 |
| 463 ColourDatabase *db = ColourDatabase::getInstance(); | 461 ColourDatabase *db = ColourDatabase::getInstance(); |
| 464 for (size_t i = 0; i < db->getColourCount(); ++i) { | 462 for (int i = 0; i < db->getColourCount(); ++i) { |
| 465 QString name = db->getColourName(i); | 463 QString name = db->getColourName(i); |
| 466 cb->addItem(db->getExamplePixmap(i, QSize(12, 12)), name); | 464 cb->addItem(db->getExamplePixmap(i, QSize(12, 12)), name); |
| 467 } | 465 } |
| 468 cb->addItem(tr("Add New Colour...")); | 466 cb->addItem(tr("Add New Colour...")); |
| 469 } | 467 } |
| 744 | 742 |
| 745 updateContextHelp(obj); | 743 updateContextHelp(obj); |
| 746 } | 744 } |
| 747 | 745 |
| 748 void | 746 void |
| 749 PropertyBox::editPlugin() | 747 PropertyBox::editPlayParameters() |
| 750 { | 748 { |
| 751 //!!! should probably just emit and let something else do this | |
| 752 | |
| 753 PlayParameters *params = m_container->getPlayParameters(); | 749 PlayParameters *params = m_container->getPlayParameters(); |
| 754 if (!params) return; | 750 if (!params) return; |
| 755 | 751 |
| 756 QString pluginId = params->getPlayPluginId(); | 752 QString clip = params->getPlayClipId(); |
| 757 QString configurationXml = params->getPlayPluginConfiguration(); | |
| 758 | 753 |
| 759 PlayParameterRepository::EditCommand *command = | 754 PlayParameterRepository::EditCommand *command = |
| 760 new PlayParameterRepository::EditCommand(params); | 755 new PlayParameterRepository::EditCommand(params); |
| 761 | 756 |
| 762 RealTimePluginFactory *factory = | 757 QInputDialog *dialog = new QInputDialog(this); |
| 763 RealTimePluginFactory::instanceFor(pluginId); | 758 |
| 764 if (!factory) return; | 759 QDir dir(":/samples"); |
| 765 | 760 QStringList clipFiles = dir.entryList(QStringList() << "*.wav", QDir::Files); |
| 766 RealTimePluginInstance *instance = | 761 |
| 767 factory->instantiatePlugin(pluginId, 0, 0, 48000, 1024, 1); | 762 QStringList clips; |
| 768 if (!instance) return; | 763 foreach (QString str, clipFiles) { |
| 769 | 764 clips.push_back(str.replace(".wav", "")); |
| 770 PluginXml(instance).setParametersFromXml(configurationXml); | 765 } |
| 771 | 766 dialog->setComboBoxItems(clips); |
| 772 PluginParameterDialog *dialog = new PluginParameterDialog(instance); | 767 |
| 773 connect(dialog, SIGNAL(pluginConfigurationChanged(QString)), | 768 dialog->setLabelText(tr("Set playback clip:")); |
| 774 this, SLOT(pluginConfigurationChanged(QString))); | 769 |
| 770 QComboBox *cb = dialog->findChild<QComboBox *>(); | |
| 771 if (cb) cb->setCurrentText(clip); | |
| 772 | |
| 773 connect(dialog, SIGNAL(textValueChanged(QString)), | |
| 774 this, SLOT(playClipChanged(QString))); | |
| 775 | 775 |
| 776 if (dialog->exec() == QDialog::Accepted) { | 776 if (dialog->exec() == QDialog::Accepted) { |
| 777 QString newConfiguration = PluginXml(instance).toXmlString(); | 777 QString newClip = dialog->textValue(); |
| 778 command->setPlayPluginConfiguration(newConfiguration); | 778 command->setPlayClipId(newClip); |
| 779 CommandHistory::getInstance()->addCommand(command, true); | 779 CommandHistory::getInstance()->addCommand(command, true); |
| 780 } else { | 780 } else { |
| 781 delete command; | 781 delete command; |
| 782 // restore in case we mucked about with the configuration | 782 // restore in case we mucked about with the configuration |
| 783 // as a consequence of signals from the dialog | 783 // as a consequence of signals from the dialog |
| 784 params->setPlayPluginConfiguration(configurationXml); | 784 params->setPlayClipId(clip); |
| 785 } | 785 } |
| 786 | 786 |
| 787 delete dialog; | 787 delete dialog; |
| 788 delete instance; | 788 } |
| 789 } | 789 |
| 790 | 790 void |
| 791 void | 791 PropertyBox::playClipChanged(QString id) |
| 792 PropertyBox::pluginConfigurationChanged(QString configurationXml) | |
| 793 { | 792 { |
| 794 PlayParameters *params = m_container->getPlayParameters(); | 793 PlayParameters *params = m_container->getPlayParameters(); |
| 795 if (!params) return; | 794 if (!params) return; |
| 796 | 795 |
| 797 params->setPlayPluginConfiguration(configurationXml); | 796 params->setPlayClipId(id); |
| 798 } | 797 } |
| 799 | 798 |
| 800 void | 799 void |
| 801 PropertyBox::layerVisibilityChanged(bool visible) | 800 PropertyBox::layerVisibilityChanged(bool visible) |
| 802 { | 801 { |
