-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 33153d4..b4e69b5 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -84,129 +84,129 @@ QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { | |||
84 | setCaption( tr("OpiePlayer - Video") ); | 84 | setCaption( tr("OpiePlayer - Video") ); |
85 | 85 | ||
86 | videoFrame = new XineVideoWidget ( this, "Video frame" ); | 86 | videoFrame = new XineVideoWidget ( this, "Video frame" ); |
87 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); | 87 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); |
88 | 88 | ||
89 | Config cfg("OpiePlayer"); | 89 | Config cfg("OpiePlayer"); |
90 | cfg.setGroup("VideoWidget"); | 90 | cfg.setGroup("VideoWidget"); |
91 | skin = cfg.readEntry("Skin","default"); | 91 | skin = cfg.readEntry("Skin","default"); |
92 | 92 | ||
93 | QString skinPath = "opieplayer2/skins/" + skin; | 93 | QString skinPath = "opieplayer2/skins/" + skin; |
94 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 94 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
95 | imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); | 95 | imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); |
96 | imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); | 96 | imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); |
97 | 97 | ||
98 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); | 98 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); |
99 | imgButtonMask->fill( 0 ); | 99 | imgButtonMask->fill( 0 ); |
100 | 100 | ||
101 | for ( int i = 0; i < 7; i++ ) { | 101 | for ( int i = 0; i < 7; i++ ) { |
102 | QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png"; | 102 | QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png"; |
103 | masks[i] = new QBitmap( filename ); | 103 | masks[i] = new QBitmap( filename ); |
104 | qDebug(filename); | 104 | qDebug(filename); |
105 | if ( !masks[i]->isNull() ) { | 105 | if ( !masks[i]->isNull() ) { |
106 | QImage imgMask = masks[i]->convertToImage(); | 106 | QImage imgMask = masks[i]->convertToImage(); |
107 | uchar **dest = imgButtonMask->jumpTable(); | 107 | uchar **dest = imgButtonMask->jumpTable(); |
108 | for ( int y = 0; y < imgUp->height(); y++ ) { | 108 | for ( int y = 0; y < imgUp->height(); y++ ) { |
109 | uchar *line = dest[y]; | 109 | uchar *line = dest[y]; |
110 | for ( int x = 0; x < imgUp->width(); x++ ) { | 110 | for ( int x = 0; x < imgUp->width(); x++ ) { |
111 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 111 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
112 | line[x] = i + 1; | 112 | line[x] = i + 1; |
113 | } | 113 | } |
114 | } | 114 | } |
115 | } | 115 | } |
116 | 116 | ||
117 | } | 117 | } |
118 | 118 | ||
119 | for ( int i = 0; i < 7; i++ ) { | 119 | for ( int i = 0; i < 7; i++ ) { |
120 | buttonPixUp[i] = NULL; | 120 | buttonPixUp[i] = NULL; |
121 | buttonPixDown[i] = NULL; | 121 | buttonPixDown[i] = NULL; |
122 | } | 122 | } |
123 | 123 | ||
124 | setBackgroundPixmap( *pixBg ); | 124 | setBackgroundPixmap( *pixBg ); |
125 | 125 | ||
126 | slider = new QSlider( Qt::Horizontal, this ); | 126 | slider = new QSlider( Qt::Horizontal, this ); |
127 | slider->setMinValue( 0 ); | 127 | slider->setMinValue( 0 ); |
128 | slider->setMaxValue( 1 ); | 128 | slider->setMaxValue( 1 ); |
129 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); | 129 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); |
130 | slider->setFocusPolicy( QWidget::NoFocus ); | 130 | slider->setFocusPolicy( QWidget::NoFocus ); |
131 | slider->setGeometry( QRect( 7, 250, 220, 20 ) ); | 131 | slider->setGeometry( QRect( 7, 250, 220, 20 ) ); |
132 | 132 | ||
133 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 133 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
134 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 134 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
135 | 135 | ||
136 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 136 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
137 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 137 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
138 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 138 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
139 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 139 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
140 | 140 | ||
141 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 141 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
142 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 142 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
143 | 143 | ||
144 | setLength( mediaPlayerState->length() ); | 144 | setLength( mediaPlayerState->length() ); |
145 | setPosition( mediaPlayerState->position() ); | 145 | setPosition( mediaPlayerState->position() ); |
146 | 146 | ||
147 | ////////////////////////// FIXME | 147 | ////////////////////////// FIXME |
148 | // setFullscreen( mediaPlayerState->fullscreen() ); | 148 | setFullscreen( mediaPlayerState->fullscreen() ); |
149 | setPaused( mediaPlayerState->paused() ); | 149 | setPaused( mediaPlayerState->paused() ); |
150 | setPlaying( mediaPlayerState->playing() ); | 150 | setPlaying( mediaPlayerState->playing() ); |
151 | qDebug("finished videowidget"); | 151 | qDebug("finished videowidget"); |
152 | } | 152 | } |
153 | 153 | ||
154 | 154 | ||
155 | VideoWidget::~VideoWidget() { | 155 | VideoWidget::~VideoWidget() { |
156 | mediaPlayerState->setPlaying( FALSE ); | 156 | mediaPlayerState->setPlaying( FALSE ); |
157 | for ( int i = 0; i < 7; i++ ) { | 157 | for ( int i = 0; i < 7; i++ ) { |
158 | delete buttonPixUp[i]; | 158 | delete buttonPixUp[i]; |
159 | delete buttonPixDown[i]; | 159 | delete buttonPixDown[i]; |
160 | } | 160 | } |
161 | 161 | ||
162 | delete pixBg; | 162 | delete pixBg; |
163 | delete imgUp; | 163 | delete imgUp; |
164 | delete imgDn; | 164 | delete imgDn; |
165 | delete imgButtonMask; | 165 | delete imgButtonMask; |
166 | for ( int i = 0; i < 7; i++ ) { | 166 | for ( int i = 0; i < 7; i++ ) { |
167 | delete masks[i]; | 167 | delete masks[i]; |
168 | } | 168 | } |
169 | 169 | ||
170 | } | 170 | } |
171 | 171 | ||
172 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 172 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
173 | QPixmap pix( img.width(), img.height() ); | 173 | QPixmap pix( img.width(), img.height() ); |
174 | QPainter p( &pix ); | 174 | QPainter p( &pix ); |
175 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 175 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
176 | p.drawImage( 0, 0, img ); | 176 | p.drawImage( 0, 0, img ); |
177 | return new QPixmap( pix ); | 177 | return new QPixmap( pix ); |
178 | } | 178 | } |
179 | 179 | ||
180 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { | 180 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { |
181 | QPixmap *pixmap = new QPixmap( pix ); | 181 | QPixmap *pixmap = new QPixmap( pix ); |
182 | pixmap->setMask( mask ); | 182 | pixmap->setMask( mask ); |
183 | return pixmap; | 183 | return pixmap; |
184 | } | 184 | } |
185 | 185 | ||
186 | void VideoWidget::resizeEvent( QResizeEvent * ) { | 186 | void VideoWidget::resizeEvent( QResizeEvent * ) { |
187 | int h = height(); | 187 | int h = height(); |
188 | int w = width(); | 188 | int w = width(); |
189 | int Vh = 160; | 189 | int Vh = 160; |
190 | //videoFrame->height(); | 190 | //videoFrame->height(); |
191 | int Vw = 220; | 191 | int Vw = 220; |
192 | //videoFrame->width(); | 192 | //videoFrame->width(); |
193 | // songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); | 193 | // songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); |
194 | 194 | ||
195 | slider->setFixedWidth( w - 110 ); | 195 | slider->setFixedWidth( w - 110 ); |
196 | slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); | 196 | slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); |
197 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); | 197 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); |
198 | slider->setFocusPolicy( QWidget::NoFocus ); | 198 | slider->setFocusPolicy( QWidget::NoFocus ); |
199 | slider->setBackgroundPixmap( *pixBg ); | 199 | slider->setBackgroundPixmap( *pixBg ); |
200 | 200 | ||
201 | // time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); | 201 | // time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); |
202 | xoff = 0;// ( imgUp->width() ) / 2; | 202 | xoff = 0;// ( imgUp->width() ) / 2; |
203 | yoff = 180;//(( Vh - imgUp->height() ) / 2) - 10; | 203 | yoff = 180;//(( Vh - imgUp->height() ) / 2) - 10; |
204 | QPoint p( xoff, yoff ); | 204 | QPoint p( xoff, yoff ); |
205 | 205 | ||
206 | 206 | ||
207 | QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); | 207 | QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); |
208 | QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); | 208 | QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); |
209 | 209 | ||
210 | for ( int i = 0; i < 7; i++ ) { | 210 | for ( int i = 0; i < 7; i++ ) { |
211 | if ( !masks[i]->isNull() ) { | 211 | if ( !masks[i]->isNull() ) { |
212 | delete buttonPixUp[i]; | 212 | delete buttonPixUp[i]; |
@@ -335,128 +335,129 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | |||
335 | } | 335 | } |
336 | case VideoNext: qDebug("next"); mediaPlayerState->setNext(); return; | 336 | case VideoNext: qDebug("next"); mediaPlayerState->setNext(); return; |
337 | case VideoPrevious: qDebug("previous"); mediaPlayerState->setPrev(); return; | 337 | case VideoPrevious: qDebug("previous"); mediaPlayerState->setPrev(); return; |
338 | case VideoVolUp: return; | 338 | case VideoVolUp: return; |
339 | case VideoVolDown: return; | 339 | case VideoVolDown: return; |
340 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | 340 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; |
341 | 341 | ||
342 | }; | 342 | }; |
343 | 343 | ||
344 | } else { | 344 | } else { |
345 | if ( videoButtons[i].isHeld ) { | 345 | if ( videoButtons[i].isHeld ) { |
346 | videoButtons[i].isHeld = FALSE; | 346 | videoButtons[i].isHeld = FALSE; |
347 | if ( !videoButtons[i].isToggle ) { | 347 | if ( !videoButtons[i].isToggle ) { |
348 | setToggleButton( i, FALSE ); | 348 | setToggleButton( i, FALSE ); |
349 | } | 349 | } |
350 | // qDebug("mouseMove event switch2 %d %d", i, VideoPlay); | 350 | // qDebug("mouseMove event switch2 %d %d", i, VideoPlay); |
351 | switch (i) { | 351 | switch (i) { |
352 | case VideoPlay: { | 352 | case VideoPlay: { |
353 | if( mediaPlayerState->isPaused) { | 353 | if( mediaPlayerState->isPaused) { |
354 | mediaPlayerState->setPaused( FALSE); return; } | 354 | mediaPlayerState->setPaused( FALSE); return; } |
355 | else if( mediaPlayerState->isPlaying) { | 355 | else if( mediaPlayerState->isPlaying) { |
356 | mediaPlayerState->setPaused( TRUE); return; } | 356 | mediaPlayerState->setPaused( TRUE); return; } |
357 | else | 357 | else |
358 | mediaPlayerState->setPlaying( TRUE /*videoButtons[i].isDown*/ ); return; | 358 | mediaPlayerState->setPlaying( TRUE /*videoButtons[i].isDown*/ ); return; |
359 | } | 359 | } |
360 | case VideoStop: mediaPlayerState->setPlaying(FALSE); return; | 360 | case VideoStop: mediaPlayerState->setPlaying(FALSE); return; |
361 | // case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; | 361 | // case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; |
362 | case VideoNext: mediaPlayerState->setNext(); return; | 362 | case VideoNext: mediaPlayerState->setNext(); return; |
363 | case VideoPrevious: mediaPlayerState->setPrev(); return; | 363 | case VideoPrevious: mediaPlayerState->setPrev(); return; |
364 | case VideoVolUp: return; | 364 | case VideoVolUp: return; |
365 | case VideoVolDown: return; | 365 | case VideoVolDown: return; |
366 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | 366 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; |
367 | } | 367 | } |
368 | } | 368 | } |
369 | } | 369 | } |
370 | } | 370 | } |
371 | } | 371 | } |
372 | 372 | ||
373 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { | 373 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { |
374 | mouseMoveEvent( event ); | 374 | mouseMoveEvent( event ); |
375 | } | 375 | } |
376 | 376 | ||
377 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 377 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
378 | if ( mediaPlayerState->fullscreen() ) { | 378 | if ( mediaPlayerState->fullscreen() ) { |
379 | mediaPlayerState->setFullscreen( FALSE ); | 379 | mediaPlayerState->setFullscreen( FALSE ); |
380 | makeVisible(); | 380 | makeVisible(); |
381 | 381 | ||
382 | mouseMoveEvent( event ); | 382 | mouseMoveEvent( event ); |
383 | } | 383 | } |
384 | } | 384 | } |
385 | 385 | ||
386 | 386 | ||
387 | void VideoWidget::makeVisible() { | 387 | void VideoWidget::makeVisible() { |
388 | if ( mediaPlayerState->fullscreen() ) { | 388 | if ( mediaPlayerState->fullscreen() ) { |
389 | setBackgroundMode( QWidget::NoBackground ); | 389 | setBackgroundMode( QWidget::NoBackground ); |
390 | showFullScreen(); | 390 | showFullScreen(); |
391 | resize( qApp->desktop()->size() ); | 391 | resize( qApp->desktop()->size() ); |
392 | slider->hide(); | 392 | slider->hide(); |
393 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); | 393 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); |
394 | } else { | 394 | } else { |
395 | showNormal(); | 395 | showNormal(); |
396 | showMaximized(); | 396 | showMaximized(); |
397 | slider->show(); | 397 | slider->show(); |
398 | videoFrame->setGeometry( QRect( 10, 20, 220, 160 ) ); | 398 | videoFrame->setGeometry( QRect( 10, 20, 220, 160 ) ); |
399 | qApp->processEvents(); | ||
399 | } | 400 | } |
400 | } | 401 | } |
401 | 402 | ||
402 | 403 | ||
403 | void VideoWidget::paintEvent( QPaintEvent * pe) { | 404 | void VideoWidget::paintEvent( QPaintEvent * pe) { |
404 | QPainter p( this ); | 405 | QPainter p( this ); |
405 | 406 | ||
406 | if ( mediaPlayerState->fullscreen() ) { | 407 | if ( mediaPlayerState->fullscreen() ) { |
407 | // Clear the background | 408 | // Clear the background |
408 | p.setBrush( QBrush( Qt::black ) ); | 409 | p.setBrush( QBrush( Qt::black ) ); |
409 | // videoFrame->setGeometry( QRect( 0, 0 , 240 ,320 ) ); | 410 | // videoFrame->setGeometry( QRect( 0, 0 , 240 ,320 ) ); |
410 | 411 | ||
411 | } else { | 412 | } else { |
412 | 413 | ||
413 | // videoFrame->setGeometry( QRect( 0, 15 , 240 ,170 ) ); | 414 | // videoFrame->setGeometry( QRect( 0, 15 , 240 ,170 ) ); |
414 | // draw the buttons | 415 | // draw the buttons |
415 | 416 | ||
416 | if ( !pe->erased() ) { | 417 | if ( !pe->erased() ) { |
417 | // Combine with background and double buffer | 418 | // Combine with background and double buffer |
418 | QPixmap pix( pe->rect().size() ); | 419 | QPixmap pix( pe->rect().size() ); |
419 | QPainter p( &pix ); | 420 | QPainter p( &pix ); |
420 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 421 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
421 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); | 422 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); |
422 | for ( int i = 0; i < numVButtons; i++ ) | 423 | for ( int i = 0; i < numVButtons; i++ ) |
423 | paintButton( &p, i ); | 424 | paintButton( &p, i ); |
424 | QPainter p2( this ); | 425 | QPainter p2( this ); |
425 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 426 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
426 | } else { | 427 | } else { |
427 | QPainter p( this ); | 428 | QPainter p( this ); |
428 | for ( int i = 0; i < numVButtons; i++ ) | 429 | for ( int i = 0; i < numVButtons; i++ ) |
429 | paintButton( &p, i ); | 430 | paintButton( &p, i ); |
430 | } | 431 | } |
431 | // for ( int i = 0; i < numButtons; i++ ) { | 432 | // for ( int i = 0; i < numButtons; i++ ) { |
432 | // paintButton( &p, i ); | 433 | // paintButton( &p, i ); |
433 | // } | 434 | // } |
434 | // draw the slider | 435 | // draw the slider |
435 | slider->repaint( TRUE ); | 436 | slider->repaint( TRUE ); |
436 | } | 437 | } |
437 | } | 438 | } |
438 | 439 | ||
439 | 440 | ||
440 | void VideoWidget::closeEvent( QCloseEvent* ) { | 441 | void VideoWidget::closeEvent( QCloseEvent* ) { |
441 | mediaPlayerState->setList(); | 442 | mediaPlayerState->setList(); |
442 | } | 443 | } |
443 | 444 | ||
444 | 445 | ||
445 | bool VideoWidget::playVideo() { | 446 | bool VideoWidget::playVideo() { |
446 | bool result = FALSE; | 447 | bool result = FALSE; |
447 | 448 | ||
448 | int stream = 0; | 449 | int stream = 0; |
449 | 450 | ||
450 | int sw = 240; | 451 | int sw = 240; |
451 | int sh = 320; | 452 | int sh = 320; |
452 | int dd = QPixmap::defaultDepth(); | 453 | int dd = QPixmap::defaultDepth(); |
453 | int w = height(); | 454 | int w = height(); |
454 | int h = width(); | 455 | int h = width(); |
455 | 456 | ||
456 | return true; | 457 | return true; |
457 | } | 458 | } |
458 | 459 | ||
459 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { | 460 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { |
460 | switch ( e->key() ) { | 461 | switch ( e->key() ) { |
461 | ////////////////////////////// Zaurus keys | 462 | ////////////////////////////// Zaurus keys |
462 | case Key_Home: | 463 | case Key_Home: |