summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-09 20:13:12 (UTC)
committer simon <simon>2002-12-09 20:13:12 (UTC)
commitaccc4e231dc34744e75d32af77eeb98f46006c27 (patch) (unidiff)
tree1ee00b2439fb186f7851da602166b1571b9bc600
parent2d2d57e3b7988f4246319cdfd0dc7fa90110db8e (diff)
downloadopie-accc4e231dc34744e75d32af77eeb98f46006c27.zip
opie-accc4e231dc34744e75d32af77eeb98f46006c27.tar.gz
opie-accc4e231dc34744e75d32af77eeb98f46006c27.tar.bz2
- minor cleanup
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp5
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.h1
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp10
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.h1
4 files changed, 2 insertions, 15 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 8e9bbf1..23d12ec 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -80,320 +80,315 @@ void changeTextColor( QWidget * w) {
80} 80}
81 81
82} 82}
83 83
84AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : 84AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) :
85 85
86 MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ), 86 MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ),
87 audioSliderBeingMoved( false ) 87 audioSliderBeingMoved( false )
88{ 88{
89 setCaption( tr("OpiePlayer") ); 89 setCaption( tr("OpiePlayer") );
90 90
91 Config cfg("OpiePlayer"); 91 Config cfg("OpiePlayer");
92 cfg.setGroup("Options"); 92 cfg.setGroup("Options");
93 skin = cfg.readEntry("Skin","default"); 93 skin = cfg.readEntry("Skin","default");
94 //skin = "scaleTest"; 94 //skin = "scaleTest";
95 // color of background, frame, degree of transparency 95 // color of background, frame, degree of transparency
96 96
97 QString skinPath = "opieplayer2/skins/" + skin; 97 QString skinPath = "opieplayer2/skins/" + skin;
98 backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 98 backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
99 imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); 99 imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
100 imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); 100 imgDn = QImage( Resource::loadImage( QString("%1/skin_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 ( uint i = 0; i < buttonCount; i++ ) { 105 for ( uint i = 0; i < buttonCount; i++ ) {
106 Button button; 106 Button button;
107 button.command = skinInfo[ i ].command; 107 button.command = skinInfo[ i ].command;
108 button.type = skinInfo[ i ].type; 108 button.type = skinInfo[ i ].type;
109 109
110 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skinInfo[i].fileName + ".png" ); 110 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skinInfo[i].fileName + ".png" );
111 button.mask =QBitmap( filename ); 111 button.mask =QBitmap( filename );
112 112
113 if ( !button.mask.isNull() ) { 113 if ( !button.mask.isNull() ) {
114 QImage imgMask = button.mask.convertToImage(); 114 QImage imgMask = button.mask.convertToImage();
115 uchar **dest = buttonMask.jumpTable(); 115 uchar **dest = buttonMask.jumpTable();
116 for ( int y = 0; y < imgUp.height(); y++ ) { 116 for ( int y = 0; y < imgUp.height(); y++ ) {
117 uchar *line = dest[y]; 117 uchar *line = dest[y];
118 for ( int x = 0; x < imgUp.width(); x++ ) 118 for ( int x = 0; x < imgUp.width(); x++ )
119 if ( !qRed( imgMask.pixel( x, y ) ) ) 119 if ( !qRed( imgMask.pixel( x, y ) ) )
120 line[x] = button.command + 1; 120 line[x] = button.command + 1;
121 } 121 }
122 } 122 }
123 123
124 buttons.push_back( button ); 124 buttons.push_back( button );
125 } 125 }
126 126
127 setBackgroundPixmap( backgroundPixmap ); 127 setBackgroundPixmap( backgroundPixmap );
128 128
129 songInfo.setFocusPolicy( QWidget::NoFocus ); 129 songInfo.setFocusPolicy( QWidget::NoFocus );
130// changeTextColor( &songInfo ); 130// changeTextColor( &songInfo );
131// songInfo.setBackgroundColor( QColor( 167, 212, 167 )); 131// songInfo.setBackgroundColor( QColor( 167, 212, 167 ));
132// songInfo.setFrameStyle( QFrame::NoFrame); 132// songInfo.setFrameStyle( QFrame::NoFrame);
133 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); 133 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
134// songInfo.setForegroundColor(Qt::white); 134// songInfo.setForegroundColor(Qt::white);
135 135
136 slider.setFixedHeight( 20 ); 136 slider.setFixedHeight( 20 );
137 slider.setMinValue( 0 ); 137 slider.setMinValue( 0 );
138 slider.setMaxValue( 1 ); 138 slider.setMaxValue( 1 );
139 slider.setFocusPolicy( QWidget::NoFocus ); 139 slider.setFocusPolicy( QWidget::NoFocus );
140 slider.setBackgroundPixmap( backgroundPixmap ); 140 slider.setBackgroundPixmap( backgroundPixmap );
141 141
142// Config cofg("qpe"); 142// Config cofg("qpe");
143// cofg.setGroup("Appearance"); 143// cofg.setGroup("Appearance");
144// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); 144// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) );
145 145
146 time.setFocusPolicy( QWidget::NoFocus ); 146 time.setFocusPolicy( QWidget::NoFocus );
147 time.setAlignment( Qt::AlignCenter ); 147 time.setAlignment( Qt::AlignCenter );
148 148
149// time.setFrame(FALSE); 149// time.setFrame(FALSE);
150// changeTextColor( &time ); 150// changeTextColor( &time );
151 151
152 resizeEvent( NULL ); 152 resizeEvent( NULL );
153 153
154 connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 154 connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
155 connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); 155 connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) );
156 156
157 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); 157 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) );
158 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); 158 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) );
159 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); 159 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) );
160 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); 160 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) );
161 161
162 // Intialise state 162 // Intialise state
163 setLength( mediaPlayerState.length() ); 163 setLength( mediaPlayerState.length() );
164 setPosition( mediaPlayerState.position() ); 164 setPosition( mediaPlayerState.position() );
165 setLooping( mediaPlayerState.isFullscreen() ); 165 setLooping( mediaPlayerState.isFullscreen() );
166 // setPaused( mediaPlayerState->paused() ); 166 // setPaused( mediaPlayerState->paused() );
167 setPlaying( mediaPlayerState.isPlaying() ); 167 setPlaying( mediaPlayerState.isPlaying() );
168 168
169} 169}
170 170
171AudioWidget::~AudioWidget() { 171AudioWidget::~AudioWidget() {
172 172
173// mediaPlayerState->setPlaying(false); 173// mediaPlayerState->setPlaying(false);
174} 174}
175 175
176namespace { 176namespace {
177 177
178QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 178QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
179 QPixmap pix( img.width(), img.height() ); 179 QPixmap pix( img.width(), img.height() );
180 QPainter p( &pix ); 180 QPainter p( &pix );
181 p.drawTiledPixmap( pix.rect(), bg, offset ); 181 p.drawTiledPixmap( pix.rect(), bg, offset );
182 p.drawImage( 0, 0, img ); 182 p.drawImage( 0, 0, img );
183 return pix; 183 return pix;
184} 184}
185 185
186 186
187QPixmap maskPixToMask( QPixmap pix, QBitmap mask ) { 187QPixmap maskPixToMask( QPixmap pix, QBitmap mask ) {
188 QPixmap pixmap( pix ); 188 QPixmap pixmap( pix );
189 pixmap.setMask( mask ); 189 pixmap.setMask( mask );
190 return pixmap; 190 return pixmap;
191} 191}
192 192
193}; 193};
194 194
195void AudioWidget::resizeEvent( QResizeEvent * ) { 195void AudioWidget::resizeEvent( QResizeEvent * ) {
196 int h = height(); 196 int h = height();
197 int w = width(); 197 int w = width();
198 198
199 songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); 199 songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) );
200 slider.setFixedWidth( w - 110 ); 200 slider.setFixedWidth( w - 110 );
201 slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 201 slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
202 slider.setBackgroundOrigin( QWidget::ParentOrigin ); 202 slider.setBackgroundOrigin( QWidget::ParentOrigin );
203 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); 203 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
204 204
205 upperLeftOfButtonMask.rx() = ( w - imgUp.width() ) / 2; 205 upperLeftOfButtonMask.rx() = ( w - imgUp.width() ) / 2;
206 upperLeftOfButtonMask.ry() = (( h - imgUp.height() ) / 2) - 10; 206 upperLeftOfButtonMask.ry() = (( h - imgUp.height() ) / 2) - 10;
207 QPoint p = upperLeftOfButtonMask; 207 QPoint p = upperLeftOfButtonMask;
208 208
209 QPixmap pixUp = combineImageWithBackground( imgUp, backgroundPixmap, p ); 209 QPixmap pixUp = combineImageWithBackground( imgUp, backgroundPixmap, p );
210 QPixmap pixDn = combineImageWithBackground( imgDn, backgroundPixmap, p ); 210 QPixmap pixDn = combineImageWithBackground( imgDn, backgroundPixmap, p );
211 211
212 for ( uint i = 0; i < buttons.size(); i++ ) { 212 for ( uint i = 0; i < buttons.size(); i++ ) {
213 if ( !buttons[i].mask.isNull() ) { 213 if ( !buttons[i].mask.isNull() ) {
214 buttons[i].pixUp = maskPixToMask( pixUp, buttons[i].mask ); 214 buttons[i].pixUp = maskPixToMask( pixUp, buttons[i].mask );
215 buttons[i].pixDown = maskPixToMask( pixDn, buttons[i].mask ); 215 buttons[i].pixDown = maskPixToMask( pixDn, buttons[i].mask );
216 } 216 }
217 } 217 }
218} 218}
219 219
220void AudioWidget::sliderPressed() { 220void AudioWidget::sliderPressed() {
221 audioSliderBeingMoved = TRUE; 221 audioSliderBeingMoved = TRUE;
222} 222}
223 223
224 224
225void AudioWidget::sliderReleased() { 225void AudioWidget::sliderReleased() {
226 audioSliderBeingMoved = FALSE; 226 audioSliderBeingMoved = FALSE;
227 if ( slider.width() == 0 ) 227 if ( slider.width() == 0 )
228 return; 228 return;
229 long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); 229 long val = long((double)slider.value() * mediaPlayerState.length() / slider.width());
230 mediaPlayerState.setPosition( val ); 230 mediaPlayerState.setPosition( val );
231} 231}
232 232
233void AudioWidget::setPosition( long i ) { 233void AudioWidget::setPosition( long i ) {
234 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); 234 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i);
235 updateSlider( i, mediaPlayerState.length() ); 235 updateSlider( i, mediaPlayerState.length() );
236} 236}
237 237
238 238
239void AudioWidget::setLength( long max ) { 239void AudioWidget::setLength( long max ) {
240 updateSlider( mediaPlayerState.position(), max ); 240 updateSlider( mediaPlayerState.position(), max );
241} 241}
242 242
243 243
244void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { 244void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) {
245 if ( mediaType == MediaPlayerState::Audio ) { 245 if ( mediaType == MediaPlayerState::Audio ) {
246 // startTimer( 150 ); 246 // startTimer( 150 );
247 showMaximized(); 247 showMaximized();
248 return; 248 return;
249 } 249 }
250 250
251 killTimers(); 251 killTimers();
252 hide(); 252 hide();
253} 253}
254 254
255 255
256void AudioWidget::setSeekable( bool isSeekable ) { 256void AudioWidget::setSeekable( bool isSeekable ) {
257 257
258 if ( !isSeekable ) { 258 if ( !isSeekable ) {
259 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); 259 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>");
260 if( !slider.isHidden()) { 260 if( !slider.isHidden()) {
261 slider.hide(); 261 slider.hide();
262 } 262 }
263 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 263 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
264 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 264 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
265 disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 265 disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
266 disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 266 disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
267 } else { 267 } else {
268 // this stops the slider from being moved, thus 268 // this stops the slider from being moved, thus
269 // does not stop stream when it reaches the end 269 // does not stop stream when it reaches the end
270 slider.show(); 270 slider.show();
271 qDebug( " CONNECT SET POSTION " ); 271 qDebug( " CONNECT SET POSTION " );
272 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 272 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
273 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 273 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
274 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 274 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
275 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 275 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
276 } 276 }
277} 277}
278 278
279 279
280static QString timeAsString( long length ) { 280static QString timeAsString( long length ) {
281 int minutes = length / 60; 281 int minutes = length / 60;
282 int seconds = length % 60; 282 int seconds = length % 60;
283 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); 283 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 );
284} 284}
285 285
286void AudioWidget::updateSlider( long i, long max ) { 286void AudioWidget::updateSlider( long i, long max ) {
287 287
288 time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); 288 time.setText( timeAsString( i ) + " / " + timeAsString( max ) );
289// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; 289// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ;
290 290
291 if ( max == 0 ) { 291 if ( max == 0 ) {
292 return; 292 return;
293 } 293 }
294 // Will flicker too much if we don't do this 294 // Will flicker too much if we don't do this
295 // Scale to something reasonable 295 // Scale to something reasonable
296 int width = slider.width(); 296 int width = slider.width();
297 int val = int((double)i * width / max); 297 int val = int((double)i * width / max);
298 if ( !audioSliderBeingMoved ) { 298 if ( !audioSliderBeingMoved ) {
299 if ( slider.value() != val ) { 299 if ( slider.value() != val ) {
300 slider.setValue( val ); 300 slider.setValue( val );
301 } 301 }
302 302
303 if ( slider.maxValue() != width ) { 303 if ( slider.maxValue() != width ) {
304 slider.setMaxValue( width ); 304 slider.setMaxValue( width );
305 } 305 }
306 } 306 }
307} 307}
308 308
309void AudioWidget::skipFor() { 309void AudioWidget::skipFor() {
310 skipDirection = +1; 310 skipDirection = +1;
311 startTimer( 50 ); 311 startTimer( 50 );
312 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); 312 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
313} 313}
314 314
315void AudioWidget::skipBack() { 315void AudioWidget::skipBack() {
316 skipDirection = -1; 316 skipDirection = -1;
317 startTimer( 50 ); 317 startTimer( 50 );
318 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); 318 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
319} 319}
320 320
321 321
322 322
323void AudioWidget::stopSkip() { 323void AudioWidget::stopSkip() {
324 killTimers(); 324 killTimers();
325} 325}
326 326
327 327
328void AudioWidget::timerEvent( QTimerEvent * ) { 328void AudioWidget::timerEvent( QTimerEvent * ) {
329 if ( skipDirection == +1 ) { 329 if ( skipDirection == +1 ) {
330 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); 330 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
331 } else if ( skipDirection == -1 ) { 331 } else if ( skipDirection == -1 ) {
332 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); 332 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
333 } 333 }
334} 334}
335 335
336void AudioWidget::showEvent( QShowEvent* ) {
337 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
338 mouseMoveEvent( &event );
339}
340
341void AudioWidget::keyReleaseEvent( QKeyEvent *e) { 336void AudioWidget::keyReleaseEvent( QKeyEvent *e) {
342 switch ( e->key() ) { 337 switch ( e->key() ) {
343 ////////////////////////////// Zaurus keys 338 ////////////////////////////// Zaurus keys
344 case Key_Home: 339 case Key_Home:
345 break; 340 break;
346 case Key_F9: //activity 341 case Key_F9: //activity
347 hide(); 342 hide();
348 // qDebug("Audio F9"); 343 // qDebug("Audio F9");
349 e->accept(); 344 e->accept();
350 break; 345 break;
351 case Key_F10: //contacts 346 case Key_F10: //contacts
352 break; 347 break;
353 case Key_F11: //menu 348 case Key_F11: //menu
354 mediaPlayerState.toggleBlank(); 349 mediaPlayerState.toggleBlank();
355 e->accept(); 350 e->accept();
356 break; 351 break;
357 case Key_F12: //home 352 case Key_F12: //home
358 break; 353 break;
359 case Key_F13: //mail 354 case Key_F13: //mail
360 mediaPlayerState.toggleBlank(); 355 mediaPlayerState.toggleBlank();
361 e->accept(); 356 e->accept();
362 break; 357 break;
363 case Key_Space: { 358 case Key_Space: {
364 e->accept(); 359 e->accept();
365 mediaPlayerState.togglePaused(); 360 mediaPlayerState.togglePaused();
366 } 361 }
367 break; 362 break;
368 case Key_Down: 363 case Key_Down:
369 // toggleButton(6); 364 // toggleButton(6);
370 emit lessClicked(); 365 emit lessClicked();
371 emit lessReleased(); 366 emit lessReleased();
372 // toggleButton(6); 367 // toggleButton(6);
373 e->accept(); 368 e->accept();
374 break; 369 break;
375 case Key_Up: 370 case Key_Up:
376 // toggleButton(5); 371 // toggleButton(5);
377 emit moreClicked(); 372 emit moreClicked();
378 emit moreReleased(); 373 emit moreReleased();
379 // toggleButton(5); 374 // toggleButton(5);
380 e->accept(); 375 e->accept();
381 break; 376 break;
382 case Key_Right: 377 case Key_Right:
383 // toggleButton(3); 378 // toggleButton(3);
384 mediaPlayerState.setNext(); 379 mediaPlayerState.setNext();
385 // toggleButton(3); 380 // toggleButton(3);
386 e->accept(); 381 e->accept();
387 break; 382 break;
388 case Key_Left: 383 case Key_Left:
389 // toggleButton(4); 384 // toggleButton(4);
390 mediaPlayerState.setPrev(); 385 mediaPlayerState.setPrev();
391 // toggleButton(4); 386 // toggleButton(4);
392 e->accept(); 387 e->accept();
393 break; 388 break;
394 case Key_Escape: { 389 case Key_Escape: {
395 } 390 }
396 break; 391 break;
397 392
398 }; 393 };
399} 394}
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h
index e2e2314..53982a1 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.h
+++ b/noncore/multimedia/opieplayer2/audiowidget.h
@@ -1,100 +1,99 @@
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 AUDIO_WIDGET_H 34#ifndef AUDIO_WIDGET_H
35#define AUDIO_WIDGET_H 35#define AUDIO_WIDGET_H
36 36
37#include <qpainter.h> 37#include <qpainter.h>
38#include <qdrawutil.h> 38#include <qdrawutil.h>
39#include <qpixmap.h> 39#include <qpixmap.h>
40#include <qstring.h> 40#include <qstring.h>
41#include <qslider.h> 41#include <qslider.h>
42#include <qframe.h> 42#include <qframe.h>
43#include <qlineedit.h> 43#include <qlineedit.h>
44#include <qimage.h> 44#include <qimage.h>
45 45
46#include <opie/oticker.h> 46#include <opie/oticker.h>
47 47
48#include "mediawidget.h" 48#include "mediawidget.h"
49 49
50class QPixmap; 50class QPixmap;
51 51
52class AudioWidget : public MediaWidget { 52class AudioWidget : public MediaWidget {
53 Q_OBJECT 53 Q_OBJECT
54public: 54public:
55 AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); 55 AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 );
56 ~AudioWidget(); 56 ~AudioWidget();
57 void setTickerText( const QString &text ) { songInfo.setText( text ); } 57 void setTickerText( const QString &text ) { songInfo.setText( text ); }
58public slots: 58public slots:
59 void updateSlider( long, long ); 59 void updateSlider( long, long );
60 void sliderPressed( ); 60 void sliderPressed( );
61 void sliderReleased( ); 61 void sliderReleased( );
62 void setLooping( bool b) { setToggleButton( Loop, b ); } 62 void setLooping( bool b) { setToggleButton( Loop, b ); }
63 void setPosition( long ); 63 void setPosition( long );
64 void setSeekable( bool ); 64 void setSeekable( bool );
65 65
66public: 66public:
67 virtual void setLength( long ); 67 virtual void setLength( long );
68 virtual void setPlaying( bool b) { setToggleButton( Play, b ); } 68 virtual void setPlaying( bool b) { setToggleButton( Play, b ); }
69 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); 69 virtual void setDisplayType( MediaPlayerState::DisplayType displayType );
70 70
71signals: 71signals:
72 void sliderMoved(long); 72 void sliderMoved(long);
73 73
74protected: 74protected:
75 void doBlank(); 75 void doBlank();
76 void doUnblank(); 76 void doUnblank();
77 void showEvent( QShowEvent *se );
78 void resizeEvent( QResizeEvent *re ); 77 void resizeEvent( QResizeEvent *re );
79 void timerEvent( QTimerEvent *event ); 78 void timerEvent( QTimerEvent *event );
80 void keyReleaseEvent( QKeyEvent *e); 79 void keyReleaseEvent( QKeyEvent *e);
81private slots: 80private slots:
82 void skipFor(); 81 void skipFor();
83 void skipBack(); 82 void skipBack();
84 void stopSkip(); 83 void stopSkip();
85private: 84private:
86 int skipDirection; 85 int skipDirection;
87 QString skin; 86 QString skin;
88 QImage imgUp; 87 QImage imgUp;
89 QImage imgDn; 88 QImage imgDn;
90 89
91 OTicker songInfo; 90 OTicker songInfo;
92 QSlider slider; 91 QSlider slider;
93 QLineEdit time; 92 QLineEdit time;
94 bool isStreaming : 1; 93 bool isStreaming : 1;
95 bool audioSliderBeingMoved : 1; 94 bool audioSliderBeingMoved : 1;
96}; 95};
97 96
98 97
99#endif // AUDIO_WIDGET_H 98#endif // AUDIO_WIDGET_H
100 99
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 04b09f9..4901e47 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -1,370 +1,364 @@
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 MediaWidget::SkinButtonInfo skinInfo[] = 62const MediaWidget::SkinButtonInfo skinInfo[] =
63{ 63{
64 { MediaWidget::Play, "play", MediaWidget::ToggleButton }, 64 { MediaWidget::Play, "play", MediaWidget::ToggleButton },
65 { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, 65 { MediaWidget::Stop, "stop", MediaWidget::NormalButton },
66 { MediaWidget::Next, "fwd", MediaWidget::NormalButton }, 66 { MediaWidget::Next, "fwd", MediaWidget::NormalButton },
67 { MediaWidget::Previous, "back", MediaWidget::NormalButton }, 67 { MediaWidget::Previous, "back", MediaWidget::NormalButton },
68 { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, 68 { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton },
69 { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, 69 { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton },
70 { MediaWidget::FullScreen, "full", MediaWidget::ToggleButton } 70 { MediaWidget::FullScreen, "full", MediaWidget::ToggleButton }
71}; 71};
72 72
73const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); 73const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] );
74 74
75} 75}
76 76
77VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) 77VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name )
78 : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ), videoSliderBeingMoved( false ) 78 : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ), videoSliderBeingMoved( false )
79{ 79{
80 setCaption( tr("OpiePlayer - Video") ); 80 setCaption( tr("OpiePlayer - Video") );
81 81
82 82
83 videoFrame = new XineVideoWidget ( this, "Video frame" ); 83 videoFrame = new XineVideoWidget ( this, "Video frame" );
84 84
85 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); 85 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & )));
86 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); 86 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) );
87 87
88 Config cfg("OpiePlayer"); 88 Config cfg("OpiePlayer");
89 cfg.setGroup("Options"); 89 cfg.setGroup("Options");
90 skin = cfg.readEntry("Skin","default"); 90 skin = cfg.readEntry("Skin","default");
91 91
92 QString skinPath = "opieplayer2/skins/" + skin; 92 QString skinPath = "opieplayer2/skins/" + skin;
93 backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 93 backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
94 imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); 94 imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) );
95 imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); 95 imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) );
96 96
97 buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); 97 buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 );
98 buttonMask.fill( 0 ); 98 buttonMask.fill( 0 );
99 99
100 for ( uint i = 0; i < buttonCount; i++ ) { 100 for ( uint i = 0; i < buttonCount; i++ ) {
101 Button button; 101 Button button;
102 button.command = skinInfo[ i ].command; 102 button.command = skinInfo[ i ].command;
103 button.type = skinInfo[ i ].type; 103 button.type = skinInfo[ i ].type;
104 104
105 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinInfo[i].fileName + ".png" ); 105 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinInfo[i].fileName + ".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] = button.command + 1; 115 line[x] = button.command + 1;
116 } 116 }
117 } 117 }
118 118
119 buttons.push_back( button ); 119 buttons.push_back( button );
120 } 120 }
121 121
122 setBackgroundPixmap( backgroundPixmap ); 122 setBackgroundPixmap( backgroundPixmap );
123 123
124 slider = new QSlider( Qt::Horizontal, this ); 124 slider = new QSlider( Qt::Horizontal, this );
125 slider->setMinValue( 0 ); 125 slider->setMinValue( 0 );
126 slider->setMaxValue( 1 ); 126 slider->setMaxValue( 1 );
127 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 127 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
128 //slider->setFocusPolicy( QWidget::NoFocus ); 128 //slider->setFocusPolicy( QWidget::NoFocus );
129 129
130 resizeEvent( NULL ); 130 resizeEvent( NULL );
131 131
132 setLength( mediaPlayerState.length() ); 132 setLength( mediaPlayerState.length() );
133 setPosition( mediaPlayerState.position() ); 133 setPosition( mediaPlayerState.position() );
134 setFullscreen( mediaPlayerState.isFullscreen() ); 134 setFullscreen( mediaPlayerState.isFullscreen() );
135 setPlaying( mediaPlayerState.isPlaying() ); 135 setPlaying( mediaPlayerState.isPlaying() );
136} 136}
137 137
138 138
139VideoWidget::~VideoWidget() 139VideoWidget::~VideoWidget()
140{ 140{
141} 141}
142 142
143QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 143QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
144 QPixmap pix( img.width(), img.height() ); 144 QPixmap pix( img.width(), img.height() );
145 QPainter p( &pix ); 145 QPainter p( &pix );
146 p.drawTiledPixmap( pix.rect(), bg, offset ); 146 p.drawTiledPixmap( pix.rect(), bg, offset );
147 p.drawImage( 0, 0, img ); 147 p.drawImage( 0, 0, img );
148 return new QPixmap( pix ); 148 return new QPixmap( pix );
149} 149}
150 150
151QPixmap maskVPixToMask( QPixmap pix, QBitmap mask ) { 151QPixmap maskVPixToMask( QPixmap pix, QBitmap mask ) {
152 QPixmap pixmap( pix ); 152 QPixmap pixmap( pix );
153 pixmap.setMask( mask ); 153 pixmap.setMask( mask );
154 return pixmap; 154 return pixmap;
155} 155}
156 156
157void VideoWidget::resizeEvent( QResizeEvent * ) { 157void VideoWidget::resizeEvent( QResizeEvent * ) {
158 int h = height(); 158 int h = height();
159 int w = width(); 159 int w = width();
160 //int Vh = 160; 160 //int Vh = 160;
161 //int Vw = 220; 161 //int Vw = 220;
162 162
163 slider->setFixedWidth( w - 20 ); 163 slider->setFixedWidth( w - 20 );
164 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 164 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
165 slider->setBackgroundOrigin( QWidget::ParentOrigin ); 165 slider->setBackgroundOrigin( QWidget::ParentOrigin );
166 slider->setFocusPolicy( QWidget::NoFocus ); 166 slider->setFocusPolicy( QWidget::NoFocus );
167 slider->setBackgroundPixmap( backgroundPixmap ); 167 slider->setBackgroundPixmap( backgroundPixmap );
168 168
169 upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; 169 upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2;
170 if(w>h) 170 if(w>h)
171 upperLeftOfButtonMask.ry() = 0; 171 upperLeftOfButtonMask.ry() = 0;
172 else 172 else
173 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; 173 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10;
174 QPoint p = upperLeftOfButtonMask; 174 QPoint p = upperLeftOfButtonMask;
175 175
176 QPixmap *pixUp = combineVImageWithBackground( imgUp, backgroundPixmap, p ); 176 QPixmap *pixUp = combineVImageWithBackground( imgUp, backgroundPixmap, p );
177 QPixmap *pixDn = combineVImageWithBackground( imgDn, backgroundPixmap, p ); 177 QPixmap *pixDn = combineVImageWithBackground( imgDn, backgroundPixmap, p );
178 178
179 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) { 179 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) {
180 Button &button = *it; 180 Button &button = *it;
181 181
182 if ( !button.mask.isNull() ) { 182 if ( !button.mask.isNull() ) {
183 button.pixUp = maskVPixToMask( *pixUp, button.mask ); 183 button.pixUp = maskVPixToMask( *pixUp, button.mask );
184 button.pixDown = maskVPixToMask( *pixDn, button.mask ); 184 button.pixDown = maskVPixToMask( *pixDn, button.mask );
185 } 185 }
186 } 186 }
187 187
188 delete pixUp; 188 delete pixUp;
189 delete pixDn; 189 delete pixDn;
190} 190}
191 191
192void VideoWidget::sliderPressed() { 192void VideoWidget::sliderPressed() {
193 videoSliderBeingMoved = TRUE; 193 videoSliderBeingMoved = TRUE;
194} 194}
195 195
196void VideoWidget::sliderReleased() { 196void VideoWidget::sliderReleased() {
197 videoSliderBeingMoved = FALSE; 197 videoSliderBeingMoved = FALSE;
198 if ( slider->width() == 0 ) { 198 if ( slider->width() == 0 ) {
199 return; 199 return;
200 } 200 }
201 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); 201 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width());
202 mediaPlayerState.setPosition( val ); 202 mediaPlayerState.setPosition( val );
203} 203}
204 204
205void VideoWidget::setPosition( long i ) { 205void VideoWidget::setPosition( long i ) {
206 updateSlider( i, mediaPlayerState.length() ); 206 updateSlider( i, mediaPlayerState.length() );
207} 207}
208 208
209 209
210void VideoWidget::setLength( long max ) { 210void VideoWidget::setLength( long max ) {
211 updateSlider( mediaPlayerState.position(), max ); 211 updateSlider( mediaPlayerState.position(), max );
212} 212}
213 213
214void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) 214void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType )
215{ 215{
216 if ( displayType == MediaPlayerState::Video ) { 216 if ( displayType == MediaPlayerState::Video ) {
217 makeVisible(); 217 makeVisible();
218 return; 218 return;
219 } 219 }
220 220
221 // Effectively blank the view next time we show it so it looks nicer 221 // Effectively blank the view next time we show it so it looks nicer
222 scaledWidth = 0; 222 scaledWidth = 0;
223 scaledHeight = 0; 223 scaledHeight = 0;
224 hide(); 224 hide();
225} 225}
226 226
227void VideoWidget::updateSlider( long i, long max ) { 227void VideoWidget::updateSlider( long i, long max ) {
228 // Will flicker too much if we don't do this 228 // Will flicker too much if we don't do this
229 if ( max == 0 ) { 229 if ( max == 0 ) {
230 return; 230 return;
231 } 231 }
232 int width = slider->width(); 232 int width = slider->width();
233 int val = int((double)i * width / max); 233 int val = int((double)i * width / max);
234 if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { 234 if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) {
235 if ( slider->value() != val ) { 235 if ( slider->value() != val ) {
236 slider->setValue( val ); 236 slider->setValue( val );
237 } 237 }
238 if ( slider->maxValue() != width ) { 238 if ( slider->maxValue() != width ) {
239 slider->setMaxValue( width ); 239 slider->setMaxValue( width );
240 } 240 }
241 } 241 }
242} 242}
243 243
244void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 244void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
245 if ( mediaPlayerState.isFullscreen() ) { 245 if ( mediaPlayerState.isFullscreen() ) {
246 mediaPlayerState.setFullscreen( FALSE ); 246 mediaPlayerState.setFullscreen( FALSE );
247 makeVisible(); 247 makeVisible();
248 } 248 }
249 MediaWidget::mouseReleaseEvent( event ); 249 MediaWidget::mouseReleaseEvent( event );
250} 250}
251 251
252void VideoWidget::showEvent( QShowEvent* ) { 252void VideoWidget::backToNormal() {
253 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
254 mouseMoveEvent( &event );
255}
256
257
258 void VideoWidget::backToNormal() {
259 mediaPlayerState.setFullscreen( FALSE ); 253 mediaPlayerState.setFullscreen( FALSE );
260 makeVisible(); 254 makeVisible();
261 } 255}
262 256
263void VideoWidget::makeVisible() { 257void VideoWidget::makeVisible() {
264 if ( mediaPlayerState.isFullscreen() ) { 258 if ( mediaPlayerState.isFullscreen() ) {
265 setBackgroundMode( QWidget::NoBackground ); 259 setBackgroundMode( QWidget::NoBackground );
266 showFullScreen(); 260 showFullScreen();
267 resize( qApp->desktop()->size() ); 261 resize( qApp->desktop()->size() );
268 videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); 262 videoFrame-> setGeometry ( 0, 0, width ( ), height ( ));
269 263
270 slider->hide(); 264 slider->hide();
271 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 265 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
272 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 266 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
273 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 267 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
274 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 268 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
275 269
276 } else { 270 } else {
277 showNormal(); 271 showNormal();
278 showMaximized(); 272 showMaximized();
279 setBackgroundPixmap( backgroundPixmap ); 273 setBackgroundPixmap( backgroundPixmap );
280 QWidget *d = QApplication::desktop(); 274 QWidget *d = QApplication::desktop();
281 int w = d->width(); 275 int w = d->width();
282 int h = d->height(); 276 int h = d->height();
283 277
284 if(w>h) { 278 if(w>h) {
285 int newW=(w/2)-(246/2); //this will only work with 320x240 279 int newW=(w/2)-(246/2); //this will only work with 320x240
286 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); 280 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) );
287 } else { 281 } else {
288 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); 282 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) );
289 } 283 }
290 284
291 if ( !mediaPlayerState.isSeekable() ) { 285 if ( !mediaPlayerState.isSeekable() ) {
292 if( !slider->isHidden()) { 286 if( !slider->isHidden()) {
293 slider->hide(); 287 slider->hide();
294 } 288 }
295 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 289 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
296 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 290 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
297 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 291 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
298 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 292 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
299 } else { 293 } else {
300 slider->show(); 294 slider->show();
301 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 295 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
302 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 296 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
303 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 297 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
304 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 298 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
305 } 299 }
306 } 300 }
307} 301}
308 302
309void VideoWidget::keyReleaseEvent( QKeyEvent *e) { 303void VideoWidget::keyReleaseEvent( QKeyEvent *e) {
310 switch ( e->key() ) { 304 switch ( e->key() ) {
311////////////////////////////// Zaurus keys 305////////////////////////////// Zaurus keys
312 case Key_Home: 306 case Key_Home:
313 break; 307 break;
314 case Key_F9: //activity 308 case Key_F9: //activity
315 break; 309 break;
316 case Key_F10: //contacts 310 case Key_F10: //contacts
317// hide(); 311// hide();
318 break; 312 break;
319 case Key_F11: //menu 313 case Key_F11: //menu
320 break; 314 break;
321 case Key_F12: //home 315 case Key_F12: //home
322 break; 316 break;
323 case Key_F13: //mail 317 case Key_F13: //mail
324 break; 318 break;
325 case Key_Space: { 319 case Key_Space: {
326 if(mediaPlayerState.isPlaying()) { 320 if(mediaPlayerState.isPlaying()) {
327 mediaPlayerState.setPlaying(FALSE); 321 mediaPlayerState.setPlaying(FALSE);
328 } else { 322 } else {
329 mediaPlayerState.setPlaying(TRUE); 323 mediaPlayerState.setPlaying(TRUE);
330 } 324 }
331 } 325 }
332 break; 326 break;
333 case Key_Down: 327 case Key_Down:
334// toggleButton(6); 328// toggleButton(6);
335 emit lessClicked(); 329 emit lessClicked();
336 emit lessReleased(); 330 emit lessReleased();
337// toggleButton(6); 331// toggleButton(6);
338 break; 332 break;
339 case Key_Up: 333 case Key_Up:
340// toggleButton(5); 334// toggleButton(5);
341 emit moreClicked(); 335 emit moreClicked();
342 emit moreReleased(); 336 emit moreReleased();
343// toggleButton(5); 337// toggleButton(5);
344 break; 338 break;
345 case Key_Right: 339 case Key_Right:
346 mediaPlayerState.setNext(); 340 mediaPlayerState.setNext();
347 break; 341 break;
348 case Key_Left: 342 case Key_Left:
349 mediaPlayerState.setPrev(); 343 mediaPlayerState.setPrev();
350 break; 344 break;
351 case Key_Escape: 345 case Key_Escape:
352 break; 346 break;
353 347
354 }; 348 };
355} 349}
356 350
357XineVideoWidget* VideoWidget::vidWidget() { 351XineVideoWidget* VideoWidget::vidWidget() {
358 return videoFrame; 352 return videoFrame;
359} 353}
360 354
361 355
362void VideoWidget::setFullscreen ( bool b ) { 356void VideoWidget::setFullscreen ( bool b ) {
363 setToggleButton( FullScreen, b ); 357 setToggleButton( FullScreen, b );
364} 358}
365 359
366 360
367void VideoWidget::setPlaying( bool b) { 361void VideoWidget::setPlaying( bool b) {
368 setToggleButton( Play, b ); 362 setToggleButton( Play, b );
369} 363}
370 364
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h
index 985c094..21a4e9e 100644
--- a/noncore/multimedia/opieplayer2/videowidget.h
+++ b/noncore/multimedia/opieplayer2/videowidget.h
@@ -1,103 +1,102 @@
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
47class VideoWidget : public MediaWidget { 47class VideoWidget : public MediaWidget {
48 Q_OBJECT 48 Q_OBJECT
49public: 49public:
50 VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); 50 VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 );
51 ~VideoWidget(); 51 ~VideoWidget();
52 52
53 53
54 XineVideoWidget* vidWidget(); 54 XineVideoWidget* vidWidget();
55public slots: 55public slots:
56 void updateSlider( long, long ); 56 void updateSlider( long, long );
57 void sliderPressed( ); 57 void sliderPressed( );
58 void sliderReleased( ); 58 void sliderReleased( );
59 void setFullscreen( bool b ); 59 void setFullscreen( bool b );
60 virtual void makeVisible(); 60 virtual void makeVisible();
61 void backToNormal(); 61 void backToNormal();
62 void setPosition( long ); 62 void setPosition( long );
63 63
64public: 64public:
65 virtual void setPlaying( bool b); 65 virtual void setPlaying( bool b);
66 virtual void setLength( long ); 66 virtual void setLength( long );
67 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); 67 virtual void setDisplayType( MediaPlayerState::DisplayType displayType );
68 68
69signals: 69signals:
70 void moreClicked(); 70 void moreClicked();
71 void lessClicked(); 71 void lessClicked();
72 void sliderMoved( long ); 72 void sliderMoved( long );
73 void videoResized ( const QSize &s ); 73 void videoResized ( const QSize &s );
74 74
75protected: 75protected:
76 76
77 void resizeEvent( QResizeEvent * ); 77 void resizeEvent( QResizeEvent * );
78 void showEvent( QShowEvent *se );
79 void mouseReleaseEvent( QMouseEvent *event ); 78 void mouseReleaseEvent( QMouseEvent *event );
80 void keyReleaseEvent( QKeyEvent *e); 79 void keyReleaseEvent( QKeyEvent *e);
81 80
82private: 81private:
83// Ticker songInfo; 82// Ticker songInfo;
84 QImage imgUp; 83 QImage imgUp;
85 QImage imgDn; 84 QImage imgDn;
86 QString skin; 85 QString skin;
87 86
88 87
89 88
90 QString backgroundPix; 89 QString backgroundPix;
91 QSlider *slider; 90 QSlider *slider;
92 QImage *currentFrame; 91 QImage *currentFrame;
93 int scaledWidth; 92 int scaledWidth;
94 int scaledHeight; 93 int scaledHeight;
95 XineVideoWidget* videoFrame; 94 XineVideoWidget* videoFrame;
96 95
97 bool videoSliderBeingMoved; 96 bool videoSliderBeingMoved;
98}; 97};
99 98
100#endif // VIDEO_WIDGET_H 99#endif // VIDEO_WIDGET_H
101 100
102 101
103 102