-rw-r--r-- | core/multimedia/opieplayer/audiowidget.cpp | 16 | ||||
-rw-r--r-- | core/multimedia/opieplayer/videowidget.cpp | 36 |
2 files changed, 26 insertions, 26 deletions
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp index cda3f77..3212001 100644 --- a/core/multimedia/opieplayer/audiowidget.cpp +++ b/core/multimedia/opieplayer/audiowidget.cpp | |||
@@ -56,40 +56,40 @@ MediaButton audioButtons[] = { | |||
56 | { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist | 56 | { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist |
57 | }; | 57 | }; |
58 | 58 | ||
59 | 59 | ||
60 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); | 60 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); |
61 | 61 | ||
62 | 62 | ||
63 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | 63 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : |
64 | QWidget( parent, name, f ) | 64 | QWidget( parent, name, f ) |
65 | { | 65 | { |
66 | // QPEApplication::grabKeyboard(); | 66 | // QPEApplication::grabKeyboard(); |
67 | setCaption( tr("OpiePlayer") ); | 67 | setCaption( tr("OpiePlayer") ); |
68 | setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); | 68 | setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); |
69 | pixmaps[0] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsAll" ) ); | 69 | pixmaps[0] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaButtonsAll" ) ); |
70 | pixmaps[1] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsBig" ) ); | 70 | pixmaps[1] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaButtonsBig" ) ); |
71 | pixmaps[2] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaControls" ) ); | 71 | pixmaps[2] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaControls" ) ); |
72 | pixmaps[3] = new QPixmap( Resource::loadPixmap( "mpegplayer/animatedButton" ) ); | 72 | pixmaps[3] = new QPixmap( Resource::loadPixmap( "opieplayer/animatedButton" ) ); |
73 | 73 | ||
74 | songInfo = new Ticker( this ); | 74 | songInfo = new Ticker( this ); |
75 | songInfo->setFocusPolicy( QWidget::NoFocus ); | 75 | songInfo->setFocusPolicy( QWidget::NoFocus ); |
76 | songInfo->setGeometry( QRect( 7, 3, 220, 20 ) ); | 76 | songInfo->setGeometry( QRect( 7, 3, 220, 20 ) ); |
77 | 77 | ||
78 | slider = new QSlider( Qt::Horizontal, this ); | 78 | slider = new QSlider( Qt::Horizontal, this ); |
79 | slider->setFixedWidth( 220 ); | 79 | slider->setFixedWidth( 220 ); |
80 | slider->setFixedHeight( 20 ); | 80 | slider->setFixedHeight( 20 ); |
81 | slider->setMinValue( 0 ); | 81 | slider->setMinValue( 0 ); |
82 | slider->setMaxValue( 1 ); | 82 | slider->setMaxValue( 1 ); |
83 | slider->setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); | 83 | slider->setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); |
84 | slider->setFocusPolicy( QWidget::NoFocus ); | 84 | slider->setFocusPolicy( QWidget::NoFocus ); |
85 | slider->setGeometry( QRect( 7, 262, 220, 20 ) ); | 85 | slider->setGeometry( QRect( 7, 262, 220, 20 ) ); |
86 | 86 | ||
87 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 87 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
88 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 88 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
89 | 89 | ||
90 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 90 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
91 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 91 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
92 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 92 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
93 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 93 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
94 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); | 94 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); |
95 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 95 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
@@ -144,25 +144,25 @@ void AudioWidget::setView( char view ) { | |||
144 | showMaximized(); | 144 | showMaximized(); |
145 | } else { | 145 | } else { |
146 | killTimers(); | 146 | killTimers(); |
147 | hide(); | 147 | hide(); |
148 | } | 148 | } |
149 | } | 149 | } |
150 | 150 | ||
151 | 151 | ||
152 | void AudioWidget::updateSlider( long i, long max ) { | 152 | void AudioWidget::updateSlider( long i, long max ) { |
153 | if ( max == 0 ) | 153 | if ( max == 0 ) |
154 | return; | 154 | return; |
155 | // Will flicker too much if we don't do this | 155 | // Will flicker too much if we don't do this |
156 | // Scale to something reasonable | 156 | // Scale to something reasonable |
157 | int width = slider->width(); | 157 | int width = slider->width(); |
158 | int val = int((double)i * width / max); | 158 | int val = int((double)i * width / max); |
159 | if ( !audioSliderBeingMoved ) { | 159 | if ( !audioSliderBeingMoved ) { |
160 | if ( slider->value() != val ) | 160 | if ( slider->value() != val ) |
161 | slider->setValue( val ); | 161 | slider->setValue( val ); |
162 | if ( slider->maxValue() != width ) | 162 | if ( slider->maxValue() != width ) |
163 | slider->setMaxValue( width ); | 163 | slider->setMaxValue( width ); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | 166 | ||
167 | 167 | ||
168 | void AudioWidget::setToggleButton( int i, bool down ) { | 168 | void AudioWidget::setToggleButton( int i, bool down ) { |
@@ -324,15 +324,15 @@ void AudioWidget::keyReleaseEvent( QKeyEvent *e) | |||
324 | case Key_Right: | 324 | case Key_Right: |
325 | // toggleButton(3); | 325 | // toggleButton(3); |
326 | mediaPlayerState->setNext(); | 326 | mediaPlayerState->setNext(); |
327 | // toggleButton(3); | 327 | // toggleButton(3); |
328 | break; | 328 | break; |
329 | case Key_Left: | 329 | case Key_Left: |
330 | // toggleButton(4); | 330 | // toggleButton(4); |
331 | mediaPlayerState->setPrev(); | 331 | mediaPlayerState->setPrev(); |
332 | // toggleButton(4); | 332 | // toggleButton(4); |
333 | break; | 333 | break; |
334 | case Key_Escape: | 334 | case Key_Escape: |
335 | break; | 335 | break; |
336 | 336 | ||
337 | }; | 337 | }; |
338 | } | 338 | } |
diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp index 23b36e5..70b4a95 100644 --- a/core/multimedia/opieplayer/videowidget.cpp +++ b/core/multimedia/opieplayer/videowidget.cpp | |||
@@ -58,34 +58,34 @@ MediaButton videoButtons[] = { | |||
58 | { 5+4*32+xo, 200+yo, FALSE, FALSE, FALSE, 3 }, // next | 58 | { 5+4*32+xo, 200+yo, FALSE, FALSE, FALSE, 3 }, // next |
59 | { 5+5*32+xo, 200+yo, FALSE, FALSE, FALSE, 8 }, // playlist | 59 | { 5+5*32+xo, 200+yo, FALSE, FALSE, FALSE, 8 }, // playlist |
60 | { 5+6*32+xo, 200+yo, TRUE, FALSE, FALSE, 9 } // fullscreen | 60 | { 5+6*32+xo, 200+yo, TRUE, FALSE, FALSE, 9 } // fullscreen |
61 | }; | 61 | }; |
62 | 62 | ||
63 | 63 | ||
64 | static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); | 64 | static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); |
65 | 65 | ||
66 | 66 | ||
67 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : | 67 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : |
68 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { | 68 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { |
69 | setCaption( tr("OpiePlayer") ); | 69 | setCaption( tr("OpiePlayer") ); |
70 | setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); | 70 | setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); |
71 | pixmaps[0] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButton0a" ) ); | 71 | pixmaps[0] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaButton0a" ) ); |
72 | pixmaps[1] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButton0b" ) ); | 72 | pixmaps[1] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaButton0b" ) ); |
73 | pixmaps[2] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaControls0" ) ); | 73 | pixmaps[2] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaControls0" ) ); |
74 | currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); | 74 | currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); |
75 | 75 | ||
76 | slider = new QSlider( Qt::Horizontal, this ); | 76 | slider = new QSlider( Qt::Horizontal, this ); |
77 | slider->setMinValue( 0 ); | 77 | slider->setMinValue( 0 ); |
78 | slider->setMaxValue( 1 ); | 78 | slider->setMaxValue( 1 ); |
79 | slider->setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); | 79 | slider->setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); |
80 | slider->setFocusPolicy( QWidget::NoFocus ); | 80 | slider->setFocusPolicy( QWidget::NoFocus ); |
81 | slider->setGeometry( QRect( 7, 250, 220, 20 ) ); | 81 | slider->setGeometry( QRect( 7, 250, 220, 20 ) ); |
82 | 82 | ||
83 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 83 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
84 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 84 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
85 | 85 | ||
86 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 86 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
87 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 87 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
88 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 88 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
89 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 89 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
90 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 90 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
91 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 91 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
@@ -192,77 +192,77 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | |||
192 | int radius = 16; | 192 | int radius = 16; |
193 | QPoint center = QPoint( x + radius, y + radius ); | 193 | QPoint center = QPoint( x + radius, y + radius ); |
194 | QPoint dXY = center - event->pos(); | 194 | QPoint dXY = center - event->pos(); |
195 | int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); | 195 | int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); |
196 | bool isOnButton = dist <= (radius * radius); | 196 | bool isOnButton = dist <= (radius * radius); |
197 | if ( isOnButton != videoButtons[i].isHeld ) { | 197 | if ( isOnButton != videoButtons[i].isHeld ) { |
198 | videoButtons[i].isHeld = isOnButton; | 198 | videoButtons[i].isHeld = isOnButton; |
199 | toggleButton(i); | 199 | toggleButton(i); |
200 | } | 200 | } |
201 | } else { | 201 | } else { |
202 | if ( videoButtons[i].isHeld ) { | 202 | if ( videoButtons[i].isHeld ) { |
203 | videoButtons[i].isHeld = FALSE; | 203 | videoButtons[i].isHeld = FALSE; |
204 | if ( !videoButtons[i].isToggle ) | 204 | if ( !videoButtons[i].isToggle ) |
205 | setToggleButton( i, FALSE ); | 205 | setToggleButton( i, FALSE ); |
206 | } | 206 | } |
207 | } | 207 | } |
208 | switch (i) { | 208 | switch (i) { |
209 | case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; | 209 | case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; |
210 | case VideoStop: mediaPlayerState->setPlaying(FALSE); return; | 210 | case VideoStop: mediaPlayerState->setPlaying(FALSE); return; |
211 | case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; | 211 | case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; |
212 | case VideoNext: mediaPlayerState->setNext(); return; | 212 | case VideoNext: mediaPlayerState->setNext(); return; |
213 | case VideoPrevious: mediaPlayerState->setPrev(); return; | 213 | case VideoPrevious: mediaPlayerState->setPrev(); return; |
214 | case VideoPlayList: mediaPlayerState->setList(); return; | 214 | case VideoPlayList: mediaPlayerState->setList(); return; |
215 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | 215 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; |
216 | } | 216 | } |
217 | 217 | ||
218 | } | 218 | } |
219 | } | 219 | } |
220 | 220 | ||
221 | 221 | ||
222 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { | 222 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { |
223 | mouseMoveEvent( event ); | 223 | mouseMoveEvent( event ); |
224 | } | 224 | } |
225 | 225 | ||
226 | 226 | ||
227 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 227 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
228 | if ( mediaPlayerState->fullscreen() ) { | 228 | if ( mediaPlayerState->fullscreen() ) { |
229 | mediaPlayerState->setFullscreen( FALSE ); | 229 | mediaPlayerState->setFullscreen( FALSE ); |
230 | makeVisible(); | 230 | makeVisible(); |
231 | 231 | ||
232 | mouseMoveEvent( event ); | 232 | mouseMoveEvent( event ); |
233 | } | 233 | } |
234 | } | 234 | } |
235 | 235 | ||
236 | 236 | ||
237 | void VideoWidget::makeVisible() { | 237 | void VideoWidget::makeVisible() { |
238 | if ( mediaPlayerState->fullscreen() ) { | 238 | if ( mediaPlayerState->fullscreen() ) { |
239 | setBackgroundMode( QWidget::NoBackground ); | 239 | setBackgroundMode( QWidget::NoBackground ); |
240 | showFullScreen(); | 240 | showFullScreen(); |
241 | resize( qApp->desktop()->size() ); | 241 | resize( qApp->desktop()->size() ); |
242 | slider->hide(); | 242 | slider->hide(); |
243 | } else { | 243 | } else { |
244 | setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); | 244 | setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); |
245 | showNormal(); | 245 | showNormal(); |
246 | showMaximized(); | 246 | showMaximized(); |
247 | slider->show(); | 247 | slider->show(); |
248 | } | 248 | } |
249 | } | 249 | } |
250 | 250 | ||
251 | 251 | ||
252 | void VideoWidget::paintEvent( QPaintEvent * ) { | 252 | void VideoWidget::paintEvent( QPaintEvent * ) { |
253 | QPainter p( this ); | 253 | QPainter p( this ); |
254 | 254 | ||
255 | if ( mediaPlayerState->fullscreen() ) { | 255 | if ( mediaPlayerState->fullscreen() ) { |
256 | // Clear the background | 256 | // Clear the background |
257 | p.setBrush( QBrush( Qt::black ) ); | 257 | p.setBrush( QBrush( Qt::black ) ); |
258 | p.drawRect( rect() ); | 258 | p.drawRect( rect() ); |
259 | 259 | ||
260 | // Draw the current frame | 260 | // Draw the current frame |
261 | //p.drawImage( ); // If using directpainter we won't have a copy except whats on the screen | 261 | //p.drawImage( ); // If using directpainter we won't have a copy except whats on the screen |
262 | } else { | 262 | } else { |
263 | // draw border | 263 | // draw border |
264 | qDrawShadePanel( &p, 4, 15, 230, 170, colorGroup(), TRUE, 5, NULL ); | 264 | qDrawShadePanel( &p, 4, 15, 230, 170, colorGroup(), TRUE, 5, NULL ); |
265 | 265 | ||
266 | // Clear the movie screen first | 266 | // Clear the movie screen first |
267 | p.setBrush( QBrush( Qt::black ) ); | 267 | p.setBrush( QBrush( Qt::black ) ); |
268 | p.drawRect( 9, 20, 220, 160 ); | 268 | p.drawRect( 9, 20, 220, 160 ); |
@@ -279,89 +279,89 @@ void VideoWidget::paintEvent( QPaintEvent * ) { | |||
279 | } | 279 | } |
280 | } | 280 | } |
281 | 281 | ||
282 | 282 | ||
283 | void VideoWidget::closeEvent( QCloseEvent* ) { | 283 | void VideoWidget::closeEvent( QCloseEvent* ) { |
284 | mediaPlayerState->setList(); | 284 | mediaPlayerState->setList(); |
285 | } | 285 | } |
286 | 286 | ||
287 | 287 | ||
288 | bool VideoWidget::playVideo() { | 288 | bool VideoWidget::playVideo() { |
289 | bool result = FALSE; | 289 | bool result = FALSE; |
290 | 290 | ||
291 | int stream = 0; | 291 | int stream = 0; |
292 | 292 | ||
293 | int sw = mediaPlayerState->curDecoder()->videoWidth( stream ); | 293 | int sw = mediaPlayerState->curDecoder()->videoWidth( stream ); |
294 | int sh = mediaPlayerState->curDecoder()->videoHeight( stream ); | 294 | int sh = mediaPlayerState->curDecoder()->videoHeight( stream ); |
295 | int dd = QPixmap::defaultDepth(); | 295 | int dd = QPixmap::defaultDepth(); |
296 | int w = height(); | 296 | int w = height(); |
297 | int h = width(); | 297 | int h = width(); |
298 | 298 | ||
299 | ColorFormat format = (dd == 16) ? RGB565 : BGRA8888; | 299 | ColorFormat format = (dd == 16) ? RGB565 : BGRA8888; |
300 | 300 | ||
301 | if ( mediaPlayerState->fullscreen() ) { | 301 | if ( mediaPlayerState->fullscreen() ) { |
302 | #ifdef USE_DIRECT_PAINTER | 302 | #ifdef USE_DIRECT_PAINTER |
303 | QDirectPainter p(this); | 303 | QDirectPainter p(this); |
304 | 304 | ||
305 | if ( ( qt_screen->transformOrientation() == 3 ) && | 305 | if ( ( qt_screen->transformOrientation() == 3 ) && |
306 | ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) ) { | 306 | ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) ) { |
307 | 307 | ||
308 | w = 320; | 308 | w = 320; |
309 | h = 240; | 309 | h = 240; |
310 | 310 | ||
311 | if ( mediaPlayerState->scaled() ) { | 311 | if ( mediaPlayerState->scaled() ) { |
312 | // maintain aspect ratio | 312 | // maintain aspect ratio |
313 | if ( w * sh > sw * h ) | 313 | if ( w * sh > sw * h ) |
314 | w = sw * h / sh; | 314 | w = sw * h / sh; |
315 | else | 315 | else |
316 | h = sh * w / sw; | 316 | h = sh * w / sw; |
317 | } else { | 317 | } else { |
318 | w = sw; | 318 | w = sw; |
319 | h = sh; | 319 | h = sh; |
320 | } | 320 | } |
321 | 321 | ||
322 | w--; // we can't allow libmpeg to overwrite. | 322 | w--; // we can't allow libmpeg to overwrite. |
323 | QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) ); | 323 | QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) ); |
324 | 324 | ||
325 | int ox = roff.x() - height() + 2 + (height() - w) / 2; | 325 | int ox = roff.x() - height() + 2 + (height() - w) / 2; |
326 | int oy = roff.y() + (width() - h) / 2; | 326 | int oy = roff.y() + (width() - h) / 2; |
327 | int sx = 0, sy = 0; | 327 | int sx = 0, sy = 0; |
328 | 328 | ||
329 | uchar* fp = p.frameBuffer() + p.lineStep() * oy; | 329 | uchar* fp = p.frameBuffer() + p.lineStep() * oy; |
330 | fp += dd * ox / 8; | 330 | fp += dd * ox / 8; |
331 | uchar **jt = new uchar*[h]; | 331 | uchar **jt = new uchar*[h]; |
332 | for ( int i = h; i; i-- ) { | 332 | for ( int i = h; i; i-- ) { |
333 | jt[h - i] = fp; | 333 | jt[h - i] = fp; |
334 | fp += p.lineStep(); | 334 | fp += p.lineStep(); |
335 | } | 335 | } |
336 | 336 | ||
337 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0; | 337 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0; |
338 | 338 | ||
339 | delete [] jt; | 339 | delete [] jt; |
340 | } else { | 340 | } else { |
341 | #endif | 341 | #endif |
342 | QPainter p(this); | 342 | QPainter p(this); |
343 | 343 | ||
344 | w = 320; | 344 | w = 320; |
345 | h = 240; | 345 | h = 240; |
346 | 346 | ||
347 | if ( mediaPlayerState->scaled() ) { | 347 | if ( mediaPlayerState->scaled() ) { |
348 | // maintain aspect ratio | 348 | // maintain aspect ratio |
349 | if ( w * sh > sw * h ) | 349 | if ( w * sh > sw * h ) |
350 | w = sw * h / sh; | 350 | w = sw * h / sh; |
351 | else | 351 | else |
352 | h = sh * w / sw; | 352 | h = sh * w / sw; |
353 | } else { | 353 | } else { |
354 | w = sw; | 354 | w = sw; |
355 | h = sh; | 355 | h = sh; |
356 | } | 356 | } |
357 | 357 | ||
358 | int bytes = ( dd == 16 ) ? 2 : 4; | 358 | int bytes = ( dd == 16 ) ? 2 : 4; |
359 | QImage tempFrame( w, h, bytes << 3 ); | 359 | QImage tempFrame( w, h, bytes << 3 ); |
360 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(), | 360 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(), |
361 | 0, 0, sw, sh, w, h, format, 0) == 0; | 361 | 0, 0, sw, sh, w, h, format, 0) == 0; |
362 | if ( result && mediaPlayerState->fullscreen() ) { | 362 | if ( result && mediaPlayerState->fullscreen() ) { |
363 | 363 | ||
364 | int rw = h, rh = w; | 364 | int rw = h, rh = w; |
365 | QImage rotatedFrame( rw, rh, bytes << 3 ); | 365 | QImage rotatedFrame( rw, rh, bytes << 3 ); |
366 | 366 | ||
367 | ushort* in = (ushort*)tempFrame.bits(); | 367 | ushort* in = (ushort*)tempFrame.bits(); |
@@ -385,25 +385,25 @@ bool VideoWidget::playVideo() { | |||
385 | 385 | ||
386 | p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh ); | 386 | p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh ); |
387 | } | 387 | } |
388 | #ifdef USE_DIRECT_PAINTER | 388 | #ifdef USE_DIRECT_PAINTER |
389 | } | 389 | } |
390 | #endif | 390 | #endif |
391 | } else { | 391 | } else { |
392 | 392 | ||
393 | w = 220; | 393 | w = 220; |
394 | h = 160; | 394 | h = 160; |
395 | 395 | ||
396 | // maintain aspect ratio | 396 | // maintain aspect ratio |
397 | if ( w * sh > sw * h ) | 397 | if ( w * sh > sw * h ) |
398 | w = sw * h / sh; | 398 | w = sw * h / sh; |
399 | else | 399 | else |
400 | h = sh * w / sw; | 400 | h = sh * w / sw; |
401 | 401 | ||
402 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0; | 402 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0; |
403 | 403 | ||
404 | QPainter p( this ); | 404 | QPainter p( this ); |
405 | 405 | ||
406 | // Image changed size, therefore need to blank the possibly unpainted regions first | 406 | // Image changed size, therefore need to blank the possibly unpainted regions first |
407 | if ( scaledWidth != w || scaledHeight != h ) { | 407 | if ( scaledWidth != w || scaledHeight != h ) { |
408 | p.setBrush( QBrush( Qt::black ) ); | 408 | p.setBrush( QBrush( Qt::black ) ); |
409 | p.drawRect( 9, 20, 220, 160 ); | 409 | p.drawRect( 9, 20, 220, 160 ); |
@@ -458,15 +458,15 @@ void VideoWidget::keyReleaseEvent( QKeyEvent *e) | |||
458 | // emit moreClicked(); | 458 | // emit moreClicked(); |
459 | // emit moreReleased(); | 459 | // emit moreReleased(); |
460 | // toggleButton(5); | 460 | // toggleButton(5); |
461 | break; | 461 | break; |
462 | case Key_Right: | 462 | case Key_Right: |
463 | mediaPlayerState->setNext(); | 463 | mediaPlayerState->setNext(); |
464 | break; | 464 | break; |
465 | case Key_Left: | 465 | case Key_Left: |
466 | mediaPlayerState->setPrev(); | 466 | mediaPlayerState->setPrev(); |
467 | break; | 467 | break; |
468 | case Key_Escape: | 468 | case Key_Escape: |
469 | break; | 469 | break; |
470 | 470 | ||
471 | }; | 471 | }; |
472 | } | 472 | } |