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
@@ -285,107 +285,115 @@ static QString timeAsString( long length ) {
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,112 +1,113 @@
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() ) {
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
@@ -8,190 +8,184 @@
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}
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
@@ -26,97 +26,98 @@
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 */