summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-09 20:02:52 (UTC)
committer simon <simon>2002-12-09 20:02:52 (UTC)
commit2d2d57e3b7988f4246319cdfd0dc7fa90110db8e (patch) (unidiff)
treefb4dfb832e2630e7da1cc57e92ba6c62ead22dee
parent046f040efcb0f313818d1dbb1dc1db9021678175 (diff)
downloadopie-2d2d57e3b7988f4246319cdfd0dc7fa90110db8e.zip
opie-2d2d57e3b7988f4246319cdfd0dc7fa90110db8e.tar.gz
opie-2d2d57e3b7988f4246319cdfd0dc7fa90110db8e.tar.bz2
- reworked the mouse event handling to be much simpler
- fixed missing return in Play case in handleCommand, which accidentially broke pausing - accept the key events we receive in the audioWidget - commented out suspicious connect to pauseCheck in mediaplayer, which broke pausing via space bar
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
@@ -343,48 +343,56 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e) {
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 };
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
@@ -42,13 +42,14 @@ MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPla
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;
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
@@ -66,74 +66,68 @@ void MediaWidget::paintEvent( QPaintEvent *pe )
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;
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
@@ -84,13 +84,14 @@ signals:
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 );