summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp19
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.h4
2 files changed, 12 insertions, 11 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index adef247..fe7ddc1 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -101,30 +101,32 @@ AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye
skin = cfg.readEntry("Skin","default");
//skin = "scaleTest";
// color of background, frame, degree of transparency
QString skinPath = "opieplayer2/skins/" + skin;
pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 );
buttonMask.fill( 0 );
- for ( int i = 0; i < 10; i++ ) {
+ masks.reserve( 10 );
+
+ for ( uint i = 0; i < masks.capacity(); i++ ) {
QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" );
- masks[i] = new QBitmap( filename );
+ masks.push_back( QBitmap( filename ) );
- if ( !masks[i]->isNull() ) {
- QImage imgMask = masks[i]->convertToImage();
+ if ( !masks[i].isNull() ) {
+ 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++ ) {
@@ -173,27 +175,24 @@ AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye
setLooping( mediaPlayerState.isFullscreen() );
// setPaused( mediaPlayerState->paused() );
setPlaying( mediaPlayerState.isPlaying() );
}
AudioWidget::~AudioWidget() {
for ( int i = 0; i < 10; i++ ) {
delete buttonPixUp[i];
delete buttonPixDown[i];
}
- for ( int i = 0; i < 10; i++ ) {
- delete masks[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;
}
@@ -216,29 +215,29 @@ void AudioWidget::resizeEvent( QResizeEvent * ) {
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() ) {
+ if ( !masks[i].isNull() ) {
delete buttonPixUp[i];
delete buttonPixDown[i];
- buttonPixUp[i] = maskPixToMask( pixUp, *masks[i] );
- buttonPixDown[i] = maskPixToMask( pixDn, *masks[i] );
+ buttonPixUp[i] = maskPixToMask( pixUp, masks[i] );
+ buttonPixDown[i] = maskPixToMask( pixDn, masks[i] );
}
}
}
void AudioWidget::sliderPressed() {
audioSliderBeingMoved = TRUE;
}
void AudioWidget::sliderReleased() {
audioSliderBeingMoved = FALSE;
if ( slider.width() == 0 )
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h
index 8426490..bc7262c 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.h
+++ b/noncore/multimedia/opieplayer2/audiowidget.h
@@ -82,32 +82,34 @@ protected:
void showEvent( QShowEvent *se );
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;
+
void setToggleButton( int, bool );
virtual void paintButton( QPainter &p, int i );
int skipDirection;
QString skin;
QPixmap pixBg;
QImage imgUp;
QImage imgDn;
- QBitmap *masks[10];
+ MaskVector masks;
QPixmap *buttonPixUp[10];
QPixmap *buttonPixDown[10];
QPixmap *pixmaps[4];
OTicker songInfo;
QSlider slider;
QLineEdit time;
bool isStreaming : 1;
bool audioSliderBeingMoved : 1;
};