-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 26 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.h | 3 |
2 files changed, 14 insertions, 15 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index cc6187c..132a911 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp @@ -169,63 +169,63 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : setBackgroundPixmap( *pixBg ); songInfo.setFocusPolicy( QWidget::NoFocus ); changeTextColor( &songInfo ); slider.setFixedHeight( 20 ); slider.setMinValue( 0 ); slider.setMaxValue( 1 ); slider.setFocusPolicy( QWidget::NoFocus ); slider.setBackgroundPixmap( *pixBg ); time.setFocusPolicy( QWidget::NoFocus ); time.setAlignment( Qt::AlignCenter ); time.setFrame(FALSE); changeTextColor( &time ); resizeEvent( NULL ); connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); - connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); +// connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); // Intialise state setLength( mediaPlayerState->length() ); setPosition( mediaPlayerState->position() ); setLooping( mediaPlayerState->fullscreen() ); - setPaused( mediaPlayerState->paused() ); +// setPaused( mediaPlayerState->paused() ); setPlaying( mediaPlayerState->playing() ); } AudioWidget::~AudioWidget() { for ( int i = 0; i < 10; i++ ) { delete buttonPixUp[i]; delete buttonPixDown[i]; } delete pixBg; delete imgUp; delete imgDn; delete imgButtonMask; for ( int i = 0; i < 10; i++ ) { delete masks[i]; } } QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { QPixmap pix( img.width(), img.height() ); QPainter p( &pix ); p.drawTiledPixmap( pix.rect(), bg, offset ); p.drawImage( 0, 0, img ); @@ -338,48 +338,49 @@ void AudioWidget::updateSlider( long i, long max ) { time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; if ( max == 0 ) { return; } // Will flicker too much if we don't do this // Scale to something reasonable int width = slider.width(); int val = int((double)i * width / max); if ( !audioSliderBeingMoved ) { if ( slider.value() != val ) { slider.setValue( val ); } if ( slider.maxValue() != width ) { slider.setMaxValue( width ); } } } void AudioWidget::setToggleButton( int i, bool down ) { + qDebug("setToggleButton %d", i); if ( down != audioButtons[i].isDown ) { toggleButton( i ); } } void AudioWidget::toggleButton( int i ) { audioButtons[i].isDown = !audioButtons[i].isDown; QPainter p(this); paintButton ( &p, i ); } void AudioWidget::paintButton( QPainter *p, int i ) { if ( audioButtons[i].isDown ) { p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); } else { p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); } } void AudioWidget::skipFor() { skipDirection = +1; @@ -402,82 +403,81 @@ void AudioWidget::stopSkip() { void AudioWidget::timerEvent( QTimerEvent * ) { if ( skipDirection == +1 ) { mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); } else if ( skipDirection == -1 ) { mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); } } void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { for ( int i = 0; i < numButtons; i++ ) { if ( event->state() == QMouseEvent::LeftButton ) { // The test to see if the mouse click is inside the button or not int x = event->pos().x() - xoff; int y = event->pos().y() - yoff; bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); if ( isOnButton && !audioButtons[i].isHeld ) { audioButtons[i].isHeld = TRUE; toggleButton(i); - switch (i) { case AudioVolumeUp: emit moreClicked(); return; case AudioVolumeDown: emit lessClicked(); return; case AudioForward: emit forwardClicked(); return; case AudioBack: emit backClicked(); return; } - } else if ( !isOnButton && audioButtons[i].isHeld ) { - audioButtons[i].isHeld = FALSE; - toggleButton(i); } + 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 ); - qDebug("button toggled3 %d",i); } switch (i) { case AudioPlay: if( mediaPlayerState->isPaused ) { - setToggleButton( i, FALSE ); +// setToggleButton( i, FALSE ); mediaPlayerState->setPaused( FALSE ); return; } else if( !mediaPlayerState->isPaused ) { - setToggleButton( i, TRUE ); +// setToggleButton( i, TRUE ); mediaPlayerState->setPaused( TRUE ); return; } else { // setToggleButton( i, TRUE ); // mediaPlayerState->setPlaying( videoButtons[i].isDown ); } case AudioStop: mediaPlayerState->setPlaying(FALSE); 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; case AudioForward: emit forwardReleased(); return; case AudioBack: emit backReleased(); return; } } } } } void AudioWidget::mousePressEvent( QMouseEvent *event ) { mouseMoveEvent( event ); @@ -528,50 +528,50 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e) hide(); // qDebug("Audio F9"); 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); +// toggleButton(6); emit lessClicked(); emit lessReleased(); - toggleButton(6); +// toggleButton(6); break; case Key_Up: - toggleButton(5); +// toggleButton(5); emit moreClicked(); emit moreReleased(); - toggleButton(5); +// 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; }; } diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h index 772d1d1..e7da6c5 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.h +++ b/noncore/multimedia/opieplayer2/audiowidget.h @@ -28,89 +28,88 @@ If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef AUDIO_WIDGET_H #define AUDIO_WIDGET_H #include <qwidget.h> #include <qpainter.h> #include <qdrawutil.h> #include <qpixmap.h> #include <qstring.h> #include <qslider.h> #include <qframe.h> #include <qlineedit.h> class QPixmap; enum AudioButtons { AudioPlay=0, AudioStop, - AudioPause, AudioNext, AudioPrevious, AudioVolumeUp, AudioVolumeDown, AudioLoop, AudioPlayList, AudioForward, AudioBack }; class Ticker : public QFrame { Q_OBJECT public: Ticker( QWidget* parent=0 ); ~Ticker(); void setText( const QString& text ) ; protected: void timerEvent( QTimerEvent * ); void drawContents( QPainter *p ); private: QString scrollText; int pos, pixelLen; }; class AudioWidget : public QWidget { Q_OBJECT public: AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); ~AudioWidget(); void setTickerText( const QString &text ) { songInfo.setText( text ); } bool isStreaming; public slots: void updateSlider( long, long ); void sliderPressed( ); void sliderReleased( ); - void setPaused( bool b) { setToggleButton( AudioPause, b ); } +// void setPaused( bool b) { setToggleButton( AudioPause, b ); } void setLooping( bool b) { setToggleButton( AudioLoop, b ); } void setPlaying( bool b) { setToggleButton( AudioPlay, b ); } void setPosition( long ); void setLength( long ); void setView( char ); signals: void moreClicked(); void lessClicked(); void moreReleased(); void lessReleased(); void forwardClicked(); void backClicked(); void forwardReleased(); void backReleased(); void sliderMoved(long); protected: void doBlank(); void doUnblank(); void paintEvent( QPaintEvent *pe ); void showEvent( QShowEvent *se ); void resizeEvent( QResizeEvent *re ); void mouseMoveEvent( QMouseEvent *event ); |