author | harlekin <harlekin> | 2002-08-17 12:09:45 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-08-17 12:09:45 (UTC) |
commit | 313a4f44a645a0b58855ac18cdbf7642fe93a753 (patch) (unidiff) | |
tree | e2e1765ddfedb3d79e7c95cba507b46861f4532f | |
parent | bf3106b139fdcb32c0abdab9de9ade2d897c2147 (diff) | |
download | opie-313a4f44a645a0b58855ac18cdbf7642fe93a753.zip opie-313a4f44a645a0b58855ac18cdbf7642fe93a753.tar.gz opie-313a4f44a645a0b58855ac18cdbf7642fe93a753.tar.bz2 |
fix visual dirt when returning from fullscreen
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 1 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.cpp | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 6f3842f..ddb4d74 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -1,501 +1,502 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
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 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library 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 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library 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 | #include <qpe/resource.h> | 34 | #include <qpe/resource.h> |
35 | #include <qpe/mediaplayerplugininterface.h> | 35 | #include <qpe/mediaplayerplugininterface.h> |
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | 37 | ||
38 | #include <qwidget.h> | 38 | #include <qwidget.h> |
39 | #include <qpainter.h> | 39 | #include <qpainter.h> |
40 | #include <qpixmap.h> | 40 | #include <qpixmap.h> |
41 | #include <qslider.h> | 41 | #include <qslider.h> |
42 | #include <qdrawutil.h> | 42 | #include <qdrawutil.h> |
43 | #include "videowidget.h" | 43 | #include "videowidget.h" |
44 | #include "mediaplayerstate.h" | 44 | #include "mediaplayerstate.h" |
45 | 45 | ||
46 | 46 | ||
47 | #ifdef Q_WS_QWS | 47 | #ifdef Q_WS_QWS |
48 | # define USE_DIRECT_PAINTER | 48 | # define USE_DIRECT_PAINTER |
49 | # include <qdirectpainter_qws.h> | 49 | # include <qdirectpainter_qws.h> |
50 | # include <qgfxraster_qws.h> | 50 | # include <qgfxraster_qws.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | 53 | ||
54 | extern MediaPlayerState *mediaPlayerState; | 54 | extern MediaPlayerState *mediaPlayerState; |
55 | 55 | ||
56 | 56 | ||
57 | static const int xo = 2; // movable x offset | 57 | static const int xo = 2; // movable x offset |
58 | static const int yo = 0; // movable y offset | 58 | static const int yo = 0; // movable y offset |
59 | 59 | ||
60 | 60 | ||
61 | struct MediaButton { | 61 | struct MediaButton { |
62 | bool isToggle, isHeld, isDown; | 62 | bool isToggle, isHeld, isDown; |
63 | }; | 63 | }; |
64 | 64 | ||
65 | MediaButton videoButtons[] = { | 65 | MediaButton videoButtons[] = { |
66 | { FALSE, FALSE, FALSE }, // stop | 66 | { FALSE, FALSE, FALSE }, // stop |
67 | { TRUE, FALSE, FALSE }, // play | 67 | { TRUE, FALSE, FALSE }, // play |
68 | { FALSE, FALSE, FALSE }, // previous | 68 | { FALSE, FALSE, FALSE }, // previous |
69 | { FALSE, FALSE, FALSE }, // next | 69 | { FALSE, FALSE, FALSE }, // next |
70 | { FALSE, FALSE, FALSE }, // volUp | 70 | { FALSE, FALSE, FALSE }, // volUp |
71 | { FALSE, FALSE, FALSE }, // volDown | 71 | { FALSE, FALSE, FALSE }, // volDown |
72 | { TRUE, FALSE, FALSE } // fullscreen | 72 | { TRUE, FALSE, FALSE } // fullscreen |
73 | }; | 73 | }; |
74 | 74 | ||
75 | const char *skinV_mask_file_names[7] = { | 75 | const char *skinV_mask_file_names[7] = { |
76 | "stop","play","back","fwd","up","down","full" | 76 | "stop","play","back","fwd","up","down","full" |
77 | }; | 77 | }; |
78 | 78 | ||
79 | static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); | 79 | static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); |
80 | 80 | ||
81 | 81 | ||
82 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : | 82 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : |
83 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { | 83 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { |
84 | setCaption( tr("OpiePlayer - Video") ); | 84 | setCaption( tr("OpiePlayer - Video") ); |
85 | 85 | ||
86 | videoFrame = new XineVideoWidget ( this, "Video frame" ); | 86 | videoFrame = new XineVideoWidget ( this, "Video frame" ); |
87 | 87 | ||
88 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); | 88 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); |
89 | connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); | 89 | connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); |
90 | 90 | ||
91 | Config cfg("OpiePlayer"); | 91 | Config cfg("OpiePlayer"); |
92 | cfg.setGroup("Options"); | 92 | cfg.setGroup("Options"); |
93 | skin = cfg.readEntry("Skin","default"); | 93 | skin = cfg.readEntry("Skin","default"); |
94 | 94 | ||
95 | QString skinPath = "opieplayer2/skins/" + skin; | 95 | QString skinPath = "opieplayer2/skins/" + skin; |
96 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 96 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
97 | imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); | 97 | imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); |
98 | imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); | 98 | imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); |
99 | 99 | ||
100 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); | 100 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); |
101 | imgButtonMask->fill( 0 ); | 101 | imgButtonMask->fill( 0 ); |
102 | 102 | ||
103 | for ( int i = 0; i < 7; i++ ) { | 103 | for ( int i = 0; i < 7; i++ ) { |
104 | QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png"; | 104 | QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png"; |
105 | masks[i] = new QBitmap( filename ); | 105 | masks[i] = new QBitmap( filename ); |
106 | 106 | ||
107 | if ( !masks[i]->isNull() ) { | 107 | if ( !masks[i]->isNull() ) { |
108 | QImage imgMask = masks[i]->convertToImage(); | 108 | QImage imgMask = masks[i]->convertToImage(); |
109 | uchar **dest = imgButtonMask->jumpTable(); | 109 | uchar **dest = imgButtonMask->jumpTable(); |
110 | for ( int y = 0; y < imgUp->height(); y++ ) { | 110 | for ( int y = 0; y < imgUp->height(); y++ ) { |
111 | uchar *line = dest[y]; | 111 | uchar *line = dest[y]; |
112 | for ( int x = 0; x < imgUp->width(); x++ ) { | 112 | for ( int x = 0; x < imgUp->width(); x++ ) { |
113 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 113 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
114 | line[x] = i + 1; | 114 | line[x] = i + 1; |
115 | } | 115 | } |
116 | } | 116 | } |
117 | } | 117 | } |
118 | } | 118 | } |
119 | 119 | ||
120 | for ( int i = 0; i < 7; i++ ) { | 120 | for ( int i = 0; i < 7; i++ ) { |
121 | buttonPixUp[i] = NULL; | 121 | buttonPixUp[i] = NULL; |
122 | buttonPixDown[i] = NULL; | 122 | buttonPixDown[i] = NULL; |
123 | } | 123 | } |
124 | 124 | ||
125 | setBackgroundPixmap( *pixBg ); | 125 | setBackgroundPixmap( *pixBg ); |
126 | 126 | ||
127 | slider = new QSlider( Qt::Horizontal, this ); | 127 | slider = new QSlider( Qt::Horizontal, this ); |
128 | slider->setMinValue( 0 ); | 128 | slider->setMinValue( 0 ); |
129 | slider->setMaxValue( 1 ); | 129 | slider->setMaxValue( 1 ); |
130 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); | 130 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); |
131 | slider->setFocusPolicy( QWidget::NoFocus ); | 131 | slider->setFocusPolicy( QWidget::NoFocus ); |
132 | 132 | ||
133 | resizeEvent( NULL ); | 133 | resizeEvent( NULL ); |
134 | 134 | ||
135 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 135 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
136 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 136 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
137 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 137 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
138 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 138 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
139 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 139 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
140 | 140 | ||
141 | setLength( mediaPlayerState->length() ); | 141 | setLength( mediaPlayerState->length() ); |
142 | setPosition( mediaPlayerState->position() ); | 142 | setPosition( mediaPlayerState->position() ); |
143 | setFullscreen( mediaPlayerState->fullscreen() ); | 143 | setFullscreen( mediaPlayerState->fullscreen() ); |
144 | setPlaying( mediaPlayerState->playing() ); | 144 | setPlaying( mediaPlayerState->playing() ); |
145 | } | 145 | } |
146 | 146 | ||
147 | 147 | ||
148 | VideoWidget::~VideoWidget() { | 148 | VideoWidget::~VideoWidget() { |
149 | 149 | ||
150 | for ( int i = 0; i < 7; i++ ) { | 150 | for ( int i = 0; i < 7; i++ ) { |
151 | delete buttonPixUp[i]; | 151 | delete buttonPixUp[i]; |
152 | delete buttonPixDown[i]; | 152 | delete buttonPixDown[i]; |
153 | } | 153 | } |
154 | 154 | ||
155 | delete pixBg; | 155 | delete pixBg; |
156 | delete imgUp; | 156 | delete imgUp; |
157 | delete imgDn; | 157 | delete imgDn; |
158 | delete imgButtonMask; | 158 | delete imgButtonMask; |
159 | for ( int i = 0; i < 7; i++ ) { | 159 | for ( int i = 0; i < 7; i++ ) { |
160 | delete masks[i]; | 160 | delete masks[i]; |
161 | } | 161 | } |
162 | 162 | ||
163 | } | 163 | } |
164 | 164 | ||
165 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 165 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
166 | QPixmap pix( img.width(), img.height() ); | 166 | QPixmap pix( img.width(), img.height() ); |
167 | QPainter p( &pix ); | 167 | QPainter p( &pix ); |
168 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 168 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
169 | p.drawImage( 0, 0, img ); | 169 | p.drawImage( 0, 0, img ); |
170 | return new QPixmap( pix ); | 170 | return new QPixmap( pix ); |
171 | } | 171 | } |
172 | 172 | ||
173 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { | 173 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { |
174 | QPixmap *pixmap = new QPixmap( pix ); | 174 | QPixmap *pixmap = new QPixmap( pix ); |
175 | pixmap->setMask( mask ); | 175 | pixmap->setMask( mask ); |
176 | return pixmap; | 176 | return pixmap; |
177 | } | 177 | } |
178 | 178 | ||
179 | void VideoWidget::resizeEvent( QResizeEvent * ) { | 179 | void VideoWidget::resizeEvent( QResizeEvent * ) { |
180 | int h = height(); | 180 | int h = height(); |
181 | int w = width(); | 181 | int w = width(); |
182 | int Vh = 160; | 182 | int Vh = 160; |
183 | int Vw = 220; | 183 | int Vw = 220; |
184 | 184 | ||
185 | slider->setFixedWidth( w - 20 ); | 185 | slider->setFixedWidth( w - 20 ); |
186 | slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); | 186 | slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); |
187 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); | 187 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); |
188 | slider->setFocusPolicy( QWidget::NoFocus ); | 188 | slider->setFocusPolicy( QWidget::NoFocus ); |
189 | slider->setBackgroundPixmap( *pixBg ); | 189 | slider->setBackgroundPixmap( *pixBg ); |
190 | 190 | ||
191 | xoff = 0;// ( imgUp->width() ) / 2; | 191 | xoff = 0;// ( imgUp->width() ) / 2; |
192 | yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; | 192 | yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; |
193 | QPoint p( xoff, yoff ); | 193 | QPoint p( xoff, yoff ); |
194 | 194 | ||
195 | QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); | 195 | QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); |
196 | QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); | 196 | QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); |
197 | 197 | ||
198 | for ( int i = 0; i < 7; i++ ) { | 198 | for ( int i = 0; i < 7; i++ ) { |
199 | if ( !masks[i]->isNull() ) { | 199 | if ( !masks[i]->isNull() ) { |
200 | delete buttonPixUp[i]; | 200 | delete buttonPixUp[i]; |
201 | delete buttonPixDown[i]; | 201 | delete buttonPixDown[i]; |
202 | buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); | 202 | buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); |
203 | buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); | 203 | buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); |
204 | } | 204 | } |
205 | } | 205 | } |
206 | 206 | ||
207 | delete pixUp; | 207 | delete pixUp; |
208 | delete pixDn; | 208 | delete pixDn; |
209 | } | 209 | } |
210 | 210 | ||
211 | static bool videoSliderBeingMoved = FALSE; | 211 | static bool videoSliderBeingMoved = FALSE; |
212 | 212 | ||
213 | void VideoWidget::sliderPressed() { | 213 | void VideoWidget::sliderPressed() { |
214 | videoSliderBeingMoved = TRUE; | 214 | videoSliderBeingMoved = TRUE; |
215 | } | 215 | } |
216 | 216 | ||
217 | void VideoWidget::sliderReleased() { | 217 | void VideoWidget::sliderReleased() { |
218 | videoSliderBeingMoved = FALSE; | 218 | videoSliderBeingMoved = FALSE; |
219 | if ( slider->width() == 0 ) { | 219 | if ( slider->width() == 0 ) { |
220 | return; | 220 | return; |
221 | } | 221 | } |
222 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); | 222 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); |
223 | mediaPlayerState->setPosition( val ); | 223 | mediaPlayerState->setPosition( val ); |
224 | } | 224 | } |
225 | 225 | ||
226 | void VideoWidget::setPosition( long i ) { | 226 | void VideoWidget::setPosition( long i ) { |
227 | updateSlider( i, mediaPlayerState->length() ); | 227 | updateSlider( i, mediaPlayerState->length() ); |
228 | } | 228 | } |
229 | 229 | ||
230 | 230 | ||
231 | void VideoWidget::setLength( long max ) { | 231 | void VideoWidget::setLength( long max ) { |
232 | updateSlider( mediaPlayerState->position(), max ); | 232 | updateSlider( mediaPlayerState->position(), max ); |
233 | } | 233 | } |
234 | 234 | ||
235 | void VideoWidget::setView( char view ) { | 235 | void VideoWidget::setView( char view ) { |
236 | 236 | ||
237 | if ( view == 'v' ) { | 237 | if ( view == 'v' ) { |
238 | makeVisible(); | 238 | makeVisible(); |
239 | } else { | 239 | } else { |
240 | // Effectively blank the view next time we show it so it looks nicer | 240 | // Effectively blank the view next time we show it so it looks nicer |
241 | scaledWidth = 0; | 241 | scaledWidth = 0; |
242 | scaledHeight = 0; | 242 | scaledHeight = 0; |
243 | hide(); | 243 | hide(); |
244 | } | 244 | } |
245 | } | 245 | } |
246 | 246 | ||
247 | void VideoWidget::updateSlider( long i, long max ) { | 247 | void VideoWidget::updateSlider( long i, long max ) { |
248 | // Will flicker too much if we don't do this | 248 | // Will flicker too much if we don't do this |
249 | if ( max == 0 ) { | 249 | if ( max == 0 ) { |
250 | return; | 250 | return; |
251 | } | 251 | } |
252 | int width = slider->width(); | 252 | int width = slider->width(); |
253 | int val = int((double)i * width / max); | 253 | int val = int((double)i * width / max); |
254 | if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { | 254 | if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { |
255 | if ( slider->value() != val ) { | 255 | if ( slider->value() != val ) { |
256 | slider->setValue( val ); | 256 | slider->setValue( val ); |
257 | } | 257 | } |
258 | if ( slider->maxValue() != width ) { | 258 | if ( slider->maxValue() != width ) { |
259 | slider->setMaxValue( width ); | 259 | slider->setMaxValue( width ); |
260 | } | 260 | } |
261 | } | 261 | } |
262 | } | 262 | } |
263 | 263 | ||
264 | void VideoWidget::setToggleButton( int i, bool down ) { | 264 | void VideoWidget::setToggleButton( int i, bool down ) { |
265 | if ( down != videoButtons[i].isDown ) { | 265 | if ( down != videoButtons[i].isDown ) { |
266 | toggleButton( i ); | 266 | toggleButton( i ); |
267 | } | 267 | } |
268 | } | 268 | } |
269 | 269 | ||
270 | void VideoWidget::toggleButton( int i ) { | 270 | void VideoWidget::toggleButton( int i ) { |
271 | videoButtons[i].isDown = !videoButtons[i].isDown; | 271 | videoButtons[i].isDown = !videoButtons[i].isDown; |
272 | QPainter p(this); | 272 | QPainter p(this); |
273 | paintButton ( &p, i ); | 273 | paintButton ( &p, i ); |
274 | } | 274 | } |
275 | 275 | ||
276 | void VideoWidget::paintButton( QPainter *p, int i ) { | 276 | void VideoWidget::paintButton( QPainter *p, int i ) { |
277 | 277 | ||
278 | if ( videoButtons[i].isDown ) { | 278 | if ( videoButtons[i].isDown ) { |
279 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | 279 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); |
280 | } else { | 280 | } else { |
281 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | 281 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); |
282 | } | 282 | } |
283 | } | 283 | } |
284 | 284 | ||
285 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 285 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
286 | for ( int i = 0; i < numVButtons; i++ ) { | 286 | for ( int i = 0; i < numVButtons; i++ ) { |
287 | if ( event->state() == QMouseEvent::LeftButton ) { | 287 | if ( event->state() == QMouseEvent::LeftButton ) { |
288 | // The test to see if the mouse click is inside the button or not | 288 | // The test to see if the mouse click is inside the button or not |
289 | int x = event->pos().x() - xoff; | 289 | int x = event->pos().x() - xoff; |
290 | int y = event->pos().y() - yoff; | 290 | int y = event->pos().y() - yoff; |
291 | 291 | ||
292 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() | 292 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() |
293 | && y < imgButtonMask->height() | 293 | && y < imgButtonMask->height() |
294 | && imgButtonMask->pixelIndex( x, y ) == i + 1 ); | 294 | && imgButtonMask->pixelIndex( x, y ) == i + 1 ); |
295 | 295 | ||
296 | if ( isOnButton && !videoButtons[i].isHeld ) { | 296 | if ( isOnButton && !videoButtons[i].isHeld ) { |
297 | videoButtons[i].isHeld = TRUE; | 297 | videoButtons[i].isHeld = TRUE; |
298 | toggleButton(i); | 298 | toggleButton(i); |
299 | 299 | ||
300 | switch (i) { | 300 | switch (i) { |
301 | case VideoVolUp: | 301 | case VideoVolUp: |
302 | emit moreClicked(); | 302 | emit moreClicked(); |
303 | return; | 303 | return; |
304 | case VideoVolDown: | 304 | case VideoVolDown: |
305 | emit lessClicked(); | 305 | emit lessClicked(); |
306 | return; | 306 | return; |
307 | } | 307 | } |
308 | } else if ( !isOnButton && videoButtons[i].isHeld ) { | 308 | } else if ( !isOnButton && videoButtons[i].isHeld ) { |
309 | videoButtons[i].isHeld = FALSE; | 309 | videoButtons[i].isHeld = FALSE; |
310 | toggleButton(i); | 310 | toggleButton(i); |
311 | } | 311 | } |
312 | } else { | 312 | } else { |
313 | 313 | ||
314 | if ( videoButtons[i].isHeld ) { | 314 | if ( videoButtons[i].isHeld ) { |
315 | videoButtons[i].isHeld = FALSE; | 315 | videoButtons[i].isHeld = FALSE; |
316 | if ( !videoButtons[i].isToggle ) { | 316 | if ( !videoButtons[i].isToggle ) { |
317 | setToggleButton( i, FALSE ); | 317 | setToggleButton( i, FALSE ); |
318 | } | 318 | } |
319 | 319 | ||
320 | switch(i) { | 320 | switch(i) { |
321 | 321 | ||
322 | case VideoPlay: { | 322 | case VideoPlay: { |
323 | if( mediaPlayerState->isPaused ) { | 323 | if( mediaPlayerState->isPaused ) { |
324 | setToggleButton( i, FALSE ); | 324 | setToggleButton( i, FALSE ); |
325 | mediaPlayerState->setPaused( FALSE ); | 325 | mediaPlayerState->setPaused( FALSE ); |
326 | return; | 326 | return; |
327 | } else if( !mediaPlayerState->isPaused ) { | 327 | } else if( !mediaPlayerState->isPaused ) { |
328 | setToggleButton( i, TRUE ); | 328 | setToggleButton( i, TRUE ); |
329 | mediaPlayerState->setPaused( TRUE ); | 329 | mediaPlayerState->setPaused( TRUE ); |
330 | return; | 330 | return; |
331 | } else { | 331 | } else { |
332 | return; | 332 | return; |
333 | } | 333 | } |
334 | } | 334 | } |
335 | 335 | ||
336 | case VideoStop: mediaPlayerState->setPlaying( FALSE ); return; | 336 | case VideoStop: mediaPlayerState->setPlaying( FALSE ); return; |
337 | case VideoNext: mediaPlayerState->setNext(); return; | 337 | case VideoNext: mediaPlayerState->setNext(); return; |
338 | case VideoPrevious: mediaPlayerState->setPrev(); return; | 338 | case VideoPrevious: mediaPlayerState->setPrev(); return; |
339 | case VideoVolUp: emit moreReleased(); return; | 339 | case VideoVolUp: emit moreReleased(); return; |
340 | case VideoVolDown: emit lessReleased(); return; | 340 | case VideoVolDown: emit lessReleased(); return; |
341 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | 341 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; |
342 | } | 342 | } |
343 | } | 343 | } |
344 | } | 344 | } |
345 | } | 345 | } |
346 | } | 346 | } |
347 | 347 | ||
348 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { | 348 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { |
349 | mouseMoveEvent( event ); | 349 | mouseMoveEvent( event ); |
350 | } | 350 | } |
351 | 351 | ||
352 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 352 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
353 | if ( mediaPlayerState->fullscreen() ) { | 353 | if ( mediaPlayerState->fullscreen() ) { |
354 | mediaPlayerState->setFullscreen( FALSE ); | 354 | mediaPlayerState->setFullscreen( FALSE ); |
355 | makeVisible(); | 355 | makeVisible(); |
356 | } | 356 | } |
357 | mouseMoveEvent( event ); | 357 | mouseMoveEvent( event ); |
358 | } | 358 | } |
359 | 359 | ||
360 | void VideoWidget::showEvent( QShowEvent* ) { | 360 | void VideoWidget::showEvent( QShowEvent* ) { |
361 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 361 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
362 | mouseMoveEvent( &event ); | 362 | mouseMoveEvent( &event ); |
363 | } | 363 | } |
364 | 364 | ||
365 | 365 | ||
366 | void VideoWidget::backToNormal() { | 366 | void VideoWidget::backToNormal() { |
367 | mediaPlayerState->setFullscreen( FALSE ); | 367 | mediaPlayerState->setFullscreen( FALSE ); |
368 | makeVisible(); | 368 | makeVisible(); |
369 | } | 369 | } |
370 | 370 | ||
371 | void VideoWidget::makeVisible() { | 371 | void VideoWidget::makeVisible() { |
372 | if ( mediaPlayerState->fullscreen() ) { | 372 | if ( mediaPlayerState->fullscreen() ) { |
373 | setBackgroundMode( QWidget::NoBackground ); | 373 | setBackgroundMode( QWidget::NoBackground ); |
374 | showFullScreen(); | 374 | showFullScreen(); |
375 | resize( qApp->desktop()->size() ); | 375 | resize( qApp->desktop()->size() ); |
376 | slider->hide(); | 376 | slider->hide(); |
377 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); | 377 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); |
378 | 378 | ||
379 | } else { | 379 | } else { |
380 | showNormal(); | ||
380 | showMaximized(); | 381 | showMaximized(); |
381 | setBackgroundPixmap( *pixBg ); | 382 | setBackgroundPixmap( *pixBg ); |
382 | if ( mediaPlayerState->streaming() ) { | 383 | if ( mediaPlayerState->streaming() ) { |
383 | slider->hide(); | 384 | slider->hide(); |
384 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 385 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
385 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 386 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
386 | } else { | 387 | } else { |
387 | slider->show(); | 388 | slider->show(); |
388 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 389 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
389 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 390 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
390 | } | 391 | } |
391 | videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); | 392 | videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); |
392 | qApp->processEvents(); | 393 | qApp->processEvents(); |
393 | } | 394 | } |
394 | } | 395 | } |
395 | 396 | ||
396 | 397 | ||
397 | void VideoWidget::paintEvent( QPaintEvent * pe) { | 398 | void VideoWidget::paintEvent( QPaintEvent * pe) { |
398 | QPainter p( this ); | 399 | QPainter p( this ); |
399 | 400 | ||
400 | if ( mediaPlayerState->fullscreen() ) { | 401 | if ( mediaPlayerState->fullscreen() ) { |
401 | // Clear the background | 402 | // Clear the background |
402 | p.setBrush( QBrush( Qt::black ) ); | 403 | p.setBrush( QBrush( Qt::black ) ); |
403 | } else { | 404 | } else { |
404 | if ( !pe->erased() ) { | 405 | if ( !pe->erased() ) { |
405 | // Combine with background and double buffer | 406 | // Combine with background and double buffer |
406 | QPixmap pix( pe->rect().size() ); | 407 | QPixmap pix( pe->rect().size() ); |
407 | QPainter p( &pix ); | 408 | QPainter p( &pix ); |
408 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 409 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
409 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); | 410 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); |
410 | for ( int i = 0; i < numVButtons; i++ ) { | 411 | for ( int i = 0; i < numVButtons; i++ ) { |
411 | paintButton( &p, i ); | 412 | paintButton( &p, i ); |
412 | } | 413 | } |
413 | QPainter p2( this ); | 414 | QPainter p2( this ); |
414 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 415 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
415 | } else { | 416 | } else { |
416 | QPainter p( this ); | 417 | QPainter p( this ); |
417 | for ( int i = 0; i < numVButtons; i++ ) | 418 | for ( int i = 0; i < numVButtons; i++ ) |
418 | paintButton( &p, i ); | 419 | paintButton( &p, i ); |
419 | } | 420 | } |
420 | slider->repaint( TRUE ); | 421 | slider->repaint( TRUE ); |
421 | } | 422 | } |
422 | } | 423 | } |
423 | 424 | ||
424 | 425 | ||
425 | void VideoWidget::closeEvent( QCloseEvent* ) { | 426 | void VideoWidget::closeEvent( QCloseEvent* ) { |
426 | mediaPlayerState->setList(); | 427 | mediaPlayerState->setList(); |
427 | } | 428 | } |
428 | 429 | ||
429 | 430 | ||
430 | 431 | ||
431 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { | 432 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { |
432 | switch ( e->key() ) { | 433 | switch ( e->key() ) { |
433 | ////////////////////////////// Zaurus keys | 434 | ////////////////////////////// Zaurus keys |
434 | case Key_Home: | 435 | case Key_Home: |
435 | break; | 436 | break; |
436 | case Key_F9: //activity | 437 | case Key_F9: //activity |
437 | break; | 438 | break; |
438 | case Key_F10: //contacts | 439 | case Key_F10: //contacts |
439 | // hide(); | 440 | // hide(); |
440 | break; | 441 | break; |
441 | case Key_F11: //menu | 442 | case Key_F11: //menu |
442 | break; | 443 | break; |
443 | case Key_F12: //home | 444 | case Key_F12: //home |
444 | break; | 445 | break; |
445 | case Key_F13: //mail | 446 | case Key_F13: //mail |
446 | break; | 447 | break; |
447 | case Key_Space: { | 448 | case Key_Space: { |
448 | if(mediaPlayerState->playing()) { | 449 | if(mediaPlayerState->playing()) { |
449 | mediaPlayerState->setPlaying(FALSE); | 450 | mediaPlayerState->setPlaying(FALSE); |
450 | } else { | 451 | } else { |
451 | mediaPlayerState->setPlaying(TRUE); | 452 | mediaPlayerState->setPlaying(TRUE); |
452 | } | 453 | } |
453 | } | 454 | } |
454 | break; | 455 | break; |
455 | case Key_Down: | 456 | case Key_Down: |
456 | // toggleButton(6); | 457 | // toggleButton(6); |
457 | emit lessClicked(); | 458 | emit lessClicked(); |
458 | emit lessReleased(); | 459 | emit lessReleased(); |
459 | // toggleButton(6); | 460 | // toggleButton(6); |
460 | break; | 461 | break; |
461 | case Key_Up: | 462 | case Key_Up: |
462 | // toggleButton(5); | 463 | // toggleButton(5); |
463 | emit moreClicked(); | 464 | emit moreClicked(); |
464 | emit moreReleased(); | 465 | emit moreReleased(); |
465 | // toggleButton(5); | 466 | // toggleButton(5); |
466 | break; | 467 | break; |
467 | case Key_Right: | 468 | case Key_Right: |
468 | mediaPlayerState->setNext(); | 469 | mediaPlayerState->setNext(); |
469 | break; | 470 | break; |
470 | case Key_Left: | 471 | case Key_Left: |
471 | mediaPlayerState->setPrev(); | 472 | mediaPlayerState->setPrev(); |
472 | break; | 473 | break; |
473 | case Key_Escape: | 474 | case Key_Escape: |
474 | #if defined(QT_QWS_IPAQ) | 475 | #if defined(QT_QWS_IPAQ) |
475 | if( mediaPlayerState->isPaused ) { | 476 | if( mediaPlayerState->isPaused ) { |
476 | setToggleButton( i, FALSE ); | 477 | setToggleButton( i, FALSE ); |
477 | mediaPlayerState->setPaused( FALSE ); | 478 | mediaPlayerState->setPaused( FALSE ); |
478 | } else if( !mediaPlayerState->isPaused ) { | 479 | } else if( !mediaPlayerState->isPaused ) { |
479 | setToggleButton( i, TRUE ); | 480 | setToggleButton( i, TRUE ); |
480 | mediaPlayerState->setPaused( TRUE ); | 481 | mediaPlayerState->setPaused( TRUE ); |
481 | } | 482 | } |
482 | #endif | 483 | #endif |
483 | break; | 484 | break; |
484 | 485 | ||
485 | }; | 486 | }; |
486 | } | 487 | } |
487 | 488 | ||
488 | XineVideoWidget* VideoWidget::vidWidget() { | 489 | XineVideoWidget* VideoWidget::vidWidget() { |
489 | return videoFrame; | 490 | return videoFrame; |
490 | } | 491 | } |
491 | 492 | ||
492 | 493 | ||
493 | void VideoWidget::setFullscreen ( bool b ) { | 494 | void VideoWidget::setFullscreen ( bool b ) { |
494 | setToggleButton( VideoFullscreen, b ); | 495 | setToggleButton( VideoFullscreen, b ); |
495 | } | 496 | } |
496 | 497 | ||
497 | 498 | ||
498 | void VideoWidget::setPlaying( bool b) { | 499 | void VideoWidget::setPlaying( bool b) { |
499 | setToggleButton( VideoPlay, b ); | 500 | setToggleButton( VideoPlay, b ); |
500 | } | 501 | } |
501 | 502 | ||
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp index 8fd2743..c03ea16 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.cpp +++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp | |||
@@ -1,200 +1,201 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
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 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library 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 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library 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 <qpe/qcopenvelope_qws.h> | 36 | #include <qpe/qcopenvelope_qws.h> |
37 | #include <qpe/qpeapplication.h> | 37 | #include <qpe/qpeapplication.h> |
38 | #include "xinecontrol.h" | 38 | #include "xinecontrol.h" |
39 | #include "mediaplayerstate.h" | 39 | #include "mediaplayerstate.h" |
40 | #include "videowidget.h" | 40 | #include "videowidget.h" |
41 | 41 | ||
42 | extern MediaPlayerState *mediaPlayerState; | 42 | extern MediaPlayerState *mediaPlayerState; |
43 | extern VideoWidget *videoUI; | 43 | extern VideoWidget *videoUI; |
44 | XineControl::XineControl( QObject *parent, const char *name ) | 44 | XineControl::XineControl( QObject *parent, const char *name ) |
45 | : QObject( parent, name ) { | 45 | : QObject( parent, name ) { |
46 | libXine = new XINE::Lib(videoUI->vidWidget() ); | 46 | libXine = new XINE::Lib(videoUI->vidWidget() ); |
47 | 47 | ||
48 | connect ( videoUI, SIGNAL( videoResized ( const QSize & )), this, SLOT( videoResized ( const QSize & ))); | 48 | connect ( videoUI, SIGNAL( videoResized ( const QSize & )), this, SLOT( videoResized ( const QSize & ))); |
49 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); | 49 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); |
50 | connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) ); | 50 | connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) ); |
51 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); | 51 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); |
52 | connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); | 52 | connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); |
53 | connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); | 53 | connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); |
54 | connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); | 54 | connect( libXine, SIGNAL( stopped() ), this, SLOT( nextMedia() ) ); |
55 | 55 | ||
56 | disabledSuspendScreenSaver = FALSE; | 56 | disabledSuspendScreenSaver = FALSE; |
57 | } | 57 | } |
58 | 58 | ||
59 | XineControl::~XineControl() { | 59 | XineControl::~XineControl() { |
60 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 60 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
61 | if ( disabledSuspendScreenSaver ) { | 61 | if ( disabledSuspendScreenSaver ) { |
62 | disabledSuspendScreenSaver = FALSE; | 62 | disabledSuspendScreenSaver = FALSE; |
63 | // Re-enable the suspend mode | 63 | // Re-enable the suspend mode |
64 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 64 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
65 | } | 65 | } |
66 | #endif | 66 | #endif |
67 | delete libXine; | 67 | delete libXine; |
68 | } | 68 | } |
69 | 69 | ||
70 | void XineControl::play( const QString& fileName ) { | 70 | void XineControl::play( const QString& fileName ) { |
71 | hasVideoChannel=FALSE; | 71 | hasVideoChannel=FALSE; |
72 | hasAudioChannel=FALSE; | 72 | hasAudioChannel=FALSE; |
73 | m_fileName = fileName; | 73 | m_fileName = fileName; |
74 | qDebug("<<FILENAME: " + fileName + ">>>>"); | ||
74 | libXine->play( fileName ); | 75 | libXine->play( fileName ); |
75 | mediaPlayerState->setPlaying( true ); | 76 | mediaPlayerState->setPlaying( true ); |
76 | // default to audio view until we know how to handle video | 77 | // default to audio view until we know how to handle video |
77 | // MediaDetect mdetect; | 78 | // MediaDetect mdetect; |
78 | char whichGui = mdetect.videoOrAudio( fileName ); | 79 | char whichGui = mdetect.videoOrAudio( fileName ); |
79 | if (whichGui == 'f') { | 80 | if (whichGui == 'f') { |
80 | qDebug("Nicht erkannter Dateityp"); | 81 | qDebug("Nicht erkannter Dateityp"); |
81 | return; | 82 | return; |
82 | } | 83 | } |
83 | 84 | ||
84 | if (whichGui == 'a') { | 85 | if (whichGui == 'a') { |
85 | libXine->setShowVideo( false ); | 86 | libXine->setShowVideo( false ); |
86 | hasAudioChannel=TRUE; | 87 | hasAudioChannel=TRUE; |
87 | } else { | 88 | } else { |
88 | libXine->setShowVideo( true ); | 89 | libXine->setShowVideo( true ); |
89 | hasVideoChannel=TRUE; | 90 | hasVideoChannel=TRUE; |
90 | } | 91 | } |
91 | 92 | ||
92 | // determine if slider is shown | 93 | // determine if slider is shown |
93 | // mediaPlayerState->setIsStreaming( mdetect.isStreaming( fileName ) ); | 94 | // mediaPlayerState->setIsStreaming( mdetect.isStreaming( fileName ) ); |
94 | mediaPlayerState->setIsStreaming( !libXine->isSeekable() ); | 95 | mediaPlayerState->setIsStreaming( !libXine->isSeekable() ); |
95 | // which gui (video / audio) | 96 | // which gui (video / audio) |
96 | mediaPlayerState->setView( whichGui ); | 97 | mediaPlayerState->setView( whichGui ); |
97 | 98 | ||
98 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 99 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
99 | if ( !disabledSuspendScreenSaver ) { | 100 | if ( !disabledSuspendScreenSaver ) { |
100 | disabledSuspendScreenSaver = TRUE; | 101 | disabledSuspendScreenSaver = TRUE; |
101 | // Stop the screen from blanking and power saving state | 102 | // Stop the screen from blanking and power saving state |
102 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) | 103 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) |
103 | << ( whichGui == 'v' ? QPEApplication::Disable : QPEApplication::DisableSuspend ); | 104 | << ( whichGui == 'v' ? QPEApplication::Disable : QPEApplication::DisableSuspend ); |
104 | } | 105 | } |
105 | #endif | 106 | #endif |
106 | 107 | ||
107 | length(); | 108 | length(); |
108 | position(); | 109 | position(); |
109 | } | 110 | } |
110 | 111 | ||
111 | void XineControl::nextMedia() { | 112 | void XineControl::nextMedia() { |
112 | mediaPlayerState->setNext(); | 113 | mediaPlayerState->setNext(); |
113 | } | 114 | } |
114 | 115 | ||
115 | void XineControl::stop( bool isSet ) { | 116 | void XineControl::stop( bool isSet ) { |
116 | if ( !isSet) { | 117 | if ( !isSet) { |
117 | libXine->stop( ); | 118 | libXine->stop( ); |
118 | mediaPlayerState->setList(); | 119 | mediaPlayerState->setList(); |
119 | // mediaPlayerState->setPlaying( false ); | 120 | // mediaPlayerState->setPlaying( false ); |
120 | 121 | ||
121 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 122 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
122 | if ( disabledSuspendScreenSaver ) { | 123 | if ( disabledSuspendScreenSaver ) { |
123 | disabledSuspendScreenSaver = FALSE; | 124 | disabledSuspendScreenSaver = FALSE; |
124 | // Re-enable the suspend mode | 125 | // Re-enable the suspend mode |
125 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 126 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
126 | } | 127 | } |
127 | #endif | 128 | #endif |
128 | 129 | ||
129 | } else { | 130 | } else { |
130 | // play again | 131 | // play again |
131 | } | 132 | } |
132 | } | 133 | } |
133 | 134 | ||
134 | /** | 135 | /** |
135 | * Pause playback | 136 | * Pause playback |
136 | * @isSet | 137 | * @isSet |
137 | */ | 138 | */ |
138 | void XineControl::pause( bool isSet) { | 139 | void XineControl::pause( bool isSet) { |
139 | if (isSet) { | 140 | if (isSet) { |
140 | libXine->pause(); | 141 | libXine->pause(); |
141 | } else { | 142 | } else { |
142 | libXine->play( m_fileName, 0, m_currentTime); | 143 | libXine->play( m_fileName, 0, m_currentTime); |
143 | } | 144 | } |
144 | } | 145 | } |
145 | 146 | ||
146 | 147 | ||
147 | /** | 148 | /** |
148 | * get current time in playback | 149 | * get current time in playback |
149 | */ | 150 | */ |
150 | long XineControl::currentTime() { | 151 | long XineControl::currentTime() { |
151 | // todo: jede sekunde überprüfen | 152 | // todo: jede sekunde überprüfen |
152 | m_currentTime = libXine->currentTime(); | 153 | m_currentTime = libXine->currentTime(); |
153 | return m_currentTime; | 154 | return m_currentTime; |
154 | QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); | 155 | QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); |
155 | } | 156 | } |
156 | 157 | ||
157 | /** | 158 | /** |
158 | * Set the length of the media file | 159 | * Set the length of the media file |
159 | */ | 160 | */ |
160 | void XineControl::length() { | 161 | void XineControl::length() { |
161 | m_length = libXine->length(); | 162 | m_length = libXine->length(); |
162 | mediaPlayerState->setLength( m_length ); | 163 | mediaPlayerState->setLength( m_length ); |
163 | } | 164 | } |
164 | 165 | ||
165 | 166 | ||
166 | /** | 167 | /** |
167 | * Reports the position the xine backend is at right now | 168 | * Reports the position the xine backend is at right now |
168 | * @return long the postion in seconds | 169 | * @return long the postion in seconds |
169 | */ | 170 | */ |
170 | long XineControl::position() { | 171 | long XineControl::position() { |
171 | m_position = ( currentTime() ); | 172 | m_position = ( currentTime() ); |
172 | mediaPlayerState->updatePosition( m_position ); | 173 | mediaPlayerState->updatePosition( m_position ); |
173 | long emitPos = (long)m_position; | 174 | long emitPos = (long)m_position; |
174 | emit positionChanged( emitPos ); | 175 | emit positionChanged( emitPos ); |
175 | if(mediaPlayerState->isPlaying) | 176 | if(mediaPlayerState->isPlaying) |
176 | // needs to be stopped the media is stopped | 177 | // needs to be stopped the media is stopped |
177 | QTimer::singleShot( 1000, this, SLOT( position() ) ); | 178 | QTimer::singleShot( 1000, this, SLOT( position() ) ); |
178 | // qDebug("POSITION : %d", m_position); | 179 | // qDebug("POSITION : %d", m_position); |
179 | return m_position; | 180 | return m_position; |
180 | } | 181 | } |
181 | 182 | ||
182 | /** | 183 | /** |
183 | * Set videoplayback to fullscreen | 184 | * Set videoplayback to fullscreen |
184 | * @param isSet | 185 | * @param isSet |
185 | */ | 186 | */ |
186 | void XineControl::setFullscreen( bool isSet ) { | 187 | void XineControl::setFullscreen( bool isSet ) { |
187 | libXine->showVideoFullScreen( isSet); | 188 | libXine->showVideoFullScreen( isSet); |
188 | } | 189 | } |
189 | 190 | ||
190 | /** | 191 | /** |
191 | * Seek to a position in the track | 192 | * Seek to a position in the track |
192 | * @param second the second to jump to | 193 | * @param second the second to jump to |
193 | */ | 194 | */ |
194 | void XineControl::seekTo( long second ) { | 195 | void XineControl::seekTo( long second ) { |
195 | libXine->play( m_fileName , 0, (int)second ); | 196 | libXine->play( m_fileName , 0, (int)second ); |
196 | } | 197 | } |
197 | 198 | ||
198 | void XineControl::videoResized ( const QSize &s ) { | 199 | void XineControl::videoResized ( const QSize &s ) { |
199 | libXine-> resize ( s ); | 200 | libXine-> resize ( s ); |
200 | } | 201 | } |