Diffstat (limited to 'core/multimedia/opieplayer/audiowidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/audiowidget.cpp | 62 |
1 files changed, 61 insertions, 1 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 | |||
@@ -8,30 +8,33 @@ | |||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
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 | ||
29 | extern MediaPlayerState *mediaPlayerState; | 32 | extern MediaPlayerState *mediaPlayerState; |
30 | 33 | ||
31 | 34 | ||
32 | static const int xo = -2; // movable x offset | 35 | static const int xo = -2; // movable x offset |
33 | static const int yo = 22; // movable y offset | 36 | static const int yo = 22; // movable y offset |
34 | 37 | ||
35 | 38 | ||
36 | struct MediaButton { | 39 | struct MediaButton { |
37 | int xPos, yPos; | 40 | int xPos, yPos; |
@@ -51,24 +54,25 @@ MediaButton audioButtons[] = { | |||
51 | { 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down | 54 | { 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down |
52 | { 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop | 55 | { 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop |
53 | { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist | 56 | { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist |
54 | }; | 57 | }; |
55 | 58 | ||
56 | 59 | ||
57 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); | 60 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); |
58 | 61 | ||
59 | 62 | ||
60 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | 63 | AudioWidget::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" ) ); |
69 | 73 | ||
70 | songInfo = new Ticker( this ); | 74 | songInfo = new Ticker( this ); |
71 | songInfo->setFocusPolicy( QWidget::NoFocus ); | 75 | songInfo->setFocusPolicy( QWidget::NoFocus ); |
72 | songInfo->setGeometry( QRect( 7, 3, 220, 20 ) ); | 76 | songInfo->setGeometry( QRect( 7, 3, 220, 20 ) ); |
73 | 77 | ||
74 | slider = new QSlider( Qt::Horizontal, this ); | 78 | slider = new QSlider( Qt::Horizontal, this ); |
@@ -207,24 +211,25 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | |||
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); |
223 | qDebug("button toggled %d",i); | ||
219 | switch (i) { | 224 | switch (i) { |
220 | case AudioVolumeUp: emit moreClicked(); return; | 225 | case AudioVolumeUp: emit moreClicked(); return; |
221 | case AudioVolumeDown: emit lessClicked(); return; | 226 | case AudioVolumeDown: emit lessClicked(); return; |
222 | } | 227 | } |
223 | } else if ( !isOnButton && audioButtons[i].isHeld ) { | 228 | } else if ( !isOnButton && audioButtons[i].isHeld ) { |
224 | audioButtons[i].isHeld = FALSE; | 229 | audioButtons[i].isHeld = FALSE; |
225 | toggleButton(i); | 230 | toggleButton(i); |
226 | } | 231 | } |
227 | } else { | 232 | } else { |
228 | if ( audioButtons[i].isHeld ) { | 233 | if ( audioButtons[i].isHeld ) { |
229 | audioButtons[i].isHeld = FALSE; | 234 | audioButtons[i].isHeld = FALSE; |
230 | if ( !audioButtons[i].isToggle ) | 235 | if ( !audioButtons[i].isToggle ) |
@@ -265,12 +270,67 @@ void AudioWidget::showEvent( QShowEvent* ) { | |||
265 | void AudioWidget::closeEvent( QCloseEvent* ) { | 270 | void AudioWidget::closeEvent( QCloseEvent* ) { |
266 | mediaPlayerState->setList(); | 271 | mediaPlayerState->setList(); |
267 | } | 272 | } |
268 | 273 | ||
269 | 274 | ||
270 | void AudioWidget::paintEvent( QPaintEvent * ) { | 275 | 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 | ||
282 | void 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 | } | ||