summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2003-04-20 04:15:39 (UTC)
committer llornkcor <llornkcor>2003-04-20 04:15:39 (UTC)
commit138fbbf45ce46228f2bec63099e0bc3a4e0537e2 (patch) (unidiff)
tree424f7bffb331270f5888f3659d02f447fbae0794
parent0bc47585aef17477ca5564dde4da4a41cf57a1c0 (diff)
downloadopie-138fbbf45ce46228f2bec63099e0bc3a4e0537e2.zip
opie-138fbbf45ce46228f2bec63099e0bc3a4e0537e2.tar.gz
opie-138fbbf45ce46228f2bec63099e0bc3a4e0537e2.tar.bz2
remove commentout code
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/videowidget.cpp107
1 files changed, 0 insertions, 107 deletions
diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp
index 6ed0108..48104ca 100644
--- a/core/multimedia/opieplayer/videowidget.cpp
+++ b/core/multimedia/opieplayer/videowidget.cpp
@@ -121,564 +121,457 @@ VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) :
121 } 121 }
122 qDebug("finished loading first pics"); 122 qDebug("finished loading first pics");
123 for ( int i = 0; i < 7; i++ ) 123 for ( int i = 0; i < 7; i++ )
124 { 124 {
125 buttonPixUp[i] = NULL; 125 buttonPixUp[i] = NULL;
126 buttonPixDown[i] = NULL; 126 buttonPixDown[i] = NULL;
127 } 127 }
128 128
129 setBackgroundPixmap( *pixBg ); 129 setBackgroundPixmap( *pixBg );
130 130
131 currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); 131 currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 );
132 132
133 slider = new QSlider( Qt::Horizontal, this ); 133 slider = new QSlider( Qt::Horizontal, this );
134 slider->setMinValue( 0 ); 134 slider->setMinValue( 0 );
135 slider->setMaxValue( 1 ); 135 slider->setMaxValue( 1 );
136 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 136 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
137 slider->setFocusPolicy( QWidget::NoFocus ); 137 slider->setFocusPolicy( QWidget::NoFocus );
138// slider->setGeometry( QRect( 7, 250, 220, 20 ) ); 138// slider->setGeometry( QRect( 7, 250, 220, 20 ) );
139 139
140 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 140 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
141 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 141 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
142 142
143 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 143 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
144 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 144 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
145 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 145 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
146 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 146 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
147// connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 147// connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
148 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 148 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
149 149
150 // Intialise state 150 // Intialise state
151 setLength( mediaPlayerState->length() ); 151 setLength( mediaPlayerState->length() );
152 setPosition( mediaPlayerState->position() ); 152 setPosition( mediaPlayerState->position() );
153 setFullscreen( mediaPlayerState->fullscreen() ); 153 setFullscreen( mediaPlayerState->fullscreen() );
154// setPaused( mediaPlayerState->paused() ); 154// setPaused( mediaPlayerState->paused() );
155 setPlaying( mediaPlayerState->playing() ); 155 setPlaying( mediaPlayerState->playing() );
156} 156}
157 157
158 158
159VideoWidget::~VideoWidget() { 159VideoWidget::~VideoWidget() {
160 160
161 for ( int i = 0; i < 7; i++ ) 161 for ( int i = 0; i < 7; i++ )
162 { 162 {
163 delete buttonPixUp[i]; 163 delete buttonPixUp[i];
164 delete buttonPixDown[i]; 164 delete buttonPixDown[i];
165 } 165 }
166 166
167 delete pixBg; 167 delete pixBg;
168 delete imgUp; 168 delete imgUp;
169 delete imgDn; 169 delete imgDn;
170 delete imgButtonMask; 170 delete imgButtonMask;
171 for ( int i = 0; i < 7; i++ ) 171 for ( int i = 0; i < 7; i++ )
172 { 172 {
173 delete masks[i]; 173 delete masks[i];
174 } 174 }
175 175
176// for ( int i = 0; i < 3; i++ ) 176// for ( int i = 0; i < 3; i++ )
177// delete pixmaps[i]; 177// delete pixmaps[i];
178// delete currentFrame; 178// delete currentFrame;
179} 179}
180 180
181 181
182static bool videoSliderBeingMoved = FALSE; 182static bool videoSliderBeingMoved = FALSE;
183 183
184QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 184QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
185 QPixmap pix( img.width(), img.height() ); 185 QPixmap pix( img.width(), img.height() );
186 QPainter p( &pix ); 186 QPainter p( &pix );
187 p.drawTiledPixmap( pix.rect(), bg, offset ); 187 p.drawTiledPixmap( pix.rect(), bg, offset );
188 p.drawImage( 0, 0, img ); 188 p.drawImage( 0, 0, img );
189 return new QPixmap( pix ); 189 return new QPixmap( pix );
190} 190}
191 191
192QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { 192QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) {
193 QPixmap *pixmap = new QPixmap( pix ); 193 QPixmap *pixmap = new QPixmap( pix );
194 pixmap->setMask( mask ); 194 pixmap->setMask( mask );
195 return pixmap; 195 return pixmap;
196} 196}
197 197
198void VideoWidget::resizeEvent( QResizeEvent * ) { 198void VideoWidget::resizeEvent( QResizeEvent * ) {
199 int h = height(); 199 int h = height();
200 int w = width(); 200 int w = width();
201 //int Vh = 160; 201 //int Vh = 160;
202 //int Vw = 220; 202 //int Vw = 220;
203 203
204 slider->setFixedWidth( w - 20 ); 204 slider->setFixedWidth( w - 20 );
205 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 205 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
206 slider->setBackgroundOrigin( QWidget::ParentOrigin ); 206 slider->setBackgroundOrigin( QWidget::ParentOrigin );
207 slider->setFocusPolicy( QWidget::NoFocus ); 207 slider->setFocusPolicy( QWidget::NoFocus );
208 slider->setBackgroundPixmap( *pixBg ); 208 slider->setBackgroundPixmap( *pixBg );
209 209
210 xoff = 0;// ( imgUp->width() ) / 2; 210 xoff = 0;// ( imgUp->width() ) / 2;
211 if(w>h) 211 if(w>h)
212 yoff = 0; 212 yoff = 0;
213 else 213 else
214 yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; 214 yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10;
215 QPoint p( xoff, yoff ); 215 QPoint p( xoff, yoff );
216 216
217 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); 217 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p );
218 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); 218 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p );
219 219
220 for ( int i = 0; i < 7; i++ ) 220 for ( int i = 0; i < 7; i++ )
221 { 221 {
222 if ( !masks[i]->isNull() ) 222 if ( !masks[i]->isNull() )
223 { 223 {
224 delete buttonPixUp[i]; 224 delete buttonPixUp[i];
225 delete buttonPixDown[i]; 225 delete buttonPixDown[i];
226 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); 226 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] );
227 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); 227 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] );
228 } 228 }
229 } 229 }
230 230
231 delete pixUp; 231 delete pixUp;
232 delete pixDn; 232 delete pixDn;
233} 233}
234 234
235 235
236void VideoWidget::sliderPressed() { 236void VideoWidget::sliderPressed() {
237 videoSliderBeingMoved = TRUE; 237 videoSliderBeingMoved = TRUE;
238} 238}
239 239
240 240
241void VideoWidget::sliderReleased() { 241void VideoWidget::sliderReleased() {
242 videoSliderBeingMoved = FALSE; 242 videoSliderBeingMoved = FALSE;
243 if ( slider->width() == 0 ) 243 if ( slider->width() == 0 )
244 return; 244 return;
245 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); 245 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width());
246 mediaPlayerState->setPosition( val ); 246 mediaPlayerState->setPosition( val );
247} 247}
248 248
249 249
250void VideoWidget::setPosition( long i ) { 250void VideoWidget::setPosition( long i ) {
251 updateSlider( i, mediaPlayerState->length() ); 251 updateSlider( i, mediaPlayerState->length() );
252} 252}
253 253
254 254
255void VideoWidget::setLength( long max ) { 255void VideoWidget::setLength( long max ) {
256 updateSlider( mediaPlayerState->position(), max ); 256 updateSlider( mediaPlayerState->position(), max );
257} 257}
258 258
259 259
260void VideoWidget::setView( char view ) { 260void VideoWidget::setView( char view ) {
261 if ( view == 'v' ) 261 if ( view == 'v' )
262 { 262 {
263 makeVisible(); 263 makeVisible();
264 } 264 }
265 else 265 else
266 { 266 {
267 // Effectively blank the view next time we show it so it looks nicer 267 // Effectively blank the view next time we show it so it looks nicer
268 scaledWidth = 0; 268 scaledWidth = 0;
269 scaledHeight = 0; 269 scaledHeight = 0;
270 hide(); 270 hide();
271 } 271 }
272} 272}
273 273
274 274
275void VideoWidget::updateSlider( long i, long max ) { 275void VideoWidget::updateSlider( long i, long max ) {
276 // Will flicker too much if we don't do this 276 // Will flicker too much if we don't do this
277 if ( max == 0 ) 277 if ( max == 0 )
278 return; 278 return;
279 int width = slider->width(); 279 int width = slider->width();
280 int val = int((double)i * width / max); 280 int val = int((double)i * width / max);
281 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) 281 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved )
282 { 282 {
283 if ( slider->value() != val ) 283 if ( slider->value() != val )
284 slider->setValue( val ); 284 slider->setValue( val );
285 if ( slider->maxValue() != width ) 285 if ( slider->maxValue() != width )
286 slider->setMaxValue( width ); 286 slider->setMaxValue( width );
287 } 287 }
288} 288}
289 289
290 290
291void VideoWidget::setToggleButton( int i, bool down ) { 291void VideoWidget::setToggleButton( int i, bool down ) {
292 if ( down != videoButtons[i].isDown ) 292 if ( down != videoButtons[i].isDown )
293 toggleButton( i ); 293 toggleButton( i );
294} 294}
295 295
296 296
297void VideoWidget::toggleButton( int i ) { 297void VideoWidget::toggleButton( int i ) {
298 videoButtons[i].isDown = !videoButtons[i].isDown; 298 videoButtons[i].isDown = !videoButtons[i].isDown;
299 QPainter p(this); 299 QPainter p(this);
300 paintButton ( &p, i ); 300 paintButton ( &p, i );
301} 301}
302 302
303 303
304void VideoWidget::paintButton( QPainter *p, int i ) { 304void VideoWidget::paintButton( QPainter *p, int i ) {
305 if ( videoButtons[i].isDown ) 305 if ( videoButtons[i].isDown )
306 { 306 {
307 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 307 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
308 } 308 }
309 else 309 else
310 { 310 {
311 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 311 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
312 } 312 }
313// int x = videoButtons[i].xPos;
314// int y = videoButtons[i].yPos;
315// int offset = 10 + videoButtons[i].isDown;
316// p->drawPixmap( x, y, *pixmaps[videoButtons[i].isDown] );
317// p->drawPixmap( x + 1 + offset, y + offset, *pixmaps[2], 9 * videoButtons[i].controlType, 0, 9, 9 );
318} 313}
319 314
320 315
321void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 316void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
322 for ( int i = 0; i < numVButtons; i++ ) { 317 for ( int i = 0; i < numVButtons; i++ ) {
323 if ( event->state() == QMouseEvent::LeftButton ) { 318 if ( event->state() == QMouseEvent::LeftButton ) {
324 // The test to see if the mouse click is inside the button or not 319 // The test to see if the mouse click is inside the button or not
325 int x = event->pos().x() - xoff; 320 int x = event->pos().x() - xoff;
326 int y = event->pos().y() - yoff; 321 int y = event->pos().y() - yoff;
327 322
328 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() 323 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
329 && y < imgButtonMask->height() 324 && y < imgButtonMask->height()
330 && imgButtonMask->pixelIndex( x, y ) == i + 1 ); 325 && imgButtonMask->pixelIndex( x, y ) == i + 1 );
331 326
332 if ( isOnButton && !videoButtons[i].isHeld ) { 327 if ( isOnButton && !videoButtons[i].isHeld ) {
333 videoButtons[i].isHeld = TRUE; 328 videoButtons[i].isHeld = TRUE;
334 toggleButton(i); 329 toggleButton(i);
335 330
336 switch (i) { 331 switch (i) {
337 case VideoVolUp: 332 case VideoVolUp:
338 emit moreClicked(); 333 emit moreClicked();
339 return; 334 return;
340 case VideoVolDown: 335 case VideoVolDown:
341 emit lessClicked(); 336 emit lessClicked();
342 return; 337 return;
343 } 338 }
344 } else if ( !isOnButton && videoButtons[i].isHeld ) { 339 } else if ( !isOnButton && videoButtons[i].isHeld ) {
345 videoButtons[i].isHeld = FALSE; 340 videoButtons[i].isHeld = FALSE;
346 toggleButton(i); 341 toggleButton(i);
347 } 342 }
348 } else { 343 } else {
349 344
350 if ( videoButtons[i].isHeld ) { 345 if ( videoButtons[i].isHeld ) {
351 videoButtons[i].isHeld = FALSE; 346 videoButtons[i].isHeld = FALSE;
352 if ( !videoButtons[i].isToggle ) { 347 if ( !videoButtons[i].isToggle ) {
353 setToggleButton( i, FALSE ); 348 setToggleButton( i, FALSE );
354 } 349 }
355 350
356 switch(i) { 351 switch(i) {
357 352
358 case VideoPlay: { 353 case VideoPlay: {
359 qDebug("play"); 354 qDebug("play");
360 if( !mediaPlayerState->playing()) { 355 if( !mediaPlayerState->playing()) {
361 mediaPlayerState->setPlaying( true); 356 mediaPlayerState->setPlaying( true);
362 setToggleButton( i-1, false ); 357 setToggleButton( i-1, false );
363 setToggleButton( i, false ); 358 setToggleButton( i, false );
364 return; 359 return;
365 } 360 }
366 if( mediaPlayerState->isPaused ) { 361 if( mediaPlayerState->isPaused ) {
367 qDebug("isPaused"); 362 qDebug("isPaused");
368 setToggleButton( i, FALSE ); 363 setToggleButton( i, FALSE );
369 mediaPlayerState->setPaused( FALSE ); 364 mediaPlayerState->setPaused( FALSE );
370 return; 365 return;
371 } else if( !mediaPlayerState->isPaused ) { 366 } else if( !mediaPlayerState->isPaused ) {
372 qDebug("is not paused"); 367 qDebug("is not paused");
373 setToggleButton( i, TRUE ); 368 setToggleButton( i, TRUE );
374 mediaPlayerState->setPaused( TRUE ); 369 mediaPlayerState->setPaused( TRUE );
375 return; 370 return;
376 } else { 371 } else {
377 return; 372 return;
378 } 373 }
379 } 374 }
380 375
381 case VideoStop: qDebug("stop"); mediaPlayerState->setPlaying( FALSE ); setToggleButton( i+1, true); setToggleButton( i, true ); return; 376 case VideoStop: qDebug("stop"); mediaPlayerState->setPlaying( FALSE ); setToggleButton( i+1, true); setToggleButton( i, true ); return;
382 case VideoNext: mediaPlayerState->setNext(); return; 377 case VideoNext: mediaPlayerState->setNext(); return;
383 case VideoPrevious: mediaPlayerState->setPrev(); return; 378 case VideoPrevious: mediaPlayerState->setPrev(); return;
384 case VideoVolUp: emit moreReleased(); return; 379 case VideoVolUp: emit moreReleased(); return;
385 case VideoVolDown: emit lessReleased(); return; 380 case VideoVolDown: emit lessReleased(); return;
386 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; 381 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
387 } 382 }
388 } 383 }
389 } 384 }
390 } 385 }
391
392// for ( int i = 0; i < numVButtons; i++ )
393// {
394// if ( event->state() == QMouseEvent::LeftButton )
395// {
396// // The test to see if the mouse click is inside the button or not
397// int x = event->pos().x() - xoff;
398// int y = event->pos().y() - yoff;
399
400// bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
401// && y < imgButtonMask->height()
402// && imgButtonMask->pixelIndex( x, y ) == i + 1 );
403
404// if ( isOnButton && !videoButtons[i].isHeld )
405// {
406// qDebug("key %d", i);
407
408// videoButtons[i].isHeld = TRUE;
409// toggleButton(i);
410// switch (i) {
411// case VideoVolUp:
412// emit moreClicked();
413// return;
414// case VideoVolDown:
415// emit lessClicked();
416// return;
417// }
418// } else if ( !isOnButton && videoButtons[i].isHeld ) {
419// videoButtons[i].isHeld = FALSE;
420// toggleButton(i);
421// }
422
423
424// } else {
425
426// if ( videoButtons[i].isHeld )
427// {
428// videoButtons[i].isHeld = FALSE;
429// if ( !videoButtons[i].isToggle ) {
430// setToggleButton( i, FALSE );
431// }
432// qDebug("key %d", i);
433// switch(i) {
434// case VideoPlay:
435// {
436// if( mediaPlayerState->isPaused ) {
437// setToggleButton( i, FALSE );
438// mediaPlayerState->setPaused( FALSE );
439// return;
440// }
441// else if( !mediaPlayerState->isPaused ) {
442// setToggleButton( i, TRUE );
443// mediaPlayerState->setPaused( TRUE );
444// return;
445// } else {
446// return;
447// }
448// }
449
450// case VideoStop: mediaPlayerState->setPlaying(FALSE); return;
451// // case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return;
452// // case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return;
453// case VideoNext: mediaPlayerState->setNext(); return;
454// case VideoPrevious: mediaPlayerState->setPrev(); return;
455// case VideoVolUp: emit moreReleased(); return;
456// case VideoVolDown: emit lessReleased(); return;
457// // case VideoPlayList: mediaPlayerState->setList(); return;
458// case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
459// }
460// }
461// }
462// }
463
464
465
466
467
468// for ( int i = 0; i < numButtons; i++ ) {
469// int x = videoButtons[i].xPos;
470// int y = videoButtons[i].yPos;
471// if ( event->state() == QMouseEvent::LeftButton ) {
472// // The test to see if the mouse click is inside the circular button or not
473// // (compared with the radius squared to avoid a square-root of our distance)
474// int radius = 16;
475// QPoint center = QPoint( x + radius, y + radius );
476// QPoint dXY = center - event->pos();
477// int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y();
478// bool isOnButton = dist <= (radius * radius);
479// if ( isOnButton != videoButtons[i].isHeld ) {
480// videoButtons[i].isHeld = isOnButton;
481// toggleButton(i);
482// }
483// } else {
484// if ( videoButtons[i].isHeld ) {
485// videoButtons[i].isHeld = FALSE;
486// if ( !videoButtons[i].isToggle )
487// setToggleButton( i, FALSE );
488// }
489// }
490
491
492// }
493} 386}
494 387
495 388
496void VideoWidget::mousePressEvent( QMouseEvent *event ) { 389void VideoWidget::mousePressEvent( QMouseEvent *event ) {
497 mouseMoveEvent( event ); 390 mouseMoveEvent( event );
498} 391}
499 392
500 393
501void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 394void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
502 if ( mediaPlayerState->fullscreen() ) 395 if ( mediaPlayerState->fullscreen() )
503 { 396 {
504 mediaPlayerState->setFullscreen( FALSE ); 397 mediaPlayerState->setFullscreen( FALSE );
505 makeVisible(); 398 makeVisible();
506 } 399 }
507 mouseMoveEvent( event ); 400 mouseMoveEvent( event );
508// } 401// }
509} 402}
510 403
511 404
512void VideoWidget::makeVisible() { 405void VideoWidget::makeVisible() {
513 if ( mediaPlayerState->fullscreen() ) 406 if ( mediaPlayerState->fullscreen() )
514 { 407 {
515 setBackgroundMode( QWidget::NoBackground ); 408 setBackgroundMode( QWidget::NoBackground );
516 showFullScreen(); 409 showFullScreen();
517 resize( qApp->desktop()->size() ); 410 resize( qApp->desktop()->size() );
518 slider->hide(); 411 slider->hide();
519 } 412 }
520 else 413 else
521 { 414 {
522 setBackgroundPixmap( *pixBg ); 415 setBackgroundPixmap( *pixBg );
523 showNormal(); 416 showNormal();
524 showMaximized(); 417 showMaximized();
525 slider->show(); 418 slider->show();
526 } 419 }
527} 420}
528 421
529 422
530void VideoWidget::paintEvent( QPaintEvent * pe) { 423void VideoWidget::paintEvent( QPaintEvent * pe) {
531 QPainter p( this ); 424 QPainter p( this );
532 425
533 if ( mediaPlayerState->fullscreen() ) { 426 if ( mediaPlayerState->fullscreen() ) {
534 // Clear the background 427 // Clear the background
535 p.setBrush( QBrush( Qt::black ) ); 428 p.setBrush( QBrush( Qt::black ) );
536 p.drawRect( rect() ); 429 p.drawRect( rect() );
537 } else { 430 } else {
538 if ( !pe->erased() ) { 431 if ( !pe->erased() ) {
539 // Combine with background and double buffer 432 // Combine with background and double buffer
540 QPixmap pix( pe->rect().size() ); 433 QPixmap pix( pe->rect().size() );
541 QPainter p( &pix ); 434 QPainter p( &pix );
542 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 435 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
543 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); 436 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
544 for ( int i = 0; i < numVButtons; i++ ) { 437 for ( int i = 0; i < numVButtons; i++ ) {
545 paintButton( &p, i ); 438 paintButton( &p, i );
546 } 439 }
547 QPainter p2( this ); 440 QPainter p2( this );
548 p2.drawPixmap( pe->rect().topLeft(), pix ); 441 p2.drawPixmap( pe->rect().topLeft(), pix );
549 } else { 442 } else {
550 QPainter p( this ); 443 QPainter p( this );
551 for ( int i = 0; i < numVButtons; i++ ) 444 for ( int i = 0; i < numVButtons; i++ )
552 paintButton( &p, i ); 445 paintButton( &p, i );
553 } 446 }
554 slider->repaint( TRUE ); 447 slider->repaint( TRUE );
555 } 448 }
556} 449}
557 450
558 451
559void VideoWidget::closeEvent( QCloseEvent* ) { 452void VideoWidget::closeEvent( QCloseEvent* ) {
560 mediaPlayerState->setList(); 453 mediaPlayerState->setList();
561} 454}
562 455
563 456
564bool VideoWidget::playVideo() { 457bool VideoWidget::playVideo() {
565 bool result = FALSE; 458 bool result = FALSE;
566// qDebug("<<<<<<<<<<<<<<<< play video"); 459// qDebug("<<<<<<<<<<<<<<<< play video");
567 int stream = 0; 460 int stream = 0;
568 461
569 int sw = mediaPlayerState->curDecoder()->videoWidth( stream ); 462 int sw = mediaPlayerState->curDecoder()->videoWidth( stream );
570 int sh = mediaPlayerState->curDecoder()->videoHeight( stream ); 463 int sh = mediaPlayerState->curDecoder()->videoHeight( stream );
571 int dd = QPixmap::defaultDepth(); 464 int dd = QPixmap::defaultDepth();
572 int w = height(); 465 int w = height();
573 int h = width(); 466 int h = width();
574 467
575 ColorFormat format = (dd == 16) ? RGB565 : BGRA8888; 468 ColorFormat format = (dd == 16) ? RGB565 : BGRA8888;
576 469
577 if ( mediaPlayerState->fullscreen() ) 470 if ( mediaPlayerState->fullscreen() )
578 { 471 {
579#ifdef USE_DIRECT_PAINTER 472#ifdef USE_DIRECT_PAINTER
580 QDirectPainter p(this); 473 QDirectPainter p(this);
581 474
582 if ( ( qt_screen->transformOrientation() == 3 ) && 475 if ( ( qt_screen->transformOrientation() == 3 ) &&
583 ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) ) 476 ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) )
584 { 477 {
585 478
586 w = 320; 479 w = 320;
587 h = 240; 480 h = 240;
588 481
589 if ( mediaPlayerState->scaled() ) 482 if ( mediaPlayerState->scaled() )
590 { 483 {
591 // maintain aspect ratio 484 // maintain aspect ratio
592 if ( w * sh > sw * h ) 485 if ( w * sh > sw * h )
593 w = sw * h / sh; 486 w = sw * h / sh;
594 else 487 else
595 h = sh * w / sw; 488 h = sh * w / sw;
596 } 489 }
597 else 490 else
598 { 491 {
599 w = sw; 492 w = sw;
600 h = sh; 493 h = sh;
601 } 494 }
602 495
603 w--; // we can't allow libmpeg to overwrite. 496 w--; // we can't allow libmpeg to overwrite.
604 QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) ); 497 QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) );
605 498
606 int ox = roff.x() - height() + 2 + (height() - w) / 2; 499 int ox = roff.x() - height() + 2 + (height() - w) / 2;
607 int oy = roff.y() + (width() - h) / 2; 500 int oy = roff.y() + (width() - h) / 2;
608 int sx = 0, sy = 0; 501 int sx = 0, sy = 0;
609 502
610 uchar* fp = p.frameBuffer() + p.lineStep() * oy; 503 uchar* fp = p.frameBuffer() + p.lineStep() * oy;
611 fp += dd * ox / 8; 504 fp += dd * ox / 8;
612 uchar **jt = new uchar*[h]; 505 uchar **jt = new uchar*[h];
613 506
614 for ( int i = h; i; i-- ) 507 for ( int i = h; i; i-- )
615 { 508 {
616 jt[h - i] = fp; 509 jt[h - i] = fp;
617 fp += p.lineStep(); 510 fp += p.lineStep();
618 } 511 }
619 512
620 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0; 513 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0;
621 514
622 delete [] jt; 515 delete [] jt;
623 } 516 }
624 else 517 else
625 { 518 {
626#endif 519#endif
627 QPainter p(this); 520 QPainter p(this);
628 521
629 w = 320; 522 w = 320;
630 h = 240; 523 h = 240;
631 524
632 if ( mediaPlayerState->scaled() ) 525 if ( mediaPlayerState->scaled() )
633 { 526 {
634 // maintain aspect ratio 527 // maintain aspect ratio
635 if ( w * sh > sw * h ) 528 if ( w * sh > sw * h )
636 w = sw * h / sh; 529 w = sw * h / sh;
637 else 530 else
638 h = sh * w / sw; 531 h = sh * w / sw;
639 } 532 }
640 else 533 else
641 { 534 {
642 w = sw; 535 w = sw;
643 h = sh; 536 h = sh;
644 } 537 }
645 538
646 int bytes = ( dd == 16 ) ? 2 : 4; 539 int bytes = ( dd == 16 ) ? 2 : 4;
647 QImage tempFrame( w, h, bytes << 3 ); 540 QImage tempFrame( w, h, bytes << 3 );
648 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(), 541 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(),
649 0, 0, sw, sh, w, h, format, 0) == 0; 542 0, 0, sw, sh, w, h, format, 0) == 0;
650 543
651 if ( result && mediaPlayerState->fullscreen() ) 544 if ( result && mediaPlayerState->fullscreen() )
652 { 545 {
653 546
654 int rw = h, rh = w; 547 int rw = h, rh = w;
655 QImage rotatedFrame( rw, rh, bytes << 3 ); 548 QImage rotatedFrame( rw, rh, bytes << 3 );
656 549
657 ushort* in = (ushort*)tempFrame.bits(); 550 ushort* in = (ushort*)tempFrame.bits();
658 ushort* out = (ushort*)rotatedFrame.bits(); 551 ushort* out = (ushort*)rotatedFrame.bits();
659 int spl = rotatedFrame.bytesPerLine() / bytes; 552 int spl = rotatedFrame.bytesPerLine() / bytes;
660 553
661 for (int x=0; x<h; x++) 554 for (int x=0; x<h; x++)
662 { 555 {
663 if ( bytes == 2 ) 556 if ( bytes == 2 )
664 { 557 {
665 ushort* lout = out++ + (w - 1)*spl; 558 ushort* lout = out++ + (w - 1)*spl;
666 for (int y=0; y<w; y++) { 559 for (int y=0; y<w; y++) {
667 *lout=*in++; 560 *lout=*in++;
668 lout-=spl; 561 lout-=spl;
669 } 562 }
670 } 563 }
671 else 564 else
672 { 565 {
673 ulong* lout = ((ulong *)out)++ + (w - 1)*spl; 566 ulong* lout = ((ulong *)out)++ + (w - 1)*spl;
674 for (int y=0; y<w; y++) 567 for (int y=0; y<w; y++)
675 { 568 {
676 *lout=*((ulong*)in)++; 569 *lout=*((ulong*)in)++;
677 lout-=spl; 570 lout-=spl;
678 } 571 }
679 } 572 }
680 } 573 }
681 574
682 p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh ); 575 p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh );
683 } 576 }
684#ifdef USE_DIRECT_PAINTER 577#ifdef USE_DIRECT_PAINTER