summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp53
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.h9
2 files changed, 28 insertions, 34 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 5cdfbf2..46d374d 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -74,7 +74,7 @@ MediaButton audioButtons[] = {
74 { FALSE, FALSE, FALSE } // back 74 { FALSE, FALSE, FALSE } // back
75}; 75};
76 76
77const char *skin_mask_file_names[10] = { 77const char * const skin_mask_file_names[10] = {
78 "play", "stop", "next", "prev", "up", 78 "play", "stop", "next", "prev", "up",
79 "down", "loop", "playlist", "forward", "back" 79 "down", "loop", "playlist", "forward", "back"
80}; 80};
@@ -103,12 +103,12 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
103 // color of background, frame, degree of transparency 103 // color of background, frame, degree of transparency
104 104
105 QString skinPath = "opieplayer2/skins/" + skin; 105 QString skinPath = "opieplayer2/skins/" + skin;
106 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 106 pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
107 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); 107 imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
108 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); 108 imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
109 109
110 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); 110 imgButtonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 );
111 imgButtonMask->fill( 0 ); 111 imgButtonMask.fill( 0 );
112 112
113 for ( int i = 0; i < 10; i++ ) { 113 for ( int i = 0; i < 10; i++ ) {
114 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" ); 114 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" );
@@ -116,10 +116,10 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
116 116
117 if ( !masks[i]->isNull() ) { 117 if ( !masks[i]->isNull() ) {
118 QImage imgMask = masks[i]->convertToImage(); 118 QImage imgMask = masks[i]->convertToImage();
119 uchar **dest = imgButtonMask->jumpTable(); 119 uchar **dest = imgButtonMask.jumpTable();
120 for ( int y = 0; y < imgUp->height(); y++ ) { 120 for ( int y = 0; y < imgUp.height(); y++ ) {
121 uchar *line = dest[y]; 121 uchar *line = dest[y];
122 for ( int x = 0; x < imgUp->width(); x++ ) 122 for ( int x = 0; x < imgUp.width(); x++ )
123 if ( !qRed( imgMask.pixel( x, y ) ) ) 123 if ( !qRed( imgMask.pixel( x, y ) ) )
124 line[x] = i + 1; 124 line[x] = i + 1;
125 } 125 }
@@ -132,7 +132,7 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
132 buttonPixDown[i] = 0l; 132 buttonPixDown[i] = 0l;
133 } 133 }
134 134
135 setBackgroundPixmap( *pixBg ); 135 setBackgroundPixmap( pixBg );
136 136
137 songInfo.setFocusPolicy( QWidget::NoFocus ); 137 songInfo.setFocusPolicy( QWidget::NoFocus );
138// changeTextColor( &songInfo ); 138// changeTextColor( &songInfo );
@@ -145,7 +145,7 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
145 slider.setMinValue( 0 ); 145 slider.setMinValue( 0 );
146 slider.setMaxValue( 1 ); 146 slider.setMaxValue( 1 );
147 slider.setFocusPolicy( QWidget::NoFocus ); 147 slider.setFocusPolicy( QWidget::NoFocus );
148 slider.setBackgroundPixmap( *pixBg ); 148 slider.setBackgroundPixmap( pixBg );
149 149
150// Config cofg("qpe"); 150// Config cofg("qpe");
151// cofg.setGroup("Appearance"); 151// cofg.setGroup("Appearance");
@@ -185,10 +185,6 @@ AudioWidget::~AudioWidget() {
185 delete buttonPixUp[i]; 185 delete buttonPixUp[i];
186 delete buttonPixDown[i]; 186 delete buttonPixDown[i];
187 } 187 }
188 delete pixBg;
189 delete imgUp;
190 delete imgDn;
191 delete imgButtonMask;
192 for ( int i = 0; i < 10; i++ ) { 188 for ( int i = 0; i < 10; i++ ) {
193 delete masks[i]; 189 delete masks[i];
194 } 190 }
@@ -197,12 +193,12 @@ AudioWidget::~AudioWidget() {
197 193
198namespace { 194namespace {
199 195
200QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 196QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
201 QPixmap pix( img.width(), img.height() ); 197 QPixmap pix( img.width(), img.height() );
202 QPainter p( &pix ); 198 QPainter p( &pix );
203 p.drawTiledPixmap( pix.rect(), bg, offset ); 199 p.drawTiledPixmap( pix.rect(), bg, offset );
204 p.drawImage( 0, 0, img ); 200 p.drawImage( 0, 0, img );
205 return new QPixmap( pix ); 201 return pix;
206} 202}
207 203
208 204
@@ -224,24 +220,21 @@ void AudioWidget::resizeEvent( QResizeEvent * ) {
224 slider.setBackgroundOrigin( QWidget::ParentOrigin ); 220 slider.setBackgroundOrigin( QWidget::ParentOrigin );
225 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); 221 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
226 222
227 xoff = ( w - imgUp->width() ) / 2; 223 xoff = ( w - imgUp.width() ) / 2;
228 yoff = (( h - imgUp->height() ) / 2) - 10; 224 yoff = (( h - imgUp.height() ) / 2) - 10;
229 QPoint p( xoff, yoff ); 225 QPoint p( xoff, yoff );
230 226
231 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); 227 QPixmap pixUp = combineImageWithBackground( imgUp, pixBg, p );
232 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); 228 QPixmap pixDn = combineImageWithBackground( imgDn, pixBg, p );
233 229
234 for ( int i = 0; i < 10; i++ ) { 230 for ( int i = 0; i < 10; i++ ) {
235 if ( !masks[i]->isNull() ) { 231 if ( !masks[i]->isNull() ) {
236 delete buttonPixUp[i]; 232 delete buttonPixUp[i];
237 delete buttonPixDown[i]; 233 delete buttonPixDown[i];
238 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); 234 buttonPixUp[i] = maskPixToMask( pixUp, *masks[i] );
239 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); 235 buttonPixDown[i] = maskPixToMask( pixDn, *masks[i] );
240 } 236 }
241 } 237 }
242
243 delete pixUp;
244 delete pixDn;
245} 238}
246 239
247static bool audioSliderBeingMoved = FALSE; 240static bool audioSliderBeingMoved = FALSE;
@@ -397,9 +390,9 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
397 int x = event->pos().x() - xoff; 390 int x = event->pos().x() - xoff;
398 int y = event->pos().y() - yoff; 391 int y = event->pos().y() - yoff;
399 392
400 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() 393 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask.width()
401 && y < imgButtonMask->height() 394 && y < imgButtonMask.height()
402 && imgButtonMask->pixelIndex( x, y ) == i + 1 ); 395 && imgButtonMask.pixelIndex( x, y ) == i + 1 );
403 396
404 if ( isOnButton && !audioButtons[i].isHeld ) { 397 if ( isOnButton && !audioButtons[i].isHeld ) {
405 audioButtons[i].isHeld = TRUE; 398 audioButtons[i].isHeld = TRUE;
@@ -481,7 +474,7 @@ void AudioWidget::paintEvent( QPaintEvent * pe ) {
481 QPixmap pix( pe->rect().size() ); 474 QPixmap pix( pe->rect().size() );
482 QPainter p( &pix ); 475 QPainter p( &pix );
483 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 476 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
484 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); 477 p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() );
485 for ( int i = 0; i < numButtons; i++ ) 478 for ( int i = 0; i < numButtons; i++ )
486 paintButton( &p, i ); 479 paintButton( &p, i );
487 QPainter p2( this ); 480 QPainter p2( this );
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h
index 7cb1d79..54adb36 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.h
+++ b/noncore/multimedia/opieplayer2/audiowidget.h
@@ -42,6 +42,7 @@
42#include <qslider.h> 42#include <qslider.h>
43#include <qframe.h> 43#include <qframe.h>
44#include <qlineedit.h> 44#include <qlineedit.h>
45#include <qimage.h>
45 46
46#include <opie/oticker.h> 47#include <opie/oticker.h>
47 48
@@ -113,10 +114,10 @@ private:
113 void paintButton( QPainter *p, int i ); 114 void paintButton( QPainter *p, int i );
114 int skipDirection; 115 int skipDirection;
115 QString skin; 116 QString skin;
116 QPixmap *pixBg; 117 QPixmap pixBg;
117 QImage *imgUp; 118 QImage imgUp;
118 QImage *imgDn; 119 QImage imgDn;
119 QImage *imgButtonMask; 120 QImage imgButtonMask;
120 QBitmap *masks[10]; 121 QBitmap *masks[10];
121 QPixmap *buttonPixUp[10]; 122 QPixmap *buttonPixUp[10];
122 QPixmap *buttonPixDown[10]; 123 QPixmap *buttonPixDown[10];