summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/mediawidget.cpp
Side-by-side diff
Diffstat (limited to 'noncore/multimedia/opieplayer2/mediawidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index 7891a7e..c0ebd63 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -70,63 +70,72 @@ void MediaWidget::paintEvent( QPaintEvent *pe )
}
void MediaWidget::handleCommand( Command command, bool buttonDown )
{
switch ( command ) {
case Play: mediaPlayerState.togglePaused();
case Stop: mediaPlayerState.setPlaying(FALSE); return;
case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return;
case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return;
case Loop: mediaPlayerState.setLooping( buttonDown ); return;
case VolumeUp: emit moreReleased(); return;
case VolumeDown: emit lessReleased(); return;
case PlayList: mediaPlayerState.setList(); return;
case Forward: emit forwardReleased(); return;
case Back: emit backReleased(); return;
default: assert( false );
}
}
bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const
{
return ( position.x() > 0 && position.y() > 0 &&
position.x() < buttonMask.width() &&
position.y() < buttonMask.height() &&
buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 );
}
void MediaWidget::paintAllButtons( QPainter &p )
{
for ( ButtonVector::const_iterator it = buttons.begin();
it != buttons.end(); ++it )
paintButton( p, *it );
}
void MediaWidget::paintButton( const Button &button )
{
QPainter p( this );
paintButton( p, button );
}
void MediaWidget::paintButton( QPainter &p, const Button &button )
{
if ( button.isDown )
p.drawPixmap( upperLeftOfButtonMask, button.pixDown );
else
p.drawPixmap( upperLeftOfButtonMask, button.pixUp );
}
+void MediaWidget::setToggleButton( Command command, bool down )
+{
+ for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it )
+ if ( it->command == command ) {
+ setToggleButton( *it, down );
+ return;
+ }
+}
+
void MediaWidget::setToggleButton( Button &button, bool down )
{
if ( down != button.isDown )
toggleButton( button );
}
void MediaWidget::toggleButton( Button &button )
{
button.isDown = !button.isDown;
paintButton( button );
}
/* vim: et sw=4 ts=4
*/