Diffstat (limited to 'core/multimedia/opieplayer/audiowidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/audiowidget.cpp | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp index a1973e9..b187cb4 100644 --- a/core/multimedia/opieplayer/audiowidget.cpp +++ b/core/multimedia/opieplayer/audiowidget.cpp @@ -73,13 +73,13 @@ static void changeTextColor( QWidget *w ) { static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { setCaption( tr("OpiePlayer") ); - qDebug("<<<<<audioWidget"); + // qDebug("<<<<<audioWidget"); Config cfg("OpiePlayer"); cfg.setGroup("Options"); skin = cfg.readEntry("Skin","default"); //skin = "scaleTest"; // color of background, frame, degree of transparency @@ -87,13 +87,13 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : // QString skinPath = "opieplayer/skins/" + skin; QString skinPath; skinPath = "opieplayer2/skins/" + skin; if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists()) skinPath = "opieplayer2/skins/default"; - qDebug("skin path " + skinPath); + // qDebug("skin path " + skinPath); pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); @@ -157,28 +157,29 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : // Intialise state setLength( mediaPlayerState->length() ); setPosition( mediaPlayerState->position() ); setLooping( mediaPlayerState->fullscreen() ); // setPaused( mediaPlayerState->paused() ); setPlaying( mediaPlayerState->playing() ); - +this->setFocus(); } AudioWidget::~AudioWidget() { + // setPlaying( false); for ( int i = 0; i < 10; i++ ) { - delete buttonPixUp[i]; - delete buttonPixDown[i]; + if(buttonPixUp[i]) delete buttonPixUp[i]; + if(buttonPixDown[i]) delete buttonPixDown[i]; } - delete pixBg; - delete imgUp; - delete imgDn; - delete imgButtonMask; + if(pixBg) delete pixBg; + if(imgUp) delete imgUp; + if(imgDn) delete imgDn; + if(imgButtonMask) delete imgButtonMask; for ( int i = 0; i < 10; i++ ) { - delete masks[i]; + if(masks[i]) delete masks[i]; } } QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { QPixmap pix( img.width(), img.height() ); @@ -276,24 +277,26 @@ void AudioWidget::setView( char view ) { // show(); showMaximized(); } else { killTimers(); hide(); } + } static QString timeAsString( long length ) { length /= 44100; int minutes = length / 60; int seconds = length % 60; return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); } void AudioWidget::updateSlider( long i, long max ) { - time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); +this->setFocus(); + time.setText( 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(); @@ -354,25 +357,25 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 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 && i == AudioVolumeUp ) - qDebug("on up"); +// if ( isOnButton && i == AudioVolumeUp ) +// qDebug("on up"); if ( isOnButton && !audioButtons[i].isHeld ) { audioButtons[i].isHeld = TRUE; toggleButton(i); switch (i) { case AudioVolumeUp: - qDebug("more clicked"); + // qDebug("more clicked"); emit moreClicked(); return; case AudioVolumeDown: - qDebug("less clicked"); + // qDebug("less clicked"); emit lessClicked(); return; case AudioForward: emit forwardClicked(); return; case AudioBack: |