-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 @@ -126,16 +126,14 @@ AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye 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 )); @@ -177,16 +175,12 @@ AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye 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 ) { @@ -195,15 +189,15 @@ QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 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 * ) { @@ -222,14 +216,12 @@ void AudioWidget::resizeEvent( QResizeEvent * ) { 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] ); } } } @@ -329,15 +321,15 @@ void AudioWidget::setToggleButton( int i, bool down ) { 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; 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 @@ -89,25 +89,25 @@ protected: 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; }; |