-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 190 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.h | 16 |
2 files changed, 103 insertions, 103 deletions
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index fb375f0..fbcd775 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -114,5 +114,4 @@ QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { | |||
114 | } | 114 | } |
115 | } | 115 | } |
116 | |||
117 | } | 116 | } |
118 | 117 | ||
@@ -129,14 +128,11 @@ QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { | |||
129 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); | 128 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); |
130 | slider->setFocusPolicy( QWidget::NoFocus ); | 129 | slider->setFocusPolicy( QWidget::NoFocus ); |
131 | slider->setGeometry( QRect( 7, 250, 220, 20 ) ); | 130 | |
131 | resizeEvent( NULL ); | ||
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 | |||
136 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 135 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
137 | connect( mediaPlayerState, SIGNAL( positionChanged(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) ) ); | 136 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
140 | |||
141 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 137 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
142 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 138 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
@@ -144,15 +140,12 @@ QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { | |||
144 | setLength( mediaPlayerState->length() ); | 140 | setLength( mediaPlayerState->length() ); |
145 | setPosition( mediaPlayerState->position() ); | 141 | setPosition( mediaPlayerState->position() ); |
146 | |||
147 | ////////////////////////// FIXME | ||
148 | setFullscreen( mediaPlayerState->fullscreen() ); | 142 | setFullscreen( mediaPlayerState->fullscreen() ); |
149 | setPaused( mediaPlayerState->paused() ); | 143 | setPaused( mediaPlayerState->paused() ); |
150 | setPlaying( mediaPlayerState->playing() ); | 144 | setPlaying( mediaPlayerState->playing() ); |
151 | qDebug("finished videowidget"); | ||
152 | } | 145 | } |
153 | 146 | ||
154 | 147 | ||
155 | VideoWidget::~VideoWidget() { | 148 | VideoWidget::~VideoWidget() { |
156 | mediaPlayerState->setPlaying( FALSE ); | 149 | |
157 | for ( int i = 0; i < 7; i++ ) { | 150 | for ( int i = 0; i < 7; i++ ) { |
158 | delete buttonPixUp[i]; | 151 | delete buttonPixUp[i]; |
@@ -167,5 +160,5 @@ VideoWidget::~VideoWidget() { | |||
167 | delete masks[i]; | 160 | delete masks[i]; |
168 | } | 161 | } |
169 | 162 | ||
170 | } | 163 | } |
171 | 164 | ||
@@ -191,7 +184,7 @@ void VideoWidget::resizeEvent( QResizeEvent * ) { | |||
191 | int Vw = 220; | 184 | int Vw = 220; |
192 | //videoFrame->width(); | 185 | //videoFrame->width(); |
193 | // songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); | ||
194 | 186 | ||
195 | slider->setFixedWidth( w - 110 ); | 187 | |
188 | slider->setFixedWidth( w - 20 ); | ||
196 | slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); | 189 | slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); |
197 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); | 190 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); |
@@ -199,5 +192,4 @@ void VideoWidget::resizeEvent( QResizeEvent * ) { | |||
199 | slider->setBackgroundPixmap( *pixBg ); | 192 | slider->setBackgroundPixmap( *pixBg ); |
200 | 193 | ||
201 | // time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); | ||
202 | xoff = 0;// ( imgUp->width() ) / 2; | 194 | xoff = 0;// ( imgUp->width() ) / 2; |
203 | yoff = 180;//(( Vh - imgUp->height() ) / 2) - 10; | 195 | yoff = 180;//(( Vh - imgUp->height() ) / 2) - 10; |
@@ -246,4 +238,20 @@ void VideoWidget::setLength( long max ) { | |||
246 | 238 | ||
247 | void VideoWidget::setView( char view ) { | 239 | void VideoWidget::setView( char view ) { |
240 | |||
241 | if ( mediaPlayerState->streaming() ) { | ||
242 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); | ||
243 | if( !slider->isHidden()) { | ||
244 | slider->hide(); | ||
245 | } | ||
246 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | ||
247 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | ||
248 | } else { | ||
249 | // this stops the slider from being moved, thus | ||
250 | // does not stop stream when it reaches the end | ||
251 | slider->show(); | ||
252 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | ||
253 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | ||
254 | } | ||
255 | |||
248 | if ( view == 'v' ) { | 256 | if ( view == 'v' ) { |
249 | makeVisible(); | 257 | makeVisible(); |
@@ -287,8 +295,9 @@ void VideoWidget::toggleButton( int i ) { | |||
287 | void VideoWidget::paintButton( QPainter *p, int i ) { | 295 | void VideoWidget::paintButton( QPainter *p, int i ) { |
288 | 296 | ||
289 | if ( videoButtons[i].isDown ) | 297 | if ( videoButtons[i].isDown ) { |
290 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | 298 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); |
291 | else | 299 | } else { |
292 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | 300 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); |
301 | } | ||
293 | } | 302 | } |
294 | 303 | ||
@@ -296,73 +305,65 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | |||
296 | for ( int i = 0; i < numVButtons; i++ ) { | 305 | for ( int i = 0; i < numVButtons; i++ ) { |
297 | if ( event->state() == QMouseEvent::LeftButton ) { | 306 | if ( event->state() == QMouseEvent::LeftButton ) { |
298 | // The test to see if the mouse click is inside the button or not | 307 | // The test to see if the mouse click is inside the button or not |
299 | int x = event->pos().x() - xoff; | 308 | int x = event->pos().x() - xoff; |
300 | int y = event->pos().y() - yoff; | 309 | int y = event->pos().y() - yoff; |
301 | 310 | ||
302 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() | 311 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() |
303 | && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); | 312 | && y < imgButtonMask->height() |
304 | if ( isOnButton != videoButtons[i].isHeld ) { | 313 | && imgButtonMask->pixelIndex( x, y ) == i + 1 ); |
305 | videoButtons[i].isHeld = isOnButton; | 314 | |
315 | if ( isOnButton && !videoButtons[i].isHeld ) { | ||
316 | videoButtons[i].isHeld = TRUE; | ||
306 | toggleButton(i); | 317 | toggleButton(i); |
307 | } | 318 | |
308 | |||
309 | // qDebug("mouseMove event switch1 %d", i); | ||
310 | if( isOnButton) | ||
311 | switch (i) { | 319 | switch (i) { |
312 | case VideoStop:{ | 320 | case VideoVolUp: |
313 | setToggleButton( i, FALSE ); | 321 | qDebug("more clicked"); |
314 | mediaPlayerState->setStop(TRUE); | 322 | emit moreClicked(); |
315 | mediaPlayerState->setPlaying(FALSE); | 323 | return; |
316 | return; | 324 | case VideoVolDown: |
317 | } | 325 | qDebug("less clicked"); |
318 | case VideoPlay: { | 326 | emit lessClicked(); |
319 | 327 | return; | |
320 | if( mediaPlayerState->isPaused) { | 328 | } |
321 | setToggleButton( i, FALSE ); | 329 | } else if ( !isOnButton && videoButtons[i].isHeld ) { |
322 | mediaPlayerState->setPaused( FALSE); | 330 | videoButtons[i].isHeld = FALSE; |
323 | return; | 331 | toggleButton(i); |
324 | } | 332 | } |
325 | else if( mediaPlayerState->isPlaying) { | ||
326 | setToggleButton( i, TRUE ); | ||
327 | mediaPlayerState->setPaused( TRUE); | ||
328 | return; | ||
329 | } | ||
330 | else { | ||
331 | setToggleButton( i, FALSE ); | ||
332 | mediaPlayerState->setPlaying( videoButtons[i].isDown ); | ||
333 | return; | ||
334 | } | ||
335 | } | ||
336 | case VideoNext: qDebug("next"); mediaPlayerState->setNext(); return; | ||
337 | case VideoPrevious: qDebug("previous"); mediaPlayerState->setPrev(); return; | ||
338 | case VideoVolUp: return; | ||
339 | case VideoVolDown: return; | ||
340 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | ||
341 | |||
342 | }; | ||
343 | |||
344 | } else { | 333 | } else { |
334 | |||
345 | if ( videoButtons[i].isHeld ) { | 335 | if ( videoButtons[i].isHeld ) { |
346 | videoButtons[i].isHeld = FALSE; | 336 | videoButtons[i].isHeld = FALSE; |
347 | if ( !videoButtons[i].isToggle ) { | 337 | if ( !videoButtons[i].isToggle ) { |
348 | setToggleButton( i, FALSE ); | 338 | setToggleButton( i, FALSE ); |
339 | qDebug("button toggled3 %d",i); | ||
349 | } | 340 | } |
350 | // qDebug("mouseMove event switch2 %d %d", i, VideoPlay); | 341 | |
351 | switch (i) { | 342 | switch(i) { |
352 | case VideoPlay: { | 343 | |
353 | if( mediaPlayerState->isPaused) { | 344 | case VideoPlay: { |
354 | mediaPlayerState->setPaused( FALSE); return; } | 345 | if( mediaPlayerState->isPaused ) { |
355 | else if( mediaPlayerState->isPlaying) { | 346 | qDebug("play again clicked"); |
356 | mediaPlayerState->setPaused( TRUE); return; } | 347 | setToggleButton( i, FALSE ); |
357 | else | 348 | mediaPlayerState->setPaused( FALSE ); |
358 | mediaPlayerState->setPlaying( TRUE /*videoButtons[i].isDown*/ ); return; | 349 | return; |
359 | } | 350 | } else if( !mediaPlayerState->isPaused ) { |
360 | case VideoStop: mediaPlayerState->setPlaying(FALSE); return; | 351 | qDebug("pause now clicked"); |
352 | setToggleButton( i, TRUE ); | ||
353 | mediaPlayerState->setPaused( TRUE ); | ||
354 | return; | ||
355 | } else { | ||
356 | // setToggleButton( i, TRUE ); | ||
357 | // mediaPlayerState->setPlaying( videoButtons[i].isDown ); | ||
358 | } | ||
359 | } | ||
360 | |||
361 | case VideoStop: mediaPlayerState->setPlaying( FALSE ); return; | ||
361 | // case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; | 362 | // case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; |
362 | case VideoNext: mediaPlayerState->setNext(); return; | 363 | case VideoNext: mediaPlayerState->setNext(); return; |
363 | case VideoPrevious: mediaPlayerState->setPrev(); return; | 364 | case VideoPrevious: mediaPlayerState->setPrev(); return; |
364 | case VideoVolUp: return; | 365 | case VideoVolUp: emit moreReleased(); return; |
365 | case VideoVolDown: return; | 366 | case VideoVolDown: emit lessReleased(); return; |
366 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | 367 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; |
367 | } | 368 | } |
368 | } | 369 | } |
@@ -384,4 +385,9 @@ void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | |||
384 | } | 385 | } |
385 | 386 | ||
387 | void VideoWidget::showEvent( QShowEvent* ) { | ||
388 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | ||
389 | mouseMoveEvent( &event ); | ||
390 | } | ||
391 | |||
386 | 392 | ||
387 | void VideoWidget::makeVisible() { | 393 | void VideoWidget::makeVisible() { |
@@ -391,7 +397,7 @@ void VideoWidget::makeVisible() { | |||
391 | resize( qApp->desktop()->size() ); | 397 | resize( qApp->desktop()->size() ); |
392 | slider->hide(); | 398 | slider->hide(); |
393 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); | 399 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); |
394 | } else { | 400 | } else { |
395 | showNormal(); | 401 | showNormal(); |
396 | showMaximized(); | 402 | showMaximized(); |
397 | slider->show(); | 403 | slider->show(); |
@@ -406,21 +412,22 @@ void VideoWidget::paintEvent( QPaintEvent * pe) { | |||
406 | 412 | ||
407 | if ( mediaPlayerState->fullscreen() ) { | 413 | if ( mediaPlayerState->fullscreen() ) { |
408 | // Clear the background | 414 | // Clear the background |
409 | p.setBrush( QBrush( Qt::black ) ); | 415 | p.setBrush( QBrush( Qt::black ) ); |
410 | // videoFrame->setGeometry( QRect( 0, 0 , 240 ,320 ) ); | 416 | // videoFrame->setGeometry( QRect( 0, 0 , 240 ,320 ) ); |
411 | 417 | ||
412 | } else { | 418 | } else { |
413 | 419 | ||
414 | // videoFrame->setGeometry( QRect( 0, 15 , 240 ,170 ) ); | 420 | // videoFrame->setGeometry( QRect( 0, 15 , 240 ,170 ) ); |
415 | // draw the buttons | 421 | // draw the buttons |
416 | 422 | ||
417 | if ( !pe->erased() ) { | 423 | if ( !pe->erased() ) { |
418 | // Combine with background and double buffer | 424 | // Combine with background and double buffer |
419 | QPixmap pix( pe->rect().size() ); | 425 | QPixmap pix( pe->rect().size() ); |
420 | QPainter p( &pix ); | 426 | QPainter p( &pix ); |
421 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 427 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
422 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); | 428 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); |
423 | for ( int i = 0; i < numVButtons; i++ ) | 429 | for ( int i = 0; i < numVButtons; i++ ) { |
424 | paintButton( &p, i ); | 430 | paintButton( &p, i ); |
431 | } | ||
425 | QPainter p2( this ); | 432 | QPainter p2( this ); |
426 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 433 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
@@ -430,9 +437,9 @@ void VideoWidget::paintEvent( QPaintEvent * pe) { | |||
430 | paintButton( &p, i ); | 437 | paintButton( &p, i ); |
431 | } | 438 | } |
432 | // for ( int i = 0; i < numButtons; i++ ) { | 439 | // for ( int i = 0; i < numButtons; i++ ) { |
433 | // paintButton( &p, i ); | 440 | // paintButton( &p, i ); |
434 | // } | 441 | // } |
435 | // draw the slider | 442 | // draw the slider |
436 | slider->repaint( TRUE ); | 443 | slider->repaint( TRUE ); |
437 | } | 444 | } |
438 | } | 445 | } |
@@ -444,17 +451,4 @@ void VideoWidget::closeEvent( QCloseEvent* ) { | |||
444 | 451 | ||
445 | 452 | ||
446 | bool VideoWidget::playVideo() { | ||
447 | bool result = FALSE; | ||
448 | |||
449 | int stream = 0; | ||
450 | |||
451 | int sw = 240; | ||
452 | int sh = 320; | ||
453 | int dd = QPixmap::defaultDepth(); | ||
454 | int w = height(); | ||
455 | int h = width(); | ||
456 | |||
457 | return true; | ||
458 | } | ||
459 | 453 | ||
460 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { | 454 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { |
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h index 92193a4..710ba9e 100644 --- a/noncore/multimedia/opieplayer2/videowidget.h +++ b/noncore/multimedia/opieplayer2/videowidget.h | |||
@@ -42,5 +42,5 @@ class QSlider; | |||
42 | 42 | ||
43 | enum VideoButtons { | 43 | enum VideoButtons { |
44 | VideoStop, | 44 | VideoStop = 0, |
45 | VideoPlay, | 45 | VideoPlay, |
46 | // VideoPause, | 46 | // VideoPause, |
@@ -58,5 +58,5 @@ public: | |||
58 | ~VideoWidget(); | 58 | ~VideoWidget(); |
59 | 59 | ||
60 | bool playVideo(); | 60 | |
61 | XineVideoWidget* vidWidget(); | 61 | XineVideoWidget* vidWidget(); |
62 | public slots: | 62 | public slots: |
@@ -73,11 +73,16 @@ public slots: | |||
73 | 73 | ||
74 | signals: | 74 | signals: |
75 | void moreClicked(); | ||
76 | void lessClicked(); | ||
77 | void moreReleased(); | ||
78 | void lessReleased(); | ||
75 | void sliderMoved( long ); | 79 | void sliderMoved( long ); |
76 | void videoResized ( const QSize &s ); | 80 | void videoResized ( const QSize &s ); |
77 | 81 | ||
78 | protected: | 82 | protected: |
79 | QString skin; | 83 | |
80 | void resizeEvent( QResizeEvent * ); | 84 | void resizeEvent( QResizeEvent * ); |
81 | void paintEvent( QPaintEvent *pe ); | 85 | void paintEvent( QPaintEvent *pe ); |
86 | void showEvent( QShowEvent *se ); | ||
82 | void mouseMoveEvent( QMouseEvent *event ); | 87 | void mouseMoveEvent( QMouseEvent *event ); |
83 | void mousePressEvent( QMouseEvent *event ); | 88 | void mousePressEvent( QMouseEvent *event ); |
@@ -95,7 +100,8 @@ private: | |||
95 | QPixmap *buttonPixUp[7]; | 100 | QPixmap *buttonPixUp[7]; |
96 | QPixmap *buttonPixDown[7]; | 101 | QPixmap *buttonPixDown[7]; |
102 | QString skin; | ||
97 | // QPixmap *pixmaps[4]; | 103 | // QPixmap *pixmaps[4]; |
98 | int xoff, yoff; | 104 | int xoff, yoff; |
99 | 105 | ||
100 | 106 | ||
101 | void paintButton( QPainter *p, int i ); | 107 | void paintButton( QPainter *p, int i ); |