From 2d0bcc714091430a065a0031cb7f75875cf497da Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Thu, 13 Oct 2005 12:29:20 +0000 Subject: [PATCH] Fixed bug in LED-checkbox git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@16 0778d3d1-df1d-0410-868b-ea421aaaa00d --- AUTHORS | 17 ++-- ChangeLog | 9 +++ Makefile.am | 1 + configure.in | 4 +- include/led_checkbox.h | 46 +++++------ include/mixer.h | 4 +- src/core/envelope_and_lfo_widget.cpp | 22 +++++- src/widgets/knob.cpp | 112 ++++++++++++++------------- src/widgets/led_checkbox.cpp | 40 +++++++++- 9 files changed, 158 insertions(+), 97 deletions(-) diff --git a/AUTHORS b/AUTHORS index 5dd0d2536..9e534b45f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,15 +1,12 @@ Tobias Doerffel - -Maintainer, main-development, artwork etc. + + Maintainer, main-development, artwork etc. -Dany McRae - -development +Danny McRae + + development Sebastian Tilsch - -recording of many samples - - -...may be there're more here in the future... + + recording of many samples diff --git a/ChangeLog b/ChangeLog index c9648619d..e71a8dbc5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2005-10-12 Dany McRae + + * Makefile.am: + * include/led_checkbox.h: + * src/core/envelope_and_lfo_widget.cpp: + * src/widgets/led_checkbox.cpp: + inherit ledCheckBox from QWidget instead of QCheckBox since it sometimes + caused graphic-errors when running on KDE with Baghira-style... + 2005-10-05 Dany McRae * resources/note_double_whole.png: diff --git a/Makefile.am b/Makefile.am index 7d5e83254..6a336da2b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -59,6 +59,7 @@ lmms_MOC = \ ./group_box.moc \ ./knob.moc \ ./lcd_spinbox.moc \ + ./led_checkbox.moc \ ./lmms_main_win.moc \ ./mixer.moc \ ./name_label.moc \ diff --git a/configure.in b/configure.in index 2d3d4f5d5..347cd4ca2 100644 --- a/configure.in +++ b/configure.in @@ -2,8 +2,8 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.50) -AC_INIT(lmms, 0.1.1-cvs20051005, tobydox@users.sourceforge.net) -AM_INIT_AUTOMAKE(lmms, 0.1.1-cvs20051005) +AC_INIT(lmms, 0.1.1-cvs20051012, tobydox@users.sourceforge.net) +AM_INIT_AUTOMAKE(lmms, 0.1.1-cvs20051012) AM_CONFIG_HEADER(config.h) diff --git a/include/led_checkbox.h b/include/led_checkbox.h index 7e2281aac..bb404b429 100644 --- a/include/led_checkbox.h +++ b/include/led_checkbox.h @@ -29,11 +29,11 @@ #ifdef QT4 -#include +#include #else -#include +#include #endif @@ -41,8 +41,9 @@ class QPixmap; -class ledCheckBox : public QCheckBox +class ledCheckBox : public QWidget { + Q_OBJECT public: enum ledColors { @@ -53,37 +54,36 @@ public: ledColors _color = YELLOW ); virtual ~ledCheckBox(); -#ifdef QT4 - inline virtual bool isChecked( void ) const + + inline bool isChecked( void ) const { - return( checkState() == Qt::Checked ); - } -#else - inline virtual bool isOn( void ) const - { - return( state() == On ); - } -#endif -#ifdef QT4 - inline virtual void setChecked( bool _on ) -#else - inline virtual void setOn( bool _on ) -#endif - { - if( _on != isChecked() ) - { - toggle(); - } + return( m_checked ); } + inline const QString & text( void ) + { + return( m_text ); + } + + +public slots: + void toggle( void ); + void setChecked( bool _on ); protected: virtual void paintEvent( QPaintEvent * _pe ); + virtual void mousePressEvent( QMouseEvent * _me ); private: QPixmap * m_ledOnPixmap; QPixmap * m_ledOffPixmap; + + bool m_checked; + QString m_text; + +signals: + void toggled( bool ); } ; diff --git a/include/mixer.h b/include/mixer.h index eceda1ef7..0a2353751 100644 --- a/include/mixer.h +++ b/include/mixer.h @@ -208,12 +208,12 @@ public: } - inline void pause( void ) + void pause( void ) { m_safetySyncMutex.lock(); } - inline void play( void ) + void play( void ) { m_safetySyncMutex.unlock(); } diff --git a/src/core/envelope_and_lfo_widget.cpp b/src/core/envelope_and_lfo_widget.cpp index 05a1d2825..edb66b5aa 100644 --- a/src/core/envelope_and_lfo_widget.cpp +++ b/src/core/envelope_and_lfo_widget.cpp @@ -43,9 +43,6 @@ #include #include -#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; } diff --git a/src/widgets/knob.cpp b/src/widgets/knob.cpp index 3d581cdcc..7fbfb9eb4 100644 --- a/src/widgets/knob.cpp +++ b/src/widgets/knob.cpp @@ -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 ) diff --git a/src/widgets/led_checkbox.cpp b/src/widgets/led_checkbox.cpp index 7f71bff55..f07752cc1 100644 --- a/src/widgets/led_checkbox.cpp +++ b/src/widgets/led_checkbox.cpp @@ -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"