-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 28 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.h | 2 |
2 files changed, 26 insertions, 4 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 879d0b4..4172da0 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp @@ -56,49 +56,69 @@ namespace const int xo = -2; // movable x offset const int yo = 22; // movable y offset struct MediaButton { bool isToggle, isHeld, isDown; }; //Layout information for the audioButtons (and if it is a toggle button or not) +/* MediaWidget::Button audioButtons[] = { { TRUE, FALSE, FALSE }, // play { FALSE, FALSE, FALSE }, // stop { 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 * const skin_mask_file_names[10] = { "play", "stop", "next", "prev", "up", "down", "loop", "playlist", "forward", "back" }; void changeTextColor( QWidget * w) { QPalette p = w->palette(); p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); w->setPalette( p ); } -const int numButtons = (sizeof(audioButtons)/sizeof(MediaWidget::Button)); +//const int numButtons = (sizeof(audioButtons)/sizeof(MediaWidget::Button)); } AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { + Button defaultButton; + defaultButton.isToggle = defaultButton.isHeld = defaultButton.isDown = false; + Button toggleButton; + toggleButton.isToggle = true; + toggleButton.isHeld = toggleButton.isDown = false; + + audioButtons.reserve( 10 ); + audioButtons.push_back( toggleButton ); // play + audioButtons.push_back( defaultButton ); // stop + audioButtons.push_back( defaultButton ); // next + audioButtons.push_back( defaultButton ); // previous + audioButtons.push_back( defaultButton ); // volume up + audioButtons.push_back( defaultButton ); // volume down + audioButtons.push_back( toggleButton ); // repeat/loop + audioButtons.push_back( defaultButton ); // playlist + audioButtons.push_back( defaultButton ); // forward + audioButtons.push_back( defaultButton ); // back + setCaption( tr("OpiePlayer") ); Config cfg("OpiePlayer"); cfg.setGroup("Options"); skin = cfg.readEntry("Skin","default"); //skin = "scaleTest"; // color of background, frame, degree of transparency @@ -375,17 +395,17 @@ void AudioWidget::timerEvent( QTimerEvent * ) { mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); } else if ( skipDirection == -1 ) { mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); } } void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { - for ( int i = 0; i < numButtons; i++ ) { + for ( unsigned int i = 0; i < audioButtons.size(); i++ ) { if ( event->state() == QMouseEvent::LeftButton ) { // The test to see if the mouse click is inside the button or not int x = event->pos().x() - xoff; int y = event->pos().y() - yoff; bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask.width() && y < imgButtonMask.height() && imgButtonMask.pixelIndex( x, y ) == i + 1 ); @@ -443,23 +463,23 @@ void AudioWidget::showEvent( QShowEvent* ) { void AudioWidget::paintEvent( QPaintEvent * pe ) { if ( !pe->erased() ) { // Combine with background and double buffer QPixmap pix( pe->rect().size() ); QPainter p( &pix ); p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); - for ( int i = 0; i < numButtons; i++ ) + for ( unsigned int i = 0; i < audioButtons.size(); i++ ) paintButton( &p, i ); QPainter p2( this ); p2.drawPixmap( pe->rect().topLeft(), pix ); } else { QPainter p( this ); - for ( int i = 0; i < numButtons; i++ ) + for ( unsigned int i = 0; i < audioButtons.size(); i++ ) paintButton( &p, i ); } } void AudioWidget::keyReleaseEvent( QKeyEvent *e) { switch ( e->key() ) { ////////////////////////////// Zaurus keys case Key_Home: diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h index 52a358c..e09c5f8 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.h +++ b/noncore/multimedia/opieplayer2/audiowidget.h @@ -105,13 +105,15 @@ private: QPixmap *buttonPixDown[10]; QPixmap *pixmaps[4]; OTicker songInfo; QSlider slider; QLineEdit time; int xoff, yoff; bool isStreaming : 1; + + ButtonVector audioButtons; }; #endif // AUDIO_WIDGET_H |