summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-09 15:04:10 (UTC)
committer simon <simon>2002-12-09 15:04:10 (UTC)
commitdcc1922ecb8c6816e4ae9ba7973f8653e482b2aa (patch) (unidiff)
tree5ff73aaf1ac1c59cde2e9ddafe8cebcddb162158
parentd3451a94e3a4425f9f1b1dcc3999259270780631 (diff)
downloadopie-dcc1922ecb8c6816e4ae9ba7973f8653e482b2aa.zip
opie-dcc1922ecb8c6816e4ae9ba7973f8653e482b2aa.tar.gz
opie-dcc1922ecb8c6816e4ae9ba7973f8653e482b2aa.tar.bz2
- getting rid of the buttonPixUp/Down arrays, reuse the Button structure
instead
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp32
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.h2
2 files changed, 12 insertions, 22 deletions
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 089ef6a..3baa087 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -1,489 +1,481 @@
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"play","stop","fwd","back","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 Button toggleButton = defaultButton; 74 Button toggleButton = defaultButton;
75 toggleButton.type = ToggleButton; 75 toggleButton.type = ToggleButton;
76 76
77 buttons.insert( 0, toggleButton ); // play 77 buttons.insert( 0, toggleButton ); // play
78 buttons.insert( 1, toggleButton ); // stop 78 buttons.insert( 1, toggleButton ); // stop
79 buttons.insert( 2, toggleButton ); // next 79 buttons.insert( 2, toggleButton ); // next
80 buttons.insert( 3, toggleButton ); // previous 80 buttons.insert( 3, toggleButton ); // previous
81 buttons.insert( 4, toggleButton ); // volUp 81 buttons.insert( 4, toggleButton ); // volUp
82 buttons.insert( 5, toggleButton ); // volDown 82 buttons.insert( 5, toggleButton ); // volDown
83 buttons.insert( 6, toggleButton ); // fullscreen 83 buttons.insert( 6, toggleButton ); // fullscreen
84 84
85 videoFrame = new XineVideoWidget ( this, "Video frame" ); 85 videoFrame = new XineVideoWidget ( this, "Video frame" );
86 86
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 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); 88 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) );
89 89
90 Config cfg("OpiePlayer"); 90 Config cfg("OpiePlayer");
91 cfg.setGroup("Options"); 91 cfg.setGroup("Options");
92 skin = cfg.readEntry("Skin","default"); 92 skin = cfg.readEntry("Skin","default");
93 93
94 QString skinPath = "opieplayer2/skins/" + skin; 94 QString skinPath = "opieplayer2/skins/" + skin;
95 pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 95 pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
96 imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); 96 imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) );
97 imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); 97 imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) );
98 98
99 buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); 99 buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 );
100 buttonMask.fill( 0 ); 100 buttonMask.fill( 0 );
101 101
102 for ( int i = 0; i < 7; i++ ) { 102 for ( int i = 0; i < 7; i++ ) {
103 Button &button = buttons[ i ]; 103 Button &button = buttons[ i ];
104 104
105 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); 105 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" );
106 button.mask = QBitmap( filename ); 106 button.mask = QBitmap( filename );
107 107
108 if ( !button.mask.isNull() ) { 108 if ( !button.mask.isNull() ) {
109 QImage imgMask = button.mask.convertToImage(); 109 QImage imgMask = button.mask.convertToImage();
110 uchar **dest = buttonMask.jumpTable(); 110 uchar **dest = buttonMask.jumpTable();
111 for ( int y = 0; y < imgUp.height(); y++ ) { 111 for ( int y = 0; y < imgUp.height(); y++ ) {
112 uchar *line = dest[y]; 112 uchar *line = dest[y];
113 for ( int x = 0; x < imgUp.width(); x++ ) { 113 for ( int x = 0; x < imgUp.width(); x++ ) {
114 if ( !qRed( imgMask.pixel( x, y ) ) ) 114 if ( !qRed( imgMask.pixel( x, y ) ) )
115 line[x] = i + 1; 115 line[x] = i + 1;
116 } 116 }
117 } 117 }
118 } 118 }
119 } 119 }
120 120
121 for ( int i = 0; i < 7; i++ ) {
122 buttonPixUp[i] = NULL;
123 buttonPixDown[i] = NULL;
124 }
125
126 setBackgroundPixmap( pixBg ); 121 setBackgroundPixmap( pixBg );
127 122
128 slider = new QSlider( Qt::Horizontal, this ); 123 slider = new QSlider( Qt::Horizontal, this );
129 slider->setMinValue( 0 ); 124 slider->setMinValue( 0 );
130 slider->setMaxValue( 1 ); 125 slider->setMaxValue( 1 );
131 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 126 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
132 //slider->setFocusPolicy( QWidget::NoFocus ); 127 //slider->setFocusPolicy( QWidget::NoFocus );
133 128
134 resizeEvent( NULL ); 129 resizeEvent( NULL );
135 130
136 setLength( mediaPlayerState.length() ); 131 setLength( mediaPlayerState.length() );
137 setPosition( mediaPlayerState.position() ); 132 setPosition( mediaPlayerState.position() );
138 setFullscreen( mediaPlayerState.isFullscreen() ); 133 setFullscreen( mediaPlayerState.isFullscreen() );
139 setPlaying( mediaPlayerState.isPlaying() ); 134 setPlaying( mediaPlayerState.isPlaying() );
140} 135}
141 136
142 137
143VideoWidget::~VideoWidget() { 138VideoWidget::~VideoWidget()
144 for ( int i = 0; i < 7; i++ ) { 139{
145 delete buttonPixUp[i];
146 delete buttonPixDown[i];
147 }
148} 140}
149 141
150QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 142QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
151 QPixmap pix( img.width(), img.height() ); 143 QPixmap pix( img.width(), img.height() );
152 QPainter p( &pix ); 144 QPainter p( &pix );
153 p.drawTiledPixmap( pix.rect(), bg, offset ); 145 p.drawTiledPixmap( pix.rect(), bg, offset );
154 p.drawImage( 0, 0, img ); 146 p.drawImage( 0, 0, img );
155 return new QPixmap( pix ); 147 return new QPixmap( pix );
156} 148}
157 149
158QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { 150QPixmap maskVPixToMask( QPixmap pix, QBitmap mask ) {
159 QPixmap *pixmap = new QPixmap( pix ); 151 QPixmap pixmap( pix );
160 pixmap->setMask( mask ); 152 pixmap.setMask( mask );
161 return pixmap; 153 return pixmap;
162} 154}
163 155
164void VideoWidget::resizeEvent( QResizeEvent * ) { 156void VideoWidget::resizeEvent( QResizeEvent * ) {
165 int h = height(); 157 int h = height();
166 int w = width(); 158 int w = width();
167 //int Vh = 160; 159 //int Vh = 160;
168 //int Vw = 220; 160 //int Vw = 220;
169 161
170 slider->setFixedWidth( w - 20 ); 162 slider->setFixedWidth( w - 20 );
171 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 163 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
172 slider->setBackgroundOrigin( QWidget::ParentOrigin ); 164 slider->setBackgroundOrigin( QWidget::ParentOrigin );
173 slider->setFocusPolicy( QWidget::NoFocus ); 165 slider->setFocusPolicy( QWidget::NoFocus );
174 slider->setBackgroundPixmap( pixBg ); 166 slider->setBackgroundPixmap( pixBg );
175 167
176 upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; 168 upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2;
177 if(w>h) 169 if(w>h)
178 upperLeftOfButtonMask.ry() = 0; 170 upperLeftOfButtonMask.ry() = 0;
179 else 171 else
180 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; 172 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10;
181 QPoint p = upperLeftOfButtonMask; 173 QPoint p = upperLeftOfButtonMask;
182 174
183 QPixmap *pixUp = combineVImageWithBackground( imgUp, pixBg, p ); 175 QPixmap *pixUp = combineVImageWithBackground( imgUp, pixBg, p );
184 QPixmap *pixDn = combineVImageWithBackground( imgDn, pixBg, p ); 176 QPixmap *pixDn = combineVImageWithBackground( imgDn, pixBg, p );
185 177
186 for ( int i = 0; i < 7; i++ ) { 178 for ( int i = 0; i < 7; i++ ) {
187 Button &button = buttons[ i ]; 179 Button &button = buttons[ i ];
188 180
189 if ( !button.mask.isNull() ) { 181 if ( !button.mask.isNull() ) {
190 delete buttonPixUp[i]; 182 button.pixUp = maskVPixToMask( *pixUp, button.mask );
191 delete buttonPixDown[i]; 183 button.pixDown = maskVPixToMask( *pixDn, button.mask );
192 buttonPixUp[i] = maskVPixToMask( *pixUp, button.mask );
193 buttonPixDown[i] = maskVPixToMask( *pixDn, button.mask );
194 } 184 }
195 } 185 }
196 186
197 delete pixUp; 187 delete pixUp;
198 delete pixDn; 188 delete pixDn;
199} 189}
200 190
201static bool videoSliderBeingMoved = FALSE; 191static bool videoSliderBeingMoved = FALSE;
202 192
203void VideoWidget::sliderPressed() { 193void VideoWidget::sliderPressed() {
204 videoSliderBeingMoved = TRUE; 194 videoSliderBeingMoved = TRUE;
205} 195}
206 196
207void VideoWidget::sliderReleased() { 197void VideoWidget::sliderReleased() {
208 videoSliderBeingMoved = FALSE; 198 videoSliderBeingMoved = FALSE;
209 if ( slider->width() == 0 ) { 199 if ( slider->width() == 0 ) {
210 return; 200 return;
211 } 201 }
212 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); 202 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width());
213 mediaPlayerState.setPosition( val ); 203 mediaPlayerState.setPosition( val );
214} 204}
215 205
216void VideoWidget::setPosition( long i ) { 206void VideoWidget::setPosition( long i ) {
217 updateSlider( i, mediaPlayerState.length() ); 207 updateSlider( i, mediaPlayerState.length() );
218} 208}
219 209
220 210
221void VideoWidget::setLength( long max ) { 211void VideoWidget::setLength( long max ) {
222 updateSlider( mediaPlayerState.position(), max ); 212 updateSlider( mediaPlayerState.position(), max );
223} 213}
224 214
225void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) 215void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType )
226{ 216{
227 if ( displayType == MediaPlayerState::Video ) { 217 if ( displayType == MediaPlayerState::Video ) {
228 makeVisible(); 218 makeVisible();
229 return; 219 return;
230 } 220 }
231 221
232 // Effectively blank the view next time we show it so it looks nicer 222 // Effectively blank the view next time we show it so it looks nicer
233 scaledWidth = 0; 223 scaledWidth = 0;
234 scaledHeight = 0; 224 scaledHeight = 0;
235 hide(); 225 hide();
236} 226}
237 227
238void VideoWidget::updateSlider( long i, long max ) { 228void VideoWidget::updateSlider( long i, long max ) {
239 // Will flicker too much if we don't do this 229 // Will flicker too much if we don't do this
240 if ( max == 0 ) { 230 if ( max == 0 ) {
241 return; 231 return;
242 } 232 }
243 int width = slider->width(); 233 int width = slider->width();
244 int val = int((double)i * width / max); 234 int val = int((double)i * width / max);
245 if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { 235 if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) {
246 if ( slider->value() != val ) { 236 if ( slider->value() != val ) {
247 slider->setValue( val ); 237 slider->setValue( val );
248 } 238 }
249 if ( slider->maxValue() != width ) { 239 if ( slider->maxValue() != width ) {
250 slider->setMaxValue( width ); 240 slider->setMaxValue( width );
251 } 241 }
252 } 242 }
253} 243}
254 244
255void VideoWidget::setToggleButton( int i, bool down ) { 245void VideoWidget::setToggleButton( int i, bool down ) {
256 if ( down != buttons[i].isDown ) { 246 if ( down != buttons[i].isDown ) {
257 toggleButton( i ); 247 toggleButton( i );
258 } 248 }
259} 249}
260 250
261void VideoWidget::paintButton( QPainter &p, int i ) { 251void VideoWidget::paintButton( QPainter &p, int i ) {
262 252
263 if ( buttons[i].isDown ) { 253 Button &button = buttons[ i ];
264 p.drawPixmap( upperLeftOfButtonMask, *buttonPixDown[i] ); 254
255 if ( button.isDown ) {
256 p.drawPixmap( upperLeftOfButtonMask, button.pixDown );
265 } else { 257 } else {
266 p.drawPixmap( upperLeftOfButtonMask, *buttonPixUp[i] ); 258 p.drawPixmap( upperLeftOfButtonMask, button.pixUp );
267 } 259 }
268} 260}
269 261
270void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 262void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
271 for ( unsigned int i = 0; i < buttons.count(); i++ ) { 263 for ( unsigned int i = 0; i < buttons.count(); i++ ) {
272 if ( event->state() == QMouseEvent::LeftButton ) { 264 if ( event->state() == QMouseEvent::LeftButton ) {
273 // The test to see if the mouse click is inside the button or not 265 // The test to see if the mouse click is inside the button or not
274 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); 266 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i );
275 267
276 if ( isOnButton && !buttons[i].isHeld ) { 268 if ( isOnButton && !buttons[i].isHeld ) {
277 buttons[i].isHeld = TRUE; 269 buttons[i].isHeld = TRUE;
278 toggleButton(i); 270 toggleButton(i);
279 271
280 switch (i) { 272 switch (i) {
281 case VideoVolUp: 273 case VideoVolUp:
282 emit moreClicked(); 274 emit moreClicked();
283 return; 275 return;
284 case VideoVolDown: 276 case VideoVolDown:
285 emit lessClicked(); 277 emit lessClicked();
286 return; 278 return;
287 } 279 }
288 } else if ( !isOnButton && buttons[i].isHeld ) { 280 } else if ( !isOnButton && buttons[i].isHeld ) {
289 buttons[i].isHeld = FALSE; 281 buttons[i].isHeld = FALSE;
290 toggleButton(i); 282 toggleButton(i);
291 } 283 }
292 } else { 284 } else {
293 285
294 if ( buttons[i].isHeld ) { 286 if ( buttons[i].isHeld ) {
295 buttons[i].isHeld = FALSE; 287 buttons[i].isHeld = FALSE;
296 if ( buttons[i].type != ToggleButton ) { 288 if ( buttons[i].type != ToggleButton ) {
297 setToggleButton( i, FALSE ); 289 setToggleButton( i, FALSE );
298 } 290 }
299 291
300 switch(i) { 292 switch(i) {
301 293
302 case VideoPlay: { 294 case VideoPlay: {
303 if( mediaPlayerState.isPaused() ) { 295 if( mediaPlayerState.isPaused() ) {
304 setToggleButton( i, FALSE ); 296 setToggleButton( i, FALSE );
305 mediaPlayerState.setPaused( FALSE ); 297 mediaPlayerState.setPaused( FALSE );
306 return; 298 return;
307 } else if( !mediaPlayerState.isPaused() ) { 299 } else if( !mediaPlayerState.isPaused() ) {
308 setToggleButton( i, TRUE ); 300 setToggleButton( i, TRUE );
309 mediaPlayerState.setPaused( TRUE ); 301 mediaPlayerState.setPaused( TRUE );
310 return; 302 return;
311 } else { 303 } else {
312 return; 304 return;
313 } 305 }
314 } 306 }
315 307
316 case VideoStop: mediaPlayerState.setPlaying( FALSE ); return; 308 case VideoStop: mediaPlayerState.setPlaying( FALSE ); return;
317 case VideoNext: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; 309 case VideoNext: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return;
318 case VideoPrevious: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; 310 case VideoPrevious: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return;
319 case VideoVolUp: emit moreReleased(); return; 311 case VideoVolUp: emit moreReleased(); return;
320 case VideoVolDown: emit lessReleased(); return; 312 case VideoVolDown: emit lessReleased(); return;
321 case VideoFullscreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return; 313 case VideoFullscreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return;
322 } 314 }
323 } 315 }
324 } 316 }
325 } 317 }
326} 318}
327 319
328void VideoWidget::mousePressEvent( QMouseEvent *event ) { 320void VideoWidget::mousePressEvent( QMouseEvent *event ) {
329 mouseMoveEvent( event ); 321 mouseMoveEvent( event );
330} 322}
331 323
332void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 324void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
333 if ( mediaPlayerState.isFullscreen() ) { 325 if ( mediaPlayerState.isFullscreen() ) {
334 mediaPlayerState.setFullscreen( FALSE ); 326 mediaPlayerState.setFullscreen( FALSE );
335 makeVisible(); 327 makeVisible();
336 } 328 }
337 mouseMoveEvent( event ); 329 mouseMoveEvent( event );
338} 330}
339 331
340void VideoWidget::showEvent( QShowEvent* ) { 332void VideoWidget::showEvent( QShowEvent* ) {
341 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 333 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
342 mouseMoveEvent( &event ); 334 mouseMoveEvent( &event );
343} 335}
344 336
345 337
346 void VideoWidget::backToNormal() { 338 void VideoWidget::backToNormal() {
347 mediaPlayerState.setFullscreen( FALSE ); 339 mediaPlayerState.setFullscreen( FALSE );
348 makeVisible(); 340 makeVisible();
349 } 341 }
350 342
351void VideoWidget::makeVisible() { 343void VideoWidget::makeVisible() {
352 if ( mediaPlayerState.isFullscreen() ) { 344 if ( mediaPlayerState.isFullscreen() ) {
353 setBackgroundMode( QWidget::NoBackground ); 345 setBackgroundMode( QWidget::NoBackground );
354 showFullScreen(); 346 showFullScreen();
355 resize( qApp->desktop()->size() ); 347 resize( qApp->desktop()->size() );
356 videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); 348 videoFrame-> setGeometry ( 0, 0, width ( ), height ( ));
357 349
358 slider->hide(); 350 slider->hide();
359 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 351 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
360 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 352 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
361 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 353 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
362 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 354 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
363 355
364 } else { 356 } else {
365 showNormal(); 357 showNormal();
366 showMaximized(); 358 showMaximized();
367 setBackgroundPixmap( pixBg ); 359 setBackgroundPixmap( pixBg );
368 QWidget *d = QApplication::desktop(); 360 QWidget *d = QApplication::desktop();
369 int w = d->width(); 361 int w = d->width();
370 int h = d->height(); 362 int h = d->height();
371 363
372 if(w>h) { 364 if(w>h) {
373 int newW=(w/2)-(246/2); //this will only work with 320x240 365 int newW=(w/2)-(246/2); //this will only work with 320x240
374 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); 366 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) );
375 } else { 367 } else {
376 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); 368 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) );
377 } 369 }
378 370
379 if ( !mediaPlayerState.isSeekable() ) { 371 if ( !mediaPlayerState.isSeekable() ) {
380 if( !slider->isHidden()) { 372 if( !slider->isHidden()) {
381 slider->hide(); 373 slider->hide();
382 } 374 }
383 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 375 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
384 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 376 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
385 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 377 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
386 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 378 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
387 } else { 379 } else {
388 slider->show(); 380 slider->show();
389 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 381 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
390 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 382 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
391 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 383 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
392 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 384 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
393 } 385 }
394 } 386 }
395} 387}
396 388
397 389
398 390
399 391
400void VideoWidget::paintEvent( QPaintEvent * pe) { 392void VideoWidget::paintEvent( QPaintEvent * pe) {
401 QPainter p( this ); 393 QPainter p( this );
402 394
403 if ( mediaPlayerState.isFullscreen() ) { 395 if ( mediaPlayerState.isFullscreen() ) {
404 // Clear the background 396 // Clear the background
405 p.setBrush( QBrush( Qt::black ) ); 397 p.setBrush( QBrush( Qt::black ) );
406 } else { 398 } else {
407 if ( !pe->erased() ) { 399 if ( !pe->erased() ) {
408 // Combine with background and double buffer 400 // Combine with background and double buffer
409 QPixmap pix( pe->rect().size() ); 401 QPixmap pix( pe->rect().size() );
410 QPainter p( &pix ); 402 QPainter p( &pix );
411 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 403 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
412 p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); 404 p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() );
413 for ( unsigned int i = 0; i < buttons.count(); i++ ) { 405 for ( unsigned int i = 0; i < buttons.count(); i++ ) {
414 paintButton( p, i ); 406 paintButton( p, i );
415 } 407 }
416 QPainter p2( this ); 408 QPainter p2( this );
417 p2.drawPixmap( pe->rect().topLeft(), pix ); 409 p2.drawPixmap( pe->rect().topLeft(), pix );
418 } else { 410 } else {
419 QPainter p( this ); 411 QPainter p( this );
420 for ( unsigned int i = 0; i < buttons.count(); i++ ) 412 for ( unsigned int i = 0; i < buttons.count(); i++ )
421 paintButton( p, i ); 413 paintButton( p, i );
422 } 414 }
423 //slider->repaint( TRUE ); 415 //slider->repaint( TRUE );
424 } 416 }
425} 417}
426 418
427 419
428void VideoWidget::keyReleaseEvent( QKeyEvent *e) { 420void VideoWidget::keyReleaseEvent( QKeyEvent *e) {
429 switch ( e->key() ) { 421 switch ( e->key() ) {
430////////////////////////////// Zaurus keys 422////////////////////////////// Zaurus keys
431 case Key_Home: 423 case Key_Home:
432 break; 424 break;
433 case Key_F9: //activity 425 case Key_F9: //activity
434 break; 426 break;
435 case Key_F10: //contacts 427 case Key_F10: //contacts
436// hide(); 428// hide();
437 break; 429 break;
438 case Key_F11: //menu 430 case Key_F11: //menu
439 break; 431 break;
440 case Key_F12: //home 432 case Key_F12: //home
441 break; 433 break;
442 case Key_F13: //mail 434 case Key_F13: //mail
443 break; 435 break;
444 case Key_Space: { 436 case Key_Space: {
445 if(mediaPlayerState.isPlaying()) { 437 if(mediaPlayerState.isPlaying()) {
446 mediaPlayerState.setPlaying(FALSE); 438 mediaPlayerState.setPlaying(FALSE);
447 } else { 439 } else {
448 mediaPlayerState.setPlaying(TRUE); 440 mediaPlayerState.setPlaying(TRUE);
449 } 441 }
450 } 442 }
451 break; 443 break;
452 case Key_Down: 444 case Key_Down:
453// toggleButton(6); 445// toggleButton(6);
454 emit lessClicked(); 446 emit lessClicked();
455 emit lessReleased(); 447 emit lessReleased();
456// toggleButton(6); 448// toggleButton(6);
457 break; 449 break;
458 case Key_Up: 450 case Key_Up:
459// toggleButton(5); 451// toggleButton(5);
460 emit moreClicked(); 452 emit moreClicked();
461 emit moreReleased(); 453 emit moreReleased();
462// toggleButton(5); 454// toggleButton(5);
463 break; 455 break;
464 case Key_Right: 456 case Key_Right:
465 mediaPlayerState.setNext(); 457 mediaPlayerState.setNext();
466 break; 458 break;
467 case Key_Left: 459 case Key_Left:
468 mediaPlayerState.setPrev(); 460 mediaPlayerState.setPrev();
469 break; 461 break;
470 case Key_Escape: 462 case Key_Escape:
471 break; 463 break;
472 464
473 }; 465 };
474} 466}
475 467
476XineVideoWidget* VideoWidget::vidWidget() { 468XineVideoWidget* VideoWidget::vidWidget() {
477 return videoFrame; 469 return videoFrame;
478} 470}
479 471
480 472
481void VideoWidget::setFullscreen ( bool b ) { 473void VideoWidget::setFullscreen ( bool b ) {
482 setToggleButton( VideoFullscreen, b ); 474 setToggleButton( VideoFullscreen, b );
483} 475}
484 476
485 477
486void VideoWidget::setPlaying( bool b) { 478void VideoWidget::setPlaying( bool b) {
487 setToggleButton( VideoPlay, b ); 479 setToggleButton( VideoPlay, b );
488} 480}
489 481
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h
index fd301f9..aeb6429 100644
--- a/noncore/multimedia/opieplayer2/videowidget.h
+++ b/noncore/multimedia/opieplayer2/videowidget.h
@@ -1,123 +1,121 @@
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 VideoPlay = 0, 48 VideoPlay = 0,
49 VideoStop, 49 VideoStop,
50// VideoPause, 50// VideoPause,
51 VideoNext, 51 VideoNext,
52 VideoPrevious, 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 QPixmap *buttonPixUp[7];
104 QPixmap *buttonPixDown[7];
105 QString skin; 103 QString skin;
106 104
107 105
108 virtual void paintButton( QPainter &p, int i ); 106 virtual void paintButton( QPainter &p, int i );
109 void setToggleButton( int, bool ); 107 void setToggleButton( int, bool );
110 108
111 QString backgroundPix; 109 QString backgroundPix;
112 QSlider *slider; 110 QSlider *slider;
113 QPixmap *pixmaps[3]; 111 QPixmap *pixmaps[3];
114 QImage *currentFrame; 112 QImage *currentFrame;
115 int scaledWidth; 113 int scaledWidth;
116 int scaledHeight; 114 int scaledHeight;
117 XineVideoWidget* videoFrame; 115 XineVideoWidget* videoFrame;
118}; 116};
119 117
120#endif // VIDEO_WIDGET_H 118#endif // VIDEO_WIDGET_H
121 119
122 120
123 121