author | simon <simon> | 2002-12-09 13:24:25 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-09 13:24:25 (UTC) |
commit | 235ef0e11bfd61c0debb530de8598ae38a396914 (patch) (side-by-side diff) | |
tree | ee014a888c1130707fadd890d2cc4fa492ed01cb | |
parent | 94a4c102d20eb63104a66fd8fba141a716ae3623 (diff) | |
download | opie-235ef0e11bfd61c0debb530de8598ae38a396914.zip opie-235ef0e11bfd61c0debb530de8598ae38a396914.tar.gz opie-235ef0e11bfd61c0debb530de8598ae38a396914.tar.bz2 |
- one global variable less
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 7 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.h | 1 |
2 files changed, 4 insertions, 4 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 8f34736..adef247 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp @@ -27,97 +27,99 @@ -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <qpe/qpeapplication.h> #include <qpe/resource.h> #include <qpe/config.h> #include <opie/oticker.h> #include <qwidget.h> #include <qpixmap.h> #include <qbutton.h> #include <qpainter.h> #include <qframe.h> #include <qlayout.h> #include <qdir.h> #include <stdlib.h> #include <stdio.h> #include "audiowidget.h" #include "mediaplayerstate.h" #include "playlistwidget.h" namespace { const int xo = -2; // movable x offset const int yo = 22; // movable y offset const char * const skin_mask_file_names[10] = { "play", "stop", "next", "prev", "up", "down", "loop", "playlist", "forward", "back" }; void changeTextColor( QWidget * w) { QPalette p = w->palette(); p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); w->setPalette( p ); } } AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : - MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { + MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ), + audioSliderBeingMoved( false ) +{ Button defaultButton; defaultButton.isToggle = defaultButton.isHeld = defaultButton.isDown = false; Button toggleButton; toggleButton.isToggle = true; toggleButton.isHeld = toggleButton.isDown = false; buttons.reserve( 10 ); buttons.push_back( toggleButton ); // play buttons.push_back( defaultButton ); // stop buttons.push_back( defaultButton ); // next buttons.push_back( defaultButton ); // previous buttons.push_back( defaultButton ); // volume up buttons.push_back( defaultButton ); // volume down buttons.push_back( toggleButton ); // repeat/loop buttons.push_back( defaultButton ); // playlist buttons.push_back( defaultButton ); // forward buttons.push_back( defaultButton ); // back setCaption( tr("OpiePlayer") ); Config cfg("OpiePlayer"); cfg.setGroup("Options"); skin = cfg.readEntry("Skin","default"); //skin = "scaleTest"; // color of background, frame, degree of transparency QString skinPath = "opieplayer2/skins/" + skin; pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); buttonMask.fill( 0 ); for ( int i = 0; i < 10; i++ ) { QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" ); masks[i] = new QBitmap( filename ); if ( !masks[i]->isNull() ) { QImage imgMask = masks[i]->convertToImage(); uchar **dest = buttonMask.jumpTable(); for ( int y = 0; y < imgUp.height(); y++ ) { uchar *line = dest[y]; for ( int x = 0; x < imgUp.width(); x++ ) if ( !qRed( imgMask.pixel( x, y ) ) ) line[x] = i + 1; } @@ -187,99 +189,96 @@ AudioWidget::~AudioWidget() { } namespace { 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 ); return pix; } QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { QPixmap *pixmap = new QPixmap( pix ); pixmap->setMask( mask ); return pixmap; } }; void AudioWidget::resizeEvent( QResizeEvent * ) { int h = height(); int w = width(); songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); slider.setFixedWidth( w - 110 ); slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); slider.setBackgroundOrigin( QWidget::ParentOrigin ); time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); upperLeftOfButtonMask.rx() = ( w - imgUp.width() ) / 2; upperLeftOfButtonMask.ry() = (( h - imgUp.height() ) / 2) - 10; QPoint p = upperLeftOfButtonMask; QPixmap pixUp = combineImageWithBackground( imgUp, pixBg, p ); QPixmap pixDn = combineImageWithBackground( imgDn, pixBg, p ); for ( int i = 0; i < 10; i++ ) { if ( !masks[i]->isNull() ) { delete buttonPixUp[i]; delete buttonPixDown[i]; buttonPixUp[i] = maskPixToMask( pixUp, *masks[i] ); buttonPixDown[i] = maskPixToMask( pixDn, *masks[i] ); } } } -static bool audioSliderBeingMoved = FALSE; - - void AudioWidget::sliderPressed() { audioSliderBeingMoved = TRUE; } void AudioWidget::sliderReleased() { audioSliderBeingMoved = FALSE; if ( slider.width() == 0 ) return; long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); mediaPlayerState.setPosition( val ); } void AudioWidget::setPosition( long i ) { // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); updateSlider( i, mediaPlayerState.length() ); } void AudioWidget::setLength( long max ) { updateSlider( mediaPlayerState.position(), max ); } void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { if ( mediaType == MediaPlayerState::Audio ) { // startTimer( 150 ); showMaximized(); return; } killTimers(); hide(); } void AudioWidget::setSeekable( bool isSeekable ) { if ( !isSeekable ) { qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); if( !slider.isHidden()) { slider.hide(); } disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); } else { diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h index 4598d51..8426490 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.h +++ b/noncore/multimedia/opieplayer2/audiowidget.h @@ -62,53 +62,54 @@ public slots: void setLooping( bool b) { setToggleButton( Loop, b ); } void setPosition( long ); void setSeekable( bool ); public: virtual void setLength( long ); virtual void setPlaying( bool b) { setToggleButton( Play, b ); } virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); signals: void moreClicked(); void lessClicked(); void forwardClicked(); void backClicked(); void sliderMoved(long); protected: void doBlank(); void doUnblank(); void paintEvent( QPaintEvent *pe ); void showEvent( QShowEvent *se ); void resizeEvent( QResizeEvent *re ); void mouseMoveEvent( QMouseEvent *event ); void mousePressEvent( QMouseEvent *event ); void mouseReleaseEvent( QMouseEvent *event ); void timerEvent( QTimerEvent *event ); void keyReleaseEvent( QKeyEvent *e); private slots: void skipFor(); void skipBack(); void stopSkip(); private: void setToggleButton( int, bool ); virtual void paintButton( QPainter &p, int i ); int skipDirection; QString skin; QPixmap pixBg; QImage imgUp; QImage imgDn; QBitmap *masks[10]; QPixmap *buttonPixUp[10]; QPixmap *buttonPixDown[10]; QPixmap *pixmaps[4]; OTicker songInfo; QSlider slider; QLineEdit time; bool isStreaming : 1; + bool audioSliderBeingMoved : 1; }; #endif // AUDIO_WIDGET_H |