Diffstat (limited to 'noncore/multimedia/opieplayer2/videowidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 136 |
1 files changed, 65 insertions, 71 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 | |||
@@ -113,7 +113,6 @@ QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { | |||
113 | } | 113 | } |
114 | } | 114 | } |
115 | } | 115 | } |
116 | |||
117 | } | 116 | } |
118 | 117 | ||
119 | for ( int i = 0; i < 7; i++ ) { | 118 | for ( int i = 0; i < 7; i++ ) { |
@@ -128,32 +127,26 @@ QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { | |||
128 | slider->setMaxValue( 1 ); | 127 | slider->setMaxValue( 1 ); |
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) ) ); |
143 | 139 | ||
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]; |
159 | delete buttonPixDown[i]; | 152 | delete buttonPixDown[i]; |
@@ -190,15 +183,14 @@ void VideoWidget::resizeEvent( QResizeEvent * ) { | |||
190 | //videoFrame->height(); | 183 | //videoFrame->height(); |
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 ); |
198 | slider->setFocusPolicy( QWidget::NoFocus ); | 191 | slider->setFocusPolicy( QWidget::NoFocus ); |
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; |
204 | QPoint p( xoff, yoff ); | 196 | QPoint p( xoff, yoff ); |
@@ -245,6 +237,22 @@ void VideoWidget::setLength( long max ) { | |||
245 | } | 237 | } |
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(); |
250 | } else { | 258 | } else { |
@@ -286,11 +294,12 @@ void VideoWidget::toggleButton( int i ) { | |||
286 | 294 | ||
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] ); |
293 | } | 301 | } |
302 | } | ||
294 | 303 | ||
295 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 304 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
296 | for ( int i = 0; i < numVButtons; i++ ) { | 305 | for ( int i = 0; i < numVButtons; i++ ) { |
@@ -300,69 +309,61 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | |||
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 | } | ||
308 | 318 | ||
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); | ||
316 | return; | 323 | return; |
317 | } | 324 | case VideoVolDown: |
318 | case VideoPlay: { | 325 | qDebug("less clicked"); |
319 | 326 | emit lessClicked(); | |
320 | if( mediaPlayerState->isPaused) { | ||
321 | setToggleButton( i, FALSE ); | ||
322 | mediaPlayerState->setPaused( FALSE); | ||
323 | return; | ||
324 | } | ||
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; | 327 | return; |
334 | } | 328 | } |
329 | } else if ( !isOnButton && videoButtons[i].isHeld ) { | ||
330 | videoButtons[i].isHeld = FALSE; | ||
331 | toggleButton(i); | ||
335 | } | 332 | } |
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) { |
343 | |||
352 | case VideoPlay: { | 344 | case VideoPlay: { |
353 | if( mediaPlayerState->isPaused) { | 345 | if( mediaPlayerState->isPaused) { |
354 | mediaPlayerState->setPaused( FALSE); return; } | 346 | qDebug("play again clicked"); |
355 | else if( mediaPlayerState->isPlaying) { | 347 | setToggleButton( i, FALSE ); |
356 | mediaPlayerState->setPaused( TRUE); return; } | 348 | mediaPlayerState->setPaused( FALSE ); |
357 | else | 349 | return; |
358 | mediaPlayerState->setPlaying( TRUE /*videoButtons[i].isDown*/ ); return; | 350 | } else if( !mediaPlayerState->isPaused ) { |
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 | } | 359 | } |
360 | |||
360 | case VideoStop: mediaPlayerState->setPlaying(FALSE); return; | 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 | } |
@@ -383,6 +384,11 @@ void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | |||
383 | } | 384 | } |
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() { |
388 | if ( mediaPlayerState->fullscreen() ) { | 394 | if ( mediaPlayerState->fullscreen() ) { |
@@ -420,8 +426,9 @@ void VideoWidget::paintEvent( QPaintEvent * pe) { | |||
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 ); |
427 | } else { | 434 | } else { |
@@ -443,19 +450,6 @@ void VideoWidget::closeEvent( QCloseEvent* ) { | |||
443 | } | 450 | } |
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) { |
461 | switch ( e->key() ) { | 455 | switch ( e->key() ) { |