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
@@ -69,17 +69,17 @@ MediaButton audioButtons[] = {
69 { FALSE, FALSE, FALSE }, // volume up 69 { FALSE, FALSE, FALSE }, // volume up
70 { FALSE, FALSE, FALSE }, // volume down 70 { FALSE, FALSE, FALSE }, // volume down
71 { TRUE, FALSE, FALSE }, // repeat/loop 71 { TRUE, FALSE, FALSE }, // repeat/loop
72 { FALSE, FALSE, FALSE }, // playlist 72 { FALSE, FALSE, FALSE }, // playlist
73 { FALSE, FALSE, FALSE }, // forward 73 { FALSE, FALSE, FALSE }, // forward
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};
81 81
82 82
83static void changeTextColor( QWidget *w ) { 83static void changeTextColor( QWidget *w ) {
84 QPalette p = w->palette(); 84 QPalette p = w->palette();
85 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); 85 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) );
@@ -98,59 +98,59 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
98 98
99 Config cfg("OpiePlayer"); 99 Config cfg("OpiePlayer");
100 cfg.setGroup("Options"); 100 cfg.setGroup("Options");
101 skin = cfg.readEntry("Skin","default"); 101 skin = cfg.readEntry("Skin","default");
102 //skin = "scaleTest"; 102 //skin = "scaleTest";
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" );
115 masks[i] = new QBitmap( filename ); 115 masks[i] = new QBitmap( filename );
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 }
126 } 126 }
127 127
128 } 128 }
129 129
130 for ( int i = 0; i < 10; i++ ) { 130 for ( int i = 0; i < 10; i++ ) {
131 buttonPixUp[i] = 0l; 131 buttonPixUp[i] = 0l;
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 );
139// songInfo.setBackgroundColor( QColor( 167, 212, 167 )); 139// songInfo.setBackgroundColor( QColor( 167, 212, 167 ));
140// songInfo.setFrameStyle( QFrame::NoFrame); 140// songInfo.setFrameStyle( QFrame::NoFrame);
141 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); 141 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
142// songInfo.setForegroundColor(Qt::white); 142// songInfo.setForegroundColor(Qt::white);
143 143
144 slider.setFixedHeight( 20 ); 144 slider.setFixedHeight( 20 );
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");
152// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); 152// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) );
153 153
154 time.setFocusPolicy( QWidget::NoFocus ); 154 time.setFocusPolicy( QWidget::NoFocus );
155 time.setAlignment( Qt::AlignCenter ); 155 time.setAlignment( Qt::AlignCenter );
156 156
@@ -180,34 +180,30 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
180} 180}
181 181
182AudioWidget::~AudioWidget() { 182AudioWidget::~AudioWidget() {
183 183
184 for ( int i = 0; i < 10; i++ ) { 184 for ( int i = 0; i < 10; i++ ) {
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 }
195// mediaPlayerState->setPlaying(false); 191// mediaPlayerState->setPlaying(false);
196} 192}
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
209QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { 205QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) {
210 QPixmap *pixmap = new QPixmap( pix ); 206 QPixmap *pixmap = new QPixmap( pix );
211 pixmap->setMask( mask ); 207 pixmap->setMask( mask );
212 return pixmap; 208 return pixmap;
213} 209}
@@ -219,34 +215,31 @@ void AudioWidget::resizeEvent( QResizeEvent * ) {
219 int w = width(); 215 int w = width();
220 216
221 songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); 217 songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) );
222 slider.setFixedWidth( w - 110 ); 218 slider.setFixedWidth( w - 110 );
223 slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 219 slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
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;
248 241
249 242
250void AudioWidget::sliderPressed() { 243void AudioWidget::sliderPressed() {
251 audioSliderBeingMoved = TRUE; 244 audioSliderBeingMoved = TRUE;
252} 245}
@@ -392,19 +385,19 @@ void AudioWidget::timerEvent( QTimerEvent * ) {
392 385
393void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 386void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
394 for ( int i = 0; i < numButtons; i++ ) { 387 for ( int i = 0; i < numButtons; i++ ) {
395 if ( event->state() == QMouseEvent::LeftButton ) { 388 if ( event->state() == QMouseEvent::LeftButton ) {
396 // The test to see if the mouse click is inside the button or not 389 // The test to see if the mouse click is inside the button or not
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;
406 toggleButton(i); 399 toggleButton(i);
407 switch (i) { 400 switch (i) {
408 case AudioVolumeUp: 401 case AudioVolumeUp:
409 emit moreClicked(); 402 emit moreClicked();
410 return; 403 return;
@@ -476,17 +469,17 @@ void AudioWidget::closeEvent( QCloseEvent* ) {
476 469
477 470
478void AudioWidget::paintEvent( QPaintEvent * pe ) { 471void AudioWidget::paintEvent( QPaintEvent * pe ) {
479 if ( !pe->erased() ) { 472 if ( !pe->erased() ) {
480 // Combine with background and double buffer 473 // Combine with background and double buffer
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 );
488 p2.drawPixmap( pe->rect().topLeft(), pix ); 481 p2.drawPixmap( pe->rect().topLeft(), pix );
489 } else { 482 } else {
490 QPainter p( this ); 483 QPainter p( this );
491 for ( int i = 0; i < numButtons; i++ ) 484 for ( int i = 0; i < numButtons; i++ )
492 paintButton( &p, i ); 485 paintButton( &p, i );
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
@@ -37,16 +37,17 @@
37#include <qwidget.h> 37#include <qwidget.h>
38#include <qpainter.h> 38#include <qpainter.h>
39#include <qdrawutil.h> 39#include <qdrawutil.h>
40#include <qpixmap.h> 40#include <qpixmap.h>
41#include <qstring.h> 41#include <qstring.h>
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
48class QPixmap; 49class QPixmap;
49 50
50namespace { 51namespace {
51 52
52enum AudioButtons { 53enum AudioButtons {
@@ -108,20 +109,20 @@ private slots:
108 void skipBack(); 109 void skipBack();
109 void stopSkip(); 110 void stopSkip();
110private: 111private:
111 void toggleButton( int ); 112 void toggleButton( int );
112 void setToggleButton( int, bool ); 113 void setToggleButton( int, bool );
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];
123 124
124 QPixmap *pixmaps[4]; 125 QPixmap *pixmaps[4];
125 OTicker songInfo; 126 OTicker songInfo;
126 QSlider slider; 127 QSlider slider;
127 QLineEdit time; 128 QLineEdit time;