author | simon <simon> | 2002-12-09 13:40:24 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-09 13:40:24 (UTC) |
commit | d0d993b584bba77905955466897a50cea758103c (patch) (side-by-side diff) | |
tree | fabf38ac7ef2d454a311bd2d264ca1eeab02e2b0 | |
parent | d1324d850a3c8269bd6009de6fdf6c321954b371 (diff) | |
download | opie-d0d993b584bba77905955466897a50cea758103c.zip opie-d0d993b584bba77905955466897a50cea758103c.tar.gz opie-d0d993b584bba77905955466897a50cea758103c.tar.bz2 |
- buttonPixUp/Down are now vectors, too
- removed unused and uninitialized pixmaps array
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 22 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.h | 6 |
2 files changed, 10 insertions, 18 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index fe7ddc1..2081b4f 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp @@ -120,28 +120,26 @@ AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye QImage imgMask = masks[i].convertToImage(); uchar **dest = buttonMask.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 < 10; i++ ) { - buttonPixUp[i] = 0l; - buttonPixDown[i] = 0l; - } + buttonPixUp.resize( masks.size(), QPixmap() ); + buttonPixDown.resize( masks.size(), QPixmap() ); setBackgroundPixmap( pixBg ); songInfo.setFocusPolicy( QWidget::NoFocus ); // changeTextColor( &songInfo ); // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); // songInfo.setFrameStyle( QFrame::NoFrame); songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); // songInfo.setForegroundColor(Qt::white); slider.setFixedHeight( 20 ); slider.setMinValue( 0 ); @@ -171,71 +169,65 @@ AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye // Intialise state setLength( mediaPlayerState.length() ); setPosition( mediaPlayerState.position() ); setLooping( mediaPlayerState.isFullscreen() ); // setPaused( mediaPlayerState->paused() ); setPlaying( mediaPlayerState.isPlaying() ); } AudioWidget::~AudioWidget() { - for ( int i = 0; i < 10; i++ ) { - delete buttonPixUp[i]; - delete buttonPixDown[i]; - } // mediaPlayerState->setPlaying(false); } namespace { QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { QPixmap pix( img.width(), img.height() ); QPainter p( &pix ); p.drawTiledPixmap( pix.rect(), bg, offset ); p.drawImage( 0, 0, img ); return pix; } -QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { - QPixmap *pixmap = new QPixmap( pix ); - pixmap->setMask( mask ); +QPixmap maskPixToMask( QPixmap pix, QBitmap mask ) { + QPixmap pixmap( pix ); + pixmap.setMask( mask ); return pixmap; } }; void AudioWidget::resizeEvent( QResizeEvent * ) { int h = height(); int w = width(); songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); slider.setFixedWidth( w - 110 ); slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); slider.setBackgroundOrigin( QWidget::ParentOrigin ); time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); 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 ( 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] ); } } } void AudioWidget::sliderPressed() { audioSliderBeingMoved = TRUE; } void AudioWidget::sliderReleased() { @@ -323,27 +315,27 @@ void AudioWidget::updateSlider( long i, long max ) { } void AudioWidget::setToggleButton( int i, bool down ) { qDebug("setToggleButton %d", i); if ( down != buttons[i].isDown ) { toggleButton( i ); } } void AudioWidget::paintButton( QPainter &p, int i ) { if ( buttons[i].isDown ) { - p.drawPixmap( upperLeftOfButtonMask, *buttonPixDown[i] ); + p.drawPixmap( upperLeftOfButtonMask, buttonPixDown[i] ); } else { - p.drawPixmap( upperLeftOfButtonMask, *buttonPixUp[i] ); + p.drawPixmap( upperLeftOfButtonMask, buttonPixUp[i] ); } } void AudioWidget::skipFor() { skipDirection = +1; startTimer( 50 ); mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); } void AudioWidget::skipBack() { skipDirection = -1; diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h index bc7262c..73ce1e5 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.h +++ b/noncore/multimedia/opieplayer2/audiowidget.h @@ -83,35 +83,35 @@ protected: void resizeEvent( QResizeEvent *re ); void mouseMoveEvent( QMouseEvent *event ); void mousePressEvent( QMouseEvent *event ); void mouseReleaseEvent( QMouseEvent *event ); void timerEvent( QTimerEvent *event ); void keyReleaseEvent( QKeyEvent *e); private slots: void skipFor(); void skipBack(); void stopSkip(); private: typedef std::vector<QBitmap> MaskVector; + typedef std::vector<QPixmap> PixmapVector; void setToggleButton( int, bool ); virtual void paintButton( QPainter &p, int i ); int skipDirection; QString skin; QPixmap pixBg; QImage imgUp; QImage imgDn; MaskVector masks; - QPixmap *buttonPixUp[10]; - QPixmap *buttonPixDown[10]; + PixmapVector buttonPixUp; + PixmapVector buttonPixDown; - QPixmap *pixmaps[4]; OTicker songInfo; QSlider slider; QLineEdit time; bool isStreaming : 1; bool audioSliderBeingMoved : 1; }; #endif // AUDIO_WIDGET_H |