summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp8
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp3
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp84
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h3
4 files changed, 51 insertions, 47 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 5986a72..8e9bbf1 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -157,235 +157,243 @@ AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlaye
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* ) { 336void AudioWidget::showEvent( QShowEvent* ) {
337 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 337 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
338 mouseMoveEvent( &event ); 338 mouseMoveEvent( &event );
339} 339}
340 340
341void AudioWidget::keyReleaseEvent( QKeyEvent *e) { 341void AudioWidget::keyReleaseEvent( QKeyEvent *e) {
342 switch ( e->key() ) { 342 switch ( e->key() ) {
343 ////////////////////////////// Zaurus keys 343 ////////////////////////////// Zaurus keys
344 case Key_Home: 344 case Key_Home:
345 break; 345 break;
346 case Key_F9: //activity 346 case Key_F9: //activity
347 hide(); 347 hide();
348 // qDebug("Audio F9"); 348 // qDebug("Audio F9");
349 e->accept();
349 break; 350 break;
350 case Key_F10: //contacts 351 case Key_F10: //contacts
351 break; 352 break;
352 case Key_F11: //menu 353 case Key_F11: //menu
353 mediaPlayerState.toggleBlank(); 354 mediaPlayerState.toggleBlank();
355 e->accept();
354 break; 356 break;
355 case Key_F12: //home 357 case Key_F12: //home
356 break; 358 break;
357 case Key_F13: //mail 359 case Key_F13: //mail
358 mediaPlayerState.toggleBlank(); 360 mediaPlayerState.toggleBlank();
361 e->accept();
359 break; 362 break;
360 case Key_Space: { 363 case Key_Space: {
364 e->accept();
361 mediaPlayerState.togglePaused(); 365 mediaPlayerState.togglePaused();
362 } 366 }
363 break; 367 break;
364 case Key_Down: 368 case Key_Down:
365 // toggleButton(6); 369 // toggleButton(6);
366 emit lessClicked(); 370 emit lessClicked();
367 emit lessReleased(); 371 emit lessReleased();
368 // toggleButton(6); 372 // toggleButton(6);
373 e->accept();
369 break; 374 break;
370 case Key_Up: 375 case Key_Up:
371 // toggleButton(5); 376 // toggleButton(5);
372 emit moreClicked(); 377 emit moreClicked();
373 emit moreReleased(); 378 emit moreReleased();
374 // toggleButton(5); 379 // toggleButton(5);
380 e->accept();
375 break; 381 break;
376 case Key_Right: 382 case Key_Right:
377 // toggleButton(3); 383 // toggleButton(3);
378 mediaPlayerState.setNext(); 384 mediaPlayerState.setNext();
379 // toggleButton(3); 385 // toggleButton(3);
386 e->accept();
380 break; 387 break;
381 case Key_Left: 388 case Key_Left:
382 // toggleButton(4); 389 // toggleButton(4);
383 mediaPlayerState.setPrev(); 390 mediaPlayerState.setPrev();
384 // toggleButton(4); 391 // toggleButton(4);
392 e->accept();
385 break; 393 break;
386 case Key_Escape: { 394 case Key_Escape: {
387 } 395 }
388 break; 396 break;
389 397
390 }; 398 };
391} 399}
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index ed7e37f..e1bfc2d 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -1,240 +1,241 @@
1#include <qpe/qpeapplication.h> 1#include <qpe/qpeapplication.h>
2#include <qpe/qlibrary.h> 2#include <qpe/qlibrary.h>
3#include <qpe/resource.h> 3#include <qpe/resource.h>
4#include <qpe/config.h> 4#include <qpe/config.h>
5#include <qpe/qcopenvelope_qws.h> 5#include <qpe/qcopenvelope_qws.h>
6#include <qfileinfo.h> 6#include <qfileinfo.h>
7 7
8#include <qmainwindow.h> 8#include <qmainwindow.h>
9#include <qmessagebox.h> 9#include <qmessagebox.h>
10#include <qwidgetstack.h> 10#include <qwidgetstack.h>
11#include <qfile.h> 11#include <qfile.h>
12 12
13#include "mediaplayer.h" 13#include "mediaplayer.h"
14#include "playlistwidget.h" 14#include "playlistwidget.h"
15#include "audiowidget.h" 15#include "audiowidget.h"
16#include "videowidget.h" 16#include "videowidget.h"
17#include "volumecontrol.h" 17#include "volumecontrol.h"
18 18
19#include "mediaplayerstate.h" 19#include "mediaplayerstate.h"
20 20
21// for setBacklight() 21// for setBacklight()
22#include <linux/fb.h> 22#include <linux/fb.h>
23#include <sys/file.h> 23#include <sys/file.h>
24#include <sys/ioctl.h> 24#include <sys/ioctl.h>
25 25
26 26
27 27
28 28
29#define FBIOBLANK 0x4611 29#define FBIOBLANK 0x4611
30 30
31MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) 31MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name )
32 : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) { 32 : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) {
33 33
34 audioUI = 0; 34 audioUI = 0;
35 videoUI = 0; 35 videoUI = 0;
36 xineControl = 0; 36 xineControl = 0;
37 recreateAudioAndVideoWidgets(); 37 recreateAudioAndVideoWidgets();
38 38
39 fd=-1;fl=-1; 39 fd=-1;fl=-1;
40 playList.setCaption( tr( "OpiePlayer: Initializating" ) ); 40 playList.setCaption( tr( "OpiePlayer: Initializating" ) );
41 41
42 qApp->processEvents(); 42 qApp->processEvents();
43 // QPEApplication::grabKeyboard(); // EVIL 43 // QPEApplication::grabKeyboard(); // EVIL
44 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 44 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
45 45
46 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); 46 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) );
47 47
48 connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); 48// What is pauseCheck good for? (Simon)
49// connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) );
49 50
50 connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); 51 connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) );
51 connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); 52 connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) );
52 connect( &mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); 53 connect( &mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) );
53 54
54 volControl = new VolumeControl; 55 volControl = new VolumeControl;
55 Config cfg( "OpiePlayer" ); 56 Config cfg( "OpiePlayer" );
56 cfg.setGroup("PlayList"); 57 cfg.setGroup("PlayList");
57 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); 58 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
58 playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); 59 playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() );
59} 60}
60 61
61MediaPlayer::~MediaPlayer() { 62MediaPlayer::~MediaPlayer() {
62 delete xineControl; 63 delete xineControl;
63 delete audioUI; 64 delete audioUI;
64 delete videoUI; 65 delete videoUI;
65 delete volControl; 66 delete volControl;
66} 67}
67 68
68void MediaPlayer::pauseCheck( bool b ) { 69void MediaPlayer::pauseCheck( bool b ) {
69 if ( b && !mediaPlayerState.isPlaying() ) { 70 if ( b && !mediaPlayerState.isPlaying() ) {
70 mediaPlayerState.setPaused( FALSE ); 71 mediaPlayerState.setPaused( FALSE );
71 } 72 }
72} 73}
73 74
74void MediaPlayer::play() { 75void MediaPlayer::play() {
75 mediaPlayerState.setPlaying( FALSE ); 76 mediaPlayerState.setPlaying( FALSE );
76 mediaPlayerState.setPlaying( TRUE ); 77 mediaPlayerState.setPlaying( TRUE );
77} 78}
78 79
79void MediaPlayer::setPlaying( bool play ) { 80void MediaPlayer::setPlaying( bool play ) {
80 if ( !play ) { 81 if ( !play ) {
81 return; 82 return;
82 } 83 }
83 84
84 if ( mediaPlayerState.isPaused() ) { 85 if ( mediaPlayerState.isPaused() ) {
85 mediaPlayerState.setPaused( FALSE ); 86 mediaPlayerState.setPaused( FALSE );
86 return; 87 return;
87 } 88 }
88 89
89 QString tickerText, time, fileName; 90 QString tickerText, time, fileName;
90 if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) { 91 if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) {
91 //if playing in file list.. play in a different way 92 //if playing in file list.. play in a different way
92 // random and looping settings enabled causes problems here, 93 // random and looping settings enabled causes problems here,
93 // since there is no selected file in the playlist, but a selected file in the file list, 94 // since there is no selected file in the playlist, but a selected file in the file list,
94 // so we remember and shutoff 95 // so we remember and shutoff
95 l = mediaPlayerState.isLooping(); 96 l = mediaPlayerState.isLooping();
96 if(l) { 97 if(l) {
97 mediaPlayerState.setLooping( false ); 98 mediaPlayerState.setLooping( false );
98 } 99 }
99 r = mediaPlayerState.isShuffled(); 100 r = mediaPlayerState.isShuffled();
100 mediaPlayerState.setShuffled( false ); 101 mediaPlayerState.setShuffled( false );
101 } 102 }
102 103
103 PlayListWidget::Entry playListEntry = playList.currentEntry(); 104 PlayListWidget::Entry playListEntry = playList.currentEntry();
104 fileName = playListEntry.name; 105 fileName = playListEntry.name;
105 xineControl->play( playListEntry.file ); 106 xineControl->play( playListEntry.file );
106 107
107 long seconds = mediaPlayerState.length(); 108 long seconds = mediaPlayerState.length();
108 time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); 109 time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
109 110
110 if( fileName.left(4) == "http" ) { 111 if( fileName.left(4) == "http" ) {
111 fileName = QFileInfo( fileName ).baseName(); 112 fileName = QFileInfo( fileName ).baseName();
112 if ( xineControl->getMetaInfo().isEmpty() ) { 113 if ( xineControl->getMetaInfo().isEmpty() ) {
113 tickerText = tr( " File: " ) + fileName; 114 tickerText = tr( " File: " ) + fileName;
114 } else { 115 } else {
115 tickerText = xineControl->getMetaInfo(); 116 tickerText = xineControl->getMetaInfo();
116 } 117 }
117 } else { 118 } else {
118 if ( xineControl->getMetaInfo().isEmpty() ) { 119 if ( xineControl->getMetaInfo().isEmpty() ) {
119 tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; 120 tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " ";
120 } else { 121 } else {
121 tickerText = xineControl->getMetaInfo() + " Length: " + time + " "; 122 tickerText = xineControl->getMetaInfo() + " Length: " + time + " ";
122 } 123 }
123 } 124 }
124 audioUI->setTickerText( tickerText ); 125 audioUI->setTickerText( tickerText );
125} 126}
126 127
127 128
128void MediaPlayer::prev() { 129void MediaPlayer::prev() {
129 if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist 130 if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist
130 if ( playList.prev() ) { 131 if ( playList.prev() ) {
131 play(); 132 play();
132 } else if ( mediaPlayerState.isLooping() ) { 133 } else if ( mediaPlayerState.isLooping() ) {
133 if ( playList.last() ) { 134 if ( playList.last() ) {
134 play(); 135 play();
135 } 136 }
136 } else { 137 } else {
137 mediaPlayerState.setList(); 138 mediaPlayerState.setList();
138 } 139 }
139 } 140 }
140} 141}
141 142
142 143
143void MediaPlayer::next() { 144void MediaPlayer::next() {
144 145
145 if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist 146 if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist
146 if ( playList.next() ) { 147 if ( playList.next() ) {
147 play(); 148 play();
148 } else if ( mediaPlayerState.isLooping() ) { 149 } else if ( mediaPlayerState.isLooping() ) {
149 if ( playList.first() ) { 150 if ( playList.first() ) {
150 play(); 151 play();
151 } 152 }
152 } else { 153 } else {
153 mediaPlayerState.setList(); 154 mediaPlayerState.setList();
154 } 155 }
155 } else { //if playing from file list, let's just stop 156 } else { //if playing from file list, let's just stop
156 qDebug("<<<<<<<<<<<<<<<<<stop for filelists"); 157 qDebug("<<<<<<<<<<<<<<<<<stop for filelists");
157 mediaPlayerState.setPlaying(false); 158 mediaPlayerState.setPlaying(false);
158 mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); 159 mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection );
159 if(l) mediaPlayerState.setLooping(l); 160 if(l) mediaPlayerState.setLooping(l);
160 if(r) mediaPlayerState.setShuffled(r); 161 if(r) mediaPlayerState.setShuffled(r);
161 } 162 }
162 qApp->processEvents(); 163 qApp->processEvents();
163} 164}
164 165
165 166
166void MediaPlayer::startDecreasingVolume() { 167void MediaPlayer::startDecreasingVolume() {
167 volumeDirection = -1; 168 volumeDirection = -1;
168 startTimer( 100 ); 169 startTimer( 100 );
169 volControl->decVol(2); 170 volControl->decVol(2);
170} 171}
171 172
172 173
173void MediaPlayer::startIncreasingVolume() { 174void MediaPlayer::startIncreasingVolume() {
174 volumeDirection = +1; 175 volumeDirection = +1;
175 startTimer( 100 ); 176 startTimer( 100 );
176 volControl->incVol(2); 177 volControl->incVol(2);
177} 178}
178 179
179 180
180bool drawnOnScreenDisplay = FALSE; 181bool drawnOnScreenDisplay = FALSE;
181unsigned int onScreenDisplayVolume = 0; 182unsigned int onScreenDisplayVolume = 0;
182const int yoff = 110; 183const int yoff = 110;
183 184
184void MediaPlayer::stopChangingVolume() { 185void MediaPlayer::stopChangingVolume() {
185 killTimers(); 186 killTimers();
186 // Get rid of the on-screen display stuff 187 // Get rid of the on-screen display stuff
187 drawnOnScreenDisplay = FALSE; 188 drawnOnScreenDisplay = FALSE;
188 onScreenDisplayVolume = 0; 189 onScreenDisplayVolume = 0;
189 int w=0; 190 int w=0;
190 int h=0; 191 int h=0;
191 if( !xineControl->hasVideo() ) { 192 if( !xineControl->hasVideo() ) {
192 w = audioUI->width(); 193 w = audioUI->width();
193 h = audioUI->height(); 194 h = audioUI->height();
194 audioUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); 195 audioUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE );
195 } else { 196 } else {
196 w = videoUI->width(); 197 w = videoUI->width();
197 h = videoUI->height(); 198 h = videoUI->height();
198 videoUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); 199 videoUI->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE );
199 } 200 }
200} 201}
201 202
202 203
203void MediaPlayer::timerEvent( QTimerEvent * ) { 204void MediaPlayer::timerEvent( QTimerEvent * ) {
204 if ( volumeDirection == +1 ) { 205 if ( volumeDirection == +1 ) {
205 volControl->incVol( 2 ); 206 volControl->incVol( 2 );
206 } else if ( volumeDirection == -1 ) { 207 } else if ( volumeDirection == -1 ) {
207 volControl->decVol( 2 ); 208 volControl->decVol( 2 );
208 } 209 }
209 210
210 211
211 // TODO FIXME 212 // TODO FIXME
212 // huh?? 213 // huh??
213 unsigned int v= 0; 214 unsigned int v= 0;
214 v = volControl->volume(); 215 v = volControl->volume();
215 v = v / 10; 216 v = v / 10;
216 217
217 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { 218 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) {
218 return; 219 return;
219 } 220 }
220 221
221 int w=0; int h=0; 222 int w=0; int h=0;
222 if( !xineControl->hasVideo() ) { 223 if( !xineControl->hasVideo() ) {
223 w = audioUI->width(); 224 w = audioUI->width();
224 h = audioUI->height(); 225 h = audioUI->height();
225 226
226 if ( drawnOnScreenDisplay ) { 227 if ( drawnOnScreenDisplay ) {
227 if ( onScreenDisplayVolume > v ) { 228 if ( onScreenDisplayVolume > v ) {
228 audioUI->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); 229 audioUI->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE );
229 } 230 }
230 } 231 }
231 drawnOnScreenDisplay = TRUE; 232 drawnOnScreenDisplay = TRUE;
232 onScreenDisplayVolume = v; 233 onScreenDisplayVolume = v;
233 QPainter p( audioUI ); 234 QPainter p( audioUI );
234 p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); 235 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
235 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); 236 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
236 237
237 QFont f; 238 QFont f;
238 f.setPixelSize( 20 ); 239 f.setPixelSize( 20 );
239 f.setBold( TRUE ); 240 f.setBold( TRUE );
240 p.setFont( f ); 241 p.setFont( f );
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index 439ba2e..4c4cead 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -1,200 +1,194 @@
1/* 1/*
2 Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> 2 Copyright (C) 2002 Simon Hausmann <hausmann@kde.org>
3 (C) 2002 Max Reiss <harlekin@handhelds.org> 3 (C) 2002 Max Reiss <harlekin@handhelds.org>
4 (C) 2002 L. Potter <ljp@llornkcor.com> 4 (C) 2002 L. Potter <ljp@llornkcor.com>
5 (C) 2002 Holger Freyther <zecke@handhelds.org> 5 (C) 2002 Holger Freyther <zecke@handhelds.org>
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23 23
24#include "mediawidget.h" 24#include "mediawidget.h"
25#include "playlistwidget.h" 25#include "playlistwidget.h"
26 26
27MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name ) 27MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name )
28 : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) 28 : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList )
29{ 29{
30 connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ), 30 connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ),
31 this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) ); 31 this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) );
32 connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ), 32 connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ),
33 this, SLOT( setLength( long ) ) ); 33 this, SLOT( setLength( long ) ) );
34 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), 34 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ),
35 this, SLOT( setPlaying( bool ) ) ); 35 this, SLOT( setPlaying( bool ) ) );
36} 36}
37 37
38MediaWidget::~MediaWidget() 38MediaWidget::~MediaWidget()
39{ 39{
40} 40}
41 41
42void MediaWidget::closeEvent( QCloseEvent * ) 42void MediaWidget::closeEvent( QCloseEvent * )
43{ 43{
44 mediaPlayerState.setList(); 44 mediaPlayerState.setList();
45} 45}
46 46
47void MediaWidget::paintEvent( QPaintEvent *pe ) 47void MediaWidget::paintEvent( QPaintEvent *pe )
48{ 48{
49 QPainter p( this ); 49 QPainter p( this );
50 50
51 if ( mediaPlayerState.isFullscreen() ) { 51 if ( mediaPlayerState.isFullscreen() ) {
52 // Clear the background 52 // Clear the background
53 p.setBrush( QBrush( Qt::black ) ); 53 p.setBrush( QBrush( Qt::black ) );
54 return; 54 return;
55 } 55 }
56 56
57 if ( !pe->erased() ) { 57 if ( !pe->erased() ) {
58 // Combine with background and double buffer 58 // Combine with background and double buffer
59 QPixmap pix( pe->rect().size() ); 59 QPixmap pix( pe->rect().size() );
60 QPainter p( &pix ); 60 QPainter p( &pix );
61 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 61 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
62 p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() ); 62 p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() );
63 paintAllButtons( p ); 63 paintAllButtons( p );
64 QPainter p2( this ); 64 QPainter p2( this );
65 p2.drawPixmap( pe->rect().topLeft(), pix ); 65 p2.drawPixmap( pe->rect().topLeft(), pix );
66 } else { 66 } else {
67 QPainter p( this ); 67 QPainter p( this );
68 paintAllButtons( p ); 68 paintAllButtons( p );
69 } 69 }
70} 70}
71 71
72void MediaWidget::mouseMoveEvent( QMouseEvent *event ) 72MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position )
73{ 73{
74 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) { 74 if ( position.x() <= 0 || position.y() <= 0 ||
75 Button &button = *it; 75 position.x() >= buttonMask.width() ||
76 Command command = button.command; 76 position.y() >= buttonMask.height() )
77 77 return 0;
78 if ( event->state() == QMouseEvent::LeftButton ) { 78
79 // The test to see if the mouse click is inside the button or not 79 int pixelIdx = buttonMask.pixelIndex( position.x(), position.y() );
80 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, command ); 80 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it )
81 81 if ( it->command + 1 == pixelIdx )
82 if ( isOnButton && !button.isHeld ) { 82 return &( *it );
83 button.isHeld = TRUE; 83
84 toggleButton( button ); 84 return 0;
85 switch ( command ) {
86 case VolumeUp:
87 emit moreClicked();
88 return;
89 case VolumeDown:
90 emit lessClicked();
91 return;
92 case Forward:
93 emit forwardClicked();
94 return;
95 case Back:
96 emit backClicked();
97 return;
98 default: break;
99 }
100 } else if ( !isOnButton && button.isHeld ) {
101 button.isHeld = FALSE;
102 toggleButton( button );
103 }
104 } else {
105 if ( button.isHeld ) {
106 button.isHeld = FALSE;
107 if ( button.type != ToggleButton ) {
108 setToggleButton( button, FALSE );
109 }
110 handleCommand( command, button.isDown );
111 }
112 }
113 }
114} 85}
115 86
116void MediaWidget::mousePressEvent( QMouseEvent *event ) 87void MediaWidget::mousePressEvent( QMouseEvent *event )
117{ 88{
118 mouseMoveEvent( event ); 89 Button *button = buttonAt( event->pos() - upperLeftOfButtonMask );
90
91 if ( !button ) {
92 QWidget::mousePressEvent( event );
93 return;
94 }
95
96 switch ( button->command ) {
97 case VolumeUp: emit moreClicked(); return;
98 case VolumeDown: emit lessClicked(); return;
99 case Back: emit backClicked(); return;
100 case Forward: emit forwardClicked(); return;
101 default: break;
102 }
119} 103}
120 104
121void MediaWidget::mouseReleaseEvent( QMouseEvent *event ) 105void MediaWidget::mouseReleaseEvent( QMouseEvent *event )
122{ 106{
123 mouseMoveEvent( event ); 107 Button *button = buttonAt( event->pos() - upperLeftOfButtonMask );
108
109 if ( !button ) {
110 QWidget::mouseReleaseEvent( event );
111 return;
112 }
113
114 if ( button->type == ToggleButton )
115 toggleButton( *button );
116
117 handleCommand( button->command, button->isDown );
124} 118}
125 119
126void MediaWidget::makeVisible() 120void MediaWidget::makeVisible()
127{ 121{
128} 122}
129 123
130void MediaWidget::handleCommand( Command command, bool buttonDown ) 124void MediaWidget::handleCommand( Command command, bool buttonDown )
131{ 125{
132 switch ( command ) { 126 switch ( command ) {
133 case Play: mediaPlayerState.togglePaused(); 127 case Play: mediaPlayerState.togglePaused(); return;
134 case Stop: mediaPlayerState.setPlaying(FALSE); return; 128 case Stop: mediaPlayerState.setPlaying(FALSE); return;
135 case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; 129 case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return;
136 case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; 130 case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return;
137 case Loop: mediaPlayerState.setLooping( buttonDown ); return; 131 case Loop: mediaPlayerState.setLooping( buttonDown ); return;
138 case VolumeUp: emit moreReleased(); return; 132 case VolumeUp: emit moreReleased(); return;
139 case VolumeDown: emit lessReleased(); return; 133 case VolumeDown: emit lessReleased(); return;
140 case PlayList: mediaPlayerState.setList(); return; 134 case PlayList: mediaPlayerState.setList(); return;
141 case Forward: emit forwardReleased(); return; 135 case Forward: emit forwardReleased(); return;
142 case Back: emit backReleased(); return; 136 case Back: emit backReleased(); return;
143 case FullScreen: mediaPlayerState.setFullscreen( true ); makeVisible(); return; 137 case FullScreen: mediaPlayerState.setFullscreen( true ); makeVisible(); return;
144 default: assert( false ); 138 default: assert( false );
145 } 139 }
146} 140}
147 141
148bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const 142bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const
149{ 143{
150 return ( position.x() > 0 && position.y() > 0 && 144 return ( position.x() > 0 && position.y() > 0 &&
151 position.x() < buttonMask.width() && 145 position.x() < buttonMask.width() &&
152 position.y() < buttonMask.height() && 146 position.y() < buttonMask.height() &&
153 buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 ); 147 buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 );
154} 148}
155 149
156void MediaWidget::paintAllButtons( QPainter &p ) 150void MediaWidget::paintAllButtons( QPainter &p )
157{ 151{
158 for ( ButtonVector::const_iterator it = buttons.begin(); 152 for ( ButtonVector::const_iterator it = buttons.begin();
159 it != buttons.end(); ++it ) 153 it != buttons.end(); ++it )
160 paintButton( p, *it ); 154 paintButton( p, *it );
161} 155}
162 156
163void MediaWidget::paintButton( const Button &button ) 157void MediaWidget::paintButton( const Button &button )
164{ 158{
165 QPainter p( this ); 159 QPainter p( this );
166 paintButton( p, button ); 160 paintButton( p, button );
167} 161}
168 162
169void MediaWidget::paintButton( QPainter &p, const Button &button ) 163void MediaWidget::paintButton( QPainter &p, const Button &button )
170{ 164{
171 if ( button.isDown ) 165 if ( button.isDown )
172 p.drawPixmap( upperLeftOfButtonMask, button.pixDown ); 166 p.drawPixmap( upperLeftOfButtonMask, button.pixDown );
173 else 167 else
174 p.drawPixmap( upperLeftOfButtonMask, button.pixUp ); 168 p.drawPixmap( upperLeftOfButtonMask, button.pixUp );
175} 169}
176 170
177void MediaWidget::setToggleButton( Command command, bool down ) 171void MediaWidget::setToggleButton( Command command, bool down )
178{ 172{
179 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) 173 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it )
180 if ( it->command == command ) { 174 if ( it->command == command ) {
181 setToggleButton( *it, down ); 175 setToggleButton( *it, down );
182 return; 176 return;
183 } 177 }
184} 178}
185 179
186void MediaWidget::setToggleButton( Button &button, bool down ) 180void MediaWidget::setToggleButton( Button &button, bool down )
187{ 181{
188 if ( down != button.isDown ) 182 if ( down != button.isDown )
189 toggleButton( button ); 183 toggleButton( button );
190} 184}
191 185
192void MediaWidget::toggleButton( Button &button ) 186void MediaWidget::toggleButton( Button &button )
193{ 187{
194 button.isDown = !button.isDown; 188 button.isDown = !button.isDown;
195 189
196 paintButton( button ); 190 paintButton( button );
197} 191}
198 192
199/* vim: et sw=4 ts=4 193/* vim: et sw=4 ts=4
200 */ 194 */
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index 9042d5b..8031371 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -1,122 +1,123 @@
1/* 1/*
2 Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> 2 Copyright (C) 2002 Simon Hausmann <hausmann@kde.org>
3 (C) 2002 Max Reiss <harlekin@handhelds.org> 3 (C) 2002 Max Reiss <harlekin@handhelds.org>
4 (C) 2002 L. Potter <ljp@llornkcor.com> 4 (C) 2002 L. Potter <ljp@llornkcor.com>
5 (C) 2002 Holger Freyther <zecke@handhelds.org> 5 (C) 2002 Holger Freyther <zecke@handhelds.org>
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23#ifndef MEDIAWIDGET_H 23#ifndef MEDIAWIDGET_H
24#define MEDIAWIDGET_H 24#define MEDIAWIDGET_H
25 25
26#include <qwidget.h> 26#include <qwidget.h>
27#include <qmap.h> 27#include <qmap.h>
28 28
29#include "mediaplayerstate.h" 29#include "mediaplayerstate.h"
30#include "playlistwidget.h" 30#include "playlistwidget.h"
31 31
32#include <vector> 32#include <vector>
33 33
34class MediaWidget : public QWidget 34class MediaWidget : public QWidget
35{ 35{
36 Q_OBJECT 36 Q_OBJECT
37public: 37public:
38 enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back, FullScreen, Undefined }; 38 enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back, FullScreen, Undefined };
39 enum ButtonType { NormalButton, ToggleButton }; 39 enum ButtonType { NormalButton, ToggleButton };
40 40
41 struct Button 41 struct Button
42 { 42 {
43 Button() : command( Undefined ), type( NormalButton ), isHeld( false ), isDown( false ) {} 43 Button() : command( Undefined ), type( NormalButton ), isHeld( false ), isDown( false ) {}
44 44
45 Command command; 45 Command command;
46 46
47 ButtonType type; // this should be part of the bitfield but gcc2 is too buggy to support this :-( 47 ButtonType type; // this should be part of the bitfield but gcc2 is too buggy to support this :-(
48 bool isHeld : 1; 48 bool isHeld : 1;
49 bool isDown : 1; 49 bool isDown : 1;
50 50
51 QBitmap mask; 51 QBitmap mask;
52 QPixmap pixUp; 52 QPixmap pixUp;
53 QPixmap pixDown; 53 QPixmap pixDown;
54 }; 54 };
55 typedef std::vector<Button> ButtonVector; 55 typedef std::vector<Button> ButtonVector;
56 56
57 struct SkinButtonInfo 57 struct SkinButtonInfo
58 { 58 {
59 Command command; 59 Command command;
60 const char *fileName; 60 const char *fileName;
61 ButtonType type; 61 ButtonType type;
62 }; 62 };
63 63
64 typedef std::vector<QBitmap> MaskVector; 64 typedef std::vector<QBitmap> MaskVector;
65 typedef std::vector<QPixmap> PixmapVector; 65 typedef std::vector<QPixmap> PixmapVector;
66 66
67 MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); 67 MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 );
68 virtual ~MediaWidget(); 68 virtual ~MediaWidget();
69 69
70public slots: 70public slots:
71 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; 71 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0;
72 virtual void setLength( long length ) = 0; 72 virtual void setLength( long length ) = 0;
73 virtual void setPlaying( bool playing ) = 0; 73 virtual void setPlaying( bool playing ) = 0;
74 74
75signals: 75signals:
76 void moreReleased(); 76 void moreReleased();
77 void lessReleased(); 77 void lessReleased();
78 void forwardReleased(); 78 void forwardReleased();
79 void backReleased(); 79 void backReleased();
80 void forwardClicked(); 80 void forwardClicked();
81 void backClicked(); 81 void backClicked();
82 void moreClicked(); 82 void moreClicked();
83 void lessClicked(); 83 void lessClicked();
84 84
85protected: 85protected:
86 virtual void closeEvent( QCloseEvent * ); 86 virtual void closeEvent( QCloseEvent * );
87 87
88 virtual void paintEvent( QPaintEvent *pe ); 88 virtual void paintEvent( QPaintEvent *pe );
89 89
90 virtual void mouseMoveEvent( QMouseEvent *event ); 90 Button *buttonAt( const QPoint &position );
91
91 virtual void mousePressEvent( QMouseEvent *event ); 92 virtual void mousePressEvent( QMouseEvent *event );
92 virtual void mouseReleaseEvent( QMouseEvent *event ); 93 virtual void mouseReleaseEvent( QMouseEvent *event );
93 94
94 virtual void makeVisible(); 95 virtual void makeVisible();
95 96
96 void handleCommand( Command command, bool buttonDown ); 97 void handleCommand( Command command, bool buttonDown );
97 98
98 bool isOverButton( const QPoint &position, int buttonId ) const; 99 bool isOverButton( const QPoint &position, int buttonId ) const;
99 100
100 void paintAllButtons( QPainter &p ); 101 void paintAllButtons( QPainter &p );
101 void paintButton( const Button &button ); 102 void paintButton( const Button &button );
102 void paintButton( QPainter &p, const Button &button ); 103 void paintButton( QPainter &p, const Button &button );
103 104
104 void setToggleButton( Button &button, bool down ); 105 void setToggleButton( Button &button, bool down );
105 void setToggleButton( Command command, bool down ); 106 void setToggleButton( Command command, bool down );
106 void toggleButton( Button &button ); 107 void toggleButton( Button &button );
107 108
108 MediaPlayerState &mediaPlayerState; 109 MediaPlayerState &mediaPlayerState;
109 PlayListWidget &playList; 110 PlayListWidget &playList;
110 111
111 ButtonVector buttons; 112 ButtonVector buttons;
112 113
113 QImage buttonMask; 114 QImage buttonMask;
114 115
115 QPoint upperLeftOfButtonMask; 116 QPoint upperLeftOfButtonMask;
116 117
117 QPixmap backgroundPixmap; 118 QPixmap backgroundPixmap;
118}; 119};
119 120
120#endif // MEDIAWIDGET_H 121#endif // MEDIAWIDGET_H
121/* vim: et sw=4 ts=4 122/* vim: et sw=4 ts=4
122 */ 123 */