summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-09 16:28:55 (UTC)
committer simon <simon>2002-12-09 16:28:55 (UTC)
commit3b31b000db15e7618b3ef06a652bae41d87a1348 (patch) (unidiff)
tree25360f74f235f016d6ca50f2e4b8cc280a2e3a2e
parenteeb797c68aca5cad9989b8438facebee13eede5e (diff)
downloadopie-3b31b000db15e7618b3ef06a652bae41d87a1348.zip
opie-3b31b000db15e7618b3ef06a652bae41d87a1348.tar.gz
opie-3b31b000db15e7618b3ef06a652bae41d87a1348.tar.bz2
- transition to MediaWidget::Command completed
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.h4
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp9
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h1
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp33
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.h11
5 files changed, 30 insertions, 28 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h
index 092e5ce..9b276b5 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.h
+++ b/noncore/multimedia/opieplayer2/audiowidget.h
@@ -14,94 +14,94 @@
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
50class QPixmap; 50class QPixmap;
51 51
52class AudioWidget : public MediaWidget { 52class AudioWidget : public MediaWidget {
53 Q_OBJECT 53 Q_OBJECT
54public: 54public:
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 ); }
58public slots: 58public 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( buttons[ 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
66public: 66public:
67 virtual void setLength( long ); 67 virtual void setLength( long );
68 virtual void setPlaying( bool b) { setToggleButton( buttons[ 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
71signals: 71signals:
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
78protected: 78protected:
79 void doBlank(); 79 void doBlank();
80 void doUnblank(); 80 void doUnblank();
81 void showEvent( QShowEvent *se ); 81 void showEvent( QShowEvent *se );
82 void resizeEvent( QResizeEvent *re ); 82 void resizeEvent( QResizeEvent *re );
83 void mouseMoveEvent( QMouseEvent *event ); 83 void mouseMoveEvent( QMouseEvent *event );
84 void mousePressEvent( QMouseEvent *event ); 84 void mousePressEvent( QMouseEvent *event );
85 void mouseReleaseEvent( QMouseEvent *event ); 85 void mouseReleaseEvent( QMouseEvent *event );
86 void timerEvent( QTimerEvent *event ); 86 void timerEvent( QTimerEvent *event );
87 void keyReleaseEvent( QKeyEvent *e); 87 void keyReleaseEvent( QKeyEvent *e);
88private slots: 88private slots:
89 void skipFor(); 89 void skipFor();
90 void skipBack(); 90 void skipBack();
91 void stopSkip(); 91 void stopSkip();
92private: 92private:
93 int skipDirection; 93 int skipDirection;
94 QString skin; 94 QString skin;
95 QImage imgUp; 95 QImage imgUp;
96 QImage imgDn; 96 QImage imgDn;
97 97
98 OTicker songInfo; 98 OTicker songInfo;
99 QSlider slider; 99 QSlider slider;
100 QLineEdit time; 100 QLineEdit time;
101 bool isStreaming : 1; 101 bool isStreaming : 1;
102 bool audioSliderBeingMoved : 1; 102 bool audioSliderBeingMoved : 1;
103}; 103};
104 104
105 105
106#endif // AUDIO_WIDGET_H 106#endif // AUDIO_WIDGET_H
107 107
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index 7891a7e..c0ebd63 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -70,63 +70,72 @@ void MediaWidget::paintEvent( QPaintEvent *pe )
70} 70}
71 71
72void MediaWidget::handleCommand( Command command, bool buttonDown ) 72void MediaWidget::handleCommand( Command command, bool buttonDown )
73{ 73{
74 switch ( command ) { 74 switch ( command ) {
75 case Play: mediaPlayerState.togglePaused(); 75 case Play: mediaPlayerState.togglePaused();
76 case Stop: mediaPlayerState.setPlaying(FALSE); return; 76 case Stop: mediaPlayerState.setPlaying(FALSE); return;
77 case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; 77 case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return;
78 case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; 78 case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return;
79 case Loop: mediaPlayerState.setLooping( buttonDown ); return; 79 case Loop: mediaPlayerState.setLooping( buttonDown ); return;
80 case VolumeUp: emit moreReleased(); return; 80 case VolumeUp: emit moreReleased(); return;
81 case VolumeDown: emit lessReleased(); return; 81 case VolumeDown: emit lessReleased(); return;
82 case PlayList: mediaPlayerState.setList(); return; 82 case PlayList: mediaPlayerState.setList(); return;
83 case Forward: emit forwardReleased(); return; 83 case Forward: emit forwardReleased(); return;
84 case Back: emit backReleased(); return; 84 case Back: emit backReleased(); return;
85 default: assert( false ); 85 default: assert( false );
86 } 86 }
87} 87}
88 88
89bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const 89bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const
90{ 90{
91 return ( position.x() > 0 && position.y() > 0 && 91 return ( position.x() > 0 && position.y() > 0 &&
92 position.x() < buttonMask.width() && 92 position.x() < buttonMask.width() &&
93 position.y() < buttonMask.height() && 93 position.y() < buttonMask.height() &&
94 buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 ); 94 buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 );
95} 95}
96 96
97void MediaWidget::paintAllButtons( QPainter &p ) 97void MediaWidget::paintAllButtons( QPainter &p )
98{ 98{
99 for ( ButtonVector::const_iterator it = buttons.begin(); 99 for ( ButtonVector::const_iterator it = buttons.begin();
100 it != buttons.end(); ++it ) 100 it != buttons.end(); ++it )
101 paintButton( p, *it ); 101 paintButton( p, *it );
102} 102}
103 103
104void MediaWidget::paintButton( const Button &button ) 104void MediaWidget::paintButton( const Button &button )
105{ 105{
106 QPainter p( this ); 106 QPainter p( this );
107 paintButton( p, button ); 107 paintButton( p, button );
108} 108}
109 109
110void MediaWidget::paintButton( QPainter &p, const Button &button ) 110void MediaWidget::paintButton( QPainter &p, const Button &button )
111{ 111{
112 if ( button.isDown ) 112 if ( button.isDown )
113 p.drawPixmap( upperLeftOfButtonMask, button.pixDown ); 113 p.drawPixmap( upperLeftOfButtonMask, button.pixDown );
114 else 114 else
115 p.drawPixmap( upperLeftOfButtonMask, button.pixUp ); 115 p.drawPixmap( upperLeftOfButtonMask, button.pixUp );
116} 116}
117 117
118void MediaWidget::setToggleButton( Command command, bool down )
119{
120 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it )
121 if ( it->command == command ) {
122 setToggleButton( *it, down );
123 return;
124 }
125}
126
118void MediaWidget::setToggleButton( Button &button, bool down ) 127void MediaWidget::setToggleButton( Button &button, bool down )
119{ 128{
120 if ( down != button.isDown ) 129 if ( down != button.isDown )
121 toggleButton( button ); 130 toggleButton( button );
122} 131}
123 132
124void MediaWidget::toggleButton( Button &button ) 133void MediaWidget::toggleButton( Button &button )
125{ 134{
126 button.isDown = !button.isDown; 135 button.isDown = !button.isDown;
127 136
128 paintButton( button ); 137 paintButton( button );
129} 138}
130 139
131/* vim: et sw=4 ts=4 140/* vim: et sw=4 ts=4
132 */ 141 */
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index 3bf01b6..caae0a7 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -47,65 +47,66 @@ public:
47 ButtonType type : 1; 47 ButtonType type : 1;
48 bool isHeld : 1; 48 bool isHeld : 1;
49 bool isDown : 1; 49 bool isDown : 1;
50 50
51 QBitmap mask; 51 QBitmap mask;
52 QPixmap pixUp; 52 QPixmap pixUp;
53 QPixmap pixDown; 53 QPixmap pixDown;
54 }; 54 };
55 typedef std::vector<Button> ButtonVector; 55 typedef std::vector<Button> ButtonVector;
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
70public slots: 70public 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
75signals: 75signals:
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
81protected: 81protected:
82 virtual void closeEvent( QCloseEvent * ); 82 virtual void closeEvent( QCloseEvent * );
83 83
84 virtual void paintEvent( QPaintEvent *pe ); 84 virtual void paintEvent( QPaintEvent *pe );
85 85
86 void handleCommand( Command command, bool buttonDown ); 86 void handleCommand( Command command, bool buttonDown );
87 87
88 bool isOverButton( const QPoint &position, int buttonId ) const; 88 bool isOverButton( const QPoint &position, int buttonId ) const;
89 89
90 void paintAllButtons( QPainter &p ); 90 void paintAllButtons( QPainter &p );
91 void paintButton( const Button &button ); 91 void paintButton( const Button &button );
92 void paintButton( QPainter &p, const Button &button ); 92 void paintButton( QPainter &p, const Button &button );
93 93
94 void setToggleButton( Button &button, bool down ); 94 void setToggleButton( Button &button, bool down );
95 void setToggleButton( Command command, bool down );
95 void toggleButton( Button &button ); 96 void toggleButton( Button &button );
96 97
97 MediaPlayerState &mediaPlayerState; 98 MediaPlayerState &mediaPlayerState;
98 PlayListWidget &playList; 99 PlayListWidget &playList;
99 100
100 ButtonVector buttons; 101 ButtonVector buttons;
101 102
102 QImage buttonMask; 103 QImage buttonMask;
103 104
104 QPoint upperLeftOfButtonMask; 105 QPoint upperLeftOfButtonMask;
105 106
106 QPixmap backgroundPixmap; 107 QPixmap backgroundPixmap;
107}; 108};
108 109
109#endif // MEDIAWIDGET_H 110#endif // MEDIAWIDGET_H
110/* vim: et sw=4 ts=4 111/* vim: et sw=4 ts=4
111 */ 112 */
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 4867ef1..06f6cd2 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -67,97 +67,97 @@ const MediaWidget::SkinButtonInfo skinInfo[] =
67 { MediaWidget::Previous, "back", MediaWidget::NormalButton }, 67 { MediaWidget::Previous, "back", MediaWidget::NormalButton },
68 { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, 68 { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton },
69 { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, 69 { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton },
70 { MediaWidget::FullScreen, "full", MediaWidget::ToggleButton } 70 { MediaWidget::FullScreen, "full", MediaWidget::ToggleButton }
71}; 71};
72 72
73const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); 73const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] );
74 74
75} 75}
76 76
77VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) 77VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name )
78 : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) 78 : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 )
79{ 79{
80 setCaption( tr("OpiePlayer - Video") ); 80 setCaption( tr("OpiePlayer - Video") );
81 81
82 82
83 videoFrame = new XineVideoWidget ( this, "Video frame" ); 83 videoFrame = new XineVideoWidget ( this, "Video frame" );
84 84
85 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); 85 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & )));
86 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); 86 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) );
87 87
88 Config cfg("OpiePlayer"); 88 Config cfg("OpiePlayer");
89 cfg.setGroup("Options"); 89 cfg.setGroup("Options");
90 skin = cfg.readEntry("Skin","default"); 90 skin = cfg.readEntry("Skin","default");
91 91
92 QString skinPath = "opieplayer2/skins/" + skin; 92 QString skinPath = "opieplayer2/skins/" + skin;
93 backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 93 backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
94 imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); 94 imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) );
95 imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); 95 imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) );
96 96
97 buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); 97 buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 );
98 buttonMask.fill( 0 ); 98 buttonMask.fill( 0 );
99 99
100 for ( uint i = 0; i < buttonCount; i++ ) { 100 for ( uint i = 0; i < buttonCount; i++ ) {
101 Button button; 101 Button button;
102 button.command = skinInfo[ i ].command; 102 button.command = skinInfo[ i ].command;
103 button.type = skinInfo[ i ].type; 103 button.type = skinInfo[ i ].type;
104 104
105 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinInfo[i].fileName + ".png" ); 105 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinInfo[i].fileName + ".png" );
106 button.mask =QBitmap( filename ); 106 button.mask =QBitmap( filename );
107 107
108 if ( !button.mask.isNull() ) { 108 if ( !button.mask.isNull() ) {
109 QImage imgMask = button.mask.convertToImage(); 109 QImage imgMask = button.mask.convertToImage();
110 uchar **dest = buttonMask.jumpTable(); 110 uchar **dest = buttonMask.jumpTable();
111 for ( int y = 0; y < imgUp.height(); y++ ) { 111 for ( int y = 0; y < imgUp.height(); y++ ) {
112 uchar *line = dest[y]; 112 uchar *line = dest[y];
113 for ( int x = 0; x < imgUp.width(); x++ ) 113 for ( int x = 0; x < imgUp.width(); x++ )
114 if ( !qRed( imgMask.pixel( x, y ) ) ) 114 if ( !qRed( imgMask.pixel( x, y ) ) )
115 line[x] = i + 1; 115 line[x] = button.command + 1;
116 } 116 }
117 } 117 }
118 118
119 buttons.push_back( button ); 119 buttons.push_back( button );
120 } 120 }
121 121
122 setBackgroundPixmap( backgroundPixmap ); 122 setBackgroundPixmap( backgroundPixmap );
123 123
124 slider = new QSlider( Qt::Horizontal, this ); 124 slider = new QSlider( Qt::Horizontal, this );
125 slider->setMinValue( 0 ); 125 slider->setMinValue( 0 );
126 slider->setMaxValue( 1 ); 126 slider->setMaxValue( 1 );
127 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 127 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
128 //slider->setFocusPolicy( QWidget::NoFocus ); 128 //slider->setFocusPolicy( QWidget::NoFocus );
129 129
130 resizeEvent( NULL ); 130 resizeEvent( NULL );
131 131
132 setLength( mediaPlayerState.length() ); 132 setLength( mediaPlayerState.length() );
133 setPosition( mediaPlayerState.position() ); 133 setPosition( mediaPlayerState.position() );
134 setFullscreen( mediaPlayerState.isFullscreen() ); 134 setFullscreen( mediaPlayerState.isFullscreen() );
135 setPlaying( mediaPlayerState.isPlaying() ); 135 setPlaying( mediaPlayerState.isPlaying() );
136} 136}
137 137
138 138
139VideoWidget::~VideoWidget() 139VideoWidget::~VideoWidget()
140{ 140{
141} 141}
142 142
143QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 143QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
144 QPixmap pix( img.width(), img.height() ); 144 QPixmap pix( img.width(), img.height() );
145 QPainter p( &pix ); 145 QPainter p( &pix );
146 p.drawTiledPixmap( pix.rect(), bg, offset ); 146 p.drawTiledPixmap( pix.rect(), bg, offset );
147 p.drawImage( 0, 0, img ); 147 p.drawImage( 0, 0, img );
148 return new QPixmap( pix ); 148 return new QPixmap( pix );
149} 149}
150 150
151QPixmap maskVPixToMask( QPixmap pix, QBitmap mask ) { 151QPixmap maskVPixToMask( QPixmap pix, QBitmap mask ) {
152 QPixmap pixmap( pix ); 152 QPixmap pixmap( pix );
153 pixmap.setMask( mask ); 153 pixmap.setMask( mask );
154 return pixmap; 154 return pixmap;
155} 155}
156 156
157void VideoWidget::resizeEvent( QResizeEvent * ) { 157void VideoWidget::resizeEvent( QResizeEvent * ) {
158 int h = height(); 158 int h = height();
159 int w = width(); 159 int w = width();
160 //int Vh = 160; 160 //int Vh = 160;
161 //int Vw = 220; 161 //int Vw = 220;
162 162
163 slider->setFixedWidth( w - 20 ); 163 slider->setFixedWidth( w - 20 );
@@ -202,147 +202,150 @@ void VideoWidget::sliderReleased() {
202 } 202 }
203 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); 203 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width());
204 mediaPlayerState.setPosition( val ); 204 mediaPlayerState.setPosition( val );
205} 205}
206 206
207void VideoWidget::setPosition( long i ) { 207void VideoWidget::setPosition( long i ) {
208 updateSlider( i, mediaPlayerState.length() ); 208 updateSlider( i, mediaPlayerState.length() );
209} 209}
210 210
211 211
212void VideoWidget::setLength( long max ) { 212void VideoWidget::setLength( long max ) {
213 updateSlider( mediaPlayerState.position(), max ); 213 updateSlider( mediaPlayerState.position(), max );
214} 214}
215 215
216void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) 216void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType )
217{ 217{
218 if ( displayType == MediaPlayerState::Video ) { 218 if ( displayType == MediaPlayerState::Video ) {
219 makeVisible(); 219 makeVisible();
220 return; 220 return;
221 } 221 }
222 222
223 // Effectively blank the view next time we show it so it looks nicer 223 // Effectively blank the view next time we show it so it looks nicer
224 scaledWidth = 0; 224 scaledWidth = 0;
225 scaledHeight = 0; 225 scaledHeight = 0;
226 hide(); 226 hide();
227} 227}
228 228
229void VideoWidget::updateSlider( long i, long max ) { 229void VideoWidget::updateSlider( long i, long max ) {
230 // Will flicker too much if we don't do this 230 // Will flicker too much if we don't do this
231 if ( max == 0 ) { 231 if ( max == 0 ) {
232 return; 232 return;
233 } 233 }
234 int width = slider->width(); 234 int width = slider->width();
235 int val = int((double)i * width / max); 235 int val = int((double)i * width / max);
236 if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { 236 if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) {
237 if ( slider->value() != val ) { 237 if ( slider->value() != val ) {
238 slider->setValue( val ); 238 slider->setValue( val );
239 } 239 }
240 if ( slider->maxValue() != width ) { 240 if ( slider->maxValue() != width ) {
241 slider->setMaxValue( width ); 241 slider->setMaxValue( width );
242 } 242 }
243 } 243 }
244} 244}
245 245
246void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 246void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
247 for ( unsigned int i = 0; i < buttons.size(); i++ ) { 247 for ( unsigned int i = 0; i < buttons.size(); i++ ) {
248 248
249 Button &button = buttons[ i ]; 249 Button &button = buttons[ i ];
250 Command command = button.command;
250 251
251 if ( event->state() == QMouseEvent::LeftButton ) { 252 if ( event->state() == QMouseEvent::LeftButton ) {
252 // The test to see if the mouse click is inside the button or not 253 // The test to see if the mouse click is inside the button or not
253 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); 254 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, command );
254 255
255 if ( isOnButton && !button.isHeld ) { 256 if ( isOnButton && !button.isHeld ) {
256 button.isHeld = TRUE; 257 button.isHeld = TRUE;
257 toggleButton( button ); 258 toggleButton( button );
258 259
259 switch (i) { 260 switch ( command ) {
260 case VideoVolUp: 261 case VolumeUp:
261 emit moreClicked(); 262 emit moreClicked();
262 return; 263 return;
263 case VideoVolDown: 264 case VolumeDown:
264 emit lessClicked(); 265 emit lessClicked();
265 return; 266 return;
267 default: break;
266 } 268 }
267 } else if ( !isOnButton && button.isHeld ) { 269 } else if ( !isOnButton && button.isHeld ) {
268 button.isHeld = FALSE; 270 button.isHeld = FALSE;
269 toggleButton( button ); 271 toggleButton( button );
270 } 272 }
271 } else { 273 } else {
272 274
273 if ( button.isHeld ) { 275 if ( button.isHeld ) {
274 button.isHeld = FALSE; 276 button.isHeld = FALSE;
275 if ( button.type != ToggleButton ) { 277 if ( button.type != ToggleButton ) {
276 setToggleButton( button, FALSE ); 278 setToggleButton( button, FALSE );
277 } 279 }
278 280
279 switch(i) { 281 switch( command ) {
280 282
281 case VideoPlay: { 283 case Play: {
282 if( mediaPlayerState.isPaused() ) { 284 if( mediaPlayerState.isPaused() ) {
283 setToggleButton( button, FALSE ); 285 setToggleButton( button, FALSE );
284 mediaPlayerState.setPaused( FALSE ); 286 mediaPlayerState.setPaused( FALSE );
285 return; 287 return;
286 } else if( !mediaPlayerState.isPaused() ) { 288 } else if( !mediaPlayerState.isPaused() ) {
287 setToggleButton( button, TRUE ); 289 setToggleButton( button, TRUE );
288 mediaPlayerState.setPaused( TRUE ); 290 mediaPlayerState.setPaused( TRUE );
289 return; 291 return;
290 } else { 292 } else {
291 return; 293 return;
292 } 294 }
293 } 295 }
294 296
295 case VideoStop: mediaPlayerState.setPlaying( FALSE ); return; 297 case Stop: mediaPlayerState.setPlaying( FALSE ); return;
296 case VideoNext: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; 298 case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return;
297 case VideoPrevious: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; 299 case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return;
298 case VideoVolUp: emit moreReleased(); return; 300 case VolumeUp: emit moreReleased(); return;
299 case VideoVolDown: emit lessReleased(); return; 301 case VolumeDown: emit lessReleased(); return;
300 case VideoFullscreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return; 302 case FullScreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return;
303 default: break;
301 } 304 }
302 } 305 }
303 } 306 }
304 } 307 }
305} 308}
306 309
307void VideoWidget::mousePressEvent( QMouseEvent *event ) { 310void VideoWidget::mousePressEvent( QMouseEvent *event ) {
308 mouseMoveEvent( event ); 311 mouseMoveEvent( event );
309} 312}
310 313
311void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 314void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
312 if ( mediaPlayerState.isFullscreen() ) { 315 if ( mediaPlayerState.isFullscreen() ) {
313 mediaPlayerState.setFullscreen( FALSE ); 316 mediaPlayerState.setFullscreen( FALSE );
314 makeVisible(); 317 makeVisible();
315 } 318 }
316 mouseMoveEvent( event ); 319 mouseMoveEvent( event );
317} 320}
318 321
319void VideoWidget::showEvent( QShowEvent* ) { 322void VideoWidget::showEvent( QShowEvent* ) {
320 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 323 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
321 mouseMoveEvent( &event ); 324 mouseMoveEvent( &event );
322} 325}
323 326
324 327
325 void VideoWidget::backToNormal() { 328 void VideoWidget::backToNormal() {
326 mediaPlayerState.setFullscreen( FALSE ); 329 mediaPlayerState.setFullscreen( FALSE );
327 makeVisible(); 330 makeVisible();
328 } 331 }
329 332
330void VideoWidget::makeVisible() { 333void VideoWidget::makeVisible() {
331 if ( mediaPlayerState.isFullscreen() ) { 334 if ( mediaPlayerState.isFullscreen() ) {
332 setBackgroundMode( QWidget::NoBackground ); 335 setBackgroundMode( QWidget::NoBackground );
333 showFullScreen(); 336 showFullScreen();
334 resize( qApp->desktop()->size() ); 337 resize( qApp->desktop()->size() );
335 videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); 338 videoFrame-> setGeometry ( 0, 0, width ( ), height ( ));
336 339
337 slider->hide(); 340 slider->hide();
338 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 341 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
339 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 342 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
340 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 343 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
341 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 344 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
342 345
343 } else { 346 } else {
344 showNormal(); 347 showNormal();
345 showMaximized(); 348 showMaximized();
346 setBackgroundPixmap( backgroundPixmap ); 349 setBackgroundPixmap( backgroundPixmap );
347 QWidget *d = QApplication::desktop(); 350 QWidget *d = QApplication::desktop();
348 int w = d->width(); 351 int w = d->width();
@@ -382,56 +385,56 @@ void VideoWidget::keyReleaseEvent( QKeyEvent *e) {
382 break; 385 break;
383 case Key_F10: //contacts 386 case Key_F10: //contacts
384// hide(); 387// hide();
385 break; 388 break;
386 case Key_F11: //menu 389 case Key_F11: //menu
387 break; 390 break;
388 case Key_F12: //home 391 case Key_F12: //home
389 break; 392 break;
390 case Key_F13: //mail 393 case Key_F13: //mail
391 break; 394 break;
392 case Key_Space: { 395 case Key_Space: {
393 if(mediaPlayerState.isPlaying()) { 396 if(mediaPlayerState.isPlaying()) {
394 mediaPlayerState.setPlaying(FALSE); 397 mediaPlayerState.setPlaying(FALSE);
395 } else { 398 } else {
396 mediaPlayerState.setPlaying(TRUE); 399 mediaPlayerState.setPlaying(TRUE);
397 } 400 }
398 } 401 }
399 break; 402 break;
400 case Key_Down: 403 case Key_Down:
401// toggleButton(6); 404// toggleButton(6);
402 emit lessClicked(); 405 emit lessClicked();
403 emit lessReleased(); 406 emit lessReleased();
404// toggleButton(6); 407// toggleButton(6);
405 break; 408 break;
406 case Key_Up: 409 case Key_Up:
407// toggleButton(5); 410// toggleButton(5);
408 emit moreClicked(); 411 emit moreClicked();
409 emit moreReleased(); 412 emit moreReleased();
410// toggleButton(5); 413// toggleButton(5);
411 break; 414 break;
412 case Key_Right: 415 case Key_Right:
413 mediaPlayerState.setNext(); 416 mediaPlayerState.setNext();
414 break; 417 break;
415 case Key_Left: 418 case Key_Left:
416 mediaPlayerState.setPrev(); 419 mediaPlayerState.setPrev();
417 break; 420 break;
418 case Key_Escape: 421 case Key_Escape:
419 break; 422 break;
420 423
421 }; 424 };
422} 425}
423 426
424XineVideoWidget* VideoWidget::vidWidget() { 427XineVideoWidget* VideoWidget::vidWidget() {
425 return videoFrame; 428 return videoFrame;
426} 429}
427 430
428 431
429void VideoWidget::setFullscreen ( bool b ) { 432void VideoWidget::setFullscreen ( bool b ) {
430 setToggleButton( buttons[ VideoFullscreen ], b ); 433 setToggleButton( FullScreen, b );
431} 434}
432 435
433 436
434void VideoWidget::setPlaying( bool b) { 437void VideoWidget::setPlaying( bool b) {
435 setToggleButton( buttons[ VideoPlay ], b ); 438 setToggleButton( Play, b );
436} 439}
437 440
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h
index 915e9cc..c3bc131 100644
--- a/noncore/multimedia/opieplayer2/videowidget.h
+++ b/noncore/multimedia/opieplayer2/videowidget.h
@@ -1,105 +1,94 @@
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
44class QPixmap; 44class QPixmap;
45class QSlider; 45class QSlider;
46 46
47enum VideoButtons {
48 VideoPlay = 0,
49 VideoStop,
50// VideoPause,
51 VideoNext,
52 VideoPrevious,
53 VideoVolUp,
54 VideoVolDown,
55 VideoFullscreen
56};
57
58class VideoWidget : public MediaWidget { 47class VideoWidget : public MediaWidget {
59 Q_OBJECT 48 Q_OBJECT
60public: 49public:
61 VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); 50 VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 );
62 ~VideoWidget(); 51 ~VideoWidget();
63 52
64 53
65 XineVideoWidget* vidWidget(); 54 XineVideoWidget* vidWidget();
66public slots: 55public slots:
67 void updateSlider( long, long ); 56 void updateSlider( long, long );
68 void sliderPressed( ); 57 void sliderPressed( );
69 void sliderReleased( ); 58 void sliderReleased( );
70 void setFullscreen( bool b ); 59 void setFullscreen( bool b );
71 void makeVisible(); 60 void makeVisible();
72 void backToNormal(); 61 void backToNormal();
73 void setPosition( long ); 62 void setPosition( long );
74 63
75public: 64public:
76 virtual void setPlaying( bool b); 65 virtual void setPlaying( bool b);
77 virtual void setLength( long ); 66 virtual void setLength( long );
78 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); 67 virtual void setDisplayType( MediaPlayerState::DisplayType displayType );
79 68
80signals: 69signals:
81 void moreClicked(); 70 void moreClicked();
82 void lessClicked(); 71 void lessClicked();
83 void moreReleased(); 72 void moreReleased();
84 void lessReleased(); 73 void lessReleased();
85 void sliderMoved( long ); 74 void sliderMoved( long );
86 void videoResized ( const QSize &s ); 75 void videoResized ( const QSize &s );
87 76
88protected: 77protected:
89 78
90 void resizeEvent( QResizeEvent * ); 79 void resizeEvent( QResizeEvent * );
91 void showEvent( QShowEvent *se ); 80 void showEvent( QShowEvent *se );
92 void mouseMoveEvent( QMouseEvent *event ); 81 void mouseMoveEvent( QMouseEvent *event );
93 void mousePressEvent( QMouseEvent *event ); 82 void mousePressEvent( QMouseEvent *event );
94 void mouseReleaseEvent( QMouseEvent *event ); 83 void mouseReleaseEvent( QMouseEvent *event );
95 void keyReleaseEvent( QKeyEvent *e); 84 void keyReleaseEvent( QKeyEvent *e);
96 85
97private: 86private:
98// Ticker songInfo; 87// Ticker songInfo;
99 QImage imgUp; 88 QImage imgUp;
100 QImage imgDn; 89 QImage imgDn;
101 QString skin; 90 QString skin;
102 91
103 92
104 93
105 QString backgroundPix; 94 QString backgroundPix;