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