Fixed bug in LED-checkbox

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@16 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2005-10-13 12:29:20 +00:00
parent 315839ff8e
commit 2d0bcc7140
9 changed files with 158 additions and 97 deletions

View File

@@ -43,9 +43,6 @@
#include <qdom.h>
#include <qlabel.h>
#define isChecked isOn
#define setChecked setOn
#endif
@@ -341,10 +338,11 @@ envelopeAndLFOWidget::envelopeAndLFOWidget( float _value_for_zero_amount,
"sin_wave_active" ) );
m_sinLfoBtn->setInactiveGraphic( embed::getIconPixmap(
"sin_wave_inactive" ) );
m_sinLfoBtn->setChecked( TRUE );
#ifdef QT4
m_sinLfoBtn->setChecked( TRUE );
m_sinLfoBtn->setWhatsThis(
#else
m_sinLfoBtn->setOn( TRUE );
QWhatsThis::add( m_sinLfoBtn,
#endif
tr( "Click here if you want a sine-wave for current "
@@ -618,19 +616,35 @@ void envelopeAndLFOWidget::loadSettings( const QDomElement & _this )
switch( m_lfoShape )
{
case SIN:
#ifdef QT4
m_sinLfoBtn->setChecked( TRUE );
#else
m_sinLfoBtn->setOn( TRUE );
#endif
break;
case TRIANGLE:
#ifdef QT4
m_triangleLfoBtn->setChecked( TRUE );
#else
m_triangleLfoBtn->setOn( TRUE );
#endif
break;
case SAW:
#ifdef QT4
m_sawLfoBtn->setChecked( TRUE );
#else
m_sawLfoBtn->setOn( TRUE );
#endif
break;
case SQUARE:
#ifdef QT4
m_sqrLfoBtn->setChecked( TRUE );
#else
m_sqrLfoBtn->setOn( TRUE );
#endif
break;
}

View File

@@ -298,6 +298,7 @@ float knob::getValue( const QPoint & _p )
}
return( new_value );
}
return( ( _p.y() - m_origMousePos.y() ) * m_step );
}
@@ -444,13 +445,29 @@ void knob::mousePressEvent( QMouseEvent * _me )
//! Emits a valueChanged() signal if necessary
void knob::buttonReleased( void )
//! Mouse Move Event handler
void knob::mouseMoveEvent( QMouseEvent * _me )
{
if( ( !m_tracking ) || ( value() != m_prevValue ) )
if( m_scrollMode == ScrMouse )
{
emit valueChanged( value() );
setPosition( _me->pos() );
if( value() != m_prevValue )
{
emit sliderMoved( value() );
if( !configManager::inst()->value( "knobs",
"classicalusability").toInt() )
{
QCursor::setPos( mapToGlobal(
m_origMousePos ) );
}
}
}
songEditor::inst()->setModified();
s_textFloat->setText( m_hintTextBeforeValue +
QString::number( value() ) +
m_hintTextAfterValue );
}
@@ -493,56 +510,6 @@ void knob::mouseReleaseEvent( QMouseEvent * _me )
void knob::setPosition( const QPoint & _p )
{
if( configManager::inst()->value( "knobs", "classicalusability"
).toInt() )
{
setNewValue( getValue( _p ) - m_mouseOffset, 1 );
}
else
{
setNewValue( m_value - getValue( _p ), 1 );
}
}
void knob::setTracking( bool _enable )
{
m_tracking = _enable;
}
//! Mouse Move Event handler
void knob::mouseMoveEvent( QMouseEvent * _me )
{
if( m_scrollMode == ScrMouse )
{
setPosition( _me->pos() );
if( value() != m_prevValue )
{
emit sliderMoved( value() );
}
if( !configManager::inst()->value( "knobs", "classicalusability"
).toInt() )
{
QCursor::setPos( mapToGlobal( m_origMousePos ) );
}
}
songEditor::inst()->setModified();
s_textFloat->setText( m_hintTextBeforeValue +
QString::number( value() ) +
m_hintTextAfterValue );
}
//! Qt wheel event
void knob::wheelEvent( QWheelEvent * _me )
{
@@ -572,6 +539,43 @@ void knob::wheelEvent( QWheelEvent * _me )
//! Emits a valueChanged() signal if necessary
void knob::buttonReleased( void )
{
if( ( !m_tracking ) || ( value() != m_prevValue ) )
{
emit valueChanged( value() );
}
}
void knob::setPosition( const QPoint & _p )
{
if( configManager::inst()->value( "knobs", "classicalusability"
).toInt() )
{
setNewValue( getValue( _p ) - m_mouseOffset, 1 );
}
else
{
setNewValue( m_value - getValue( _p ), 1 );
}
}
void knob::setTracking( bool _enable )
{
m_tracking = _enable;
}
void knob::setValue( float _val, bool _is_init_value )
{
if( _is_init_value )

View File

@@ -53,7 +53,9 @@ static const QString names[ledCheckBox::TOTAL_COLORS] =
ledCheckBox::ledCheckBox( const QString & _text, QWidget * _parent,
ledColors _color ) :
QCheckBox( _text, _parent )
QWidget( _parent ),
m_checked( FALSE ),
m_text( _text )
{
if( _color >= TOTAL_COLORS || _color < YELLOW )
{
@@ -67,7 +69,7 @@ ledCheckBox::ledCheckBox( const QString & _text, QWidget * _parent,
m_ledOffPixmap = new QPixmap( embed::getIconPixmap( "led_off" ) );
#ifndef QT4
setBackgroundMode( Qt::NoBackground );
setBackgroundMode( Qt::PaletteBackground );
#endif
setFont( pointSize<7>( font() ) );
@@ -88,6 +90,38 @@ ledCheckBox::~ledCheckBox()
void ledCheckBox::mousePressEvent( QMouseEvent * _me )
{
if( _me->button() == Qt::LeftButton )
{
toggle();
}
}
void ledCheckBox::toggle( void )
{
m_checked = !m_checked;
update();
emit( toggled( m_checked ) );
}
void ledCheckBox::setChecked( bool _on )
{
if( _on != isChecked() )
{
toggle();
}
}
void ledCheckBox::paintEvent( QPaintEvent * )
{
#ifdef QT4
@@ -118,3 +152,5 @@ void ledCheckBox::paintEvent( QPaintEvent * )
}
#include "led_checkbox.moc"