summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp6
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.h6
2 files changed, 6 insertions, 6 deletions
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 77eab71..2f51c82 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -1,494 +1,494 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include <qpe/qpeapplication.h> 34#include <qpe/qpeapplication.h>
35#include <qpe/resource.h> 35#include <qpe/resource.h>
36#include <qpe/config.h> 36#include <qpe/config.h>
37 37
38 38
39#include <qwidget.h> 39#include <qwidget.h>
40#include <qpainter.h> 40#include <qpainter.h>
41#include <qpixmap.h> 41#include <qpixmap.h>
42#include <qslider.h> 42#include <qslider.h>
43#include <qdrawutil.h> 43#include <qdrawutil.h>
44#include "videowidget.h" 44#include "videowidget.h"
45#include "mediaplayerstate.h" 45#include "mediaplayerstate.h"
46#include "playlistwidget.h" 46#include "playlistwidget.h"
47 47
48 48
49#ifdef Q_WS_QWS 49#ifdef Q_WS_QWS
50# define USE_DIRECT_PAINTER 50# define USE_DIRECT_PAINTER
51# include <qdirectpainter_qws.h> 51# include <qdirectpainter_qws.h>
52# include <qgfxraster_qws.h> 52# include <qgfxraster_qws.h>
53#endif 53#endif
54 54
55 55
56namespace 56namespace
57{ 57{
58 58
59const int xo = 2; // movable x offset 59const int xo = 2; // movable x offset
60const int yo = 0; // movable y offset 60const int yo = 0; // movable y offset
61 61
62const char * const skinV_mask_file_names[7] = { 62const char * const skinV_mask_file_names[7] = {
63"stop","play","back","fwd","up","down","full" 63"play","stop","fwd","back","up","down","full"
64}; 64};
65 65
66} 66}
67 67
68VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) 68VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name )
69 : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) 69 : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 )
70{ 70{
71 setCaption( tr("OpiePlayer - Video") ); 71 setCaption( tr("OpiePlayer - Video") );
72 72
73 Button defaultButton; 73 Button defaultButton;
74 defaultButton.isToggle = defaultButton.isHeld = defaultButton.isDown = false; 74 defaultButton.isToggle = defaultButton.isHeld = defaultButton.isDown = false;
75 Button toggleButton; 75 Button toggleButton;
76 toggleButton.isToggle = true; 76 toggleButton.isToggle = true;
77 toggleButton.isHeld = toggleButton.isDown = false; 77 toggleButton.isHeld = toggleButton.isDown = false;
78 78
79 buttons.reserve( 7 ); 79 buttons.reserve( 7 );
80 buttons.push_back( defaultButton ); // stop
81 buttons.push_back( toggleButton ); // play 80 buttons.push_back( toggleButton ); // play
82 buttons.push_back( defaultButton ); // previous 81 buttons.push_back( defaultButton ); // stop
83 buttons.push_back( defaultButton ); // next 82 buttons.push_back( defaultButton ); // next
83 buttons.push_back( defaultButton ); // previous
84 buttons.push_back( defaultButton ); // volUp 84 buttons.push_back( defaultButton ); // volUp
85 buttons.push_back( defaultButton ); // volDown 85 buttons.push_back( defaultButton ); // volDown
86 buttons.push_back( toggleButton ); //fullscreen 86 buttons.push_back( toggleButton ); //fullscreen
87 87
88 videoFrame = new XineVideoWidget ( this, "Video frame" ); 88 videoFrame = new XineVideoWidget ( this, "Video frame" );
89 89
90 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); 90 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & )));
91 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); 91 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) );
92 92
93 Config cfg("OpiePlayer"); 93 Config cfg("OpiePlayer");
94 cfg.setGroup("Options"); 94 cfg.setGroup("Options");
95 skin = cfg.readEntry("Skin","default"); 95 skin = cfg.readEntry("Skin","default");
96 96
97 QString skinPath = "opieplayer2/skins/" + skin; 97 QString skinPath = "opieplayer2/skins/" + skin;
98 pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 98 pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
99 imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); 99 imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) );
100 imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); 100 imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) );
101 101
102 buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); 102 buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 );
103 buttonMask.fill( 0 ); 103 buttonMask.fill( 0 );
104 104
105 for ( int i = 0; i < 7; i++ ) { 105 for ( int i = 0; i < 7; i++ ) {
106 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); 106 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" );
107 masks[i] = new QBitmap( filename ); 107 masks[i] = new QBitmap( filename );
108 108
109 if ( !masks[i]->isNull() ) { 109 if ( !masks[i]->isNull() ) {
110 QImage imgMask = masks[i]->convertToImage(); 110 QImage imgMask = masks[i]->convertToImage();
111 uchar **dest = buttonMask.jumpTable(); 111 uchar **dest = buttonMask.jumpTable();
112 for ( int y = 0; y < imgUp.height(); y++ ) { 112 for ( int y = 0; y < imgUp.height(); y++ ) {
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 if ( !qRed( imgMask.pixel( x, y ) ) ) 115 if ( !qRed( imgMask.pixel( x, y ) ) )
116 line[x] = i + 1; 116 line[x] = i + 1;
117 } 117 }
118 } 118 }
119 } 119 }
120 } 120 }
121 121
122 for ( int i = 0; i < 7; i++ ) { 122 for ( int i = 0; i < 7; i++ ) {
123 buttonPixUp[i] = NULL; 123 buttonPixUp[i] = NULL;
124 buttonPixDown[i] = NULL; 124 buttonPixDown[i] = NULL;
125 } 125 }
126 126
127 setBackgroundPixmap( pixBg ); 127 setBackgroundPixmap( pixBg );
128 128
129 slider = new QSlider( Qt::Horizontal, this ); 129 slider = new QSlider( Qt::Horizontal, this );
130 slider->setMinValue( 0 ); 130 slider->setMinValue( 0 );
131 slider->setMaxValue( 1 ); 131 slider->setMaxValue( 1 );
132 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 132 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
133 //slider->setFocusPolicy( QWidget::NoFocus ); 133 //slider->setFocusPolicy( QWidget::NoFocus );
134 134
135 resizeEvent( NULL ); 135 resizeEvent( NULL );
136 136
137 setLength( mediaPlayerState.length() ); 137 setLength( mediaPlayerState.length() );
138 setPosition( mediaPlayerState.position() ); 138 setPosition( mediaPlayerState.position() );
139 setFullscreen( mediaPlayerState.isFullscreen() ); 139 setFullscreen( mediaPlayerState.isFullscreen() );
140 setPlaying( mediaPlayerState.isPlaying() ); 140 setPlaying( mediaPlayerState.isPlaying() );
141} 141}
142 142
143 143
144VideoWidget::~VideoWidget() { 144VideoWidget::~VideoWidget() {
145 145
146 for ( int i = 0; i < 7; i++ ) { 146 for ( int i = 0; i < 7; i++ ) {
147 delete buttonPixUp[i]; 147 delete buttonPixUp[i];
148 delete buttonPixDown[i]; 148 delete buttonPixDown[i];
149 } 149 }
150 150
151 for ( int i = 0; i < 7; i++ ) { 151 for ( int i = 0; i < 7; i++ ) {
152 delete masks[i]; 152 delete masks[i];
153 } 153 }
154 154
155} 155}
156 156
157QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 157QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
158 QPixmap pix( img.width(), img.height() ); 158 QPixmap pix( img.width(), img.height() );
159 QPainter p( &pix ); 159 QPainter p( &pix );
160 p.drawTiledPixmap( pix.rect(), bg, offset ); 160 p.drawTiledPixmap( pix.rect(), bg, offset );
161 p.drawImage( 0, 0, img ); 161 p.drawImage( 0, 0, img );
162 return new QPixmap( pix ); 162 return new QPixmap( pix );
163} 163}
164 164
165QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { 165QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) {
166 QPixmap *pixmap = new QPixmap( pix ); 166 QPixmap *pixmap = new QPixmap( pix );
167 pixmap->setMask( mask ); 167 pixmap->setMask( mask );
168 return pixmap; 168 return pixmap;
169} 169}
170 170
171void VideoWidget::resizeEvent( QResizeEvent * ) { 171void VideoWidget::resizeEvent( QResizeEvent * ) {
172 int h = height(); 172 int h = height();
173 int w = width(); 173 int w = width();
174 //int Vh = 160; 174 //int Vh = 160;
175 //int Vw = 220; 175 //int Vw = 220;
176 176
177 slider->setFixedWidth( w - 20 ); 177 slider->setFixedWidth( w - 20 );
178 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 178 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
179 slider->setBackgroundOrigin( QWidget::ParentOrigin ); 179 slider->setBackgroundOrigin( QWidget::ParentOrigin );
180 slider->setFocusPolicy( QWidget::NoFocus ); 180 slider->setFocusPolicy( QWidget::NoFocus );
181 slider->setBackgroundPixmap( pixBg ); 181 slider->setBackgroundPixmap( pixBg );
182 182
183 upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; 183 upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2;
184 if(w>h) 184 if(w>h)
185 upperLeftOfButtonMask.ry() = 0; 185 upperLeftOfButtonMask.ry() = 0;
186 else 186 else
187 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; 187 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10;
188 QPoint p = upperLeftOfButtonMask; 188 QPoint p = upperLeftOfButtonMask;
189 189
190 QPixmap *pixUp = combineVImageWithBackground( imgUp, pixBg, p ); 190 QPixmap *pixUp = combineVImageWithBackground( imgUp, pixBg, p );
191 QPixmap *pixDn = combineVImageWithBackground( imgDn, pixBg, p ); 191 QPixmap *pixDn = combineVImageWithBackground( imgDn, pixBg, p );
192 192
193 for ( int i = 0; i < 7; i++ ) { 193 for ( int i = 0; i < 7; i++ ) {
194 if ( !masks[i]->isNull() ) { 194 if ( !masks[i]->isNull() ) {
195 delete buttonPixUp[i]; 195 delete buttonPixUp[i];
196 delete buttonPixDown[i]; 196 delete buttonPixDown[i];
197 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); 197 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] );
198 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); 198 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] );
199 } 199 }
200 } 200 }
201 201
202 delete pixUp; 202 delete pixUp;
203 delete pixDn; 203 delete pixDn;
204} 204}
205 205
206static bool videoSliderBeingMoved = FALSE; 206static bool videoSliderBeingMoved = FALSE;
207 207
208void VideoWidget::sliderPressed() { 208void VideoWidget::sliderPressed() {
209 videoSliderBeingMoved = TRUE; 209 videoSliderBeingMoved = TRUE;
210} 210}
211 211
212void VideoWidget::sliderReleased() { 212void VideoWidget::sliderReleased() {
213 videoSliderBeingMoved = FALSE; 213 videoSliderBeingMoved = FALSE;
214 if ( slider->width() == 0 ) { 214 if ( slider->width() == 0 ) {
215 return; 215 return;
216 } 216 }
217 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); 217 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width());
218 mediaPlayerState.setPosition( val ); 218 mediaPlayerState.setPosition( val );
219} 219}
220 220
221void VideoWidget::setPosition( long i ) { 221void VideoWidget::setPosition( long i ) {
222 updateSlider( i, mediaPlayerState.length() ); 222 updateSlider( i, mediaPlayerState.length() );
223} 223}
224 224
225 225
226void VideoWidget::setLength( long max ) { 226void VideoWidget::setLength( long max ) {
227 updateSlider( mediaPlayerState.position(), max ); 227 updateSlider( mediaPlayerState.position(), max );
228} 228}
229 229
230void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) 230void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType )
231{ 231{
232 if ( displayType == MediaPlayerState::Video ) { 232 if ( displayType == MediaPlayerState::Video ) {
233 makeVisible(); 233 makeVisible();
234 return; 234 return;
235 } 235 }
236 236
237 // Effectively blank the view next time we show it so it looks nicer 237 // Effectively blank the view next time we show it so it looks nicer
238 scaledWidth = 0; 238 scaledWidth = 0;
239 scaledHeight = 0; 239 scaledHeight = 0;
240 hide(); 240 hide();
241} 241}
242 242
243void VideoWidget::updateSlider( long i, long max ) { 243void VideoWidget::updateSlider( long i, long max ) {
244 // Will flicker too much if we don't do this 244 // Will flicker too much if we don't do this
245 if ( max == 0 ) { 245 if ( max == 0 ) {
246 return; 246 return;
247 } 247 }
248 int width = slider->width(); 248 int width = slider->width();
249 int val = int((double)i * width / max); 249 int val = int((double)i * width / max);
250 if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { 250 if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) {
251 if ( slider->value() != val ) { 251 if ( slider->value() != val ) {
252 slider->setValue( val ); 252 slider->setValue( val );
253 } 253 }
254 if ( slider->maxValue() != width ) { 254 if ( slider->maxValue() != width ) {
255 slider->setMaxValue( width ); 255 slider->setMaxValue( width );
256 } 256 }
257 } 257 }
258} 258}
259 259
260void VideoWidget::setToggleButton( int i, bool down ) { 260void VideoWidget::setToggleButton( int i, bool down ) {
261 if ( down != buttons[i].isDown ) { 261 if ( down != buttons[i].isDown ) {
262 toggleButton( i ); 262 toggleButton( i );
263 } 263 }
264} 264}
265 265
266void VideoWidget::paintButton( QPainter &p, int i ) { 266void VideoWidget::paintButton( QPainter &p, int i ) {
267 267
268 if ( buttons[i].isDown ) { 268 if ( buttons[i].isDown ) {
269 p.drawPixmap( upperLeftOfButtonMask, *buttonPixDown[i] ); 269 p.drawPixmap( upperLeftOfButtonMask, *buttonPixDown[i] );
270 } else { 270 } else {
271 p.drawPixmap( upperLeftOfButtonMask, *buttonPixUp[i] ); 271 p.drawPixmap( upperLeftOfButtonMask, *buttonPixUp[i] );
272 } 272 }
273} 273}
274 274
275void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 275void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
276 for ( unsigned int i = 0; i < buttons.size(); i++ ) { 276 for ( unsigned int i = 0; i < buttons.size(); i++ ) {
277 if ( event->state() == QMouseEvent::LeftButton ) { 277 if ( event->state() == QMouseEvent::LeftButton ) {
278 // The test to see if the mouse click is inside the button or not 278 // The test to see if the mouse click is inside the button or not
279 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); 279 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i );
280 280
281 if ( isOnButton && !buttons[i].isHeld ) { 281 if ( isOnButton && !buttons[i].isHeld ) {
282 buttons[i].isHeld = TRUE; 282 buttons[i].isHeld = TRUE;
283 toggleButton(i); 283 toggleButton(i);
284 284
285 switch (i) { 285 switch (i) {
286 case VideoVolUp: 286 case VideoVolUp:
287 emit moreClicked(); 287 emit moreClicked();
288 return; 288 return;
289 case VideoVolDown: 289 case VideoVolDown:
290 emit lessClicked(); 290 emit lessClicked();
291 return; 291 return;
292 } 292 }
293 } else if ( !isOnButton && buttons[i].isHeld ) { 293 } else if ( !isOnButton && buttons[i].isHeld ) {
294 buttons[i].isHeld = FALSE; 294 buttons[i].isHeld = FALSE;
295 toggleButton(i); 295 toggleButton(i);
296 } 296 }
297 } else { 297 } else {
298 298
299 if ( buttons[i].isHeld ) { 299 if ( buttons[i].isHeld ) {
300 buttons[i].isHeld = FALSE; 300 buttons[i].isHeld = FALSE;
301 if ( !buttons[i].isToggle ) { 301 if ( !buttons[i].isToggle ) {
302 setToggleButton( i, FALSE ); 302 setToggleButton( i, FALSE );
303 } 303 }
304 304
305 switch(i) { 305 switch(i) {
306 306
307 case VideoPlay: { 307 case VideoPlay: {
308 if( mediaPlayerState.isPaused() ) { 308 if( mediaPlayerState.isPaused() ) {
309 setToggleButton( i, FALSE ); 309 setToggleButton( i, FALSE );
310 mediaPlayerState.setPaused( FALSE ); 310 mediaPlayerState.setPaused( FALSE );
311 return; 311 return;
312 } else if( !mediaPlayerState.isPaused() ) { 312 } else if( !mediaPlayerState.isPaused() ) {
313 setToggleButton( i, TRUE ); 313 setToggleButton( i, TRUE );
314 mediaPlayerState.setPaused( TRUE ); 314 mediaPlayerState.setPaused( TRUE );
315 return; 315 return;
316 } else { 316 } else {
317 return; 317 return;
318 } 318 }
319 } 319 }
320 320
321 case VideoStop: mediaPlayerState.setPlaying( FALSE ); return; 321 case VideoStop: mediaPlayerState.setPlaying( FALSE ); return;
322 case VideoNext: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; 322 case VideoNext: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return;
323 case VideoPrevious: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; 323 case VideoPrevious: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return;
324 case VideoVolUp: emit moreReleased(); return; 324 case VideoVolUp: emit moreReleased(); return;
325 case VideoVolDown: emit lessReleased(); return; 325 case VideoVolDown: emit lessReleased(); return;
326 case VideoFullscreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return; 326 case VideoFullscreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return;
327 } 327 }
328 } 328 }
329 } 329 }
330 } 330 }
331} 331}
332 332
333void VideoWidget::mousePressEvent( QMouseEvent *event ) { 333void VideoWidget::mousePressEvent( QMouseEvent *event ) {
334 mouseMoveEvent( event ); 334 mouseMoveEvent( event );
335} 335}
336 336
337void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 337void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
338 if ( mediaPlayerState.isFullscreen() ) { 338 if ( mediaPlayerState.isFullscreen() ) {
339 mediaPlayerState.setFullscreen( FALSE ); 339 mediaPlayerState.setFullscreen( FALSE );
340 makeVisible(); 340 makeVisible();
341 } 341 }
342 mouseMoveEvent( event ); 342 mouseMoveEvent( event );
343} 343}
344 344
345void VideoWidget::showEvent( QShowEvent* ) { 345void VideoWidget::showEvent( QShowEvent* ) {
346 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 346 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
347 mouseMoveEvent( &event ); 347 mouseMoveEvent( &event );
348} 348}
349 349
350 350
351 void VideoWidget::backToNormal() { 351 void VideoWidget::backToNormal() {
352 mediaPlayerState.setFullscreen( FALSE ); 352 mediaPlayerState.setFullscreen( FALSE );
353 makeVisible(); 353 makeVisible();
354 } 354 }
355 355
356void VideoWidget::makeVisible() { 356void VideoWidget::makeVisible() {
357 if ( mediaPlayerState.isFullscreen() ) { 357 if ( mediaPlayerState.isFullscreen() ) {
358 setBackgroundMode( QWidget::NoBackground ); 358 setBackgroundMode( QWidget::NoBackground );
359 showFullScreen(); 359 showFullScreen();
360 resize( qApp->desktop()->size() ); 360 resize( qApp->desktop()->size() );
361 videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); 361 videoFrame-> setGeometry ( 0, 0, width ( ), height ( ));
362 362
363 slider->hide(); 363 slider->hide();
364 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 364 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
365 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 365 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
366 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 366 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
367 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 367 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
368 368
369 } else { 369 } else {
370 showNormal(); 370 showNormal();
371 showMaximized(); 371 showMaximized();
372 setBackgroundPixmap( pixBg ); 372 setBackgroundPixmap( pixBg );
373 QWidget *d = QApplication::desktop(); 373 QWidget *d = QApplication::desktop();
374 int w = d->width(); 374 int w = d->width();
375 int h = d->height(); 375 int h = d->height();
376 376
377 if(w>h) { 377 if(w>h) {
378 int newW=(w/2)-(246/2); //this will only work with 320x240 378 int newW=(w/2)-(246/2); //this will only work with 320x240
379 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); 379 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) );
380 } else { 380 } else {
381 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); 381 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) );
382 } 382 }
383 383
384 if ( !mediaPlayerState.isSeekable() ) { 384 if ( !mediaPlayerState.isSeekable() ) {
385 if( !slider->isHidden()) { 385 if( !slider->isHidden()) {
386 slider->hide(); 386 slider->hide();
387 } 387 }
388 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 388 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
389 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 389 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
390 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 390 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
391 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 391 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
392 } else { 392 } else {
393 slider->show(); 393 slider->show();
394 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 394 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
395 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 395 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
396 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 396 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
397 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 397 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
398 } 398 }
399 } 399 }
400} 400}
401 401
402 402
403 403
404 404
405void VideoWidget::paintEvent( QPaintEvent * pe) { 405void VideoWidget::paintEvent( QPaintEvent * pe) {
406 QPainter p( this ); 406 QPainter p( this );
407 407
408 if ( mediaPlayerState.isFullscreen() ) { 408 if ( mediaPlayerState.isFullscreen() ) {
409 // Clear the background 409 // Clear the background
410 p.setBrush( QBrush( Qt::black ) ); 410 p.setBrush( QBrush( Qt::black ) );
411 } else { 411 } else {
412 if ( !pe->erased() ) { 412 if ( !pe->erased() ) {
413 // Combine with background and double buffer 413 // Combine with background and double buffer
414 QPixmap pix( pe->rect().size() ); 414 QPixmap pix( pe->rect().size() );
415 QPainter p( &pix ); 415 QPainter p( &pix );
416 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 416 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
417 p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); 417 p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() );
418 for ( unsigned int i = 0; i < buttons.size(); i++ ) { 418 for ( unsigned int i = 0; i < buttons.size(); i++ ) {
419 paintButton( p, i ); 419 paintButton( p, i );
420 } 420 }
421 QPainter p2( this ); 421 QPainter p2( this );
422 p2.drawPixmap( pe->rect().topLeft(), pix ); 422 p2.drawPixmap( pe->rect().topLeft(), pix );
423 } else { 423 } else {
424 QPainter p( this ); 424 QPainter p( this );
425 for ( unsigned int i = 0; i < buttons.size(); i++ ) 425 for ( unsigned int i = 0; i < buttons.size(); i++ )
426 paintButton( p, i ); 426 paintButton( p, i );
427 } 427 }
428 //slider->repaint( TRUE ); 428 //slider->repaint( TRUE );
429 } 429 }
430} 430}
431 431
432 432
433void VideoWidget::keyReleaseEvent( QKeyEvent *e) { 433void VideoWidget::keyReleaseEvent( QKeyEvent *e) {
434 switch ( e->key() ) { 434 switch ( e->key() ) {
435////////////////////////////// Zaurus keys 435////////////////////////////// Zaurus keys
436 case Key_Home: 436 case Key_Home:
437 break; 437 break;
438 case Key_F9: //activity 438 case Key_F9: //activity
439 break; 439 break;
440 case Key_F10: //contacts 440 case Key_F10: //contacts
441// hide(); 441// hide();
442 break; 442 break;
443 case Key_F11: //menu 443 case Key_F11: //menu
444 break; 444 break;
445 case Key_F12: //home 445 case Key_F12: //home
446 break; 446 break;
447 case Key_F13: //mail 447 case Key_F13: //mail
448 break; 448 break;
449 case Key_Space: { 449 case Key_Space: {
450 if(mediaPlayerState.isPlaying()) { 450 if(mediaPlayerState.isPlaying()) {
451 mediaPlayerState.setPlaying(FALSE); 451 mediaPlayerState.setPlaying(FALSE);
452 } else { 452 } else {
453 mediaPlayerState.setPlaying(TRUE); 453 mediaPlayerState.setPlaying(TRUE);
454 } 454 }
455 } 455 }
456 break; 456 break;
457 case Key_Down: 457 case Key_Down:
458// toggleButton(6); 458// toggleButton(6);
459 emit lessClicked(); 459 emit lessClicked();
460 emit lessReleased(); 460 emit lessReleased();
461// toggleButton(6); 461// toggleButton(6);
462 break; 462 break;
463 case Key_Up: 463 case Key_Up:
464// toggleButton(5); 464// toggleButton(5);
465 emit moreClicked(); 465 emit moreClicked();
466 emit moreReleased(); 466 emit moreReleased();
467// toggleButton(5); 467// toggleButton(5);
468 break; 468 break;
469 case Key_Right: 469 case Key_Right:
470 mediaPlayerState.setNext(); 470 mediaPlayerState.setNext();
471 break; 471 break;
472 case Key_Left: 472 case Key_Left:
473 mediaPlayerState.setPrev(); 473 mediaPlayerState.setPrev();
474 break; 474 break;
475 case Key_Escape: 475 case Key_Escape:
476 break; 476 break;
477 477
478 }; 478 };
479} 479}
480 480
481XineVideoWidget* VideoWidget::vidWidget() { 481XineVideoWidget* VideoWidget::vidWidget() {
482 return videoFrame; 482 return videoFrame;
483} 483}
484 484
485 485
486void VideoWidget::setFullscreen ( bool b ) { 486void VideoWidget::setFullscreen ( bool b ) {
487 setToggleButton( VideoFullscreen, b ); 487 setToggleButton( VideoFullscreen, b );
488} 488}
489 489
490 490
491void VideoWidget::setPlaying( bool b) { 491void VideoWidget::setPlaying( bool b) {
492 setToggleButton( VideoPlay, b ); 492 setToggleButton( VideoPlay, b );
493} 493}
494 494
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h
index 24e8741..cb6171c 100644
--- a/noncore/multimedia/opieplayer2/videowidget.h
+++ b/noncore/multimedia/opieplayer2/videowidget.h
@@ -1,125 +1,125 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef VIDEO_WIDGET_H 34#ifndef VIDEO_WIDGET_H
35#define VIDEO_WIDGET_H 35#define VIDEO_WIDGET_H
36 36
37#include <qwidget.h> 37#include <qwidget.h>
38#include <qimage.h> 38#include <qimage.h>
39#include <qpixmap.h> 39#include <qpixmap.h>
40#include "xinevideowidget.h" 40#include "xinevideowidget.h"
41 41
42#include "mediawidget.h" 42#include "mediawidget.h"
43 43
44class QPixmap; 44class QPixmap;
45class QSlider; 45class QSlider;
46 46
47enum VideoButtons { 47enum VideoButtons {
48 VideoStop = 0, 48 VideoPlay = 0,
49 VideoPlay, 49 VideoStop,
50// VideoPause, 50// VideoPause,
51 VideoPrevious,
52 VideoNext, 51 VideoNext,
52 VideoPrevious,
53 VideoVolUp, 53 VideoVolUp,
54 VideoVolDown, 54 VideoVolDown,
55 VideoFullscreen 55 VideoFullscreen
56}; 56};
57 57
58class VideoWidget : public MediaWidget { 58class VideoWidget : public MediaWidget {
59 Q_OBJECT 59 Q_OBJECT
60public: 60public:
61 VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); 61 VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 );
62 ~VideoWidget(); 62 ~VideoWidget();
63 63
64 64
65 XineVideoWidget* vidWidget(); 65 XineVideoWidget* vidWidget();
66public slots: 66public slots:
67 void updateSlider( long, long ); 67 void updateSlider( long, long );
68 void sliderPressed( ); 68 void sliderPressed( );
69 void sliderReleased( ); 69 void sliderReleased( );
70 void setFullscreen( bool b ); 70 void setFullscreen( bool b );
71 void makeVisible(); 71 void makeVisible();
72 void backToNormal(); 72 void backToNormal();
73 void setPosition( long ); 73 void setPosition( long );
74 74
75public: 75public:
76 virtual void setPlaying( bool b); 76 virtual void setPlaying( bool b);
77 virtual void setLength( long ); 77 virtual void setLength( long );
78 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); 78 virtual void setDisplayType( MediaPlayerState::DisplayType displayType );
79 79
80signals: 80signals:
81 void moreClicked(); 81 void moreClicked();
82 void lessClicked(); 82 void lessClicked();
83 void moreReleased(); 83 void moreReleased();
84 void lessReleased(); 84 void lessReleased();
85 void sliderMoved( long ); 85 void sliderMoved( long );
86 void videoResized ( const QSize &s ); 86 void videoResized ( const QSize &s );
87 87
88protected: 88protected:
89 89
90 void resizeEvent( QResizeEvent * ); 90 void resizeEvent( QResizeEvent * );
91 void paintEvent( QPaintEvent *pe ); 91 void paintEvent( QPaintEvent *pe );
92 void showEvent( QShowEvent *se ); 92 void showEvent( QShowEvent *se );
93 void mouseMoveEvent( QMouseEvent *event ); 93 void mouseMoveEvent( QMouseEvent *event );
94 void mousePressEvent( QMouseEvent *event ); 94 void mousePressEvent( QMouseEvent *event );
95 void mouseReleaseEvent( QMouseEvent *event ); 95 void mouseReleaseEvent( QMouseEvent *event );
96 void keyReleaseEvent( QKeyEvent *e); 96 void keyReleaseEvent( QKeyEvent *e);
97 97
98private: 98private:
99// Ticker songInfo; 99// Ticker songInfo;
100 QPixmap pixBg; 100 QPixmap pixBg;
101 QImage imgUp; 101 QImage imgUp;
102 QImage imgDn; 102 QImage imgDn;
103 QBitmap *masks[7]; 103 QBitmap *masks[7];
104 QPixmap *buttonPixUp[7]; 104 QPixmap *buttonPixUp[7];
105 QPixmap *buttonPixDown[7]; 105 QPixmap *buttonPixDown[7];
106 QString skin; 106 QString skin;
107// QPixmap *pixmaps[4]; 107// QPixmap *pixmaps[4];
108 108
109 109
110 virtual void paintButton( QPainter &p, int i ); 110 virtual void paintButton( QPainter &p, int i );
111 void setToggleButton( int, bool ); 111 void setToggleButton( int, bool );
112 112
113 QString backgroundPix; 113 QString backgroundPix;
114 QSlider *slider; 114 QSlider *slider;
115 QPixmap *pixmaps[3]; 115 QPixmap *pixmaps[3];
116 QImage *currentFrame; 116 QImage *currentFrame;
117 int scaledWidth; 117 int scaledWidth;
118 int scaledHeight; 118 int scaledHeight;
119 XineVideoWidget* videoFrame; 119 XineVideoWidget* videoFrame;
120}; 120};
121 121
122#endif // VIDEO_WIDGET_H 122#endif // VIDEO_WIDGET_H
123 123
124 124
125 125