summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/videowidget.cpp
Unidiff
Diffstat (limited to 'noncore/multimedia/opieplayer2/videowidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 7c20c6d..efd756c 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -50,47 +50,64 @@
50# define USE_DIRECT_PAINTER 50# define USE_DIRECT_PAINTER
51# include <qdirectpainter_qws.h> 51# include <qdirectpainter_qws.h>
52# include <qgfxraster_qws.h> 52# include <qgfxraster_qws.h>
53#endif 53#endif
54 54
55 55
56namespace 56namespace
57{ 57{
58 58
59const int xo = 2; // movable x offset 59const int xo = 2; // movable x offset
60const int yo = 0; // movable y offset 60const int yo = 0; // movable y offset
61 61
62/*
62MediaWidget::Button videoButtons[] = { 63MediaWidget::Button videoButtons[] = {
63 { FALSE, FALSE, FALSE }, // stop 64 { FALSE, FALSE, FALSE }, // stop
64 { TRUE, FALSE, FALSE }, // play 65 { TRUE, FALSE, FALSE }, // play
65 { FALSE, FALSE, FALSE }, // previous 66 { FALSE, FALSE, FALSE }, // previous
66 { FALSE, FALSE, FALSE }, // next 67 { FALSE, FALSE, FALSE }, // next
67 { FALSE, FALSE, FALSE }, // volUp 68 { FALSE, FALSE, FALSE }, // volUp
68 { FALSE, FALSE, FALSE }, // volDown 69 { FALSE, FALSE, FALSE }, // volDown
69 { TRUE, FALSE, FALSE } // fullscreen 70 { TRUE, FALSE, FALSE } // fullscreen
70}; 71};
72*/
71 73
72const char * const skinV_mask_file_names[7] = { 74const char * const skinV_mask_file_names[7] = {
73"stop","play","back","fwd","up","down","full" 75"stop","play","back","fwd","up","down","full"
74}; 76};
75 77
76const int numVButtons = (sizeof(videoButtons)/sizeof(MediaWidget::Button)); 78//const int numVButtons = (sizeof(videoButtons)/sizeof(MediaWidget::Button));
77 79
78} 80}
79 81
80VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) 82VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name )
81 : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) 83 : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 )
82{ 84{
83 setCaption( tr("OpiePlayer - Video") ); 85 setCaption( tr("OpiePlayer - Video") );
84 86
87 Button defaultButton;
88 defaultButton.isToggle = defaultButton.isHeld = defaultButton.isDown = false;
89 Button toggleButton;
90 toggleButton.isToggle = true;
91 toggleButton.isHeld = toggleButton.isDown = false;
92
93 videoButtons.reserve( 7 );
94 videoButtons.push_back( defaultButton ); // stop
95 videoButtons.push_back( toggleButton ); // play
96 videoButtons.push_back( defaultButton ); // previous
97 videoButtons.push_back( defaultButton ); // next
98 videoButtons.push_back( defaultButton ); // volUp
99 videoButtons.push_back( defaultButton ); // volDown
100 videoButtons.push_back( toggleButton ); //fullscreen
101
85 videoFrame = new XineVideoWidget ( this, "Video frame" ); 102 videoFrame = new XineVideoWidget ( this, "Video frame" );
86 103
87 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); 104 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & )));
88 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); 105 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) );
89 106
90 Config cfg("OpiePlayer"); 107 Config cfg("OpiePlayer");
91 cfg.setGroup("Options"); 108 cfg.setGroup("Options");
92 skin = cfg.readEntry("Skin","default"); 109 skin = cfg.readEntry("Skin","default");
93 110
94 QString skinPath = "opieplayer2/skins/" + skin; 111 QString skinPath = "opieplayer2/skins/" + skin;
95 pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 112 pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
96 imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); 113 imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) );
@@ -267,25 +284,25 @@ void VideoWidget::toggleButton( int i ) {
267} 284}
268 285
269void VideoWidget::paintButton( QPainter *p, int i ) { 286void VideoWidget::paintButton( QPainter *p, int i ) {
270 287
271 if ( videoButtons[i].isDown ) { 288 if ( videoButtons[i].isDown ) {
272 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 289 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
273 } else { 290 } else {
274 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 291 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
275 } 292 }
276} 293}
277 294
278void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 295void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
279 for ( int i = 0; i < numVButtons; i++ ) { 296 for ( unsigned int i = 0; i < videoButtons.size(); i++ ) {
280 if ( event->state() == QMouseEvent::LeftButton ) { 297 if ( event->state() == QMouseEvent::LeftButton ) {
281 // The test to see if the mouse click is inside the button or not 298 // The test to see if the mouse click is inside the button or not
282 int x = event->pos().x() - xoff; 299 int x = event->pos().x() - xoff;
283 int y = event->pos().y() - yoff; 300 int y = event->pos().y() - yoff;
284 301
285 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask.width() 302 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask.width()
286 && y < imgButtonMask.height() 303 && y < imgButtonMask.height()
287 && imgButtonMask.pixelIndex( x, y ) == i + 1 ); 304 && imgButtonMask.pixelIndex( x, y ) == i + 1 );
288 305
289 if ( isOnButton && !videoButtons[i].isHeld ) { 306 if ( isOnButton && !videoButtons[i].isHeld ) {
290 videoButtons[i].isHeld = TRUE; 307 videoButtons[i].isHeld = TRUE;
291 toggleButton(i); 308 toggleButton(i);
@@ -414,32 +431,32 @@ void VideoWidget::paintEvent( QPaintEvent * pe) {
414 QPainter p( this ); 431 QPainter p( this );
415 432
416 if ( mediaPlayerState.isFullscreen() ) { 433 if ( mediaPlayerState.isFullscreen() ) {
417 // Clear the background 434 // Clear the background
418 p.setBrush( QBrush( Qt::black ) ); 435 p.setBrush( QBrush( Qt::black ) );
419 } else { 436 } else {
420 if ( !pe->erased() ) { 437 if ( !pe->erased() ) {
421 // Combine with background and double buffer 438 // Combine with background and double buffer
422 QPixmap pix( pe->rect().size() ); 439 QPixmap pix( pe->rect().size() );
423 QPainter p( &pix ); 440 QPainter p( &pix );
424 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 441 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
425 p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); 442 p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() );
426 for ( int i = 0; i < numVButtons; i++ ) { 443 for ( unsigned int i = 0; i < videoButtons.size(); i++ ) {
427 paintButton( &p, i ); 444 paintButton( &p, i );
428 } 445 }
429 QPainter p2( this ); 446 QPainter p2( this );
430 p2.drawPixmap( pe->rect().topLeft(), pix ); 447 p2.drawPixmap( pe->rect().topLeft(), pix );
431 } else { 448 } else {
432 QPainter p( this ); 449 QPainter p( this );
433 for ( int i = 0; i < numVButtons; i++ ) 450 for ( unsigned int i = 0; i < videoButtons.size(); i++ )
434 paintButton( &p, i ); 451 paintButton( &p, i );
435 } 452 }
436 //slider->repaint( TRUE ); 453 //slider->repaint( TRUE );
437 } 454 }
438} 455}
439 456
440 457
441void VideoWidget::keyReleaseEvent( QKeyEvent *e) { 458void VideoWidget::keyReleaseEvent( QKeyEvent *e) {
442 switch ( e->key() ) { 459 switch ( e->key() ) {
443////////////////////////////// Zaurus keys 460////////////////////////////// Zaurus keys
444 case Key_Home: 461 case Key_Home:
445 break; 462 break;