author | llornkcor <llornkcor> | 2002-08-15 20:23:51 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-08-15 20:23:51 (UTC) |
commit | 645183c07c68dd420b8565d809bfc0340fee0ff3 (patch) (side-by-side diff) | |
tree | 9182788bf3149f8c6c60019018ebf29fb9d6ea17 | |
parent | 8ec3adb6685ea2342024254052e2ba110c6bb88d (diff) | |
download | opie-645183c07c68dd420b8565d809bfc0340fee0ff3.zip opie-645183c07c68dd420b8565d809bfc0340fee0ff3.tar.gz opie-645183c07c68dd420b8565d809bfc0340fee0ff3.tar.bz2 |
new play/pause
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 31 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.h | 6 |
2 files changed, 23 insertions, 14 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 2cb1385..cc6187c 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp @@ -95,29 +95,28 @@ void Ticker::drawContents( QPainter *p ) { struct MediaButton { bool isToggle, isHeld, isDown; }; //Layout information for the audioButtons (and if it is a toggle button or not) MediaButton audioButtons[] = { { TRUE, FALSE, FALSE }, // play { FALSE, FALSE, FALSE }, // stop - { FALSE, FALSE, FALSE }, // pause { FALSE, FALSE, FALSE }, // next { FALSE, FALSE, FALSE }, // previous { FALSE, FALSE, FALSE }, // volume up { FALSE, FALSE, FALSE }, // volume down { TRUE, FALSE, FALSE }, // repeat/loop { FALSE, FALSE, FALSE }, // playlist { FALSE, FALSE, FALSE }, // forward { FALSE, FALSE, FALSE } // back }; -const char *skin_mask_file_names[11] = { - "play", "stop", "pause", "next", "prev", "up", +const char *skin_mask_file_names[10] = { + "play", "stop", "next", "prev", "up", "down", "loop", "playlist", "forward", "back" }; static void changeTextColor( QWidget *w ) { QPalette p = w->palette(); p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); @@ -140,34 +139,34 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : QString skinPath = "opieplayer2/skins/" + skin; pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); imgButtonMask->fill( 0 ); - for ( int i = 0; i < 11; i++ ) { + for ( int i = 0; i < 10; i++ ) { QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; masks[i] = new QBitmap( filename ); if ( !masks[i]->isNull() ) { QImage imgMask = masks[i]->convertToImage(); uchar **dest = imgButtonMask->jumpTable(); for ( int y = 0; y < imgUp->height(); y++ ) { uchar *line = dest[y]; for ( int x = 0; x < imgUp->width(); x++ ) if ( !qRed( imgMask.pixel( x, y ) ) ) line[x] = i + 1; } } } - for ( int i = 0; i < 11; i++ ) { + for ( int i = 0; i < 10; i++ ) { buttonPixUp[i] = NULL; buttonPixDown[i] = NULL; } setBackgroundPixmap( *pixBg ); songInfo.setFocusPolicy( QWidget::NoFocus ); changeTextColor( &songInfo ); @@ -207,25 +206,25 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : setLooping( mediaPlayerState->fullscreen() ); setPaused( mediaPlayerState->paused() ); setPlaying( mediaPlayerState->playing() ); } AudioWidget::~AudioWidget() { - for ( int i = 0; i < 11; i++ ) { + for ( int i = 0; i < 10; i++ ) { delete buttonPixUp[i]; delete buttonPixDown[i]; } delete pixBg; delete imgUp; delete imgDn; delete imgButtonMask; - for ( int i = 0; i < 11; i++ ) { + for ( int i = 0; i < 10; i++ ) { delete masks[i]; } } QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { QPixmap pix( img.width(), img.height() ); QPainter p( &pix ); p.drawTiledPixmap( pix.rect(), bg, offset ); @@ -255,17 +254,17 @@ void AudioWidget::resizeEvent( QResizeEvent * ) { xoff = ( w - imgUp->width() ) / 2; yoff = (( h - imgUp->height() ) / 2) - 10; QPoint p( xoff, yoff ); QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); - for ( int i = 0; i < 11; i++ ) { + for ( int i = 0; i < 10; i++ ) { if ( !masks[i]->isNull() ) { delete buttonPixUp[i]; delete buttonPixDown[i]; buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); } } @@ -422,17 +421,16 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { && imgButtonMask->pixelIndex( x, y ) == i + 1 ); if ( isOnButton && !audioButtons[i].isHeld ) { audioButtons[i].isHeld = TRUE; toggleButton(i); switch (i) { case AudioVolumeUp: - qDebug("more clicked"); emit moreClicked(); return; case AudioVolumeDown: emit lessClicked(); return; case AudioForward: emit forwardClicked(); return; @@ -447,19 +445,30 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { } else { if ( audioButtons[i].isHeld ) { audioButtons[i].isHeld = FALSE; if ( !audioButtons[i].isToggle ) { setToggleButton( i, FALSE ); qDebug("button toggled3 %d",i); } switch (i) { - case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; + case AudioPlay: + if( mediaPlayerState->isPaused ) { + setToggleButton( i, FALSE ); + mediaPlayerState->setPaused( FALSE ); + return; + } else if( !mediaPlayerState->isPaused ) { + setToggleButton( i, TRUE ); + mediaPlayerState->setPaused( TRUE ); + return; + } else { + // setToggleButton( i, TRUE ); + // mediaPlayerState->setPlaying( videoButtons[i].isDown ); + } case AudioStop: mediaPlayerState->setPlaying(FALSE); return; - case AudioPause: mediaPlayerState->setPaused( audioButtons[i].isDown); return; case AudioNext: mediaPlayerState->setNext(); return; case AudioPrevious: mediaPlayerState->setPrev(); return; case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; case AudioVolumeUp: emit moreReleased(); return; case AudioVolumeDown: emit lessReleased(); return; case AudioPlayList: mediaPlayerState->setList(); return; case AudioForward: emit forwardReleased(); return; case AudioBack: emit backReleased(); return; diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h index e05188e..772d1d1 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.h +++ b/noncore/multimedia/opieplayer2/audiowidget.h @@ -128,19 +128,19 @@ private: void setToggleButton( int, bool ); void paintButton( QPainter *p, int i ); int skipDirection; QString skin; QPixmap *pixBg; QImage *imgUp; QImage *imgDn; QImage *imgButtonMask; - QBitmap *masks[11]; - QPixmap *buttonPixUp[11]; - QPixmap *buttonPixDown[11]; + QBitmap *masks[10]; + QPixmap *buttonPixUp[10]; + QPixmap *buttonPixDown[10]; QPixmap *pixmaps[4]; Ticker songInfo; QSlider slider; QLineEdit time; int xoff, yoff; }; |