summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index f59772e..8409e5c 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -1,436 +1,437 @@
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.push_back( toggleButton ); // play 77 buttons.push_back( toggleButton ); // play
78 buttons.push_back( toggleButton ); // stop 78 buttons.push_back( toggleButton ); // stop
79 buttons.push_back( toggleButton ); // next 79 buttons.push_back( toggleButton ); // next
80 buttons.push_back( toggleButton ); // previous 80 buttons.push_back( toggleButton ); // previous
81 buttons.push_back( toggleButton ); // volUp 81 buttons.push_back( toggleButton ); // volUp
82 buttons.push_back( toggleButton ); // volDown 82 buttons.push_back( toggleButton ); // volDown
83 buttons.push_back( toggleButton ); // fullscreen 83 buttons.push_back( 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 backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 95 backgroundPixmap = 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 uint i = 0;
103 Button &button = buttons[ i ]; 103 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it, ++i ) {
104 Button &button = *it;
104 105
105 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" );
106 button.mask = QBitmap( filename ); 107 button.mask = QBitmap( filename );
107 108
108 if ( !button.mask.isNull() ) { 109 if ( !button.mask.isNull() ) {
109 QImage imgMask = button.mask.convertToImage(); 110 QImage imgMask = button.mask.convertToImage();
110 uchar **dest = buttonMask.jumpTable(); 111 uchar **dest = buttonMask.jumpTable();
111 for ( int y = 0; y < imgUp.height(); y++ ) { 112 for ( int y = 0; y < imgUp.height(); y++ ) {
112 uchar *line = dest[y]; 113 uchar *line = dest[y];
113 for ( int x = 0; x < imgUp.width(); x++ ) { 114 for ( int x = 0; x < imgUp.width(); x++ ) {
114 if ( !qRed( imgMask.pixel( x, y ) ) ) 115 if ( !qRed( imgMask.pixel( x, y ) ) )
115 line[x] = i + 1; 116 line[x] = i + 1;
116 } 117 }
117 } 118 }
118 } 119 }
119 } 120 }
120 121
121 setBackgroundPixmap( backgroundPixmap ); 122 setBackgroundPixmap( backgroundPixmap );
122 123
123 slider = new QSlider( Qt::Horizontal, this ); 124 slider = new QSlider( Qt::Horizontal, this );
124 slider->setMinValue( 0 ); 125 slider->setMinValue( 0 );
125 slider->setMaxValue( 1 ); 126 slider->setMaxValue( 1 );
126 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 127 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
127 //slider->setFocusPolicy( QWidget::NoFocus ); 128 //slider->setFocusPolicy( QWidget::NoFocus );
128 129
129 resizeEvent( NULL ); 130 resizeEvent( NULL );
130 131
131 setLength( mediaPlayerState.length() ); 132 setLength( mediaPlayerState.length() );
132 setPosition( mediaPlayerState.position() ); 133 setPosition( mediaPlayerState.position() );
133 setFullscreen( mediaPlayerState.isFullscreen() ); 134 setFullscreen( mediaPlayerState.isFullscreen() );
134 setPlaying( mediaPlayerState.isPlaying() ); 135 setPlaying( mediaPlayerState.isPlaying() );
135} 136}
136 137
137 138
138VideoWidget::~VideoWidget() 139VideoWidget::~VideoWidget()
139{ 140{
140} 141}
141 142
142QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 143QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
143 QPixmap pix( img.width(), img.height() ); 144 QPixmap pix( img.width(), img.height() );
144 QPainter p( &pix ); 145 QPainter p( &pix );
145 p.drawTiledPixmap( pix.rect(), bg, offset ); 146 p.drawTiledPixmap( pix.rect(), bg, offset );
146 p.drawImage( 0, 0, img ); 147 p.drawImage( 0, 0, img );
147 return new QPixmap( pix ); 148 return new QPixmap( pix );
148} 149}
149 150
150QPixmap maskVPixToMask( QPixmap pix, QBitmap mask ) { 151QPixmap maskVPixToMask( QPixmap pix, QBitmap mask ) {
151 QPixmap pixmap( pix ); 152 QPixmap pixmap( pix );
152 pixmap.setMask( mask ); 153 pixmap.setMask( mask );
153 return pixmap; 154 return pixmap;
154} 155}
155 156
156void VideoWidget::resizeEvent( QResizeEvent * ) { 157void VideoWidget::resizeEvent( QResizeEvent * ) {
157 int h = height(); 158 int h = height();
158 int w = width(); 159 int w = width();
159 //int Vh = 160; 160 //int Vh = 160;
160 //int Vw = 220; 161 //int Vw = 220;
161 162
162 slider->setFixedWidth( w - 20 ); 163 slider->setFixedWidth( w - 20 );
163 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 164 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
164 slider->setBackgroundOrigin( QWidget::ParentOrigin ); 165 slider->setBackgroundOrigin( QWidget::ParentOrigin );
165 slider->setFocusPolicy( QWidget::NoFocus ); 166 slider->setFocusPolicy( QWidget::NoFocus );
166 slider->setBackgroundPixmap( backgroundPixmap ); 167 slider->setBackgroundPixmap( backgroundPixmap );
167 168
168 upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; 169 upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2;
169 if(w>h) 170 if(w>h)
170 upperLeftOfButtonMask.ry() = 0; 171 upperLeftOfButtonMask.ry() = 0;
171 else 172 else
172 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; 173 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10;
173 QPoint p = upperLeftOfButtonMask; 174 QPoint p = upperLeftOfButtonMask;
174 175
175 QPixmap *pixUp = combineVImageWithBackground( imgUp, backgroundPixmap, p ); 176 QPixmap *pixUp = combineVImageWithBackground( imgUp, backgroundPixmap, p );
176 QPixmap *pixDn = combineVImageWithBackground( imgDn, backgroundPixmap, p ); 177 QPixmap *pixDn = combineVImageWithBackground( imgDn, backgroundPixmap, p );
177 178
178 for ( int i = 0; i < 7; i++ ) { 179 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) {
179 Button &button = buttons[ i ]; 180 Button &button = *it;
180 181
181 if ( !button.mask.isNull() ) { 182 if ( !button.mask.isNull() ) {
182 button.pixUp = maskVPixToMask( *pixUp, button.mask ); 183 button.pixUp = maskVPixToMask( *pixUp, button.mask );
183 button.pixDown = maskVPixToMask( *pixDn, button.mask ); 184 button.pixDown = maskVPixToMask( *pixDn, button.mask );
184 } 185 }
185 } 186 }
186 187
187 delete pixUp; 188 delete pixUp;
188 delete pixDn; 189 delete pixDn;
189} 190}
190 191
191static bool videoSliderBeingMoved = FALSE; 192static bool videoSliderBeingMoved = FALSE;
192 193
193void VideoWidget::sliderPressed() { 194void VideoWidget::sliderPressed() {
194 videoSliderBeingMoved = TRUE; 195 videoSliderBeingMoved = TRUE;
195} 196}
196 197
197void VideoWidget::sliderReleased() { 198void VideoWidget::sliderReleased() {
198 videoSliderBeingMoved = FALSE; 199 videoSliderBeingMoved = FALSE;
199 if ( slider->width() == 0 ) { 200 if ( slider->width() == 0 ) {
200 return; 201 return;
201 } 202 }
202 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); 203 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width());
203 mediaPlayerState.setPosition( val ); 204 mediaPlayerState.setPosition( val );
204} 205}
205 206
206void VideoWidget::setPosition( long i ) { 207void VideoWidget::setPosition( long i ) {
207 updateSlider( i, mediaPlayerState.length() ); 208 updateSlider( i, mediaPlayerState.length() );
208} 209}
209 210
210 211
211void VideoWidget::setLength( long max ) { 212void VideoWidget::setLength( long max ) {
212 updateSlider( mediaPlayerState.position(), max ); 213 updateSlider( mediaPlayerState.position(), max );
213} 214}
214 215
215void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) 216void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType )
216{ 217{
217 if ( displayType == MediaPlayerState::Video ) { 218 if ( displayType == MediaPlayerState::Video ) {
218 makeVisible(); 219 makeVisible();
219 return; 220 return;
220 } 221 }
221 222
222 // Effectively blank the view next time we show it so it looks nicer 223 // Effectively blank the view next time we show it so it looks nicer
223 scaledWidth = 0; 224 scaledWidth = 0;
224 scaledHeight = 0; 225 scaledHeight = 0;
225 hide(); 226 hide();
226} 227}
227 228
228void VideoWidget::updateSlider( long i, long max ) { 229void VideoWidget::updateSlider( long i, long max ) {
229 // Will flicker too much if we don't do this 230 // Will flicker too much if we don't do this
230 if ( max == 0 ) { 231 if ( max == 0 ) {
231 return; 232 return;
232 } 233 }
233 int width = slider->width(); 234 int width = slider->width();
234 int val = int((double)i * width / max); 235 int val = int((double)i * width / max);
235 if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { 236 if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) {
236 if ( slider->value() != val ) { 237 if ( slider->value() != val ) {
237 slider->setValue( val ); 238 slider->setValue( val );
238 } 239 }
239 if ( slider->maxValue() != width ) { 240 if ( slider->maxValue() != width ) {
240 slider->setMaxValue( width ); 241 slider->setMaxValue( width );
241 } 242 }
242 } 243 }
243} 244}
244 245
245void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 246void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
246 for ( unsigned int i = 0; i < buttons.size(); i++ ) { 247 for ( unsigned int i = 0; i < buttons.size(); i++ ) {
247 248
248 Button &button = buttons[ i ]; 249 Button &button = buttons[ i ];
249 250
250 if ( event->state() == QMouseEvent::LeftButton ) { 251 if ( event->state() == QMouseEvent::LeftButton ) {
251 // The test to see if the mouse click is inside the button or not 252 // The test to see if the mouse click is inside the button or not
252 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); 253 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i );
253 254
254 if ( isOnButton && !button.isHeld ) { 255 if ( isOnButton && !button.isHeld ) {
255 button.isHeld = TRUE; 256 button.isHeld = TRUE;
256 toggleButton( button ); 257 toggleButton( button );
257 258
258 switch (i) { 259 switch (i) {
259 case VideoVolUp: 260 case VideoVolUp:
260 emit moreClicked(); 261 emit moreClicked();
261 return; 262 return;
262 case VideoVolDown: 263 case VideoVolDown:
263 emit lessClicked(); 264 emit lessClicked();
264 return; 265 return;
265 } 266 }
266 } else if ( !isOnButton && button.isHeld ) { 267 } else if ( !isOnButton && button.isHeld ) {
267 button.isHeld = FALSE; 268 button.isHeld = FALSE;
268 toggleButton( button ); 269 toggleButton( button );
269 } 270 }
270 } else { 271 } else {
271 272
272 if ( button.isHeld ) { 273 if ( button.isHeld ) {
273 button.isHeld = FALSE; 274 button.isHeld = FALSE;
274 if ( button.type != ToggleButton ) { 275 if ( button.type != ToggleButton ) {
275 setToggleButton( button, FALSE ); 276 setToggleButton( button, FALSE );
276 } 277 }
277 278
278 switch(i) { 279 switch(i) {
279 280
280 case VideoPlay: { 281 case VideoPlay: {
281 if( mediaPlayerState.isPaused() ) { 282 if( mediaPlayerState.isPaused() ) {
282 setToggleButton( button, FALSE ); 283 setToggleButton( button, FALSE );
283 mediaPlayerState.setPaused( FALSE ); 284 mediaPlayerState.setPaused( FALSE );
284 return; 285 return;
285 } else if( !mediaPlayerState.isPaused() ) { 286 } else if( !mediaPlayerState.isPaused() ) {
286 setToggleButton( button, TRUE ); 287 setToggleButton( button, TRUE );
287 mediaPlayerState.setPaused( TRUE ); 288 mediaPlayerState.setPaused( TRUE );
288 return; 289 return;
289 } else { 290 } else {
290 return; 291 return;
291 } 292 }
292 } 293 }
293 294
294 case VideoStop: mediaPlayerState.setPlaying( FALSE ); return; 295 case VideoStop: mediaPlayerState.setPlaying( FALSE ); return;
295 case VideoNext: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; 296 case VideoNext: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return;
296 case VideoPrevious: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; 297 case VideoPrevious: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return;
297 case VideoVolUp: emit moreReleased(); return; 298 case VideoVolUp: emit moreReleased(); return;
298 case VideoVolDown: emit lessReleased(); return; 299 case VideoVolDown: emit lessReleased(); return;
299 case VideoFullscreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return; 300 case VideoFullscreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return;
300 } 301 }
301 } 302 }
302 } 303 }
303 } 304 }
304} 305}
305 306
306void VideoWidget::mousePressEvent( QMouseEvent *event ) { 307void VideoWidget::mousePressEvent( QMouseEvent *event ) {
307 mouseMoveEvent( event ); 308 mouseMoveEvent( event );
308} 309}
309 310
310void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 311void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
311 if ( mediaPlayerState.isFullscreen() ) { 312 if ( mediaPlayerState.isFullscreen() ) {
312 mediaPlayerState.setFullscreen( FALSE ); 313 mediaPlayerState.setFullscreen( FALSE );
313 makeVisible(); 314 makeVisible();
314 } 315 }
315 mouseMoveEvent( event ); 316 mouseMoveEvent( event );
316} 317}
317 318
318void VideoWidget::showEvent( QShowEvent* ) { 319void VideoWidget::showEvent( QShowEvent* ) {
319 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 320 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
320 mouseMoveEvent( &event ); 321 mouseMoveEvent( &event );
321} 322}
322 323
323 324
324 void VideoWidget::backToNormal() { 325 void VideoWidget::backToNormal() {
325 mediaPlayerState.setFullscreen( FALSE ); 326 mediaPlayerState.setFullscreen( FALSE );
326 makeVisible(); 327 makeVisible();
327 } 328 }
328 329
329void VideoWidget::makeVisible() { 330void VideoWidget::makeVisible() {
330 if ( mediaPlayerState.isFullscreen() ) { 331 if ( mediaPlayerState.isFullscreen() ) {
331 setBackgroundMode( QWidget::NoBackground ); 332 setBackgroundMode( QWidget::NoBackground );
332 showFullScreen(); 333 showFullScreen();
333 resize( qApp->desktop()->size() ); 334 resize( qApp->desktop()->size() );
334 videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); 335 videoFrame-> setGeometry ( 0, 0, width ( ), height ( ));
335 336
336 slider->hide(); 337 slider->hide();
337 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 338 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
338 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 339 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
339 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 340 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
340 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 341 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
341 342
342 } else { 343 } else {
343 showNormal(); 344 showNormal();
344 showMaximized(); 345 showMaximized();
345 setBackgroundPixmap( backgroundPixmap ); 346 setBackgroundPixmap( backgroundPixmap );
346 QWidget *d = QApplication::desktop(); 347 QWidget *d = QApplication::desktop();
347 int w = d->width(); 348 int w = d->width();
348 int h = d->height(); 349 int h = d->height();
349 350
350 if(w>h) { 351 if(w>h) {
351 int newW=(w/2)-(246/2); //this will only work with 320x240 352 int newW=(w/2)-(246/2); //this will only work with 320x240
352 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); 353 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) );
353 } else { 354 } else {
354 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); 355 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) );
355 } 356 }
356 357
357 if ( !mediaPlayerState.isSeekable() ) { 358 if ( !mediaPlayerState.isSeekable() ) {
358 if( !slider->isHidden()) { 359 if( !slider->isHidden()) {
359 slider->hide(); 360 slider->hide();
360 } 361 }
361 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 362 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
362 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 363 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
363 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 364 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
364 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 365 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
365 } else { 366 } else {
366 slider->show(); 367 slider->show();
367 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 368 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
368 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 369 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
369 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 370 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
370 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 371 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
371 } 372 }
372 } 373 }
373} 374}
374 375
375void VideoWidget::keyReleaseEvent( QKeyEvent *e) { 376void VideoWidget::keyReleaseEvent( QKeyEvent *e) {
376 switch ( e->key() ) { 377 switch ( e->key() ) {
377////////////////////////////// Zaurus keys 378////////////////////////////// Zaurus keys
378 case Key_Home: 379 case Key_Home:
379 break; 380 break;
380 case Key_F9: //activity 381 case Key_F9: //activity
381 break; 382 break;
382 case Key_F10: //contacts 383 case Key_F10: //contacts
383// hide(); 384// hide();
384 break; 385 break;
385 case Key_F11: //menu 386 case Key_F11: //menu
386 break; 387 break;
387 case Key_F12: //home 388 case Key_F12: //home
388 break; 389 break;
389 case Key_F13: //mail 390 case Key_F13: //mail
390 break; 391 break;
391 case Key_Space: { 392 case Key_Space: {
392 if(mediaPlayerState.isPlaying()) { 393 if(mediaPlayerState.isPlaying()) {
393 mediaPlayerState.setPlaying(FALSE); 394 mediaPlayerState.setPlaying(FALSE);
394 } else { 395 } else {
395 mediaPlayerState.setPlaying(TRUE); 396 mediaPlayerState.setPlaying(TRUE);
396 } 397 }
397 } 398 }
398 break; 399 break;
399 case Key_Down: 400 case Key_Down:
400// toggleButton(6); 401// toggleButton(6);
401 emit lessClicked(); 402 emit lessClicked();
402 emit lessReleased(); 403 emit lessReleased();
403// toggleButton(6); 404// toggleButton(6);
404 break; 405 break;
405 case Key_Up: 406 case Key_Up:
406// toggleButton(5); 407// toggleButton(5);
407 emit moreClicked(); 408 emit moreClicked();
408 emit moreReleased(); 409 emit moreReleased();
409// toggleButton(5); 410// toggleButton(5);
410 break; 411 break;
411 case Key_Right: 412 case Key_Right:
412 mediaPlayerState.setNext(); 413 mediaPlayerState.setNext();
413 break; 414 break;
414 case Key_Left: 415 case Key_Left:
415 mediaPlayerState.setPrev(); 416 mediaPlayerState.setPrev();
416 break; 417 break;
417 case Key_Escape: 418 case Key_Escape:
418 break; 419 break;
419 420
420 }; 421 };
421} 422}
422 423
423XineVideoWidget* VideoWidget::vidWidget() { 424XineVideoWidget* VideoWidget::vidWidget() {
424 return videoFrame; 425 return videoFrame;
425} 426}
426 427
427 428
428void VideoWidget::setFullscreen ( bool b ) { 429void VideoWidget::setFullscreen ( bool b ) {
429 setToggleButton( buttons[ VideoFullscreen ], b ); 430 setToggleButton( buttons[ VideoFullscreen ], b );
430} 431}
431 432
432 433
433void VideoWidget::setPlaying( bool b) { 434void VideoWidget::setPlaying( bool b) {
434 setToggleButton( buttons[ VideoPlay ], b ); 435 setToggleButton( buttons[ VideoPlay ], b );
435} 436}
436 437