Mercurial > hg > svgui
comparison widgets/PropertyBox.cpp @ 377:0bcb449d15f4
* Fix #1628781 changes to layer visibility and mute should use a command
* Also use a command for changes to layer playback pan, gain, plugin settings
* Refactor PlayParameterRepository to remove dependency on audioio from base
* Fix failure to save play parameters for main model in session file
author | Chris Cannam |
---|---|
date | Thu, 13 Mar 2008 14:06:03 +0000 |
parents | e1a9e478b7f2 |
children | e2a40fdadd8c |
comparison
equal
deleted
inserted
replaced
376:e1a9e478b7f2 | 377:0bcb449d15f4 |
---|---|
16 #include "PropertyBox.h" | 16 #include "PropertyBox.h" |
17 #include "PluginParameterDialog.h" | 17 #include "PluginParameterDialog.h" |
18 | 18 |
19 #include "base/PropertyContainer.h" | 19 #include "base/PropertyContainer.h" |
20 #include "base/PlayParameters.h" | 20 #include "base/PlayParameters.h" |
21 #include "base/PlayParameterRepository.h" | |
21 #include "layer/Layer.h" | 22 #include "layer/Layer.h" |
22 #include "layer/ColourDatabase.h" | 23 #include "layer/ColourDatabase.h" |
23 #include "base/UnitDatabase.h" | 24 #include "base/UnitDatabase.h" |
24 #include "base/RangeMapper.h" | 25 #include "base/RangeMapper.h" |
25 | 26 |
174 | 175 |
175 m_playButton = new LEDButton(Qt::darkGreen); | 176 m_playButton = new LEDButton(Qt::darkGreen); |
176 m_playButton->setState(!params->isPlayMuted()); | 177 m_playButton->setState(!params->isPlayMuted()); |
177 layout->addWidget(m_playButton); | 178 layout->addWidget(m_playButton); |
178 connect(m_playButton, SIGNAL(stateChanged(bool)), | 179 connect(m_playButton, SIGNAL(stateChanged(bool)), |
179 params, SLOT(setPlayAudible(bool))); | 180 this, SLOT(playAudibleButtonChanged(bool))); |
180 connect(m_playButton, SIGNAL(mouseEntered()), | 181 connect(m_playButton, SIGNAL(mouseEntered()), |
181 this, SLOT(mouseEnteredWidget())); | 182 this, SLOT(mouseEnteredWidget())); |
182 connect(m_playButton, SIGNAL(mouseLeft()), | 183 connect(m_playButton, SIGNAL(mouseLeft()), |
183 this, SLOT(mouseLeftWidget())); | 184 this, SLOT(mouseLeftWidget())); |
184 connect(params, SIGNAL(playAudibleChanged(bool)), | 185 connect(params, SIGNAL(playAudibleChanged(bool)), |
185 m_playButton, SLOT(setState(bool))); | 186 this, SLOT(playAudibleChanged(bool))); |
186 layout->setAlignment(m_playButton, Qt::AlignVCenter); | 187 layout->setAlignment(m_playButton, Qt::AlignVCenter); |
187 | 188 |
188 layout->insertStretch(-1, 10); | 189 layout->insertStretch(-1, 10); |
189 | 190 |
190 if (params->getPlayPluginId() != "") { | 191 if (params->getPlayPluginId() != "") { |
212 gainDial->setShowToolTip(true); | 213 gainDial->setShowToolTip(true); |
213 connect(gainDial, SIGNAL(valueChanged(int)), | 214 connect(gainDial, SIGNAL(valueChanged(int)), |
214 this, SLOT(playGainDialChanged(int))); | 215 this, SLOT(playGainDialChanged(int))); |
215 connect(params, SIGNAL(playGainChanged(float)), | 216 connect(params, SIGNAL(playGainChanged(float)), |
216 this, SLOT(playGainChanged(float))); | 217 this, SLOT(playGainChanged(float))); |
217 connect(this, SIGNAL(changePlayGain(float)), | |
218 params, SLOT(setPlayGain(float))); | |
219 connect(this, SIGNAL(changePlayGainDial(int)), | 218 connect(this, SIGNAL(changePlayGainDial(int)), |
220 gainDial, SLOT(setValue(int))); | 219 gainDial, SLOT(setValue(int))); |
221 connect(gainDial, SIGNAL(mouseEntered()), | 220 connect(gainDial, SIGNAL(mouseEntered()), |
222 this, SLOT(mouseEnteredWidget())); | 221 this, SLOT(mouseEnteredWidget())); |
223 connect(gainDial, SIGNAL(mouseLeft()), | 222 connect(gainDial, SIGNAL(mouseLeft()), |
224 this, SLOT(mouseLeftWidget())); | 223 this, SLOT(mouseLeftWidget())); |
224 playGainChanged(params->getPlayGain()); | |
225 layout->setAlignment(gainDial, Qt::AlignVCenter); | 225 layout->setAlignment(gainDial, Qt::AlignVCenter); |
226 | 226 |
227 AudioDial *panDial = new AudioDial; | 227 AudioDial *panDial = new AudioDial; |
228 layout->addWidget(panDial); | 228 layout->addWidget(panDial); |
229 panDial->setMeterColor(Qt::darkGreen); | 229 panDial->setMeterColor(Qt::darkGreen); |
239 panDial->setShowToolTip(true); | 239 panDial->setShowToolTip(true); |
240 connect(panDial, SIGNAL(valueChanged(int)), | 240 connect(panDial, SIGNAL(valueChanged(int)), |
241 this, SLOT(playPanDialChanged(int))); | 241 this, SLOT(playPanDialChanged(int))); |
242 connect(params, SIGNAL(playPanChanged(float)), | 242 connect(params, SIGNAL(playPanChanged(float)), |
243 this, SLOT(playPanChanged(float))); | 243 this, SLOT(playPanChanged(float))); |
244 connect(this, SIGNAL(changePlayPan(float)), | |
245 params, SLOT(setPlayPan(float))); | |
246 connect(this, SIGNAL(changePlayPanDial(int)), | 244 connect(this, SIGNAL(changePlayPanDial(int)), |
247 panDial, SLOT(setValue(int))); | 245 panDial, SLOT(setValue(int))); |
248 connect(panDial, SIGNAL(mouseEntered()), | 246 connect(panDial, SIGNAL(mouseEntered()), |
249 this, SLOT(mouseEnteredWidget())); | 247 this, SLOT(mouseEnteredWidget())); |
250 connect(panDial, SIGNAL(mouseLeft()), | 248 connect(panDial, SIGNAL(mouseLeft()), |
251 this, SLOT(mouseLeftWidget())); | 249 this, SLOT(mouseLeftWidget())); |
250 playPanChanged(params->getPlayPan()); | |
252 layout->setAlignment(panDial, Qt::AlignVCenter); | 251 layout->setAlignment(panDial, Qt::AlignVCenter); |
253 | 252 |
254 } else { | 253 } else { |
255 | 254 |
256 layout->insertStretch(-1, 10); | 255 layout->insertStretch(-1, 10); |
654 ColourDatabase *db = ColourDatabase::getInstance(); | 653 ColourDatabase *db = ColourDatabase::getInstance(); |
655 int index = db->addColour(newColour, dialog.getColourName()); | 654 int index = db->addColour(newColour, dialog.getColourName()); |
656 db->setUseDarkBackground(index, dialog.isDarkBackgroundChecked()); | 655 db->setUseDarkBackground(index, dialog.isDarkBackgroundChecked()); |
657 } | 656 } |
658 } | 657 } |
658 | |
659 void | |
660 PropertyBox::playAudibleChanged(bool audible) | |
661 { | |
662 m_playButton->setState(audible); | |
663 } | |
664 | |
665 void | |
666 PropertyBox::playAudibleButtonChanged(bool audible) | |
667 { | |
668 PlayParameters *params = m_container->getPlayParameters(); | |
669 if (!params) return; | |
670 | |
671 if (params->isPlayAudible() != audible) { | |
672 PlayParameterRepository::EditCommand *command = | |
673 new PlayParameterRepository::EditCommand(params); | |
674 command->setPlayAudible(audible); | |
675 CommandHistory::getInstance()->addCommand(command, true, true); | |
676 } | |
677 } | |
659 | 678 |
660 void | 679 void |
661 PropertyBox::playGainChanged(float gain) | 680 PropertyBox::playGainChanged(float gain) |
662 { | 681 { |
663 int dialValue = lrint(log10(gain) * 20.0); | 682 int dialValue = lrint(log10(gain) * 20.0); |
668 | 687 |
669 void | 688 void |
670 PropertyBox::playGainDialChanged(int dialValue) | 689 PropertyBox::playGainDialChanged(int dialValue) |
671 { | 690 { |
672 QObject *obj = sender(); | 691 QObject *obj = sender(); |
692 | |
693 PlayParameters *params = m_container->getPlayParameters(); | |
694 if (!params) return; | |
695 | |
673 float gain = pow(10, float(dialValue) / 20.0); | 696 float gain = pow(10, float(dialValue) / 20.0); |
674 emit changePlayGain(gain); | 697 |
698 if (params->getPlayGain() != gain) { | |
699 PlayParameterRepository::EditCommand *command = | |
700 new PlayParameterRepository::EditCommand(params); | |
701 command->setPlayGain(gain); | |
702 CommandHistory::getInstance()->addCommand(command, true, true); | |
703 } | |
704 | |
675 updateContextHelp(obj); | 705 updateContextHelp(obj); |
676 } | 706 } |
677 | 707 |
678 void | 708 void |
679 PropertyBox::playPanChanged(float pan) | 709 PropertyBox::playPanChanged(float pan) |
686 | 716 |
687 void | 717 void |
688 PropertyBox::playPanDialChanged(int dialValue) | 718 PropertyBox::playPanDialChanged(int dialValue) |
689 { | 719 { |
690 QObject *obj = sender(); | 720 QObject *obj = sender(); |
721 | |
722 PlayParameters *params = m_container->getPlayParameters(); | |
723 if (!params) return; | |
724 | |
691 float pan = float(dialValue) / 50.0; | 725 float pan = float(dialValue) / 50.0; |
692 if (pan < -1.0) pan = -1.0; | 726 if (pan < -1.0) pan = -1.0; |
693 if (pan > 1.0) pan = 1.0; | 727 if (pan > 1.0) pan = 1.0; |
694 emit changePlayPan(pan); | 728 |
729 if (params->getPlayPan() != pan) { | |
730 PlayParameterRepository::EditCommand *command = | |
731 new PlayParameterRepository::EditCommand(params); | |
732 command->setPlayPan(pan); | |
733 CommandHistory::getInstance()->addCommand(command, true, true); | |
734 } | |
735 | |
695 updateContextHelp(obj); | 736 updateContextHelp(obj); |
696 } | 737 } |
697 | 738 |
698 void | 739 void |
699 PropertyBox::editPlugin() | 740 PropertyBox::editPlugin() |
703 PlayParameters *params = m_container->getPlayParameters(); | 744 PlayParameters *params = m_container->getPlayParameters(); |
704 if (!params) return; | 745 if (!params) return; |
705 | 746 |
706 QString pluginId = params->getPlayPluginId(); | 747 QString pluginId = params->getPlayPluginId(); |
707 QString configurationXml = params->getPlayPluginConfiguration(); | 748 QString configurationXml = params->getPlayPluginConfiguration(); |
749 | |
750 PlayParameterRepository::EditCommand *command = | |
751 new PlayParameterRepository::EditCommand(params); | |
708 | 752 |
709 RealTimePluginFactory *factory = | 753 RealTimePluginFactory *factory = |
710 RealTimePluginFactory::instanceFor(pluginId); | 754 RealTimePluginFactory::instanceFor(pluginId); |
711 if (!factory) return; | 755 if (!factory) return; |
712 | 756 |
719 PluginParameterDialog *dialog = new PluginParameterDialog(instance); | 763 PluginParameterDialog *dialog = new PluginParameterDialog(instance); |
720 connect(dialog, SIGNAL(pluginConfigurationChanged(QString)), | 764 connect(dialog, SIGNAL(pluginConfigurationChanged(QString)), |
721 this, SLOT(pluginConfigurationChanged(QString))); | 765 this, SLOT(pluginConfigurationChanged(QString))); |
722 | 766 |
723 if (dialog->exec() == QDialog::Accepted) { | 767 if (dialog->exec() == QDialog::Accepted) { |
724 params->setPlayPluginConfiguration(PluginXml(instance).toXmlString()); | 768 QString newConfiguration = PluginXml(instance).toXmlString(); |
769 command->setPlayPluginConfiguration(newConfiguration); | |
770 CommandHistory::getInstance()->addCommand(command, true); | |
725 } else { | 771 } else { |
772 delete command; | |
726 // restore in case we mucked about with the configuration | 773 // restore in case we mucked about with the configuration |
727 // as a consequence of signals from the dialog | 774 // as a consequence of signals from the dialog |
728 params->setPlayPluginConfiguration(configurationXml); | 775 params->setPlayPluginConfiguration(configurationXml); |
729 } | 776 } |
730 | 777 |