summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp13
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp9
2 files changed, 21 insertions, 1 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 132a911..442864f 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -136,442 +136,453 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
136 //skin = "scaleTest"; 136 //skin = "scaleTest";
137// color of background, frame, degree of transparency 137// color of background, frame, degree of transparency
138 138
139 QString skinPath = "opieplayer2/skins/" + skin; 139 QString skinPath = "opieplayer2/skins/" + skin;
140 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 140 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
141 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); 141 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
142 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); 142 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
143 143
144 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); 144 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
145 imgButtonMask->fill( 0 ); 145 imgButtonMask->fill( 0 );
146 146
147 for ( int i = 0; i < 10; i++ ) { 147 for ( int i = 0; i < 10; i++ ) {
148 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; 148 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png";
149 masks[i] = new QBitmap( filename ); 149 masks[i] = new QBitmap( filename );
150 150
151 if ( !masks[i]->isNull() ) { 151 if ( !masks[i]->isNull() ) {
152 QImage imgMask = masks[i]->convertToImage(); 152 QImage imgMask = masks[i]->convertToImage();
153 uchar **dest = imgButtonMask->jumpTable(); 153 uchar **dest = imgButtonMask->jumpTable();
154 for ( int y = 0; y < imgUp->height(); y++ ) { 154 for ( int y = 0; y < imgUp->height(); y++ ) {
155 uchar *line = dest[y]; 155 uchar *line = dest[y];
156 for ( int x = 0; x < imgUp->width(); x++ ) 156 for ( int x = 0; x < imgUp->width(); x++ )
157 if ( !qRed( imgMask.pixel( x, y ) ) ) 157 if ( !qRed( imgMask.pixel( x, y ) ) )
158 line[x] = i + 1; 158 line[x] = i + 1;
159 } 159 }
160 } 160 }
161 161
162 } 162 }
163 163
164 for ( int i = 0; i < 10; i++ ) { 164 for ( int i = 0; i < 10; i++ ) {
165 buttonPixUp[i] = NULL; 165 buttonPixUp[i] = NULL;
166 buttonPixDown[i] = NULL; 166 buttonPixDown[i] = NULL;
167 } 167 }
168 168
169 setBackgroundPixmap( *pixBg ); 169 setBackgroundPixmap( *pixBg );
170 170
171 songInfo.setFocusPolicy( QWidget::NoFocus ); 171 songInfo.setFocusPolicy( QWidget::NoFocus );
172 changeTextColor( &songInfo ); 172 changeTextColor( &songInfo );
173 173
174 slider.setFixedHeight( 20 ); 174 slider.setFixedHeight( 20 );
175 slider.setMinValue( 0 ); 175 slider.setMinValue( 0 );
176 slider.setMaxValue( 1 ); 176 slider.setMaxValue( 1 );
177 slider.setFocusPolicy( QWidget::NoFocus ); 177 slider.setFocusPolicy( QWidget::NoFocus );
178 slider.setBackgroundPixmap( *pixBg ); 178 slider.setBackgroundPixmap( *pixBg );
179 179
180 time.setFocusPolicy( QWidget::NoFocus ); 180 time.setFocusPolicy( QWidget::NoFocus );
181 time.setAlignment( Qt::AlignCenter ); 181 time.setAlignment( Qt::AlignCenter );
182 time.setFrame(FALSE); 182 time.setFrame(FALSE);
183 changeTextColor( &time ); 183 changeTextColor( &time );
184 184
185 resizeEvent( NULL ); 185 resizeEvent( NULL );
186 186
187 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 187 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
188 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 188 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
189 189
190 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 190 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
191 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 191 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
192 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 192 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
193// connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 193// connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
194 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 194 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
195 195
196 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); 196 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) );
197 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); 197 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) );
198 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); 198 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) );
199 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); 199 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) );
200 200
201 201
202 202
203 // Intialise state 203 // Intialise state
204 setLength( mediaPlayerState->length() ); 204 setLength( mediaPlayerState->length() );
205 setPosition( mediaPlayerState->position() ); 205 setPosition( mediaPlayerState->position() );
206 setLooping( mediaPlayerState->fullscreen() ); 206 setLooping( mediaPlayerState->fullscreen() );
207// setPaused( mediaPlayerState->paused() ); 207// setPaused( mediaPlayerState->paused() );
208 setPlaying( mediaPlayerState->playing() ); 208 setPlaying( mediaPlayerState->playing() );
209 209
210} 210}
211 211
212AudioWidget::~AudioWidget() { 212AudioWidget::~AudioWidget() {
213 213
214 for ( int i = 0; i < 10; i++ ) { 214 for ( int i = 0; i < 10; i++ ) {
215 delete buttonPixUp[i]; 215 delete buttonPixUp[i];
216 delete buttonPixDown[i]; 216 delete buttonPixDown[i];
217 } 217 }
218 delete pixBg; 218 delete pixBg;
219 delete imgUp; 219 delete imgUp;
220 delete imgDn; 220 delete imgDn;
221 delete imgButtonMask; 221 delete imgButtonMask;
222 for ( int i = 0; i < 10; i++ ) { 222 for ( int i = 0; i < 10; i++ ) {
223 delete masks[i]; 223 delete masks[i];
224 } 224 }
225} 225}
226 226
227QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 227QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
228 QPixmap pix( img.width(), img.height() ); 228 QPixmap pix( img.width(), img.height() );
229 QPainter p( &pix ); 229 QPainter p( &pix );
230 p.drawTiledPixmap( pix.rect(), bg, offset ); 230 p.drawTiledPixmap( pix.rect(), bg, offset );
231 p.drawImage( 0, 0, img ); 231 p.drawImage( 0, 0, img );
232 return new QPixmap( pix ); 232 return new QPixmap( pix );
233} 233}
234 234
235 235
236QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) 236QPixmap *maskPixToMask( QPixmap pix, QBitmap mask )
237{ 237{
238 QPixmap *pixmap = new QPixmap( pix ); 238 QPixmap *pixmap = new QPixmap( pix );
239 pixmap->setMask( mask ); 239 pixmap->setMask( mask );
240 return pixmap; 240 return pixmap;
241} 241}
242 242
243 243
244 244
245void AudioWidget::resizeEvent( QResizeEvent * ) { 245void AudioWidget::resizeEvent( QResizeEvent * ) {
246 int h = height(); 246 int h = height();
247 int w = width(); 247 int w = width();
248 248
249 songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); 249 songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) );
250 slider.setFixedWidth( w - 110 ); 250 slider.setFixedWidth( w - 110 );
251 slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); 251 slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) );
252 slider.setBackgroundOrigin( QWidget::ParentOrigin ); 252 slider.setBackgroundOrigin( QWidget::ParentOrigin );
253 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); 253 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
254 254
255 xoff = ( w - imgUp->width() ) / 2; 255 xoff = ( w - imgUp->width() ) / 2;
256 yoff = (( h - imgUp->height() ) / 2) - 10; 256 yoff = (( h - imgUp->height() ) / 2) - 10;
257 QPoint p( xoff, yoff ); 257 QPoint p( xoff, yoff );
258 258
259 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); 259 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p );
260 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); 260 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p );
261 261
262 for ( int i = 0; i < 10; i++ ) { 262 for ( int i = 0; i < 10; i++ ) {
263 if ( !masks[i]->isNull() ) { 263 if ( !masks[i]->isNull() ) {
264 delete buttonPixUp[i]; 264 delete buttonPixUp[i];
265 delete buttonPixDown[i]; 265 delete buttonPixDown[i];
266 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); 266 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] );
267 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); 267 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] );
268 } 268 }
269 } 269 }
270 270
271 delete pixUp; 271 delete pixUp;
272 delete pixDn; 272 delete pixDn;
273} 273}
274 274
275static bool audioSliderBeingMoved = FALSE; 275static bool audioSliderBeingMoved = FALSE;
276 276
277 277
278void AudioWidget::sliderPressed() { 278void AudioWidget::sliderPressed() {
279 audioSliderBeingMoved = TRUE; 279 audioSliderBeingMoved = TRUE;
280} 280}
281 281
282 282
283void AudioWidget::sliderReleased() { 283void AudioWidget::sliderReleased() {
284 audioSliderBeingMoved = FALSE; 284 audioSliderBeingMoved = FALSE;
285 if ( slider.width() == 0 ) 285 if ( slider.width() == 0 )
286 return; 286 return;
287 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); 287 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width());
288 mediaPlayerState->setPosition( val ); 288 mediaPlayerState->setPosition( val );
289} 289}
290 290
291void AudioWidget::setPosition( long i ) { 291void AudioWidget::setPosition( long i ) {
292// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); 292// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i);
293 updateSlider( i, mediaPlayerState->length() ); 293 updateSlider( i, mediaPlayerState->length() );
294} 294}
295 295
296 296
297void AudioWidget::setLength( long max ) { 297void AudioWidget::setLength( long max ) {
298 updateSlider( mediaPlayerState->position(), max ); 298 updateSlider( mediaPlayerState->position(), max );
299} 299}
300 300
301 301
302void AudioWidget::setView( char view ) { 302void AudioWidget::setView( char view ) {
303 303
304// this isnt working for some reason 304// this isnt working for some reason
305 305
306 if ( mediaPlayerState->streaming() ) { 306 if ( mediaPlayerState->streaming() ) {
307 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); 307 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>");
308 if( !slider.isHidden()) { 308 if( !slider.isHidden()) {
309 slider.hide(); 309 slider.hide();
310 } 310 }
311 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 311 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
312 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 312 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
313 } else { 313 } else {
314 // this stops the slider from being moved, thus 314 // this stops the slider from being moved, thus
315 // does not stop stream when it reaches the end 315 // does not stop stream when it reaches the end
316 slider.show(); 316 slider.show();
317 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 317 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
318 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 318 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
319 } 319 }
320 320
321 if ( view == 'a' ) { 321 if ( view == 'a' ) {
322 // startTimer( 150 ); 322 // startTimer( 150 );
323 showMaximized(); 323 showMaximized();
324 } else { 324 } else {
325 killTimers(); 325 killTimers();
326 hide(); 326 hide();
327 } 327 }
328 qApp->processEvents();
328} 329}
329 330
330 331
331static QString timeAsString( long length ) { 332static QString timeAsString( long length ) {
332 int minutes = length / 60; 333 int minutes = length / 60;
333 int seconds = length % 60; 334 int seconds = length % 60;
334 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); 335 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 );
335} 336}
336 337
337void AudioWidget::updateSlider( long i, long max ) { 338void AudioWidget::updateSlider( long i, long max ) {
338 339
339 time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); 340 time.setText( timeAsString( i ) + " / " + timeAsString( max ) );
340// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; 341// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ;
341 342
342 if ( max == 0 ) { 343 if ( max == 0 ) {
343 return; 344 return;
344 } 345 }
345 // Will flicker too much if we don't do this 346 // Will flicker too much if we don't do this
346 // Scale to something reasonable 347 // Scale to something reasonable
347 int width = slider.width(); 348 int width = slider.width();
348 int val = int((double)i * width / max); 349 int val = int((double)i * width / max);
349 if ( !audioSliderBeingMoved ) { 350 if ( !audioSliderBeingMoved ) {
350 if ( slider.value() != val ) { 351 if ( slider.value() != val ) {
351 slider.setValue( val ); 352 slider.setValue( val );
352 } 353 }
353 354
354 if ( slider.maxValue() != width ) { 355 if ( slider.maxValue() != width ) {
355 slider.setMaxValue( width ); 356 slider.setMaxValue( width );
356 } 357 }
357 } 358 }
358} 359}
359 360
360 361
361void AudioWidget::setToggleButton( int i, bool down ) { 362void AudioWidget::setToggleButton( int i, bool down ) {
362 qDebug("setToggleButton %d", i); 363 qDebug("setToggleButton %d", i);
363 if ( down != audioButtons[i].isDown ) { 364 if ( down != audioButtons[i].isDown ) {
364 toggleButton( i ); 365 toggleButton( i );
365 } 366 }
366} 367}
367 368
368 369
369void AudioWidget::toggleButton( int i ) { 370void AudioWidget::toggleButton( int i ) {
370 audioButtons[i].isDown = !audioButtons[i].isDown; 371 audioButtons[i].isDown = !audioButtons[i].isDown;
371 QPainter p(this); 372 QPainter p(this);
372 paintButton ( &p, i ); 373 paintButton ( &p, i );
373} 374}
374 375
375 376
376void AudioWidget::paintButton( QPainter *p, int i ) { 377void AudioWidget::paintButton( QPainter *p, int i ) {
377 if ( audioButtons[i].isDown ) { 378 if ( audioButtons[i].isDown ) {
378 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 379 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
379 } else { 380 } else {
380 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 381 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
381 } 382 }
382} 383}
383 384
384 385
385void AudioWidget::skipFor() { 386void AudioWidget::skipFor() {
386 skipDirection = +1; 387 skipDirection = +1;
387 startTimer( 50 ); 388 startTimer( 50 );
388 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); 389 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 );
389} 390}
390 391
391void AudioWidget::skipBack() { 392void AudioWidget::skipBack() {
392 skipDirection = -1; 393 skipDirection = -1;
393 startTimer( 50 ); 394 startTimer( 50 );
394 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); 395 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 );
395} 396}
396 397
397 398
398 399
399void AudioWidget::stopSkip() { 400void AudioWidget::stopSkip() {
400 killTimers(); 401 killTimers();
401} 402}
402 403
403 404
404void AudioWidget::timerEvent( QTimerEvent * ) { 405void AudioWidget::timerEvent( QTimerEvent * ) {
405 if ( skipDirection == +1 ) { 406 if ( skipDirection == +1 ) {
406 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); 407 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 );
407 } else if ( skipDirection == -1 ) { 408 } else if ( skipDirection == -1 ) {
408 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); 409 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 );
409 } 410 }
410} 411}
411 412
412 413
413void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 414void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
414 for ( int i = 0; i < numButtons; i++ ) { 415 for ( int i = 0; i < numButtons; i++ ) {
415 if ( event->state() == QMouseEvent::LeftButton ) { 416 if ( event->state() == QMouseEvent::LeftButton ) {
416 // The test to see if the mouse click is inside the button or not 417 // The test to see if the mouse click is inside the button or not
417 int x = event->pos().x() - xoff; 418 int x = event->pos().x() - xoff;
418 int y = event->pos().y() - yoff; 419 int y = event->pos().y() - yoff;
419 420
420 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() 421 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
421 && y < imgButtonMask->height() 422 && y < imgButtonMask->height()
422 && imgButtonMask->pixelIndex( x, y ) == i + 1 ); 423 && imgButtonMask->pixelIndex( x, y ) == i + 1 );
423 424
424 if ( isOnButton && !audioButtons[i].isHeld ) { 425 if ( isOnButton && !audioButtons[i].isHeld ) {
425 audioButtons[i].isHeld = TRUE; 426 audioButtons[i].isHeld = TRUE;
426 toggleButton(i); 427 toggleButton(i);
427 switch (i) { 428 switch (i) {
428 case AudioVolumeUp: 429 case AudioVolumeUp:
429 emit moreClicked(); 430 emit moreClicked();
430 return; 431 return;
431 case AudioVolumeDown: 432 case AudioVolumeDown:
432 emit lessClicked(); 433 emit lessClicked();
433 return; 434 return;
434 case AudioForward: 435 case AudioForward:
435 emit forwardClicked(); 436 emit forwardClicked();
436 return; 437 return;
437 case AudioBack: 438 case AudioBack:
438 emit backClicked(); 439 emit backClicked();
439 return; 440 return;
440 } 441 }
441 } 442 }
442 else if ( !isOnButton && audioButtons[i].isHeld ) { 443 else if ( !isOnButton && audioButtons[i].isHeld ) {
443 audioButtons[i].isHeld = FALSE; 444 audioButtons[i].isHeld = FALSE;
444 toggleButton(i); 445 toggleButton(i);
445 } 446 }
446 } else { 447 } else {
447 if ( audioButtons[i].isHeld ) { 448 if ( audioButtons[i].isHeld ) {
448 audioButtons[i].isHeld = FALSE; 449 audioButtons[i].isHeld = FALSE;
449 if ( !audioButtons[i].isToggle ) { 450 if ( !audioButtons[i].isToggle ) {
450 setToggleButton( i, FALSE ); 451 setToggleButton( i, FALSE );
451 } 452 }
452 switch (i) { 453 switch (i) {
453 case AudioPlay: 454 case AudioPlay:
454 if( mediaPlayerState->isPaused ) { 455 if( mediaPlayerState->isPaused ) {
455// setToggleButton( i, FALSE ); 456// setToggleButton( i, FALSE );
456 mediaPlayerState->setPaused( FALSE ); 457 mediaPlayerState->setPaused( FALSE );
457 return; 458 return;
458 } else if( !mediaPlayerState->isPaused ) { 459 } else if( !mediaPlayerState->isPaused ) {
459// setToggleButton( i, TRUE ); 460// setToggleButton( i, TRUE );
460 mediaPlayerState->setPaused( TRUE ); 461 mediaPlayerState->setPaused( TRUE );
461 return; 462 return;
462 } else { 463 } else {
463 // setToggleButton( i, TRUE ); 464 // setToggleButton( i, TRUE );
464 // mediaPlayerState->setPlaying( videoButtons[i].isDown ); 465 // mediaPlayerState->setPlaying( videoButtons[i].isDown );
465 } 466 }
466 case AudioStop: mediaPlayerState->setPlaying(FALSE); return; 467 case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
467 case AudioNext: mediaPlayerState->setNext(); return; 468 case AudioNext: mediaPlayerState->setNext(); return;
468 case AudioPrevious: mediaPlayerState->setPrev(); return; 469 case AudioPrevious: mediaPlayerState->setPrev(); return;
469 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; 470 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return;
470 case AudioVolumeUp: emit moreReleased(); return; 471 case AudioVolumeUp: emit moreReleased(); return;
471 case AudioVolumeDown: emit lessReleased(); return; 472 case AudioVolumeDown: emit lessReleased(); return;
472 case AudioPlayList: mediaPlayerState->setList(); return; 473 case AudioPlayList: mediaPlayerState->setList(); return;
473 case AudioForward: emit forwardReleased(); return; 474 case AudioForward: emit forwardReleased(); return;
474 case AudioBack: emit backReleased(); return; 475 case AudioBack: emit backReleased(); return;
475 } 476 }
476 } 477 }
477 } 478 }
478 } 479 }
479} 480}
480 481
481 482
482void AudioWidget::mousePressEvent( QMouseEvent *event ) { 483void AudioWidget::mousePressEvent( QMouseEvent *event ) {
483 mouseMoveEvent( event ); 484 mouseMoveEvent( event );
484} 485}
485 486
486 487
487void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { 488void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
488 mouseMoveEvent( event ); 489 mouseMoveEvent( event );
489} 490}
490 491
491 492
492void AudioWidget::showEvent( QShowEvent* ) { 493void AudioWidget::showEvent( QShowEvent* ) {
493 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 494 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
494 mouseMoveEvent( &event ); 495 mouseMoveEvent( &event );
495} 496}
496 497
497 498
498void AudioWidget::closeEvent( QCloseEvent* ) { 499void AudioWidget::closeEvent( QCloseEvent* ) {
499 mediaPlayerState->setList(); 500 mediaPlayerState->setList();
500} 501}
501 502
502 503
503void AudioWidget::paintEvent( QPaintEvent * pe) { 504void AudioWidget::paintEvent( QPaintEvent * pe) {
504 if ( !pe->erased() ) { 505 if ( !pe->erased() ) {
505 // Combine with background and double buffer 506 // Combine with background and double buffer
506 QPixmap pix( pe->rect().size() ); 507 QPixmap pix( pe->rect().size() );
507 QPainter p( &pix ); 508 QPainter p( &pix );
508 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 509 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
509 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); 510 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
510 for ( int i = 0; i < numButtons; i++ ) 511 for ( int i = 0; i < numButtons; i++ )
511 paintButton( &p, i ); 512 paintButton( &p, i );
512 QPainter p2( this ); 513 QPainter p2( this );
513 p2.drawPixmap( pe->rect().topLeft(), pix ); 514 p2.drawPixmap( pe->rect().topLeft(), pix );
514 } else { 515 } else {
515 QPainter p( this ); 516 QPainter p( this );
516 for ( int i = 0; i < numButtons; i++ ) 517 for ( int i = 0; i < numButtons; i++ )
517 paintButton( &p, i ); 518 paintButton( &p, i );
518 } 519 }
519} 520}
520 521
521void AudioWidget::keyReleaseEvent( QKeyEvent *e) 522void AudioWidget::keyReleaseEvent( QKeyEvent *e)
522{ 523{
523 switch ( e->key() ) { 524 switch ( e->key() ) {
524////////////////////////////// Zaurus keys 525////////////////////////////// Zaurus keys
525 case Key_Home: 526 case Key_Home:
526 break; 527 break;
527 case Key_F9: //activity 528 case Key_F9: //activity
528 hide(); 529 hide();
529// qDebug("Audio F9"); 530// qDebug("Audio F9");
530 break; 531 break;
531 case Key_F10: //contacts 532 case Key_F10: //contacts
532 break; 533 break;
533 case Key_F11: //menu 534 case Key_F11: //menu
534 break; 535 break;
535 case Key_F12: //home 536 case Key_F12: //home
536 break; 537 break;
537 case Key_F13: //mail 538 case Key_F13: //mail
538 break; 539 break;
539 case Key_Space: { 540 case Key_Space: {
540 if(mediaPlayerState->playing()) { 541 if(mediaPlayerState->playing()) {
541// toggleButton(1); 542// toggleButton(1);
542 mediaPlayerState->setPlaying(FALSE); 543 mediaPlayerState->setPlaying(FALSE);
543// toggleButton(1); 544// toggleButton(1);
544 } else { 545 } else {
545// toggleButton(0); 546// toggleButton(0);
546 mediaPlayerState->setPlaying(TRUE); 547 mediaPlayerState->setPlaying(TRUE);
547// toggleButton(0); 548// toggleButton(0);
548 } 549 }
549 } 550 }
550 break; 551 break;
551 case Key_Down: 552 case Key_Down:
552// toggleButton(6); 553// toggleButton(6);
553 emit lessClicked(); 554 emit lessClicked();
554 emit lessReleased(); 555 emit lessReleased();
555// toggleButton(6); 556// toggleButton(6);
556 break; 557 break;
557 case Key_Up: 558 case Key_Up:
558// toggleButton(5); 559// toggleButton(5);
559 emit moreClicked(); 560 emit moreClicked();
560 emit moreReleased(); 561 emit moreReleased();
561// toggleButton(5); 562// toggleButton(5);
562 break; 563 break;
563 case Key_Right: 564 case Key_Right:
564// toggleButton(3); 565// toggleButton(3);
565 mediaPlayerState->setNext(); 566 mediaPlayerState->setNext();
566// toggleButton(3); 567// toggleButton(3);
567 break; 568 break;
568 case Key_Left: 569 case Key_Left:
569// toggleButton(4); 570// toggleButton(4);
570 mediaPlayerState->setPrev(); 571 mediaPlayerState->setPrev();
571// toggleButton(4); 572// toggleButton(4);
572 break; 573 break;
573 case Key_Escape: 574 case Key_Escape: {
575#if defined(QT_QWS_IPAQ)
576 if( mediaPlayerState->isPaused ) {
577 setToggleButton( i, FALSE );
578 mediaPlayerState->setPaused( FALSE );
579 } else if( !mediaPlayerState->isPaused ) {
580 setToggleButton( i, TRUE );
581 mediaPlayerState->setPaused( TRUE );
582 }
583#endif
584 }
574 break; 585 break;
575 586
576 }; 587 };
577} 588}
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 0521419..5a69bf5 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -289,211 +289,220 @@ void VideoWidget::toggleButton( int i ) {
289} 289}
290 290
291void VideoWidget::paintButton( QPainter *p, int i ) { 291void VideoWidget::paintButton( QPainter *p, int i ) {
292 292
293 if ( videoButtons[i].isDown ) { 293 if ( videoButtons[i].isDown ) {
294 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 294 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
295 } else { 295 } else {
296 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 296 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
297 } 297 }
298} 298}
299 299
300void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 300void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
301 for ( int i = 0; i < numVButtons; i++ ) { 301 for ( int i = 0; i < numVButtons; i++ ) {
302 if ( event->state() == QMouseEvent::LeftButton ) { 302 if ( event->state() == QMouseEvent::LeftButton ) {
303 // The test to see if the mouse click is inside the button or not 303 // The test to see if the mouse click is inside the button or not
304 int x = event->pos().x() - xoff; 304 int x = event->pos().x() - xoff;
305 int y = event->pos().y() - yoff; 305 int y = event->pos().y() - yoff;
306 306
307 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() 307 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
308 && y < imgButtonMask->height() 308 && y < imgButtonMask->height()
309 && imgButtonMask->pixelIndex( x, y ) == i + 1 ); 309 && imgButtonMask->pixelIndex( x, y ) == i + 1 );
310 310
311 if ( isOnButton && !videoButtons[i].isHeld ) { 311 if ( isOnButton && !videoButtons[i].isHeld ) {
312 videoButtons[i].isHeld = TRUE; 312 videoButtons[i].isHeld = TRUE;
313 toggleButton(i); 313 toggleButton(i);
314 314
315 switch (i) { 315 switch (i) {
316 case VideoVolUp: 316 case VideoVolUp:
317 emit moreClicked(); 317 emit moreClicked();
318 return; 318 return;
319 case VideoVolDown: 319 case VideoVolDown:
320 emit lessClicked(); 320 emit lessClicked();
321 return; 321 return;
322 } 322 }
323 } else if ( !isOnButton && videoButtons[i].isHeld ) { 323 } else if ( !isOnButton && videoButtons[i].isHeld ) {
324 videoButtons[i].isHeld = FALSE; 324 videoButtons[i].isHeld = FALSE;
325 toggleButton(i); 325 toggleButton(i);
326 } 326 }
327 } else { 327 } else {
328 328
329 if ( videoButtons[i].isHeld ) { 329 if ( videoButtons[i].isHeld ) {
330 videoButtons[i].isHeld = FALSE; 330 videoButtons[i].isHeld = FALSE;
331 if ( !videoButtons[i].isToggle ) { 331 if ( !videoButtons[i].isToggle ) {
332 setToggleButton( i, FALSE ); 332 setToggleButton( i, FALSE );
333 } 333 }
334 334
335 switch(i) { 335 switch(i) {
336 336
337 case VideoPlay: { 337 case VideoPlay: {
338 if( mediaPlayerState->isPaused ) { 338 if( mediaPlayerState->isPaused ) {
339 setToggleButton( i, FALSE ); 339 setToggleButton( i, FALSE );
340 mediaPlayerState->setPaused( FALSE ); 340 mediaPlayerState->setPaused( FALSE );
341 return; 341 return;
342 } else if( !mediaPlayerState->isPaused ) { 342 } else if( !mediaPlayerState->isPaused ) {
343 setToggleButton( i, TRUE ); 343 setToggleButton( i, TRUE );
344 mediaPlayerState->setPaused( TRUE ); 344 mediaPlayerState->setPaused( TRUE );
345 return; 345 return;
346 } else { 346 } else {
347 return; 347 return;
348 } 348 }
349 } 349 }
350 350
351 case VideoStop: mediaPlayerState->setPlaying( FALSE ); return; 351 case VideoStop: mediaPlayerState->setPlaying( FALSE ); return;
352 case VideoNext: mediaPlayerState->setNext(); return; 352 case VideoNext: mediaPlayerState->setNext(); return;
353 case VideoPrevious: mediaPlayerState->setPrev(); return; 353 case VideoPrevious: mediaPlayerState->setPrev(); return;
354 case VideoVolUp: emit moreReleased(); return; 354 case VideoVolUp: emit moreReleased(); return;
355 case VideoVolDown: emit lessReleased(); return; 355 case VideoVolDown: emit lessReleased(); return;
356 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; 356 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
357 } 357 }
358 } 358 }
359 } 359 }
360 } 360 }
361} 361}
362 362
363void VideoWidget::mousePressEvent( QMouseEvent *event ) { 363void VideoWidget::mousePressEvent( QMouseEvent *event ) {
364 mouseMoveEvent( event ); 364 mouseMoveEvent( event );
365} 365}
366 366
367void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 367void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
368 if ( mediaPlayerState->fullscreen() ) { 368 if ( mediaPlayerState->fullscreen() ) {
369 mediaPlayerState->setFullscreen( FALSE ); 369 mediaPlayerState->setFullscreen( FALSE );
370 makeVisible(); 370 makeVisible();
371 } 371 }
372 mouseMoveEvent( event ); 372 mouseMoveEvent( event );
373} 373}
374 374
375void VideoWidget::showEvent( QShowEvent* ) { 375void VideoWidget::showEvent( QShowEvent* ) {
376 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 376 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
377 mouseMoveEvent( &event ); 377 mouseMoveEvent( &event );
378} 378}
379 379
380 380
381 void VideoWidget::backToNormal() { 381 void VideoWidget::backToNormal() {
382 mediaPlayerState->setFullscreen( FALSE ); 382 mediaPlayerState->setFullscreen( FALSE );
383 makeVisible(); 383 makeVisible();
384 } 384 }
385 385
386void VideoWidget::makeVisible() { 386void VideoWidget::makeVisible() {
387 if ( mediaPlayerState->fullscreen() ) { 387 if ( mediaPlayerState->fullscreen() ) {
388 setBackgroundMode( QWidget::NoBackground ); 388 setBackgroundMode( QWidget::NoBackground );
389 showFullScreen(); 389 showFullScreen();
390 resize( qApp->desktop()->size() ); 390 resize( qApp->desktop()->size() );
391 slider->hide(); 391 slider->hide();
392 videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); 392 videoFrame-> setGeometry ( 0, 0, width ( ), height ( ));
393 393
394 } else { 394 } else {
395 showMaximized(); 395 showMaximized();
396 setBackgroundPixmap( *pixBg ); 396 setBackgroundPixmap( *pixBg );
397 slider->show(); 397 slider->show();
398 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); 398 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) );
399 qApp->processEvents(); 399 qApp->processEvents();
400 } 400 }
401} 401}
402 402
403 403
404void VideoWidget::paintEvent( QPaintEvent * pe) { 404void VideoWidget::paintEvent( QPaintEvent * pe) {
405 QPainter p( this ); 405 QPainter p( this );
406 406
407 if ( mediaPlayerState->fullscreen() ) { 407 if ( mediaPlayerState->fullscreen() ) {
408 // Clear the background 408 // Clear the background
409 p.setBrush( QBrush( Qt::black ) ); 409 p.setBrush( QBrush( Qt::black ) );
410 } else { 410 } else {
411 if ( !pe->erased() ) { 411 if ( !pe->erased() ) {
412 // Combine with background and double buffer 412 // Combine with background and double buffer
413 QPixmap pix( pe->rect().size() ); 413 QPixmap pix( pe->rect().size() );
414 QPainter p( &pix ); 414 QPainter p( &pix );
415 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 415 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
416 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); 416 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
417 for ( int i = 0; i < numVButtons; i++ ) { 417 for ( int i = 0; i < numVButtons; i++ ) {
418 paintButton( &p, i ); 418 paintButton( &p, i );
419 } 419 }
420 QPainter p2( this ); 420 QPainter p2( this );
421 p2.drawPixmap( pe->rect().topLeft(), pix ); 421 p2.drawPixmap( pe->rect().topLeft(), pix );
422 } else { 422 } else {
423 QPainter p( this ); 423 QPainter p( this );
424 for ( int i = 0; i < numVButtons; i++ ) 424 for ( int i = 0; i < numVButtons; i++ )
425 paintButton( &p, i ); 425 paintButton( &p, i );
426 } 426 }
427 slider->repaint( TRUE ); 427 slider->repaint( TRUE );
428 } 428 }
429} 429}
430 430
431 431
432void VideoWidget::closeEvent( QCloseEvent* ) { 432void VideoWidget::closeEvent( QCloseEvent* ) {
433 mediaPlayerState->setList(); 433 mediaPlayerState->setList();
434} 434}
435 435
436 436
437 437
438void VideoWidget::keyReleaseEvent( QKeyEvent *e) { 438void VideoWidget::keyReleaseEvent( QKeyEvent *e) {
439 switch ( e->key() ) { 439 switch ( e->key() ) {
440////////////////////////////// Zaurus keys 440////////////////////////////// Zaurus keys
441 case Key_Home: 441 case Key_Home:
442 break; 442 break;
443 case Key_F9: //activity 443 case Key_F9: //activity
444 break; 444 break;
445 case Key_F10: //contacts 445 case Key_F10: //contacts
446// hide(); 446// hide();
447 break; 447 break;
448 case Key_F11: //menu 448 case Key_F11: //menu
449 break; 449 break;
450 case Key_F12: //home 450 case Key_F12: //home
451 break; 451 break;
452 case Key_F13: //mail 452 case Key_F13: //mail
453 break; 453 break;
454 case Key_Space: { 454 case Key_Space: {
455 if(mediaPlayerState->playing()) { 455 if(mediaPlayerState->playing()) {
456 mediaPlayerState->setPlaying(FALSE); 456 mediaPlayerState->setPlaying(FALSE);
457 } else { 457 } else {
458 mediaPlayerState->setPlaying(TRUE); 458 mediaPlayerState->setPlaying(TRUE);
459 } 459 }
460 } 460 }
461 break; 461 break;
462 case Key_Down: 462 case Key_Down:
463// toggleButton(6); 463// toggleButton(6);
464 emit lessClicked(); 464 emit lessClicked();
465 emit lessReleased(); 465 emit lessReleased();
466// toggleButton(6); 466// toggleButton(6);
467 break; 467 break;
468 case Key_Up: 468 case Key_Up:
469// toggleButton(5); 469// toggleButton(5);
470 emit moreClicked(); 470 emit moreClicked();
471 emit moreReleased(); 471 emit moreReleased();
472// toggleButton(5); 472// toggleButton(5);
473 break; 473 break;
474 case Key_Right: 474 case Key_Right:
475 mediaPlayerState->setNext(); 475 mediaPlayerState->setNext();
476 break; 476 break;
477 case Key_Left: 477 case Key_Left:
478 mediaPlayerState->setPrev(); 478 mediaPlayerState->setPrev();
479 break; 479 break;
480 case Key_Escape: 480 case Key_Escape:
481#if defined(QT_QWS_IPAQ)
482 if( mediaPlayerState->isPaused ) {
483 setToggleButton( i, FALSE );
484 mediaPlayerState->setPaused( FALSE );
485 } else if( !mediaPlayerState->isPaused ) {
486 setToggleButton( i, TRUE );
487 mediaPlayerState->setPaused( TRUE );
488 }
489#endif
481 break; 490 break;
482 491
483 }; 492 };
484} 493}
485 494
486XineVideoWidget* VideoWidget::vidWidget() { 495XineVideoWidget* VideoWidget::vidWidget() {
487 return videoFrame; 496 return videoFrame;
488} 497}
489 498
490 499
491void VideoWidget::setFullscreen ( bool b ) { 500void VideoWidget::setFullscreen ( bool b ) {
492 setToggleButton( VideoFullscreen, b ); 501 setToggleButton( VideoFullscreen, b );
493} 502}
494 503
495 504
496void VideoWidget::setPlaying( bool b) { 505void VideoWidget::setPlaying( bool b) {
497 setToggleButton( VideoPlay, b ); 506 setToggleButton( VideoPlay, b );
498} 507}
499 508