summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 9f384cc..31687b9 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -1,364 +1,364 @@
1 1
2#include <qpe/qpeapplication.h> 2#include <qpe/qpeapplication.h>
3#include <qpe/resource.h> 3#include <qpe/resource.h>
4#include <qpe/config.h> 4#include <qpe/config.h>
5 5
6#include <qwidget.h> 6#include <qwidget.h>
7#include <qpixmap.h> 7#include <qpixmap.h>
8#include <qbutton.h> 8#include <qbutton.h>
9#include <qpainter.h> 9#include <qpainter.h>
10#include <qframe.h> 10#include <qframe.h>
11#include <qlayout.h> 11#include <qlayout.h>
12 12
13#include <stdlib.h> 13#include <stdlib.h>
14#include <stdio.h> 14#include <stdio.h>
15 15
16#include "audiowidget.h" 16#include "audiowidget.h"
17#include "mediaplayerstate.h" 17#include "mediaplayerstate.h"
18 18
19extern MediaPlayerState *mediaPlayerState; 19extern MediaPlayerState *mediaPlayerState;
20 20
21static const int xo = -2; // movable x offset 21static const int xo = -2; // movable x offset
22static const int yo = 22; // movable y offset 22static const int yo = 22; // movable y offset
23 23
24 24
25Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) { 25Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) {
26 setFrameStyle( WinPanel | Sunken ); 26 setFrameStyle( WinPanel | Sunken );
27 setText( "No Song" ); 27 setText( "No Song" );
28} 28}
29 29
30Ticker::~Ticker() { 30Ticker::~Ticker() {
31} 31}
32 32
33void Ticker::setText( const QString& text ) { 33void Ticker::setText( const QString& text ) {
34 pos = 0; // reset it everytime the text is changed 34 pos = 0; // reset it everytime the text is changed
35 scrollText = text; 35 scrollText = text;
36 pixelLen = fontMetrics().width( scrollText ); 36 pixelLen = fontMetrics().width( scrollText );
37 killTimers(); 37 killTimers();
38 if ( pixelLen > width() ) { 38 if ( pixelLen > width() ) {
39 startTimer( 50 ); 39 startTimer( 50 );
40 } 40 }
41 update(); 41 update();
42} 42}
43 43
44 44
45void Ticker::timerEvent( QTimerEvent * ) { 45void Ticker::timerEvent( QTimerEvent * ) {
46 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; 46 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1;
47 scroll( -1, 0, contentsRect() ); 47 scroll( -1, 0, contentsRect() );
48 repaint( FALSE ); 48 repaint( FALSE );
49} 49}
50 50
51void Ticker::drawContents( QPainter *p ) { 51void Ticker::drawContents( QPainter *p ) {
52 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) 52 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen )
53 p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); 53 p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
54 QPixmap pm( width(), height() ); 54 QPixmap pm( width(), height() );
55 pm.fill( colorGroup().base() ); 55 pm.fill( colorGroup().base() );
56 QPainter pmp( &pm ); 56 QPainter pmp( &pm );
57 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { 57 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) {
58 pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); 58 pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
59 } 59 }
60 p->drawPixmap( 0, 0, pm ); 60 p->drawPixmap( 0, 0, pm );
61} 61}
62 62
63struct MediaButton { 63struct MediaButton {
64 bool isToggle, isHeld, isDown; 64 bool isToggle, isHeld, isDown;
65}; 65};
66 66
67//Layout information for the audioButtons (and if it is a toggle button or not) 67//Layout information for the audioButtons (and if it is a toggle button or not)
68MediaButton audioButtons[] = { 68MediaButton audioButtons[] = {
69 { TRUE, FALSE, FALSE }, // play 69 { TRUE, FALSE, FALSE }, // play
70 { FALSE, FALSE, FALSE }, // stop 70 { FALSE, FALSE, FALSE }, // stop
71 { TRUE, FALSE, FALSE }, // pause 71 { TRUE, FALSE, FALSE }, // pause
72 { FALSE, FALSE, FALSE }, // next 72 { FALSE, FALSE, FALSE }, // next
73 { FALSE, FALSE, FALSE }, // previous 73 { FALSE, FALSE, FALSE }, // previous
74 { FALSE, FALSE, FALSE }, // volume up 74 { FALSE, FALSE, FALSE }, // volume up
75 { FALSE, FALSE, FALSE }, // volume down 75 { FALSE, FALSE, FALSE }, // volume down
76 { TRUE, FALSE, FALSE }, // repeat/loop 76 { TRUE, FALSE, FALSE }, // repeat/loop
77 { FALSE, FALSE, FALSE }, // playlist 77 { FALSE, FALSE, FALSE }, // playlist
78 { FALSE, FALSE, FALSE }, // forward 78 { FALSE, FALSE, FALSE }, // forward
79 { FALSE, FALSE, FALSE } // back 79 { FALSE, FALSE, FALSE } // back
80}; 80};
81 81
82const char *skin_mask_file_names[11] = { 82const char *skin_mask_file_names[11] = {
83 "play", "stop", "pause", "next", "prev", "up", 83 "play", "stop", "pause", "next", "prev", "up",
84 "down", "loop", "playlist", "forward", "back" 84 "down", "loop", "playlist", "forward", "back"
85}; 85};
86 86
87 87
88static void changeTextColor( QWidget *w ) { 88static void changeTextColor( QWidget *w ) {
89 QPalette p = w->palette(); 89 QPalette p = w->palette();
90 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); 90 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) );
91 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); 91 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) );
92 w->setPalette( p ); 92 w->setPalette( p );
93} 93}
94 94
95static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); 95static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
96 96
97 97
98AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : 98AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
99 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) 99 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this )
100 setCaption( tr("OpiePlayer") ); 100 setCaption( tr("OpiePlayer") );
101 101
102 Config cfg("OpiePlayer"); 102 Config cfg("OpiePlayer");
103 cfg.setGroup("AudioWidget"); 103 cfg.setGroup("AudioWidget");
104 skin = cfg.readEntry("Skin","default"); 104 skin = cfg.readEntry("Skin","default");
105 //skin = "scaleTest"; 105 //skin = "scaleTest";
106// color of background, frame, degree of transparency 106// color of background, frame, degree of transparency
107 107
108 QString skinPath = "mediaplayer/skins/" + skin; 108 QString skinPath = "opieplayer/skins/" + skin;
109 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 109 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
110 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); 110 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
111 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); 111 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
112 112
113 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); 113 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
114 imgButtonMask->fill( 0 ); 114 imgButtonMask->fill( 0 );
115 115
116 for ( int i = 0; i < 11; i++ ) { 116 for ( int i = 0; i < 11; i++ ) {
117 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; 117 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png";
118 masks[i] = new QBitmap( filename ); 118 masks[i] = new QBitmap( filename );
119 119
120 if ( !masks[i]->isNull() ) { 120 if ( !masks[i]->isNull() ) {
121 QImage imgMask = masks[i]->convertToImage(); 121 QImage imgMask = masks[i]->convertToImage();
122 uchar **dest = imgButtonMask->jumpTable(); 122 uchar **dest = imgButtonMask->jumpTable();
123 for ( int y = 0; y < imgUp->height(); y++ ) { 123 for ( int y = 0; y < imgUp->height(); y++ ) {
124 uchar *line = dest[y]; 124 uchar *line = dest[y];
125 for ( int x = 0; x < imgUp->width(); x++ ) 125 for ( int x = 0; x < imgUp->width(); x++ )
126 if ( !qRed( imgMask.pixel( x, y ) ) ) 126 if ( !qRed( imgMask.pixel( x, y ) ) )
127 line[x] = i + 1; 127 line[x] = i + 1;
128 } 128 }
129 } 129 }
130 130
131 } 131 }
132 132
133 for ( int i = 0; i < 11; i++ ) { 133 for ( int i = 0; i < 11; i++ ) {
134 buttonPixUp[i] = NULL; 134 buttonPixUp[i] = NULL;
135 buttonPixDown[i] = NULL; 135 buttonPixDown[i] = NULL;
136 } 136 }
137 137
138 setBackgroundPixmap( *pixBg ); 138 setBackgroundPixmap( *pixBg );
139 139
140 songInfo.setFocusPolicy( QWidget::NoFocus ); 140 songInfo.setFocusPolicy( QWidget::NoFocus );
141 changeTextColor( &songInfo ); 141 changeTextColor( &songInfo );
142 142
143 slider.setFixedHeight( 20 ); 143 slider.setFixedHeight( 20 );
144 slider.setMinValue( 0 ); 144 slider.setMinValue( 0 );
145 slider.setMaxValue( 1 ); 145 slider.setMaxValue( 1 );
146 slider.setFocusPolicy( QWidget::NoFocus ); 146 slider.setFocusPolicy( QWidget::NoFocus );
147 slider.setBackgroundPixmap( *pixBg ); 147 slider.setBackgroundPixmap( *pixBg );
148 148
149 time.setFocusPolicy( QWidget::NoFocus ); 149 time.setFocusPolicy( QWidget::NoFocus );
150 time.setAlignment( Qt::AlignCenter ); 150 time.setAlignment( Qt::AlignCenter );
151 time.setFrame(FALSE); 151 time.setFrame(FALSE);
152 changeTextColor( &time ); 152 changeTextColor( &time );
153 153
154 resizeEvent( NULL ); 154 resizeEvent( NULL );
155 155
156 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 156 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
157 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 157 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
158 158
159 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 159 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
160 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 160 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
161 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 161 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
162 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 162 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
163 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 163 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
164 164
165 // Intialise state 165 // Intialise state
166 setLength( mediaPlayerState->length() ); 166 setLength( mediaPlayerState->length() );
167 setPosition( mediaPlayerState->position() ); 167 setPosition( mediaPlayerState->position() );
168 setLooping( mediaPlayerState->fullscreen() ); 168 setLooping( mediaPlayerState->fullscreen() );
169 setPaused( mediaPlayerState->paused() ); 169 setPaused( mediaPlayerState->paused() );
170 setPlaying( mediaPlayerState->playing() ); 170 setPlaying( mediaPlayerState->playing() );
171 171
172} 172}
173 173
174AudioWidget::~AudioWidget() { 174AudioWidget::~AudioWidget() {
175 175
176 for ( int i = 0; i < 11; i++ ) { 176 for ( int i = 0; i < 11; i++ ) {
177 delete buttonPixUp[i]; 177 delete buttonPixUp[i];
178 delete buttonPixDown[i]; 178 delete buttonPixDown[i];
179 } 179 }
180 delete pixBg; 180 delete pixBg;
181 delete imgUp; 181 delete imgUp;
182 delete imgDn; 182 delete imgDn;
183 delete imgButtonMask; 183 delete imgButtonMask;
184 for ( int i = 0; i < 11; i++ ) { 184 for ( int i = 0; i < 11; i++ ) {
185 delete masks[i]; 185 delete masks[i];
186 } 186 }
187} 187}
188 188
189QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 189QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
190 QPixmap pix( img.width(), img.height() ); 190 QPixmap pix( img.width(), img.height() );
191 QPainter p( &pix ); 191 QPainter p( &pix );
192 p.drawTiledPixmap( pix.rect(), bg, offset ); 192 p.drawTiledPixmap( pix.rect(), bg, offset );
193 p.drawImage( 0, 0, img ); 193 p.drawImage( 0, 0, img );
194 return new QPixmap( pix ); 194 return new QPixmap( pix );
195} 195}
196 196
197 197
198QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) 198QPixmap *maskPixToMask( QPixmap pix, QBitmap mask )
199{ 199{
200 QPixmap *pixmap = new QPixmap( pix ); 200 QPixmap *pixmap = new QPixmap( pix );
201 pixmap->setMask( mask ); 201 pixmap->setMask( mask );
202 return pixmap; 202 return pixmap;
203} 203}
204 204
205 205
206 206
207void AudioWidget::resizeEvent( QResizeEvent * ) { 207void AudioWidget::resizeEvent( QResizeEvent * ) {
208 int h = height(); 208 int h = height();
209 int w = width(); 209 int w = width();
210 210
211 songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); 211 songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) );
212 slider.setFixedWidth( w - 110 ); 212 slider.setFixedWidth( w - 110 );
213 slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); 213 slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) );
214 slider.setBackgroundOrigin( QWidget::ParentOrigin ); 214 slider.setBackgroundOrigin( QWidget::ParentOrigin );
215 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); 215 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
216 216
217 xoff = ( w - imgUp->width() ) / 2; 217 xoff = ( w - imgUp->width() ) / 2;
218 yoff = (( h - imgUp->height() ) / 2) - 10; 218 yoff = (( h - imgUp->height() ) / 2) - 10;
219 QPoint p( xoff, yoff ); 219 QPoint p( xoff, yoff );
220 220
221 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); 221 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p );
222 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); 222 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p );
223 223
224 for ( int i = 0; i < 11; i++ ) { 224 for ( int i = 0; i < 11; i++ ) {
225 if ( !masks[i]->isNull() ) { 225 if ( !masks[i]->isNull() ) {
226 delete buttonPixUp[i]; 226 delete buttonPixUp[i];
227 delete buttonPixDown[i]; 227 delete buttonPixDown[i];
228 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); 228 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] );
229 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); 229 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] );
230 } 230 }
231 } 231 }
232 232
233 delete pixUp; 233 delete pixUp;
234 delete pixDn; 234 delete pixDn;
235} 235}
236 236
237static bool audioSliderBeingMoved = FALSE; 237static bool audioSliderBeingMoved = FALSE;
238 238
239 239
240void AudioWidget::sliderPressed() { 240void AudioWidget::sliderPressed() {
241 audioSliderBeingMoved = TRUE; 241 audioSliderBeingMoved = TRUE;
242} 242}
243 243
244 244
245void AudioWidget::sliderReleased() { 245void AudioWidget::sliderReleased() {
246 audioSliderBeingMoved = FALSE; 246 audioSliderBeingMoved = FALSE;
247 if ( slider.width() == 0 ) 247 if ( slider.width() == 0 )
248 return; 248 return;
249 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); 249 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width());
250 mediaPlayerState->setPosition( val ); 250 mediaPlayerState->setPosition( val );
251} 251}
252 252
253void AudioWidget::setPosition( long i ) { 253void AudioWidget::setPosition( long i ) {
254 // qDebug("set position %d",i); 254 // qDebug("set position %d",i);
255 updateSlider( i, mediaPlayerState->length() ); 255 updateSlider( i, mediaPlayerState->length() );
256} 256}
257 257
258 258
259void AudioWidget::setLength( long max ) { 259void AudioWidget::setLength( long max ) {
260 updateSlider( mediaPlayerState->position(), max ); 260 updateSlider( mediaPlayerState->position(), max );
261} 261}
262 262
263 263
264void AudioWidget::setView( char view ) { 264void AudioWidget::setView( char view ) {
265 if (mediaPlayerState->streaming() ) { 265 if (mediaPlayerState->streaming() ) {
266 if( !slider.isHidden()) slider.hide(); 266 if( !slider.isHidden()) slider.hide();
267 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 267 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
268 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 268 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
269 } else { 269 } else {
270 // this stops the slider from being moved, thus 270 // this stops the slider from being moved, thus
271 // does not stop stream when it reaches the end 271 // does not stop stream when it reaches the end
272 slider->show(); 272 slider->show();
273 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 273 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
274 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 274 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
275 } 275 }
276 276
277 if ( view == 'a' ) { 277 if ( view == 'a' ) {
278 startTimer( 150 ); 278 startTimer( 150 );
279 showMaximized(); 279 showMaximized();
280 } else { 280 } else {
281 killTimers(); 281 killTimers();
282 hide(); 282 hide();
283 } 283 }
284} 284}
285 285
286 286
287static QString timeAsString( long length ) { 287static QString timeAsString( long length ) {
288 length /= 44100; 288 length /= 44100;
289 int minutes = length / 60; 289 int minutes = length / 60;
290 int seconds = length % 60; 290 int seconds = length % 60;
291 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); 291 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 );
292} 292}
293 293
294void AudioWidget::updateSlider( long i, long max ) { 294void AudioWidget::updateSlider( long i, long max ) {
295 time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); 295 time.setText( timeAsString( i ) + " / " + timeAsString( max ) );
296 if ( max == 0 ) { 296 if ( max == 0 ) {
297 return; 297 return;
298 } 298 }
299 // Will flicker too much if we don't do this 299 // Will flicker too much if we don't do this
300 // Scale to something reasonable 300 // Scale to something reasonable
301 int width = slider->width(); 301 int width = slider->width();
302 int val = int((double)i * width / max); 302 int val = int((double)i * width / max);
303 if ( !audioSliderBeingMoved ) { 303 if ( !audioSliderBeingMoved ) {
304 if ( slider->value() != val ) { 304 if ( slider->value() != val ) {
305 slider->setValue( val ); 305 slider->setValue( val );
306 } 306 }
307 307
308 if ( slider->maxValue() != width ) { 308 if ( slider->maxValue() != width ) {
309 slider->setMaxValue( width ); 309 slider->setMaxValue( width );
310 } 310 }
311 } 311 }
312} 312}
313 313
314 314
315void AudioWidget::setToggleButton( int i, bool down ) { 315void AudioWidget::setToggleButton( int i, bool down ) {
316 if ( down != audioButtons[i].isDown ) { 316 if ( down != audioButtons[i].isDown ) {
317 toggleButton( i ); 317 toggleButton( i );
318 } 318 }
319} 319}
320 320
321 321
322void AudioWidget::toggleButton( int i ) { 322void AudioWidget::toggleButton( int i ) {
323 audioButtons[i].isDown = !audioButtons[i].isDown; 323 audioButtons[i].isDown = !audioButtons[i].isDown;
324 QPainter p(this); 324 QPainter p(this);
325 paintButton ( &p, i ); 325 paintButton ( &p, i );
326} 326}
327 327
328 328
329void AudioWidget::paintButton( QPainter *p, int i ) { 329void AudioWidget::paintButton( QPainter *p, int i ) {
330 if ( audioButtons[i].isDown ) 330 if ( audioButtons[i].isDown )
331 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 331 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
332 else 332 else
333 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 333 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
334} 334}
335 335
336 336
337void AudioWidget::timerEvent( QTimerEvent * ) { 337void AudioWidget::timerEvent( QTimerEvent * ) {
338// static int frame = 0; 338// static int frame = 0;
339// if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { 339// if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) {
340// frame = frame >= 7 ? 0 : frame + 1; 340// frame = frame >= 7 ? 0 : frame + 1;
341// } 341// }
342} 342}
343 343
344 344
345void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 345void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
346 for ( int i = 0; i < numButtons; i++ ) { 346 for ( int i = 0; i < numButtons; i++ ) {
347 if ( event->state() == QMouseEvent::LeftButton ) { 347 if ( event->state() == QMouseEvent::LeftButton ) {
348 348
349 // The test to see if the mouse click is inside the button or not 349 // The test to see if the mouse click is inside the button or not
350 int x = event->pos().x() - xoff; 350 int x = event->pos().x() - xoff;
351 int y = event->pos().y() - yoff; 351 int y = event->pos().y() - yoff;
352 352
353 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() 353 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
354 && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); 354 && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 );
355 355
356 if ( isOnButton && i == AudioVolumeUp ) 356 if ( isOnButton && i == AudioVolumeUp )
357 qDebug("on up"); 357 qDebug("on up");
358 358
359 if ( isOnButton && !audioButtons[i].isHeld ) { 359 if ( isOnButton && !audioButtons[i].isHeld ) {
360 audioButtons[i].isHeld = TRUE; 360 audioButtons[i].isHeld = TRUE;
361 toggleButton(i); 361 toggleButton(i);
362 switch (i) { 362 switch (i) {
363 case AudioVolumeUp: 363 case AudioVolumeUp:
364 qDebug("more clicked"); 364 qDebug("more clicked");