summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/audiowidget.cpp
Unidiff
Diffstat (limited to 'core/multimedia/opieplayer/audiowidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/audiowidget.cpp142
1 files changed, 101 insertions, 41 deletions
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp
index 582660c..3901446 100644
--- a/core/multimedia/opieplayer/audiowidget.cpp
+++ b/core/multimedia/opieplayer/audiowidget.cpp
@@ -14,18 +14,21 @@
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qpe/qpeapplication.h>
21#include <qpe/resource.h>
22
20#include <qwidget.h> 23#include <qwidget.h>
21#include <qpixmap.h> 24#include <qpixmap.h>
22#include <qbutton.h> 25#include <qbutton.h>
23#include <qpainter.h> 26#include <qpainter.h>
24#include <qframe.h> 27#include <qframe.h>
25#include <qpe/resource.h> 28
26#include "audiowidget.h" 29#include "audiowidget.h"
27#include "mediaplayerstate.h" 30#include "mediaplayerstate.h"
28 31
29extern MediaPlayerState *mediaPlayerState; 32extern MediaPlayerState *mediaPlayerState;
30 33
31 34
@@ -57,12 +60,13 @@ MediaButton audioButtons[] = {
57static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); 60static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
58 61
59 62
60AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : 63AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
61 QWidget( parent, name, f ) 64 QWidget( parent, name, f )
62{ 65{
66// QPEApplication::grabKeyboard();
63 setCaption( tr("OpiePlayer") ); 67 setCaption( tr("OpiePlayer") );
64 setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); 68 setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) );
65 pixmaps[0] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsAll" ) ); 69 pixmaps[0] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsAll" ) );
66 pixmaps[1] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsBig" ) ); 70 pixmaps[1] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsBig" ) );
67 pixmaps[2] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaControls" ) ); 71 pixmaps[2] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaControls" ) );
68 pixmaps[3] = new QPixmap( Resource::loadPixmap( "mpegplayer/animatedButton" ) ); 72 pixmaps[3] = new QPixmap( Resource::loadPixmap( "mpegplayer/animatedButton" ) );
@@ -197,54 +201,55 @@ void AudioWidget::timerEvent( QTimerEvent * ) {
197 } 201 }
198} 202}
199 203
200 204
201void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 205void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
202 for ( int i = 0; i < numButtons; i++ ) { 206 for ( int i = 0; i < numButtons; i++ ) {
203 int size = audioButtons[i].isBig; 207 int size = audioButtons[i].isBig;
204 int x = audioButtons[i].xPos; 208 int x = audioButtons[i].xPos;
205 int y = audioButtons[i].yPos; 209 int y = audioButtons[i].yPos;
206 if ( event->state() == QMouseEvent::LeftButton ) { 210 if ( event->state() == QMouseEvent::LeftButton ) {
207 // The test to see if the mouse click is inside the circular button or not 211 // The test to see if the mouse click is inside the circular button or not
208 // (compared with the radius squared to avoid a square-root of our distance) 212 // (compared with the radius squared to avoid a square-root of our distance)
209 int radius = 32 + 13 * size; 213 int radius = 32 + 13 * size;
210 QPoint center = QPoint( x + radius, y + radius ); 214 QPoint center = QPoint( x + radius, y + radius );
211 QPoint dXY = center - event->pos(); 215 QPoint dXY = center - event->pos();
212 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); 216 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y();
213 bool isOnButton = dist <= (radius * radius); 217 bool isOnButton = dist <= (radius * radius);
214// QRect r( x, y, 64 + 22*size, 64 + 22*size ); 218// QRect r( x, y, 64 + 22*size, 64 + 22*size );
215// bool isOnButton = r.contains( event->pos() ); // Rectangular Button code 219// bool isOnButton = r.contains( event->pos() ); // Rectangular Button code
216 if ( isOnButton && !audioButtons[i].isHeld ) { 220 if ( isOnButton && !audioButtons[i].isHeld ) {
217 audioButtons[i].isHeld = TRUE; 221 audioButtons[i].isHeld = TRUE;
218 toggleButton(i); 222 toggleButton(i);
219 switch (i) { 223 qDebug("button toggled %d",i);
220 case AudioVolumeUp: emit moreClicked(); return; 224 switch (i) {
221 case AudioVolumeDown: emit lessClicked(); return; 225 case AudioVolumeUp: emit moreClicked(); return;
222 } 226 case AudioVolumeDown: emit lessClicked(); return;
223 } else if ( !isOnButton && audioButtons[i].isHeld ) { 227 }
224 audioButtons[i].isHeld = FALSE; 228 } else if ( !isOnButton && audioButtons[i].isHeld ) {
225 toggleButton(i); 229 audioButtons[i].isHeld = FALSE;
226 } 230 toggleButton(i);
227 } else { 231 }
228 if ( audioButtons[i].isHeld ) { 232 } else {
229 audioButtons[i].isHeld = FALSE; 233 if ( audioButtons[i].isHeld ) {
230 if ( !audioButtons[i].isToggle ) 234 audioButtons[i].isHeld = FALSE;
231 setToggleButton( i, FALSE ); 235 if ( !audioButtons[i].isToggle )
232 switch (i) { 236 setToggleButton( i, FALSE );
233 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; 237 switch (i) {
234 case AudioStop: mediaPlayerState->setPlaying(FALSE); return; 238 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return;
235 case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; 239 case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
236 case AudioNext: mediaPlayerState->setNext(); return; 240 case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return;
237 case AudioPrevious: mediaPlayerState->setPrev(); return; 241 case AudioNext: mediaPlayerState->setNext(); return;
238 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; 242 case AudioPrevious: mediaPlayerState->setPrev(); return;
239 case AudioVolumeUp: emit moreReleased(); return; 243 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return;
240 case AudioVolumeDown: emit lessReleased(); return; 244 case AudioVolumeUp: emit moreReleased(); return;
241 case AudioPlayList: mediaPlayerState->setList(); return; 245 case AudioVolumeDown: emit lessReleased(); return;
242 } 246 case AudioPlayList: mediaPlayerState->setList(); return;
243 } 247 }
244 } 248 }
249 }
245 } 250 }
246} 251}
247 252
248 253
249void AudioWidget::mousePressEvent( QMouseEvent *event ) { 254void AudioWidget::mousePressEvent( QMouseEvent *event ) {
250 mouseMoveEvent( event ); 255 mouseMoveEvent( event );
@@ -271,6 +276,61 @@ void AudioWidget::paintEvent( QPaintEvent * ) {
271 QPainter p( this ); 276 QPainter p( this );
272 for ( int i = 0; i < numButtons; i++ ) 277 for ( int i = 0; i < numButtons; i++ )
273 paintButton( &p, i ); 278 paintButton( &p, i );
274} 279}
275 280
276 281
282void AudioWidget::keyReleaseEvent( QKeyEvent *e)
283{
284 switch ( e->key() ) {
285////////////////////////////// Zaurus keys
286 case Key_Home:
287 break;
288 case Key_F9: //activity
289 break;
290 case Key_F10: //contacts
291 break;
292 case Key_F11: //menu
293 break;
294 case Key_F12: //home
295 break;
296 case Key_F13: //mail
297 break;
298 case Key_Space: {
299 if(mediaPlayerState->playing()) {
300// toggleButton(1);
301 mediaPlayerState->setPlaying(FALSE);
302// toggleButton(1);
303 } else {
304// toggleButton(0);
305 mediaPlayerState->setPlaying(TRUE);
306// toggleButton(0);
307 }
308 }
309 break;
310 case Key_Down:
311 toggleButton(6);
312 emit lessClicked();
313 emit lessReleased();
314 toggleButton(6);
315 break;
316 case Key_Up:
317 toggleButton(5);
318 emit moreClicked();
319 emit moreReleased();
320 toggleButton(5);
321 break;
322 case Key_Right:
323// toggleButton(3);
324 mediaPlayerState->setNext();
325// toggleButton(3);
326 break;
327 case Key_Left:
328// toggleButton(4);
329 mediaPlayerState->setPrev();
330// toggleButton(4);
331 break;
332 case Key_Escape:
333 break;
334
335 };
336}