Fix mouse events not changing volume

Using the scroll wheel over the volume slider would not change the
volume, neither would dragging the slider (until released) or clicking
on the slider.

This patch fixes the above.

See: TDE/codeine#5
Signed-off-by: mio <stigma@disroot.org>
(cherry picked from commit 14b52b5a46)
r14.1.x
mio 7 months ago
parent 2ae198284f
commit 673f35da4c

@ -63,7 +63,7 @@ MainWindow::engineStateChanged( Engine::State state )
toggleAction( "play" )->setChecked( state == Playing ); toggleAction( "play" )->setChecked( state == Playing );
//FIXME bad design to do this way //FIXME bad design to do this way
m_volumeAction->sliderMoved( engine()->volume() ); m_volumeAction->setVolume(engine()->volume());
} }

@ -54,9 +54,8 @@ VolumeAction::VolumeAction( TDEToolBar *bar, TDEActionCollection *ac )
m_widget = new VolumeSlider( bar->topLevelWidget() ); m_widget = new VolumeSlider( bar->topLevelWidget() );
connect( this, TQ_SIGNAL(toggled( bool )), TQ_SLOT(toggled( bool )) ); connect( this, TQ_SIGNAL(toggled( bool )), TQ_SLOT(toggled( bool )) );
connect( m_widget->slider, TQ_SIGNAL(sliderMoved( int )), TQ_SLOT(sliderMoved( int )) ); connect(m_widget->slider, TQ_SIGNAL(valueChanged(int)), Codeine::engine(), TQ_SLOT(setStreamParameter(int)));
connect( m_widget->slider, TQ_SIGNAL(sliderMoved( int )), Codeine::engine(), TQ_SLOT(setStreamParameter( int )) ); connect(m_widget->slider, TQ_SIGNAL(valueChanged(int)), TQ_SLOT(sliderMoved(int)));
connect( m_widget->slider, TQ_SIGNAL(sliderReleased()), TQ_SLOT(sliderReleased()) );
} }
int int
@ -75,25 +74,28 @@ VolumeAction::plug( TQWidget *bar, int index )
void void
VolumeAction::toggled( bool const b ) VolumeAction::toggled( bool const b )
{ {
DEBUG_BLOCK
TQString t = TQString::number(100 - m_widget->slider->value()) + "%";
setToolTip( i18n( "Volume: %1" ).arg( t ) );
m_widget->label->setText( t );
m_widget->raise(); m_widget->raise();
m_widget->setShown( b ); m_widget->setShown( b );
} }
void void
VolumeAction::sliderMoved( int v ) VolumeAction::sliderMoved(int v)
{ {
v = 100 - v; //TQt sliders are wrong way round when vertical // TQt sliders are wrong way round when vertical
v = 100 - v;
TQString t = TQString::number( v ) + '%'; auto vol = TQString("%1%").arg(v);
m_widget->label->setText(vol);
setToolTip(i18n("Volume %1").arg(vol));
}
void
VolumeAction::setVolume(int volume)
{
TQString vol = TQString("%1%").arg(volume);
setToolTip( i18n( "Volume: %1" ).arg( t ) ); // TQt sliders are the wrong way round when vertical.
m_widget->label->setText( t ); m_widget->slider->setValue(100 - volume);
} }
bool bool

@ -18,11 +18,12 @@ class VolumeAction : public TDEToggleAction
virtual int plug( TQWidget*, int ); virtual int plug( TQWidget*, int );
public slots: public slots:
void sliderMoved( int ); // Update Slider and Label to \a volume
void setVolume(int volume);
private slots: private slots:
void toggled( bool ); void toggled( bool );
void sliderReleased() { setChecked( false ); toggled( false ); } void sliderMoved(int);
public: public:
VolumeAction( TDEToolBar *anchor, TDEActionCollection *ac ); VolumeAction( TDEToolBar *anchor, TDEActionCollection *ac );

Loading…
Cancel
Save