-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 19 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.h | 1 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.cpp | 28 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.h | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 31 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.h | 1 |
6 files changed, 30 insertions, 52 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 553c56b..277d162 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -304,166 +304,147 @@ void AudioWidget::updateSlider( long i, long max ) { | |||
304 | } | 304 | } |
305 | } | 305 | } |
306 | } | 306 | } |
307 | 307 | ||
308 | 308 | ||
309 | void AudioWidget::setToggleButton( int i, bool down ) { | 309 | void AudioWidget::setToggleButton( int i, bool down ) { |
310 | qDebug("setToggleButton %d", i); | 310 | qDebug("setToggleButton %d", i); |
311 | if ( down != buttons[i].isDown ) { | 311 | if ( down != buttons[i].isDown ) { |
312 | toggleButton( i ); | 312 | toggleButton( i ); |
313 | } | 313 | } |
314 | } | 314 | } |
315 | 315 | ||
316 | void AudioWidget::skipFor() { | 316 | void AudioWidget::skipFor() { |
317 | skipDirection = +1; | 317 | skipDirection = +1; |
318 | startTimer( 50 ); | 318 | startTimer( 50 ); |
319 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); | 319 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); |
320 | } | 320 | } |
321 | 321 | ||
322 | void AudioWidget::skipBack() { | 322 | void AudioWidget::skipBack() { |
323 | skipDirection = -1; | 323 | skipDirection = -1; |
324 | startTimer( 50 ); | 324 | startTimer( 50 ); |
325 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); | 325 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); |
326 | } | 326 | } |
327 | 327 | ||
328 | 328 | ||
329 | 329 | ||
330 | void AudioWidget::stopSkip() { | 330 | void AudioWidget::stopSkip() { |
331 | killTimers(); | 331 | killTimers(); |
332 | } | 332 | } |
333 | 333 | ||
334 | 334 | ||
335 | void AudioWidget::timerEvent( QTimerEvent * ) { | 335 | void AudioWidget::timerEvent( QTimerEvent * ) { |
336 | if ( skipDirection == +1 ) { | 336 | if ( skipDirection == +1 ) { |
337 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); | 337 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); |
338 | } else if ( skipDirection == -1 ) { | 338 | } else if ( skipDirection == -1 ) { |
339 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); | 339 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); |
340 | } | 340 | } |
341 | } | 341 | } |
342 | 342 | ||
343 | 343 | ||
344 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | 344 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { |
345 | for ( unsigned int i = 0; i < buttons.count(); i++ ) { | 345 | for ( unsigned int i = 0; i < buttons.count(); i++ ) { |
346 | if ( event->state() == QMouseEvent::LeftButton ) { | 346 | if ( event->state() == QMouseEvent::LeftButton ) { |
347 | // The test to see if the mouse click is inside the button or not | 347 | // The test to see if the mouse click is inside the button or not |
348 | bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); | 348 | bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); |
349 | 349 | ||
350 | if ( isOnButton && !buttons[i].isHeld ) { | 350 | if ( isOnButton && !buttons[i].isHeld ) { |
351 | buttons[i].isHeld = TRUE; | 351 | buttons[i].isHeld = TRUE; |
352 | toggleButton(i); | 352 | toggleButton(i); |
353 | switch (i) { | 353 | switch (i) { |
354 | case VolumeUp: | 354 | case VolumeUp: |
355 | emit moreClicked(); | 355 | emit moreClicked(); |
356 | return; | 356 | return; |
357 | case VolumeDown: | 357 | case VolumeDown: |
358 | emit lessClicked(); | 358 | emit lessClicked(); |
359 | return; | 359 | return; |
360 | case Forward: | 360 | case Forward: |
361 | emit forwardClicked(); | 361 | emit forwardClicked(); |
362 | return; | 362 | return; |
363 | case Back: | 363 | case Back: |
364 | emit backClicked(); | 364 | emit backClicked(); |
365 | return; | 365 | return; |
366 | } | 366 | } |
367 | } else if ( !isOnButton && buttons[i].isHeld ) { | 367 | } else if ( !isOnButton && buttons[i].isHeld ) { |
368 | buttons[i].isHeld = FALSE; | 368 | buttons[i].isHeld = FALSE; |
369 | toggleButton(i); | 369 | toggleButton(i); |
370 | } | 370 | } |
371 | } else { | 371 | } else { |
372 | if ( buttons[i].isHeld ) { | 372 | if ( buttons[i].isHeld ) { |
373 | buttons[i].isHeld = FALSE; | 373 | buttons[i].isHeld = FALSE; |
374 | if ( buttons[i].type != ToggleButton ) { | 374 | if ( buttons[i].type != ToggleButton ) { |
375 | setToggleButton( i, FALSE ); | 375 | setToggleButton( i, FALSE ); |
376 | } | 376 | } |
377 | qDebug("mouseEvent %d", i); | 377 | qDebug("mouseEvent %d", i); |
378 | handleCommand( static_cast<Command>( i ), buttons[ i ].isDown ); | 378 | handleCommand( static_cast<Command>( i ), buttons[ i ].isDown ); |
379 | } | 379 | } |
380 | } | 380 | } |
381 | } | 381 | } |
382 | } | 382 | } |
383 | 383 | ||
384 | 384 | ||
385 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { | 385 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { |
386 | mouseMoveEvent( event ); | 386 | mouseMoveEvent( event ); |
387 | } | 387 | } |
388 | 388 | ||
389 | 389 | ||
390 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { | 390 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { |
391 | mouseMoveEvent( event ); | 391 | mouseMoveEvent( event ); |
392 | } | 392 | } |
393 | 393 | ||
394 | 394 | ||
395 | void AudioWidget::showEvent( QShowEvent* ) { | 395 | void AudioWidget::showEvent( QShowEvent* ) { |
396 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 396 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
397 | mouseMoveEvent( &event ); | 397 | mouseMoveEvent( &event ); |
398 | } | 398 | } |
399 | 399 | ||
400 | |||
401 | void AudioWidget::paintEvent( QPaintEvent * pe ) { | ||
402 | if ( !pe->erased() ) { | ||
403 | // Combine with background and double buffer | ||
404 | QPixmap pix( pe->rect().size() ); | ||
405 | QPainter p( &pix ); | ||
406 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | ||
407 | p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() ); | ||
408 | for ( unsigned int i = 0; i < buttons.count(); i++ ) | ||
409 | paintButton( p, buttons[ i ] ); | ||
410 | QPainter p2( this ); | ||
411 | p2.drawPixmap( pe->rect().topLeft(), pix ); | ||
412 | } else { | ||
413 | QPainter p( this ); | ||
414 | for ( unsigned int i = 0; i < buttons.count(); i++ ) | ||
415 | paintButton( p, buttons[ i ] ); | ||
416 | } | ||
417 | } | ||
418 | |||
419 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { | 400 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { |
420 | switch ( e->key() ) { | 401 | switch ( e->key() ) { |
421 | ////////////////////////////// Zaurus keys | 402 | ////////////////////////////// Zaurus keys |
422 | case Key_Home: | 403 | case Key_Home: |
423 | break; | 404 | break; |
424 | case Key_F9: //activity | 405 | case Key_F9: //activity |
425 | hide(); | 406 | hide(); |
426 | // qDebug("Audio F9"); | 407 | // qDebug("Audio F9"); |
427 | break; | 408 | break; |
428 | case Key_F10: //contacts | 409 | case Key_F10: //contacts |
429 | break; | 410 | break; |
430 | case Key_F11: //menu | 411 | case Key_F11: //menu |
431 | mediaPlayerState.toggleBlank(); | 412 | mediaPlayerState.toggleBlank(); |
432 | break; | 413 | break; |
433 | case Key_F12: //home | 414 | case Key_F12: //home |
434 | break; | 415 | break; |
435 | case Key_F13: //mail | 416 | case Key_F13: //mail |
436 | mediaPlayerState.toggleBlank(); | 417 | mediaPlayerState.toggleBlank(); |
437 | break; | 418 | break; |
438 | case Key_Space: { | 419 | case Key_Space: { |
439 | mediaPlayerState.togglePaused(); | 420 | mediaPlayerState.togglePaused(); |
440 | } | 421 | } |
441 | break; | 422 | break; |
442 | case Key_Down: | 423 | case Key_Down: |
443 | // toggleButton(6); | 424 | // toggleButton(6); |
444 | emit lessClicked(); | 425 | emit lessClicked(); |
445 | emit lessReleased(); | 426 | emit lessReleased(); |
446 | // toggleButton(6); | 427 | // toggleButton(6); |
447 | break; | 428 | break; |
448 | case Key_Up: | 429 | case Key_Up: |
449 | // toggleButton(5); | 430 | // toggleButton(5); |
450 | emit moreClicked(); | 431 | emit moreClicked(); |
451 | emit moreReleased(); | 432 | emit moreReleased(); |
452 | // toggleButton(5); | 433 | // toggleButton(5); |
453 | break; | 434 | break; |
454 | case Key_Right: | 435 | case Key_Right: |
455 | // toggleButton(3); | 436 | // toggleButton(3); |
456 | mediaPlayerState.setNext(); | 437 | mediaPlayerState.setNext(); |
457 | // toggleButton(3); | 438 | // toggleButton(3); |
458 | break; | 439 | break; |
459 | case Key_Left: | 440 | case Key_Left: |
460 | // toggleButton(4); | 441 | // toggleButton(4); |
461 | mediaPlayerState.setPrev(); | 442 | mediaPlayerState.setPrev(); |
462 | // toggleButton(4); | 443 | // toggleButton(4); |
463 | break; | 444 | break; |
464 | case Key_Escape: { | 445 | case Key_Escape: { |
465 | } | 446 | } |
466 | break; | 447 | break; |
467 | 448 | ||
468 | }; | 449 | }; |
469 | } | 450 | } |
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h index 69837cd..8c433ac 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.h +++ b/noncore/multimedia/opieplayer2/audiowidget.h | |||
@@ -1,109 +1,108 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifndef AUDIO_WIDGET_H | 34 | #ifndef AUDIO_WIDGET_H |
35 | #define AUDIO_WIDGET_H | 35 | #define AUDIO_WIDGET_H |
36 | 36 | ||
37 | #include <qpainter.h> | 37 | #include <qpainter.h> |
38 | #include <qdrawutil.h> | 38 | #include <qdrawutil.h> |
39 | #include <qpixmap.h> | 39 | #include <qpixmap.h> |
40 | #include <qstring.h> | 40 | #include <qstring.h> |
41 | #include <qslider.h> | 41 | #include <qslider.h> |
42 | #include <qframe.h> | 42 | #include <qframe.h> |
43 | #include <qlineedit.h> | 43 | #include <qlineedit.h> |
44 | #include <qimage.h> | 44 | #include <qimage.h> |
45 | 45 | ||
46 | #include <opie/oticker.h> | 46 | #include <opie/oticker.h> |
47 | 47 | ||
48 | #include "mediawidget.h" | 48 | #include "mediawidget.h" |
49 | 49 | ||
50 | class QPixmap; | 50 | class QPixmap; |
51 | 51 | ||
52 | class AudioWidget : public MediaWidget { | 52 | class AudioWidget : public MediaWidget { |
53 | Q_OBJECT | 53 | Q_OBJECT |
54 | public: | 54 | public: |
55 | AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); | 55 | AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); |
56 | ~AudioWidget(); | 56 | ~AudioWidget(); |
57 | void setTickerText( const QString &text ) { songInfo.setText( text ); } | 57 | void setTickerText( const QString &text ) { songInfo.setText( text ); } |
58 | public slots: | 58 | public slots: |
59 | void updateSlider( long, long ); | 59 | void updateSlider( long, long ); |
60 | void sliderPressed( ); | 60 | void sliderPressed( ); |
61 | void sliderReleased( ); | 61 | void sliderReleased( ); |
62 | void setLooping( bool b) { setToggleButton( Loop, b ); } | 62 | void setLooping( bool b) { setToggleButton( Loop, b ); } |
63 | void setPosition( long ); | 63 | void setPosition( long ); |
64 | void setSeekable( bool ); | 64 | void setSeekable( bool ); |
65 | 65 | ||
66 | public: | 66 | public: |
67 | virtual void setLength( long ); | 67 | virtual void setLength( long ); |
68 | virtual void setPlaying( bool b) { setToggleButton( Play, b ); } | 68 | virtual void setPlaying( bool b) { setToggleButton( Play, b ); } |
69 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); | 69 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); |
70 | 70 | ||
71 | signals: | 71 | signals: |
72 | void moreClicked(); | 72 | void moreClicked(); |
73 | void lessClicked(); | 73 | void lessClicked(); |
74 | void forwardClicked(); | 74 | void forwardClicked(); |
75 | void backClicked(); | 75 | void backClicked(); |
76 | void sliderMoved(long); | 76 | void sliderMoved(long); |
77 | 77 | ||
78 | protected: | 78 | protected: |
79 | void doBlank(); | 79 | void doBlank(); |
80 | void doUnblank(); | 80 | void doUnblank(); |
81 | void paintEvent( QPaintEvent *pe ); | ||
82 | void showEvent( QShowEvent *se ); | 81 | void showEvent( QShowEvent *se ); |
83 | void resizeEvent( QResizeEvent *re ); | 82 | void resizeEvent( QResizeEvent *re ); |
84 | void mouseMoveEvent( QMouseEvent *event ); | 83 | void mouseMoveEvent( QMouseEvent *event ); |
85 | void mousePressEvent( QMouseEvent *event ); | 84 | void mousePressEvent( QMouseEvent *event ); |
86 | void mouseReleaseEvent( QMouseEvent *event ); | 85 | void mouseReleaseEvent( QMouseEvent *event ); |
87 | void timerEvent( QTimerEvent *event ); | 86 | void timerEvent( QTimerEvent *event ); |
88 | void keyReleaseEvent( QKeyEvent *e); | 87 | void keyReleaseEvent( QKeyEvent *e); |
89 | private slots: | 88 | private slots: |
90 | void skipFor(); | 89 | void skipFor(); |
91 | void skipBack(); | 90 | void skipBack(); |
92 | void stopSkip(); | 91 | void stopSkip(); |
93 | private: | 92 | private: |
94 | void setToggleButton( int, bool ); | 93 | void setToggleButton( int, bool ); |
95 | int skipDirection; | 94 | int skipDirection; |
96 | QString skin; | 95 | QString skin; |
97 | QImage imgUp; | 96 | QImage imgUp; |
98 | QImage imgDn; | 97 | QImage imgDn; |
99 | 98 | ||
100 | OTicker songInfo; | 99 | OTicker songInfo; |
101 | QSlider slider; | 100 | QSlider slider; |
102 | QLineEdit time; | 101 | QLineEdit time; |
103 | bool isStreaming : 1; | 102 | bool isStreaming : 1; |
104 | bool audioSliderBeingMoved : 1; | 103 | bool audioSliderBeingMoved : 1; |
105 | }; | 104 | }; |
106 | 105 | ||
107 | 106 | ||
108 | #endif // AUDIO_WIDGET_H | 107 | #endif // AUDIO_WIDGET_H |
109 | 108 | ||
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp index f977b61..3a44185 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.cpp +++ b/noncore/multimedia/opieplayer2/mediawidget.cpp | |||
@@ -1,92 +1,120 @@ | |||
1 | /* | 1 | /* |
2 | Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> | 2 | Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> |
3 | (C) 2002 Max Reiss <harlekin@handhelds.org> | 3 | (C) 2002 Max Reiss <harlekin@handhelds.org> |
4 | (C) 2002 L. Potter <ljp@llornkcor.com> | 4 | (C) 2002 L. Potter <ljp@llornkcor.com> |
5 | (C) 2002 Holger Freyther <zecke@handhelds.org> | 5 | (C) 2002 Holger Freyther <zecke@handhelds.org> |
6 | 6 | ||
7 | This library is free software; you can redistribute it and/or | 7 | This library is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU Library General Public | 8 | modify it under the terms of the GNU Library General Public |
9 | License as published by the Free Software Foundation; either | 9 | License as published by the Free Software Foundation; either |
10 | version 2 of the License, or (at your option) any later version. | 10 | version 2 of the License, or (at your option) any later version. |
11 | 11 | ||
12 | This library is distributed in the hope that it will be useful, | 12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Library General Public License for more details. | 15 | Library General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU Library General Public License | 17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to | 18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. | 20 | Boston, MA 02111-1307, USA. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | 23 | ||
24 | #include "mediawidget.h" | 24 | #include "mediawidget.h" |
25 | #include "playlistwidget.h" | 25 | #include "playlistwidget.h" |
26 | 26 | ||
27 | MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name ) | 27 | MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name ) |
28 | : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) | 28 | : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) |
29 | { | 29 | { |
30 | connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ), | 30 | connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ), |
31 | this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) ); | 31 | this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) ); |
32 | connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ), | 32 | connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ), |
33 | this, SLOT( setLength( long ) ) ); | 33 | this, SLOT( setLength( long ) ) ); |
34 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), | 34 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), |
35 | this, SLOT( setPlaying( bool ) ) ); | 35 | this, SLOT( setPlaying( bool ) ) ); |
36 | } | 36 | } |
37 | 37 | ||
38 | MediaWidget::~MediaWidget() | 38 | MediaWidget::~MediaWidget() |
39 | { | 39 | { |
40 | } | 40 | } |
41 | 41 | ||
42 | void MediaWidget::closeEvent( QCloseEvent * ) | 42 | void MediaWidget::closeEvent( QCloseEvent * ) |
43 | { | 43 | { |
44 | mediaPlayerState.setList(); | 44 | mediaPlayerState.setList(); |
45 | } | 45 | } |
46 | 46 | ||
47 | void MediaWidget::paintEvent( QPaintEvent *pe ) | ||
48 | { | ||
49 | QPainter p( this ); | ||
50 | |||
51 | if ( mediaPlayerState.isFullscreen() ) { | ||
52 | // Clear the background | ||
53 | p.setBrush( QBrush( Qt::black ) ); | ||
54 | return; | ||
55 | } | ||
56 | |||
57 | if ( !pe->erased() ) { | ||
58 | // Combine with background and double buffer | ||
59 | QPixmap pix( pe->rect().size() ); | ||
60 | QPainter p( &pix ); | ||
61 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | ||
62 | p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() ); | ||
63 | for ( unsigned int i = 0; i < buttons.count(); i++ ) { | ||
64 | paintButton( p, buttons[ i ] ); | ||
65 | } | ||
66 | QPainter p2( this ); | ||
67 | p2.drawPixmap( pe->rect().topLeft(), pix ); | ||
68 | } else { | ||
69 | QPainter p( this ); | ||
70 | for ( unsigned int i = 0; i < buttons.count(); i++ ) | ||
71 | paintButton( p, buttons[ i ] ); | ||
72 | } | ||
73 | } | ||
74 | |||
47 | void MediaWidget::handleCommand( Command command, bool buttonDown ) | 75 | void MediaWidget::handleCommand( Command command, bool buttonDown ) |
48 | { | 76 | { |
49 | switch ( command ) { | 77 | switch ( command ) { |
50 | case Play: mediaPlayerState.togglePaused(); | 78 | case Play: mediaPlayerState.togglePaused(); |
51 | case Stop: mediaPlayerState.setPlaying(FALSE); return; | 79 | case Stop: mediaPlayerState.setPlaying(FALSE); return; |
52 | case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; | 80 | case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; |
53 | case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; | 81 | case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; |
54 | case Loop: mediaPlayerState.setLooping( buttonDown ); return; | 82 | case Loop: mediaPlayerState.setLooping( buttonDown ); return; |
55 | case VolumeUp: emit moreReleased(); return; | 83 | case VolumeUp: emit moreReleased(); return; |
56 | case VolumeDown: emit lessReleased(); return; | 84 | case VolumeDown: emit lessReleased(); return; |
57 | case PlayList: mediaPlayerState.setList(); return; | 85 | case PlayList: mediaPlayerState.setList(); return; |
58 | case Forward: emit forwardReleased(); return; | 86 | case Forward: emit forwardReleased(); return; |
59 | case Back: emit backReleased(); return; | 87 | case Back: emit backReleased(); return; |
60 | } | 88 | } |
61 | } | 89 | } |
62 | 90 | ||
63 | bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const | 91 | bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const |
64 | { | 92 | { |
65 | return ( position.x() > 0 && position.y() > 0 && | 93 | return ( position.x() > 0 && position.y() > 0 && |
66 | position.x() < buttonMask.width() && | 94 | position.x() < buttonMask.width() && |
67 | position.y() < buttonMask.height() && | 95 | position.y() < buttonMask.height() && |
68 | buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 ); | 96 | buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 ); |
69 | } | 97 | } |
70 | 98 | ||
71 | void MediaWidget::paintButton( int buttonId ) | 99 | void MediaWidget::paintButton( int buttonId ) |
72 | { | 100 | { |
73 | QPainter p( this ); | 101 | QPainter p( this ); |
74 | paintButton( p, buttons[ buttonId ] ); | 102 | paintButton( p, buttons[ buttonId ] ); |
75 | } | 103 | } |
76 | 104 | ||
77 | void MediaWidget::paintButton( QPainter &p, const Button &button ) | 105 | void MediaWidget::paintButton( QPainter &p, const Button &button ) |
78 | { | 106 | { |
79 | if ( button.isDown ) | 107 | if ( button.isDown ) |
80 | p.drawPixmap( upperLeftOfButtonMask, button.pixDown ); | 108 | p.drawPixmap( upperLeftOfButtonMask, button.pixDown ); |
81 | else | 109 | else |
82 | p.drawPixmap( upperLeftOfButtonMask, button.pixUp ); | 110 | p.drawPixmap( upperLeftOfButtonMask, button.pixUp ); |
83 | } | 111 | } |
84 | 112 | ||
85 | void MediaWidget::toggleButton( int buttonId ) | 113 | void MediaWidget::toggleButton( int buttonId ) |
86 | { | 114 | { |
87 | buttons[ buttonId ].isDown = !buttons[ buttonId ].isDown; | 115 | buttons[ buttonId ].isDown = !buttons[ buttonId ].isDown; |
88 | paintButton( buttonId ); | 116 | paintButton( buttonId ); |
89 | } | 117 | } |
90 | 118 | ||
91 | /* vim: et sw=4 ts=4 | 119 | /* vim: et sw=4 ts=4 |
92 | */ | 120 | */ |
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h index 211e56c..8cdaad1 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.h +++ b/noncore/multimedia/opieplayer2/mediawidget.h | |||
@@ -1,107 +1,109 @@ | |||
1 | /* | 1 | /* |
2 | Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> | 2 | Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> |
3 | (C) 2002 Max Reiss <harlekin@handhelds.org> | 3 | (C) 2002 Max Reiss <harlekin@handhelds.org> |
4 | (C) 2002 L. Potter <ljp@llornkcor.com> | 4 | (C) 2002 L. Potter <ljp@llornkcor.com> |
5 | (C) 2002 Holger Freyther <zecke@handhelds.org> | 5 | (C) 2002 Holger Freyther <zecke@handhelds.org> |
6 | 6 | ||
7 | This library is free software; you can redistribute it and/or | 7 | This library is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU Library General Public | 8 | modify it under the terms of the GNU Library General Public |
9 | License as published by the Free Software Foundation; either | 9 | License as published by the Free Software Foundation; either |
10 | version 2 of the License, or (at your option) any later version. | 10 | version 2 of the License, or (at your option) any later version. |
11 | 11 | ||
12 | This library is distributed in the hope that it will be useful, | 12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Library General Public License for more details. | 15 | Library General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU Library General Public License | 17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to | 18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 19 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. | 20 | Boston, MA 02111-1307, USA. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #ifndef MEDIAWIDGET_H | 23 | #ifndef MEDIAWIDGET_H |
24 | #define MEDIAWIDGET_H | 24 | #define MEDIAWIDGET_H |
25 | 25 | ||
26 | #include <qwidget.h> | 26 | #include <qwidget.h> |
27 | #include <qmap.h> | 27 | #include <qmap.h> |
28 | 28 | ||
29 | #include "mediaplayerstate.h" | 29 | #include "mediaplayerstate.h" |
30 | #include "playlistwidget.h" | 30 | #include "playlistwidget.h" |
31 | 31 | ||
32 | #include <vector> | 32 | #include <vector> |
33 | 33 | ||
34 | class MediaWidget : public QWidget | 34 | class MediaWidget : public QWidget |
35 | { | 35 | { |
36 | Q_OBJECT | 36 | Q_OBJECT |
37 | public: | 37 | public: |
38 | enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back }; | 38 | enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back }; |
39 | enum ButtonType { NormalButton, ToggleButton }; | 39 | enum ButtonType { NormalButton, ToggleButton }; |
40 | 40 | ||
41 | struct Button | 41 | struct Button |
42 | { | 42 | { |
43 | Button() : type( NormalButton ), isHeld( false ), isDown( false ) {} | 43 | Button() : type( NormalButton ), isHeld( false ), isDown( false ) {} |
44 | 44 | ||
45 | ButtonType type : 1; | 45 | ButtonType type : 1; |
46 | bool isHeld : 1; | 46 | bool isHeld : 1; |
47 | bool isDown : 1; | 47 | bool isDown : 1; |
48 | 48 | ||
49 | QBitmap mask; | 49 | QBitmap mask; |
50 | QPixmap pixUp; | 50 | QPixmap pixUp; |
51 | QPixmap pixDown; | 51 | QPixmap pixDown; |
52 | }; | 52 | }; |
53 | typedef std::vector<Button> ButtonVector; | 53 | typedef std::vector<Button> ButtonVector; |
54 | // when the transition is done this should be Command -> Button | 54 | // when the transition is done this should be Command -> Button |
55 | typedef QMap<int, Button> ButtonMap; | 55 | typedef QMap<int, Button> ButtonMap; |
56 | 56 | ||
57 | struct SkinButtonInfo | 57 | struct SkinButtonInfo |
58 | { | 58 | { |
59 | Command command; | 59 | Command command; |
60 | const char *fileName; | 60 | const char *fileName; |
61 | ButtonType type; | 61 | ButtonType type; |
62 | }; | 62 | }; |
63 | 63 | ||
64 | typedef std::vector<QBitmap> MaskVector; | 64 | typedef std::vector<QBitmap> MaskVector; |
65 | typedef std::vector<QPixmap> PixmapVector; | 65 | typedef std::vector<QPixmap> PixmapVector; |
66 | 66 | ||
67 | MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); | 67 | MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); |
68 | virtual ~MediaWidget(); | 68 | virtual ~MediaWidget(); |
69 | 69 | ||
70 | public slots: | 70 | public slots: |
71 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; | 71 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; |
72 | virtual void setLength( long length ) = 0; | 72 | virtual void setLength( long length ) = 0; |
73 | virtual void setPlaying( bool playing ) = 0; | 73 | virtual void setPlaying( bool playing ) = 0; |
74 | 74 | ||
75 | signals: | 75 | signals: |
76 | void moreReleased(); | 76 | void moreReleased(); |
77 | void lessReleased(); | 77 | void lessReleased(); |
78 | void forwardReleased(); | 78 | void forwardReleased(); |
79 | void backReleased(); | 79 | void backReleased(); |
80 | 80 | ||
81 | protected: | 81 | protected: |
82 | virtual void closeEvent( QCloseEvent * ); | 82 | virtual void closeEvent( QCloseEvent * ); |
83 | 83 | ||
84 | virtual void paintEvent( QPaintEvent *pe ); | ||
85 | |||
84 | void handleCommand( Command command, bool buttonDown ); | 86 | void handleCommand( Command command, bool buttonDown ); |
85 | 87 | ||
86 | bool isOverButton( const QPoint &position, int buttonId ) const; | 88 | bool isOverButton( const QPoint &position, int buttonId ) const; |
87 | 89 | ||
88 | void paintButton( int buttonId ); | 90 | void paintButton( int buttonId ); |
89 | void paintButton( QPainter &p, const Button &button ); | 91 | void paintButton( QPainter &p, const Button &button ); |
90 | 92 | ||
91 | void toggleButton( int buttonId ); | 93 | void toggleButton( int buttonId ); |
92 | 94 | ||
93 | MediaPlayerState &mediaPlayerState; | 95 | MediaPlayerState &mediaPlayerState; |
94 | PlayListWidget &playList; | 96 | PlayListWidget &playList; |
95 | 97 | ||
96 | ButtonMap buttons; | 98 | ButtonMap buttons; |
97 | 99 | ||
98 | QImage buttonMask; | 100 | QImage buttonMask; |
99 | 101 | ||
100 | QPoint upperLeftOfButtonMask; | 102 | QPoint upperLeftOfButtonMask; |
101 | 103 | ||
102 | QPixmap backgroundPixmap; | 104 | QPixmap backgroundPixmap; |
103 | }; | 105 | }; |
104 | 106 | ||
105 | #endif // MEDIAWIDGET_H | 107 | #endif // MEDIAWIDGET_H |
106 | /* vim: et sw=4 ts=4 | 108 | /* vim: et sw=4 ts=4 |
107 | */ | 109 | */ |
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index a8bf252..8f6a8a9 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -282,189 +282,158 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | |||
282 | 282 | ||
283 | case VideoPlay: { | 283 | case VideoPlay: { |
284 | if( mediaPlayerState.isPaused() ) { | 284 | if( mediaPlayerState.isPaused() ) { |
285 | setToggleButton( i, FALSE ); | 285 | setToggleButton( i, FALSE ); |
286 | mediaPlayerState.setPaused( FALSE ); | 286 | mediaPlayerState.setPaused( FALSE ); |
287 | return; | 287 | return; |
288 | } else if( !mediaPlayerState.isPaused() ) { | 288 | } else if( !mediaPlayerState.isPaused() ) { |
289 | setToggleButton( i, TRUE ); | 289 | setToggleButton( i, TRUE ); |
290 | mediaPlayerState.setPaused( TRUE ); | 290 | mediaPlayerState.setPaused( TRUE ); |
291 | return; | 291 | return; |
292 | } else { | 292 | } else { |
293 | return; | 293 | return; |
294 | } | 294 | } |
295 | } | 295 | } |
296 | 296 | ||
297 | case VideoStop: mediaPlayerState.setPlaying( FALSE ); return; | 297 | case VideoStop: mediaPlayerState.setPlaying( FALSE ); return; |
298 | case VideoNext: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; | 298 | case VideoNext: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; |
299 | case VideoPrevious: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; | 299 | case VideoPrevious: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; |
300 | case VideoVolUp: emit moreReleased(); return; | 300 | case VideoVolUp: emit moreReleased(); return; |
301 | case VideoVolDown: emit lessReleased(); return; | 301 | case VideoVolDown: emit lessReleased(); return; |
302 | case VideoFullscreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return; | 302 | case VideoFullscreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return; |
303 | } | 303 | } |
304 | } | 304 | } |
305 | } | 305 | } |
306 | } | 306 | } |
307 | } | 307 | } |
308 | 308 | ||
309 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { | 309 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { |
310 | mouseMoveEvent( event ); | 310 | mouseMoveEvent( event ); |
311 | } | 311 | } |
312 | 312 | ||
313 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 313 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
314 | if ( mediaPlayerState.isFullscreen() ) { | 314 | if ( mediaPlayerState.isFullscreen() ) { |
315 | mediaPlayerState.setFullscreen( FALSE ); | 315 | mediaPlayerState.setFullscreen( FALSE ); |
316 | makeVisible(); | 316 | makeVisible(); |
317 | } | 317 | } |
318 | mouseMoveEvent( event ); | 318 | mouseMoveEvent( event ); |
319 | } | 319 | } |
320 | 320 | ||
321 | void VideoWidget::showEvent( QShowEvent* ) { | 321 | void VideoWidget::showEvent( QShowEvent* ) { |
322 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 322 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
323 | mouseMoveEvent( &event ); | 323 | mouseMoveEvent( &event ); |
324 | } | 324 | } |
325 | 325 | ||
326 | 326 | ||
327 | void VideoWidget::backToNormal() { | 327 | void VideoWidget::backToNormal() { |
328 | mediaPlayerState.setFullscreen( FALSE ); | 328 | mediaPlayerState.setFullscreen( FALSE ); |
329 | makeVisible(); | 329 | makeVisible(); |
330 | } | 330 | } |
331 | 331 | ||
332 | void VideoWidget::makeVisible() { | 332 | void VideoWidget::makeVisible() { |
333 | if ( mediaPlayerState.isFullscreen() ) { | 333 | if ( mediaPlayerState.isFullscreen() ) { |
334 | setBackgroundMode( QWidget::NoBackground ); | 334 | setBackgroundMode( QWidget::NoBackground ); |
335 | showFullScreen(); | 335 | showFullScreen(); |
336 | resize( qApp->desktop()->size() ); | 336 | resize( qApp->desktop()->size() ); |
337 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); | 337 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); |
338 | 338 | ||
339 | slider->hide(); | 339 | slider->hide(); |
340 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 340 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
341 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 341 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
342 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 342 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
343 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 343 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
344 | 344 | ||
345 | } else { | 345 | } else { |
346 | showNormal(); | 346 | showNormal(); |
347 | showMaximized(); | 347 | showMaximized(); |
348 | setBackgroundPixmap( backgroundPixmap ); | 348 | setBackgroundPixmap( backgroundPixmap ); |
349 | QWidget *d = QApplication::desktop(); | 349 | QWidget *d = QApplication::desktop(); |
350 | int w = d->width(); | 350 | int w = d->width(); |
351 | int h = d->height(); | 351 | int h = d->height(); |
352 | 352 | ||
353 | if(w>h) { | 353 | if(w>h) { |
354 | int newW=(w/2)-(246/2); //this will only work with 320x240 | 354 | int newW=(w/2)-(246/2); //this will only work with 320x240 |
355 | videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); | 355 | videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); |
356 | } else { | 356 | } else { |
357 | videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); | 357 | videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); |
358 | } | 358 | } |
359 | 359 | ||
360 | if ( !mediaPlayerState.isSeekable() ) { | 360 | if ( !mediaPlayerState.isSeekable() ) { |
361 | if( !slider->isHidden()) { | 361 | if( !slider->isHidden()) { |
362 | slider->hide(); | 362 | slider->hide(); |
363 | } | 363 | } |
364 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 364 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
365 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 365 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
366 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 366 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
367 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 367 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
368 | } else { | 368 | } else { |
369 | slider->show(); | 369 | slider->show(); |
370 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 370 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
371 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 371 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
372 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 372 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
373 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 373 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
374 | } | 374 | } |
375 | } | 375 | } |
376 | } | 376 | } |
377 | 377 | ||
378 | |||
379 | |||
380 | |||
381 | void VideoWidget::paintEvent( QPaintEvent * pe) { | ||
382 | QPainter p( this ); | ||
383 | |||
384 | if ( mediaPlayerState.isFullscreen() ) { | ||
385 | // Clear the background | ||
386 | p.setBrush( QBrush( Qt::black ) ); | ||
387 | } else { | ||
388 | if ( !pe->erased() ) { | ||
389 | // Combine with background and double buffer | ||
390 | QPixmap pix( pe->rect().size() ); | ||
391 | QPainter p( &pix ); | ||
392 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | ||
393 | p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() ); | ||
394 | for ( unsigned int i = 0; i < buttons.count(); i++ ) { | ||
395 | paintButton( p, buttons[ i ] ); | ||
396 | } | ||
397 | QPainter p2( this ); | ||
398 | p2.drawPixmap( pe->rect().topLeft(), pix ); | ||
399 | } else { | ||
400 | QPainter p( this ); | ||
401 | for ( unsigned int i = 0; i < buttons.count(); i++ ) | ||
402 | paintButton( p, buttons[ i ] ); | ||
403 | } | ||
404 | //slider->repaint( TRUE ); | ||
405 | } | ||
406 | } | ||
407 | |||
408 | |||
409 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { | 378 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { |
410 | switch ( e->key() ) { | 379 | switch ( e->key() ) { |
411 | ////////////////////////////// Zaurus keys | 380 | ////////////////////////////// Zaurus keys |
412 | case Key_Home: | 381 | case Key_Home: |
413 | break; | 382 | break; |
414 | case Key_F9: //activity | 383 | case Key_F9: //activity |
415 | break; | 384 | break; |
416 | case Key_F10: //contacts | 385 | case Key_F10: //contacts |
417 | // hide(); | 386 | // hide(); |
418 | break; | 387 | break; |
419 | case Key_F11: //menu | 388 | case Key_F11: //menu |
420 | break; | 389 | break; |
421 | case Key_F12: //home | 390 | case Key_F12: //home |
422 | break; | 391 | break; |
423 | case Key_F13: //mail | 392 | case Key_F13: //mail |
424 | break; | 393 | break; |
425 | case Key_Space: { | 394 | case Key_Space: { |
426 | if(mediaPlayerState.isPlaying()) { | 395 | if(mediaPlayerState.isPlaying()) { |
427 | mediaPlayerState.setPlaying(FALSE); | 396 | mediaPlayerState.setPlaying(FALSE); |
428 | } else { | 397 | } else { |
429 | mediaPlayerState.setPlaying(TRUE); | 398 | mediaPlayerState.setPlaying(TRUE); |
430 | } | 399 | } |
431 | } | 400 | } |
432 | break; | 401 | break; |
433 | case Key_Down: | 402 | case Key_Down: |
434 | // toggleButton(6); | 403 | // toggleButton(6); |
435 | emit lessClicked(); | 404 | emit lessClicked(); |
436 | emit lessReleased(); | 405 | emit lessReleased(); |
437 | // toggleButton(6); | 406 | // toggleButton(6); |
438 | break; | 407 | break; |
439 | case Key_Up: | 408 | case Key_Up: |
440 | // toggleButton(5); | 409 | // toggleButton(5); |
441 | emit moreClicked(); | 410 | emit moreClicked(); |
442 | emit moreReleased(); | 411 | emit moreReleased(); |
443 | // toggleButton(5); | 412 | // toggleButton(5); |
444 | break; | 413 | break; |
445 | case Key_Right: | 414 | case Key_Right: |
446 | mediaPlayerState.setNext(); | 415 | mediaPlayerState.setNext(); |
447 | break; | 416 | break; |
448 | case Key_Left: | 417 | case Key_Left: |
449 | mediaPlayerState.setPrev(); | 418 | mediaPlayerState.setPrev(); |
450 | break; | 419 | break; |
451 | case Key_Escape: | 420 | case Key_Escape: |
452 | break; | 421 | break; |
453 | 422 | ||
454 | }; | 423 | }; |
455 | } | 424 | } |
456 | 425 | ||
457 | XineVideoWidget* VideoWidget::vidWidget() { | 426 | XineVideoWidget* VideoWidget::vidWidget() { |
458 | return videoFrame; | 427 | return videoFrame; |
459 | } | 428 | } |
460 | 429 | ||
461 | 430 | ||
462 | void VideoWidget::setFullscreen ( bool b ) { | 431 | void VideoWidget::setFullscreen ( bool b ) { |
463 | setToggleButton( VideoFullscreen, b ); | 432 | setToggleButton( VideoFullscreen, b ); |
464 | } | 433 | } |
465 | 434 | ||
466 | 435 | ||
467 | void VideoWidget::setPlaying( bool b) { | 436 | void VideoWidget::setPlaying( bool b) { |
468 | setToggleButton( VideoPlay, b ); | 437 | setToggleButton( VideoPlay, b ); |
469 | } | 438 | } |
470 | 439 | ||
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h index 9d5239b..45279d7 100644 --- a/noncore/multimedia/opieplayer2/videowidget.h +++ b/noncore/multimedia/opieplayer2/videowidget.h | |||
@@ -1,118 +1,117 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifndef VIDEO_WIDGET_H | 34 | #ifndef VIDEO_WIDGET_H |
35 | #define VIDEO_WIDGET_H | 35 | #define VIDEO_WIDGET_H |
36 | 36 | ||
37 | #include <qwidget.h> | 37 | #include <qwidget.h> |
38 | #include <qimage.h> | 38 | #include <qimage.h> |
39 | #include <qpixmap.h> | 39 | #include <qpixmap.h> |
40 | #include "xinevideowidget.h" | 40 | #include "xinevideowidget.h" |
41 | 41 | ||
42 | #include "mediawidget.h" | 42 | #include "mediawidget.h" |
43 | 43 | ||
44 | class QPixmap; | 44 | class QPixmap; |
45 | class QSlider; | 45 | class QSlider; |
46 | 46 | ||
47 | enum VideoButtons { | 47 | enum VideoButtons { |
48 | VideoPlay = 0, | 48 | VideoPlay = 0, |
49 | VideoStop, | 49 | VideoStop, |
50 | // VideoPause, | 50 | // VideoPause, |
51 | VideoNext, | 51 | VideoNext, |
52 | VideoPrevious, | 52 | VideoPrevious, |
53 | VideoVolUp, | 53 | VideoVolUp, |
54 | VideoVolDown, | 54 | VideoVolDown, |
55 | VideoFullscreen | 55 | VideoFullscreen |
56 | }; | 56 | }; |
57 | 57 | ||
58 | class VideoWidget : public MediaWidget { | 58 | class VideoWidget : public MediaWidget { |
59 | Q_OBJECT | 59 | Q_OBJECT |
60 | public: | 60 | public: |
61 | VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); | 61 | VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); |
62 | ~VideoWidget(); | 62 | ~VideoWidget(); |
63 | 63 | ||
64 | 64 | ||
65 | XineVideoWidget* vidWidget(); | 65 | XineVideoWidget* vidWidget(); |
66 | public slots: | 66 | public slots: |
67 | void updateSlider( long, long ); | 67 | void updateSlider( long, long ); |
68 | void sliderPressed( ); | 68 | void sliderPressed( ); |
69 | void sliderReleased( ); | 69 | void sliderReleased( ); |
70 | void setFullscreen( bool b ); | 70 | void setFullscreen( bool b ); |
71 | void makeVisible(); | 71 | void makeVisible(); |
72 | void backToNormal(); | 72 | void backToNormal(); |
73 | void setPosition( long ); | 73 | void setPosition( long ); |
74 | 74 | ||
75 | public: | 75 | public: |
76 | virtual void setPlaying( bool b); | 76 | virtual void setPlaying( bool b); |
77 | virtual void setLength( long ); | 77 | virtual void setLength( long ); |
78 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); | 78 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); |
79 | 79 | ||
80 | signals: | 80 | signals: |
81 | void moreClicked(); | 81 | void moreClicked(); |
82 | void lessClicked(); | 82 | void lessClicked(); |
83 | void moreReleased(); | 83 | void moreReleased(); |
84 | void lessReleased(); | 84 | void lessReleased(); |
85 | void sliderMoved( long ); | 85 | void sliderMoved( long ); |
86 | void videoResized ( const QSize &s ); | 86 | void videoResized ( const QSize &s ); |
87 | 87 | ||
88 | protected: | 88 | protected: |
89 | 89 | ||
90 | void resizeEvent( QResizeEvent * ); | 90 | void resizeEvent( QResizeEvent * ); |
91 | void paintEvent( QPaintEvent *pe ); | ||
92 | void showEvent( QShowEvent *se ); | 91 | void showEvent( QShowEvent *se ); |
93 | void mouseMoveEvent( QMouseEvent *event ); | 92 | void mouseMoveEvent( QMouseEvent *event ); |
94 | void mousePressEvent( QMouseEvent *event ); | 93 | void mousePressEvent( QMouseEvent *event ); |
95 | void mouseReleaseEvent( QMouseEvent *event ); | 94 | void mouseReleaseEvent( QMouseEvent *event ); |
96 | void keyReleaseEvent( QKeyEvent *e); | 95 | void keyReleaseEvent( QKeyEvent *e); |
97 | 96 | ||
98 | private: | 97 | private: |
99 | // Ticker songInfo; | 98 | // Ticker songInfo; |
100 | QImage imgUp; | 99 | QImage imgUp; |
101 | QImage imgDn; | 100 | QImage imgDn; |
102 | QString skin; | 101 | QString skin; |
103 | 102 | ||
104 | 103 | ||
105 | void setToggleButton( int, bool ); | 104 | void setToggleButton( int, bool ); |
106 | 105 | ||
107 | QString backgroundPix; | 106 | QString backgroundPix; |
108 | QSlider *slider; | 107 | QSlider *slider; |
109 | QImage *currentFrame; | 108 | QImage *currentFrame; |
110 | int scaledWidth; | 109 | int scaledWidth; |
111 | int scaledHeight; | 110 | int scaledHeight; |
112 | XineVideoWidget* videoFrame; | 111 | XineVideoWidget* videoFrame; |
113 | }; | 112 | }; |
114 | 113 | ||
115 | #endif // VIDEO_WIDGET_H | 114 | #endif // VIDEO_WIDGET_H |
116 | 115 | ||
117 | 116 | ||
118 | 117 | ||