summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-07-16 12:33:22 (UTC)
committer llornkcor <llornkcor>2002-07-16 12:33:22 (UTC)
commit4d5c003d4602e5e5bdc42deba7587fc0b838c7fb (patch) (unidiff)
tree7b20d18733555591dc11a557629a4cf94f727242
parent5e9626775709fdf1815e3ff4584aede3ceaa4d58 (diff)
downloadopie-4d5c003d4602e5e5bdc42deba7587fc0b838c7fb.zip
opie-4d5c003d4602e5e5bdc42deba7587fc0b838c7fb.tar.gz
opie-4d5c003d4602e5e5bdc42deba7587fc0b838c7fb.tar.bz2
added new audiowidget skinable from qtopia 1.6 graphics later
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp276
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.h18
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp47
3 files changed, 260 insertions, 81 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 303e56e..9f384cc 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -10,6 +10,9 @@
10#include <qframe.h> 10#include <qframe.h>
11#include <qlayout.h> 11#include <qlayout.h>
12 12
13#include <stdlib.h>
14#include <stdio.h>
15
13#include "audiowidget.h" 16#include "audiowidget.h"
14#include "mediaplayerstate.h" 17#include "mediaplayerstate.h"
15 18
@@ -41,10 +44,13 @@ void Ticker::setText( const QString& text ) {
41 44
42void Ticker::timerEvent( QTimerEvent * ) { 45void Ticker::timerEvent( QTimerEvent * ) {
43 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; 46 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1;
47 scroll( -1, 0, contentsRect() );
44 repaint( FALSE ); 48 repaint( FALSE );
45} 49}
46 50
47void Ticker::drawContents( QPainter *p ) { 51void Ticker::drawContents( QPainter *p ) {
52 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen )
53 p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
48 QPixmap pm( width(), height() ); 54 QPixmap pm( width(), height() );
49 pm.fill( colorGroup().base() ); 55 pm.fill( colorGroup().base() );
50 QPainter pmp( &pm ); 56 QPainter pmp( &pm );
@@ -54,62 +60,102 @@ void Ticker::drawContents( QPainter *p ) {
54 p->drawPixmap( 0, 0, pm ); 60 p->drawPixmap( 0, 0, pm );
55} 61}
56 62
57
58struct MediaButton { 63struct MediaButton {
59 int xPos, yPos; 64 bool isToggle, isHeld, isDown;
60 int color;
61 bool isToggle, isBig, isHeld, isDown;
62}; 65};
63 66
64 67//Layout information for the audioButtons (and if it is a toggle button or not)
65// Layout information for the audioButtons (and if it is a toggle button or not)
66MediaButton audioButtons[] = { 68MediaButton audioButtons[] = {
67 { 3*30-15+xo, 3*30-13+yo, 0, TRUE, TRUE, FALSE, FALSE }, // play 69 { TRUE, FALSE, FALSE }, // play
68 { 1*30+xo, 5*30+yo, 2, FALSE, FALSE, FALSE, FALSE }, // stop 70 { FALSE, FALSE, FALSE }, // stop
69 { 5*30+xo, 5*30+yo, 2, TRUE, FALSE, FALSE, FALSE }, // pause 71 { TRUE, FALSE, FALSE }, // pause
70 { 6*30-5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // next 72 { FALSE, FALSE, FALSE }, // next
71 { 0*30+5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // previous 73 { FALSE, FALSE, FALSE }, // previous
72 { 3*30+xo, 0*30+5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume up 74 { FALSE, FALSE, FALSE }, // volume up
73 { 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down 75 { FALSE, FALSE, FALSE }, // volume down
74 { 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop 76 { TRUE, FALSE, FALSE }, // repeat/loop
75 { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist 77 { FALSE, FALSE, FALSE }, // playlist
78 { FALSE, FALSE, FALSE }, // forward
79 { FALSE, FALSE, FALSE } // back
76}; 80};
77 81
82const char *skin_mask_file_names[11] = {
83 "play", "stop", "pause", "next", "prev", "up",
84 "down", "loop", "playlist", "forward", "back"
85};
86
87
88static void changeTextColor( QWidget *w ) {
89 QPalette p = w->palette();
90 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) );
91 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) );
92 w->setPalette( p );
93}
94
78static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); 95static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
79 96
80 97
81AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : 98AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
82 QWidget( parent, name, f ) { 99 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this )
83 setCaption( tr("OpiePlayer - Audio") ); 100 setCaption( tr("OpiePlayer") );
101
84 Config cfg("OpiePlayer"); 102 Config cfg("OpiePlayer");
85 cfg.setGroup("AudioWidget"); 103 cfg.setGroup("AudioWidget");
104 skin = cfg.readEntry("Skin","default");
105 //skin = "scaleTest";
106// color of background, frame, degree of transparency
107
108 QString skinPath = "mediaplayer/skins/" + skin;
109 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
110 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
111 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
112
113 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
114 imgButtonMask->fill( 0 );
115
116 for ( int i = 0; i < 11; i++ ) {
117 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png";
118 masks[i] = new QBitmap( filename );
119
120 if ( !masks[i]->isNull() ) {
121 QImage imgMask = masks[i]->convertToImage();
122 uchar **dest = imgButtonMask->jumpTable();
123 for ( int y = 0; y < imgUp->height(); y++ ) {
124 uchar *line = dest[y];
125 for ( int x = 0; x < imgUp->width(); x++ )
126 if ( !qRed( imgMask.pixel( x, y ) ) )
127 line[x] = i + 1;
128 }
129 }
130
131 }
132
133 for ( int i = 0; i < 11; i++ ) {
134 buttonPixUp[i] = NULL;
135 buttonPixDown[i] = NULL;
136 }
137
138 setBackgroundPixmap( *pixBg );
139
140 songInfo.setFocusPolicy( QWidget::NoFocus );
141 changeTextColor( &songInfo );
142
143 slider.setFixedHeight( 20 );
144 slider.setMinValue( 0 );
145 slider.setMaxValue( 1 );
146 slider.setFocusPolicy( QWidget::NoFocus );
147 slider.setBackgroundPixmap( *pixBg );
148
149 time.setFocusPolicy( QWidget::NoFocus );
150 time.setAlignment( Qt::AlignCenter );
151 time.setFrame(FALSE);
152 changeTextColor( &time );
153
154 resizeEvent( NULL );
155
156 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
157 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
86 158
87 QString backgroundPix, buttonsAllPix, buttonsBigPix, controlsPix, animatedPix;
88 backgroundPix=cfg.readEntry( " backgroundPix", "opieplayer/metalFinish");
89 buttonsAllPix=cfg.readEntry( "buttonsAllPix","opieplayer/mediaButtonsAll");
90 buttonsBigPix=cfg.readEntry( "buttonsBigPix","opieplayer/mediaButtonsBig");
91 controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls");
92
93 setBackgroundPixmap( Resource::loadPixmap( backgroundPix) );
94 pixmaps[0] = new QPixmap( Resource::loadPixmap( buttonsAllPix ) );
95 pixmaps[1] = new QPixmap( Resource::loadPixmap( buttonsBigPix ) );
96 pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix ) );
97
98 songInfo = new Ticker( this );
99 songInfo->setFocusPolicy( QWidget::NoFocus );
100 songInfo->setGeometry( QRect( 7, 3, 220, 20 ) );
101
102 slider = new QSlider( Qt::Horizontal, this );
103 slider->setFixedWidth( 220 );
104 slider->setFixedHeight( 20 );
105 slider->setMinValue( 0 );
106 slider->setMaxValue( 1 );
107 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
108 slider->setFocusPolicy( QWidget::NoFocus );
109 slider->setGeometry( QRect( 7, 262, 220, 20 ) );
110
111 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
112 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
113 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 159 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
114 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 160 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
115 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 161 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
@@ -122,16 +168,72 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
122 setLooping( mediaPlayerState->fullscreen() ); 168 setLooping( mediaPlayerState->fullscreen() );
123 setPaused( mediaPlayerState->paused() ); 169 setPaused( mediaPlayerState->paused() );
124 setPlaying( mediaPlayerState->playing() ); 170 setPlaying( mediaPlayerState->playing() );
171
125} 172}
126 173
127AudioWidget::~AudioWidget() { 174AudioWidget::~AudioWidget() {
128 mediaPlayerState->setIsStreaming( FALSE ); 175
129 for ( int i = 0; i < 3; i++ ) { 176 for ( int i = 0; i < 11; i++ ) {
130 delete pixmaps[i]; 177 delete buttonPixUp[i];
178 delete buttonPixDown[i];
131 } 179 }
180 delete pixBg;
181 delete imgUp;
182 delete imgDn;
183 delete imgButtonMask;
184 for ( int i = 0; i < 11; i++ ) {
185 delete masks[i];
186 }
187}
188
189QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
190 QPixmap pix( img.width(), img.height() );
191 QPainter p( &pix );
192 p.drawTiledPixmap( pix.rect(), bg, offset );
193 p.drawImage( 0, 0, img );
194 return new QPixmap( pix );
132} 195}
133 196
134 197
198QPixmap *maskPixToMask( QPixmap pix, QBitmap mask )
199{
200 QPixmap *pixmap = new QPixmap( pix );
201 pixmap->setMask( mask );
202 return pixmap;
203}
204
205
206
207void AudioWidget::resizeEvent( QResizeEvent * ) {
208 int h = height();
209 int w = width();
210
211 songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) );
212 slider.setFixedWidth( w - 110 );
213 slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) );
214 slider.setBackgroundOrigin( QWidget::ParentOrigin );
215 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
216
217 xoff = ( w - imgUp->width() ) / 2;
218 yoff = (( h - imgUp->height() ) / 2) - 10;
219 QPoint p( xoff, yoff );
220
221 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p );
222 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p );
223
224 for ( int i = 0; i < 11; i++ ) {
225 if ( !masks[i]->isNull() ) {
226 delete buttonPixUp[i];
227 delete buttonPixDown[i];
228 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] );
229 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] );
230 }
231 }
232
233 delete pixUp;
234 delete pixDn;
235}
236
135static bool audioSliderBeingMoved = FALSE; 237static bool audioSliderBeingMoved = FALSE;
136 238
137 239
@@ -142,10 +244,9 @@ void AudioWidget::sliderPressed() {
142 244
143void AudioWidget::sliderReleased() { 245void AudioWidget::sliderReleased() {
144 audioSliderBeingMoved = FALSE; 246 audioSliderBeingMoved = FALSE;
145 if ( slider->width() == 0 ) { 247 if ( slider.width() == 0 )
146 return; 248 return;
147 } 249 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width());
148 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width());
149 mediaPlayerState->setPosition( val ); 250 mediaPlayerState->setPosition( val );
150} 251}
151 252
@@ -162,7 +263,7 @@ void AudioWidget::setLength( long max ) {
162 263
163void AudioWidget::setView( char view ) { 264void AudioWidget::setView( char view ) {
164 if (mediaPlayerState->streaming() ) { 265 if (mediaPlayerState->streaming() ) {
165 if( !slider->isHidden()) slider->hide(); 266 if( !slider.isHidden()) slider.hide();
166 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 267 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
167 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 268 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
168 } else { 269 } else {
@@ -183,7 +284,15 @@ void AudioWidget::setView( char view ) {
183} 284}
184 285
185 286
287static QString timeAsString( long length ) {
288 length /= 44100;
289 int minutes = length / 60;
290 int seconds = length % 60;
291 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 );
292}
293
186void AudioWidget::updateSlider( long i, long max ) { 294void AudioWidget::updateSlider( long i, long max ) {
295 time.setText( timeAsString( i ) + " / " + timeAsString( max ) );
187 if ( max == 0 ) { 296 if ( max == 0 ) {
188 return; 297 return;
189 } 298 }
@@ -218,55 +327,54 @@ void AudioWidget::toggleButton( int i ) {
218 327
219 328
220void AudioWidget::paintButton( QPainter *p, int i ) { 329void AudioWidget::paintButton( QPainter *p, int i ) {
221 int x = audioButtons[i].xPos; 330 if ( audioButtons[i].isDown )
222 int y = audioButtons[i].yPos; 331 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
223 int offset = 22 + 14 * audioButtons[i].isBig + audioButtons[i].isDown; 332 else
224 int buttonSize = 64 + audioButtons[i].isBig * (90 - 64); 333 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
225 p->drawPixmap( x, y, *pixmaps[audioButtons[i].isBig], buttonSize * (audioButtons[i].isDown + 2 * audioButtons[i].color), 0, buttonSize, buttonSize );
226 p->drawPixmap( x + offset, y + offset, *pixmaps[2], 18 * i, 0, 18, 18 );
227} 334}
228 335
229 336
230void AudioWidget::timerEvent( QTimerEvent * ) { 337void AudioWidget::timerEvent( QTimerEvent * ) {
231 static int frame = 0; 338// static int frame = 0;
232 if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { 339// if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) {
233 frame = frame >= 7 ? 0 : frame + 1; 340// frame = frame >= 7 ? 0 : frame + 1;
234 } 341// }
235} 342}
236 343
237 344
238void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 345void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
239 for ( int i = 0; i < numButtons; i++ ) { 346 for ( int i = 0; i < numButtons; i++ ) {
240 int size = audioButtons[i].isBig;
241 int x = audioButtons[i].xPos;
242 int y = audioButtons[i].yPos;
243 if ( event->state() == QMouseEvent::LeftButton ) { 347 if ( event->state() == QMouseEvent::LeftButton ) {
244 // The test to see if the mouse click is inside the circular button or not 348
245 // (compared with the radius squared to avoid a square-root of our distance) 349 // The test to see if the mouse click is inside the button or not
246 int radius = 32 + 13 * size; 350 int x = event->pos().x() - xoff;
247 QPoint center = QPoint( x + radius, y + radius ); 351 int y = event->pos().y() - yoff;
248 QPoint dXY = center - event->pos(); 352
249 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); 353 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
250 bool isOnButton = dist <= (radius * radius); 354 && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 );
355
356 if ( isOnButton && i == AudioVolumeUp )
357 qDebug("on up");
358
251 if ( isOnButton && !audioButtons[i].isHeld ) { 359 if ( isOnButton && !audioButtons[i].isHeld ) {
252 audioButtons[i].isHeld = TRUE; 360 audioButtons[i].isHeld = TRUE;
253 toggleButton(i); 361 toggleButton(i);
254 qDebug("button toggled1 %d",i);
255 switch (i) { 362 switch (i) {
256 case AudioVolumeUp: emit moreClicked(); return; 363 case AudioVolumeUp:
364 qDebug("more clicked");
365 emit moreClicked();
366 return;
257 case AudioVolumeDown: emit lessClicked(); return; 367 case AudioVolumeDown: emit lessClicked(); return;
258 } 368 }
259 } else if ( !isOnButton && audioButtons[i].isHeld ) { 369 } else if ( !isOnButton && audioButtons[i].isHeld ) {
260 audioButtons[i].isHeld = FALSE; 370 audioButtons[i].isHeld = FALSE;
261 toggleButton(i); 371 toggleButton(i);
262 qDebug("button toggled2 %d",i);
263 } 372 }
264 } else { 373 } else {
265 if ( audioButtons[i].isHeld ) { 374 if ( audioButtons[i].isHeld ) {
266 audioButtons[i].isHeld = FALSE; 375 audioButtons[i].isHeld = FALSE;
267 if ( !audioButtons[i].isToggle ) 376 if ( !audioButtons[i].isToggle )
268 setToggleButton( i, FALSE ); 377 setToggleButton( i, FALSE );
269 qDebug("button toggled3 %d",i);
270 switch (i) { 378 switch (i) {
271 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; 379 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return;
272 case AudioStop: mediaPlayerState->setPlaying(FALSE); return; 380 case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
@@ -306,9 +414,21 @@ void AudioWidget::closeEvent( QCloseEvent* ) {
306 414
307 415
308void AudioWidget::paintEvent( QPaintEvent * ) { 416void AudioWidget::paintEvent( QPaintEvent * ) {
309 QPainter p( this ); 417 if ( !pe->erased() ) {
310 for ( int i = 0; i < numButtons; i++ ) 418 // Combine with background and double buffer
311 paintButton( &p, i ); 419 QPixmap pix( pe->rect().size() );
420 QPainter p( &pix );
421 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
422 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
423 for ( int i = 0; i < numButtons; i++ )
424 paintButton( &p, i );
425 QPainter p2( this );
426 p2.drawPixmap( pe->rect().topLeft(), pix );
427 } else {
428 QPainter p( this );
429 for ( int i = 0; i < numButtons; i++ )
430 paintButton( &p, i );
431 }
312} 432}
313 433
314void AudioWidget::keyReleaseEvent( QKeyEvent *e) 434void AudioWidget::keyReleaseEvent( QKeyEvent *e)
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h
index ce8604a..3ebec5b 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.h
+++ b/noncore/multimedia/opieplayer2/audiowidget.h
@@ -25,7 +25,7 @@ enum AudioButtons {
25}; 25};
26 26
27 27
28#define USE_DBLBUF 28//#define USE_DBLBUF
29 29
30 30
31class Ticker : public QFrame { 31class Ticker : public QFrame {
@@ -75,6 +75,7 @@ protected:
75 void doUnblank(); 75 void doUnblank();
76 void paintEvent( QPaintEvent *pe ); 76 void paintEvent( QPaintEvent *pe );
77 void showEvent( QShowEvent *se ); 77 void showEvent( QShowEvent *se );
78 void resizeEvent( QResizeEvent *re );
78 void mouseMoveEvent( QMouseEvent *event ); 79 void mouseMoveEvent( QMouseEvent *event );
79 void mousePressEvent( QMouseEvent *event ); 80 void mousePressEvent( QMouseEvent *event );
80 void mouseReleaseEvent( QMouseEvent *event ); 81 void mouseReleaseEvent( QMouseEvent *event );
@@ -85,9 +86,20 @@ private:
85 void toggleButton( int ); 86 void toggleButton( int );
86 void setToggleButton( int, bool ); 87 void setToggleButton( int, bool );
87 void paintButton( QPainter *p, int i ); 88 void paintButton( QPainter *p, int i );
89 QString skin;
90 QPixmap *pixBg;
91 QImage *imgUp;
92 QImage *imgDn;
93 QImage *imgButtonMask;
94 QBitmap *masks[11];
95 QPixmap *buttonPixUp[11];
96 QPixmap *buttonPixDown[11];
97
88 QPixmap *pixmaps[4]; 98 QPixmap *pixmaps[4];
89 Ticker *songInfo; 99 Ticker songInfo;
90 QSlider *slider; 100 QSlider slider;
101 QLineEdit time;
102 int xoff, yoff;
91}; 103};
92 104
93 105
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index 38ba08f..43e3133 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -108,6 +108,7 @@ void MediaPlayer::startDecreasingVolume() {
108 volumeDirection = -1; 108 volumeDirection = -1;
109 startTimer( 100 ); 109 startTimer( 100 );
110 // da kommt demnächst osound denk ich mal 110 // da kommt demnächst osound denk ich mal
111 /////////////////////////// lets just move those change volume here
111 // AudioDevice::decreaseVolume(); 112 // AudioDevice::decreaseVolume();
112} 113}
113 114
@@ -119,8 +120,18 @@ void MediaPlayer::startIncreasingVolume() {
119} 120}
120 121
121 122
123bool drawnOnScreenDisplay = FALSE;
124unsigned int onScreenDisplayVolume = 0;
125const int yoff = 110;
126
122void MediaPlayer::stopChangingVolume() { 127void MediaPlayer::stopChangingVolume() {
123 killTimers(); 128 killTimers();
129 // Get rid of the on-screen display stuff
130 drawnOnScreenDisplay = FALSE;
131 onScreenDisplayVolume = 0;
132 int w = audioUI->width();
133 int h = audioUI->height();
134 audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE );
124} 135}
125 136
126 137
@@ -129,6 +140,42 @@ void MediaPlayer::timerEvent( QTimerEvent * ) {
129 // AudioDevice::increaseVolume(); 140 // AudioDevice::increaseVolume();
130 // else if ( volumeDirection == -1 ) 141 // else if ( volumeDirection == -1 )
131 // AudioDevice::decreaseVolume(); 142 // AudioDevice::decreaseVolume();
143
144// Display an on-screen display volume
145 unsigned int l, r, v; bool m;
146 AudioDevice::getVolume( l, r, m );
147 v = ((l + r) * 11) / (2*0xFFFF);
148
149 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v )
150 return;
151
152 int w = audioUI->width();
153 int h = audioUI->height();
154
155 if ( drawnOnScreenDisplay ) {
156 if ( onScreenDisplayVolume > v )
157 audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE );
158 }
159
160 drawnOnScreenDisplay = TRUE;
161 onScreenDisplayVolume = v;
162
163 QPainter p( audioUI );
164 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
165 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
166
167 QFont f;
168 f.setPixelSize( 20 );
169 f.setBold( TRUE );
170 p.setFont( f );
171 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") );
172
173 for ( unsigned int i = 0; i < 10; i++ ) {
174 if ( v > i )
175 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
176 else
177 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
178 }
132} 179}
133 180
134void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { 181void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {