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