author | simon <simon> | 2002-12-11 11:40:20 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-11 11:40:20 (UTC) |
commit | 03ac4af4d6014bbd46b12d5fe89ee2cc73941080 (patch) (unidiff) | |
tree | f88296c20f73e7e46d03daff3000ef34acd31bb0 | |
parent | 9431b69a1efab055c28c77e780df012b0a476a57 (diff) | |
download | opie-03ac4af4d6014bbd46b12d5fe89ee2cc73941080.zip opie-03ac4af4d6014bbd46b12d5fe89ee2cc73941080.tar.gz opie-03ac4af4d6014bbd46b12d5fe89ee2cc73941080.tar.bz2 |
- slight simplification of XineControl constructor
- fixed a race between the video resizing and the xine initialization
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayer.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.cpp | 16 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.h | 6 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinevideowidget.cpp | 27 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinevideowidget.h | 4 |
5 files changed, 37 insertions, 18 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp index 0d9a5b8..c230d6f 100644 --- a/noncore/multimedia/opieplayer2/mediaplayer.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp | |||
@@ -343,35 +343,35 @@ void MediaPlayer::cleanUp() {// this happens on closing | |||
343 | playList.writeDefaultPlaylist( ); | 343 | playList.writeDefaultPlaylist( ); |
344 | 344 | ||
345 | // QPEApplication::grabKeyboard(); | 345 | // QPEApplication::grabKeyboard(); |
346 | // QPEApplication::ungrabKeyboard(); | 346 | // QPEApplication::ungrabKeyboard(); |
347 | } | 347 | } |
348 | 348 | ||
349 | void MediaPlayer::recreateAudioAndVideoWidgets() | 349 | void MediaPlayer::recreateAudioAndVideoWidgets() |
350 | { | 350 | { |
351 | delete xineControl; | 351 | delete xineControl; |
352 | delete audioUI; | 352 | delete audioUI; |
353 | delete videoUI; | 353 | delete videoUI; |
354 | audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" ); | 354 | audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" ); |
355 | videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" ); | 355 | videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" ); |
356 | 356 | ||
357 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 357 | connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
358 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 358 | connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
359 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 359 | connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
360 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 360 | connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
361 | 361 | ||
362 | connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); | 362 | connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); |
363 | connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); | 363 | connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); |
364 | connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); | 364 | connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); |
365 | connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); | 365 | connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); |
366 | 366 | ||
367 | xineControl = new XineControl( videoUI, videoUI->vidWidget(), mediaPlayerState ); | 367 | xineControl = new XineControl( videoUI->vidWidget(), mediaPlayerState ); |
368 | connect( xineControl, SIGNAL( initialized() ), | 368 | connect( xineControl, SIGNAL( initialized() ), |
369 | &mediaPlayerState, SLOT( setBackendInitialized() ) ); | 369 | &mediaPlayerState, SLOT( setBackendInitialized() ) ); |
370 | } | 370 | } |
371 | 371 | ||
372 | void MediaPlayer::reloadSkins() | 372 | void MediaPlayer::reloadSkins() |
373 | { | 373 | { |
374 | audioUI->loadSkin(); | 374 | audioUI->loadSkin(); |
375 | videoUI->loadSkin(); | 375 | videoUI->loadSkin(); |
376 | } | 376 | } |
377 | 377 | ||
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp index 14e71d9..e791c3b 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.cpp +++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp | |||
@@ -17,66 +17,66 @@ | |||
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; General Public License for more | 22 | ..}^=.= = ; General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = General Public License along with | 26 | -_. . . )=. = General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | 34 | ||
35 | #include <qtimer.h> | 35 | #include <qtimer.h> |
36 | #include <qmessagebox.h> | 36 | #include <qmessagebox.h> |
37 | #include <qpe/qcopenvelope_qws.h> | 37 | #include <qpe/qcopenvelope_qws.h> |
38 | #include <qpe/qpeapplication.h> | 38 | #include <qpe/qpeapplication.h> |
39 | #include "xinecontrol.h" | 39 | #include "xinecontrol.h" |
40 | #include "mediaplayerstate.h" | 40 | #include "mediaplayerstate.h" |
41 | #include "xinevideowidget.h" | ||
41 | 42 | ||
42 | XineControl::XineControl( QWidget *videoContainerWidget, XineVideoWidget *xineWidget, | 43 | XineControl::XineControl( XineVideoWidget *xineWidget, |
43 | MediaPlayerState &_mediaPlayerState, | 44 | MediaPlayerState &_mediaPlayerState, |
44 | QObject *parent, const char *name ) | 45 | QObject *parent, const char *name ) |
45 | : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ) | 46 | : QObject( parent, name ), mediaPlayerState( _mediaPlayerState ), xineVideoWidget( xineWidget ) |
46 | { | 47 | { |
47 | 48 | ||
48 | libXine = new XINE::Lib( xineWidget ); | 49 | libXine = new XINE::Lib( xineWidget ); |
49 | 50 | ||
50 | connect ( videoContainerWidget, SIGNAL( videoResized( const QSize & )), this, SLOT( videoResized ( const QSize & ) ) ); | ||
51 | connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pause( bool ) ) ); | 51 | connect( &mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pause( bool ) ) ); |
52 | connect( this, SIGNAL( positionChanged( long ) ), &mediaPlayerState, SLOT( updatePosition( long ) ) ); | 52 | connect( this, SIGNAL( positionChanged( long ) ), &mediaPlayerState, SLOT( updatePosition( long ) ) ); |
53 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); | 53 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); |
54 | connect( &mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); | 54 | connect( &mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); |
55 | connect( &mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); | 55 | connect( &mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); |
56 | connect( &mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) ); | 56 | connect( &mediaPlayerState, SIGNAL( videoGammaChanged( int ) ), this, SLOT( setGamma( int ) ) ); |
57 | connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); | 57 | connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); |
58 | connect( libXine, SIGNAL( initialized() ), this, SIGNAL( initialized() ) ); | 58 | connect( libXine, SIGNAL( initialized() ), this, SLOT( xineInitialized() ) ); |
59 | 59 | ||
60 | disabledSuspendScreenSaver = FALSE; | 60 | disabledSuspendScreenSaver = FALSE; |
61 | } | 61 | } |
62 | 62 | ||
63 | XineControl::~XineControl() { | 63 | XineControl::~XineControl() { |
64 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 64 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
65 | if ( disabledSuspendScreenSaver ) { | 65 | if ( disabledSuspendScreenSaver ) { |
66 | disabledSuspendScreenSaver = FALSE; | 66 | disabledSuspendScreenSaver = FALSE; |
67 | // Re-enable the suspend mode | 67 | // Re-enable the suspend mode |
68 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 68 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
69 | } | 69 | } |
70 | #endif | 70 | #endif |
71 | delete libXine; | 71 | delete libXine; |
72 | } | 72 | } |
73 | 73 | ||
74 | void XineControl::play( const QString& fileName ) { | 74 | void XineControl::play( const QString& fileName ) { |
75 | hasVideoChannel = FALSE; | 75 | hasVideoChannel = FALSE; |
76 | hasAudioChannel = FALSE; | 76 | hasAudioChannel = FALSE; |
77 | m_fileName = fileName; | 77 | m_fileName = fileName; |
78 | 78 | ||
79 | qDebug("<<FILENAME: " + fileName + ">>>>"); | 79 | qDebug("<<FILENAME: " + fileName + ">>>>"); |
80 | 80 | ||
81 | if ( !libXine->play( fileName, 0, 0 ) ) { | 81 | if ( !libXine->play( fileName, 0, 0 ) ) { |
82 | QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); | 82 | QMessageBox::warning( 0l , tr( "Failure" ), getErrorCode() ); |
@@ -105,48 +105,56 @@ void XineControl::play( const QString& fileName ) { | |||
105 | // which gui (video / audio) | 105 | // which gui (video / audio) |
106 | mediaPlayerState.setDisplayType( displayType ); | 106 | mediaPlayerState.setDisplayType( displayType ); |
107 | 107 | ||
108 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 108 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
109 | if ( !disabledSuspendScreenSaver ) { | 109 | if ( !disabledSuspendScreenSaver ) { |
110 | disabledSuspendScreenSaver = TRUE; | 110 | disabledSuspendScreenSaver = TRUE; |
111 | // Stop the screen from blanking and power saving state | 111 | // Stop the screen from blanking and power saving state |
112 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) | 112 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) |
113 | << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend ); | 113 | << ( displayType == MediaPlayerState::Video ? QPEApplication::Disable : QPEApplication::DisableSuspend ); |
114 | } | 114 | } |
115 | #endif | 115 | #endif |
116 | 116 | ||
117 | length(); | 117 | length(); |
118 | position(); | 118 | position(); |
119 | } | 119 | } |
120 | 120 | ||
121 | void XineControl::nextMedia() { | 121 | void XineControl::nextMedia() { |
122 | mediaPlayerState.setNext(); | 122 | mediaPlayerState.setNext(); |
123 | } | 123 | } |
124 | 124 | ||
125 | void XineControl::setGamma( int value ) { | 125 | void XineControl::setGamma( int value ) { |
126 | libXine->setGamma( value ); | 126 | libXine->setGamma( value ); |
127 | } | 127 | } |
128 | 128 | ||
129 | void XineControl::xineInitialized() | ||
130 | { | ||
131 | connect( xineVideoWidget, SIGNAL( videoResized( const QSize & ) ), this, SLOT( videoResized ( const QSize & ) ) ); | ||
132 | libXine->resize( xineVideoWidget->videoSize() ); | ||
133 | |||
134 | emit initialized(); | ||
135 | } | ||
136 | |||
129 | void XineControl::stop( bool isSet ) { | 137 | void XineControl::stop( bool isSet ) { |
130 | if ( !isSet ) { | 138 | if ( !isSet ) { |
131 | libXine->stop(); | 139 | libXine->stop(); |
132 | 140 | ||
133 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 141 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
134 | if ( disabledSuspendScreenSaver ) { | 142 | if ( disabledSuspendScreenSaver ) { |
135 | disabledSuspendScreenSaver = FALSE; | 143 | disabledSuspendScreenSaver = FALSE; |
136 | // Re-enable the suspend mode | 144 | // Re-enable the suspend mode |
137 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 145 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
138 | } | 146 | } |
139 | #endif | 147 | #endif |
140 | } | 148 | } |
141 | } | 149 | } |
142 | 150 | ||
143 | /** | 151 | /** |
144 | * Pause playback | 152 | * Pause playback |
145 | * @isSet | 153 | * @isSet |
146 | */ | 154 | */ |
147 | void XineControl::pause( bool isSet) { | 155 | void XineControl::pause( bool isSet) { |
148 | libXine->pause( isSet ); | 156 | libXine->pause( isSet ); |
149 | } | 157 | } |
150 | 158 | ||
151 | 159 | ||
152 | /** | 160 | /** |
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.h b/noncore/multimedia/opieplayer2/xinecontrol.h index 000529c..085de3f 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.h +++ b/noncore/multimedia/opieplayer2/xinecontrol.h | |||
@@ -21,49 +21,49 @@ | |||
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; General Public License for more | 22 | ..}^=.= = ; General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = General Public License along with | 26 | -_. . . )=. = General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifndef XINECONTROL_H | 34 | #ifndef XINECONTROL_H |
35 | #define XINECONTROL_H | 35 | #define XINECONTROL_H |
36 | 36 | ||
37 | #include "lib.h" | 37 | #include "lib.h" |
38 | #include <qobject.h> | 38 | #include <qobject.h> |
39 | 39 | ||
40 | #include "mediaplayerstate.h" | 40 | #include "mediaplayerstate.h" |
41 | 41 | ||
42 | class XineControl : public QObject { | 42 | class XineControl : public QObject { |
43 | Q_OBJECT | 43 | Q_OBJECT |
44 | public: | 44 | public: |
45 | XineControl( QWidget *videoContainerWidget, XineVideoWidget *xineWidget, | 45 | XineControl( XineVideoWidget *xineWidget, |
46 | MediaPlayerState &_mediaPlayerState, | 46 | MediaPlayerState &_mediaPlayerState, |
47 | QObject *parent = 0, const char *name =0 ); | 47 | QObject *parent = 0, const char *name =0 ); |
48 | ~XineControl(); | 48 | ~XineControl(); |
49 | 49 | ||
50 | bool hasVideo() const { return hasVideoChannel; } | 50 | bool hasVideo() const { return hasVideoChannel; } |
51 | bool hasAudio() const { return hasAudioChannel; } | 51 | bool hasAudio() const { return hasAudioChannel; } |
52 | 52 | ||
53 | public slots: | 53 | public slots: |
54 | void play( const QString& fileName ); | 54 | void play( const QString& fileName ); |
55 | void stop( bool ); | 55 | void stop( bool ); |
56 | 56 | ||
57 | /** | 57 | /** |
58 | * Pause the media stream | 58 | * Pause the media stream |
59 | * @param if pause or not | 59 | * @param if pause or not |
60 | */ | 60 | */ |
61 | void pause( bool ); | 61 | void pause( bool ); |
62 | 62 | ||
63 | /** | 63 | /** |
64 | * Set videos fullscreen | 64 | * Set videos fullscreen |
65 | * @param yes or no | 65 | * @param yes or no |
66 | */ | 66 | */ |
67 | void setFullscreen( bool ); | 67 | void setFullscreen( bool ); |
68 | 68 | ||
69 | /** | 69 | /** |
@@ -80,43 +80,47 @@ public slots: | |||
80 | */ | 80 | */ |
81 | void nextMedia(); | 81 | void nextMedia(); |
82 | 82 | ||
83 | /** | 83 | /** |
84 | * Get as much info about the stream from xine as possible | 84 | * Get as much info about the stream from xine as possible |
85 | */ | 85 | */ |
86 | QString getMetaInfo(); | 86 | QString getMetaInfo(); |
87 | 87 | ||
88 | /** | 88 | /** |
89 | * get the error code and "translate" it for the user | 89 | * get the error code and "translate" it for the user |
90 | * | 90 | * |
91 | */ | 91 | */ |
92 | QString getErrorCode(); | 92 | QString getErrorCode(); |
93 | 93 | ||
94 | 94 | ||
95 | void videoResized ( const QSize &s ); | 95 | void videoResized ( const QSize &s ); |
96 | 96 | ||
97 | /** | 97 | /** |
98 | * Set the gamma value of the video output | 98 | * Set the gamma value of the video output |
99 | * @param int value between -100 and 100, 0 is original | 99 | * @param int value between -100 and 100, 0 is original |
100 | */ | 100 | */ |
101 | void setGamma( int ); | 101 | void setGamma( int ); |
102 | 102 | ||
103 | 103 | ||
104 | private slots: | ||
105 | void xineInitialized(); | ||
106 | |||
104 | private: | 107 | private: |
105 | XINE::Lib *libXine; | 108 | XINE::Lib *libXine; |
106 | long m_currentTime; | 109 | long m_currentTime; |
107 | long m_position; | 110 | long m_position; |
108 | int m_length; | 111 | int m_length; |
109 | QString m_fileName; | 112 | QString m_fileName; |
110 | bool disabledSuspendScreenSaver : 1; | 113 | bool disabledSuspendScreenSaver : 1; |
111 | bool hasVideoChannel : 1; | 114 | bool hasVideoChannel : 1; |
112 | bool hasAudioChannel : 1; | 115 | bool hasAudioChannel : 1; |
113 | MediaPlayerState &mediaPlayerState; | 116 | MediaPlayerState &mediaPlayerState; |
117 | XineVideoWidget *xineVideoWidget; | ||
114 | 118 | ||
115 | signals: | 119 | signals: |
116 | void positionChanged( long ); | 120 | void positionChanged( long ); |
117 | 121 | ||
118 | void initialized(); | 122 | void initialized(); |
119 | }; | 123 | }; |
120 | 124 | ||
121 | 125 | ||
122 | #endif | 126 | #endif |
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp index 1d88cea..791818e 100644 --- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp +++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp | |||
@@ -87,48 +87,63 @@ static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t st | |||
87 | XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name ) | 87 | XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name ) |
88 | : QWidget ( parent, name, WRepaintNoErase | WResizeNoErase ) | 88 | : QWidget ( parent, name, WRepaintNoErase | WResizeNoErase ) |
89 | { | 89 | { |
90 | setBackgroundMode ( NoBackground ); | 90 | setBackgroundMode ( NoBackground ); |
91 | 91 | ||
92 | m_logo = 0; | 92 | m_logo = 0; |
93 | m_buff = 0; | 93 | m_buff = 0; |
94 | m_bytes_per_line_fb = qt_screen-> linestep ( ); | 94 | m_bytes_per_line_fb = qt_screen-> linestep ( ); |
95 | m_bytes_per_pixel = ( qt_screen->depth() + 7 ) / 8; | 95 | m_bytes_per_pixel = ( qt_screen->depth() + 7 ) / 8; |
96 | m_rotation = 0; | 96 | m_rotation = 0; |
97 | } | 97 | } |
98 | 98 | ||
99 | 99 | ||
100 | XineVideoWidget::~XineVideoWidget ( ) | 100 | XineVideoWidget::~XineVideoWidget ( ) |
101 | { | 101 | { |
102 | delete m_logo; | 102 | delete m_logo; |
103 | } | 103 | } |
104 | 104 | ||
105 | void XineVideoWidget::clear ( ) | 105 | void XineVideoWidget::clear ( ) |
106 | { | 106 | { |
107 | m_buff = 0; | 107 | m_buff = 0; |
108 | repaint ( false ); | 108 | repaint ( false ); |
109 | } | 109 | } |
110 | 110 | ||
111 | QSize XineVideoWidget::videoSize() const | ||
112 | { | ||
113 | QSize s = size(); | ||
114 | bool fs = ( s == qApp->desktop()->size() ); | ||
115 | |||
116 | // if we are in fullscreen mode, do not rotate the video | ||
117 | // (!! the paint routine uses m_rotation + qt_screen-> transformOrientation() !!) | ||
118 | m_rotation = fs ? - qt_screen->transformOrientation() : 0; | ||
119 | |||
120 | if ( fs && qt_screen->isTransformed() ) | ||
121 | s = qt_screen->mapToDevice( s ); | ||
122 | |||
123 | return s; | ||
124 | } | ||
125 | |||
111 | void XineVideoWidget::paintEvent ( QPaintEvent * ) | 126 | void XineVideoWidget::paintEvent ( QPaintEvent * ) |
112 | { | 127 | { |
113 | if ( m_buff == 0 ) { | 128 | if ( m_buff == 0 ) { |
114 | QPainter p ( this ); | 129 | QPainter p ( this ); |
115 | p. fillRect ( rect ( ), black ); | 130 | p. fillRect ( rect ( ), black ); |
116 | if ( m_logo ) | 131 | if ( m_logo ) |
117 | p. drawImage ( 0, 0, *m_logo ); | 132 | p. drawImage ( 0, 0, *m_logo ); |
118 | } | 133 | } |
119 | else { | 134 | else { |
120 | // Qt needs to be notified which areas were really updated .. strange | 135 | // Qt needs to be notified which areas were really updated .. strange |
121 | QArray <QRect> qt_bug_workaround_clip_rects; | 136 | QArray <QRect> qt_bug_workaround_clip_rects; |
122 | 137 | ||
123 | { | 138 | { |
124 | QDirectPainter dp ( this ); | 139 | QDirectPainter dp ( this ); |
125 | 140 | ||
126 | int rot = dp. transformOrientation ( ) + m_rotation; // device rotation + custom rotation | 141 | int rot = dp. transformOrientation ( ) + m_rotation; // device rotation + custom rotation |
127 | 142 | ||
128 | uchar *fb = dp. frameBuffer ( ); | 143 | uchar *fb = dp. frameBuffer ( ); |
129 | uchar *frame = m_buff; | 144 | uchar *frame = m_buff; |
130 | 145 | ||
131 | // where is the video frame in fb coordinates | 146 | // where is the video frame in fb coordinates |
132 | QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); | 147 | QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); |
133 | 148 | ||
134 | qt_bug_workaround_clip_rects. resize ( dp. numRects ( )); | 149 | qt_bug_workaround_clip_rects. resize ( dp. numRects ( )); |
@@ -230,43 +245,33 @@ void XineVideoWidget::setLogo ( QImage* logo ) | |||
230 | 245 | ||
231 | void XineVideoWidget::setVideoFrame ( uchar* img, int w, int h, int bpl ) | 246 | void XineVideoWidget::setVideoFrame ( uchar* img, int w, int h, int bpl ) |
232 | { | 247 | { |
233 | bool rot90 = (( -m_rotation ) & 1 ); | 248 | bool rot90 = (( -m_rotation ) & 1 ); |
234 | 249 | ||
235 | if ( rot90 ) { // if the rotation is 90 or 270 we have to swap width / height | 250 | if ( rot90 ) { // if the rotation is 90 or 270 we have to swap width / height |
236 | int d = w; | 251 | int d = w; |
237 | w = h; | 252 | w = h; |
238 | h = d; | 253 | h = d; |
239 | } | 254 | } |
240 | 255 | ||
241 | m_lastframe = m_thisframe; | 256 | m_lastframe = m_thisframe; |
242 | m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); | 257 | m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); |
243 | 258 | ||
244 | m_buff = img; | 259 | m_buff = img; |
245 | m_bytes_per_line_frame = bpl; | 260 | m_bytes_per_line_frame = bpl; |
246 | 261 | ||
247 | // only repaint the area that *really* needs to be repainted | 262 | // only repaint the area that *really* needs to be repainted |
248 | 263 | ||
249 | repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false ); | 264 | repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false ); |
250 | } | 265 | } |
251 | 266 | ||
252 | void XineVideoWidget::resizeEvent ( QResizeEvent * ) | 267 | void XineVideoWidget::resizeEvent ( QResizeEvent * ) |
253 | { | 268 | { |
254 | QSize s = size ( ); | 269 | emit videoResized( videoSize() ); |
255 | bool fs = ( s == qApp-> desktop ( )-> size ( )); | ||
256 | |||
257 | // if we are in fullscreen mode, do not rotate the video | ||
258 | // (!! the paint routine uses m_rotation + qt_screen-> transformOrientation() !!) | ||
259 | m_rotation = fs ? -qt_screen-> transformOrientation ( ) : 0; | ||
260 | |||
261 | if ( fs && qt_screen-> isTransformed ( )) | ||
262 | s = qt_screen-> mapToDevice ( s ); | ||
263 | |||
264 | emit videoResized ( s ); | ||
265 | } | 270 | } |
266 | 271 | ||
267 | 272 | ||
268 | void XineVideoWidget::mouseReleaseEvent ( QMouseEvent * /*me*/ ) | 273 | void XineVideoWidget::mouseReleaseEvent ( QMouseEvent * /*me*/ ) |
269 | { | 274 | { |
270 | emit clicked(); | 275 | emit clicked(); |
271 | } | 276 | } |
272 | 277 | ||
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.h b/noncore/multimedia/opieplayer2/xinevideowidget.h index 33f1470..8b3a3ea 100644 --- a/noncore/multimedia/opieplayer2/xinevideowidget.h +++ b/noncore/multimedia/opieplayer2/xinevideowidget.h | |||
@@ -29,46 +29,48 @@ | |||
29 | Boston, MA 02111-1307, USA. | 29 | Boston, MA 02111-1307, USA. |
30 | 30 | ||
31 | */ | 31 | */ |
32 | 32 | ||
33 | 33 | ||
34 | 34 | ||
35 | #include <qwidget.h> | 35 | #include <qwidget.h> |
36 | 36 | ||
37 | #include "lib.h" | 37 | #include "lib.h" |
38 | 38 | ||
39 | class QImage; | 39 | class QImage; |
40 | 40 | ||
41 | 41 | ||
42 | class XineVideoWidget : public QWidget { | 42 | class XineVideoWidget : public QWidget { |
43 | Q_OBJECT | 43 | Q_OBJECT |
44 | 44 | ||
45 | public: | 45 | public: |
46 | XineVideoWidget ( QWidget* parent, const char* name ); | 46 | XineVideoWidget ( QWidget* parent, const char* name ); |
47 | ~XineVideoWidget ( ); | 47 | ~XineVideoWidget ( ); |
48 | QImage *logo ( ) const; | 48 | QImage *logo ( ) const; |
49 | void setLogo ( QImage *image ); | 49 | void setLogo ( QImage *image ); |
50 | void setVideoFrame ( uchar *image, int width, int height, int linestep ); | 50 | void setVideoFrame ( uchar *image, int width, int height, int linestep ); |
51 | void clear ( ); | 51 | void clear ( ); |
52 | 52 | ||
53 | QSize videoSize() const; | ||
54 | |||
53 | protected: | 55 | protected: |
54 | void paintEvent( QPaintEvent *p ); | 56 | void paintEvent( QPaintEvent *p ); |
55 | void resizeEvent ( QResizeEvent *r ); | 57 | void resizeEvent ( QResizeEvent *r ); |
56 | 58 | ||
57 | void mouseReleaseEvent ( QMouseEvent *e ); | 59 | void mouseReleaseEvent ( QMouseEvent *e ); |
58 | 60 | ||
59 | signals: | 61 | signals: |
60 | void clicked ( ); | 62 | void clicked ( ); |
61 | void videoResized ( const QSize &s ); | 63 | void videoResized ( const QSize &s ); |
62 | 64 | ||
63 | private: | 65 | private: |
64 | QRect m_lastframe; | 66 | QRect m_lastframe; |
65 | QRect m_thisframe; | 67 | QRect m_thisframe; |
66 | 68 | ||
67 | uchar *m_buff; | 69 | uchar *m_buff; |
68 | int m_bytes_per_line_fb; | 70 | int m_bytes_per_line_fb; |
69 | int m_bytes_per_line_frame; | 71 | int m_bytes_per_line_frame; |
70 | int m_bytes_per_pixel; | 72 | int m_bytes_per_pixel; |
71 | QImage *m_logo; | 73 | QImage *m_logo; |
72 | int m_rotation; | 74 | mutable int m_rotation; |
73 | }; | 75 | }; |
74 | 76 | ||