summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 419c3ae..a4e6b6e 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -147,101 +147,105 @@ QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) {
147// setFullscreen( mediaPlayerState->fullscreen() ); 147// setFullscreen( mediaPlayerState->fullscreen() );
148 setPaused( mediaPlayerState->paused() ); 148 setPaused( mediaPlayerState->paused() );
149 setPlaying( mediaPlayerState->playing() ); 149 setPlaying( mediaPlayerState->playing() );
150 qDebug("finished videowidget"); 150 qDebug("finished videowidget");
151} 151}
152 152
153 153
154VideoWidget::~VideoWidget() { 154VideoWidget::~VideoWidget() {
155 for ( int i = 0; i < 7; i++ ) { 155 for ( int i = 0; i < 7; i++ ) {
156 delete buttonPixUp[i]; 156 delete buttonPixUp[i];
157 delete buttonPixDown[i]; 157 delete buttonPixDown[i];
158 } 158 }
159 159
160 delete pixBg; 160 delete pixBg;
161 delete imgUp; 161 delete imgUp;
162 delete imgDn; 162 delete imgDn;
163 delete imgButtonMask; 163 delete imgButtonMask;
164 for ( int i = 0; i < 7; i++ ) { 164 for ( int i = 0; i < 7; i++ ) {
165 delete masks[i]; 165 delete masks[i];
166 } 166 }
167} 167}
168 168
169QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 169QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
170 QPixmap pix( img.width(), img.height() ); 170 QPixmap pix( img.width(), img.height() );
171 QPainter p( &pix ); 171 QPainter p( &pix );
172 p.drawTiledPixmap( pix.rect(), bg, offset ); 172 p.drawTiledPixmap( pix.rect(), bg, offset );
173 p.drawImage( 0, 0, img ); 173 p.drawImage( 0, 0, img );
174 return new QPixmap( pix ); 174 return new QPixmap( pix );
175} 175}
176 176
177QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { 177QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) {
178 QPixmap *pixmap = new QPixmap( pix ); 178 QPixmap *pixmap = new QPixmap( pix );
179 pixmap->setMask( mask ); 179 pixmap->setMask( mask );
180 return pixmap; 180 return pixmap;
181} 181}
182 182
183void VideoWidget::resizeEvent( QResizeEvent * ) { 183void VideoWidget::resizeEvent( QResizeEvent * ) {
184 int h = height(); 184 int h = height();
185 int w = width(); 185 int w = width();
186 int Vh = 160; 186 int Vh = 160;
187 //videoFrame->height(); 187 //videoFrame->height();
188 int Vw = 220; 188 int Vw = 220;
189 //videoFrame->width(); 189 //videoFrame->width();
190// songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); 190// songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) );
191 191
192 slider->setFixedWidth( w - 110 ); 192 slider->setFixedWidth( w - 110 );
193 slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); 193 slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) );
194 slider->setBackgroundOrigin( QWidget::ParentOrigin ); 194 slider->setBackgroundOrigin( QWidget::ParentOrigin );
195 slider->setFocusPolicy( QWidget::NoFocus );
196make slider->setBackgroundPixmap( *pixBg );
197
195// time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); 198// time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
196 xoff = 0;// ( imgUp->width() ) / 2; 199 xoff = 0;// ( imgUp->width() ) / 2;
197 yoff = 180;//(( Vh - imgUp->height() ) / 2) - 10; 200 yoff = 180;//(( Vh - imgUp->height() ) / 2) - 10;
198 QPoint p( xoff, yoff ); 201 QPoint p( xoff, yoff );
199 202
203
200 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); 204 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p );
201 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); 205 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p );
202 206
203 for ( int i = 0; i < 7; i++ ) { 207 for ( int i = 0; i < 7; i++ ) {
204 if ( !masks[i]->isNull() ) { 208 if ( !masks[i]->isNull() ) {
205 delete buttonPixUp[i]; 209 delete buttonPixUp[i];
206 delete buttonPixDown[i]; 210 delete buttonPixDown[i];
207 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); 211 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] );
208 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); 212 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] );
209 } 213 }
210 } 214 }
211 215
212 delete pixUp; 216 delete pixUp;
213 delete pixDn; 217 delete pixDn;
214} 218}
215 219
216static bool videoSliderBeingMoved = FALSE; 220static bool videoSliderBeingMoved = FALSE;
217 221
218void VideoWidget::sliderPressed() { 222void VideoWidget::sliderPressed() {
219 videoSliderBeingMoved = TRUE; 223 videoSliderBeingMoved = TRUE;
220} 224}
221 225
222void VideoWidget::sliderReleased() { 226void VideoWidget::sliderReleased() {
223 videoSliderBeingMoved = FALSE; 227 videoSliderBeingMoved = FALSE;
224 if ( slider->width() == 0 ) { 228 if ( slider->width() == 0 ) {
225 return; 229 return;
226 } 230 }
227 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); 231 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width());
228 mediaPlayerState->setPosition( val ); 232 mediaPlayerState->setPosition( val );
229} 233}
230 234
231void VideoWidget::setPosition( long i ) { 235void VideoWidget::setPosition( long i ) {
232 updateSlider( i, mediaPlayerState->length() ); 236 updateSlider( i, mediaPlayerState->length() );
233} 237}
234 238
235 239
236void VideoWidget::setLength( long max ) { 240void VideoWidget::setLength( long max ) {
237 updateSlider( mediaPlayerState->position(), max ); 241 updateSlider( mediaPlayerState->position(), max );
238} 242}
239 243
240void VideoWidget::setView( char view ) { 244void VideoWidget::setView( char view ) {
241 if ( view == 'v' ) { 245 if ( view == 'v' ) {
242 makeVisible(); 246 makeVisible();
243 } else { 247 } else {
244 // Effectively blank the view next time we show it so it looks nicer 248 // Effectively blank the view next time we show it so it looks nicer
245 scaledWidth = 0; 249 scaledWidth = 0;
246 scaledHeight = 0; 250 scaledHeight = 0;
247 hide(); 251 hide();
@@ -295,97 +299,96 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
295 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() 299 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
296 && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); 300 && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 );
297 if ( isOnButton != videoButtons[i].isHeld ) { 301 if ( isOnButton != videoButtons[i].isHeld ) {
298 videoButtons[i].isHeld = isOnButton; 302 videoButtons[i].isHeld = isOnButton;
299 toggleButton(i); 303 toggleButton(i);
300 } 304 }
301 } else { 305 } else {
302 if ( videoButtons[i].isHeld ) { 306 if ( videoButtons[i].isHeld ) {
303 videoButtons[i].isHeld = FALSE; 307 videoButtons[i].isHeld = FALSE;
304 if ( !videoButtons[i].isToggle ) 308 if ( !videoButtons[i].isToggle )
305 setToggleButton( i, FALSE ); 309 setToggleButton( i, FALSE );
306 } 310 }
307 } 311 }
308 switch (i) { 312 switch (i) {
309 case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; 313 case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return;
310 case VideoStop: mediaPlayerState->setPlaying(FALSE); return; 314 case VideoStop: mediaPlayerState->setPlaying(FALSE); return;
311 case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; 315 case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return;
312 case VideoNext: mediaPlayerState->setNext(); return; 316 case VideoNext: mediaPlayerState->setNext(); return;
313 case VideoPrevious: mediaPlayerState->setPrev(); return; 317 case VideoPrevious: mediaPlayerState->setPrev(); return;
314 case VideoPlayList: mediaPlayerState->setList(); return; 318 case VideoPlayList: mediaPlayerState->setList(); return;
315 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; 319 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
316 } 320 }
317 321
318 } 322 }
319} 323}
320 324
321void VideoWidget::mousePressEvent( QMouseEvent *event ) { 325void VideoWidget::mousePressEvent( QMouseEvent *event ) {
322 mouseMoveEvent( event ); 326 mouseMoveEvent( event );
323} 327}
324 328
325void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 329void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
326 if ( mediaPlayerState->fullscreen() ) { 330 if ( mediaPlayerState->fullscreen() ) {
327 mediaPlayerState->setFullscreen( FALSE ); 331 mediaPlayerState->setFullscreen( FALSE );
328 makeVisible(); 332 makeVisible();
329 333
330 mouseMoveEvent( event ); 334 mouseMoveEvent( event );
331 } 335 }
332} 336}
333 337
334 338
335void VideoWidget::makeVisible() { 339void VideoWidget::makeVisible() {
336 if ( mediaPlayerState->fullscreen() ) { 340 if ( mediaPlayerState->fullscreen() ) {
337 setBackgroundMode( QWidget::NoBackground ); 341 setBackgroundMode( QWidget::NoBackground );
338 showFullScreen(); 342 showFullScreen();
339 resize( qApp->desktop()->size() ); 343 resize( qApp->desktop()->size() );
340 slider->hide(); 344 slider->hide();
341 videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); 345 videoFrame-> setGeometry ( 0, 0, width ( ), height ( ));
342 } else { 346 } else {
343 setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
344 showNormal(); 347 showNormal();
345 showMaximized(); 348 showMaximized();
346 slider->show(); 349 slider->show();
347 videoFrame->setGeometry( QRect( 10, 20, 220, 160 ) ); 350 videoFrame->setGeometry( QRect( 10, 20, 220, 160 ) );
348 } 351 }
349} 352}
350 353
351 354
352void VideoWidget::paintEvent( QPaintEvent * pe) { 355void VideoWidget::paintEvent( QPaintEvent * pe) {
353 QPainter p( this ); 356 QPainter p( this );
354 357
355 if ( mediaPlayerState->fullscreen() ) { 358 if ( mediaPlayerState->fullscreen() ) {
356 // Clear the background 359 // Clear the background
357 p.setBrush( QBrush( Qt::black ) ); 360 p.setBrush( QBrush( Qt::black ) );
358// videoFrame->setGeometry( QRect( 0, 0 , 240 ,320 ) ); 361// videoFrame->setGeometry( QRect( 0, 0 , 240 ,320 ) );
359 362
360 } else { 363 } else {
361 364
362 // videoFrame->setGeometry( QRect( 0, 15 , 240 ,170 ) ); 365 // videoFrame->setGeometry( QRect( 0, 15 , 240 ,170 ) );
363 // draw the buttons 366 // draw the buttons
364 367
365 if ( !pe->erased() ) { 368 if ( !pe->erased() ) {
366 // Combine with background and double buffer 369 // Combine with background and double buffer
367 QPixmap pix( pe->rect().size() ); 370 QPixmap pix( pe->rect().size() );
368 QPainter p( &pix ); 371 QPainter p( &pix );
369 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 372 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
370 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); 373 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
371 for ( int i = 0; i < numButtons; i++ ) 374 for ( int i = 0; i < numButtons; i++ )
372 paintButton( &p, i ); 375 paintButton( &p, i );
373 QPainter p2( this ); 376 QPainter p2( this );
374 p2.drawPixmap( pe->rect().topLeft(), pix ); 377 p2.drawPixmap( pe->rect().topLeft(), pix );
375 } else { 378 } else {
376 QPainter p( this ); 379 QPainter p( this );
377 for ( int i = 0; i < numButtons; i++ ) 380 for ( int i = 0; i < numButtons; i++ )
378 paintButton( &p, i ); 381 paintButton( &p, i );
379 } 382 }
380// for ( int i = 0; i < numButtons; i++ ) { 383// for ( int i = 0; i < numButtons; i++ ) {
381// paintButton( &p, i ); 384// paintButton( &p, i );
382// } 385// }
383// // draw the slider 386// // draw the slider
384// slider->repaint( TRUE ); 387// slider->repaint( TRUE );
385 } 388 }
386} 389}
387 390
388 391
389void VideoWidget::closeEvent( QCloseEvent* ) { 392void VideoWidget::closeEvent( QCloseEvent* ) {
390 mediaPlayerState->setList(); 393 mediaPlayerState->setList();
391} 394}