author | simon <simon> | 2002-12-09 15:10:48 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-09 15:10:48 (UTC) |
commit | 80902b6ade54252e05cf948040a11b2e975f6759 (patch) (unidiff) | |
tree | d251490e8e1e83af1cd8522736cc02a772463f0f /noncore/multimedia/opieplayer2/videowidget.cpp | |
parent | e487238141c57df63252e41a47b409cbb1f9ae83 (diff) | |
download | opie-80902b6ade54252e05cf948040a11b2e975f6759.zip opie-80902b6ade54252e05cf948040a11b2e975f6759.tar.gz opie-80902b6ade54252e05cf948040a11b2e975f6759.tar.bz2 |
- paintButton is no more a duplicated method but centralized in the
base class now :)
Diffstat (limited to 'noncore/multimedia/opieplayer2/videowidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 3baa087..a483434 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -227,59 +227,48 @@ void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) | |||
227 | 227 | ||
228 | void VideoWidget::updateSlider( long i, long max ) { | 228 | void VideoWidget::updateSlider( long i, long max ) { |
229 | // Will flicker too much if we don't do this | 229 | // Will flicker too much if we don't do this |
230 | if ( max == 0 ) { | 230 | if ( max == 0 ) { |
231 | return; | 231 | return; |
232 | } | 232 | } |
233 | int width = slider->width(); | 233 | int width = slider->width(); |
234 | int val = int((double)i * width / max); | 234 | int val = int((double)i * width / max); |
235 | if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { | 235 | if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { |
236 | if ( slider->value() != val ) { | 236 | if ( slider->value() != val ) { |
237 | slider->setValue( val ); | 237 | slider->setValue( val ); |
238 | } | 238 | } |
239 | if ( slider->maxValue() != width ) { | 239 | if ( slider->maxValue() != width ) { |
240 | slider->setMaxValue( width ); | 240 | slider->setMaxValue( width ); |
241 | } | 241 | } |
242 | } | 242 | } |
243 | } | 243 | } |
244 | 244 | ||
245 | void VideoWidget::setToggleButton( int i, bool down ) { | 245 | void VideoWidget::setToggleButton( int i, bool down ) { |
246 | if ( down != buttons[i].isDown ) { | 246 | if ( down != buttons[i].isDown ) { |
247 | toggleButton( i ); | 247 | toggleButton( i ); |
248 | } | 248 | } |
249 | } | 249 | } |
250 | 250 | ||
251 | void VideoWidget::paintButton( QPainter &p, int i ) { | ||
252 | |||
253 | Button &button = buttons[ i ]; | ||
254 | |||
255 | if ( button.isDown ) { | ||
256 | p.drawPixmap( upperLeftOfButtonMask, button.pixDown ); | ||
257 | } else { | ||
258 | p.drawPixmap( upperLeftOfButtonMask, button.pixUp ); | ||
259 | } | ||
260 | } | ||
261 | |||
262 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 251 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
263 | for ( unsigned int i = 0; i < buttons.count(); i++ ) { | 252 | for ( unsigned int i = 0; i < buttons.count(); i++ ) { |
264 | if ( event->state() == QMouseEvent::LeftButton ) { | 253 | if ( event->state() == QMouseEvent::LeftButton ) { |
265 | // The test to see if the mouse click is inside the button or not | 254 | // The test to see if the mouse click is inside the button or not |
266 | bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); | 255 | bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); |
267 | 256 | ||
268 | if ( isOnButton && !buttons[i].isHeld ) { | 257 | if ( isOnButton && !buttons[i].isHeld ) { |
269 | buttons[i].isHeld = TRUE; | 258 | buttons[i].isHeld = TRUE; |
270 | toggleButton(i); | 259 | toggleButton(i); |
271 | 260 | ||
272 | switch (i) { | 261 | switch (i) { |
273 | case VideoVolUp: | 262 | case VideoVolUp: |
274 | emit moreClicked(); | 263 | emit moreClicked(); |
275 | return; | 264 | return; |
276 | case VideoVolDown: | 265 | case VideoVolDown: |
277 | emit lessClicked(); | 266 | emit lessClicked(); |
278 | return; | 267 | return; |
279 | } | 268 | } |
280 | } else if ( !isOnButton && buttons[i].isHeld ) { | 269 | } else if ( !isOnButton && buttons[i].isHeld ) { |
281 | buttons[i].isHeld = FALSE; | 270 | buttons[i].isHeld = FALSE; |
282 | toggleButton(i); | 271 | toggleButton(i); |
283 | } | 272 | } |
284 | } else { | 273 | } else { |
285 | 274 | ||
@@ -382,56 +371,56 @@ void VideoWidget::makeVisible() { | |||
382 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 371 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
383 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 372 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
384 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 373 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
385 | } | 374 | } |
386 | } | 375 | } |
387 | } | 376 | } |
388 | 377 | ||
389 | 378 | ||
390 | 379 | ||
391 | 380 | ||
392 | void VideoWidget::paintEvent( QPaintEvent * pe) { | 381 | void VideoWidget::paintEvent( QPaintEvent * pe) { |
393 | QPainter p( this ); | 382 | QPainter p( this ); |
394 | 383 | ||
395 | if ( mediaPlayerState.isFullscreen() ) { | 384 | if ( mediaPlayerState.isFullscreen() ) { |
396 | // Clear the background | 385 | // Clear the background |
397 | p.setBrush( QBrush( Qt::black ) ); | 386 | p.setBrush( QBrush( Qt::black ) ); |
398 | } else { | 387 | } else { |
399 | if ( !pe->erased() ) { | 388 | if ( !pe->erased() ) { |
400 | // Combine with background and double buffer | 389 | // Combine with background and double buffer |
401 | QPixmap pix( pe->rect().size() ); | 390 | QPixmap pix( pe->rect().size() ); |
402 | QPainter p( &pix ); | 391 | QPainter p( &pix ); |
403 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 392 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
404 | p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); | 393 | p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); |
405 | for ( unsigned int i = 0; i < buttons.count(); i++ ) { | 394 | for ( unsigned int i = 0; i < buttons.count(); i++ ) { |
406 | paintButton( p, i ); | 395 | paintButton( p, buttons[ i ] ); |
407 | } | 396 | } |
408 | QPainter p2( this ); | 397 | QPainter p2( this ); |
409 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 398 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
410 | } else { | 399 | } else { |
411 | QPainter p( this ); | 400 | QPainter p( this ); |
412 | for ( unsigned int i = 0; i < buttons.count(); i++ ) | 401 | for ( unsigned int i = 0; i < buttons.count(); i++ ) |
413 | paintButton( p, i ); | 402 | paintButton( p, buttons[ i ] ); |
414 | } | 403 | } |
415 | //slider->repaint( TRUE ); | 404 | //slider->repaint( TRUE ); |
416 | } | 405 | } |
417 | } | 406 | } |
418 | 407 | ||
419 | 408 | ||
420 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { | 409 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { |
421 | switch ( e->key() ) { | 410 | switch ( e->key() ) { |
422 | ////////////////////////////// Zaurus keys | 411 | ////////////////////////////// Zaurus keys |
423 | case Key_Home: | 412 | case Key_Home: |
424 | break; | 413 | break; |
425 | case Key_F9: //activity | 414 | case Key_F9: //activity |
426 | break; | 415 | break; |
427 | case Key_F10: //contacts | 416 | case Key_F10: //contacts |
428 | // hide(); | 417 | // hide(); |
429 | break; | 418 | break; |
430 | case Key_F11: //menu | 419 | case Key_F11: //menu |
431 | break; | 420 | break; |
432 | case Key_F12: //home | 421 | case Key_F12: //home |
433 | break; | 422 | break; |
434 | case Key_F13: //mail | 423 | case Key_F13: //mail |
435 | break; | 424 | break; |
436 | case Key_Space: { | 425 | case Key_Space: { |
437 | if(mediaPlayerState.isPlaying()) { | 426 | if(mediaPlayerState.isPlaying()) { |