summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp190
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.h16
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
@@ -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
155VideoWidget::~VideoWidget() { 148VideoWidget::~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];
@@ -166,7 +159,7 @@ VideoWidget::~VideoWidget() {
166 for ( int i = 0; i < 7; i++ ) { 159 for ( int i = 0; i < 7; i++ ) {
167 delete masks[i]; 160 delete masks[i];
168 } 161 }
169 162
170} 163}
171 164
172QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 165QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
@@ -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
247void VideoWidget::setView( char view ) { 239void 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,84 +294,77 @@ void VideoWidget::toggleButton( int i ) {
286 294
287void VideoWidget::paintButton( QPainter *p, int i ) { 295void 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
295void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 304void 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 }
369 } 370 }
@@ -383,6 +384,11 @@ void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
383 } 384 }
384} 385}
385 386
387void VideoWidget::showEvent( QShowEvent* ) {
388 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
389 mouseMoveEvent( &event );
390}
391
386 392
387void VideoWidget::makeVisible() { 393void VideoWidget::makeVisible() {
388 if ( mediaPlayerState->fullscreen() ) { 394 if ( mediaPlayerState->fullscreen() ) {
@@ -390,9 +396,9 @@ void VideoWidget::makeVisible() {
390 showFullScreen(); 396 showFullScreen();
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();
398 videoFrame->setGeometry( QRect( 10, 20, 220, 160 ) ); 404 videoFrame->setGeometry( QRect( 10, 20, 220, 160 ) );
@@ -405,23 +411,24 @@ void VideoWidget::paintEvent( QPaintEvent * pe) {
405 QPainter p( this ); 411 QPainter p( this );
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 );
427 } else { 434 } else {
@@ -429,11 +436,11 @@ void VideoWidget::paintEvent( QPaintEvent * pe) {
429 for ( int i = 0; i < numVButtons; i++ ) 436 for ( int i = 0; i < numVButtons; i++ )
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}
439 446
@@ -443,19 +450,6 @@ void VideoWidget::closeEvent( QCloseEvent* ) {
443} 450}
444 451
445 452
446bool 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
460void VideoWidget::keyReleaseEvent( QKeyEvent *e) { 454void VideoWidget::keyReleaseEvent( QKeyEvent *e) {
461 switch ( e->key() ) { 455 switch ( e->key() ) {
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
@@ -41,7 +41,7 @@ class QPixmap;
41class QSlider; 41class QSlider;
42 42
43enum VideoButtons { 43enum VideoButtons {
44 VideoStop, 44 VideoStop = 0,
45 VideoPlay, 45 VideoPlay,
46// VideoPause, 46// VideoPause,
47 VideoPrevious, 47 VideoPrevious,
@@ -57,7 +57,7 @@ public:
57 VideoWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); 57 VideoWidget( QWidget* parent=0, const char* name=0, WFlags f=0 );
58 ~VideoWidget(); 58 ~VideoWidget();
59 59
60 bool playVideo(); 60
61 XineVideoWidget* vidWidget(); 61 XineVideoWidget* vidWidget();
62public slots: 62public slots:
63 void updateSlider( long, long ); 63 void updateSlider( long, long );
@@ -72,13 +72,18 @@ public slots:
72 void setView( char ); 72 void setView( char );
73 73
74signals: 74signals:
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
78protected: 82protected:
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 );
84 void mouseReleaseEvent( QMouseEvent *event ); 89 void mouseReleaseEvent( QMouseEvent *event );
@@ -94,9 +99,10 @@ private:
94 QBitmap *masks[7]; 99 QBitmap *masks[7];
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 );
102 void toggleButton( int ); 108 void toggleButton( int );