author | llornkcor <llornkcor> | 2002-09-19 19:45:49 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-09-19 19:45:49 (UTC) |
commit | 2e0cb5c85f913141985df4e7f2514817851420fb (patch) (unidiff) | |
tree | e58f576310994d1bb813143cb96b312af37b78fb | |
parent | aef34909dcfb2ffb637c9d3693e395c15b255cb2 (diff) | |
download | opie-2e0cb5c85f913141985df4e7f2514817851420fb.zip opie-2e0cb5c85f913141985df4e7f2514817851420fb.tar.gz opie-2e0cb5c85f913141985df4e7f2514817851420fb.tar.bz2 |
tweak for landscape mode
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 8e3a365..b0ec673 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -144,103 +144,106 @@ QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { | |||
144 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 144 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
145 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 145 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
146 | 146 | ||
147 | setLength( mediaPlayerState->length() ); | 147 | setLength( mediaPlayerState->length() ); |
148 | setPosition( mediaPlayerState->position() ); | 148 | setPosition( mediaPlayerState->position() ); |
149 | setFullscreen( mediaPlayerState->fullscreen() ); | 149 | setFullscreen( mediaPlayerState->fullscreen() ); |
150 | setPlaying( mediaPlayerState->playing() ); | 150 | setPlaying( mediaPlayerState->playing() ); |
151 | } | 151 | } |
152 | 152 | ||
153 | 153 | ||
154 | VideoWidget::~VideoWidget() { | 154 | VideoWidget::~VideoWidget() { |
155 | 155 | ||
156 | for ( int i = 0; i < 7; i++ ) { | 156 | for ( int i = 0; i < 7; i++ ) { |
157 | delete buttonPixUp[i]; | 157 | delete buttonPixUp[i]; |
158 | delete buttonPixDown[i]; | 158 | delete buttonPixDown[i]; |
159 | } | 159 | } |
160 | 160 | ||
161 | delete pixBg; | 161 | delete pixBg; |
162 | delete imgUp; | 162 | delete imgUp; |
163 | delete imgDn; | 163 | delete imgDn; |
164 | delete imgButtonMask; | 164 | delete imgButtonMask; |
165 | for ( int i = 0; i < 7; i++ ) { | 165 | for ( int i = 0; i < 7; i++ ) { |
166 | delete masks[i]; | 166 | delete masks[i]; |
167 | } | 167 | } |
168 | 168 | ||
169 | } | 169 | } |
170 | 170 | ||
171 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 171 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
172 | QPixmap pix( img.width(), img.height() ); | 172 | QPixmap pix( img.width(), img.height() ); |
173 | QPainter p( &pix ); | 173 | QPainter p( &pix ); |
174 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 174 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
175 | p.drawImage( 0, 0, img ); | 175 | p.drawImage( 0, 0, img ); |
176 | return new QPixmap( pix ); | 176 | return new QPixmap( pix ); |
177 | } | 177 | } |
178 | 178 | ||
179 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { | 179 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { |
180 | QPixmap *pixmap = new QPixmap( pix ); | 180 | QPixmap *pixmap = new QPixmap( pix ); |
181 | pixmap->setMask( mask ); | 181 | pixmap->setMask( mask ); |
182 | return pixmap; | 182 | return pixmap; |
183 | } | 183 | } |
184 | 184 | ||
185 | void VideoWidget::resizeEvent( QResizeEvent * ) { | 185 | void VideoWidget::resizeEvent( QResizeEvent * ) { |
186 | int h = height(); | 186 | int h = height(); |
187 | int w = width(); | 187 | int w = width(); |
188 | //int Vh = 160; | 188 | //int Vh = 160; |
189 | //int Vw = 220; | 189 | //int Vw = 220; |
190 | 190 | ||
191 | slider->setFixedWidth( w - 20 ); | 191 | slider->setFixedWidth( w - 20 ); |
192 | slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); | 192 | slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); |
193 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); | 193 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); |
194 | slider->setFocusPolicy( QWidget::NoFocus ); | 194 | slider->setFocusPolicy( QWidget::NoFocus ); |
195 | slider->setBackgroundPixmap( *pixBg ); | 195 | slider->setBackgroundPixmap( *pixBg ); |
196 | 196 | ||
197 | xoff = 0;// ( imgUp->width() ) / 2; | 197 | xoff = 0;// ( imgUp->width() ) / 2; |
198 | yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; | 198 | if(w>h) |
199 | yoff = 0; | ||
200 | else | ||
201 | yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; | ||
199 | QPoint p( xoff, yoff ); | 202 | QPoint p( xoff, yoff ); |
200 | 203 | ||
201 | QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); | 204 | QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); |
202 | QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); | 205 | QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); |
203 | 206 | ||
204 | for ( int i = 0; i < 7; i++ ) { | 207 | for ( int i = 0; i < 7; i++ ) { |
205 | if ( !masks[i]->isNull() ) { | 208 | if ( !masks[i]->isNull() ) { |
206 | delete buttonPixUp[i]; | 209 | delete buttonPixUp[i]; |
207 | delete buttonPixDown[i]; | 210 | delete buttonPixDown[i]; |
208 | buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); | 211 | buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); |
209 | buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); | 212 | buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); |
210 | } | 213 | } |
211 | } | 214 | } |
212 | 215 | ||
213 | delete pixUp; | 216 | delete pixUp; |
214 | delete pixDn; | 217 | delete pixDn; |
215 | } | 218 | } |
216 | 219 | ||
217 | static bool videoSliderBeingMoved = FALSE; | 220 | static bool videoSliderBeingMoved = FALSE; |
218 | 221 | ||
219 | void VideoWidget::sliderPressed() { | 222 | void VideoWidget::sliderPressed() { |
220 | videoSliderBeingMoved = TRUE; | 223 | videoSliderBeingMoved = TRUE; |
221 | } | 224 | } |
222 | 225 | ||
223 | void VideoWidget::sliderReleased() { | 226 | void VideoWidget::sliderReleased() { |
224 | videoSliderBeingMoved = FALSE; | 227 | videoSliderBeingMoved = FALSE; |
225 | if ( slider->width() == 0 ) { | 228 | if ( slider->width() == 0 ) { |
226 | return; | 229 | return; |
227 | } | 230 | } |
228 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); | 231 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); |
229 | mediaPlayerState->setPosition( val ); | 232 | mediaPlayerState->setPosition( val ); |
230 | } | 233 | } |
231 | 234 | ||
232 | void VideoWidget::setPosition( long i ) { | 235 | void VideoWidget::setPosition( long i ) { |
233 | updateSlider( i, mediaPlayerState->length() ); | 236 | updateSlider( i, mediaPlayerState->length() ); |
234 | } | 237 | } |
235 | 238 | ||
236 | 239 | ||
237 | void VideoWidget::setLength( long max ) { | 240 | void VideoWidget::setLength( long max ) { |
238 | updateSlider( mediaPlayerState->position(), max ); | 241 | updateSlider( mediaPlayerState->position(), max ); |
239 | } | 242 | } |
240 | 243 | ||
241 | void VideoWidget::setView( char view ) { | 244 | void VideoWidget::setView( char view ) { |
242 | 245 | ||
243 | if ( view == 'v' ) { | 246 | if ( view == 'v' ) { |
244 | makeVisible(); | 247 | makeVisible(); |
245 | } else { | 248 | } else { |
246 | // Effectively blank the view next time we show it so it looks nicer | 249 | // Effectively blank the view next time we show it so it looks nicer |
@@ -350,97 +353,107 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | |||
350 | } | 353 | } |
351 | } | 354 | } |
352 | } | 355 | } |
353 | 356 | ||
354 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { | 357 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { |
355 | mouseMoveEvent( event ); | 358 | mouseMoveEvent( event ); |
356 | } | 359 | } |
357 | 360 | ||
358 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 361 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
359 | if ( mediaPlayerState->fullscreen() ) { | 362 | if ( mediaPlayerState->fullscreen() ) { |
360 | mediaPlayerState->setFullscreen( FALSE ); | 363 | mediaPlayerState->setFullscreen( FALSE ); |
361 | makeVisible(); | 364 | makeVisible(); |
362 | } | 365 | } |
363 | mouseMoveEvent( event ); | 366 | mouseMoveEvent( event ); |
364 | } | 367 | } |
365 | 368 | ||
366 | void VideoWidget::showEvent( QShowEvent* ) { | 369 | void VideoWidget::showEvent( QShowEvent* ) { |
367 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 370 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
368 | mouseMoveEvent( &event ); | 371 | mouseMoveEvent( &event ); |
369 | } | 372 | } |
370 | 373 | ||
371 | 374 | ||
372 | void VideoWidget::backToNormal() { | 375 | void VideoWidget::backToNormal() { |
373 | mediaPlayerState->setFullscreen( FALSE ); | 376 | mediaPlayerState->setFullscreen( FALSE ); |
374 | makeVisible(); | 377 | makeVisible(); |
375 | } | 378 | } |
376 | 379 | ||
377 | void VideoWidget::makeVisible() { | 380 | void VideoWidget::makeVisible() { |
378 | if ( mediaPlayerState->fullscreen() ) { | 381 | if ( mediaPlayerState->fullscreen() ) { |
379 | setBackgroundMode( QWidget::NoBackground ); | 382 | setBackgroundMode( QWidget::NoBackground ); |
380 | showFullScreen(); | 383 | showFullScreen(); |
381 | resize( qApp->desktop()->size() ); | 384 | resize( qApp->desktop()->size() ); |
382 | slider->hide(); | 385 | slider->hide(); |
383 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); | 386 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); |
384 | qApp->processEvents(); | 387 | qApp->processEvents(); |
385 | } else { | 388 | } else { |
386 | showNormal(); | 389 | showNormal(); |
387 | showMaximized(); | 390 | showMaximized(); |
388 | setBackgroundPixmap( *pixBg ); | 391 | setBackgroundPixmap( *pixBg ); |
389 | if ( mediaPlayerState->streaming() ) { | 392 | if ( mediaPlayerState->streaming() ) { |
390 | slider->hide(); | 393 | slider->hide(); |
391 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 394 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
392 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 395 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
393 | } else { | 396 | } else { |
394 | slider->show(); | 397 | slider->show(); |
395 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 398 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
396 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 399 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
397 | } | 400 | } |
398 | videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); | 401 | |
402 | QWidget *d = QApplication::desktop(); | ||
403 | int w=d->width(); | ||
404 | int h=d->height(); | ||
405 | |||
406 | if(w>h) { | ||
407 | int newW=(w/2)-(246/2); //this will only work with 320x240 | ||
408 | videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); | ||
409 | } else | ||
410 | videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); | ||
411 | |||
399 | qApp->processEvents(); | 412 | qApp->processEvents(); |
400 | } | 413 | } |
401 | } | 414 | } |
402 | 415 | ||
403 | 416 | ||
404 | void VideoWidget::paintEvent( QPaintEvent * pe) { | 417 | void VideoWidget::paintEvent( QPaintEvent * pe) { |
405 | QPainter p( this ); | 418 | QPainter p( this ); |
406 | 419 | ||
407 | if ( mediaPlayerState->fullscreen() ) { | 420 | if ( mediaPlayerState->fullscreen() ) { |
408 | // Clear the background | 421 | // Clear the background |
409 | p.setBrush( QBrush( Qt::black ) ); | 422 | p.setBrush( QBrush( Qt::black ) ); |
410 | } else { | 423 | } else { |
411 | if ( !pe->erased() ) { | 424 | if ( !pe->erased() ) { |
412 | // Combine with background and double buffer | 425 | // Combine with background and double buffer |
413 | QPixmap pix( pe->rect().size() ); | 426 | QPixmap pix( pe->rect().size() ); |
414 | QPainter p( &pix ); | 427 | QPainter p( &pix ); |
415 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 428 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
416 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); | 429 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); |
417 | for ( int i = 0; i < numVButtons; i++ ) { | 430 | for ( int i = 0; i < numVButtons; i++ ) { |
418 | paintButton( &p, i ); | 431 | paintButton( &p, i ); |
419 | } | 432 | } |
420 | QPainter p2( this ); | 433 | QPainter p2( this ); |
421 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 434 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
422 | } else { | 435 | } else { |
423 | QPainter p( this ); | 436 | QPainter p( this ); |
424 | for ( int i = 0; i < numVButtons; i++ ) | 437 | for ( int i = 0; i < numVButtons; i++ ) |
425 | paintButton( &p, i ); | 438 | paintButton( &p, i ); |
426 | } | 439 | } |
427 | slider->repaint( TRUE ); | 440 | slider->repaint( TRUE ); |
428 | } | 441 | } |
429 | } | 442 | } |
430 | 443 | ||
431 | 444 | ||
432 | void VideoWidget::closeEvent( QCloseEvent* ) { | 445 | void VideoWidget::closeEvent( QCloseEvent* ) { |
433 | mediaPlayerState->setList(); | 446 | mediaPlayerState->setList(); |
434 | } | 447 | } |
435 | 448 | ||
436 | 449 | ||
437 | 450 | ||
438 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { | 451 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { |
439 | switch ( e->key() ) { | 452 | switch ( e->key() ) { |
440 | ////////////////////////////// Zaurus keys | 453 | ////////////////////////////// Zaurus keys |
441 | case Key_Home: | 454 | case Key_Home: |
442 | break; | 455 | break; |
443 | case Key_F9: //activity | 456 | case Key_F9: //activity |
444 | break; | 457 | break; |
445 | case Key_F10: //contacts | 458 | case Key_F10: //contacts |
446 | // hide(); | 459 | // hide(); |