summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp9
1 files changed, 0 insertions, 9 deletions
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 5b53568..53837c7 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -1,506 +1,497 @@
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#include <qpe/qpeapplication.h> 34#include <qpe/qpeapplication.h>
35#include <qpe/resource.h> 35#include <qpe/resource.h>
36#include <qpe/mediaplayerplugininterface.h> 36#include <qpe/mediaplayerplugininterface.h>
37#include <qpe/config.h> 37#include <qpe/config.h>
38 38
39 39
40#include <qwidget.h> 40#include <qwidget.h>
41#include <qpainter.h> 41#include <qpainter.h>
42#include <qpixmap.h> 42#include <qpixmap.h>
43#include <qslider.h> 43#include <qslider.h>
44#include <qdrawutil.h> 44#include <qdrawutil.h>
45#include "videowidget.h" 45#include "videowidget.h"
46#include "mediaplayerstate.h" 46#include "mediaplayerstate.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
56extern MediaPlayerState *mediaPlayerState; 56extern MediaPlayerState *mediaPlayerState;
57 57
58 58
59static const int xo = 2; // movable x offset 59static const int xo = 2; // movable x offset
60static const int yo = 0; // movable y offset 60static const int yo = 0; // movable y offset
61 61
62 62
63struct MediaButton { 63struct MediaButton {
64 bool isToggle, isHeld, isDown; 64 bool isToggle, isHeld, isDown;
65}; 65};
66 66
67MediaButton videoButtons[] = { 67MediaButton videoButtons[] = {
68 { FALSE, FALSE, FALSE }, // stop 68 { FALSE, FALSE, FALSE }, // stop
69 { TRUE, FALSE, FALSE }, // play 69 { TRUE, FALSE, FALSE }, // play
70 { FALSE, FALSE, FALSE }, // previous 70 { FALSE, FALSE, FALSE }, // previous
71 { FALSE, FALSE, FALSE }, // next 71 { FALSE, FALSE, FALSE }, // next
72 { FALSE, FALSE, FALSE }, // volUp 72 { FALSE, FALSE, FALSE }, // volUp
73 { FALSE, FALSE, FALSE }, // volDown 73 { FALSE, FALSE, FALSE }, // volDown
74 { TRUE, FALSE, FALSE } // fullscreen 74 { TRUE, FALSE, FALSE } // fullscreen
75}; 75};
76 76
77const char *skinV_mask_file_names[7] = { 77const char *skinV_mask_file_names[7] = {
78"stop","play","back","fwd","up","down","full" 78"stop","play","back","fwd","up","down","full"
79}; 79};
80 80
81static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); 81static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton));
82 82
83 83
84VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : 84VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) :
85QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { 85QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) {
86 86
87 87
88 setCaption( tr("OpiePlayer - Video") ); 88 setCaption( tr("OpiePlayer - Video") );
89 89
90 videoFrame = new XineVideoWidget ( this, "Video frame" ); 90 videoFrame = new XineVideoWidget ( this, "Video frame" );
91 91
92 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); 92 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & )));
93 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); 93 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) );
94 94
95 Config cfg("OpiePlayer"); 95 Config cfg("OpiePlayer");
96 cfg.setGroup("Options"); 96 cfg.setGroup("Options");
97 skin = cfg.readEntry("Skin","default"); 97 skin = cfg.readEntry("Skin","default");
98 98
99 QString skinPath = "opieplayer2/skins/" + skin; 99 QString skinPath = "opieplayer2/skins/" + skin;
100 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 100 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
101 imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); 101 imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) );
102 imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); 102 imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) );
103 103
104 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); 104 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
105 imgButtonMask->fill( 0 ); 105 imgButtonMask->fill( 0 );
106 106
107 for ( int i = 0; i < 7; i++ ) { 107 for ( int i = 0; i < 7; i++ ) {
108 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); 108 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" );
109 masks[i] = new QBitmap( filename ); 109 masks[i] = new QBitmap( filename );
110 110
111 if ( !masks[i]->isNull() ) { 111 if ( !masks[i]->isNull() ) {
112 QImage imgMask = masks[i]->convertToImage(); 112 QImage imgMask = masks[i]->convertToImage();
113 uchar **dest = imgButtonMask->jumpTable(); 113 uchar **dest = imgButtonMask->jumpTable();
114 for ( int y = 0; y < imgUp->height(); y++ ) { 114 for ( int y = 0; y < imgUp->height(); y++ ) {
115 uchar *line = dest[y]; 115 uchar *line = dest[y];
116 for ( int x = 0; x < imgUp->width(); x++ ) { 116 for ( int x = 0; x < imgUp->width(); x++ ) {
117 if ( !qRed( imgMask.pixel( x, y ) ) ) 117 if ( !qRed( imgMask.pixel( x, y ) ) )
118 line[x] = i + 1; 118 line[x] = i + 1;
119 } 119 }
120 } 120 }
121 } 121 }
122 } 122 }
123 123
124 for ( int i = 0; i < 7; i++ ) { 124 for ( int i = 0; i < 7; i++ ) {
125 buttonPixUp[i] = NULL; 125 buttonPixUp[i] = NULL;
126 buttonPixDown[i] = NULL; 126 buttonPixDown[i] = NULL;
127 } 127 }
128 128
129 setBackgroundPixmap( *pixBg ); 129 setBackgroundPixmap( *pixBg );
130 130
131 slider = new QSlider( Qt::Horizontal, this ); 131 slider = new QSlider( Qt::Horizontal, this );
132 slider->setMinValue( 0 ); 132 slider->setMinValue( 0 );
133 slider->setMaxValue( 1 ); 133 slider->setMaxValue( 1 );
134 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 134 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
135 slider->setFocusPolicy( QWidget::NoFocus ); 135 slider->setFocusPolicy( QWidget::NoFocus );
136 136
137 resizeEvent( NULL ); 137 resizeEvent( NULL );
138 138
139 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 139 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
140 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 140 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
141 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 141 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
142 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 142 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
143 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 143 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
144 144
145 setLength( mediaPlayerState->length() ); 145 setLength( mediaPlayerState->length() );
146 setPosition( mediaPlayerState->position() ); 146 setPosition( mediaPlayerState->position() );
147 setFullscreen( mediaPlayerState->fullscreen() ); 147 setFullscreen( mediaPlayerState->fullscreen() );
148 setPlaying( mediaPlayerState->playing() ); 148 setPlaying( mediaPlayerState->playing() );
149} 149}
150 150
151 151
152VideoWidget::~VideoWidget() { 152VideoWidget::~VideoWidget() {
153 153
154 for ( int i = 0; i < 7; i++ ) { 154 for ( int i = 0; i < 7; i++ ) {
155 delete buttonPixUp[i]; 155 delete buttonPixUp[i];
156 delete buttonPixDown[i]; 156 delete buttonPixDown[i];
157 } 157 }
158 158
159 delete pixBg; 159 delete pixBg;
160 delete imgUp; 160 delete imgUp;
161 delete imgDn; 161 delete imgDn;
162 delete imgButtonMask; 162 delete imgButtonMask;
163 for ( int i = 0; i < 7; i++ ) { 163 for ( int i = 0; i < 7; i++ ) {
164 delete masks[i]; 164 delete masks[i];
165 } 165 }
166 166
167} 167}
168 168
169QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 169QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
170 QPixmap pix( img.width(), img.height() ); 170 QPixmap pix( img.width(), img.height() );
171 QPainter p( &pix ); 171 QPainter p( &pix );
172 p.drawTiledPixmap( pix.rect(), bg, offset ); 172 p.drawTiledPixmap( pix.rect(), bg, offset );
173 p.drawImage( 0, 0, img ); 173 p.drawImage( 0, 0, img );
174 return new QPixmap( pix ); 174 return new QPixmap( pix );
175} 175}
176 176
177QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { 177QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) {
178 QPixmap *pixmap = new QPixmap( pix ); 178 QPixmap *pixmap = new QPixmap( pix );
179 pixmap->setMask( mask ); 179 pixmap->setMask( mask );
180 return pixmap; 180 return pixmap;
181} 181}
182 182
183void VideoWidget::resizeEvent( QResizeEvent * ) { 183void VideoWidget::resizeEvent( QResizeEvent * ) {
184 int h = height(); 184 int h = height();
185 int w = width(); 185 int w = width();
186 //int Vh = 160; 186 //int Vh = 160;
187 //int Vw = 220; 187 //int Vw = 220;
188 188
189 slider->setFixedWidth( w - 20 ); 189 slider->setFixedWidth( w - 20 );
190 slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); 190 slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) );
191 slider->setBackgroundOrigin( QWidget::ParentOrigin ); 191 slider->setBackgroundOrigin( QWidget::ParentOrigin );
192 slider->setFocusPolicy( QWidget::NoFocus ); 192 slider->setFocusPolicy( QWidget::NoFocus );
193 slider->setBackgroundPixmap( *pixBg ); 193 slider->setBackgroundPixmap( *pixBg );
194 194
195 xoff = 0;// ( imgUp->width() ) / 2; 195 xoff = 0;// ( imgUp->width() ) / 2;
196 yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; 196 yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10;
197 QPoint p( xoff, yoff ); 197 QPoint p( xoff, yoff );
198 198
199 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); 199 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p );
200 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); 200 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p );
201 201
202 for ( int i = 0; i < 7; i++ ) { 202 for ( int i = 0; i < 7; i++ ) {
203 if ( !masks[i]->isNull() ) { 203 if ( !masks[i]->isNull() ) {
204 delete buttonPixUp[i]; 204 delete buttonPixUp[i];
205 delete buttonPixDown[i]; 205 delete buttonPixDown[i];
206 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); 206 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] );
207 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); 207 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] );
208 } 208 }
209 } 209 }
210 210
211 delete pixUp; 211 delete pixUp;
212 delete pixDn; 212 delete pixDn;
213} 213}
214 214
215static bool videoSliderBeingMoved = FALSE; 215static bool videoSliderBeingMoved = FALSE;
216 216
217void VideoWidget::sliderPressed() { 217void VideoWidget::sliderPressed() {
218 videoSliderBeingMoved = TRUE; 218 videoSliderBeingMoved = TRUE;
219} 219}
220 220
221void VideoWidget::sliderReleased() { 221void VideoWidget::sliderReleased() {
222 videoSliderBeingMoved = FALSE; 222 videoSliderBeingMoved = FALSE;
223 if ( slider->width() == 0 ) { 223 if ( slider->width() == 0 ) {
224 return; 224 return;
225 } 225 }
226 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); 226 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width());
227 mediaPlayerState->setPosition( val ); 227 mediaPlayerState->setPosition( val );
228} 228}
229 229
230void VideoWidget::setPosition( long i ) { 230void VideoWidget::setPosition( long i ) {
231 updateSlider( i, mediaPlayerState->length() ); 231 updateSlider( i, mediaPlayerState->length() );
232} 232}
233 233
234 234
235void VideoWidget::setLength( long max ) { 235void VideoWidget::setLength( long max ) {
236 updateSlider( mediaPlayerState->position(), max ); 236 updateSlider( mediaPlayerState->position(), max );
237} 237}
238 238
239void VideoWidget::setView( char view ) { 239void VideoWidget::setView( char view ) {
240 240
241 if ( view == 'v' ) { 241 if ( view == 'v' ) {
242 makeVisible(); 242 makeVisible();
243 } else { 243 } else {
244 // 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
245 scaledWidth = 0; 245 scaledWidth = 0;
246 scaledHeight = 0; 246 scaledHeight = 0;
247 hide(); 247 hide();
248 } 248 }
249} 249}
250 250
251void VideoWidget::updateSlider( long i, long max ) { 251void VideoWidget::updateSlider( long i, long max ) {
252 // Will flicker too much if we don't do this 252 // Will flicker too much if we don't do this
253 if ( max == 0 ) { 253 if ( max == 0 ) {
254 return; 254 return;
255 } 255 }
256 int width = slider->width(); 256 int width = slider->width();
257 int val = int((double)i * width / max); 257 int val = int((double)i * width / max);
258 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { 258 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) {
259 if ( slider->value() != val ) { 259 if ( slider->value() != val ) {
260 slider->setValue( val ); 260 slider->setValue( val );
261 } 261 }
262 if ( slider->maxValue() != width ) { 262 if ( slider->maxValue() != width ) {
263 slider->setMaxValue( width ); 263 slider->setMaxValue( width );
264 } 264 }
265 } 265 }
266} 266}
267 267
268void VideoWidget::setToggleButton( int i, bool down ) { 268void VideoWidget::setToggleButton( int i, bool down ) {
269 if ( down != videoButtons[i].isDown ) { 269 if ( down != videoButtons[i].isDown ) {
270 toggleButton( i ); 270 toggleButton( i );
271 } 271 }
272} 272}
273 273
274void VideoWidget::toggleButton( int i ) { 274void VideoWidget::toggleButton( int i ) {
275 videoButtons[i].isDown = !videoButtons[i].isDown; 275 videoButtons[i].isDown = !videoButtons[i].isDown;
276 QPainter p(this); 276 QPainter p(this);
277 paintButton ( &p, i ); 277 paintButton ( &p, i );
278} 278}
279 279
280void VideoWidget::paintButton( QPainter *p, int i ) { 280void VideoWidget::paintButton( QPainter *p, int i ) {
281 281
282 if ( videoButtons[i].isDown ) { 282 if ( videoButtons[i].isDown ) {
283 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 283 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
284 } else { 284 } else {
285 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 285 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
286 } 286 }
287} 287}
288 288
289void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 289void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
290 for ( int i = 0; i < numVButtons; i++ ) { 290 for ( int i = 0; i < numVButtons; i++ ) {
291 if ( event->state() == QMouseEvent::LeftButton ) { 291 if ( event->state() == QMouseEvent::LeftButton ) {
292 // The test to see if the mouse click is inside the button or not 292 // The test to see if the mouse click is inside the button or not
293 int x = event->pos().x() - xoff; 293 int x = event->pos().x() - xoff;
294 int y = event->pos().y() - yoff; 294 int y = event->pos().y() - yoff;
295 295
296 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() 296 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
297 && y < imgButtonMask->height() 297 && y < imgButtonMask->height()
298 && imgButtonMask->pixelIndex( x, y ) == i + 1 ); 298 && imgButtonMask->pixelIndex( x, y ) == i + 1 );
299 299
300 if ( isOnButton && !videoButtons[i].isHeld ) { 300 if ( isOnButton && !videoButtons[i].isHeld ) {
301 videoButtons[i].isHeld = TRUE; 301 videoButtons[i].isHeld = TRUE;
302 toggleButton(i); 302 toggleButton(i);
303 303
304 switch (i) { 304 switch (i) {
305 case VideoVolUp: 305 case VideoVolUp:
306 emit moreClicked(); 306 emit moreClicked();
307 return; 307 return;
308 case VideoVolDown: 308 case VideoVolDown:
309 emit lessClicked(); 309 emit lessClicked();
310 return; 310 return;
311 } 311 }
312 } else if ( !isOnButton && videoButtons[i].isHeld ) { 312 } else if ( !isOnButton && videoButtons[i].isHeld ) {
313 videoButtons[i].isHeld = FALSE; 313 videoButtons[i].isHeld = FALSE;
314 toggleButton(i); 314 toggleButton(i);
315 } 315 }
316 } else { 316 } else {
317 317
318 if ( videoButtons[i].isHeld ) { 318 if ( videoButtons[i].isHeld ) {
319 videoButtons[i].isHeld = FALSE; 319 videoButtons[i].isHeld = FALSE;
320 if ( !videoButtons[i].isToggle ) { 320 if ( !videoButtons[i].isToggle ) {
321 setToggleButton( i, FALSE ); 321 setToggleButton( i, FALSE );
322 } 322 }
323 323
324 switch(i) { 324 switch(i) {
325 325
326 case VideoPlay: { 326 case VideoPlay: {
327 if( mediaPlayerState->isPaused ) { 327 if( mediaPlayerState->isPaused ) {
328 setToggleButton( i, FALSE ); 328 setToggleButton( i, FALSE );
329 mediaPlayerState->setPaused( FALSE ); 329 mediaPlayerState->setPaused( FALSE );
330 return; 330 return;
331 } else if( !mediaPlayerState->isPaused ) { 331 } else if( !mediaPlayerState->isPaused ) {
332 setToggleButton( i, TRUE ); 332 setToggleButton( i, TRUE );
333 mediaPlayerState->setPaused( TRUE ); 333 mediaPlayerState->setPaused( TRUE );
334 return; 334 return;
335 } else { 335 } else {
336 return; 336 return;
337 } 337 }
338 } 338 }
339 339
340 case VideoStop: mediaPlayerState->setPlaying( FALSE ); return; 340 case VideoStop: mediaPlayerState->setPlaying( FALSE ); return;
341 case VideoNext: mediaPlayerState->setNext(); return; 341 case VideoNext: mediaPlayerState->setNext(); return;
342 case VideoPrevious: mediaPlayerState->setPrev(); return; 342 case VideoPrevious: mediaPlayerState->setPrev(); return;
343 case VideoVolUp: emit moreReleased(); return; 343 case VideoVolUp: emit moreReleased(); return;
344 case VideoVolDown: emit lessReleased(); return; 344 case VideoVolDown: emit lessReleased(); return;
345 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; 345 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
346 } 346 }
347 } 347 }
348 } 348 }
349 } 349 }
350} 350}
351 351
352void VideoWidget::mousePressEvent( QMouseEvent *event ) { 352void VideoWidget::mousePressEvent( QMouseEvent *event ) {
353 mouseMoveEvent( event ); 353 mouseMoveEvent( event );
354} 354}
355 355
356void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 356void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
357 if ( mediaPlayerState->fullscreen() ) { 357 if ( mediaPlayerState->fullscreen() ) {
358 mediaPlayerState->setFullscreen( FALSE ); 358 mediaPlayerState->setFullscreen( FALSE );
359 makeVisible(); 359 makeVisible();
360 } 360 }
361 mouseMoveEvent( event ); 361 mouseMoveEvent( event );
362} 362}
363 363
364void VideoWidget::showEvent( QShowEvent* ) { 364void VideoWidget::showEvent( QShowEvent* ) {
365 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 365 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
366 mouseMoveEvent( &event ); 366 mouseMoveEvent( &event );
367} 367}
368 368
369 369
370 void VideoWidget::backToNormal() { 370 void VideoWidget::backToNormal() {
371 mediaPlayerState->setFullscreen( FALSE ); 371 mediaPlayerState->setFullscreen( FALSE );
372 makeVisible(); 372 makeVisible();
373 } 373 }
374 374
375void VideoWidget::makeVisible() { 375void VideoWidget::makeVisible() {
376 if ( mediaPlayerState->fullscreen() ) { 376 if ( mediaPlayerState->fullscreen() ) {
377 setBackgroundMode( QWidget::NoBackground ); 377 setBackgroundMode( QWidget::NoBackground );
378 showFullScreen(); 378 showFullScreen();
379 resize( qApp->desktop()->size() ); 379 resize( qApp->desktop()->size() );
380 slider->hide(); 380 slider->hide();
381 videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); 381 videoFrame-> setGeometry ( 0, 0, width ( ), height ( ));
382 382
383 } else { 383 } else {
384 showNormal(); 384 showNormal();
385 showMaximized(); 385 showMaximized();
386 setBackgroundPixmap( *pixBg ); 386 setBackgroundPixmap( *pixBg );
387 if ( mediaPlayerState->streaming() ) { 387 if ( mediaPlayerState->streaming() ) {
388 slider->hide(); 388 slider->hide();
389 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 389 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
390 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 390 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
391 } else { 391 } else {
392 slider->show(); 392 slider->show();
393 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 393 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
394 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 394 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
395 } 395 }
396 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); 396 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) );
397 qApp->processEvents(); 397 qApp->processEvents();
398 } 398 }
399} 399}
400 400
401 401
402void VideoWidget::paintEvent( QPaintEvent * pe) { 402void VideoWidget::paintEvent( QPaintEvent * pe) {
403 QPainter p( this ); 403 QPainter p( this );
404 404
405 if ( mediaPlayerState->fullscreen() ) { 405 if ( mediaPlayerState->fullscreen() ) {
406 // Clear the background 406 // Clear the background
407 p.setBrush( QBrush( Qt::black ) ); 407 p.setBrush( QBrush( Qt::black ) );
408 } else { 408 } else {
409 if ( !pe->erased() ) { 409 if ( !pe->erased() ) {
410 // Combine with background and double buffer 410 // Combine with background and double buffer
411 QPixmap pix( pe->rect().size() ); 411 QPixmap pix( pe->rect().size() );
412 QPainter p( &pix ); 412 QPainter p( &pix );
413 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 413 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
414 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); 414 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
415 for ( int i = 0; i < numVButtons; i++ ) { 415 for ( int i = 0; i < numVButtons; i++ ) {
416 paintButton( &p, i ); 416 paintButton( &p, i );
417 } 417 }
418 QPainter p2( this ); 418 QPainter p2( this );
419 p2.drawPixmap( pe->rect().topLeft(), pix ); 419 p2.drawPixmap( pe->rect().topLeft(), pix );
420 } else { 420 } else {
421 QPainter p( this ); 421 QPainter p( this );
422 for ( int i = 0; i < numVButtons; i++ ) 422 for ( int i = 0; i < numVButtons; i++ )
423 paintButton( &p, i ); 423 paintButton( &p, i );
424 } 424 }
425 slider->repaint( TRUE ); 425 slider->repaint( TRUE );
426 } 426 }
427} 427}
428 428
429 429
430void VideoWidget::closeEvent( QCloseEvent* ) { 430void VideoWidget::closeEvent( QCloseEvent* ) {
431 mediaPlayerState->setList(); 431 mediaPlayerState->setList();
432} 432}
433 433
434 434
435 435
436void VideoWidget::keyReleaseEvent( QKeyEvent *e) { 436void VideoWidget::keyReleaseEvent( QKeyEvent *e) {
437 switch ( e->key() ) { 437 switch ( e->key() ) {
438////////////////////////////// Zaurus keys 438////////////////////////////// Zaurus keys
439 case Key_Home: 439 case Key_Home:
440 break; 440 break;
441 case Key_F9: //activity 441 case Key_F9: //activity
442 break; 442 break;
443 case Key_F10: //contacts 443 case Key_F10: //contacts
444// hide(); 444// hide();
445 break; 445 break;
446 case Key_F11: //menu 446 case Key_F11: //menu
447 break; 447 break;
448 case Key_F12: //home 448 case Key_F12: //home
449 break; 449 break;
450 case Key_F13: //mail 450 case Key_F13: //mail
451 break; 451 break;
452 case Key_Space: { 452 case Key_Space: {
453 if(mediaPlayerState->playing()) { 453 if(mediaPlayerState->playing()) {
454 mediaPlayerState->setPlaying(FALSE); 454 mediaPlayerState->setPlaying(FALSE);
455 } else { 455 } else {
456 mediaPlayerState->setPlaying(TRUE); 456 mediaPlayerState->setPlaying(TRUE);
457 } 457 }
458 } 458 }
459 break; 459 break;
460 case Key_Down: 460 case Key_Down:
461// toggleButton(6); 461// toggleButton(6);
462 emit lessClicked(); 462 emit lessClicked();
463 emit lessReleased(); 463 emit lessReleased();
464// toggleButton(6); 464// toggleButton(6);
465 break; 465 break;
466 case Key_Up: 466 case Key_Up:
467// toggleButton(5); 467// toggleButton(5);
468 emit moreClicked(); 468 emit moreClicked();
469 emit moreReleased(); 469 emit moreReleased();
470// toggleButton(5); 470// toggleButton(5);
471 break; 471 break;
472 case Key_Right: 472 case Key_Right:
473 mediaPlayerState->setNext(); 473 mediaPlayerState->setNext();
474 break; 474 break;
475 case Key_Left: 475 case Key_Left:
476 mediaPlayerState->setPrev(); 476 mediaPlayerState->setPrev();
477 break; 477 break;
478 case Key_Escape: 478 case Key_Escape:
479#if defined(QT_QWS_IPAQ)
480 if( mediaPlayerState->isPaused ) {
481 setToggleButton( i, FALSE );
482 mediaPlayerState->setPaused( FALSE );
483 } else if( !mediaPlayerState->isPaused ) {
484 setToggleButton( i, TRUE );
485 mediaPlayerState->setPaused( TRUE );
486 }
487#endif
488 break; 479 break;
489 480
490 }; 481 };
491} 482}
492 483
493XineVideoWidget* VideoWidget::vidWidget() { 484XineVideoWidget* VideoWidget::vidWidget() {
494 return videoFrame; 485 return videoFrame;
495} 486}
496 487
497 488
498void VideoWidget::setFullscreen ( bool b ) { 489void VideoWidget::setFullscreen ( bool b ) {
499 setToggleButton( VideoFullscreen, b ); 490 setToggleButton( VideoFullscreen, b );
500} 491}
501 492
502 493
503void VideoWidget::setPlaying( bool b) { 494void VideoWidget::setPlaying( bool b) {
504 setToggleButton( VideoPlay, b ); 495 setToggleButton( VideoPlay, b );
505} 496}
506 497