summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-08-15 16:42:08 (UTC)
committer llornkcor <llornkcor>2002-08-15 16:42:08 (UTC)
commit71520dfe386a04f8bce5d6f5d9d86dcbeda000d2 (patch) (unidiff)
tree78a284abbce1cc1da57b78f39e9e47fe5271cc1c
parent07ea5f165a2f17f818147b2e8afb02af2c269b55 (diff)
downloadopie-71520dfe386a04f8bce5d6f5d9d86dcbeda000d2.zip
opie-71520dfe386a04f8bce5d6f5d9d86dcbeda000d2.tar.gz
opie-71520dfe386a04f8bce5d6f5d9d86dcbeda000d2.tar.bz2
fix rightmouse hold
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp8
1 files changed, 1 insertions, 7 deletions
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index fbcd775..f5780aa 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -193,320 +193,314 @@ void VideoWidget::resizeEvent( QResizeEvent * ) {
193 193
194 xoff = 0;// ( imgUp->width() ) / 2; 194 xoff = 0;// ( imgUp->width() ) / 2;
195 yoff = 180;//(( Vh - imgUp->height() ) / 2) - 10; 195 yoff = 180;//(( Vh - imgUp->height() ) / 2) - 10;
196 QPoint p( xoff, yoff ); 196 QPoint p( xoff, yoff );
197 197
198 198
199 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); 199 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p );
200 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); 200 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p );
201 201
202 for ( int i = 0; i < 7; i++ ) { 202 for ( int i = 0; i < 7; i++ ) {
203 if ( !masks[i]->isNull() ) { 203 if ( !masks[i]->isNull() ) {
204 delete buttonPixUp[i]; 204 delete buttonPixUp[i];
205 delete buttonPixDown[i]; 205 delete buttonPixDown[i];
206 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); 206 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] );
207 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); 207 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] );
208 } 208 }
209 } 209 }
210 210
211 delete pixUp; 211 delete pixUp;
212 delete pixDn; 212 delete pixDn;
213} 213}
214 214
215static bool videoSliderBeingMoved = FALSE; 215static bool videoSliderBeingMoved = FALSE;
216 216
217void VideoWidget::sliderPressed() { 217void VideoWidget::sliderPressed() {
218 videoSliderBeingMoved = TRUE; 218 videoSliderBeingMoved = TRUE;
219} 219}
220 220
221void VideoWidget::sliderReleased() { 221void VideoWidget::sliderReleased() {
222 videoSliderBeingMoved = FALSE; 222 videoSliderBeingMoved = FALSE;
223 if ( slider->width() == 0 ) { 223 if ( slider->width() == 0 ) {
224 return; 224 return;
225 } 225 }
226 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); 226 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width());
227 mediaPlayerState->setPosition( val ); 227 mediaPlayerState->setPosition( val );
228} 228}
229 229
230void VideoWidget::setPosition( long i ) { 230void VideoWidget::setPosition( long i ) {
231 updateSlider( i, mediaPlayerState->length() ); 231 updateSlider( i, mediaPlayerState->length() );
232} 232}
233 233
234 234
235void VideoWidget::setLength( long max ) { 235void VideoWidget::setLength( long max ) {
236 updateSlider( mediaPlayerState->position(), max ); 236 updateSlider( mediaPlayerState->position(), max );
237} 237}
238 238
239void VideoWidget::setView( char view ) { 239void VideoWidget::setView( char view ) {
240 240
241 if ( mediaPlayerState->streaming() ) { 241 if ( mediaPlayerState->streaming() ) {
242 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); 242 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>");
243 if( !slider->isHidden()) { 243 if( !slider->isHidden()) {
244 slider->hide(); 244 slider->hide();
245 } 245 }
246 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 246 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
247 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 247 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
248 } else { 248 } else {
249 // this stops the slider from being moved, thus 249 // this stops the slider from being moved, thus
250 // does not stop stream when it reaches the end 250 // does not stop stream when it reaches the end
251 slider->show(); 251 slider->show();
252 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 252 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
253 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 253 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
254 } 254 }
255 255
256 if ( view == 'v' ) { 256 if ( view == 'v' ) {
257 makeVisible(); 257 makeVisible();
258 } else { 258 } else {
259 // Effectively blank the view next time we show it so it looks nicer 259 // Effectively blank the view next time we show it so it looks nicer
260 scaledWidth = 0; 260 scaledWidth = 0;
261 scaledHeight = 0; 261 scaledHeight = 0;
262 hide(); 262 hide();
263 } 263 }
264} 264}
265 265
266void VideoWidget::updateSlider( long i, long max ) { 266void VideoWidget::updateSlider( long i, long max ) {
267 // Will flicker too much if we don't do this 267 // Will flicker too much if we don't do this
268 if ( max == 0 ) { 268 if ( max == 0 ) {
269 return; 269 return;
270 } 270 }
271 int width = slider->width(); 271 int width = slider->width();
272 int val = int((double)i * width / max); 272 int val = int((double)i * width / max);
273 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { 273 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) {
274 if ( slider->value() != val ) { 274 if ( slider->value() != val ) {
275 slider->setValue( val ); 275 slider->setValue( val );
276 } 276 }
277 if ( slider->maxValue() != width ) { 277 if ( slider->maxValue() != width ) {
278 slider->setMaxValue( width ); 278 slider->setMaxValue( width );
279 } 279 }
280 } 280 }
281} 281}
282 282
283void VideoWidget::setToggleButton( int i, bool down ) { 283void VideoWidget::setToggleButton( int i, bool down ) {
284 if ( down != videoButtons[i].isDown ) { 284 if ( down != videoButtons[i].isDown ) {
285 toggleButton( i ); 285 toggleButton( i );
286 } 286 }
287} 287}
288 288
289void VideoWidget::toggleButton( int i ) { 289void VideoWidget::toggleButton( int i ) {
290 videoButtons[i].isDown = !videoButtons[i].isDown; 290 videoButtons[i].isDown = !videoButtons[i].isDown;
291 QPainter p(this); 291 QPainter p(this);
292 paintButton ( &p, i ); 292 paintButton ( &p, i );
293} 293}
294 294
295void VideoWidget::paintButton( QPainter *p, int i ) { 295void VideoWidget::paintButton( QPainter *p, int i ) {
296 296
297 if ( videoButtons[i].isDown ) { 297 if ( videoButtons[i].isDown ) {
298 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 298 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
299 } else { 299 } else {
300 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 300 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
301 } 301 }
302} 302}
303 303
304void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 304void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
305 for ( int i = 0; i < numVButtons; i++ ) { 305 for ( int i = 0; i < numVButtons; i++ ) {
306 if ( event->state() == QMouseEvent::LeftButton ) { 306 if ( event->state() == QMouseEvent::LeftButton ) {
307 // The test to see if the mouse click is inside the button or not 307 // The test to see if the mouse click is inside the button or not
308 int x = event->pos().x() - xoff; 308 int x = event->pos().x() - xoff;
309 int y = event->pos().y() - yoff; 309 int y = event->pos().y() - yoff;
310 310
311 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() 311 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
312 && y < imgButtonMask->height() 312 && y < imgButtonMask->height()
313 && imgButtonMask->pixelIndex( x, y ) == i + 1 ); 313 && imgButtonMask->pixelIndex( x, y ) == i + 1 );
314 314
315 if ( isOnButton && !videoButtons[i].isHeld ) { 315 if ( isOnButton && !videoButtons[i].isHeld ) {
316 videoButtons[i].isHeld = TRUE; 316 videoButtons[i].isHeld = TRUE;
317 toggleButton(i); 317 toggleButton(i);
318 318
319 switch (i) { 319 switch (i) {
320 case VideoVolUp: 320 case VideoVolUp:
321 qDebug("more clicked");
322 emit moreClicked(); 321 emit moreClicked();
323 return; 322 return;
324 case VideoVolDown: 323 case VideoVolDown:
325 qDebug("less clicked");
326 emit lessClicked(); 324 emit lessClicked();
327 return; 325 return;
328 } 326 }
329 } else if ( !isOnButton && videoButtons[i].isHeld ) { 327 } else if ( !isOnButton && videoButtons[i].isHeld ) {
330 videoButtons[i].isHeld = FALSE; 328 videoButtons[i].isHeld = FALSE;
331 toggleButton(i); 329 toggleButton(i);
332 } 330 }
333 } else { 331 } else {
334 332
335 if ( videoButtons[i].isHeld ) { 333 if ( videoButtons[i].isHeld ) {
336 videoButtons[i].isHeld = FALSE; 334 videoButtons[i].isHeld = FALSE;
337 if ( !videoButtons[i].isToggle ) { 335 if ( !videoButtons[i].isToggle ) {
338 setToggleButton( i, FALSE ); 336 setToggleButton( i, FALSE );
339 qDebug("button toggled3 %d",i);
340 } 337 }
341 338
342 switch(i) { 339 switch(i) {
343 340
344 case VideoPlay: { 341 case VideoPlay: {
345 if( mediaPlayerState->isPaused ) { 342 if( mediaPlayerState->isPaused ) {
346 qDebug("play again clicked");
347 setToggleButton( i, FALSE ); 343 setToggleButton( i, FALSE );
348 mediaPlayerState->setPaused( FALSE ); 344 mediaPlayerState->setPaused( FALSE );
349 return; 345 return;
350 } else if( !mediaPlayerState->isPaused ) { 346 } else if( !mediaPlayerState->isPaused ) {
351 qDebug("pause now clicked");
352 setToggleButton( i, TRUE ); 347 setToggleButton( i, TRUE );
353 mediaPlayerState->setPaused( TRUE ); 348 mediaPlayerState->setPaused( TRUE );
354 return; 349 return;
355 } else { 350 } else {
356 // setToggleButton( i, TRUE ); 351 // setToggleButton( i, TRUE );
357 // mediaPlayerState->setPlaying( videoButtons[i].isDown ); 352 // mediaPlayerState->setPlaying( videoButtons[i].isDown );
358 } 353 }
359 } 354 }
360 355
361 case VideoStop: mediaPlayerState->setPlaying( FALSE ); return; 356 case VideoStop: mediaPlayerState->setPlaying( FALSE ); return;
362// case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; 357// case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return;
363 case VideoNext: mediaPlayerState->setNext(); return; 358 case VideoNext: mediaPlayerState->setNext(); return;
364 case VideoPrevious: mediaPlayerState->setPrev(); return; 359 case VideoPrevious: mediaPlayerState->setPrev(); return;
365 case VideoVolUp: emit moreReleased(); return; 360 case VideoVolUp: emit moreReleased(); return;
366 case VideoVolDown: emit lessReleased(); return; 361 case VideoVolDown: emit lessReleased(); return;
367 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; 362 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
368 } 363 }
369 } 364 }
370 } 365 }
371 } 366 }
372} 367}
373 368
374void VideoWidget::mousePressEvent( QMouseEvent *event ) { 369void VideoWidget::mousePressEvent( QMouseEvent *event ) {
375 mouseMoveEvent( event ); 370 mouseMoveEvent( event );
376} 371}
377 372
378void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 373void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
379 if ( mediaPlayerState->fullscreen() ) { 374 if ( mediaPlayerState->fullscreen() ) {
380 mediaPlayerState->setFullscreen( FALSE ); 375 mediaPlayerState->setFullscreen( FALSE );
381 makeVisible(); 376 makeVisible();
382
383 mouseMoveEvent( event );
384 } 377 }
378 mouseMoveEvent( event );
385} 379}
386 380
387void VideoWidget::showEvent( QShowEvent* ) { 381void VideoWidget::showEvent( QShowEvent* ) {
388 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 382 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
389 mouseMoveEvent( &event ); 383 mouseMoveEvent( &event );
390} 384}
391 385
392 386
393void VideoWidget::makeVisible() { 387void VideoWidget::makeVisible() {
394 if ( mediaPlayerState->fullscreen() ) { 388 if ( mediaPlayerState->fullscreen() ) {
395 setBackgroundMode( QWidget::NoBackground ); 389 setBackgroundMode( QWidget::NoBackground );
396 showFullScreen(); 390 showFullScreen();
397 resize( qApp->desktop()->size() ); 391 resize( qApp->desktop()->size() );
398 slider->hide(); 392 slider->hide();
399 videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); 393 videoFrame-> setGeometry ( 0, 0, width ( ), height ( ));
400 } else { 394 } else {
401 showNormal(); 395 showNormal();
402 showMaximized(); 396 showMaximized();
403 slider->show(); 397 slider->show();
404 videoFrame->setGeometry( QRect( 10, 20, 220, 160 ) ); 398 videoFrame->setGeometry( QRect( 10, 20, 220, 160 ) );
405 qApp->processEvents(); 399 qApp->processEvents();
406 } 400 }
407} 401}
408 402
409 403
410void VideoWidget::paintEvent( QPaintEvent * pe) { 404void VideoWidget::paintEvent( QPaintEvent * pe) {
411 QPainter p( this ); 405 QPainter p( this );
412 406
413 if ( mediaPlayerState->fullscreen() ) { 407 if ( mediaPlayerState->fullscreen() ) {
414 // Clear the background 408 // Clear the background
415 p.setBrush( QBrush( Qt::black ) ); 409 p.setBrush( QBrush( Qt::black ) );
416 // videoFrame->setGeometry( QRect( 0, 0 , 240 ,320 ) ); 410 // videoFrame->setGeometry( QRect( 0, 0 , 240 ,320 ) );
417 411
418 } else { 412 } else {
419 413
420 // videoFrame->setGeometry( QRect( 0, 15 , 240 ,170 ) ); 414 // videoFrame->setGeometry( QRect( 0, 15 , 240 ,170 ) );
421 // draw the buttons 415 // draw the buttons
422 416
423 if ( !pe->erased() ) { 417 if ( !pe->erased() ) {
424 // Combine with background and double buffer 418 // Combine with background and double buffer
425 QPixmap pix( pe->rect().size() ); 419 QPixmap pix( pe->rect().size() );
426 QPainter p( &pix ); 420 QPainter p( &pix );
427 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 421 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
428 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); 422 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
429 for ( int i = 0; i < numVButtons; i++ ) { 423 for ( int i = 0; i < numVButtons; i++ ) {
430 paintButton( &p, i ); 424 paintButton( &p, i );
431 } 425 }
432 QPainter p2( this ); 426 QPainter p2( this );
433 p2.drawPixmap( pe->rect().topLeft(), pix ); 427 p2.drawPixmap( pe->rect().topLeft(), pix );
434 } else { 428 } else {
435 QPainter p( this ); 429 QPainter p( this );
436 for ( int i = 0; i < numVButtons; i++ ) 430 for ( int i = 0; i < numVButtons; i++ )
437 paintButton( &p, i ); 431 paintButton( &p, i );
438 } 432 }
439 // for ( int i = 0; i < numButtons; i++ ) { 433 // for ( int i = 0; i < numButtons; i++ ) {
440 // paintButton( &p, i ); 434 // paintButton( &p, i );
441 // } 435 // }
442 // draw the slider 436 // draw the slider
443 slider->repaint( TRUE ); 437 slider->repaint( TRUE );
444 } 438 }
445} 439}
446 440
447 441
448void VideoWidget::closeEvent( QCloseEvent* ) { 442void VideoWidget::closeEvent( QCloseEvent* ) {
449 mediaPlayerState->setList(); 443 mediaPlayerState->setList();
450} 444}
451 445
452 446
453 447
454void VideoWidget::keyReleaseEvent( QKeyEvent *e) { 448void VideoWidget::keyReleaseEvent( QKeyEvent *e) {
455 switch ( e->key() ) { 449 switch ( e->key() ) {
456////////////////////////////// Zaurus keys 450////////////////////////////// Zaurus keys
457 case Key_Home: 451 case Key_Home:
458 break; 452 break;
459 case Key_F9: //activity 453 case Key_F9: //activity
460 break; 454 break;
461 case Key_F10: //contacts 455 case Key_F10: //contacts
462// hide(); 456// hide();
463 break; 457 break;
464 case Key_F11: //menu 458 case Key_F11: //menu
465 break; 459 break;
466 case Key_F12: //home 460 case Key_F12: //home
467 break; 461 break;
468 case Key_F13: //mail 462 case Key_F13: //mail
469 break; 463 break;
470 case Key_Space: { 464 case Key_Space: {
471 if(mediaPlayerState->playing()) { 465 if(mediaPlayerState->playing()) {
472 mediaPlayerState->setPlaying(FALSE); 466 mediaPlayerState->setPlaying(FALSE);
473 } else { 467 } else {
474 mediaPlayerState->setPlaying(TRUE); 468 mediaPlayerState->setPlaying(TRUE);
475 } 469 }
476 } 470 }
477 break; 471 break;
478 case Key_Down: 472 case Key_Down:
479// toggleButton(6); 473// toggleButton(6);
480// emit lessClicked(); 474// emit lessClicked();
481// emit lessReleased(); 475// emit lessReleased();
482// toggleButton(6); 476// toggleButton(6);
483 break; 477 break;
484 case Key_Up: 478 case Key_Up:
485// toggleButton(5); 479// toggleButton(5);
486// emit moreClicked(); 480// emit moreClicked();
487// emit moreReleased(); 481// emit moreReleased();
488// toggleButton(5); 482// toggleButton(5);
489 break; 483 break;
490 case Key_Right: 484 case Key_Right:
491 mediaPlayerState->setNext(); 485 mediaPlayerState->setNext();
492 break; 486 break;
493 case Key_Left: 487 case Key_Left:
494 mediaPlayerState->setPrev(); 488 mediaPlayerState->setPrev();
495 break; 489 break;
496 case Key_Escape: 490 case Key_Escape:
497 break; 491 break;
498 492
499 }; 493 };
500} 494}
501 495
502XineVideoWidget* VideoWidget::vidWidget() { 496XineVideoWidget* VideoWidget::vidWidget() {
503 return videoFrame; 497 return videoFrame;
504} 498}
505 499
506 500
507void VideoWidget::setFullscreen ( bool b ) { 501void VideoWidget::setFullscreen ( bool b ) {
508 setToggleButton( VideoFullscreen, b ); 502 setToggleButton( VideoFullscreen, b );
509} 503}
510 504
511void VideoWidget::setPaused( bool b) { 505void VideoWidget::setPaused( bool b) {
512// setToggleButton( VideoPause, b ); 506// setToggleButton( VideoPause, b );