-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 8 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 3 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.cpp | 84 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediawidget.h | 3 |
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 | |||
@@ -347,4 +347,5 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e) { | |||
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 |
@@ -352,4 +353,5 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e) { | |||
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 |
@@ -357,6 +359,8 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e) { | |||
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 | } |
@@ -367,4 +371,5 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e) { | |||
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: |
@@ -373,4 +378,5 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e) { | |||
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: |
@@ -378,4 +384,5 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e) { | |||
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: |
@@ -383,4 +390,5 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e) { | |||
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: { |
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 | |||
@@ -46,5 +46,6 @@ MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPla | |||
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() ) ); |
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 | |||
@@ -70,56 +70,50 @@ void MediaWidget::paintEvent( QPaintEvent *pe ) | |||
70 | } | 70 | } |
71 | 71 | ||
72 | void MediaWidget::mouseMoveEvent( QMouseEvent *event ) | 72 | MediaWidget::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 | ||
116 | void MediaWidget::mousePressEvent( QMouseEvent *event ) | 87 | void 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 | ||
121 | void MediaWidget::mouseReleaseEvent( QMouseEvent *event ) | 105 | void 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 | ||
@@ -131,5 +125,5 @@ void 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; |
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 | |||
@@ -88,5 +88,6 @@ protected: | |||
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 ); |