Add tooltips to fxmixer faders

Added tooltips to show the actual value when moving the fader handle.
This works mostly like the same feature we already have for the volume
knobs. Depending on settings the value is shown in a range between
0% to 200% or -inf/-34dBV to 6.02 dBV. Again that's the same as for the
volume knob. Value range could be adjusted easily if necessary.

Closes #3305914.

Signed-off-by: Tobias Doerffel <tobias.doerffel@gmail.com>
This commit is contained in:
Thorsten Müller
2011-06-23 10:14:07 +02:00
committed by Tobias Doerffel
parent 8f9d90df5d
commit ee0f6ccd10
2 changed files with 48 additions and 0 deletions

View File

@@ -53,9 +53,13 @@
#include "embed.h"
#include "engine.h"
#include "caption_menu.h"
#include "config_mgr.h"
#include "text_float.h"
#include "MainWindow.h"
textFloat * fader::s_textFloat = NULL;
fader::fader( FloatModel * _model, const QString & _name, QWidget * _parent ) :
QWidget( _parent ),
@@ -69,6 +73,10 @@ fader::fader( FloatModel * _model, const QString & _name, QWidget * _parent ) :
m_leds( embed::getIconPixmap( "fader_leds" ) ),
m_knob( embed::getIconPixmap( "fader_knob" ) )
{
if( s_textFloat == NULL )
{
s_textFloat = new textFloat;
}
setAccessibleName( _name );
setAttribute( Qt::WA_OpaquePaintEvent, true );
setMinimumSize( 23, 116 );
@@ -105,6 +113,8 @@ void fader::mouseMoveEvent( QMouseEvent *ev )
fVal = fVal + m_model->minValue();
m_model->setValue( fVal );
updateTextFloat();
}
@@ -115,6 +125,9 @@ void fader::mousePressEvent( QMouseEvent * _me )
if( _me->button() == Qt::LeftButton &&
! ( _me->modifiers() & Qt::ControlModifier ) )
{
updateTextFloat();
s_textFloat->show();
mouseMoveEvent( _me );
_me->accept();
}
@@ -126,6 +139,11 @@ void fader::mousePressEvent( QMouseEvent * _me )
void fader::mouseReleaseEvent( QMouseEvent * _me )
{
s_textFloat->hide();
}
void fader::wheelEvent ( QWheelEvent *ev )
{
@@ -139,6 +157,8 @@ void fader::wheelEvent ( QWheelEvent *ev )
{
m_model->incValue( -5 );
}
updateTextFloat();
s_textFloat->setVisibilityTimeOut( 1000 );
}
@@ -182,6 +202,19 @@ void fader::setPeak_R( float fPeak )
}
}
void fader::updateTextFloat()
{
if( configManager::inst()->value( "app", "displaydbv" ).toInt() )
{
s_textFloat->setText( QString("Volume: %1 dBV").
arg( 20.0 * log10( model()->value() ), 3, 'f', 2 ) );
}
else
{
s_textFloat->setText( QString("Volume: %1 %").arg( m_model->value() * 100 ) );
}
s_textFloat->moveGlobal( this, QPoint( width() - m_knob.width() - 5, knob_y() - 46 ) );
}