comparison widgets/PropertyBox.cpp @ 335:2f83b6e3b8ca

* Add Erase tool and mode * Add icons for Normalize buttons in property boxes, and for Show Peaks * Add support for velocity in notes -- not yet reflected in display or editable in the note edit dialog, but they are imported from MIDI, played, and exported * Begin work on making pastes align pasted times (subtler than I thought)
author Chris Cannam
date Fri, 23 Nov 2007 16:48:23 +0000
parents 3101c68a00c1
children 67834ac56f2b
comparison
equal deleted inserted replaced
334:0a74248af622 335:2f83b6e3b8ca
27 #include "plugin/RealTimePluginInstance.h" 27 #include "plugin/RealTimePluginInstance.h"
28 #include "plugin/PluginXml.h" 28 #include "plugin/PluginXml.h"
29 29
30 #include "AudioDial.h" 30 #include "AudioDial.h"
31 #include "LEDButton.h" 31 #include "LEDButton.h"
32 #include "IconLoader.h"
32 33
33 #include "NotifyingCheckBox.h" 34 #include "NotifyingCheckBox.h"
34 #include "NotifyingComboBox.h" 35 #include "NotifyingComboBox.h"
36 #include "NotifyingPushButton.h"
35 #include "ColourNameDialog.h" 37 #include "ColourNameDialog.h"
36 38
37 #include <QGridLayout> 39 #include <QGridLayout>
38 #include <QHBoxLayout> 40 #include <QHBoxLayout>
39 #include <QVBoxLayout> 41 #include <QVBoxLayout>
268 bool have = (m_propertyControllers.find(name) != 270 bool have = (m_propertyControllers.find(name) !=
269 m_propertyControllers.end()); 271 m_propertyControllers.end());
270 272
271 QString groupName = m_container->getPropertyGroupName(name); 273 QString groupName = m_container->getPropertyGroupName(name);
272 QString propertyLabel = m_container->getPropertyLabel(name); 274 QString propertyLabel = m_container->getPropertyLabel(name);
275 QString iconName = m_container->getPropertyIconName(name);
273 276
274 #ifdef DEBUG_PROPERTY_BOX 277 #ifdef DEBUG_PROPERTY_BOX
275 std::cerr << "PropertyBox[" << this 278 std::cerr << "PropertyBox[" << this
276 << "(\"" << m_container->getPropertyContainerName().toStdString() 279 << "(\"" << m_container->getPropertyContainerName().toStdString()
277 << "\")]"; 280 << "\")]";
305 308
306 switch (type) { 309 switch (type) {
307 310
308 case PropertyContainer::ToggleProperty: 311 case PropertyContainer::ToggleProperty:
309 { 312 {
310 NotifyingCheckBox *cb; 313 QAbstractButton *button = 0;
311 314
312 if (have) { 315 if (have) {
313 cb = dynamic_cast<NotifyingCheckBox *>(m_propertyControllers[name]); 316 button = dynamic_cast<QAbstractButton *>(m_propertyControllers[name]);
314 assert(cb); 317 assert(button);
315 } else { 318 } else {
316 #ifdef DEBUG_PROPERTY_BOX 319 #ifdef DEBUG_PROPERTY_BOX
317 std::cerr << "PropertyBox: creating new checkbox" << std::endl; 320 std::cerr << "PropertyBox: creating new checkbox" << std::endl;
318 #endif 321 #endif
319 cb = new NotifyingCheckBox(); 322 if (iconName != "") {
320 cb->setObjectName(name); 323 button = new NotifyingPushButton();
321 connect(cb, SIGNAL(stateChanged(int)), 324 button->setCheckable(true);
322 this, SLOT(propertyControllerChanged(int))); 325 QIcon icon(IconLoader().load(iconName));
323 connect(cb, SIGNAL(mouseEntered()), 326 button->setIcon(icon);
327 button->setObjectName(name);
328 button->setFixedSize(QSize(18, 18));
329 } else {
330 button = new NotifyingCheckBox();
331 button->setObjectName(name);
332 }
333 connect(button, SIGNAL(toggled(bool)),
334 this, SLOT(propertyControllerChanged(bool)));
335 connect(button, SIGNAL(mouseEntered()),
324 this, SLOT(mouseEnteredWidget())); 336 this, SLOT(mouseEnteredWidget()));
325 connect(cb, SIGNAL(mouseLeft()), 337 connect(button, SIGNAL(mouseLeft()),
326 this, SLOT(mouseLeftWidget())); 338 this, SLOT(mouseLeftWidget()));
327 if (inGroup) { 339 if (inGroup) {
328 cb->setToolTip(propertyLabel); 340 button->setToolTip(propertyLabel);
329 m_groupLayouts[groupName]->addWidget(cb); 341 m_groupLayouts[groupName]->addWidget(button);
330 } else { 342 } else {
331 m_layout->addWidget(cb, row, 1, 1, 2); 343 m_layout->addWidget(button, row, 1, 1, 2);
332 } 344 }
333 m_propertyControllers[name] = cb; 345 m_propertyControllers[name] = button;
334 } 346 }
335 347
336 if (cb->isChecked() != (value > 0)) { 348 if (button->isChecked() != (value > 0)) {
337 cb->blockSignals(true); 349 button->blockSignals(true);
338 cb->setChecked(value > 0); 350 button->setChecked(value > 0);
339 cb->blockSignals(false); 351 button->blockSignals(false);
340 } 352 }
341 break; 353 break;
342 } 354 }
343 355
344 case PropertyContainer::RangeProperty: 356 case PropertyContainer::RangeProperty:
575 587
576 blockSignals(false); 588 blockSignals(false);
577 } 589 }
578 590
579 void 591 void
592 PropertyBox::propertyControllerChanged(bool on)
593 {
594 propertyControllerChanged(on ? 1 : 0);
595 }
596
597 void
580 PropertyBox::propertyControllerChanged(int value) 598 PropertyBox::propertyControllerChanged(int value)
581 { 599 {
582 QObject *obj = sender(); 600 QObject *obj = sender();
583 QString name = obj->objectName(); 601 QString name = obj->objectName();
584 602
760 emit contextHelpChanged(tr("Toggle Visibility of %1").arg(cname)); 778 emit contextHelpChanged(tr("Toggle Visibility of %1").arg(cname));
761 } else if (w == m_playButton) { 779 } else if (w == m_playButton) {
762 emit contextHelpChanged(tr("Toggle Playback of %1").arg(cname)); 780 emit contextHelpChanged(tr("Toggle Playback of %1").arg(cname));
763 } else if (wname == "") { 781 } else if (wname == "") {
764 return; 782 return;
765 } else if (dynamic_cast<NotifyingCheckBox *>(w)) { 783 } else if (dynamic_cast<QAbstractButton *>(w)) {
766 emit contextHelpChanged(tr("Toggle %1 property of %2") 784 emit contextHelpChanged(tr("Toggle %1 property of %2")
767 .arg(wname).arg(cname)); 785 .arg(wname).arg(cname));
768 } else { 786 } else {
769 emit contextHelpChanged(tr("Adjust %1 property of %2%3") 787 emit contextHelpChanged(tr("Adjust %1 property of %2%3")
770 .arg(wname).arg(cname).arg(extraText)); 788 .arg(wname).arg(cname).arg(extraText));