summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/audiowidget.cpp
Side-by-side diff
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
@@ -8,30 +8,33 @@
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
+#include <qpe/qpeapplication.h>
+#include <qpe/resource.h>
+
#include <qwidget.h>
#include <qpixmap.h>
#include <qbutton.h>
#include <qpainter.h>
#include <qframe.h>
-#include <qpe/resource.h>
+
#include "audiowidget.h"
#include "mediaplayerstate.h"
extern MediaPlayerState *mediaPlayerState;
static const int xo = -2; // movable x offset
static const int yo = 22; // movable y offset
struct MediaButton {
int xPos, yPos;
@@ -51,24 +54,25 @@ MediaButton audioButtons[] = {
{ 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down
{ 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop
{ 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist
};
static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
QWidget( parent, name, f )
{
+// QPEApplication::grabKeyboard();
setCaption( tr("OpiePlayer") );
setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) );
pixmaps[0] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsAll" ) );
pixmaps[1] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsBig" ) );
pixmaps[2] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaControls" ) );
pixmaps[3] = new QPixmap( Resource::loadPixmap( "mpegplayer/animatedButton" ) );
songInfo = new Ticker( this );
songInfo->setFocusPolicy( QWidget::NoFocus );
songInfo->setGeometry( QRect( 7, 3, 220, 20 ) );
slider = new QSlider( Qt::Horizontal, this );
@@ -191,66 +195,67 @@ void AudioWidget::timerEvent( QTimerEvent * ) {
int x = audioButtons[AudioPlay].xPos;
int y = audioButtons[AudioPlay].yPos;
QPainter p( this );
// Optimize to only draw the little bit of the changing images which is different
p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 );
p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 );
}
}
void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
for ( int i = 0; i < numButtons; i++ ) {
- int size = audioButtons[i].isBig;
- int x = audioButtons[i].xPos;
- int y = audioButtons[i].yPos;
- if ( event->state() == QMouseEvent::LeftButton ) {
- // The test to see if the mouse click is inside the circular button or not
- // (compared with the radius squared to avoid a square-root of our distance)
- int radius = 32 + 13 * size;
- QPoint center = QPoint( x + radius, y + radius );
- QPoint dXY = center - event->pos();
- int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y();
- bool isOnButton = dist <= (radius * radius);
+ int size = audioButtons[i].isBig;
+ int x = audioButtons[i].xPos;
+ int y = audioButtons[i].yPos;
+ if ( event->state() == QMouseEvent::LeftButton ) {
+ // The test to see if the mouse click is inside the circular button or not
+ // (compared with the radius squared to avoid a square-root of our distance)
+ int radius = 32 + 13 * size;
+ QPoint center = QPoint( x + radius, y + radius );
+ QPoint dXY = center - event->pos();
+ int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y();
+ bool isOnButton = dist <= (radius * radius);
// QRect r( x, y, 64 + 22*size, 64 + 22*size );
// bool isOnButton = r.contains( event->pos() ); // Rectangular Button code
- if ( isOnButton && !audioButtons[i].isHeld ) {
- audioButtons[i].isHeld = TRUE;
- toggleButton(i);
- switch (i) {
- case AudioVolumeUp: emit moreClicked(); return;
- case AudioVolumeDown: emit lessClicked(); return;
- }
- } else if ( !isOnButton && audioButtons[i].isHeld ) {
- audioButtons[i].isHeld = FALSE;
- toggleButton(i);
- }
- } else {
- if ( audioButtons[i].isHeld ) {
- audioButtons[i].isHeld = FALSE;
- if ( !audioButtons[i].isToggle )
- setToggleButton( i, FALSE );
- switch (i) {
- case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return;
- case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
- case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return;
- case AudioNext: mediaPlayerState->setNext(); return;
- case AudioPrevious: mediaPlayerState->setPrev(); return;
- case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return;
- case AudioVolumeUp: emit moreReleased(); return;
- case AudioVolumeDown: emit lessReleased(); return;
- case AudioPlayList: mediaPlayerState->setList(); return;
- }
- }
- }
+ if ( isOnButton && !audioButtons[i].isHeld ) {
+ audioButtons[i].isHeld = TRUE;
+ toggleButton(i);
+ qDebug("button toggled %d",i);
+ switch (i) {
+ case AudioVolumeUp: emit moreClicked(); return;
+ case AudioVolumeDown: emit lessClicked(); return;
+ }
+ } else if ( !isOnButton && audioButtons[i].isHeld ) {
+ audioButtons[i].isHeld = FALSE;
+ toggleButton(i);
+ }
+ } else {
+ if ( audioButtons[i].isHeld ) {
+ audioButtons[i].isHeld = FALSE;
+ if ( !audioButtons[i].isToggle )
+ setToggleButton( i, FALSE );
+ switch (i) {
+ case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return;
+ case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
+ case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return;
+ case AudioNext: mediaPlayerState->setNext(); return;
+ case AudioPrevious: mediaPlayerState->setPrev(); return;
+ case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return;
+ case AudioVolumeUp: emit moreReleased(); return;
+ case AudioVolumeDown: emit lessReleased(); return;
+ case AudioPlayList: mediaPlayerState->setList(); return;
+ }
+ }
+ }
}
}
void AudioWidget::mousePressEvent( QMouseEvent *event ) {
mouseMoveEvent( event );
}
void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
mouseMoveEvent( event );
}
@@ -265,12 +270,67 @@ void AudioWidget::showEvent( QShowEvent* ) {
void AudioWidget::closeEvent( QCloseEvent* ) {
mediaPlayerState->setList();
}
void AudioWidget::paintEvent( QPaintEvent * ) {
QPainter p( this );
for ( int i = 0; i < numButtons; i++ )
paintButton( &p, i );
}
+void AudioWidget::keyReleaseEvent( QKeyEvent *e)
+{
+ switch ( e->key() ) {
+////////////////////////////// Zaurus keys
+ case Key_Home:
+ break;
+ case Key_F9: //activity
+ break;
+ case Key_F10: //contacts
+ break;
+ case Key_F11: //menu
+ break;
+ case Key_F12: //home
+ break;
+ case Key_F13: //mail
+ break;
+ case Key_Space: {
+ if(mediaPlayerState->playing()) {
+// toggleButton(1);
+ mediaPlayerState->setPlaying(FALSE);
+// toggleButton(1);
+ } else {
+// toggleButton(0);
+ mediaPlayerState->setPlaying(TRUE);
+// toggleButton(0);
+ }
+ }
+ break;
+ case Key_Down:
+ toggleButton(6);
+ emit lessClicked();
+ emit lessReleased();
+ toggleButton(6);
+ break;
+ case Key_Up:
+ toggleButton(5);
+ emit moreClicked();
+ emit moreReleased();
+ toggleButton(5);
+ break;
+ case Key_Right:
+// toggleButton(3);
+ mediaPlayerState->setNext();
+// toggleButton(3);
+ break;
+ case Key_Left:
+// toggleButton(4);
+ mediaPlayerState->setPrev();
+// toggleButton(4);
+ break;
+ case Key_Escape:
+ break;
+
+ };
+}