-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 276 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.h | 18 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 47 |
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 | |||
@@ -12,2 +12,5 @@ | |||
12 | 12 | ||
13 | #include <stdlib.h> | ||
14 | #include <stdio.h> | ||
15 | |||
13 | #include "audiowidget.h" | 16 | #include "audiowidget.h" |
@@ -43,2 +46,3 @@ void 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 ); |
@@ -47,2 +51,4 @@ void Ticker::timerEvent( QTimerEvent * ) { | |||
47 | void Ticker::drawContents( QPainter *p ) { | 51 | void 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() ); |
@@ -56,23 +62,34 @@ void Ticker::drawContents( QPainter *p ) { | |||
56 | 62 | ||
57 | |||
58 | struct MediaButton { | 63 | struct 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) | ||
66 | MediaButton audioButtons[] = { | 68 | MediaButton 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 | ||
82 | const char *skin_mask_file_names[11] = { | ||
83 | "play", "stop", "pause", "next", "prev", "up", | ||
84 | "down", "loop", "playlist", "forward", "back" | ||
85 | }; | ||
86 | |||
87 | |||
88 | static 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 | |||
78 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); | 95 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); |
@@ -81,33 +98,62 @@ static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); | |||
81 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | 98 | AudioWidget::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) ) ); |
@@ -124,2 +170,3 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | |||
124 | setPlaying( mediaPlayerState->playing() ); | 170 | setPlaying( mediaPlayerState->playing() ); |
171 | |||
125 | } | 172 | } |
@@ -127,6 +174,22 @@ AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | |||
127 | AudioWidget::~AudioWidget() { | 174 | AudioWidget::~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 | |||
189 | QPixmap *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 | } |
@@ -134,2 +197,41 @@ AudioWidget::~AudioWidget() { | |||
134 | 197 | ||
198 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) | ||
199 | { | ||
200 | QPixmap *pixmap = new QPixmap( pix ); | ||
201 | pixmap->setMask( mask ); | ||
202 | return pixmap; | ||
203 | } | ||
204 | |||
205 | |||
206 | |||
207 | void 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 | |||
135 | static bool audioSliderBeingMoved = FALSE; | 237 | static bool audioSliderBeingMoved = FALSE; |
@@ -144,6 +246,5 @@ void 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 ); |
@@ -164,3 +265,3 @@ void 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) ) ); |
@@ -185,3 +286,11 @@ void AudioWidget::setView( char view ) { | |||
185 | 286 | ||
287 | static 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 | |||
186 | void AudioWidget::updateSlider( long i, long max ) { | 294 | void AudioWidget::updateSlider( long i, long max ) { |
295 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); | ||
187 | if ( max == 0 ) { | 296 | if ( max == 0 ) { |
@@ -220,8 +329,6 @@ void AudioWidget::toggleButton( int i ) { | |||
220 | void AudioWidget::paintButton( QPainter *p, int i ) { | 329 | void 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 | } |
@@ -230,6 +337,6 @@ void AudioWidget::paintButton( QPainter *p, int i ) { | |||
230 | void AudioWidget::timerEvent( QTimerEvent * ) { | 337 | void 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 | } |
@@ -239,13 +346,14 @@ void 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 ) { |
@@ -253,5 +361,7 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | |||
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; |
@@ -261,3 +371,2 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | |||
261 | toggleButton(i); | 371 | toggleButton(i); |
262 | qDebug("button toggled2 %d",i); | ||
263 | } | 372 | } |
@@ -268,3 +377,2 @@ void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | |||
268 | setToggleButton( i, FALSE ); | 377 | setToggleButton( i, FALSE ); |
269 | qDebug("button toggled3 %d",i); | ||
270 | switch (i) { | 378 | switch (i) { |
@@ -308,5 +416,17 @@ void AudioWidget::closeEvent( QCloseEvent* ) { | |||
308 | void AudioWidget::paintEvent( QPaintEvent * ) { | 416 | void 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 | } |
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 | |||
@@ -27,3 +27,3 @@ enum AudioButtons { | |||
27 | 27 | ||
28 | #define USE_DBLBUF | 28 | //#define USE_DBLBUF |
29 | 29 | ||
@@ -77,2 +77,3 @@ protected: | |||
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 ); |
@@ -87,5 +88,16 @@ private: | |||
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 | }; |
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 | |||
@@ -110,2 +110,3 @@ void MediaPlayer::startDecreasingVolume() { | |||
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(); |
@@ -121,4 +122,14 @@ void MediaPlayer::startIncreasingVolume() { | |||
121 | 122 | ||
123 | bool drawnOnScreenDisplay = FALSE; | ||
124 | unsigned int onScreenDisplayVolume = 0; | ||
125 | const int yoff = 110; | ||
126 | |||
122 | void MediaPlayer::stopChangingVolume() { | 127 | void 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 | } |
@@ -131,2 +142,38 @@ void MediaPlayer::timerEvent( QTimerEvent * ) { | |||
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 | } |