Diffstat (limited to 'noncore/multimedia/opieplayer2/videowidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 246 |
1 files changed, 164 insertions, 82 deletions
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 188b18d..419c3ae 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -23,24 +23,25 @@ | |||
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 | #include <qpe/resource.h> | 34 | #include <qpe/resource.h> |
35 | #include <qpe/mediaplayerplugininterface.h> | ||
35 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
36 | 37 | ||
37 | #include <qwidget.h> | 38 | #include <qwidget.h> |
38 | #include <qpainter.h> | 39 | #include <qpainter.h> |
39 | #include <qpixmap.h> | 40 | #include <qpixmap.h> |
40 | #include <qslider.h> | 41 | #include <qslider.h> |
41 | #include <qdrawutil.h> | 42 | #include <qdrawutil.h> |
42 | #include "videowidget.h" | 43 | #include "videowidget.h" |
43 | #include "mediaplayerstate.h" | 44 | #include "mediaplayerstate.h" |
44 | 45 | ||
45 | 46 | ||
46 | #ifdef Q_WS_QWS | 47 | #ifdef Q_WS_QWS |
@@ -49,290 +50,371 @@ | |||
49 | # include <qgfxraster_qws.h> | 50 | # include <qgfxraster_qws.h> |
50 | #endif | 51 | #endif |
51 | 52 | ||
52 | 53 | ||
53 | extern MediaPlayerState *mediaPlayerState; | 54 | extern MediaPlayerState *mediaPlayerState; |
54 | 55 | ||
55 | 56 | ||
56 | static const int xo = 2; // movable x offset | 57 | static const int xo = 2; // movable x offset |
57 | static const int yo = 0; // movable y offset | 58 | static const int yo = 0; // movable y offset |
58 | 59 | ||
59 | 60 | ||
60 | struct MediaButton { | 61 | struct MediaButton { |
61 | int xPos, yPos; | ||
62 | bool isToggle, isHeld, isDown; | 62 | bool isToggle, isHeld, isDown; |
63 | int controlType; | ||
64 | }; | 63 | }; |
65 | 64 | ||
66 | |||
67 | // Layout information for the videoButtons (and if it is a toggle button or not) | ||
68 | MediaButton videoButtons[] = { | 65 | MediaButton videoButtons[] = { |
69 | { 5+0*32+xo, 200+yo, FALSE, FALSE, FALSE, 4 }, // previous | 66 | { FALSE, FALSE, FALSE }, // previous |
70 | { 5+1*32+xo, 200+yo, FALSE, FALSE, FALSE, 1 }, // stop | 67 | { FALSE, FALSE, FALSE }, // stop |
71 | { 5+2*32+xo, 200+yo, TRUE, FALSE, FALSE, 0 }, // play | 68 | { TRUE, FALSE, FALSE }, // play |
72 | { 5+3*32+xo, 200+yo, TRUE, FALSE, FALSE, 2 }, // pause | 69 | { TRUE, FALSE, FALSE }, // pause |
73 | { 5+4*32+xo, 200+yo, FALSE, FALSE, FALSE, 3 }, // next | 70 | { FALSE, FALSE, FALSE }, // next |
74 | { 5+5*32+xo, 200+yo, FALSE, FALSE, FALSE, 8 }, // playlist | 71 | { FALSE, FALSE, FALSE }, // playlist |
75 | { 5+6*32+xo, 200+yo, TRUE, FALSE, FALSE, 9 } // fullscreen | 72 | { TRUE, FALSE, FALSE } // fullscreen |
76 | }; | 73 | }; |
77 | 74 | ||
75 | const char *skinV_mask_file_names[7] = { | ||
76 | "stop","play","back","fwd","up","down","full" | ||
77 | }; | ||
78 | 78 | ||
79 | static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); | 79 | static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); |
80 | 80 | ||
81 | 81 | ||
82 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : | 82 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : |
83 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { | 83 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { |
84 | setCaption( tr("OpiePlayer - Video") ); | 84 | setCaption( tr("OpiePlayer - Video") ); |
85 | |||
86 | videoFrame = new XineVideoWidget ( this, "Video frame" ); | ||
87 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); | ||
88 | |||
85 | Config cfg("OpiePlayer"); | 89 | Config cfg("OpiePlayer"); |
86 | cfg.setGroup("VideoWidget"); | 90 | cfg.setGroup("VideoWidget"); |
91 | skin = cfg.readEntry("Skin","default"); | ||
92 | |||
93 | QString skinPath = "opieplayer2/skins/" + skin; | ||
94 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | ||
95 | imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); | ||
96 | imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); | ||
97 | |||
98 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); | ||
99 | imgButtonMask->fill( 0 ); | ||
100 | |||
101 | for ( int i = 0; i < 7; i++ ) { | ||
102 | QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png"; | ||
103 | masks[i] = new QBitmap( filename ); | ||
104 | qDebug(filename); | ||
105 | if ( !masks[i]->isNull() ) { | ||
106 | QImage imgMask = masks[i]->convertToImage(); | ||
107 | uchar **dest = imgButtonMask->jumpTable(); | ||
108 | for ( int y = 0; y < imgUp->height(); y++ ) { | ||
109 | uchar *line = dest[y]; | ||
110 | for ( int x = 0; x < imgUp->width(); x++ ) { | ||
111 | if ( !qRed( imgMask.pixel( x, y ) ) ) | ||
112 | line[x] = i + 1; | ||
113 | } | ||
114 | } | ||
115 | } | ||
87 | 116 | ||
88 | QString Button0aPix, Button0bPix, controlsPix; | 117 | } |
89 | Button0aPix=cfg.readEntry( "Button0aPix", "opieplayer/mediaButton0a"); | ||
90 | Button0bPix=cfg.readEntry( "Button0bPix","opieplayer/mediaButton0b"); | ||
91 | controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls0" ); | ||
92 | 118 | ||
93 | cfg.setGroup("AudioWidget"); | 119 | for ( int i = 0; i < 7; i++ ) { |
94 | QString skin = cfg.readEntry("Skin","default"); | 120 | buttonPixUp[i] = NULL; |
95 | QString skinPath = "opieplayer/skins/" + skin; | 121 | buttonPixDown[i] = NULL; |
96 | backgroundPix = QString("%1/background").arg(skinPath) ; | 122 | } |
97 | 123 | ||
98 | setBackgroundPixmap( Resource::loadPixmap( backgroundPix) ); | 124 | setBackgroundPixmap( *pixBg ); |
99 | pixmaps[0] = new QPixmap( Resource::loadPixmap( Button0aPix ) ); | ||
100 | pixmaps[1] = new QPixmap( Resource::loadPixmap( Button0bPix ) ); | ||
101 | pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix) ); | ||
102 | currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); | ||
103 | 125 | ||
104 | slider = new QSlider( Qt::Horizontal, this ); | 126 | slider = new QSlider( Qt::Horizontal, this ); |
105 | slider->setMinValue( 0 ); | 127 | slider->setMinValue( 0 ); |
106 | slider->setMaxValue( 1 ); | 128 | slider->setMaxValue( 1 ); |
107 | 129 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); | |
108 | slider->setBackgroundPixmap( *this->backgroundPixmap () ); //Resource::loadPixmap( backgroundPix ) ); | ||
109 | slider->setBackgroundOrigin( QWidget::ParentOrigin); | ||
110 | slider->setFocusPolicy( QWidget::NoFocus ); | 130 | slider->setFocusPolicy( QWidget::NoFocus ); |
111 | slider->setGeometry( QRect( 7, 250, 220, 20 ) ); | 131 | slider->setGeometry( QRect( 7, 250, 220, 20 ) ); |
112 | 132 | ||
113 | videoFrame = new XineVideoWidget ( this, "Video frame" ); | ||
114 | |||
115 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); | ||
116 | |||
117 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 133 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
118 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 134 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
119 | 135 | ||
120 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 136 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
121 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 137 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
122 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 138 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
123 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 139 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
124 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 140 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
125 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 141 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
126 | 142 | ||
127 | // Intialise state | ||
128 | setLength( mediaPlayerState->length() ); | 143 | setLength( mediaPlayerState->length() ); |
129 | setPosition( mediaPlayerState->position() ); | 144 | setPosition( mediaPlayerState->position() ); |
130 | setFullscreen( mediaPlayerState->fullscreen() ); | 145 | |
146 | ////////////////////////// FIXME | ||
147 | // setFullscreen( mediaPlayerState->fullscreen() ); | ||
131 | setPaused( mediaPlayerState->paused() ); | 148 | setPaused( mediaPlayerState->paused() ); |
132 | setPlaying( mediaPlayerState->playing() ); | 149 | setPlaying( mediaPlayerState->playing() ); |
133 | 150 | qDebug("finished videowidget"); | |
134 | } | 151 | } |
135 | 152 | ||
136 | 153 | ||
137 | VideoWidget::~VideoWidget() { | 154 | VideoWidget::~VideoWidget() { |
138 | for ( int i = 0; i < 3; i++ ) { | 155 | for ( int i = 0; i < 7; i++ ) { |
139 | delete pixmaps[i]; | 156 | delete buttonPixUp[i]; |
157 | delete buttonPixDown[i]; | ||
158 | } | ||
159 | |||
160 | delete pixBg; | ||
161 | delete imgUp; | ||
162 | delete imgDn; | ||
163 | delete imgButtonMask; | ||
164 | for ( int i = 0; i < 7; i++ ) { | ||
165 | delete masks[i]; | ||
140 | } | 166 | } |
141 | delete currentFrame; | ||
142 | } | 167 | } |
143 | 168 | ||
169 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | ||
170 | QPixmap pix( img.width(), img.height() ); | ||
171 | QPainter p( &pix ); | ||
172 | p.drawTiledPixmap( pix.rect(), bg, offset ); | ||
173 | p.drawImage( 0, 0, img ); | ||
174 | return new QPixmap( pix ); | ||
175 | } | ||
144 | 176 | ||
145 | static bool videoSliderBeingMoved = FALSE; | 177 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { |
178 | QPixmap *pixmap = new QPixmap( pix ); | ||
179 | pixmap->setMask( mask ); | ||
180 | return pixmap; | ||
181 | } | ||
182 | |||
183 | void VideoWidget::resizeEvent( QResizeEvent * ) { | ||
184 | int h = height(); | ||
185 | int w = width(); | ||
186 | int Vh = 160; | ||
187 | //videoFrame->height(); | ||
188 | int Vw = 220; | ||
189 | //videoFrame->width(); | ||
190 | // songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); | ||
191 | |||
192 | slider->setFixedWidth( w - 110 ); | ||
193 | slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); | ||
194 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); | ||
195 | // time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); | ||
196 | xoff = 0;// ( imgUp->width() ) / 2; | ||
197 | yoff = 180;//(( Vh - imgUp->height() ) / 2) - 10; | ||
198 | QPoint p( xoff, yoff ); | ||
199 | |||
200 | QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); | ||
201 | QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); | ||
202 | |||
203 | for ( int i = 0; i < 7; i++ ) { | ||
204 | if ( !masks[i]->isNull() ) { | ||
205 | delete buttonPixUp[i]; | ||
206 | delete buttonPixDown[i]; | ||
207 | buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); | ||
208 | buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); | ||
209 | } | ||
210 | } | ||
146 | 211 | ||
212 | delete pixUp; | ||
213 | delete pixDn; | ||
214 | } | ||
215 | |||
216 | static bool videoSliderBeingMoved = FALSE; | ||
147 | 217 | ||
148 | void VideoWidget::sliderPressed() { | 218 | void VideoWidget::sliderPressed() { |
149 | videoSliderBeingMoved = TRUE; | 219 | videoSliderBeingMoved = TRUE; |
150 | } | 220 | } |
151 | 221 | ||
152 | |||
153 | void VideoWidget::sliderReleased() { | 222 | void VideoWidget::sliderReleased() { |
154 | videoSliderBeingMoved = FALSE; | 223 | videoSliderBeingMoved = FALSE; |
155 | if ( slider->width() == 0 ) { | 224 | if ( slider->width() == 0 ) { |
156 | return; | 225 | return; |
157 | } | 226 | } |
158 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); | 227 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); |
159 | mediaPlayerState->setPosition( val ); | 228 | mediaPlayerState->setPosition( val ); |
160 | } | 229 | } |
161 | 230 | ||
162 | |||
163 | void VideoWidget::setPosition( long i ) { | 231 | void VideoWidget::setPosition( long i ) { |
164 | updateSlider( i, mediaPlayerState->length() ); | 232 | updateSlider( i, mediaPlayerState->length() ); |
165 | } | 233 | } |
166 | 234 | ||
167 | 235 | ||
168 | void VideoWidget::setLength( long max ) { | 236 | void VideoWidget::setLength( long max ) { |
169 | updateSlider( mediaPlayerState->position(), max ); | 237 | updateSlider( mediaPlayerState->position(), max ); |
170 | } | 238 | } |
171 | 239 | ||
172 | |||
173 | void VideoWidget::setView( char view ) { | 240 | void VideoWidget::setView( char view ) { |
174 | if ( view == 'v' ) { | 241 | if ( view == 'v' ) { |
175 | makeVisible(); | 242 | makeVisible(); |
176 | } else { | 243 | } else { |
177 | // Effectively blank the view next time we show it so it looks nicer | 244 | // Effectively blank the view next time we show it so it looks nicer |
178 | scaledWidth = 0; | 245 | scaledWidth = 0; |
179 | scaledHeight = 0; | 246 | scaledHeight = 0; |
180 | hide(); | 247 | hide(); |
181 | } | 248 | } |
182 | } | 249 | } |
183 | 250 | ||
184 | |||
185 | void VideoWidget::updateSlider( long i, long max ) { | 251 | void VideoWidget::updateSlider( long i, long max ) { |
186 | // Will flicker too much if we don't do this | 252 | // Will flicker too much if we don't do this |
187 | if ( max == 0 ) { | 253 | if ( max == 0 ) { |
188 | return; | 254 | return; |
189 | } | 255 | } |
190 | int width = slider->width(); | 256 | int width = slider->width(); |
191 | int val = int((double)i * width / max); | 257 | int val = int((double)i * width / max); |
192 | if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { | 258 | if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { |
193 | if ( slider->value() != val ) { | 259 | if ( slider->value() != val ) { |
194 | slider->setValue( val ); | 260 | slider->setValue( val ); |
195 | } | 261 | } |
196 | if ( slider->maxValue() != width ) { | 262 | if ( slider->maxValue() != width ) { |
197 | slider->setMaxValue( width ); | 263 | slider->setMaxValue( width ); |
198 | } | 264 | } |
199 | } | 265 | } |
200 | } | 266 | } |
201 | 267 | ||
202 | |||
203 | void VideoWidget::setToggleButton( int i, bool down ) { | 268 | void VideoWidget::setToggleButton( int i, bool down ) { |
204 | if ( down != videoButtons[i].isDown ) { | 269 | if ( down != videoButtons[i].isDown ) { |
205 | toggleButton( i ); | 270 | toggleButton( i ); |
206 | } | 271 | } |
207 | } | 272 | } |
208 | 273 | ||
209 | |||
210 | void VideoWidget::toggleButton( int i ) { | 274 | void VideoWidget::toggleButton( int i ) { |
211 | videoButtons[i].isDown = !videoButtons[i].isDown; | 275 | videoButtons[i].isDown = !videoButtons[i].isDown; |
212 | QPainter p(this); | 276 | QPainter p(this); |
213 | paintButton ( &p, i ); | 277 | paintButton ( &p, i ); |
214 | } | 278 | } |
215 | 279 | ||
216 | |||
217 | void VideoWidget::paintButton( QPainter *p, int i ) { | 280 | void VideoWidget::paintButton( QPainter *p, int i ) { |
218 | int x = videoButtons[i].xPos; | ||
219 | int y = videoButtons[i].yPos; | ||
220 | int offset = 10 + videoButtons[i].isDown; | ||
221 | p->drawPixmap( x, y, *pixmaps[videoButtons[i].isDown] ); | ||
222 | p->drawPixmap( x + 1 + offset, y + offset, *pixmaps[2], 9 * videoButtons[i].controlType, 0, 9, 9 ); | ||
223 | } | ||
224 | 281 | ||
282 | if ( videoButtons[i].isDown ) | ||
283 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | ||
284 | else | ||
285 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | ||
286 | } | ||
225 | 287 | ||
226 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 288 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
227 | for ( int i = 0; i < numButtons; i++ ) { | 289 | for ( int i = 0; i < numButtons; i++ ) { |
228 | int x = videoButtons[i].xPos; | ||
229 | int y = videoButtons[i].yPos; | ||
230 | if ( event->state() == QMouseEvent::LeftButton ) { | 290 | if ( event->state() == QMouseEvent::LeftButton ) { |
231 | // The test to see if the mouse click is inside the circular button or not | 291 | // The test to see if the mouse click is inside the button or not |
232 | // (compared with the radius squared to avoid a square-root of our distance) | 292 | int x = event->pos().x() - xoff; |
233 | int radius = 16; | 293 | int y = event->pos().y() - yoff; |
234 | QPoint center = QPoint( x + radius, y + radius ); | 294 | |
235 | QPoint dXY = center - event->pos(); | 295 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() |
236 | int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); | 296 | && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); |
237 | bool isOnButton = dist <= (radius * radius); | ||
238 | if ( isOnButton != videoButtons[i].isHeld ) { | 297 | if ( isOnButton != videoButtons[i].isHeld ) { |
239 | videoButtons[i].isHeld = isOnButton; | 298 | videoButtons[i].isHeld = isOnButton; |
240 | toggleButton(i); | 299 | toggleButton(i); |
241 | } | 300 | } |
242 | } else { | 301 | } else { |
243 | if ( videoButtons[i].isHeld ) { | 302 | if ( videoButtons[i].isHeld ) { |
244 | videoButtons[i].isHeld = FALSE; | 303 | videoButtons[i].isHeld = FALSE; |
245 | if ( !videoButtons[i].isToggle ) | 304 | if ( !videoButtons[i].isToggle ) |
246 | setToggleButton( i, FALSE ); | 305 | setToggleButton( i, FALSE ); |
247 | qDebug("button toggled3 %d",i); | ||
248 | } | 306 | } |
249 | |||
250 | } | 307 | } |
251 | switch (i) { | 308 | switch (i) { |
252 | case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; | 309 | case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; |
253 | case VideoStop: mediaPlayerState->setPlaying(FALSE); return; | 310 | case VideoStop: mediaPlayerState->setPlaying(FALSE); return; |
254 | case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; | 311 | case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; |
255 | case VideoNext: mediaPlayerState->setNext(); return; | 312 | case VideoNext: mediaPlayerState->setNext(); return; |
256 | case VideoPrevious: mediaPlayerState->setPrev(); return; | 313 | case VideoPrevious: mediaPlayerState->setPrev(); return; |
257 | case VideoPlayList: mediaPlayerState->setList(); return; | 314 | case VideoPlayList: mediaPlayerState->setList(); return; |
258 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | 315 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; |
259 | } | 316 | } |
260 | 317 | ||
261 | } | 318 | } |
262 | } | 319 | } |
263 | 320 | ||
264 | |||
265 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { | 321 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { |
266 | mouseMoveEvent( event ); | 322 | mouseMoveEvent( event ); |
267 | } | 323 | } |
268 | 324 | ||
269 | |||
270 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 325 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
271 | if ( mediaPlayerState->fullscreen() ) { | 326 | if ( mediaPlayerState->fullscreen() ) { |
272 | mediaPlayerState->setFullscreen( FALSE ); | 327 | mediaPlayerState->setFullscreen( FALSE ); |
273 | makeVisible(); | 328 | makeVisible(); |
274 | 329 | ||
275 | mouseMoveEvent( event ); | 330 | mouseMoveEvent( event ); |
276 | } | 331 | } |
277 | } | 332 | } |
278 | 333 | ||
279 | 334 | ||
280 | void VideoWidget::makeVisible() { | 335 | void VideoWidget::makeVisible() { |
281 | if ( mediaPlayerState->fullscreen() ) { | 336 | if ( mediaPlayerState->fullscreen() ) { |
282 | setBackgroundMode( QWidget::NoBackground ); | 337 | setBackgroundMode( QWidget::NoBackground ); |
283 | showFullScreen(); | 338 | showFullScreen(); |
284 | resize( qApp->desktop()->size() ); | 339 | resize( qApp->desktop()->size() ); |
285 | slider->hide(); | 340 | slider->hide(); |
286 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); | 341 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); |
287 | } else { | 342 | } else { |
288 | setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); | 343 | setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); |
289 | showNormal(); | 344 | showNormal(); |
290 | showMaximized(); | 345 | showMaximized(); |
291 | slider->show(); | 346 | slider->show(); |
292 | videoFrame->setGeometry( QRect( 10, 20, 220, 160 ) ); | 347 | videoFrame->setGeometry( QRect( 10, 20, 220, 160 ) ); |
293 | } | 348 | } |
294 | } | 349 | } |
295 | 350 | ||
296 | 351 | ||
297 | void VideoWidget::paintEvent( QPaintEvent * ) { | 352 | void VideoWidget::paintEvent( QPaintEvent * pe) { |
298 | QPainter p( this ); | 353 | QPainter p( this ); |
299 | 354 | ||
300 | if ( mediaPlayerState->fullscreen() ) { | 355 | if ( mediaPlayerState->fullscreen() ) { |
301 | // Clear the background | 356 | // Clear the background |
302 | p.setBrush( QBrush( Qt::black ) ); | 357 | p.setBrush( QBrush( Qt::black ) ); |
303 | // videoFrame->setGeometry( QRect( 0, 0 , 240 ,320 ) ); | 358 | // videoFrame->setGeometry( QRect( 0, 0 , 240 ,320 ) ); |
304 | 359 | ||
305 | } else { | 360 | } else { |
306 | 361 | ||
307 | // videoFrame->setGeometry( QRect( 0, 15 , 240 ,170 ) ); | 362 | // videoFrame->setGeometry( QRect( 0, 15 , 240 ,170 ) ); |
308 | // draw the buttons | 363 | // draw the buttons |
309 | 364 | ||
310 | for ( int i = 0; i < numButtons; i++ ) { | 365 | if ( !pe->erased() ) { |
311 | paintButton( &p, i ); | 366 | // Combine with background and double buffer |
367 | QPixmap pix( pe->rect().size() ); | ||
368 | QPainter p( &pix ); | ||
369 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | ||
370 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); | ||
371 | for ( int i = 0; i < numButtons; i++ ) | ||
372 | paintButton( &p, i ); | ||
373 | QPainter p2( this ); | ||
374 | p2.drawPixmap( pe->rect().topLeft(), pix ); | ||
375 | } else { | ||
376 | QPainter p( this ); | ||
377 | for ( int i = 0; i < numButtons; i++ ) | ||
378 | paintButton( &p, i ); | ||
312 | } | 379 | } |
313 | // draw the slider | 380 | // for ( int i = 0; i < numButtons; i++ ) { |
314 | slider->repaint( TRUE ); | 381 | // paintButton( &p, i ); |
315 | } | 382 | // } |
383 | // // draw the slider | ||
384 | // slider->repaint( TRUE ); | ||
385 | } | ||
316 | } | 386 | } |
317 | 387 | ||
318 | 388 | ||
319 | void VideoWidget::closeEvent( QCloseEvent* ) { | 389 | void VideoWidget::closeEvent( QCloseEvent* ) { |
320 | mediaPlayerState->setList(); | 390 | mediaPlayerState->setList(); |
321 | } | 391 | } |
322 | 392 | ||
323 | 393 | ||
394 | bool VideoWidget::playVideo() { | ||
395 | bool result = FALSE; | ||
396 | |||
397 | int stream = 0; | ||
398 | |||
399 | int sw = 240; | ||
400 | int sh = 320; | ||
401 | int dd = QPixmap::defaultDepth(); | ||
402 | int w = height(); | ||
403 | int h = width(); | ||
324 | 404 | ||
325 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) | 405 | return true; |
326 | { | 406 | } |
407 | |||
408 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { | ||
327 | switch ( e->key() ) { | 409 | switch ( e->key() ) { |
328 | ////////////////////////////// Zaurus keys | 410 | ////////////////////////////// Zaurus keys |
329 | case Key_Home: | 411 | case Key_Home: |
330 | break; | 412 | break; |
331 | case Key_F9: //activity | 413 | case Key_F9: //activity |
332 | break; | 414 | break; |
333 | case Key_F10: //contacts | 415 | case Key_F10: //contacts |
334 | // hide(); | 416 | // hide(); |
335 | break; | 417 | break; |
336 | case Key_F11: //menu | 418 | case Key_F11: //menu |
337 | break; | 419 | break; |
338 | case Key_F12: //home | 420 | case Key_F12: //home |
@@ -361,21 +443,21 @@ void VideoWidget::keyReleaseEvent( QKeyEvent *e) | |||
361 | break; | 443 | break; |
362 | case Key_Right: | 444 | case Key_Right: |
363 | mediaPlayerState->setNext(); | 445 | mediaPlayerState->setNext(); |
364 | break; | 446 | break; |
365 | case Key_Left: | 447 | case Key_Left: |
366 | mediaPlayerState->setPrev(); | 448 | mediaPlayerState->setPrev(); |
367 | break; | 449 | break; |
368 | case Key_Escape: | 450 | case Key_Escape: |
369 | break; | 451 | break; |
370 | 452 | ||
371 | }; | 453 | }; |
372 | } | 454 | } |
455 | |||
373 | XineVideoWidget* VideoWidget::vidWidget() { | 456 | XineVideoWidget* VideoWidget::vidWidget() { |
374 | return videoFrame; | 457 | return videoFrame; |
375 | } | 458 | } |
376 | 459 | ||
377 | 460 | ||
378 | void VideoWidget::setFullscreen ( bool b ) | 461 | void VideoWidget::setFullscreen ( bool b ) { |
379 | { | 462 | setToggleButton( VideoFullscreen, b ); |
380 | setToggleButton( VideoFullscreen, b ); | ||
381 | } | 463 | } |