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