author | simon <simon> | 2002-12-09 14:48:13 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-09 14:48:13 (UTC) |
commit | 9ab8a657b23fd1871c4a376fdd097732c14392e0 (patch) (side-by-side diff) | |
tree | 5e507bf74fad84ae6da1ed1facc689fd89de167d | |
parent | 174c4a427750a3829ffd81a87454be8abf61ee30 (diff) | |
download | opie-9ab8a657b23fd1871c4a376fdd097732c14392e0.zip opie-9ab8a657b23fd1871c4a376fdd097732c14392e0.tar.gz opie-9ab8a657b23fd1871c4a376fdd097732c14392e0.tar.bz2 |
- migrating from a button vector to a button map
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 10 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.h | 4 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 21 |
3 files changed, 18 insertions, 17 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index c148820..12f91a9 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp @@ -115,17 +115,17 @@ AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye 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; } } - buttons.push_back( button ); + buttons.insert( i, button ); } setBackgroundPixmap( pixBg ); songInfo.setFocusPolicy( QWidget::NoFocus ); // changeTextColor( &songInfo ); // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); // songInfo.setFrameStyle( QFrame::NoFrame); @@ -203,17 +203,17 @@ void AudioWidget::resizeEvent( QResizeEvent * ) { upperLeftOfButtonMask.rx() = ( w - imgUp.width() ) / 2; upperLeftOfButtonMask.ry() = (( h - imgUp.height() ) / 2) - 10; QPoint p = upperLeftOfButtonMask; QPixmap pixUp = combineImageWithBackground( imgUp, pixBg, p ); QPixmap pixDn = combineImageWithBackground( imgDn, pixBg, p ); - for ( uint i = 0; i < buttons.size(); i++ ) { + for ( uint i = 0; i < buttons.count(); i++ ) { if ( !buttons[i].mask.isNull() ) { buttons[i].pixUp = maskPixToMask( pixUp, buttons[i].mask ); buttons[i].pixDown = maskPixToMask( pixDn, buttons[i].mask ); } } } void AudioWidget::sliderPressed() { @@ -346,17 +346,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 ( unsigned int i = 0; i < buttons.size(); i++ ) { + for ( unsigned int i = 0; i < buttons.count(); i++ ) { if ( event->state() == QMouseEvent::LeftButton ) { // The test to see if the mouse click is inside the button or not bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); if ( isOnButton && !buttons[i].isHeld ) { buttons[i].isHeld = TRUE; toggleButton(i); switch (i) { @@ -409,23 +409,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 ( unsigned int i = 0; i < buttons.size(); i++ ) + for ( unsigned int i = 0; i < buttons.count(); i++ ) paintButton( p, i ); QPainter p2( this ); p2.drawPixmap( pe->rect().topLeft(), pix ); } else { QPainter p( this ); - for ( unsigned int i = 0; i < buttons.size(); i++ ) + for ( unsigned int i = 0; i < buttons.count(); i++ ) paintButton( p, i ); } } void AudioWidget::keyReleaseEvent( QKeyEvent *e) { switch ( e->key() ) { ////////////////////////////// Zaurus keys case Key_Home: diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h index 504b705..49bf024 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.h +++ b/noncore/multimedia/opieplayer2/mediawidget.h @@ -46,16 +46,18 @@ public: bool isHeld : 1; bool isDown : 1; QBitmap mask; QPixmap pixUp; QPixmap pixDown; }; typedef std::vector<Button> ButtonVector; + // when the transition is done this should be Command -> Button + typedef QMap<int, Button> ButtonMap; struct SkinButtonInfo { Command command; const char *fileName; ButtonType type; }; @@ -86,17 +88,17 @@ protected: void paintButton( int buttonId ); virtual void paintButton( QPainter &p, int i ) = 0; void toggleButton( int buttonId ); MediaPlayerState &mediaPlayerState; PlayListWidget &playList; - ButtonVector buttons; + ButtonMap buttons; QImage buttonMask; QPoint upperLeftOfButtonMask; }; #endif // MEDIAWIDGET_H /* vim: et sw=4 ts=4 diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 380c703..7d85d63 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp @@ -69,24 +69,23 @@ VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) { setCaption( tr("OpiePlayer - Video") ); Button defaultButton; Button toggleButton = defaultButton; toggleButton.type = ToggleButton; - buttons.reserve( 7 ); - buttons.push_back( toggleButton ); // play - buttons.push_back( defaultButton ); // stop - buttons.push_back( defaultButton ); // next - buttons.push_back( defaultButton ); // previous - buttons.push_back( defaultButton ); // volUp - buttons.push_back( defaultButton ); // volDown - buttons.push_back( toggleButton ); //fullscreen + buttons.insert( 0, toggleButton ); // play + buttons.insert( 1, toggleButton ); // stop + buttons.insert( 2, toggleButton ); // next + buttons.insert( 3, toggleButton ); // previous + buttons.insert( 4, toggleButton ); // volUp + buttons.insert( 5, toggleButton ); // volDown + buttons.insert( 6, toggleButton ); // fullscreen videoFrame = new XineVideoWidget ( this, "Video frame" ); connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); Config cfg("OpiePlayer"); cfg.setGroup("Options"); @@ -266,17 +265,17 @@ void VideoWidget::paintButton( QPainter &p, int i ) { if ( buttons[i].isDown ) { p.drawPixmap( upperLeftOfButtonMask, *buttonPixDown[i] ); } else { p.drawPixmap( upperLeftOfButtonMask, *buttonPixUp[i] ); } } void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { - for ( unsigned int i = 0; i < buttons.size(); i++ ) { + for ( unsigned int i = 0; i < buttons.count(); i++ ) { if ( event->state() == QMouseEvent::LeftButton ) { // The test to see if the mouse click is inside the button or not bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); if ( isOnButton && !buttons[i].isHeld ) { buttons[i].isHeld = TRUE; toggleButton(i); @@ -408,24 +407,24 @@ void VideoWidget::paintEvent( QPaintEvent * pe) { p.setBrush( QBrush( Qt::black ) ); } else { 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 ( unsigned int i = 0; i < buttons.size(); i++ ) { + for ( unsigned int i = 0; i < buttons.count(); i++ ) { paintButton( p, i ); } QPainter p2( this ); p2.drawPixmap( pe->rect().topLeft(), pix ); } else { QPainter p( this ); - for ( unsigned int i = 0; i < buttons.size(); i++ ) + for ( unsigned int i = 0; i < buttons.count(); i++ ) paintButton( p, i ); } //slider->repaint( TRUE ); } } void VideoWidget::keyReleaseEvent( QKeyEvent *e) { |