summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp4
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.h2
2 files changed, 3 insertions, 3 deletions
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 41844e1..26777e6 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -30,97 +30,97 @@
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
56namespace 56namespace
57{ 57{
58 58
59const int xo = 2; // movable x offset 59const int xo = 2; // movable x offset
60const int yo = 0; // movable y offset 60const int yo = 0; // movable y offset
61 61
62const MediaWidget::SkinButtonInfo skinInfo[] = 62const MediaWidget::SkinButtonInfo skinInfo[] =
63{ 63{
64 { MediaWidget::Play, "play", MediaWidget::ToggleButton }, 64 { MediaWidget::Play, "play", MediaWidget::ToggleButton },
65 { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, 65 { MediaWidget::Stop, "stop", MediaWidget::NormalButton },
66 { MediaWidget::Next, "fwd", MediaWidget::NormalButton }, 66 { MediaWidget::Next, "fwd", MediaWidget::NormalButton },
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 ), videoSliderBeingMoved( false )
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] = button.command + 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 );
@@ -144,98 +144,96 @@ QPixmap *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 );
164 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 164 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
165 slider->setBackgroundOrigin( QWidget::ParentOrigin ); 165 slider->setBackgroundOrigin( QWidget::ParentOrigin );
166 slider->setFocusPolicy( QWidget::NoFocus ); 166 slider->setFocusPolicy( QWidget::NoFocus );
167 slider->setBackgroundPixmap( backgroundPixmap ); 167 slider->setBackgroundPixmap( backgroundPixmap );
168 168
169 upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; 169 upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2;
170 if(w>h) 170 if(w>h)
171 upperLeftOfButtonMask.ry() = 0; 171 upperLeftOfButtonMask.ry() = 0;
172 else 172 else
173 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; 173 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10;
174 QPoint p = upperLeftOfButtonMask; 174 QPoint p = upperLeftOfButtonMask;
175 175
176 QPixmap *pixUp = combineVImageWithBackground( imgUp, backgroundPixmap, p ); 176 QPixmap *pixUp = combineVImageWithBackground( imgUp, backgroundPixmap, p );
177 QPixmap *pixDn = combineVImageWithBackground( imgDn, backgroundPixmap, p ); 177 QPixmap *pixDn = combineVImageWithBackground( imgDn, backgroundPixmap, p );
178 178
179 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) { 179 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) {
180 Button &button = *it; 180 Button &button = *it;
181 181
182 if ( !button.mask.isNull() ) { 182 if ( !button.mask.isNull() ) {
183 button.pixUp = maskVPixToMask( *pixUp, button.mask ); 183 button.pixUp = maskVPixToMask( *pixUp, button.mask );
184 button.pixDown = maskVPixToMask( *pixDn, button.mask ); 184 button.pixDown = maskVPixToMask( *pixDn, button.mask );
185 } 185 }
186 } 186 }
187 187
188 delete pixUp; 188 delete pixUp;
189 delete pixDn; 189 delete pixDn;
190} 190}
191 191
192static bool videoSliderBeingMoved = FALSE;
193
194void VideoWidget::sliderPressed() { 192void VideoWidget::sliderPressed() {
195 videoSliderBeingMoved = TRUE; 193 videoSliderBeingMoved = TRUE;
196} 194}
197 195
198void VideoWidget::sliderReleased() { 196void VideoWidget::sliderReleased() {
199 videoSliderBeingMoved = FALSE; 197 videoSliderBeingMoved = FALSE;
200 if ( slider->width() == 0 ) { 198 if ( slider->width() == 0 ) {
201 return; 199 return;
202 } 200 }
203 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); 201 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width());
204 mediaPlayerState.setPosition( val ); 202 mediaPlayerState.setPosition( val );
205} 203}
206 204
207void VideoWidget::setPosition( long i ) { 205void VideoWidget::setPosition( long i ) {
208 updateSlider( i, mediaPlayerState.length() ); 206 updateSlider( i, mediaPlayerState.length() );
209} 207}
210 208
211 209
212void VideoWidget::setLength( long max ) { 210void VideoWidget::setLength( long max ) {
213 updateSlider( mediaPlayerState.position(), max ); 211 updateSlider( mediaPlayerState.position(), max );
214} 212}
215 213
216void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) 214void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType )
217{ 215{
218 if ( displayType == MediaPlayerState::Video ) { 216 if ( displayType == MediaPlayerState::Video ) {
219 makeVisible(); 217 makeVisible();
220 return; 218 return;
221 } 219 }
222 220
223 // Effectively blank the view next time we show it so it looks nicer 221 // Effectively blank the view next time we show it so it looks nicer
224 scaledWidth = 0; 222 scaledWidth = 0;
225 scaledHeight = 0; 223 scaledHeight = 0;
226 hide(); 224 hide();
227} 225}
228 226
229void VideoWidget::updateSlider( long i, long max ) { 227void VideoWidget::updateSlider( long i, long max ) {
230 // Will flicker too much if we don't do this 228 // Will flicker too much if we don't do this
231 if ( max == 0 ) { 229 if ( max == 0 ) {
232 return; 230 return;
233 } 231 }
234 int width = slider->width(); 232 int width = slider->width();
235 int val = int((double)i * width / max); 233 int val = int((double)i * width / max);
236 if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { 234 if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) {
237 if ( slider->value() != val ) { 235 if ( slider->value() != val ) {
238 slider->setValue( val ); 236 slider->setValue( val );
239 } 237 }
240 if ( slider->maxValue() != width ) { 238 if ( slider->maxValue() != width ) {
241 slider->setMaxValue( width ); 239 slider->setMaxValue( width );
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h
index 7d50ea0..bed2116 100644
--- a/noncore/multimedia/opieplayer2/videowidget.h
+++ b/noncore/multimedia/opieplayer2/videowidget.h
@@ -49,54 +49,56 @@ class VideoWidget : public MediaWidget {
49public: 49public:
50 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 );
51 ~VideoWidget(); 51 ~VideoWidget();
52 52
53 53
54 XineVideoWidget* vidWidget(); 54 XineVideoWidget* vidWidget();
55public slots: 55public slots:
56 void updateSlider( long, long ); 56 void updateSlider( long, long );
57 void sliderPressed( ); 57 void sliderPressed( );
58 void sliderReleased( ); 58 void sliderReleased( );
59 void setFullscreen( bool b ); 59 void setFullscreen( bool b );
60 virtual void makeVisible(); 60 virtual void makeVisible();
61 void backToNormal(); 61 void backToNormal();
62 void setPosition( long ); 62 void setPosition( long );
63 63
64public: 64public:
65 virtual void setPlaying( bool b); 65 virtual void setPlaying( bool b);
66 virtual void setLength( long ); 66 virtual void setLength( long );
67 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); 67 virtual void setDisplayType( MediaPlayerState::DisplayType displayType );
68 68
69signals: 69signals:
70 void moreClicked(); 70 void moreClicked();
71 void lessClicked(); 71 void lessClicked();
72 void sliderMoved( long ); 72 void sliderMoved( long );
73 void videoResized ( const QSize &s ); 73 void videoResized ( const QSize &s );
74 74
75protected: 75protected:
76 76
77 void resizeEvent( QResizeEvent * ); 77 void resizeEvent( QResizeEvent * );
78 void showEvent( QShowEvent *se ); 78 void showEvent( QShowEvent *se );
79 void mousePressEvent( QMouseEvent *event ); 79 void mousePressEvent( QMouseEvent *event );
80 void mouseReleaseEvent( QMouseEvent *event ); 80 void mouseReleaseEvent( QMouseEvent *event );
81 void keyReleaseEvent( QKeyEvent *e); 81 void keyReleaseEvent( QKeyEvent *e);
82 82
83private: 83private:
84// Ticker songInfo; 84// Ticker songInfo;
85 QImage imgUp; 85 QImage imgUp;
86 QImage imgDn; 86 QImage imgDn;
87 QString skin; 87 QString skin;
88 88
89 89
90 90
91 QString backgroundPix; 91 QString backgroundPix;
92 QSlider *slider; 92 QSlider *slider;
93 QImage *currentFrame; 93 QImage *currentFrame;
94 int scaledWidth; 94 int scaledWidth;
95 int scaledHeight; 95 int scaledHeight;
96 XineVideoWidget* videoFrame; 96 XineVideoWidget* videoFrame;
97
98 bool videoSliderBeingMoved;
97}; 99};
98 100
99#endif // VIDEO_WIDGET_H 101#endif // VIDEO_WIDGET_H
100 102
101 103
102 104