summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 419c3ae..a4e6b6e 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -1,463 +1,466 @@
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 }, // previous 66 { FALSE, FALSE, FALSE }, // previous
67 { FALSE, FALSE, FALSE }, // stop 67 { FALSE, FALSE, FALSE }, // stop
68 { TRUE, FALSE, FALSE }, // play 68 { TRUE, FALSE, FALSE }, // play
69 { TRUE, FALSE, FALSE }, // pause 69 { TRUE, FALSE, FALSE }, // pause
70 { FALSE, FALSE, FALSE }, // next 70 { FALSE, FALSE, FALSE }, // next
71 { FALSE, FALSE, FALSE }, // playlist 71 { FALSE, FALSE, FALSE }, // playlist
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 numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); 79static const int numButtons = (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 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 140 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
141 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 141 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
142 142
143 setLength( mediaPlayerState->length() ); 143 setLength( mediaPlayerState->length() );
144 setPosition( mediaPlayerState->position() ); 144 setPosition( mediaPlayerState->position() );
145 145
146 ////////////////////////// FIXME 146 ////////////////////////// FIXME
147// setFullscreen( mediaPlayerState->fullscreen() ); 147// setFullscreen( mediaPlayerState->fullscreen() );
148 setPaused( mediaPlayerState->paused() ); 148 setPaused( mediaPlayerState->paused() );
149 setPlaying( mediaPlayerState->playing() ); 149 setPlaying( mediaPlayerState->playing() );
150 qDebug("finished videowidget"); 150 qDebug("finished videowidget");
151} 151}
152 152
153 153
154VideoWidget::~VideoWidget() { 154VideoWidget::~VideoWidget() {
155 for ( int i = 0; i < 7; i++ ) { 155 for ( int i = 0; i < 7; i++ ) {
156 delete buttonPixUp[i]; 156 delete buttonPixUp[i];
157 delete buttonPixDown[i]; 157 delete buttonPixDown[i];
158 } 158 }
159 159
160 delete pixBg; 160 delete pixBg;
161 delete imgUp; 161 delete imgUp;
162 delete imgDn; 162 delete imgDn;
163 delete imgButtonMask; 163 delete imgButtonMask;
164 for ( int i = 0; i < 7; i++ ) { 164 for ( int i = 0; i < 7; i++ ) {
165 delete masks[i]; 165 delete masks[i];
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 //videoFrame->height(); 187 //videoFrame->height();
188 int Vw = 220; 188 int Vw = 220;
189 //videoFrame->width(); 189 //videoFrame->width();
190// songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); 190// songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) );
191 191
192 slider->setFixedWidth( w - 110 ); 192 slider->setFixedWidth( w - 110 );
193 slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); 193 slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) );
194 slider->setBackgroundOrigin( QWidget::ParentOrigin ); 194 slider->setBackgroundOrigin( QWidget::ParentOrigin );
195 slider->setFocusPolicy( QWidget::NoFocus );
196make slider->setBackgroundPixmap( *pixBg );
197
195// time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); 198// time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
196 xoff = 0;// ( imgUp->width() ) / 2; 199 xoff = 0;// ( imgUp->width() ) / 2;
197 yoff = 180;//(( Vh - imgUp->height() ) / 2) - 10; 200 yoff = 180;//(( Vh - imgUp->height() ) / 2) - 10;
198 QPoint p( xoff, yoff ); 201 QPoint p( xoff, yoff );
199 202
203
200 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); 204 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p );
201 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); 205 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p );
202 206
203 for ( int i = 0; i < 7; i++ ) { 207 for ( int i = 0; i < 7; i++ ) {
204 if ( !masks[i]->isNull() ) { 208 if ( !masks[i]->isNull() ) {
205 delete buttonPixUp[i]; 209 delete buttonPixUp[i];
206 delete buttonPixDown[i]; 210 delete buttonPixDown[i];
207 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); 211 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] );
208 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); 212 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] );
209 } 213 }
210 } 214 }
211 215
212 delete pixUp; 216 delete pixUp;
213 delete pixDn; 217 delete pixDn;
214} 218}
215 219
216static bool videoSliderBeingMoved = FALSE; 220static bool videoSliderBeingMoved = FALSE;
217 221
218void VideoWidget::sliderPressed() { 222void VideoWidget::sliderPressed() {
219 videoSliderBeingMoved = TRUE; 223 videoSliderBeingMoved = TRUE;
220} 224}
221 225
222void VideoWidget::sliderReleased() { 226void VideoWidget::sliderReleased() {
223 videoSliderBeingMoved = FALSE; 227 videoSliderBeingMoved = FALSE;
224 if ( slider->width() == 0 ) { 228 if ( slider->width() == 0 ) {
225 return; 229 return;
226 } 230 }
227 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); 231 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width());
228 mediaPlayerState->setPosition( val ); 232 mediaPlayerState->setPosition( val );
229} 233}
230 234
231void VideoWidget::setPosition( long i ) { 235void VideoWidget::setPosition( long i ) {
232 updateSlider( i, mediaPlayerState->length() ); 236 updateSlider( i, mediaPlayerState->length() );
233} 237}
234 238
235 239
236void VideoWidget::setLength( long max ) { 240void VideoWidget::setLength( long max ) {
237 updateSlider( mediaPlayerState->position(), max ); 241 updateSlider( mediaPlayerState->position(), max );
238} 242}
239 243
240void VideoWidget::setView( char view ) { 244void VideoWidget::setView( char view ) {
241 if ( view == 'v' ) { 245 if ( view == 'v' ) {
242 makeVisible(); 246 makeVisible();
243 } else { 247 } else {
244 // Effectively blank the view next time we show it so it looks nicer 248 // Effectively blank the view next time we show it so it looks nicer
245 scaledWidth = 0; 249 scaledWidth = 0;
246 scaledHeight = 0; 250 scaledHeight = 0;
247 hide(); 251 hide();
248 } 252 }
249} 253}
250 254
251void VideoWidget::updateSlider( long i, long max ) { 255void VideoWidget::updateSlider( long i, long max ) {
252 // Will flicker too much if we don't do this 256 // Will flicker too much if we don't do this
253 if ( max == 0 ) { 257 if ( max == 0 ) {
254 return; 258 return;
255 } 259 }
256 int width = slider->width(); 260 int width = slider->width();
257 int val = int((double)i * width / max); 261 int val = int((double)i * width / max);
258 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { 262 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) {
259 if ( slider->value() != val ) { 263 if ( slider->value() != val ) {
260 slider->setValue( val ); 264 slider->setValue( val );
261 } 265 }
262 if ( slider->maxValue() != width ) { 266 if ( slider->maxValue() != width ) {
263 slider->setMaxValue( width ); 267 slider->setMaxValue( width );
264 } 268 }
265 } 269 }
266} 270}
267 271
268void VideoWidget::setToggleButton( int i, bool down ) { 272void VideoWidget::setToggleButton( int i, bool down ) {
269 if ( down != videoButtons[i].isDown ) { 273 if ( down != videoButtons[i].isDown ) {
270 toggleButton( i ); 274 toggleButton( i );
271 } 275 }
272} 276}
273 277
274void VideoWidget::toggleButton( int i ) { 278void VideoWidget::toggleButton( int i ) {
275 videoButtons[i].isDown = !videoButtons[i].isDown; 279 videoButtons[i].isDown = !videoButtons[i].isDown;
276 QPainter p(this); 280 QPainter p(this);
277 paintButton ( &p, i ); 281 paintButton ( &p, i );
278} 282}
279 283
280void VideoWidget::paintButton( QPainter *p, int i ) { 284void VideoWidget::paintButton( QPainter *p, int i ) {
281 285
282 if ( videoButtons[i].isDown ) 286 if ( videoButtons[i].isDown )
283 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 287 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
284 else 288 else
285 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 289 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
286} 290}
287 291
288void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 292void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
289 for ( int i = 0; i < numButtons; i++ ) { 293 for ( int i = 0; i < numButtons; i++ ) {
290 if ( event->state() == QMouseEvent::LeftButton ) { 294 if ( event->state() == QMouseEvent::LeftButton ) {
291 // The test to see if the mouse click is inside the button or not 295 // The test to see if the mouse click is inside the button or not
292 int x = event->pos().x() - xoff; 296 int x = event->pos().x() - xoff;
293 int y = event->pos().y() - yoff; 297 int y = event->pos().y() - yoff;
294 298
295 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() 299 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
296 && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); 300 && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 );
297 if ( isOnButton != videoButtons[i].isHeld ) { 301 if ( isOnButton != videoButtons[i].isHeld ) {
298 videoButtons[i].isHeld = isOnButton; 302 videoButtons[i].isHeld = isOnButton;
299 toggleButton(i); 303 toggleButton(i);
300 } 304 }
301 } else { 305 } else {
302 if ( videoButtons[i].isHeld ) { 306 if ( videoButtons[i].isHeld ) {
303 videoButtons[i].isHeld = FALSE; 307 videoButtons[i].isHeld = FALSE;
304 if ( !videoButtons[i].isToggle ) 308 if ( !videoButtons[i].isToggle )
305 setToggleButton( i, FALSE ); 309 setToggleButton( i, FALSE );
306 } 310 }
307 } 311 }
308 switch (i) { 312 switch (i) {
309 case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; 313 case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return;
310 case VideoStop: mediaPlayerState->setPlaying(FALSE); return; 314 case VideoStop: mediaPlayerState->setPlaying(FALSE); return;
311 case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; 315 case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return;
312 case VideoNext: mediaPlayerState->setNext(); return; 316 case VideoNext: mediaPlayerState->setNext(); return;
313 case VideoPrevious: mediaPlayerState->setPrev(); return; 317 case VideoPrevious: mediaPlayerState->setPrev(); return;
314 case VideoPlayList: mediaPlayerState->setList(); return; 318 case VideoPlayList: mediaPlayerState->setList(); return;
315 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; 319 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
316 } 320 }
317 321
318 } 322 }
319} 323}
320 324
321void VideoWidget::mousePressEvent( QMouseEvent *event ) { 325void VideoWidget::mousePressEvent( QMouseEvent *event ) {
322 mouseMoveEvent( event ); 326 mouseMoveEvent( event );
323} 327}
324 328
325void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 329void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
326 if ( mediaPlayerState->fullscreen() ) { 330 if ( mediaPlayerState->fullscreen() ) {
327 mediaPlayerState->setFullscreen( FALSE ); 331 mediaPlayerState->setFullscreen( FALSE );
328 makeVisible(); 332 makeVisible();
329 333
330 mouseMoveEvent( event ); 334 mouseMoveEvent( event );
331 } 335 }
332} 336}
333 337
334 338
335void VideoWidget::makeVisible() { 339void VideoWidget::makeVisible() {
336 if ( mediaPlayerState->fullscreen() ) { 340 if ( mediaPlayerState->fullscreen() ) {
337 setBackgroundMode( QWidget::NoBackground ); 341 setBackgroundMode( QWidget::NoBackground );
338 showFullScreen(); 342 showFullScreen();
339 resize( qApp->desktop()->size() ); 343 resize( qApp->desktop()->size() );
340 slider->hide(); 344 slider->hide();
341 videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); 345 videoFrame-> setGeometry ( 0, 0, width ( ), height ( ));
342 } else { 346 } else {
343 setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
344 showNormal(); 347 showNormal();
345 showMaximized(); 348 showMaximized();
346 slider->show(); 349 slider->show();
347 videoFrame->setGeometry( QRect( 10, 20, 220, 160 ) ); 350 videoFrame->setGeometry( QRect( 10, 20, 220, 160 ) );
348 } 351 }
349} 352}
350 353
351 354
352void VideoWidget::paintEvent( QPaintEvent * pe) { 355void VideoWidget::paintEvent( QPaintEvent * pe) {
353 QPainter p( this ); 356 QPainter p( this );
354 357
355 if ( mediaPlayerState->fullscreen() ) { 358 if ( mediaPlayerState->fullscreen() ) {
356 // Clear the background 359 // Clear the background
357 p.setBrush( QBrush( Qt::black ) ); 360 p.setBrush( QBrush( Qt::black ) );
358// videoFrame->setGeometry( QRect( 0, 0 , 240 ,320 ) ); 361// videoFrame->setGeometry( QRect( 0, 0 , 240 ,320 ) );
359 362
360 } else { 363 } else {
361 364
362 // videoFrame->setGeometry( QRect( 0, 15 , 240 ,170 ) ); 365 // videoFrame->setGeometry( QRect( 0, 15 , 240 ,170 ) );
363 // draw the buttons 366 // draw the buttons
364 367
365 if ( !pe->erased() ) { 368 if ( !pe->erased() ) {
366 // Combine with background and double buffer 369 // Combine with background and double buffer
367 QPixmap pix( pe->rect().size() ); 370 QPixmap pix( pe->rect().size() );
368 QPainter p( &pix ); 371 QPainter p( &pix );
369 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 372 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
370 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); 373 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
371 for ( int i = 0; i < numButtons; i++ ) 374 for ( int i = 0; i < numButtons; i++ )
372 paintButton( &p, i ); 375 paintButton( &p, i );
373 QPainter p2( this ); 376 QPainter p2( this );
374 p2.drawPixmap( pe->rect().topLeft(), pix ); 377 p2.drawPixmap( pe->rect().topLeft(), pix );
375 } else { 378 } else {
376 QPainter p( this ); 379 QPainter p( this );
377 for ( int i = 0; i < numButtons; i++ ) 380 for ( int i = 0; i < numButtons; i++ )
378 paintButton( &p, i ); 381 paintButton( &p, i );
379 } 382 }
380// for ( int i = 0; i < numButtons; i++ ) { 383// for ( int i = 0; i < numButtons; i++ ) {
381// paintButton( &p, i ); 384// paintButton( &p, i );
382// } 385// }
383// // draw the slider 386// // draw the slider
384// slider->repaint( TRUE ); 387// slider->repaint( TRUE );
385 } 388 }
386} 389}
387 390
388 391
389void VideoWidget::closeEvent( QCloseEvent* ) { 392void VideoWidget::closeEvent( QCloseEvent* ) {
390 mediaPlayerState->setList(); 393 mediaPlayerState->setList();
391} 394}
392 395
393 396
394bool VideoWidget::playVideo() { 397bool VideoWidget::playVideo() {
395 bool result = FALSE; 398 bool result = FALSE;
396 399
397 int stream = 0; 400 int stream = 0;
398 401
399 int sw = 240; 402 int sw = 240;
400 int sh = 320; 403 int sh = 320;
401 int dd = QPixmap::defaultDepth(); 404 int dd = QPixmap::defaultDepth();
402 int w = height(); 405 int w = height();
403 int h = width(); 406 int h = width();
404 407
405 return true; 408 return true;
406} 409}
407 410
408void VideoWidget::keyReleaseEvent( QKeyEvent *e) { 411void VideoWidget::keyReleaseEvent( QKeyEvent *e) {
409 switch ( e->key() ) { 412 switch ( e->key() ) {
410////////////////////////////// Zaurus keys 413////////////////////////////// Zaurus keys
411 case Key_Home: 414 case Key_Home:
412 break; 415 break;
413 case Key_F9: //activity 416 case Key_F9: //activity
414 break; 417 break;
415 case Key_F10: //contacts 418 case Key_F10: //contacts
416// hide(); 419// hide();
417 break; 420 break;
418 case Key_F11: //menu 421 case Key_F11: //menu
419 break; 422 break;
420 case Key_F12: //home 423 case Key_F12: //home
421 break; 424 break;
422 case Key_F13: //mail 425 case Key_F13: //mail
423 break; 426 break;
424 case Key_Space: { 427 case Key_Space: {
425 if(mediaPlayerState->playing()) { 428 if(mediaPlayerState->playing()) {
426 mediaPlayerState->setPlaying(FALSE); 429 mediaPlayerState->setPlaying(FALSE);
427 } else { 430 } else {
428 mediaPlayerState->setPlaying(TRUE); 431 mediaPlayerState->setPlaying(TRUE);
429 } 432 }
430 } 433 }
431 break; 434 break;
432 case Key_Down: 435 case Key_Down:
433// toggleButton(6); 436// toggleButton(6);
434// emit lessClicked(); 437// emit lessClicked();
435// emit lessReleased(); 438// emit lessReleased();
436// toggleButton(6); 439// toggleButton(6);
437 break; 440 break;
438 case Key_Up: 441 case Key_Up:
439// toggleButton(5); 442// toggleButton(5);
440// emit moreClicked(); 443// emit moreClicked();
441// emit moreReleased(); 444// emit moreReleased();
442// toggleButton(5); 445// toggleButton(5);
443 break; 446 break;
444 case Key_Right: 447 case Key_Right:
445 mediaPlayerState->setNext(); 448 mediaPlayerState->setNext();
446 break; 449 break;
447 case Key_Left: 450 case Key_Left:
448 mediaPlayerState->setPrev(); 451 mediaPlayerState->setPrev();
449 break; 452 break;
450 case Key_Escape: 453 case Key_Escape:
451 break; 454 break;
452 455
453 }; 456 };
454} 457}
455 458
456XineVideoWidget* VideoWidget::vidWidget() { 459XineVideoWidget* VideoWidget::vidWidget() {
457 return videoFrame; 460 return videoFrame;
458} 461}
459 462
460 463
461void VideoWidget::setFullscreen ( bool b ) { 464void VideoWidget::setFullscreen ( bool b ) {
462 setToggleButton( VideoFullscreen, b ); 465 setToggleButton( VideoFullscreen, b );
463} 466}