summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/audiowidget.cpp
authorllornkcor <llornkcor>2003-06-11 22:11:38 (UTC)
committer llornkcor <llornkcor>2003-06-11 22:11:38 (UTC)
commit24097a2790fd7bb241a0a8da24ef2996e4f4ad15 (patch) (unidiff)
tree142e0fb758067bc9a601b3bd2dabdff27675c0f3 /core/multimedia/opieplayer/audiowidget.cpp
parent188319af82322c84f02e1abb848d908ca8f9e26c (diff)
downloadopie-24097a2790fd7bb241a0a8da24ef2996e4f4ad15.zip
opie-24097a2790fd7bb241a0a8da24ef2996e4f4ad15.tar.gz
opie-24097a2790fd7bb241a0a8da24ef2996e4f4ad15.tar.bz2
fix setDoc for playlists and others. remove qDebugs
Diffstat (limited to 'core/multimedia/opieplayer/audiowidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/audiowidget.cpp33
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 ) {
73static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); 73static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
74 74
75AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : 75AudioWidget::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
@@ -87,13 +87,13 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
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 );
@@ -157,28 +157,29 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
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 163this->setFocus();
164} 164}
165 165
166 166
167AudioWidget::~AudioWidget() { 167AudioWidget::~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
183QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 184QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
184 QPixmap pix( img.width(), img.height() ); 185 QPixmap pix( img.width(), img.height() );
@@ -276,24 +277,26 @@ void AudioWidget::setView( char view ) {
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
285static QString timeAsString( long length ) { 287static 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
292void AudioWidget::updateSlider( long i, long max ) { 294void AudioWidget::updateSlider( long i, long max ) {
293 time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); 295this->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();
@@ -354,25 +357,25 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
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: