Diffstat (limited to 'core/multimedia/opieplayer/videowidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/videowidget.cpp | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp index be838c4..bb5f9e8 100644 --- a/core/multimedia/opieplayer/videowidget.cpp +++ b/core/multimedia/opieplayer/videowidget.cpp | |||
@@ -182,97 +182,97 @@ void VideoWidget::paintButton( QPainter *p, int i ) { | |||
182 | } | 182 | } |
183 | 183 | ||
184 | 184 | ||
185 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 185 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
186 | for ( int i = 0; i < numButtons; i++ ) { | 186 | for ( int i = 0; i < numButtons; i++ ) { |
187 | int x = videoButtons[i].xPos; | 187 | int x = videoButtons[i].xPos; |
188 | int y = videoButtons[i].yPos; | 188 | int y = videoButtons[i].yPos; |
189 | if ( event->state() == QMouseEvent::LeftButton ) { | 189 | if ( event->state() == QMouseEvent::LeftButton ) { |
190 | // The test to see if the mouse click is inside the circular button or not | 190 | // The test to see if the mouse click is inside the circular button or not |
191 | // (compared with the radius squared to avoid a square-root of our distance) | 191 | // (compared with the radius squared to avoid a square-root of our distance) |
192 | int radius = 16; | 192 | int radius = 16; |
193 | QPoint center = QPoint( x + radius, y + radius ); | 193 | QPoint center = QPoint( x + radius, y + radius ); |
194 | QPoint dXY = center - event->pos(); | 194 | QPoint dXY = center - event->pos(); |
195 | int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); | 195 | int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); |
196 | bool isOnButton = dist <= (radius * radius); | 196 | bool isOnButton = dist <= (radius * radius); |
197 | if ( isOnButton != videoButtons[i].isHeld ) { | 197 | if ( isOnButton != videoButtons[i].isHeld ) { |
198 | videoButtons[i].isHeld = isOnButton; | 198 | videoButtons[i].isHeld = isOnButton; |
199 | toggleButton(i); | 199 | toggleButton(i); |
200 | } | 200 | } |
201 | } else { | 201 | } else { |
202 | if ( videoButtons[i].isHeld ) { | 202 | if ( videoButtons[i].isHeld ) { |
203 | videoButtons[i].isHeld = FALSE; | 203 | videoButtons[i].isHeld = FALSE; |
204 | if ( !videoButtons[i].isToggle ) | 204 | if ( !videoButtons[i].isToggle ) |
205 | setToggleButton( i, FALSE ); | 205 | setToggleButton( i, FALSE ); |
206 | switch (i) { | 206 | switch (i) { |
207 | case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; | 207 | case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; |
208 | case VideoStop: mediaPlayerState->setPlaying(FALSE); return; | 208 | case VideoStop: mediaPlayerState->setPlaying(FALSE); return; |
209 | case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; | 209 | case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; |
210 | case VideoNext: mediaPlayerState->setNext(); return; | 210 | case VideoNext: mediaPlayerState->setNext(); return; |
211 | case VideoPrevious: mediaPlayerState->setPrev(); return; | 211 | case VideoPrevious: mediaPlayerState->setPrev(); return; |
212 | case VideoPlayList: mediaPlayerState->setList(); return; | 212 | case VideoPlayList: mediaPlayerState->setList(); return; |
213 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | 213 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; |
214 | } | 214 | } |
215 | } | 215 | } |
216 | } | 216 | } |
217 | } | 217 | } |
218 | } | 218 | } |
219 | 219 | ||
220 | 220 | ||
221 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { | 221 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { |
222 | mouseMoveEvent( event ); | 222 | mouseMoveEvent( event ); |
223 | } | 223 | } |
224 | 224 | ||
225 | 225 | ||
226 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 226 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
227 | if ( mediaPlayerState->fullscreen() ) { | 227 | if ( mediaPlayerState->fullscreen() ) { |
228 | mediaPlayerState->setFullscreen( FALSE ); | 228 | mediaPlayerState->setFullscreen( FALSE ); |
229 | makeVisible(); | 229 | makeVisible(); |
230 | } else { | 230 | |
231 | mouseMoveEvent( event ); | 231 | mouseMoveEvent( event ); |
232 | } | 232 | } |
233 | } | 233 | } |
234 | 234 | ||
235 | 235 | ||
236 | void VideoWidget::makeVisible() { | 236 | void VideoWidget::makeVisible() { |
237 | if ( mediaPlayerState->fullscreen() ) { | 237 | if ( mediaPlayerState->fullscreen() ) { |
238 | setBackgroundMode( QWidget::NoBackground ); | 238 | setBackgroundMode( QWidget::NoBackground ); |
239 | showFullScreen(); | 239 | showFullScreen(); |
240 | resize( qApp->desktop()->size() ); | 240 | resize( qApp->desktop()->size() ); |
241 | slider->hide(); | 241 | slider->hide(); |
242 | } else { | 242 | } else { |
243 | setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); | 243 | setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); |
244 | showNormal(); | 244 | showNormal(); |
245 | showMaximized(); | 245 | showMaximized(); |
246 | slider->show(); | 246 | slider->show(); |
247 | } | 247 | } |
248 | } | 248 | } |
249 | 249 | ||
250 | 250 | ||
251 | void VideoWidget::paintEvent( QPaintEvent * ) { | 251 | void VideoWidget::paintEvent( QPaintEvent * ) { |
252 | QPainter p( this ); | 252 | QPainter p( this ); |
253 | 253 | ||
254 | if ( mediaPlayerState->fullscreen() ) { | 254 | if ( mediaPlayerState->fullscreen() ) { |
255 | // Clear the background | 255 | // Clear the background |
256 | p.setBrush( QBrush( Qt::black ) ); | 256 | p.setBrush( QBrush( Qt::black ) ); |
257 | p.drawRect( rect() ); | 257 | p.drawRect( rect() ); |
258 | 258 | ||
259 | // Draw the current frame | 259 | // Draw the current frame |
260 | //p.drawImage( ); // If using directpainter we won't have a copy except whats on the screen | 260 | //p.drawImage( ); // If using directpainter we won't have a copy except whats on the screen |
261 | } else { | 261 | } else { |
262 | // draw border | 262 | // draw border |
263 | qDrawShadePanel( &p, 4, 15, 230, 170, colorGroup(), TRUE, 5, NULL ); | 263 | qDrawShadePanel( &p, 4, 15, 230, 170, colorGroup(), TRUE, 5, NULL ); |
264 | 264 | ||
265 | // Clear the movie screen first | 265 | // Clear the movie screen first |
266 | p.setBrush( QBrush( Qt::black ) ); | 266 | p.setBrush( QBrush( Qt::black ) ); |
267 | p.drawRect( 9, 20, 220, 160 ); | 267 | p.drawRect( 9, 20, 220, 160 ); |
268 | 268 | ||
269 | // draw current frame (centrally positioned from scaling to maintain aspect ratio) | 269 | // draw current frame (centrally positioned from scaling to maintain aspect ratio) |
270 | p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); | 270 | p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); |
271 | 271 | ||
272 | // draw the buttons | 272 | // draw the buttons |
273 | for ( int i = 0; i < numButtons; i++ ) | 273 | for ( int i = 0; i < numButtons; i++ ) |
274 | paintButton( &p, i ); | 274 | paintButton( &p, i ); |
275 | 275 | ||
276 | // draw the slider | 276 | // draw the slider |
277 | slider->repaint( TRUE ); | 277 | slider->repaint( TRUE ); |
278 | } | 278 | } |
@@ -376,48 +376,96 @@ bool VideoWidget::playVideo() { | |||
376 | } else { | 376 | } else { |
377 | ulong* lout = ((ulong *)out)++ + (w - 1)*spl; | 377 | ulong* lout = ((ulong *)out)++ + (w - 1)*spl; |
378 | for (int y=0; y<w; y++) { | 378 | for (int y=0; y<w; y++) { |
379 | *lout=*((ulong*)in)++; | 379 | *lout=*((ulong*)in)++; |
380 | lout-=spl; | 380 | lout-=spl; |
381 | } | 381 | } |
382 | } | 382 | } |
383 | } | 383 | } |
384 | 384 | ||
385 | p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh ); | 385 | p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh ); |
386 | } | 386 | } |
387 | #ifdef USE_DIRECT_PAINTER | 387 | #ifdef USE_DIRECT_PAINTER |
388 | } | 388 | } |
389 | #endif | 389 | #endif |
390 | } else { | 390 | } else { |
391 | 391 | ||
392 | w = 220; | 392 | w = 220; |
393 | h = 160; | 393 | h = 160; |
394 | 394 | ||
395 | // maintain aspect ratio | 395 | // maintain aspect ratio |
396 | if ( w * sh > sw * h ) | 396 | if ( w * sh > sw * h ) |
397 | w = sw * h / sh; | 397 | w = sw * h / sh; |
398 | else | 398 | else |
399 | h = sh * w / sw; | 399 | h = sh * w / sw; |
400 | 400 | ||
401 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0; | 401 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0; |
402 | 402 | ||
403 | QPainter p( this ); | 403 | QPainter p( this ); |
404 | 404 | ||
405 | // Image changed size, therefore need to blank the possibly unpainted regions first | 405 | // Image changed size, therefore need to blank the possibly unpainted regions first |
406 | if ( scaledWidth != w || scaledHeight != h ) { | 406 | if ( scaledWidth != w || scaledHeight != h ) { |
407 | p.setBrush( QBrush( Qt::black ) ); | 407 | p.setBrush( QBrush( Qt::black ) ); |
408 | p.drawRect( 9, 20, 220, 160 ); | 408 | p.drawRect( 9, 20, 220, 160 ); |
409 | } | 409 | } |
410 | 410 | ||
411 | scaledWidth = w; | 411 | scaledWidth = w; |
412 | scaledHeight = h; | 412 | scaledHeight = h; |
413 | 413 | ||
414 | if ( result ) { | 414 | if ( result ) { |
415 | p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); | 415 | p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); |
416 | } | 416 | } |
417 | 417 | ||
418 | } | 418 | } |
419 | 419 | ||
420 | return result; | 420 | return result; |
421 | } | 421 | } |
422 | 422 | ||
423 | 423 | ||
424 | |||
425 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) | ||
426 | { | ||
427 | switch ( e->key() ) { | ||
428 | ////////////////////////////// Zaurus keys | ||
429 | case Key_Home: | ||
430 | break; | ||
431 | case Key_F9: //activity | ||
432 | break; | ||
433 | case Key_F10: //contacts | ||
434 | break; | ||
435 | case Key_F11: //menu | ||
436 | break; | ||
437 | case Key_F12: //home | ||
438 | break; | ||
439 | case Key_F13: //mail | ||
440 | break; | ||
441 | case Key_Space: { | ||
442 | if(mediaPlayerState->playing()) { | ||
443 | mediaPlayerState->setPlaying(FALSE); | ||
444 | } else { | ||
445 | mediaPlayerState->setPlaying(TRUE); | ||
446 | } | ||
447 | } | ||
448 | break; | ||
449 | case Key_Down: | ||
450 | // toggleButton(6); | ||
451 | // emit lessClicked(); | ||
452 | // emit lessReleased(); | ||
453 | // toggleButton(6); | ||
454 | break; | ||
455 | case Key_Up: | ||
456 | // toggleButton(5); | ||
457 | // emit moreClicked(); | ||
458 | // emit moreReleased(); | ||
459 | // toggleButton(5); | ||
460 | break; | ||
461 | case Key_Right: | ||
462 | mediaPlayerState->setNext(); | ||
463 | break; | ||
464 | case Key_Left: | ||
465 | mediaPlayerState->setPrev(); | ||
466 | break; | ||
467 | case Key_Escape: | ||
468 | break; | ||
469 | |||
470 | }; | ||
471 | } | ||