summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2003-04-20 04:09:51 (UTC)
committer llornkcor <llornkcor>2003-04-20 04:09:51 (UTC)
commit0bc47585aef17477ca5564dde4da4a41cf57a1c0 (patch) (unidiff)
treeb425c7820c64c1673680b86a87932401a6e8f4a1
parentf4b192f79649abb3318c2c404da31f067f4ca467 (diff)
downloadopie-0bc47585aef17477ca5564dde4da4a41cf57a1c0.zip
opie-0bc47585aef17477ca5564dde4da4a41cf57a1c0.tar.gz
opie-0bc47585aef17477ca5564dde4da4a41cf57a1c0.tar.bz2
buttons working
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/videowidget.cpp225
-rw-r--r--core/multimedia/opieplayer/videowidget.h14
2 files changed, 146 insertions, 93 deletions
diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp
index 1b38206..6ed0108 100644
--- a/core/multimedia/opieplayer/videowidget.cpp
+++ b/core/multimedia/opieplayer/videowidget.cpp
@@ -1,653 +1,700 @@
1/********************************************************************** 1/**********************************************************************
2 ** Copyright (C) 2000 Trolltech AS. All rights reserved. 2 ** Copyright (C) 2000 Trolltech AS. All rights reserved.
3 ** 3 **
4 ** This file is part of Qtopia Environment. 4 ** This file is part of Qtopia Environment.
5 ** 5 **
6 ** This file may be distributed and/or modified under the terms of the 6 ** This file may be distributed and/or modified under the terms of the
7 ** GNU General Public License version 2 as published by the Free Software 7 ** GNU General Public License version 2 as published by the Free Software
8 ** Foundation and appearing in the file LICENSE.GPL included in the 8 ** Foundation and appearing in the file LICENSE.GPL included in the
9 ** packaging of this file. 9 ** packaging of this file.
10 ** 10 **
11 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13 ** 13 **
14 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 14 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
15 ** 15 **
16 ** Contact info@trolltech.com if any conditions of this licensing are 16 ** Contact info@trolltech.com if any conditions of this licensing are
17 ** not clear to you. 17 ** not clear to you.
18 ** 18 **
19 **********************************************************************/ 19 **********************************************************************/
20#include <qpe/resource.h> 20#include <qpe/resource.h>
21#include <qpe/mediaplayerplugininterface.h> 21#include <qpe/mediaplayerplugininterface.h>
22#include <qpe/config.h> 22#include <qpe/config.h>
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24 24
25#include <qdir.h> 25#include <qdir.h>
26#include <qwidget.h> 26#include <qwidget.h>
27#include <qpainter.h> 27#include <qpainter.h>
28#include <qpixmap.h> 28#include <qpixmap.h>
29#include <qslider.h> 29#include <qslider.h>
30#include <qdrawutil.h> 30#include <qdrawutil.h>
31#include "videowidget.h" 31#include "videowidget.h"
32#include "mediaplayerstate.h" 32#include "mediaplayerstate.h"
33 33
34 34
35#ifdef Q_WS_QWS 35#ifdef Q_WS_QWS
36# define USE_DIRECT_PAINTER 36# define USE_DIRECT_PAINTER
37# include <qdirectpainter_qws.h> 37# include <qdirectpainter_qws.h>
38# include <qgfxraster_qws.h> 38# include <qgfxraster_qws.h>
39#endif 39#endif
40 40
41 41
42extern MediaPlayerState *mediaPlayerState; 42extern MediaPlayerState *mediaPlayerState;
43 43
44 44
45static const int xo = 2; // movable x offset 45static const int xo = 2; // movable x offset
46static const int yo = 0; // movable y offset 46static const int yo = 0; // movable y offset
47 47
48 48
49struct MediaButton { 49struct MediaButton {
50// int xPos, yPos; 50// int xPos, yPos;
51 bool isToggle, isHeld, isDown; 51 bool isToggle, isHeld, isDown;
52// int controlType; 52// int controlType;
53}; 53};
54 54
55 55
56// Layout information for the videoButtons (and if it is a toggle button or not) 56// Layout information for the videoButtons (and if it is a toggle button or not)
57MediaButton videoButtons[] = { 57MediaButton videoButtons[] = {
58 { FALSE, FALSE, FALSE }, // stop 58 { FALSE, FALSE, FALSE }, // stop
59 { TRUE, FALSE, FALSE }, // play 59 { FALSE, FALSE, FALSE }, // play
60 { FALSE, FALSE, FALSE }, // previous 60 { FALSE, FALSE, FALSE }, // previous
61 { FALSE, FALSE, FALSE }, // next 61 { FALSE, FALSE, FALSE }, // next
62 { FALSE, FALSE, FALSE }, // volUp 62 { FALSE, FALSE, FALSE }, // volUp
63 { FALSE, FALSE, FALSE }, // volDown 63 { FALSE, FALSE, FALSE }, // volDown
64 { TRUE, FALSE, FALSE } // fullscreen 64 { TRUE, FALSE, FALSE } // fullscreen
65}; 65};
66 66
67//static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); 67//static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton));
68 68
69const char *skinV_mask_file_names[7] = { 69const char *skinV_mask_file_names[7] = {
70 "stop","play","back","fwd","up","down","full" 70 "stop","play","back","fwd","up","down","full"
71}; 71};
72 72
73static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); 73static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton));
74 74
75VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : 75VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) :
76 QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) 76 QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 )
77{ 77{
78 setCaption( tr("OpiePlayer") ); 78 setCaption( tr("OpiePlayer") );
79 Config cfg("OpiePlayer"); 79 Config cfg("OpiePlayer");
80 80
81 cfg.setGroup("Options"); 81 cfg.setGroup("Options");
82 skin = cfg.readEntry("Skin","default"); 82 skin = cfg.readEntry("Skin","default");
83 83
84 QString skinPath; 84 QString skinPath;
85 skinPath = "opieplayer2/skins/" + skin; 85 skinPath = "opieplayer2/skins/" + skin;
86 if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists()) 86 if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists())
87 skinPath = "opieplayer2/skins/default"; 87 skinPath = "opieplayer2/skins/default";
88 88
89 qDebug("skin path " + skinPath); 89 qDebug("skin path " + skinPath);
90 90
91// QString skinPath = "opieplayer2/skins/" + skin; 91// QString skinPath = "opieplayer2/skins/" + skin;
92 92
93 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 93 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
94 imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); 94 imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) );
95 imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); 95 imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) );
96 96
97 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); 97 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
98 imgButtonMask->fill( 0 ); 98 imgButtonMask->fill( 0 );
99 99
100 for ( int i = 0; i < 7; i++ ) 100 for ( int i = 0; i < 7; i++ )
101 { 101 {
102 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + 102 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath +
103 "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); 103 "/skinV_mask_" + skinV_mask_file_names[i] + ".png" );
104 qDebug("loading "+filename); 104 qDebug("loading "+filename);
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 { 108 {
109 QImage imgMask = masks[i]->convertToImage(); 109 QImage imgMask = masks[i]->convertToImage();
110 uchar **dest = imgButtonMask->jumpTable(); 110 uchar **dest = imgButtonMask->jumpTable();
111 for ( int y = 0; y < imgUp->height(); y++ ) 111 for ( int y = 0; y < imgUp->height(); y++ )
112 { 112 {
113 uchar *line = dest[y]; 113 uchar *line = dest[y];
114 for ( int x = 0; x < imgUp->width(); x++ ) 114 for ( int x = 0; x < imgUp->width(); x++ )
115 { 115 {
116 if ( !qRed( imgMask.pixel( x, y ) ) ) 116 if ( !qRed( imgMask.pixel( x, y ) ) )
117 line[x] = i + 1; 117 line[x] = i + 1;
118 } 118 }
119 } 119 }
120 } 120 }
121 } 121 }
122 qDebug("finished loading first pics"); 122 qDebug("finished loading first pics");
123 for ( int i = 0; i < 7; i++ ) 123 for ( int i = 0; i < 7; i++ )
124 { 124 {
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 currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); 131 currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 );
132 132
133 slider = new QSlider( Qt::Horizontal, this ); 133 slider = new QSlider( Qt::Horizontal, this );
134 slider->setMinValue( 0 ); 134 slider->setMinValue( 0 );
135 slider->setMaxValue( 1 ); 135 slider->setMaxValue( 1 );
136 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 136 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
137 slider->setFocusPolicy( QWidget::NoFocus ); 137 slider->setFocusPolicy( QWidget::NoFocus );
138// slider->setGeometry( QRect( 7, 250, 220, 20 ) ); 138// slider->setGeometry( QRect( 7, 250, 220, 20 ) );
139 139
140 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 140 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
141 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 141 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
142 142
143 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 143 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
144 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 144 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
145 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 145 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
146 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 146 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
147 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 147// connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
148 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 148 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
149 149
150 // Intialise state 150 // Intialise state
151 setLength( mediaPlayerState->length() ); 151 setLength( mediaPlayerState->length() );
152 setPosition( mediaPlayerState->position() ); 152 setPosition( mediaPlayerState->position() );
153 setFullscreen( mediaPlayerState->fullscreen() ); 153 setFullscreen( mediaPlayerState->fullscreen() );
154 setPaused( mediaPlayerState->paused() ); 154// setPaused( mediaPlayerState->paused() );
155 setPlaying( mediaPlayerState->playing() ); 155 setPlaying( mediaPlayerState->playing() );
156} 156}
157 157
158 158
159VideoWidget::~VideoWidget() { 159VideoWidget::~VideoWidget() {
160 160
161 for ( int i = 0; i < 7; i++ ) 161 for ( int i = 0; i < 7; i++ )
162 { 162 {
163 delete buttonPixUp[i]; 163 delete buttonPixUp[i];
164 delete buttonPixDown[i]; 164 delete buttonPixDown[i];
165 } 165 }
166 166
167 delete pixBg; 167 delete pixBg;
168 delete imgUp; 168 delete imgUp;
169 delete imgDn; 169 delete imgDn;
170 delete imgButtonMask; 170 delete imgButtonMask;
171 for ( int i = 0; i < 7; i++ ) 171 for ( int i = 0; i < 7; i++ )
172 { 172 {
173 delete masks[i]; 173 delete masks[i];
174 } 174 }
175 175
176// for ( int i = 0; i < 3; i++ ) 176// for ( int i = 0; i < 3; i++ )
177// delete pixmaps[i]; 177// delete pixmaps[i];
178// delete currentFrame; 178// delete currentFrame;
179} 179}
180 180
181 181
182static bool videoSliderBeingMoved = FALSE; 182static bool videoSliderBeingMoved = FALSE;
183 183
184QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 184QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
185 QPixmap pix( img.width(), img.height() ); 185 QPixmap pix( img.width(), img.height() );
186 QPainter p( &pix ); 186 QPainter p( &pix );
187 p.drawTiledPixmap( pix.rect(), bg, offset ); 187 p.drawTiledPixmap( pix.rect(), bg, offset );
188 p.drawImage( 0, 0, img ); 188 p.drawImage( 0, 0, img );
189 return new QPixmap( pix ); 189 return new QPixmap( pix );
190} 190}
191 191
192QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { 192QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) {
193 QPixmap *pixmap = new QPixmap( pix ); 193 QPixmap *pixmap = new QPixmap( pix );
194 pixmap->setMask( mask ); 194 pixmap->setMask( mask );
195 return pixmap; 195 return pixmap;
196} 196}
197 197
198void VideoWidget::resizeEvent( QResizeEvent * ) { 198void VideoWidget::resizeEvent( QResizeEvent * ) {
199 int h = height(); 199 int h = height();
200 int w = width(); 200 int w = width();
201 //int Vh = 160; 201 //int Vh = 160;
202 //int Vw = 220; 202 //int Vw = 220;
203 203
204 slider->setFixedWidth( w - 20 ); 204 slider->setFixedWidth( w - 20 );
205 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 205 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
206 slider->setBackgroundOrigin( QWidget::ParentOrigin ); 206 slider->setBackgroundOrigin( QWidget::ParentOrigin );
207 slider->setFocusPolicy( QWidget::NoFocus ); 207 slider->setFocusPolicy( QWidget::NoFocus );
208 slider->setBackgroundPixmap( *pixBg ); 208 slider->setBackgroundPixmap( *pixBg );
209 209
210 xoff = 0;// ( imgUp->width() ) / 2; 210 xoff = 0;// ( imgUp->width() ) / 2;
211 if(w>h) 211 if(w>h)
212 yoff = 0; 212 yoff = 0;
213 else 213 else
214 yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; 214 yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10;
215 QPoint p( xoff, yoff ); 215 QPoint p( xoff, yoff );
216 216
217 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); 217 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p );
218 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); 218 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p );
219 219
220 for ( int i = 0; i < 7; i++ ) 220 for ( int i = 0; i < 7; i++ )
221 { 221 {
222 if ( !masks[i]->isNull() ) 222 if ( !masks[i]->isNull() )
223 { 223 {
224 delete buttonPixUp[i]; 224 delete buttonPixUp[i];
225 delete buttonPixDown[i]; 225 delete buttonPixDown[i];
226 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); 226 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] );
227 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); 227 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] );
228 } 228 }
229 } 229 }
230 230
231 delete pixUp; 231 delete pixUp;
232 delete pixDn; 232 delete pixDn;
233} 233}
234 234
235 235
236void VideoWidget::sliderPressed() { 236void VideoWidget::sliderPressed() {
237 videoSliderBeingMoved = TRUE; 237 videoSliderBeingMoved = TRUE;
238} 238}
239 239
240 240
241void VideoWidget::sliderReleased() { 241void VideoWidget::sliderReleased() {
242 videoSliderBeingMoved = FALSE; 242 videoSliderBeingMoved = FALSE;
243 if ( slider->width() == 0 ) 243 if ( slider->width() == 0 )
244 return; 244 return;
245 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); 245 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width());
246 mediaPlayerState->setPosition( val ); 246 mediaPlayerState->setPosition( val );
247} 247}
248 248
249 249
250void VideoWidget::setPosition( long i ) { 250void VideoWidget::setPosition( long i ) {
251 updateSlider( i, mediaPlayerState->length() ); 251 updateSlider( i, mediaPlayerState->length() );
252} 252}
253 253
254 254
255void VideoWidget::setLength( long max ) { 255void VideoWidget::setLength( long max ) {
256 updateSlider( mediaPlayerState->position(), max ); 256 updateSlider( mediaPlayerState->position(), max );
257} 257}
258 258
259 259
260void VideoWidget::setView( char view ) { 260void VideoWidget::setView( char view ) {
261 if ( view == 'v' ) 261 if ( view == 'v' )
262 { 262 {
263 makeVisible(); 263 makeVisible();
264 } 264 }
265 else 265 else
266 { 266 {
267 // Effectively blank the view next time we show it so it looks nicer 267 // Effectively blank the view next time we show it so it looks nicer
268 scaledWidth = 0; 268 scaledWidth = 0;
269 scaledHeight = 0; 269 scaledHeight = 0;
270 hide(); 270 hide();
271 } 271 }
272} 272}
273 273
274 274
275void VideoWidget::updateSlider( long i, long max ) { 275void VideoWidget::updateSlider( long i, long max ) {
276 // Will flicker too much if we don't do this 276 // Will flicker too much if we don't do this
277 if ( max == 0 ) 277 if ( max == 0 )
278 return; 278 return;
279 int width = slider->width(); 279 int width = slider->width();
280 int val = int((double)i * width / max); 280 int val = int((double)i * width / max);
281 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) 281 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved )
282 { 282 {
283 if ( slider->value() != val ) 283 if ( slider->value() != val )
284 slider->setValue( val ); 284 slider->setValue( val );
285 if ( slider->maxValue() != width ) 285 if ( slider->maxValue() != width )
286 slider->setMaxValue( width ); 286 slider->setMaxValue( width );
287 } 287 }
288} 288}
289 289
290 290
291void VideoWidget::setToggleButton( int i, bool down ) { 291void VideoWidget::setToggleButton( int i, bool down ) {
292 if ( down != videoButtons[i].isDown ) 292 if ( down != videoButtons[i].isDown )
293 toggleButton( i ); 293 toggleButton( i );
294} 294}
295 295
296 296
297void VideoWidget::toggleButton( int i ) { 297void VideoWidget::toggleButton( int i ) {
298 videoButtons[i].isDown = !videoButtons[i].isDown; 298 videoButtons[i].isDown = !videoButtons[i].isDown;
299 QPainter p(this); 299 QPainter p(this);
300 paintButton ( &p, i ); 300 paintButton ( &p, i );
301} 301}
302 302
303 303
304void VideoWidget::paintButton( QPainter *p, int i ) { 304void VideoWidget::paintButton( QPainter *p, int i ) {
305 if ( videoButtons[i].isDown ) 305 if ( videoButtons[i].isDown )
306 { 306 {
307 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 307 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
308 } 308 }
309 else 309 else
310 { 310 {
311 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 311 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
312 } 312 }
313// int x = videoButtons[i].xPos; 313// int x = videoButtons[i].xPos;
314// int y = videoButtons[i].yPos; 314// int y = videoButtons[i].yPos;
315// int offset = 10 + videoButtons[i].isDown; 315// int offset = 10 + videoButtons[i].isDown;
316// p->drawPixmap( x, y, *pixmaps[videoButtons[i].isDown] ); 316// p->drawPixmap( x, y, *pixmaps[videoButtons[i].isDown] );
317// p->drawPixmap( x + 1 + offset, y + offset, *pixmaps[2], 9 * videoButtons[i].controlType, 0, 9, 9 ); 317// p->drawPixmap( x + 1 + offset, y + offset, *pixmaps[2], 9 * videoButtons[i].controlType, 0, 9, 9 );
318} 318}
319 319
320 320
321void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 321void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
322 322 for ( int i = 0; i < numVButtons; i++ ) {
323 for ( int i = 0; i < numVButtons; i++ ) 323 if ( event->state() == QMouseEvent::LeftButton ) {
324 { 324 // The test to see if the mouse click is inside the button or not
325 if ( event->state() == QMouseEvent::LeftButton ) 325 int x = event->pos().x() - xoff;
326 { 326 int y = event->pos().y() - yoff;
327 // The test to see if the mouse click is inside the button or not 327
328 int x = event->pos().x() - xoff; 328 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
329 int y = event->pos().y() - yoff; 329 && y < imgButtonMask->height()
330 330 && imgButtonMask->pixelIndex( x, y ) == i + 1 );
331 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() 331
332 && y < imgButtonMask->height() 332 if ( isOnButton && !videoButtons[i].isHeld ) {
333 && imgButtonMask->pixelIndex( x, y ) == i + 1 ); 333 videoButtons[i].isHeld = TRUE;
334 334 toggleButton(i);
335 if ( isOnButton && !videoButtons[i].isHeld ) 335
336 { 336 switch (i) {
337 videoButtons[i].isHeld = TRUE; 337 case VideoVolUp:
338 toggleButton(i); 338 emit moreClicked();
339 339 return;
340 case VideoVolDown:
341 emit lessClicked();
342 return;
343 }
344 } else if ( !isOnButton && videoButtons[i].isHeld ) {
345 videoButtons[i].isHeld = FALSE;
346 toggleButton(i);
347 }
348 } else {
349
350 if ( videoButtons[i].isHeld ) {
351 videoButtons[i].isHeld = FALSE;
352 if ( !videoButtons[i].isToggle ) {
353 setToggleButton( i, FALSE );
354 }
355
356 switch(i) {
357
358 case VideoPlay: {
359 qDebug("play");
360 if( !mediaPlayerState->playing()) {
361 mediaPlayerState->setPlaying( true);
362 setToggleButton( i-1, false );
363 setToggleButton( i, false );
364 return;
365 }
366 if( mediaPlayerState->isPaused ) {
367 qDebug("isPaused");
368 setToggleButton( i, FALSE );
369 mediaPlayerState->setPaused( FALSE );
370 return;
371 } else if( !mediaPlayerState->isPaused ) {
372 qDebug("is not paused");
373 setToggleButton( i, TRUE );
374 mediaPlayerState->setPaused( TRUE );
375 return;
376 } else {
377 return;
378 }
379 }
380
381 case VideoStop: qDebug("stop"); mediaPlayerState->setPlaying( FALSE ); setToggleButton( i+1, true); setToggleButton( i, true ); return;
382 case VideoNext: mediaPlayerState->setNext(); return;
383 case VideoPrevious: mediaPlayerState->setPrev(); return;
384 case VideoVolUp: emit moreReleased(); return;
385 case VideoVolDown: emit lessReleased(); return;
386 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
387 }
388 }
389 }
390 }
391
392// for ( int i = 0; i < numVButtons; i++ )
393// {
394// if ( event->state() == QMouseEvent::LeftButton )
395// {
396// // The test to see if the mouse click is inside the button or not
397// int x = event->pos().x() - xoff;
398// int y = event->pos().y() - yoff;
399
400// bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
401// && y < imgButtonMask->height()
402// && imgButtonMask->pixelIndex( x, y ) == i + 1 );
403
404// if ( isOnButton && !videoButtons[i].isHeld )
405// {
406// qDebug("key %d", i);
407
408// videoButtons[i].isHeld = TRUE;
409// toggleButton(i);
340// switch (i) { 410// switch (i) {
341// case VideoVolUp: 411// case VideoVolUp:
342// emit moreClicked(); 412// emit moreClicked();
343// return; 413// return;
344// case VideoVolDown: 414// case VideoVolDown:
345// emit lessClicked(); 415// emit lessClicked();
346// return; 416// return;
347// } 417// }
348 } 418// } else if ( !isOnButton && videoButtons[i].isHeld ) {
349 else if ( !isOnButton && videoButtons[i].isHeld ) 419// videoButtons[i].isHeld = FALSE;
350 { 420// toggleButton(i);
351 videoButtons[i].isHeld = FALSE; 421// }
352 toggleButton(i);
353 }
354 }
355 else
356 {
357 422
358 if ( videoButtons[i].isHeld )
359 {
360 videoButtons[i].isHeld = FALSE;
361 if ( !videoButtons[i].isToggle )
362 {
363 setToggleButton( i, FALSE );
364 }
365 qDebug("key %d", i);
366 switch(i)
367 {
368// case VideoPlay:
369// {
370// if( mediaPlayerState->isPaused )
371// {
372// setToggleButton( i, FALSE );
373// mediaPlayerState->setPaused( FALSE );
374// return;
375// }
376// else if( !mediaPlayerState->isPaused )
377// {
378// setToggleButton( i, TRUE );
379// mediaPlayerState->setPaused( TRUE );
380// return;
381// }
382// else
383// {
384// return;
385// }
386// }
387 423
388 case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; 424// } else {
389 case VideoStop: mediaPlayerState->setPlaying(FALSE); return;
390// case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return;
391 case VideoNext: mediaPlayerState->setNext(); return;
392 case VideoPrevious: mediaPlayerState->setPrev(); return;
393// case VideoPlayList: mediaPlayerState->setList(); return;
394 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
395
396// case VideoStop: mediaPlayerState->setPlaying( FALSE ); return;
397// case VideoNext: if(playList->whichList() ==0) mediaPlayerState->setNext(); return;
398// case VideoPrevious: if(playList->whichList() ==0) mediaPlayerState->setPrev(); return;
399// case VideoVolUp: emit moreReleased(); return;
400// case VideoVolDown: emit lessReleased(); return;
401// case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
402 }
403 }
404 }
405 }
406 425
426// if ( videoButtons[i].isHeld )
427// {
428// videoButtons[i].isHeld = FALSE;
429// if ( !videoButtons[i].isToggle ) {
430// setToggleButton( i, FALSE );
431// }
432// qDebug("key %d", i);
433// switch(i) {
434// case VideoPlay:
435// {
436// if( mediaPlayerState->isPaused ) {
437// setToggleButton( i, FALSE );
438// mediaPlayerState->setPaused( FALSE );
439// return;
440// }
441// else if( !mediaPlayerState->isPaused ) {
442// setToggleButton( i, TRUE );
443// mediaPlayerState->setPaused( TRUE );
444// return;
445// } else {
446// return;
447// }
448// }
449
450// case VideoStop: mediaPlayerState->setPlaying(FALSE); return;
451// // case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return;
452// // case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return;
453// case VideoNext: mediaPlayerState->setNext(); return;
454// case VideoPrevious: mediaPlayerState->setPrev(); return;
455// case VideoVolUp: emit moreReleased(); return;
456// case VideoVolDown: emit lessReleased(); return;
457// // case VideoPlayList: mediaPlayerState->setList(); return;
458// case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
459// }
460// }
461// }
462// }
407 463
408 464
409 465
410 466
411 467
412// for ( int i = 0; i < numButtons; i++ ) { 468// for ( int i = 0; i < numButtons; i++ ) {
413// int x = videoButtons[i].xPos; 469// int x = videoButtons[i].xPos;
414// int y = videoButtons[i].yPos; 470// int y = videoButtons[i].yPos;
415// if ( event->state() == QMouseEvent::LeftButton ) { 471// if ( event->state() == QMouseEvent::LeftButton ) {
416// // The test to see if the mouse click is inside the circular button or not 472// // The test to see if the mouse click is inside the circular button or not
417// // (compared with the radius squared to avoid a square-root of our distance) 473// // (compared with the radius squared to avoid a square-root of our distance)
418// int radius = 16; 474// int radius = 16;
419// QPoint center = QPoint( x + radius, y + radius ); 475// QPoint center = QPoint( x + radius, y + radius );
420// QPoint dXY = center - event->pos(); 476// QPoint dXY = center - event->pos();
421// int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); 477// int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y();
422// bool isOnButton = dist <= (radius * radius); 478// bool isOnButton = dist <= (radius * radius);
423// if ( isOnButton != videoButtons[i].isHeld ) { 479// if ( isOnButton != videoButtons[i].isHeld ) {
424// videoButtons[i].isHeld = isOnButton; 480// videoButtons[i].isHeld = isOnButton;
425// toggleButton(i); 481// toggleButton(i);
426// } 482// }
427// } else { 483// } else {
428// if ( videoButtons[i].isHeld ) { 484// if ( videoButtons[i].isHeld ) {
429// videoButtons[i].isHeld = FALSE; 485// videoButtons[i].isHeld = FALSE;
430// if ( !videoButtons[i].isToggle ) 486// if ( !videoButtons[i].isToggle )
431// setToggleButton( i, FALSE ); 487// setToggleButton( i, FALSE );
432// } 488// }
433// } 489// }
434 490
435// switch (i) {
436// case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return;
437// case VideoStop: mediaPlayerState->setPlaying(FALSE); return;
438// case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return;
439// case VideoNext: mediaPlayerState->setNext(); return;
440// case VideoPrevious: mediaPlayerState->setPrev(); return;
441// case VideoPlayList: mediaPlayerState->setList(); return;
442// case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
443// }
444 491
445// } 492// }
446} 493}
447 494
448 495
449void VideoWidget::mousePressEvent( QMouseEvent *event ) { 496void VideoWidget::mousePressEvent( QMouseEvent *event ) {
450 mouseMoveEvent( event ); 497 mouseMoveEvent( event );
451} 498}
452 499
453 500
454void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 501void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
455 if ( mediaPlayerState->fullscreen() ) 502 if ( mediaPlayerState->fullscreen() )
456 { 503 {
457 mediaPlayerState->setFullscreen( FALSE ); 504 mediaPlayerState->setFullscreen( FALSE );
458 makeVisible(); 505 makeVisible();
459
460 mouseMoveEvent( event );
461 } 506 }
507 mouseMoveEvent( event );
508// }
462} 509}
463 510
464 511
465void VideoWidget::makeVisible() { 512void VideoWidget::makeVisible() {
466 if ( mediaPlayerState->fullscreen() ) 513 if ( mediaPlayerState->fullscreen() )
467 { 514 {
468 setBackgroundMode( QWidget::NoBackground ); 515 setBackgroundMode( QWidget::NoBackground );
469 showFullScreen(); 516 showFullScreen();
470 resize( qApp->desktop()->size() ); 517 resize( qApp->desktop()->size() );
471 slider->hide(); 518 slider->hide();
472 } 519 }
473 else 520 else
474 { 521 {
475 setBackgroundPixmap( *pixBg ); 522 setBackgroundPixmap( *pixBg );
476 showNormal(); 523 showNormal();
477 showMaximized(); 524 showMaximized();
478 slider->show(); 525 slider->show();
479 } 526 }
480} 527}
481 528
482 529
483void VideoWidget::paintEvent( QPaintEvent * pe) { 530void VideoWidget::paintEvent( QPaintEvent * pe) {
484 QPainter p( this ); 531 QPainter p( this );
485 532
486 if ( mediaPlayerState->fullscreen() ) { 533 if ( mediaPlayerState->fullscreen() ) {
487 // Clear the background 534 // Clear the background
488 p.setBrush( QBrush( Qt::black ) ); 535 p.setBrush( QBrush( Qt::black ) );
489 p.drawRect( rect() ); 536 p.drawRect( rect() );
490 } else { 537 } else {
491 if ( !pe->erased() ) { 538 if ( !pe->erased() ) {
492 // Combine with background and double buffer 539 // Combine with background and double buffer
493 QPixmap pix( pe->rect().size() ); 540 QPixmap pix( pe->rect().size() );
494 QPainter p( &pix ); 541 QPainter p( &pix );
495 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 542 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
496 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); 543 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
497 for ( int i = 0; i < numVButtons; i++ ) { 544 for ( int i = 0; i < numVButtons; i++ ) {
498 paintButton( &p, i ); 545 paintButton( &p, i );
499 } 546 }
500 QPainter p2( this ); 547 QPainter p2( this );
501 p2.drawPixmap( pe->rect().topLeft(), pix ); 548 p2.drawPixmap( pe->rect().topLeft(), pix );
502 } else { 549 } else {
503 QPainter p( this ); 550 QPainter p( this );
504 for ( int i = 0; i < numVButtons; i++ ) 551 for ( int i = 0; i < numVButtons; i++ )
505 paintButton( &p, i ); 552 paintButton( &p, i );
506 } 553 }
507 slider->repaint( TRUE ); 554 slider->repaint( TRUE );
508 } 555 }
509} 556}
510 557
511 558
512void VideoWidget::closeEvent( QCloseEvent* ) { 559void VideoWidget::closeEvent( QCloseEvent* ) {
513 mediaPlayerState->setList(); 560 mediaPlayerState->setList();
514} 561}
515 562
516 563
517bool VideoWidget::playVideo() { 564bool VideoWidget::playVideo() {
518 bool result = FALSE; 565 bool result = FALSE;
519// qDebug("<<<<<<<<<<<<<<<< play video"); 566// qDebug("<<<<<<<<<<<<<<<< play video");
520 int stream = 0; 567 int stream = 0;
521 568
522 int sw = mediaPlayerState->curDecoder()->videoWidth( stream ); 569 int sw = mediaPlayerState->curDecoder()->videoWidth( stream );
523 int sh = mediaPlayerState->curDecoder()->videoHeight( stream ); 570 int sh = mediaPlayerState->curDecoder()->videoHeight( stream );
524 int dd = QPixmap::defaultDepth(); 571 int dd = QPixmap::defaultDepth();
525 int w = height(); 572 int w = height();
526 int h = width(); 573 int h = width();
527 574
528 ColorFormat format = (dd == 16) ? RGB565 : BGRA8888; 575 ColorFormat format = (dd == 16) ? RGB565 : BGRA8888;
529 576
530 if ( mediaPlayerState->fullscreen() ) 577 if ( mediaPlayerState->fullscreen() )
531 { 578 {
532#ifdef USE_DIRECT_PAINTER 579#ifdef USE_DIRECT_PAINTER
533 QDirectPainter p(this); 580 QDirectPainter p(this);
534 581
535 if ( ( qt_screen->transformOrientation() == 3 ) && 582 if ( ( qt_screen->transformOrientation() == 3 ) &&
536 ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) ) 583 ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) )
537 { 584 {
538 585
539 w = 320; 586 w = 320;
540 h = 240; 587 h = 240;
541 588
542 if ( mediaPlayerState->scaled() ) 589 if ( mediaPlayerState->scaled() )
543 { 590 {
544 // maintain aspect ratio 591 // maintain aspect ratio
545 if ( w * sh > sw * h ) 592 if ( w * sh > sw * h )
546 w = sw * h / sh; 593 w = sw * h / sh;
547 else 594 else
548 h = sh * w / sw; 595 h = sh * w / sw;
549 } 596 }
550 else 597 else
551 { 598 {
552 w = sw; 599 w = sw;
553 h = sh; 600 h = sh;
554 } 601 }
555 602
556 w--; // we can't allow libmpeg to overwrite. 603 w--; // we can't allow libmpeg to overwrite.
557 QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) ); 604 QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) );
558 605
559 int ox = roff.x() - height() + 2 + (height() - w) / 2; 606 int ox = roff.x() - height() + 2 + (height() - w) / 2;
560 int oy = roff.y() + (width() - h) / 2; 607 int oy = roff.y() + (width() - h) / 2;
561 int sx = 0, sy = 0; 608 int sx = 0, sy = 0;
562 609
563 uchar* fp = p.frameBuffer() + p.lineStep() * oy; 610 uchar* fp = p.frameBuffer() + p.lineStep() * oy;
564 fp += dd * ox / 8; 611 fp += dd * ox / 8;
565 uchar **jt = new uchar*[h]; 612 uchar **jt = new uchar*[h];
566 613
567 for ( int i = h; i; i-- ) 614 for ( int i = h; i; i-- )
568 { 615 {
569 jt[h - i] = fp; 616 jt[h - i] = fp;
570 fp += p.lineStep(); 617 fp += p.lineStep();
571 } 618 }
572 619
573 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0; 620 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0;
574 621
575 delete [] jt; 622 delete [] jt;
576 } 623 }
577 else 624 else
578 { 625 {
579#endif 626#endif
580 QPainter p(this); 627 QPainter p(this);
581 628
582 w = 320; 629 w = 320;
583 h = 240; 630 h = 240;
584 631
585 if ( mediaPlayerState->scaled() ) 632 if ( mediaPlayerState->scaled() )
586 { 633 {
587 // maintain aspect ratio 634 // maintain aspect ratio
588 if ( w * sh > sw * h ) 635 if ( w * sh > sw * h )
589 w = sw * h / sh; 636 w = sw * h / sh;
590 else 637 else
591 h = sh * w / sw; 638 h = sh * w / sw;
592 } 639 }
593 else 640 else
594 { 641 {
595 w = sw; 642 w = sw;
596 h = sh; 643 h = sh;
597 } 644 }
598 645
599 int bytes = ( dd == 16 ) ? 2 : 4; 646 int bytes = ( dd == 16 ) ? 2 : 4;
600 QImage tempFrame( w, h, bytes << 3 ); 647 QImage tempFrame( w, h, bytes << 3 );
601 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(), 648 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(),
602 0, 0, sw, sh, w, h, format, 0) == 0; 649 0, 0, sw, sh, w, h, format, 0) == 0;
603 650
604 if ( result && mediaPlayerState->fullscreen() ) 651 if ( result && mediaPlayerState->fullscreen() )
605 { 652 {
606 653
607 int rw = h, rh = w; 654 int rw = h, rh = w;
608 QImage rotatedFrame( rw, rh, bytes << 3 ); 655 QImage rotatedFrame( rw, rh, bytes << 3 );
609 656
610 ushort* in = (ushort*)tempFrame.bits(); 657 ushort* in = (ushort*)tempFrame.bits();
611 ushort* out = (ushort*)rotatedFrame.bits(); 658 ushort* out = (ushort*)rotatedFrame.bits();
612 int spl = rotatedFrame.bytesPerLine() / bytes; 659 int spl = rotatedFrame.bytesPerLine() / bytes;
613 660
614 for (int x=0; x<h; x++) 661 for (int x=0; x<h; x++)
615 { 662 {
616 if ( bytes == 2 ) 663 if ( bytes == 2 )
617 { 664 {
618 ushort* lout = out++ + (w - 1)*spl; 665 ushort* lout = out++ + (w - 1)*spl;
619 for (int y=0; y<w; y++) { 666 for (int y=0; y<w; y++) {
620 *lout=*in++; 667 *lout=*in++;
621 lout-=spl; 668 lout-=spl;
622 } 669 }
623 } 670 }
624 else 671 else
625 { 672 {
626 ulong* lout = ((ulong *)out)++ + (w - 1)*spl; 673 ulong* lout = ((ulong *)out)++ + (w - 1)*spl;
627 for (int y=0; y<w; y++) 674 for (int y=0; y<w; y++)
628 { 675 {
629 *lout=*((ulong*)in)++; 676 *lout=*((ulong*)in)++;
630 lout-=spl; 677 lout-=spl;
631 } 678 }
632 } 679 }
633 } 680 }
634 681
635 p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh ); 682 p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh );
636 } 683 }
637#ifdef USE_DIRECT_PAINTER 684#ifdef USE_DIRECT_PAINTER
638 } 685 }
639#endif 686#endif
640 } 687 }
641 else 688 else
642 { 689 {
643 690
644 w = 220; 691 w = 220;
645 h = 160; 692 h = 160;
646 693
647 // maintain aspect ratio 694 // maintain aspect ratio
648 if ( w * sh > sw * h ) 695 if ( w * sh > sw * h )
649 w = sw * h / sh; 696 w = sw * h / sh;
650 else 697 else
651 h = sh * w / sw; 698 h = sh * w / sw;
652 699
653 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0; 700 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0;
diff --git a/core/multimedia/opieplayer/videowidget.h b/core/multimedia/opieplayer/videowidget.h
index fd86cd2..e9778f1 100644
--- a/core/multimedia/opieplayer/videowidget.h
+++ b/core/multimedia/opieplayer/videowidget.h
@@ -1,99 +1,105 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef VIDEO_WIDGET_H 20#ifndef VIDEO_WIDGET_H
21#define VIDEO_WIDGET_H 21#define VIDEO_WIDGET_H
22 22
23 23
24#include <qwidget.h> 24#include <qwidget.h>
25 25
26class QPixmap; 26class QPixmap;
27class QSlider; 27class QSlider;
28 28
29 29
30enum VideoButtons { 30enum VideoButtons {
31 VideoPrevious,
32 VideoStop, 31 VideoStop,
33 VideoPlay, 32 VideoPlay,
34 VideoPause, 33// VideoPause,
34 VideoPrevious,
35 VideoNext, 35 VideoNext,
36 VideoPlayList, 36 VideoVolUp,
37 VideoVolDown,
38// VideoPlayList,
37 VideoFullscreen 39 VideoFullscreen
38}; 40};
39 41
40class VideoWidget : public QWidget { 42class VideoWidget : public QWidget {
41 Q_OBJECT 43 Q_OBJECT
42public: 44public:
43 VideoWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); 45 VideoWidget( QWidget* parent=0, const char* name=0, WFlags f=0 );
44 ~VideoWidget(); 46 ~VideoWidget();
45 47
46 bool playVideo(); 48 bool playVideo();
47 49
48public slots: 50public slots:
49 void updateSlider( long, long ); 51 void updateSlider( long, long );
50 void sliderPressed( ); 52 void sliderPressed( );
51 void sliderReleased( ); 53 void sliderReleased( );
52 void setPaused( bool b) { setToggleButton( VideoPause, b ); } 54// void setPaused( bool b) { setToggleButton( VideoPause, b ); }
53 void setPlaying( bool b) { setToggleButton( VideoPlay, b ); } 55 void setPlaying( bool b) { setToggleButton( VideoPlay, b ); }
54 void setFullscreen( bool b ) { setToggleButton( VideoFullscreen, b ); } 56 void setFullscreen( bool b ) { setToggleButton( VideoFullscreen, b ); }
55 void makeVisible(); 57 void makeVisible();
56 void setPosition( long ); 58 void setPosition( long );
57 void setLength( long ); 59 void setLength( long );
58 void setView( char ); 60 void setView( char );
59 61
60signals: 62signals:
63 void moreClicked();
64 void lessClicked();
65 void moreReleased();
66 void lessReleased();
61 void sliderMoved( long ); 67 void sliderMoved( long );
62 68
63protected: 69protected:
64 void resizeEvent( QResizeEvent * ); 70 void resizeEvent( QResizeEvent * );
65 void paintEvent( QPaintEvent *pe ); 71 void paintEvent( QPaintEvent *pe );
66 void mouseMoveEvent( QMouseEvent *event ); 72 void mouseMoveEvent( QMouseEvent *event );
67 void mousePressEvent( QMouseEvent *event ); 73 void mousePressEvent( QMouseEvent *event );
68 void mouseReleaseEvent( QMouseEvent *event ); 74 void mouseReleaseEvent( QMouseEvent *event );
69 void closeEvent( QCloseEvent *event ); 75 void closeEvent( QCloseEvent *event );
70 void keyReleaseEvent( QKeyEvent *e); 76 void keyReleaseEvent( QKeyEvent *e);
71 77
72private: 78private:
73 QPixmap *pixBg; 79 QPixmap *pixBg;
74 QImage *imgUp; 80 QImage *imgUp;
75 QImage *imgDn; 81 QImage *imgDn;
76 QImage *imgButtonMask; 82 QImage *imgButtonMask;
77 QBitmap *masks[7]; 83 QBitmap *masks[7];
78 QString backgroundPix; 84 QString backgroundPix;
79 QPixmap *buttonPixUp[7]; 85 QPixmap *buttonPixUp[7];
80 QPixmap *buttonPixDown[7]; 86 QPixmap *buttonPixDown[7];
81 QString skin; 87 QString skin;
82 QSlider *slider; 88 QSlider *slider;
83 QPixmap *pixmaps[3]; 89 QPixmap *pixmaps[3];
84 QImage *currentFrame; 90 QImage *currentFrame;
85 int xoff, yoff; 91 int xoff, yoff;
86 int scaledWidth; 92 int scaledWidth;
87 int scaledHeight; 93 int scaledHeight;
88 94
89 void paintButton( QPainter *p, int i ); 95 void paintButton( QPainter *p, int i );
90 void toggleButton( int ); 96 void toggleButton( int );
91 void setToggleButton( int, bool ); 97 void setToggleButton( int, bool );
92 98
93}; 99};
94 100
95 101
96#endif // VIDEO_WIDGET_H 102#endif // VIDEO_WIDGET_H
97 103
98 104
99 105