author | llornkcor <llornkcor> | 2003-04-20 02:30:43 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-04-20 02:30:43 (UTC) |
commit | 845c8a880a2ff701f21c2845674e97a2493499f4 (patch) (unidiff) | |
tree | c91b65869022c2628f509cb27685e45dfb199679 /core/multimedia/opieplayer/videowidget.cpp | |
parent | b62c40465c917e4952651b6f359e5ec76b340d3f (diff) | |
download | opie-845c8a880a2ff701f21c2845674e97a2493499f4.zip opie-845c8a880a2ff701f21c2845674e97a2493499f4.tar.gz opie-845c8a880a2ff701f21c2845674e97a2493499f4.tar.bz2 |
add video skin support *finally*, fixed widget for landscape/sizing
Diffstat (limited to 'core/multimedia/opieplayer/videowidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/videowidget.cpp | 449 |
1 files changed, 348 insertions, 101 deletions
diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp index 97997f9..1b38206 100644 --- a/core/multimedia/opieplayer/videowidget.cpp +++ b/core/multimedia/opieplayer/videowidget.cpp | |||
@@ -22,3 +22,5 @@ | |||
22 | #include <qpe/config.h> | 22 | #include <qpe/config.h> |
23 | #include <qpe/qpeapplication.h> | ||
23 | 24 | ||
25 | #include <qdir.h> | ||
24 | #include <qwidget.h> | 26 | #include <qwidget.h> |
@@ -47,5 +49,5 @@ static const int yo = 0; // movable y offset | |||
47 | struct MediaButton { | 49 | struct MediaButton { |
48 | int xPos, yPos; | 50 | // int xPos, yPos; |
49 | bool isToggle, isHeld, isDown; | 51 | bool isToggle, isHeld, isDown; |
50 | int controlType; | 52 | // int controlType; |
51 | }; | 53 | }; |
@@ -55,31 +57,75 @@ struct MediaButton { | |||
55 | MediaButton videoButtons[] = { | 57 | MediaButton videoButtons[] = { |
56 | { 5+0*32+xo, 200+yo, FALSE, FALSE, FALSE, 4 }, // previous | 58 | { FALSE, FALSE, FALSE }, // stop |
57 | { 5+1*32+xo, 200+yo, FALSE, FALSE, FALSE, 1 }, // stop | 59 | { TRUE, FALSE, FALSE }, // play |
58 | { 5+2*32+xo, 200+yo, TRUE, FALSE, FALSE, 0 }, // play | 60 | { FALSE, FALSE, FALSE }, // previous |
59 | { 5+3*32+xo, 200+yo, TRUE, FALSE, FALSE, 2 }, // pause | 61 | { FALSE, FALSE, FALSE }, // next |
60 | { 5+4*32+xo, 200+yo, FALSE, FALSE, FALSE, 3 }, // next | 62 | { FALSE, FALSE, FALSE }, // volUp |
61 | { 5+5*32+xo, 200+yo, FALSE, FALSE, FALSE, 8 }, // playlist | 63 | { FALSE, FALSE, FALSE }, // volDown |
62 | { 5+6*32+xo, 200+yo, TRUE, FALSE, FALSE, 9 } // fullscreen | 64 | { TRUE, FALSE, FALSE } // fullscreen |
63 | }; | 65 | }; |
64 | 66 | ||
67 | //static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); | ||
65 | 68 | ||
66 | static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); | 69 | const char *skinV_mask_file_names[7] = { |
70 | "stop","play","back","fwd","up","down","full" | ||
71 | }; | ||
67 | 72 | ||
73 | static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); | ||
68 | 74 | ||
69 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : | 75 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : |
70 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { | 76 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) |
77 | { | ||
71 | setCaption( tr("OpiePlayer") ); | 78 | setCaption( tr("OpiePlayer") ); |
72 | Config cfg("OpiePlayer"); | 79 | Config cfg("OpiePlayer"); |
73 | cfg.setGroup("VideoWidget"); | 80 | |
74 | 81 | cfg.setGroup("Options"); | |
75 | QString backgroundPix, Button0aPix, Button0bPix, controlsPix; | 82 | skin = cfg.readEntry("Skin","default"); |
76 | backgroundPix=cfg.readEntry( "backgroundPix", "opieplayer/metalFinish"); | 83 | |
77 | Button0aPix=cfg.readEntry( "Button0aPix", "opieplayer/mediaButton0a"); | 84 | QString skinPath; |
78 | Button0bPix=cfg.readEntry( "Button0bPix","opieplayer/mediaButton0b"); | 85 | skinPath = "opieplayer2/skins/" + skin; |
79 | controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls0" ); | 86 | if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists()) |
80 | 87 | skinPath = "opieplayer2/skins/default"; | |
81 | setBackgroundPixmap( Resource::loadPixmap( backgroundPix) ); | 88 | |
82 | pixmaps[0] = new QPixmap( Resource::loadPixmap( Button0aPix ) ); | 89 | qDebug("skin path " + skinPath); |
83 | pixmaps[1] = new QPixmap( Resource::loadPixmap( Button0bPix ) ); | 90 | |
84 | pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix) ); | 91 | // QString skinPath = "opieplayer2/skins/" + skin; |
92 | |||
93 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | ||
94 | imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); | ||
95 | imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); | ||
96 | |||
97 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); | ||
98 | imgButtonMask->fill( 0 ); | ||
99 | |||
100 | for ( int i = 0; i < 7; i++ ) | ||
101 | { | ||
102 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + | ||
103 | "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); | ||
104 | qDebug("loading "+filename); | ||
105 | masks[i] = new QBitmap( filename ); | ||
106 | |||
107 | if ( !masks[i]->isNull() ) | ||
108 | { | ||
109 | QImage imgMask = masks[i]->convertToImage(); | ||
110 | uchar **dest = imgButtonMask->jumpTable(); | ||
111 | for ( int y = 0; y < imgUp->height(); y++ ) | ||
112 | { | ||
113 | uchar *line = dest[y]; | ||
114 | for ( int x = 0; x < imgUp->width(); x++ ) | ||
115 | { | ||
116 | if ( !qRed( imgMask.pixel( x, y ) ) ) | ||
117 | line[x] = i + 1; | ||
118 | } | ||
119 | } | ||
120 | } | ||
121 | } | ||
122 | qDebug("finished loading first pics"); | ||
123 | for ( int i = 0; i < 7; i++ ) | ||
124 | { | ||
125 | buttonPixUp[i] = NULL; | ||
126 | buttonPixDown[i] = NULL; | ||
127 | } | ||
128 | |||
129 | setBackgroundPixmap( *pixBg ); | ||
130 | |||
85 | currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); | 131 | currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); |
@@ -91,3 +137,3 @@ VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : | |||
91 | slider->setFocusPolicy( QWidget::NoFocus ); | 137 | slider->setFocusPolicy( QWidget::NoFocus ); |
92 | slider->setGeometry( QRect( 7, 250, 220, 20 ) ); | 138 | // slider->setGeometry( QRect( 7, 250, 220, 20 ) ); |
93 | 139 | ||
@@ -113,5 +159,21 @@ VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : | |||
113 | VideoWidget::~VideoWidget() { | 159 | VideoWidget::~VideoWidget() { |
114 | for ( int i = 0; i < 3; i++ ) | 160 | |
115 | delete pixmaps[i]; | 161 | for ( int i = 0; i < 7; i++ ) |
116 | delete currentFrame; | 162 | { |
163 | delete buttonPixUp[i]; | ||
164 | delete buttonPixDown[i]; | ||
165 | } | ||
166 | |||
167 | delete pixBg; | ||
168 | delete imgUp; | ||
169 | delete imgDn; | ||
170 | delete imgButtonMask; | ||
171 | for ( int i = 0; i < 7; i++ ) | ||
172 | { | ||
173 | delete masks[i]; | ||
174 | } | ||
175 | |||
176 | // for ( int i = 0; i < 3; i++ ) | ||
177 | // delete pixmaps[i]; | ||
178 | // delete currentFrame; | ||
117 | } | 179 | } |
@@ -121,2 +183,53 @@ static bool videoSliderBeingMoved = FALSE; | |||
121 | 183 | ||
184 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | ||
185 | QPixmap pix( img.width(), img.height() ); | ||
186 | QPainter p( &pix ); | ||
187 | p.drawTiledPixmap( pix.rect(), bg, offset ); | ||
188 | p.drawImage( 0, 0, img ); | ||
189 | return new QPixmap( pix ); | ||
190 | } | ||
191 | |||
192 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { | ||
193 | QPixmap *pixmap = new QPixmap( pix ); | ||
194 | pixmap->setMask( mask ); | ||
195 | return pixmap; | ||
196 | } | ||
197 | |||
198 | void VideoWidget::resizeEvent( QResizeEvent * ) { | ||
199 | int h = height(); | ||
200 | int w = width(); | ||
201 | //int Vh = 160; | ||
202 | //int Vw = 220; | ||
203 | |||
204 | slider->setFixedWidth( w - 20 ); | ||
205 | slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); | ||
206 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); | ||
207 | slider->setFocusPolicy( QWidget::NoFocus ); | ||
208 | slider->setBackgroundPixmap( *pixBg ); | ||
209 | |||
210 | xoff = 0;// ( imgUp->width() ) / 2; | ||
211 | if(w>h) | ||
212 | yoff = 0; | ||
213 | else | ||
214 | yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; | ||
215 | QPoint p( xoff, yoff ); | ||
216 | |||
217 | QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); | ||
218 | QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); | ||
219 | |||
220 | for ( int i = 0; i < 7; i++ ) | ||
221 | { | ||
222 | if ( !masks[i]->isNull() ) | ||
223 | { | ||
224 | delete buttonPixUp[i]; | ||
225 | delete buttonPixDown[i]; | ||
226 | buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); | ||
227 | buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); | ||
228 | } | ||
229 | } | ||
230 | |||
231 | delete pixUp; | ||
232 | delete pixDn; | ||
233 | } | ||
234 | |||
122 | 235 | ||
@@ -147,5 +260,8 @@ void VideoWidget::setLength( long max ) { | |||
147 | void VideoWidget::setView( char view ) { | 260 | void VideoWidget::setView( char view ) { |
148 | if ( view == 'v' ) { | 261 | if ( view == 'v' ) |
262 | { | ||
149 | makeVisible(); | 263 | makeVisible(); |
150 | } else { | 264 | } |
265 | else | ||
266 | { | ||
151 | // 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 |
@@ -164,3 +280,4 @@ void VideoWidget::updateSlider( long i, long max ) { | |||
164 | int val = int((double)i * width / max); | 280 | int val = int((double)i * width / max); |
165 | if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { | 281 | if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) |
282 | { | ||
166 | if ( slider->value() != val ) | 283 | if ( slider->value() != val ) |
@@ -187,7 +304,15 @@ void VideoWidget::toggleButton( int i ) { | |||
187 | void VideoWidget::paintButton( QPainter *p, int i ) { | 304 | void VideoWidget::paintButton( QPainter *p, int i ) { |
188 | int x = videoButtons[i].xPos; | 305 | if ( videoButtons[i].isDown ) |
189 | int y = videoButtons[i].yPos; | 306 | { |
190 | int offset = 10 + videoButtons[i].isDown; | 307 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); |
191 | p->drawPixmap( x, y, *pixmaps[videoButtons[i].isDown] ); | 308 | } |
192 | p->drawPixmap( x + 1 + offset, y + offset, *pixmaps[2], 9 * videoButtons[i].controlType, 0, 9, 9 ); | 309 | else |
310 | { | ||
311 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | ||
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 ); | ||
193 | } | 318 | } |
@@ -196,34 +321,84 @@ void VideoWidget::paintButton( QPainter *p, int i ) { | |||
196 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 321 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
197 | for ( int i = 0; i < numButtons; i++ ) { | 322 | |
198 | int x = videoButtons[i].xPos; | 323 | for ( int i = 0; i < numVButtons; i++ ) |
199 | int y = videoButtons[i].yPos; | 324 | { |
200 | if ( event->state() == QMouseEvent::LeftButton ) { | 325 | if ( event->state() == QMouseEvent::LeftButton ) |
201 | // The test to see if the mouse click is inside the circular button or not | 326 | { |
202 | // (compared with the radius squared to avoid a square-root of our distance) | 327 | // The test to see if the mouse click is inside the button or not |
203 | int radius = 16; | 328 | int x = event->pos().x() - xoff; |
204 | QPoint center = QPoint( x + radius, y + radius ); | 329 | int y = event->pos().y() - yoff; |
205 | QPoint dXY = center - event->pos(); | 330 | |
206 | int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); | 331 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() |
207 | bool isOnButton = dist <= (radius * radius); | 332 | && y < imgButtonMask->height() |
208 | if ( isOnButton != videoButtons[i].isHeld ) { | 333 | && imgButtonMask->pixelIndex( x, y ) == i + 1 ); |
209 | videoButtons[i].isHeld = isOnButton; | 334 | |
335 | if ( isOnButton && !videoButtons[i].isHeld ) | ||
336 | { | ||
337 | videoButtons[i].isHeld = TRUE; | ||
210 | toggleButton(i); | 338 | toggleButton(i); |
339 | |||
340 | // switch (i) { | ||
341 | // case VideoVolUp: | ||
342 | // emit moreClicked(); | ||
343 | // return; | ||
344 | // case VideoVolDown: | ||
345 | // emit lessClicked(); | ||
346 | // return; | ||
347 | // } | ||
211 | } | 348 | } |
212 | } else { | 349 | else if ( !isOnButton && videoButtons[i].isHeld ) |
213 | if ( videoButtons[i].isHeld ) { | 350 | { |
351 | videoButtons[i].isHeld = FALSE; | ||
352 | toggleButton(i); | ||
353 | } | ||
354 | } | ||
355 | else | ||
356 | { | ||
357 | |||
358 | if ( videoButtons[i].isHeld ) | ||
359 | { | ||
214 | videoButtons[i].isHeld = FALSE; | 360 | videoButtons[i].isHeld = FALSE; |
215 | if ( !videoButtons[i].isToggle ) | 361 | if ( !videoButtons[i].isToggle ) |
362 | { | ||
216 | setToggleButton( i, FALSE ); | 363 | setToggleButton( i, FALSE ); |
217 | } | 364 | } |
218 | } | 365 | qDebug("key %d", i); |
219 | switch (i) { | 366 | switch(i) |
367 | { | ||
368 | // case VideoPlay: | ||
369 | // { | ||
370 | // if( mediaPlayerState->isPaused ) | ||
371 | // { | ||
372 | // setToggleButton( i, FALSE ); | ||
373 | // mediaPlayerState->setPaused( FALSE ); | ||
374 | // return; | ||
375 | // } | ||
376 | // else if( !mediaPlayerState->isPaused ) | ||
377 | // { | ||
378 | // setToggleButton( i, TRUE ); | ||
379 | // mediaPlayerState->setPaused( TRUE ); | ||
380 | // return; | ||
381 | // } | ||
382 | // else | ||
383 | // { | ||
384 | // return; | ||
385 | // } | ||
386 | // } | ||
387 | |||
220 | case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; | 388 | case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; |
221 | case VideoStop: mediaPlayerState->setPlaying(FALSE); return; | 389 | case VideoStop: mediaPlayerState->setPlaying(FALSE); return; |
222 | case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; | 390 | // case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; |
223 | case VideoNext: mediaPlayerState->setNext(); return; | 391 | case VideoNext: mediaPlayerState->setNext(); return; |
224 | case VideoPrevious: mediaPlayerState->setPrev(); return; | 392 | case VideoPrevious: mediaPlayerState->setPrev(); return; |
225 | case VideoPlayList: mediaPlayerState->setList(); return; | 393 | // case VideoPlayList: mediaPlayerState->setList(); return; |
226 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | 394 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; |
227 | } | ||
228 | 395 | ||
396 | // case VideoStop: mediaPlayerState->setPlaying( FALSE ); return; | ||
397 | // case VideoNext: if(playList->whichList() ==0) mediaPlayerState->setNext(); return; | ||
398 | // case VideoPrevious: if(playList->whichList() ==0) mediaPlayerState->setPrev(); return; | ||
399 | // case VideoVolUp: emit moreReleased(); return; | ||
400 | // case VideoVolDown: emit lessReleased(); return; | ||
401 | // case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | ||
402 | } | ||
403 | } | ||
229 | } | 404 | } |
@@ -232,2 +407,43 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | |||
232 | 407 | ||
408 | |||
409 | |||
410 | |||
411 | |||
412 | // for ( int i = 0; i < numButtons; i++ ) { | ||
413 | // int x = videoButtons[i].xPos; | ||
414 | // int y = videoButtons[i].yPos; | ||
415 | // if ( event->state() == QMouseEvent::LeftButton ) { | ||
416 | // // The test to see if the mouse click is inside the circular button or not | ||
417 | // // (compared with the radius squared to avoid a square-root of our distance) | ||
418 | // int radius = 16; | ||
419 | // QPoint center = QPoint( x + radius, y + radius ); | ||
420 | // QPoint dXY = center - event->pos(); | ||
421 | // int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); | ||
422 | // bool isOnButton = dist <= (radius * radius); | ||
423 | // if ( isOnButton != videoButtons[i].isHeld ) { | ||
424 | // videoButtons[i].isHeld = isOnButton; | ||
425 | // toggleButton(i); | ||
426 | // } | ||
427 | // } else { | ||
428 | // if ( videoButtons[i].isHeld ) { | ||
429 | // videoButtons[i].isHeld = FALSE; | ||
430 | // if ( !videoButtons[i].isToggle ) | ||
431 | // setToggleButton( i, FALSE ); | ||
432 | // } | ||
433 | // } | ||
434 | |||
435 | // switch (i) { | ||
436 | // case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; | ||
437 | // case VideoStop: mediaPlayerState->setPlaying(FALSE); return; | ||
438 | // case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; | ||
439 | // case VideoNext: mediaPlayerState->setNext(); return; | ||
440 | // case VideoPrevious: mediaPlayerState->setPrev(); return; | ||
441 | // case VideoPlayList: mediaPlayerState->setList(); return; | ||
442 | // case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | ||
443 | // } | ||
444 | |||
445 | // } | ||
446 | } | ||
447 | |||
448 | |||
233 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { | 449 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { |
@@ -238,3 +454,4 @@ void VideoWidget::mousePressEvent( QMouseEvent *event ) { | |||
238 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 454 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
239 | if ( mediaPlayerState->fullscreen() ) { | 455 | if ( mediaPlayerState->fullscreen() ) |
456 | { | ||
240 | mediaPlayerState->setFullscreen( FALSE ); | 457 | mediaPlayerState->setFullscreen( FALSE ); |
@@ -248,3 +465,4 @@ void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | |||
248 | void VideoWidget::makeVisible() { | 465 | void VideoWidget::makeVisible() { |
249 | if ( mediaPlayerState->fullscreen() ) { | 466 | if ( mediaPlayerState->fullscreen() ) |
467 | { | ||
250 | setBackgroundMode( QWidget::NoBackground ); | 468 | setBackgroundMode( QWidget::NoBackground ); |
@@ -253,4 +471,6 @@ void VideoWidget::makeVisible() { | |||
253 | slider->hide(); | 471 | slider->hide(); |
254 | } else { | 472 | } |
255 | setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); | 473 | else |
474 | { | ||
475 | setBackgroundPixmap( *pixBg ); | ||
256 | showNormal(); | 476 | showNormal(); |
@@ -262,3 +482,3 @@ void VideoWidget::makeVisible() { | |||
262 | 482 | ||
263 | void VideoWidget::paintEvent( QPaintEvent * ) { | 483 | void VideoWidget::paintEvent( QPaintEvent * pe) { |
264 | QPainter p( this ); | 484 | QPainter p( this ); |
@@ -269,21 +489,19 @@ void VideoWidget::paintEvent( QPaintEvent * ) { | |||
269 | p.drawRect( rect() ); | 489 | p.drawRect( rect() ); |
270 | |||
271 | // Draw the current frame | ||
272 | //p.drawImage( ); // If using directpainter we won't have a copy except whats on the screen | ||
273 | } else { | 490 | } else { |
274 | // draw border | 491 | if ( !pe->erased() ) { |
275 | qDrawShadePanel( &p, 4, 15, 230, 170, colorGroup(), TRUE, 5, NULL ); | 492 | // Combine with background and double buffer |
276 | 493 | QPixmap pix( pe->rect().size() ); | |
277 | // Clear the movie screen first | 494 | QPainter p( &pix ); |
278 | p.setBrush( QBrush( Qt::black ) ); | 495 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
279 | p.drawRect( 9, 20, 220, 160 ); | 496 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); |
280 | 497 | for ( int i = 0; i < numVButtons; i++ ) { | |
281 | // draw current frame (centrally positioned from scaling to maintain aspect ratio) | ||
282 | p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); | ||
283 | |||
284 | // draw the buttons | ||
285 | for ( int i = 0; i < numButtons; i++ ) | ||
286 | paintButton( &p, i ); | 498 | paintButton( &p, i ); |
287 | 499 | } | |
288 | // draw the slider | 500 | QPainter p2( this ); |
501 | p2.drawPixmap( pe->rect().topLeft(), pix ); | ||
502 | } else { | ||
503 | QPainter p( this ); | ||
504 | for ( int i = 0; i < numVButtons; i++ ) | ||
505 | paintButton( &p, i ); | ||
506 | } | ||
289 | slider->repaint( TRUE ); | 507 | slider->repaint( TRUE ); |
@@ -300,3 +518,3 @@ bool VideoWidget::playVideo() { | |||
300 | bool result = FALSE; | 518 | bool result = FALSE; |
301 | 519 | // qDebug("<<<<<<<<<<<<<<<< play video"); | |
302 | int stream = 0; | 520 | int stream = 0; |
@@ -311,3 +529,4 @@ bool VideoWidget::playVideo() { | |||
311 | 529 | ||
312 | if ( mediaPlayerState->fullscreen() ) { | 530 | if ( mediaPlayerState->fullscreen() ) |
531 | { | ||
313 | #ifdef USE_DIRECT_PAINTER | 532 | #ifdef USE_DIRECT_PAINTER |
@@ -316,3 +535,4 @@ bool VideoWidget::playVideo() { | |||
316 | if ( ( qt_screen->transformOrientation() == 3 ) && | 535 | if ( ( qt_screen->transformOrientation() == 3 ) && |
317 | ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) ) { | 536 | ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) ) |
537 | { | ||
318 | 538 | ||
@@ -321,3 +541,4 @@ bool VideoWidget::playVideo() { | |||
321 | 541 | ||
322 | if ( mediaPlayerState->scaled() ) { | 542 | if ( mediaPlayerState->scaled() ) |
543 | { | ||
323 | // maintain aspect ratio | 544 | // maintain aspect ratio |
@@ -327,3 +548,5 @@ bool VideoWidget::playVideo() { | |||
327 | h = sh * w / sw; | 548 | h = sh * w / sw; |
328 | } else { | 549 | } |
550 | else | ||
551 | { | ||
329 | w = sw; | 552 | w = sw; |
@@ -342,3 +565,5 @@ bool VideoWidget::playVideo() { | |||
342 | uchar **jt = new uchar*[h]; | 565 | uchar **jt = new uchar*[h]; |
343 | for ( int i = h; i; i-- ) { | 566 | |
567 | for ( int i = h; i; i-- ) | ||
568 | { | ||
344 | jt[h - i] = fp; | 569 | jt[h - i] = fp; |
@@ -350,3 +575,5 @@ bool VideoWidget::playVideo() { | |||
350 | delete [] jt; | 575 | delete [] jt; |
351 | } else { | 576 | } |
577 | else | ||
578 | { | ||
352 | #endif | 579 | #endif |
@@ -357,3 +584,4 @@ bool VideoWidget::playVideo() { | |||
357 | 584 | ||
358 | if ( mediaPlayerState->scaled() ) { | 585 | if ( mediaPlayerState->scaled() ) |
586 | { | ||
359 | // maintain aspect ratio | 587 | // maintain aspect ratio |
@@ -363,3 +591,5 @@ bool VideoWidget::playVideo() { | |||
363 | h = sh * w / sw; | 591 | h = sh * w / sw; |
364 | } else { | 592 | } |
593 | else | ||
594 | { | ||
365 | w = sw; | 595 | w = sw; |
@@ -372,3 +602,5 @@ bool VideoWidget::playVideo() { | |||
372 | 0, 0, sw, sh, w, h, format, 0) == 0; | 602 | 0, 0, sw, sh, w, h, format, 0) == 0; |
373 | if ( result && mediaPlayerState->fullscreen() ) { | 603 | |
604 | if ( result && mediaPlayerState->fullscreen() ) | ||
605 | { | ||
374 | 606 | ||
@@ -380,4 +612,7 @@ bool VideoWidget::playVideo() { | |||
380 | int spl = rotatedFrame.bytesPerLine() / bytes; | 612 | int spl = rotatedFrame.bytesPerLine() / bytes; |
381 | for (int x=0; x<h; x++) { | 613 | |
382 | if ( bytes == 2 ) { | 614 | for (int x=0; x<h; x++) |
615 | { | ||
616 | if ( bytes == 2 ) | ||
617 | { | ||
383 | ushort* lout = out++ + (w - 1)*spl; | 618 | ushort* lout = out++ + (w - 1)*spl; |
@@ -387,5 +622,8 @@ bool VideoWidget::playVideo() { | |||
387 | } | 622 | } |
388 | } else { | 623 | } |
624 | else | ||
625 | { | ||
389 | ulong* lout = ((ulong *)out)++ + (w - 1)*spl; | 626 | ulong* lout = ((ulong *)out)++ + (w - 1)*spl; |
390 | for (int y=0; y<w; y++) { | 627 | for (int y=0; y<w; y++) |
628 | { | ||
391 | *lout=*((ulong*)in)++; | 629 | *lout=*((ulong*)in)++; |
@@ -401,3 +639,5 @@ bool VideoWidget::playVideo() { | |||
401 | #endif | 639 | #endif |
402 | } else { | 640 | } |
641 | else | ||
642 | { | ||
403 | 643 | ||
@@ -415,7 +655,8 @@ bool VideoWidget::playVideo() { | |||
415 | QPainter p( this ); | 655 | QPainter p( this ); |
416 | 656 | int deskW = qApp->desktop()->width(); | |
417 | // Image changed size, therefore need to blank the possibly unpainted regions first | 657 | // Image changed size, therefore need to blank the possibly unpainted regions first |
418 | if ( scaledWidth != w || scaledHeight != h ) { | 658 | if ( scaledWidth != w || scaledHeight != h ) |
659 | { | ||
419 | p.setBrush( QBrush( Qt::black ) ); | 660 | p.setBrush( QBrush( Qt::black ) ); |
420 | p.drawRect( 9, 20, 220, 160 ); | 661 | p.drawRect( ( deskW -scaledWidth)/2, 20, scaledWidth, 160 ); |
421 | } | 662 | } |
@@ -425,4 +666,5 @@ bool VideoWidget::playVideo() { | |||
425 | 666 | ||
426 | if ( result ) { | 667 | if ( result ) |
427 | p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); | 668 | { |
669 | p.drawImage( (deskW - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); | ||
428 | } | 670 | } |
@@ -438,3 +680,4 @@ void VideoWidget::keyReleaseEvent( QKeyEvent *e) | |||
438 | { | 680 | { |
439 | switch ( e->key() ) { | 681 | switch ( e->key() ) |
682 | { | ||
440 | ////////////////////////////// Zaurus keys | 683 | ////////////////////////////// Zaurus keys |
@@ -453,6 +696,10 @@ void VideoWidget::keyReleaseEvent( QKeyEvent *e) | |||
453 | break; | 696 | break; |
454 | case Key_Space: { | 697 | case Key_Space: |
455 | if(mediaPlayerState->playing()) { | 698 | { |
699 | if(mediaPlayerState->playing()) | ||
700 | { | ||
456 | mediaPlayerState->setPlaying(FALSE); | 701 | mediaPlayerState->setPlaying(FALSE); |
457 | } else { | 702 | } |
703 | else | ||
704 | { | ||
458 | mediaPlayerState->setPlaying(TRUE); | 705 | mediaPlayerState->setPlaying(TRUE); |