Mercurial > hg > svgui
changeset 218:21a5e4e7cb92
* Add current value to context help for dials in property boxes, and update
the text when the value is changed
author | Chris Cannam |
---|---|
date | Mon, 05 Mar 2007 12:00:32 +0000 |
parents | bd2d0346da0e |
children | 1fff998ae4a9 |
files | widgets/PropertyBox.cpp widgets/PropertyBox.h |
diffstat | 2 files changed, 34 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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 <QPushButton> #include <QLabel> #include <QFrame> +#include <QApplication> #include <cassert> #include <iostream> @@ -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<QWidget *>(sender()); + updateContextHelp(sender()); +} + +void +PropertyBox::updateContextHelp(QObject *o) +{ + QWidget *w = dynamic_cast<QWidget *>(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<AudioDial *>(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(""); + } }
--- 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;