Diffstat (limited to 'core/multimedia/opieplayer/videowidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/videowidget.cpp | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp index 164458b..e851044 100644 --- a/core/multimedia/opieplayer/videowidget.cpp +++ b/core/multimedia/opieplayer/videowidget.cpp | |||
@@ -8,33 +8,38 @@ | |||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | |||
21 | #include "videowidget.h" | ||
22 | #include "mediaplayerstate.h" | ||
23 | |||
24 | /* OPIE */ | ||
20 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
21 | #include <qpe/mediaplayerplugininterface.h> | 26 | #include <qpe/mediaplayerplugininterface.h> |
22 | #include <qpe/config.h> | 27 | #include <qpe/config.h> |
23 | #include <qpe/qpeapplication.h> | 28 | #include <qpe/qpeapplication.h> |
29 | #include <opie2/odebug.h> | ||
24 | 30 | ||
31 | /* QT */ | ||
25 | #include <qdir.h> | 32 | #include <qdir.h> |
26 | #include <qslider.h> | 33 | #include <qslider.h> |
27 | #include "videowidget.h" | ||
28 | #include "mediaplayerstate.h" | ||
29 | 34 | ||
30 | 35 | ||
31 | #ifdef Q_WS_QWS | 36 | #ifdef Q_WS_QWS |
32 | # define USE_DIRECT_PAINTER | 37 | # define USE_DIRECT_PAINTER |
33 | # include <qdirectpainter_qws.h> | 38 | # include <qdirectpainter_qws.h> |
34 | # include <qgfxraster_qws.h> | 39 | # include <qgfxraster_qws.h> |
35 | #endif | 40 | #endif |
36 | 41 | ||
37 | 42 | ||
38 | extern MediaPlayerState *mediaPlayerState; | 43 | extern MediaPlayerState *mediaPlayerState; |
39 | 44 | ||
40 | 45 | ||
@@ -73,70 +78,70 @@ VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : | |||
73 | { | 78 | { |
74 | setCaption( tr("OpiePlayer") ); | 79 | setCaption( tr("OpiePlayer") ); |
75 | Config cfg("OpiePlayer"); | 80 | Config cfg("OpiePlayer"); |
76 | 81 | ||
77 | cfg.setGroup("Options"); | 82 | cfg.setGroup("Options"); |
78 | skin = cfg.readEntry("Skin","default"); | 83 | skin = cfg.readEntry("Skin","default"); |
79 | 84 | ||
80 | QString skinPath; | 85 | QString skinPath; |
81 | skinPath = "opieplayer2/skins/" + skin; | 86 | skinPath = "opieplayer2/skins/" + skin; |
82 | if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists()) | 87 | if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists()) |
83 | skinPath = "opieplayer2/skins/default"; | 88 | skinPath = "opieplayer2/skins/default"; |
84 | 89 | ||
85 | // qDebug("skin path " + skinPath); | 90 | // odebug << "skin path " + skinPath << oendl; |
86 | 91 | ||
87 | // QString skinPath = "opieplayer2/skins/" + skin; | 92 | // QString skinPath = "opieplayer2/skins/" + skin; |
88 | 93 | ||
89 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 94 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
90 | imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); | 95 | imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); |
91 | imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); | 96 | imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); |
92 | 97 | ||
93 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); | 98 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); |
94 | imgButtonMask->fill( 0 ); | 99 | imgButtonMask->fill( 0 ); |
95 | 100 | ||
96 | for ( int i = 0; i < 7; i++ ) { | 101 | for ( int i = 0; i < 7; i++ ) { |
97 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + | 102 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + |
98 | "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); | 103 | "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); |
99 | // qDebug("loading "+filename); | 104 | // odebug << "loading "+filename << oendl; |
100 | masks[i] = new QBitmap( filename ); | 105 | masks[i] = new QBitmap( filename ); |
101 | 106 | ||
102 | if ( !masks[i]->isNull() ) { | 107 | if ( !masks[i]->isNull() ) { |
103 | QImage imgMask = masks[i]->convertToImage(); | 108 | QImage imgMask = masks[i]->convertToImage(); |
104 | uchar **dest = imgButtonMask->jumpTable(); | 109 | uchar **dest = imgButtonMask->jumpTable(); |
105 | for ( int y = 0; y < imgUp->height(); y++ ) { | 110 | for ( int y = 0; y < imgUp->height(); y++ ) { |
106 | uchar *line = dest[y]; | 111 | uchar *line = dest[y]; |
107 | for ( int x = 0; x < imgUp->width(); x++ ) { | 112 | for ( int x = 0; x < imgUp->width(); x++ ) { |
108 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 113 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
109 | line[x] = i + 1; | 114 | line[x] = i + 1; |
110 | } | 115 | } |
111 | } | 116 | } |
112 | } | 117 | } |
113 | } | 118 | } |
114 | // qDebug("finished loading first pics"); | 119 | // odebug << "finished loading first pics" << oendl; |
115 | for ( int i = 0; i < 7; i++ ) { | 120 | for ( int i = 0; i < 7; i++ ) { |
116 | buttonPixUp[i] = NULL; | 121 | buttonPixUp[i] = NULL; |
117 | buttonPixDown[i] = NULL; | 122 | buttonPixDown[i] = NULL; |
118 | } | 123 | } |
119 | 124 | ||
120 | 125 | ||
121 | QWidget *d = QApplication::desktop(); | 126 | QWidget *d = QApplication::desktop(); |
122 | int width = d->width(); | 127 | int width = d->width(); |
123 | int height = d->height(); | 128 | int height = d->height(); |
124 | 129 | ||
125 | if( (width != pixBg->width() ) || (height != pixBg->height() ) ) { | 130 | if( (width != pixBg->width() ) || (height != pixBg->height() ) ) { |
126 | // qDebug("<<<<<<<< scale image >>>>>>>>>>>>"); | 131 | // odebug << "<<<<<<<< scale image >>>>>>>>>>>>" << oendl; |
127 | QImage img; | 132 | QImage img; |
128 | img = pixBg->convertToImage(); | 133 | img = pixBg->convertToImage(); |
129 | pixBg->convertFromImage( img.smoothScale( width, height)); | 134 | pixBg->convertFromImage( img.smoothScale( width, height)); |
130 | } | 135 | } |
131 | setBackgroundPixmap( *pixBg ); | 136 | setBackgroundPixmap( *pixBg ); |
132 | 137 | ||
133 | currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); | 138 | currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); |
134 | 139 | ||
135 | slider = new QSlider( Qt::Horizontal, this ); | 140 | slider = new QSlider( Qt::Horizontal, this ); |
136 | slider->setMinValue( 0 ); | 141 | slider->setMinValue( 0 ); |
137 | slider->setMaxValue( 1 ); | 142 | slider->setMaxValue( 1 ); |
138 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); | 143 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); |
139 | slider->setFocusPolicy( QWidget::NoFocus ); | 144 | slider->setFocusPolicy( QWidget::NoFocus ); |
140 | // slider->setGeometry( QRect( 7, 250, 220, 20 ) ); | 145 | // slider->setGeometry( QRect( 7, 250, 220, 20 ) ); |
141 | 146 | ||
142 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 147 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
@@ -344,38 +349,38 @@ void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | |||
344 | } | 349 | } |
345 | } else { | 350 | } else { |
346 | 351 | ||
347 | if ( videoButtons[i].isHeld ) { | 352 | if ( videoButtons[i].isHeld ) { |
348 | videoButtons[i].isHeld = FALSE; | 353 | videoButtons[i].isHeld = FALSE; |
349 | if ( !videoButtons[i].isToggle ) { | 354 | if ( !videoButtons[i].isToggle ) { |
350 | setToggleButton( i, FALSE ); | 355 | setToggleButton( i, FALSE ); |
351 | } | 356 | } |
352 | 357 | ||
353 | switch(i) { | 358 | switch(i) { |
354 | 359 | ||
355 | case VideoPlay: { | 360 | case VideoPlay: { |
356 | // qDebug("play"); | 361 | // odebug << "play" << oendl; |
357 | if( !mediaPlayerState->playing()) { | 362 | if( !mediaPlayerState->playing()) { |
358 | mediaPlayerState->setPlaying( true); | 363 | mediaPlayerState->setPlaying( true); |
359 | setToggleButton( i-1, false ); | 364 | setToggleButton( i-1, false ); |
360 | setToggleButton( i, false ); | 365 | setToggleButton( i, false ); |
361 | return; | 366 | return; |
362 | } | 367 | } |
363 | if( mediaPlayerState->isPaused ) { | 368 | if( mediaPlayerState->isPaused ) { |
364 | // qDebug("isPaused"); | 369 | // odebug << "isPaused" << oendl; |
365 | setToggleButton( i, FALSE ); | 370 | setToggleButton( i, FALSE ); |
366 | mediaPlayerState->setPaused( FALSE ); | 371 | mediaPlayerState->setPaused( FALSE ); |
367 | return; | 372 | return; |
368 | } else if( !mediaPlayerState->isPaused ) { | 373 | } else if( !mediaPlayerState->isPaused ) { |
369 | // qDebug("is not paused"); | 374 | // odebug << "is not paused" << oendl; |
370 | setToggleButton( i, TRUE ); | 375 | setToggleButton( i, TRUE ); |
371 | mediaPlayerState->setPaused( TRUE ); | 376 | mediaPlayerState->setPaused( TRUE ); |
372 | return; | 377 | return; |
373 | } else { | 378 | } else { |
374 | return; | 379 | return; |
375 | } | 380 | } |
376 | } | 381 | } |
377 | 382 | ||
378 | case VideoStop: mediaPlayerState->setPlaying( FALSE ); setToggleButton( i+1, true); setToggleButton( i, true ); return; | 383 | case VideoStop: mediaPlayerState->setPlaying( FALSE ); setToggleButton( i+1, true); setToggleButton( i, true ); return; |
379 | case VideoNext: mediaPlayerState->setNext(); return; | 384 | case VideoNext: mediaPlayerState->setNext(); return; |
380 | case VideoPrevious: mediaPlayerState->setPrev(); return; | 385 | case VideoPrevious: mediaPlayerState->setPrev(); return; |
381 | case VideoVolUp: emit moreReleased(); return; | 386 | case VideoVolUp: emit moreReleased(); return; |
@@ -449,25 +454,25 @@ void VideoWidget::paintEvent( QPaintEvent * pe) { | |||
449 | slider->repaint( TRUE ); | 454 | slider->repaint( TRUE ); |
450 | } | 455 | } |
451 | } | 456 | } |
452 | 457 | ||
453 | 458 | ||
454 | void VideoWidget::closeEvent( QCloseEvent* ) { | 459 | void VideoWidget::closeEvent( QCloseEvent* ) { |
455 | mediaPlayerState->setList(); | 460 | mediaPlayerState->setList(); |
456 | } | 461 | } |
457 | 462 | ||
458 | 463 | ||
459 | bool VideoWidget::playVideo() { | 464 | bool VideoWidget::playVideo() { |
460 | bool result = FALSE; | 465 | bool result = FALSE; |
461 | // qDebug("<<<<<<<<<<<<<<<< play video"); | 466 | // odebug << "<<<<<<<<<<<<<<<< play video" << oendl; |
462 | int stream = 0; | 467 | int stream = 0; |
463 | 468 | ||
464 | int sw = mediaPlayerState->curDecoder()->videoWidth( stream ); | 469 | int sw = mediaPlayerState->curDecoder()->videoWidth( stream ); |
465 | int sh = mediaPlayerState->curDecoder()->videoHeight( stream ); | 470 | int sh = mediaPlayerState->curDecoder()->videoHeight( stream ); |
466 | int dd = QPixmap::defaultDepth(); | 471 | int dd = QPixmap::defaultDepth(); |
467 | int w = height(); | 472 | int w = height(); |
468 | int h = width(); | 473 | int h = width(); |
469 | 474 | ||
470 | ColorFormat format = (dd == 16) ? RGB565 : BGRA8888; | 475 | ColorFormat format = (dd == 16) ? RGB565 : BGRA8888; |
471 | 476 | ||
472 | if ( mediaPlayerState->fullscreen() ) | 477 | if ( mediaPlayerState->fullscreen() ) |
473 | { | 478 | { |