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 | |||
@@ -71,31 +71,31 @@ static void changeTextColor( QWidget *w ) { | |||
71 | } | 71 | } |
72 | 72 | ||
73 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); | 73 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); |
74 | 74 | ||
75 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | 75 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : |
76 | QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) | 76 | QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) |
77 | { | 77 | { |
78 | setCaption( tr("OpiePlayer") ); | 78 | setCaption( tr("OpiePlayer") ); |
79 | qDebug("<<<<<audioWidget"); | 79 | // qDebug("<<<<<audioWidget"); |
80 | 80 | ||
81 | Config cfg("OpiePlayer"); | 81 | Config cfg("OpiePlayer"); |
82 | cfg.setGroup("Options"); | 82 | cfg.setGroup("Options"); |
83 | skin = cfg.readEntry("Skin","default"); | 83 | skin = cfg.readEntry("Skin","default"); |
84 | //skin = "scaleTest"; | 84 | //skin = "scaleTest"; |
85 | // color of background, frame, degree of transparency | 85 | // color of background, frame, degree of transparency |
86 | 86 | ||
87 | // QString skinPath = "opieplayer/skins/" + skin; | 87 | // QString skinPath = "opieplayer/skins/" + skin; |
88 | QString skinPath; | 88 | QString skinPath; |
89 | skinPath = "opieplayer2/skins/" + skin; | 89 | skinPath = "opieplayer2/skins/" + skin; |
90 | if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists()) | 90 | if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists()) |
91 | skinPath = "opieplayer2/skins/default"; | 91 | skinPath = "opieplayer2/skins/default"; |
92 | 92 | ||
93 | qDebug("skin path " + skinPath); | 93 | // qDebug("skin path " + skinPath); |
94 | 94 | ||
95 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 95 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
96 | imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); | 96 | imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); |
97 | imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); | 97 | imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); |
98 | 98 | ||
99 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); | 99 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); |
100 | imgButtonMask->fill( 0 ); | 100 | imgButtonMask->fill( 0 ); |
101 | 101 | ||
@@ -155,32 +155,33 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | |||
155 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 155 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
156 | 156 | ||
157 | // Intialise state | 157 | // Intialise state |
158 | setLength( mediaPlayerState->length() ); | 158 | setLength( mediaPlayerState->length() ); |
159 | setPosition( mediaPlayerState->position() ); | 159 | setPosition( mediaPlayerState->position() ); |
160 | setLooping( mediaPlayerState->fullscreen() ); | 160 | setLooping( mediaPlayerState->fullscreen() ); |
161 | // setPaused( mediaPlayerState->paused() ); | 161 | // setPaused( mediaPlayerState->paused() ); |
162 | setPlaying( mediaPlayerState->playing() ); | 162 | setPlaying( mediaPlayerState->playing() ); |
163 | 163 | this->setFocus(); | |
164 | } | 164 | } |
165 | 165 | ||
166 | 166 | ||
167 | AudioWidget::~AudioWidget() { | 167 | AudioWidget::~AudioWidget() { |
168 | // setPlaying( false); | ||
168 | 169 | ||
169 | for ( int i = 0; i < 10; i++ ) { | 170 | for ( int i = 0; i < 10; i++ ) { |
170 | delete buttonPixUp[i]; | 171 | if(buttonPixUp[i]) delete buttonPixUp[i]; |
171 | delete buttonPixDown[i]; | 172 | if(buttonPixDown[i]) delete buttonPixDown[i]; |
172 | } | 173 | } |
173 | delete pixBg; | 174 | if(pixBg) delete pixBg; |
174 | delete imgUp; | 175 | if(imgUp) delete imgUp; |
175 | delete imgDn; | 176 | if(imgDn) delete imgDn; |
176 | delete imgButtonMask; | 177 | if(imgButtonMask) delete imgButtonMask; |
177 | for ( int i = 0; i < 10; i++ ) { | 178 | for ( int i = 0; i < 10; i++ ) { |
178 | delete masks[i]; | 179 | if(masks[i]) delete masks[i]; |
179 | } | 180 | } |
180 | } | 181 | } |
181 | 182 | ||
182 | 183 | ||
183 | QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 184 | QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
184 | QPixmap pix( img.width(), img.height() ); | 185 | QPixmap pix( img.width(), img.height() ); |
185 | QPainter p( &pix ); | 186 | QPainter p( &pix ); |
186 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 187 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
@@ -274,28 +275,30 @@ void AudioWidget::setView( char view ) { | |||
274 | if ( view == 'a' ) { | 275 | if ( view == 'a' ) { |
275 | startTimer( 150 ); | 276 | startTimer( 150 ); |
276 | // show(); | 277 | // show(); |
277 | showMaximized(); | 278 | showMaximized(); |
278 | } else { | 279 | } else { |
279 | killTimers(); | 280 | killTimers(); |
280 | hide(); | 281 | hide(); |
281 | } | 282 | } |
283 | |||
282 | } | 284 | } |
283 | 285 | ||
284 | 286 | ||
285 | static QString timeAsString( long length ) { | 287 | static QString timeAsString( long length ) { |
286 | length /= 44100; | 288 | length /= 44100; |
287 | int minutes = length / 60; | 289 | int minutes = length / 60; |
288 | int seconds = length % 60; | 290 | int seconds = length % 60; |
289 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); | 291 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); |
290 | } | 292 | } |
291 | 293 | ||
292 | void AudioWidget::updateSlider( long i, long max ) { | 294 | void AudioWidget::updateSlider( long i, long max ) { |
293 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); | 295 | this->setFocus(); |
296 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); | ||
294 | 297 | ||
295 | if ( max == 0 ) | 298 | if ( max == 0 ) |
296 | return; | 299 | return; |
297 | // Will flicker too much if we don't do this | 300 | // Will flicker too much if we don't do this |
298 | // Scale to something reasonable | 301 | // Scale to something reasonable |
299 | int width = slider.width(); | 302 | int width = slider.width(); |
300 | int val = int((double)i * width / max); | 303 | int val = int((double)i * width / max); |
301 | if ( !audioSliderBeingMoved ) { | 304 | if ( !audioSliderBeingMoved ) { |
@@ -352,29 +355,29 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | |||
352 | 355 | ||
353 | // The test to see if the mouse click is inside the button or not | 356 | // The test to see if the mouse click is inside the button or not |
354 | int x = event->pos().x() - xoff; | 357 | int x = event->pos().x() - xoff; |
355 | int y = event->pos().y() - yoff; | 358 | int y = event->pos().y() - yoff; |
356 | 359 | ||
357 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() | 360 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() |
358 | && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); | 361 | && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); |
359 | 362 | ||
360 | if ( isOnButton && i == AudioVolumeUp ) | 363 | // if ( isOnButton && i == AudioVolumeUp ) |
361 | qDebug("on up"); | 364 | // qDebug("on up"); |
362 | 365 | ||
363 | if ( isOnButton && !audioButtons[i].isHeld ) { | 366 | if ( isOnButton && !audioButtons[i].isHeld ) { |
364 | audioButtons[i].isHeld = TRUE; | 367 | audioButtons[i].isHeld = TRUE; |
365 | toggleButton(i); | 368 | toggleButton(i); |
366 | switch (i) { | 369 | switch (i) { |
367 | case AudioVolumeUp: | 370 | case AudioVolumeUp: |
368 | qDebug("more clicked"); | 371 | // qDebug("more clicked"); |
369 | emit moreClicked(); | 372 | emit moreClicked(); |
370 | return; | 373 | return; |
371 | case AudioVolumeDown: | 374 | case AudioVolumeDown: |
372 | qDebug("less clicked"); | 375 | // qDebug("less clicked"); |
373 | emit lessClicked(); | 376 | emit lessClicked(); |
374 | return; | 377 | return; |
375 | case AudioForward: | 378 | case AudioForward: |
376 | emit forwardClicked(); | 379 | emit forwardClicked(); |
377 | return; | 380 | return; |
378 | case AudioBack: | 381 | case AudioBack: |
379 | emit backClicked(); | 382 | emit backClicked(); |
380 | return; | 383 | return; |