Mercurial > hg > svgui
diff widgets/PropertyBox.cpp @ 374:64e84e5efb76 spectrogram-cache-rejig
* Merge from trunk
author | Chris Cannam |
---|---|
date | Wed, 27 Feb 2008 11:59:42 +0000 |
parents | 3101c68a00c1 |
children |
line wrap: on
line diff
--- a/widgets/PropertyBox.cpp Mon Nov 19 15:50:37 2007 +0000 +++ b/widgets/PropertyBox.cpp Wed Feb 27 11:59:42 2008 +0000 @@ -29,9 +29,11 @@ #include "AudioDial.h" #include "LEDButton.h" +#include "IconLoader.h" #include "NotifyingCheckBox.h" #include "NotifyingComboBox.h" +#include "NotifyingPushButton.h" #include "ColourNameDialog.h" #include <QGridLayout> @@ -270,6 +272,7 @@ QString groupName = m_container->getPropertyGroupName(name); QString propertyLabel = m_container->getPropertyLabel(name); + QString iconName = m_container->getPropertyIconName(name); #ifdef DEBUG_PROPERTY_BOX std::cerr << "PropertyBox[" << this @@ -307,36 +310,45 @@ case PropertyContainer::ToggleProperty: { - NotifyingCheckBox *cb; + QAbstractButton *button = 0; if (have) { - cb = dynamic_cast<NotifyingCheckBox *>(m_propertyControllers[name]); - assert(cb); + button = dynamic_cast<QAbstractButton *>(m_propertyControllers[name]); + assert(button); } else { #ifdef DEBUG_PROPERTY_BOX std::cerr << "PropertyBox: creating new checkbox" << std::endl; #endif - cb = new NotifyingCheckBox(); - cb->setObjectName(name); - connect(cb, SIGNAL(stateChanged(int)), - this, SLOT(propertyControllerChanged(int))); - connect(cb, SIGNAL(mouseEntered()), + if (iconName != "") { + button = new NotifyingPushButton(); + button->setCheckable(true); + QIcon icon(IconLoader().load(iconName)); + button->setIcon(icon); + button->setObjectName(name); + button->setFixedSize(QSize(18, 18)); + } else { + button = new NotifyingCheckBox(); + button->setObjectName(name); + } + connect(button, SIGNAL(toggled(bool)), + this, SLOT(propertyControllerChanged(bool))); + connect(button, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget())); - connect(cb, SIGNAL(mouseLeft()), + connect(button, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget())); if (inGroup) { - cb->setToolTip(propertyLabel); - m_groupLayouts[groupName]->addWidget(cb); + button->setToolTip(propertyLabel); + m_groupLayouts[groupName]->addWidget(button); } else { - m_layout->addWidget(cb, row, 1, 1, 2); + m_layout->addWidget(button, row, 1, 1, 2); } - m_propertyControllers[name] = cb; + m_propertyControllers[name] = button; } - if (cb->isChecked() != (value > 0)) { - cb->blockSignals(true); - cb->setChecked(value > 0); - cb->blockSignals(false); + if (button->isChecked() != (value > 0)) { + button->blockSignals(true); + button->setChecked(value > 0); + button->blockSignals(false); } break; } @@ -577,6 +589,12 @@ } void +PropertyBox::propertyControllerChanged(bool on) +{ + propertyControllerChanged(on ? 1 : 0); +} + +void PropertyBox::propertyControllerChanged(int value) { QObject *obj = sender(); @@ -624,8 +642,8 @@ if (!newColour.isValid()) return; ColourNameDialog dialog(tr("Name New Colour"), - tr("Enter name for the new colour:"), - newColour, "", this); + tr("Enter a name for the new colour:"), + newColour, newColour.name(), this); dialog.showDarkBackgroundCheckbox(tr("Prefer black background for this colour")); if (dialog.exec() == QDialog::Accepted) { //!!! command @@ -762,7 +780,7 @@ emit contextHelpChanged(tr("Toggle Playback of %1").arg(cname)); } else if (wname == "") { return; - } else if (dynamic_cast<NotifyingCheckBox *>(w)) { + } else if (dynamic_cast<QAbstractButton *>(w)) { emit contextHelpChanged(tr("Toggle %1 property of %2") .arg(wname).arg(cname)); } else {