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