author | simon <simon> | 2002-12-09 13:52:00 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-09 13:52:00 (UTC) |
commit | 46bca195f0dacc3b596eb1537ae47bc2117ce8e4 (patch) (unidiff) | |
tree | 135414127395da9466d77ef71fa85bd41b130bf0 | |
parent | 374d7ba11f669449900c7e93f7929d724eb85f26 (diff) | |
download | opie-46bca195f0dacc3b596eb1537ae47bc2117ce8e4.zip opie-46bca195f0dacc3b596eb1537ae47bc2117ce8e4.tar.gz opie-46bca195f0dacc3b596eb1537ae47bc2117ce8e4.tar.bz2 |
- isToggle is now an enum ButtonType { NormalButton, ToggleButton };
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 10 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.h | 5 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 8 |
3 files changed, 10 insertions, 13 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 8659971..56b75f2 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -30,102 +30,100 @@ | |||
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <qpe/qpeapplication.h> | 34 | #include <qpe/qpeapplication.h> |
35 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | #include <opie/oticker.h> | 37 | #include <opie/oticker.h> |
38 | 38 | ||
39 | #include <qwidget.h> | 39 | #include <qwidget.h> |
40 | #include <qpixmap.h> | 40 | #include <qpixmap.h> |
41 | #include <qbutton.h> | 41 | #include <qbutton.h> |
42 | #include <qpainter.h> | 42 | #include <qpainter.h> |
43 | #include <qframe.h> | 43 | #include <qframe.h> |
44 | #include <qlayout.h> | 44 | #include <qlayout.h> |
45 | #include <qdir.h> | 45 | #include <qdir.h> |
46 | #include <stdlib.h> | 46 | #include <stdlib.h> |
47 | #include <stdio.h> | 47 | #include <stdio.h> |
48 | 48 | ||
49 | #include "audiowidget.h" | 49 | #include "audiowidget.h" |
50 | #include "mediaplayerstate.h" | 50 | #include "mediaplayerstate.h" |
51 | #include "playlistwidget.h" | 51 | #include "playlistwidget.h" |
52 | 52 | ||
53 | namespace | 53 | namespace |
54 | { | 54 | { |
55 | 55 | ||
56 | const int xo = -2; // movable x offset | 56 | const int xo = -2; // movable x offset |
57 | const int yo = 22; // movable y offset | 57 | const int yo = 22; // movable y offset |
58 | 58 | ||
59 | const char * const skin_mask_file_names[10] = { | 59 | const char * const skin_mask_file_names[10] = { |
60 | "play", "stop", "next", "prev", "up", | 60 | "play", "stop", "next", "prev", "up", |
61 | "down", "loop", "playlist", "forward", "back" | 61 | "down", "loop", "playlist", "forward", "back" |
62 | }; | 62 | }; |
63 | 63 | ||
64 | void changeTextColor( QWidget * w) { | 64 | void changeTextColor( QWidget * w) { |
65 | QPalette p = w->palette(); | 65 | QPalette p = w->palette(); |
66 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); | 66 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); |
67 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); | 67 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); |
68 | w->setPalette( p ); | 68 | w->setPalette( p ); |
69 | } | 69 | } |
70 | 70 | ||
71 | } | 71 | } |
72 | 72 | ||
73 | AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : | 73 | AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : |
74 | 74 | ||
75 | MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ), | 75 | MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ), |
76 | audioSliderBeingMoved( false ) | 76 | audioSliderBeingMoved( false ) |
77 | { | 77 | { |
78 | Button defaultButton; | ||
78 | 79 | ||
79 | Button defaultButton; | 80 | Button toggleButton = defaultButton; |
80 | defaultButton.isToggle = defaultButton.isHeld = defaultButton.isDown = false; | 81 | toggleButton.buttonType = ToggleButton; |
81 | Button toggleButton; | ||
82 | toggleButton.isToggle = true; | ||
83 | toggleButton.isHeld = toggleButton.isDown = false; | ||
84 | 82 | ||
85 | buttons.reserve( 10 ); | 83 | buttons.reserve( 10 ); |
86 | buttons.push_back( toggleButton ); // play | 84 | buttons.push_back( toggleButton ); // play |
87 | buttons.push_back( defaultButton ); // stop | 85 | buttons.push_back( defaultButton ); // stop |
88 | buttons.push_back( defaultButton ); // next | 86 | buttons.push_back( defaultButton ); // next |
89 | buttons.push_back( defaultButton ); // previous | 87 | buttons.push_back( defaultButton ); // previous |
90 | buttons.push_back( defaultButton ); // volume up | 88 | buttons.push_back( defaultButton ); // volume up |
91 | buttons.push_back( defaultButton ); // volume down | 89 | buttons.push_back( defaultButton ); // volume down |
92 | buttons.push_back( toggleButton ); // repeat/loop | 90 | buttons.push_back( toggleButton ); // repeat/loop |
93 | buttons.push_back( defaultButton ); // playlist | 91 | buttons.push_back( defaultButton ); // playlist |
94 | buttons.push_back( defaultButton ); // forward | 92 | buttons.push_back( defaultButton ); // forward |
95 | buttons.push_back( defaultButton ); // back | 93 | buttons.push_back( defaultButton ); // back |
96 | 94 | ||
97 | setCaption( tr("OpiePlayer") ); | 95 | setCaption( tr("OpiePlayer") ); |
98 | 96 | ||
99 | Config cfg("OpiePlayer"); | 97 | Config cfg("OpiePlayer"); |
100 | cfg.setGroup("Options"); | 98 | cfg.setGroup("Options"); |
101 | skin = cfg.readEntry("Skin","default"); | 99 | skin = cfg.readEntry("Skin","default"); |
102 | //skin = "scaleTest"; | 100 | //skin = "scaleTest"; |
103 | // color of background, frame, degree of transparency | 101 | // color of background, frame, degree of transparency |
104 | 102 | ||
105 | QString skinPath = "opieplayer2/skins/" + skin; | 103 | QString skinPath = "opieplayer2/skins/" + skin; |
106 | pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 104 | pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
107 | imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); | 105 | imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); |
108 | imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); | 106 | imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); |
109 | 107 | ||
110 | buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); | 108 | buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); |
111 | buttonMask.fill( 0 ); | 109 | buttonMask.fill( 0 ); |
112 | 110 | ||
113 | masks.reserve( 10 ); | 111 | masks.reserve( 10 ); |
114 | 112 | ||
115 | for ( uint i = 0; i < masks.capacity(); i++ ) { | 113 | for ( uint i = 0; i < masks.capacity(); i++ ) { |
116 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" ); | 114 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" ); |
117 | masks.push_back( QBitmap( filename ) ); | 115 | masks.push_back( QBitmap( filename ) ); |
118 | 116 | ||
119 | if ( !masks[i].isNull() ) { | 117 | if ( !masks[i].isNull() ) { |
120 | QImage imgMask = masks[i].convertToImage(); | 118 | QImage imgMask = masks[i].convertToImage(); |
121 | uchar **dest = buttonMask.jumpTable(); | 119 | uchar **dest = buttonMask.jumpTable(); |
122 | for ( int y = 0; y < imgUp.height(); y++ ) { | 120 | for ( int y = 0; y < imgUp.height(); y++ ) { |
123 | uchar *line = dest[y]; | 121 | uchar *line = dest[y]; |
124 | for ( int x = 0; x < imgUp.width(); x++ ) | 122 | for ( int x = 0; x < imgUp.width(); x++ ) |
125 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 123 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
126 | line[x] = i + 1; | 124 | line[x] = i + 1; |
127 | } | 125 | } |
128 | } | 126 | } |
129 | 127 | ||
130 | } | 128 | } |
131 | 129 | ||
@@ -344,97 +342,97 @@ void AudioWidget::skipBack() { | |||
344 | } | 342 | } |
345 | 343 | ||
346 | 344 | ||
347 | 345 | ||
348 | void AudioWidget::stopSkip() { | 346 | void AudioWidget::stopSkip() { |
349 | killTimers(); | 347 | killTimers(); |
350 | } | 348 | } |
351 | 349 | ||
352 | 350 | ||
353 | void AudioWidget::timerEvent( QTimerEvent * ) { | 351 | void AudioWidget::timerEvent( QTimerEvent * ) { |
354 | if ( skipDirection == +1 ) { | 352 | if ( skipDirection == +1 ) { |
355 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); | 353 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); |
356 | } else if ( skipDirection == -1 ) { | 354 | } else if ( skipDirection == -1 ) { |
357 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); | 355 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); |
358 | } | 356 | } |
359 | } | 357 | } |
360 | 358 | ||
361 | 359 | ||
362 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | 360 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { |
363 | for ( unsigned int i = 0; i < buttons.size(); i++ ) { | 361 | for ( unsigned int i = 0; i < buttons.size(); i++ ) { |
364 | if ( event->state() == QMouseEvent::LeftButton ) { | 362 | if ( event->state() == QMouseEvent::LeftButton ) { |
365 | // The test to see if the mouse click is inside the button or not | 363 | // The test to see if the mouse click is inside the button or not |
366 | bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); | 364 | bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); |
367 | 365 | ||
368 | if ( isOnButton && !buttons[i].isHeld ) { | 366 | if ( isOnButton && !buttons[i].isHeld ) { |
369 | buttons[i].isHeld = TRUE; | 367 | buttons[i].isHeld = TRUE; |
370 | toggleButton(i); | 368 | toggleButton(i); |
371 | switch (i) { | 369 | switch (i) { |
372 | case VolumeUp: | 370 | case VolumeUp: |
373 | emit moreClicked(); | 371 | emit moreClicked(); |
374 | return; | 372 | return; |
375 | case VolumeDown: | 373 | case VolumeDown: |
376 | emit lessClicked(); | 374 | emit lessClicked(); |
377 | return; | 375 | return; |
378 | case Forward: | 376 | case Forward: |
379 | emit forwardClicked(); | 377 | emit forwardClicked(); |
380 | return; | 378 | return; |
381 | case Back: | 379 | case Back: |
382 | emit backClicked(); | 380 | emit backClicked(); |
383 | return; | 381 | return; |
384 | } | 382 | } |
385 | } else if ( !isOnButton && buttons[i].isHeld ) { | 383 | } else if ( !isOnButton && buttons[i].isHeld ) { |
386 | buttons[i].isHeld = FALSE; | 384 | buttons[i].isHeld = FALSE; |
387 | toggleButton(i); | 385 | toggleButton(i); |
388 | } | 386 | } |
389 | } else { | 387 | } else { |
390 | if ( buttons[i].isHeld ) { | 388 | if ( buttons[i].isHeld ) { |
391 | buttons[i].isHeld = FALSE; | 389 | buttons[i].isHeld = FALSE; |
392 | if ( !buttons[i].isToggle ) { | 390 | if ( buttons[i].buttonType != ToggleButton ) { |
393 | setToggleButton( i, FALSE ); | 391 | setToggleButton( i, FALSE ); |
394 | } | 392 | } |
395 | qDebug("mouseEvent %d", i); | 393 | qDebug("mouseEvent %d", i); |
396 | handleCommand( static_cast<Command>( i ), buttons[ i ].isDown ); | 394 | handleCommand( static_cast<Command>( i ), buttons[ i ].isDown ); |
397 | } | 395 | } |
398 | } | 396 | } |
399 | } | 397 | } |
400 | } | 398 | } |
401 | 399 | ||
402 | 400 | ||
403 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { | 401 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { |
404 | mouseMoveEvent( event ); | 402 | mouseMoveEvent( event ); |
405 | } | 403 | } |
406 | 404 | ||
407 | 405 | ||
408 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { | 406 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { |
409 | mouseMoveEvent( event ); | 407 | mouseMoveEvent( event ); |
410 | } | 408 | } |
411 | 409 | ||
412 | 410 | ||
413 | void AudioWidget::showEvent( QShowEvent* ) { | 411 | void AudioWidget::showEvent( QShowEvent* ) { |
414 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 412 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
415 | mouseMoveEvent( &event ); | 413 | mouseMoveEvent( &event ); |
416 | } | 414 | } |
417 | 415 | ||
418 | 416 | ||
419 | void AudioWidget::paintEvent( QPaintEvent * pe ) { | 417 | void AudioWidget::paintEvent( QPaintEvent * pe ) { |
420 | if ( !pe->erased() ) { | 418 | if ( !pe->erased() ) { |
421 | // Combine with background and double buffer | 419 | // Combine with background and double buffer |
422 | QPixmap pix( pe->rect().size() ); | 420 | QPixmap pix( pe->rect().size() ); |
423 | QPainter p( &pix ); | 421 | QPainter p( &pix ); |
424 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 422 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
425 | p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); | 423 | p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); |
426 | for ( unsigned int i = 0; i < buttons.size(); i++ ) | 424 | for ( unsigned int i = 0; i < buttons.size(); i++ ) |
427 | paintButton( p, i ); | 425 | paintButton( p, i ); |
428 | QPainter p2( this ); | 426 | QPainter p2( this ); |
429 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 427 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
430 | } else { | 428 | } else { |
431 | QPainter p( this ); | 429 | QPainter p( this ); |
432 | for ( unsigned int i = 0; i < buttons.size(); i++ ) | 430 | for ( unsigned int i = 0; i < buttons.size(); i++ ) |
433 | paintButton( p, i ); | 431 | paintButton( p, i ); |
434 | } | 432 | } |
435 | } | 433 | } |
436 | 434 | ||
437 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { | 435 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { |
438 | switch ( e->key() ) { | 436 | switch ( e->key() ) { |
439 | ////////////////////////////// Zaurus keys | 437 | ////////////////////////////// Zaurus keys |
440 | case Key_Home: | 438 | case Key_Home: |
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h index 46c304d..aa8891f 100644 --- a/noncore/multimedia/opieplayer2/mediawidget.h +++ b/noncore/multimedia/opieplayer2/mediawidget.h | |||
@@ -1,87 +1,88 @@ | |||
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 | 27 | ||
28 | #include "mediaplayerstate.h" | 28 | #include "mediaplayerstate.h" |
29 | #include "playlistwidget.h" | 29 | #include "playlistwidget.h" |
30 | 30 | ||
31 | #include <vector> | 31 | #include <vector> |
32 | 32 | ||
33 | class MediaWidget : public QWidget | 33 | class MediaWidget : public QWidget |
34 | { | 34 | { |
35 | Q_OBJECT | 35 | Q_OBJECT |
36 | public: | 36 | public: |
37 | enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back }; | 37 | enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back }; |
38 | enum ButtonType { NormalButton, ToggleButton }; | ||
38 | 39 | ||
39 | struct Button | 40 | struct Button |
40 | { | 41 | { |
41 | Button() : isToggle( false ), isHeld( false ), isDown( false ) {} | 42 | Button() : buttonType( NormalButton ), isHeld( false ), isDown( false ) {} |
42 | 43 | ||
43 | bool isToggle : 1; | 44 | ButtonType buttonType : 1; |
44 | bool isHeld : 1; | 45 | bool isHeld : 1; |
45 | bool isDown : 1; | 46 | bool isDown : 1; |
46 | }; | 47 | }; |
47 | typedef std::vector<Button> ButtonVector; | 48 | typedef std::vector<Button> ButtonVector; |
48 | 49 | ||
49 | MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); | 50 | MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); |
50 | virtual ~MediaWidget(); | 51 | virtual ~MediaWidget(); |
51 | 52 | ||
52 | public slots: | 53 | public slots: |
53 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; | 54 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; |
54 | virtual void setLength( long length ) = 0; | 55 | virtual void setLength( long length ) = 0; |
55 | virtual void setPlaying( bool playing ) = 0; | 56 | virtual void setPlaying( bool playing ) = 0; |
56 | 57 | ||
57 | signals: | 58 | signals: |
58 | void moreReleased(); | 59 | void moreReleased(); |
59 | void lessReleased(); | 60 | void lessReleased(); |
60 | void forwardReleased(); | 61 | void forwardReleased(); |
61 | void backReleased(); | 62 | void backReleased(); |
62 | 63 | ||
63 | protected: | 64 | protected: |
64 | virtual void closeEvent( QCloseEvent * ); | 65 | virtual void closeEvent( QCloseEvent * ); |
65 | 66 | ||
66 | void handleCommand( Command command, bool buttonDown ); | 67 | void handleCommand( Command command, bool buttonDown ); |
67 | 68 | ||
68 | bool isOverButton( const QPoint &position, int buttonId ) const; | 69 | bool isOverButton( const QPoint &position, int buttonId ) const; |
69 | 70 | ||
70 | void paintButton( int buttonId ); | 71 | void paintButton( int buttonId ); |
71 | virtual void paintButton( QPainter &p, int i ) = 0; | 72 | virtual void paintButton( QPainter &p, int i ) = 0; |
72 | 73 | ||
73 | void toggleButton( int buttonId ); | 74 | void toggleButton( int buttonId ); |
74 | 75 | ||
75 | MediaPlayerState &mediaPlayerState; | 76 | MediaPlayerState &mediaPlayerState; |
76 | PlayListWidget &playList; | 77 | PlayListWidget &playList; |
77 | 78 | ||
78 | ButtonVector buttons; | 79 | ButtonVector buttons; |
79 | 80 | ||
80 | QImage buttonMask; | 81 | QImage buttonMask; |
81 | 82 | ||
82 | QPoint upperLeftOfButtonMask; | 83 | QPoint upperLeftOfButtonMask; |
83 | }; | 84 | }; |
84 | 85 | ||
85 | #endif // MEDIAWIDGET_H | 86 | #endif // MEDIAWIDGET_H |
86 | /* vim: et sw=4 ts=4 | 87 | /* vim: et sw=4 ts=4 |
87 | */ | 88 | */ |
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 2f51c82..23acfa3 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -26,100 +26,98 @@ | |||
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 | #include <qpe/qpeapplication.h> | 34 | #include <qpe/qpeapplication.h> |
35 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | 37 | ||
38 | 38 | ||
39 | #include <qwidget.h> | 39 | #include <qwidget.h> |
40 | #include <qpainter.h> | 40 | #include <qpainter.h> |
41 | #include <qpixmap.h> | 41 | #include <qpixmap.h> |
42 | #include <qslider.h> | 42 | #include <qslider.h> |
43 | #include <qdrawutil.h> | 43 | #include <qdrawutil.h> |
44 | #include "videowidget.h" | 44 | #include "videowidget.h" |
45 | #include "mediaplayerstate.h" | 45 | #include "mediaplayerstate.h" |
46 | #include "playlistwidget.h" | 46 | #include "playlistwidget.h" |
47 | 47 | ||
48 | 48 | ||
49 | #ifdef Q_WS_QWS | 49 | #ifdef Q_WS_QWS |
50 | # define USE_DIRECT_PAINTER | 50 | # define USE_DIRECT_PAINTER |
51 | # include <qdirectpainter_qws.h> | 51 | # include <qdirectpainter_qws.h> |
52 | # include <qgfxraster_qws.h> | 52 | # include <qgfxraster_qws.h> |
53 | #endif | 53 | #endif |
54 | 54 | ||
55 | 55 | ||
56 | namespace | 56 | namespace |
57 | { | 57 | { |
58 | 58 | ||
59 | const int xo = 2; // movable x offset | 59 | const int xo = 2; // movable x offset |
60 | const int yo = 0; // movable y offset | 60 | const int yo = 0; // movable y offset |
61 | 61 | ||
62 | const char * const skinV_mask_file_names[7] = { | 62 | const char * const skinV_mask_file_names[7] = { |
63 | "play","stop","fwd","back","up","down","full" | 63 | "play","stop","fwd","back","up","down","full" |
64 | }; | 64 | }; |
65 | 65 | ||
66 | } | 66 | } |
67 | 67 | ||
68 | VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) | 68 | VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) |
69 | : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) | 69 | : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) |
70 | { | 70 | { |
71 | setCaption( tr("OpiePlayer - Video") ); | 71 | setCaption( tr("OpiePlayer - Video") ); |
72 | 72 | ||
73 | Button defaultButton; | 73 | Button defaultButton; |
74 | defaultButton.isToggle = defaultButton.isHeld = defaultButton.isDown = false; | 74 | Button toggleButton = defaultButton; |
75 | Button toggleButton; | 75 | toggleButton.buttonType = ToggleButton; |
76 | toggleButton.isToggle = true; | ||
77 | toggleButton.isHeld = toggleButton.isDown = false; | ||
78 | 76 | ||
79 | buttons.reserve( 7 ); | 77 | buttons.reserve( 7 ); |
80 | buttons.push_back( toggleButton ); // play | 78 | buttons.push_back( toggleButton ); // play |
81 | buttons.push_back( defaultButton ); // stop | 79 | buttons.push_back( defaultButton ); // stop |
82 | buttons.push_back( defaultButton ); // next | 80 | buttons.push_back( defaultButton ); // next |
83 | buttons.push_back( defaultButton ); // previous | 81 | buttons.push_back( defaultButton ); // previous |
84 | buttons.push_back( defaultButton ); // volUp | 82 | buttons.push_back( defaultButton ); // volUp |
85 | buttons.push_back( defaultButton ); // volDown | 83 | buttons.push_back( defaultButton ); // volDown |
86 | buttons.push_back( toggleButton ); //fullscreen | 84 | buttons.push_back( toggleButton ); //fullscreen |
87 | 85 | ||
88 | videoFrame = new XineVideoWidget ( this, "Video frame" ); | 86 | videoFrame = new XineVideoWidget ( this, "Video frame" ); |
89 | 87 | ||
90 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); | 88 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); |
91 | connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); | 89 | connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); |
92 | 90 | ||
93 | Config cfg("OpiePlayer"); | 91 | Config cfg("OpiePlayer"); |
94 | cfg.setGroup("Options"); | 92 | cfg.setGroup("Options"); |
95 | skin = cfg.readEntry("Skin","default"); | 93 | skin = cfg.readEntry("Skin","default"); |
96 | 94 | ||
97 | QString skinPath = "opieplayer2/skins/" + skin; | 95 | QString skinPath = "opieplayer2/skins/" + skin; |
98 | pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 96 | pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
99 | imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); | 97 | imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); |
100 | imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); | 98 | imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); |
101 | 99 | ||
102 | buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); | 100 | buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); |
103 | buttonMask.fill( 0 ); | 101 | buttonMask.fill( 0 ); |
104 | 102 | ||
105 | for ( int i = 0; i < 7; i++ ) { | 103 | for ( int i = 0; i < 7; i++ ) { |
106 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); | 104 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); |
107 | masks[i] = new QBitmap( filename ); | 105 | masks[i] = new QBitmap( filename ); |
108 | 106 | ||
109 | if ( !masks[i]->isNull() ) { | 107 | if ( !masks[i]->isNull() ) { |
110 | QImage imgMask = masks[i]->convertToImage(); | 108 | QImage imgMask = masks[i]->convertToImage(); |
111 | uchar **dest = buttonMask.jumpTable(); | 109 | uchar **dest = buttonMask.jumpTable(); |
112 | for ( int y = 0; y < imgUp.height(); y++ ) { | 110 | for ( int y = 0; y < imgUp.height(); y++ ) { |
113 | uchar *line = dest[y]; | 111 | uchar *line = dest[y]; |
114 | for ( int x = 0; x < imgUp.width(); x++ ) { | 112 | for ( int x = 0; x < imgUp.width(); x++ ) { |
115 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 113 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
116 | line[x] = i + 1; | 114 | line[x] = i + 1; |
117 | } | 115 | } |
118 | } | 116 | } |
119 | } | 117 | } |
120 | } | 118 | } |
121 | 119 | ||
122 | for ( int i = 0; i < 7; i++ ) { | 120 | for ( int i = 0; i < 7; i++ ) { |
123 | buttonPixUp[i] = NULL; | 121 | buttonPixUp[i] = NULL; |
124 | buttonPixDown[i] = NULL; | 122 | buttonPixDown[i] = NULL; |
125 | } | 123 | } |
@@ -253,97 +251,97 @@ void VideoWidget::updateSlider( long i, long max ) { | |||
253 | } | 251 | } |
254 | if ( slider->maxValue() != width ) { | 252 | if ( slider->maxValue() != width ) { |
255 | slider->setMaxValue( width ); | 253 | slider->setMaxValue( width ); |
256 | } | 254 | } |
257 | } | 255 | } |
258 | } | 256 | } |
259 | 257 | ||
260 | void VideoWidget::setToggleButton( int i, bool down ) { | 258 | void VideoWidget::setToggleButton( int i, bool down ) { |
261 | if ( down != buttons[i].isDown ) { | 259 | if ( down != buttons[i].isDown ) { |
262 | toggleButton( i ); | 260 | toggleButton( i ); |
263 | } | 261 | } |
264 | } | 262 | } |
265 | 263 | ||
266 | void VideoWidget::paintButton( QPainter &p, int i ) { | 264 | void VideoWidget::paintButton( QPainter &p, int i ) { |
267 | 265 | ||
268 | if ( buttons[i].isDown ) { | 266 | if ( buttons[i].isDown ) { |
269 | p.drawPixmap( upperLeftOfButtonMask, *buttonPixDown[i] ); | 267 | p.drawPixmap( upperLeftOfButtonMask, *buttonPixDown[i] ); |
270 | } else { | 268 | } else { |
271 | p.drawPixmap( upperLeftOfButtonMask, *buttonPixUp[i] ); | 269 | p.drawPixmap( upperLeftOfButtonMask, *buttonPixUp[i] ); |
272 | } | 270 | } |
273 | } | 271 | } |
274 | 272 | ||
275 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 273 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
276 | for ( unsigned int i = 0; i < buttons.size(); i++ ) { | 274 | for ( unsigned int i = 0; i < buttons.size(); i++ ) { |
277 | if ( event->state() == QMouseEvent::LeftButton ) { | 275 | if ( event->state() == QMouseEvent::LeftButton ) { |
278 | // The test to see if the mouse click is inside the button or not | 276 | // The test to see if the mouse click is inside the button or not |
279 | bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); | 277 | bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); |
280 | 278 | ||
281 | if ( isOnButton && !buttons[i].isHeld ) { | 279 | if ( isOnButton && !buttons[i].isHeld ) { |
282 | buttons[i].isHeld = TRUE; | 280 | buttons[i].isHeld = TRUE; |
283 | toggleButton(i); | 281 | toggleButton(i); |
284 | 282 | ||
285 | switch (i) { | 283 | switch (i) { |
286 | case VideoVolUp: | 284 | case VideoVolUp: |
287 | emit moreClicked(); | 285 | emit moreClicked(); |
288 | return; | 286 | return; |
289 | case VideoVolDown: | 287 | case VideoVolDown: |
290 | emit lessClicked(); | 288 | emit lessClicked(); |
291 | return; | 289 | return; |
292 | } | 290 | } |
293 | } else if ( !isOnButton && buttons[i].isHeld ) { | 291 | } else if ( !isOnButton && buttons[i].isHeld ) { |
294 | buttons[i].isHeld = FALSE; | 292 | buttons[i].isHeld = FALSE; |
295 | toggleButton(i); | 293 | toggleButton(i); |
296 | } | 294 | } |
297 | } else { | 295 | } else { |
298 | 296 | ||
299 | if ( buttons[i].isHeld ) { | 297 | if ( buttons[i].isHeld ) { |
300 | buttons[i].isHeld = FALSE; | 298 | buttons[i].isHeld = FALSE; |
301 | if ( !buttons[i].isToggle ) { | 299 | if ( buttons[i].buttonType != ToggleButton ) { |
302 | setToggleButton( i, FALSE ); | 300 | setToggleButton( i, FALSE ); |
303 | } | 301 | } |
304 | 302 | ||
305 | switch(i) { | 303 | switch(i) { |
306 | 304 | ||
307 | case VideoPlay: { | 305 | case VideoPlay: { |
308 | if( mediaPlayerState.isPaused() ) { | 306 | if( mediaPlayerState.isPaused() ) { |
309 | setToggleButton( i, FALSE ); | 307 | setToggleButton( i, FALSE ); |
310 | mediaPlayerState.setPaused( FALSE ); | 308 | mediaPlayerState.setPaused( FALSE ); |
311 | return; | 309 | return; |
312 | } else if( !mediaPlayerState.isPaused() ) { | 310 | } else if( !mediaPlayerState.isPaused() ) { |
313 | setToggleButton( i, TRUE ); | 311 | setToggleButton( i, TRUE ); |
314 | mediaPlayerState.setPaused( TRUE ); | 312 | mediaPlayerState.setPaused( TRUE ); |
315 | return; | 313 | return; |
316 | } else { | 314 | } else { |
317 | return; | 315 | return; |
318 | } | 316 | } |
319 | } | 317 | } |
320 | 318 | ||
321 | case VideoStop: mediaPlayerState.setPlaying( FALSE ); return; | 319 | case VideoStop: mediaPlayerState.setPlaying( FALSE ); return; |
322 | case VideoNext: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; | 320 | case VideoNext: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; |
323 | case VideoPrevious: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; | 321 | case VideoPrevious: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; |
324 | case VideoVolUp: emit moreReleased(); return; | 322 | case VideoVolUp: emit moreReleased(); return; |
325 | case VideoVolDown: emit lessReleased(); return; | 323 | case VideoVolDown: emit lessReleased(); return; |
326 | case VideoFullscreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return; | 324 | case VideoFullscreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return; |
327 | } | 325 | } |
328 | } | 326 | } |
329 | } | 327 | } |
330 | } | 328 | } |
331 | } | 329 | } |
332 | 330 | ||
333 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { | 331 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { |
334 | mouseMoveEvent( event ); | 332 | mouseMoveEvent( event ); |
335 | } | 333 | } |
336 | 334 | ||
337 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 335 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
338 | if ( mediaPlayerState.isFullscreen() ) { | 336 | if ( mediaPlayerState.isFullscreen() ) { |
339 | mediaPlayerState.setFullscreen( FALSE ); | 337 | mediaPlayerState.setFullscreen( FALSE ); |
340 | makeVisible(); | 338 | makeVisible(); |
341 | } | 339 | } |
342 | mouseMoveEvent( event ); | 340 | mouseMoveEvent( event ); |
343 | } | 341 | } |
344 | 342 | ||
345 | void VideoWidget::showEvent( QShowEvent* ) { | 343 | void VideoWidget::showEvent( QShowEvent* ) { |
346 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 344 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
347 | mouseMoveEvent( &event ); | 345 | mouseMoveEvent( &event ); |
348 | } | 346 | } |
349 | 347 | ||