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