# HG changeset patch # User Chris Cannam # Date 1173096032 0 # Node ID 21a5e4e7cb92ae58e36b73ffc1b0829cdbbbdff0 # Parent bd2d0346da0e92705a2812acb8ad297282b32373 * Add current value to context help for dials in property boxes, and update the text when the value is changed diff -r bd2d0346da0e -r 21a5e4e7cb92 widgets/PropertyBox.cpp --- a/widgets/PropertyBox.cpp Mon Mar 05 10:53:41 2007 +0000 +++ b/widgets/PropertyBox.cpp Mon Mar 05 12:00:32 2007 +0000 @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -548,6 +549,8 @@ } else if (type != PropertyContainer::InvalidProperty) { m_container->setPropertyWithCommand(name, value); } + + updateContextHelp(obj); } void @@ -562,8 +565,10 @@ void PropertyBox::playGainDialChanged(int dialValue) { + QObject *obj = sender(); float gain = pow(10, float(dialValue) / 20.0); emit changePlayGain(gain); + updateContextHelp(obj); } void @@ -578,10 +583,12 @@ void PropertyBox::playPanDialChanged(int dialValue) { + QObject *obj = sender(); float pan = float(dialValue) / 50.0; if (pan < -1.0) pan = -1.0; if (pan > 1.0) pan = 1.0; emit changePlayPan(pan); + updateContextHelp(obj); } void @@ -639,15 +646,34 @@ void PropertyBox::mouseEnteredWidget() { - QWidget *w = dynamic_cast(sender()); + updateContextHelp(sender()); +} + +void +PropertyBox::updateContextHelp(QObject *o) +{ + QWidget *w = dynamic_cast(o); if (!w) return; - + if (!m_container) return; QString cname = m_container->getPropertyContainerName(); if (cname == "") return; QString wname = w->objectName(); + QString extraText; + AudioDial *dial = dynamic_cast(w); + if (dial) { + float mv = dial->mappedValue(); + QString unit = ""; + if (dial->rangeMapper()) unit = dial->rangeMapper()->getUnit(); + if (unit != "") { + extraText = tr(" (current value: %1%2)").arg(mv).arg(unit); + } else { + extraText = tr(" (current value: %1)").arg(mv); + } + } + if (w == m_showButton) { emit contextHelpChanged(tr("Toggle Visibility of %1").arg(cname)); } else if (w == m_playButton) { @@ -658,15 +684,17 @@ emit contextHelpChanged(tr("Toggle %1 property of %2") .arg(wname).arg(cname)); } else { - emit contextHelpChanged(tr("Adjust %1 property of %2") - .arg(wname).arg(cname)); + emit contextHelpChanged(tr("Adjust %1 property of %2%3") + .arg(wname).arg(cname).arg(extraText)); } } void PropertyBox::mouseLeftWidget() { - emit contextHelpChanged(""); + if (!(QApplication::mouseButtons() & Qt::LeftButton)) { + emit contextHelpChanged(""); + } } diff -r bd2d0346da0e -r 21a5e4e7cb92 widgets/PropertyBox.h --- a/widgets/PropertyBox.h Mon Mar 05 10:53:41 2007 +0000 +++ b/widgets/PropertyBox.h Mon Mar 05 12:00:32 2007 +0000 @@ -72,6 +72,7 @@ protected: void updatePropertyEditor(PropertyContainer::PropertyName, bool rangeChanged = false); + void updateContextHelp(QObject *o); QLabel *m_nameWidget; QWidget *m_mainWidget;