Diffstat (limited to 'core/multimedia/opieplayer/mediaplayer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/mediaplayer.cpp | 59 |
1 files changed, 56 insertions, 3 deletions
diff --git a/core/multimedia/opieplayer/mediaplayer.cpp b/core/multimedia/opieplayer/mediaplayer.cpp index b0963cf..4f3823a 100644 --- a/core/multimedia/opieplayer/mediaplayer.cpp +++ b/core/multimedia/opieplayer/mediaplayer.cpp | |||
@@ -107,5 +107,6 @@ void MediaPlayer::setPlaying( bool play ) { | |||
107 | if ( ((currentFile->file()).left(4) != "http") && !QFile::exists( currentFile->file() ) ) { | 107 | if ( ((currentFile->file()).left(4) != "http") && !QFile::exists( currentFile->file() ) ) { |
108 | QMessageBox::critical( 0, tr( "File not found"), | 108 | QMessageBox::critical( 0, tr( "File not found"), |
109 | tr( "The following file was not found: <i>" ) + currentFile->file() + "</i>" ); | 109 | tr( "The following file was not found: <i>" ) |
110 | + currentFile->file() + "</i>" ); | ||
110 | mediaPlayerState->setPlaying( FALSE ); | 111 | mediaPlayerState->setPlaying( FALSE ); |
111 | return; | 112 | return; |
@@ -114,5 +115,6 @@ void MediaPlayer::setPlaying( bool play ) { | |||
114 | if ( !mediaPlayerState->newDecoder( currentFile->file() ) ) { | 115 | if ( !mediaPlayerState->newDecoder( currentFile->file() ) ) { |
115 | QMessageBox::critical( 0, tr( "No decoder found"), | 116 | QMessageBox::critical( 0, tr( "No decoder found"), |
116 | tr( "Sorry, no appropriate decoders found for this file: <i>" ) + currentFile->file() + "</i>" ); | 117 | tr( "Sorry, no appropriate decoders found for this file: <i>" ) |
118 | + currentFile->file() + "</i>" ); | ||
117 | mediaPlayerState->setPlaying( FALSE ); | 119 | mediaPlayerState->setPlaying( FALSE ); |
118 | return; | 120 | return; |
@@ -177,17 +179,68 @@ void MediaPlayer::startIncreasingVolume() { | |||
177 | startTimer( 100 ); | 179 | startTimer( 100 ); |
178 | AudioDevice::increaseVolume(); | 180 | AudioDevice::increaseVolume(); |
181 | |||
179 | } | 182 | } |
180 | 183 | ||
184 | bool drawnOnScreenDisplay = FALSE; | ||
185 | unsigned int onScreenDisplayVolume = 0; | ||
186 | const int yoff = 110; | ||
181 | 187 | ||
182 | void MediaPlayer::stopChangingVolume() { | 188 | void MediaPlayer::stopChangingVolume() { |
183 | killTimers(); | 189 | killTimers(); |
190 | |||
191 | // Get rid of the on-screen display stuff | ||
192 | drawnOnScreenDisplay = FALSE; | ||
193 | onScreenDisplayVolume = 0; | ||
194 | int w = audioUI->width(); | ||
195 | int h = audioUI->height(); | ||
196 | audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); | ||
184 | } | 197 | } |
185 | 198 | ||
186 | 199 | ||
187 | void MediaPlayer::timerEvent( QTimerEvent * ) { | 200 | void MediaPlayer::timerEvent( QTimerEvent * ) { |
201 | // qDebug("timer"); | ||
188 | if ( volumeDirection == +1 ) | 202 | if ( volumeDirection == +1 ) |
189 | AudioDevice::increaseVolume(); | 203 | AudioDevice::increaseVolume(); |
190 | else if ( volumeDirection == -1 ) | 204 | else if ( volumeDirection == -1 ) |
191 | AudioDevice::decreaseVolume(); | 205 | AudioDevice::decreaseVolume(); |
206 | |||
207 | // Display an on-screen display volume | ||
208 | unsigned int l, r, v; bool m; | ||
209 | AudioDevice::getVolume( l, r, m ); | ||
210 | v = ((l + r) * 11) / (2*0xFFFF); | ||
211 | |||
212 | if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { | ||
213 | // qDebug("returning %d, %d, %d, %d", v, l, r, m); | ||
214 | return; | ||
215 | } | ||
216 | |||
217 | int w = audioUI->width(); | ||
218 | int h = audioUI->height(); | ||
219 | |||
220 | if ( drawnOnScreenDisplay ) { | ||
221 | if ( onScreenDisplayVolume > v ) | ||
222 | audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, | ||
223 | (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); | ||
224 | } | ||
225 | |||
226 | drawnOnScreenDisplay = TRUE; | ||
227 | onScreenDisplayVolume = v; | ||
228 | |||
229 | QPainter p( audioUI ); | ||
230 | p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); | ||
231 | p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); | ||
232 | |||
233 | QFont f; | ||
234 | f.setPixelSize( 20 ); | ||
235 | f.setBold( TRUE ); | ||
236 | p.setFont( f ); | ||
237 | p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); | ||
238 | |||
239 | for ( unsigned int i = 0; i < 10; i++ ) { | ||
240 | if ( v > i ) | ||
241 | p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); | ||
242 | else | ||
243 | p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); | ||
244 | } | ||
192 | } | 245 | } |
193 | 246 | ||