author | harlekin <harlekin> | 2002-08-15 16:29:52 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-08-15 16:29:52 (UTC) |
commit | 320f73ae9a8ffc6daf009b3fefb9035506b0f684 (patch) (unidiff) | |
tree | 52b4e54d1c73cdff58411a1da2485effb2aaa6bb | |
parent | 32ce744f58463ff11afb26ef5c4c8cf3f3d03fd3 (diff) | |
download | opie-320f73ae9a8ffc6daf009b3fefb9035506b0f684.zip opie-320f73ae9a8ffc6daf009b3fefb9035506b0f684.tar.gz opie-320f73ae9a8ffc6daf009b3fefb9035506b0f684.tar.bz2 |
more simular to audiowidget
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 190 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.h | 16 |
2 files changed, 103 insertions, 103 deletions
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index fb375f0..fbcd775 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -84,407 +84,401 @@ 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 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); | 87 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); |
88 | 88 | ||
89 | Config cfg("OpiePlayer"); | 89 | Config cfg("OpiePlayer"); |
90 | cfg.setGroup("Options"); | 90 | cfg.setGroup("Options"); |
91 | skin = cfg.readEntry("Skin","default"); | 91 | skin = cfg.readEntry("Skin","default"); |
92 | 92 | ||
93 | QString skinPath = "opieplayer2/skins/" + skin; | 93 | QString skinPath = "opieplayer2/skins/" + skin; |
94 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 94 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
95 | imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); | 95 | imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); |
96 | imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); | 96 | imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); |
97 | 97 | ||
98 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); | 98 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); |
99 | imgButtonMask->fill( 0 ); | 99 | imgButtonMask->fill( 0 ); |
100 | 100 | ||
101 | for ( int i = 0; i < 7; i++ ) { | 101 | for ( int i = 0; i < 7; i++ ) { |
102 | QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png"; | 102 | QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png"; |
103 | masks[i] = new QBitmap( filename ); | 103 | masks[i] = new QBitmap( filename ); |
104 | qDebug(filename); | 104 | qDebug(filename); |
105 | if ( !masks[i]->isNull() ) { | 105 | if ( !masks[i]->isNull() ) { |
106 | QImage imgMask = masks[i]->convertToImage(); | 106 | QImage imgMask = masks[i]->convertToImage(); |
107 | uchar **dest = imgButtonMask->jumpTable(); | 107 | uchar **dest = imgButtonMask->jumpTable(); |
108 | for ( int y = 0; y < imgUp->height(); y++ ) { | 108 | for ( int y = 0; y < imgUp->height(); y++ ) { |
109 | uchar *line = dest[y]; | 109 | uchar *line = dest[y]; |
110 | for ( int x = 0; x < imgUp->width(); x++ ) { | 110 | for ( int x = 0; x < imgUp->width(); x++ ) { |
111 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 111 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
112 | line[x] = i + 1; | 112 | line[x] = i + 1; |
113 | } | 113 | } |
114 | } | 114 | } |
115 | } | 115 | } |
116 | |||
117 | } | 116 | } |
118 | 117 | ||
119 | for ( int i = 0; i < 7; i++ ) { | 118 | for ( int i = 0; i < 7; i++ ) { |
120 | buttonPixUp[i] = NULL; | 119 | buttonPixUp[i] = NULL; |
121 | buttonPixDown[i] = NULL; | 120 | buttonPixDown[i] = NULL; |
122 | } | 121 | } |
123 | 122 | ||
124 | setBackgroundPixmap( *pixBg ); | 123 | setBackgroundPixmap( *pixBg ); |
125 | 124 | ||
126 | slider = new QSlider( Qt::Horizontal, this ); | 125 | slider = new QSlider( Qt::Horizontal, this ); |
127 | slider->setMinValue( 0 ); | 126 | slider->setMinValue( 0 ); |
128 | slider->setMaxValue( 1 ); | 127 | slider->setMaxValue( 1 ); |
129 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); | 128 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); |
130 | slider->setFocusPolicy( QWidget::NoFocus ); | 129 | slider->setFocusPolicy( QWidget::NoFocus ); |
131 | slider->setGeometry( QRect( 7, 250, 220, 20 ) ); | 130 | |
131 | resizeEvent( NULL ); | ||
132 | 132 | ||
133 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 133 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
134 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 134 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
135 | |||
136 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 135 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
137 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | ||
138 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | ||
139 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 136 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
140 | |||
141 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 137 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
142 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 138 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
143 | 139 | ||
144 | setLength( mediaPlayerState->length() ); | 140 | setLength( mediaPlayerState->length() ); |
145 | setPosition( mediaPlayerState->position() ); | 141 | setPosition( mediaPlayerState->position() ); |
146 | |||
147 | ////////////////////////// FIXME | ||
148 | setFullscreen( mediaPlayerState->fullscreen() ); | 142 | setFullscreen( mediaPlayerState->fullscreen() ); |
149 | setPaused( mediaPlayerState->paused() ); | 143 | setPaused( mediaPlayerState->paused() ); |
150 | setPlaying( mediaPlayerState->playing() ); | 144 | setPlaying( mediaPlayerState->playing() ); |
151 | qDebug("finished videowidget"); | ||
152 | } | 145 | } |
153 | 146 | ||
154 | 147 | ||
155 | VideoWidget::~VideoWidget() { | 148 | VideoWidget::~VideoWidget() { |
156 | mediaPlayerState->setPlaying( FALSE ); | 149 | |
157 | for ( int i = 0; i < 7; i++ ) { | 150 | for ( int i = 0; i < 7; i++ ) { |
158 | delete buttonPixUp[i]; | 151 | delete buttonPixUp[i]; |
159 | delete buttonPixDown[i]; | 152 | delete buttonPixDown[i]; |
160 | } | 153 | } |
161 | 154 | ||
162 | delete pixBg; | 155 | delete pixBg; |
163 | delete imgUp; | 156 | delete imgUp; |
164 | delete imgDn; | 157 | delete imgDn; |
165 | delete imgButtonMask; | 158 | delete imgButtonMask; |
166 | for ( int i = 0; i < 7; i++ ) { | 159 | for ( int i = 0; i < 7; i++ ) { |
167 | delete masks[i]; | 160 | delete masks[i]; |
168 | } | 161 | } |
169 | 162 | ||
170 | } | 163 | } |
171 | 164 | ||
172 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 165 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
173 | QPixmap pix( img.width(), img.height() ); | 166 | QPixmap pix( img.width(), img.height() ); |
174 | QPainter p( &pix ); | 167 | QPainter p( &pix ); |
175 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 168 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
176 | p.drawImage( 0, 0, img ); | 169 | p.drawImage( 0, 0, img ); |
177 | return new QPixmap( pix ); | 170 | return new QPixmap( pix ); |
178 | } | 171 | } |
179 | 172 | ||
180 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { | 173 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { |
181 | QPixmap *pixmap = new QPixmap( pix ); | 174 | QPixmap *pixmap = new QPixmap( pix ); |
182 | pixmap->setMask( mask ); | 175 | pixmap->setMask( mask ); |
183 | return pixmap; | 176 | return pixmap; |
184 | } | 177 | } |
185 | 178 | ||
186 | void VideoWidget::resizeEvent( QResizeEvent * ) { | 179 | void VideoWidget::resizeEvent( QResizeEvent * ) { |
187 | int h = height(); | 180 | int h = height(); |
188 | int w = width(); | 181 | int w = width(); |
189 | int Vh = 160; | 182 | int Vh = 160; |
190 | //videoFrame->height(); | 183 | //videoFrame->height(); |
191 | int Vw = 220; | 184 | int Vw = 220; |
192 | //videoFrame->width(); | 185 | //videoFrame->width(); |
193 | // songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); | ||
194 | 186 | ||
195 | slider->setFixedWidth( w - 110 ); | 187 | |
188 | slider->setFixedWidth( w - 20 ); | ||
196 | slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); | 189 | slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); |
197 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); | 190 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); |
198 | slider->setFocusPolicy( QWidget::NoFocus ); | 191 | slider->setFocusPolicy( QWidget::NoFocus ); |
199 | slider->setBackgroundPixmap( *pixBg ); | 192 | slider->setBackgroundPixmap( *pixBg ); |
200 | 193 | ||
201 | // time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); | ||
202 | xoff = 0;// ( imgUp->width() ) / 2; | 194 | xoff = 0;// ( imgUp->width() ) / 2; |
203 | yoff = 180;//(( Vh - imgUp->height() ) / 2) - 10; | 195 | yoff = 180;//(( Vh - imgUp->height() ) / 2) - 10; |
204 | QPoint p( xoff, yoff ); | 196 | QPoint p( xoff, yoff ); |
205 | 197 | ||
206 | 198 | ||
207 | QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); | 199 | QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); |
208 | QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); | 200 | QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); |
209 | 201 | ||
210 | for ( int i = 0; i < 7; i++ ) { | 202 | for ( int i = 0; i < 7; i++ ) { |
211 | if ( !masks[i]->isNull() ) { | 203 | if ( !masks[i]->isNull() ) { |
212 | delete buttonPixUp[i]; | 204 | delete buttonPixUp[i]; |
213 | delete buttonPixDown[i]; | 205 | delete buttonPixDown[i]; |
214 | buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); | 206 | buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); |
215 | buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); | 207 | buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); |
216 | } | 208 | } |
217 | } | 209 | } |
218 | 210 | ||
219 | delete pixUp; | 211 | delete pixUp; |
220 | delete pixDn; | 212 | delete pixDn; |
221 | } | 213 | } |
222 | 214 | ||
223 | static bool videoSliderBeingMoved = FALSE; | 215 | static bool videoSliderBeingMoved = FALSE; |
224 | 216 | ||
225 | void VideoWidget::sliderPressed() { | 217 | void VideoWidget::sliderPressed() { |
226 | videoSliderBeingMoved = TRUE; | 218 | videoSliderBeingMoved = TRUE; |
227 | } | 219 | } |
228 | 220 | ||
229 | void VideoWidget::sliderReleased() { | 221 | void VideoWidget::sliderReleased() { |
230 | videoSliderBeingMoved = FALSE; | 222 | videoSliderBeingMoved = FALSE; |
231 | if ( slider->width() == 0 ) { | 223 | if ( slider->width() == 0 ) { |
232 | return; | 224 | return; |
233 | } | 225 | } |
234 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); | 226 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); |
235 | mediaPlayerState->setPosition( val ); | 227 | mediaPlayerState->setPosition( val ); |
236 | } | 228 | } |
237 | 229 | ||
238 | void VideoWidget::setPosition( long i ) { | 230 | void VideoWidget::setPosition( long i ) { |
239 | updateSlider( i, mediaPlayerState->length() ); | 231 | updateSlider( i, mediaPlayerState->length() ); |
240 | } | 232 | } |
241 | 233 | ||
242 | 234 | ||
243 | void VideoWidget::setLength( long max ) { | 235 | void VideoWidget::setLength( long max ) { |
244 | updateSlider( mediaPlayerState->position(), max ); | 236 | updateSlider( mediaPlayerState->position(), max ); |
245 | } | 237 | } |
246 | 238 | ||
247 | void VideoWidget::setView( char view ) { | 239 | void VideoWidget::setView( char view ) { |
240 | |||
241 | if ( mediaPlayerState->streaming() ) { | ||
242 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); | ||
243 | if( !slider->isHidden()) { | ||
244 | slider->hide(); | ||
245 | } | ||
246 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | ||
247 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | ||
248 | } else { | ||
249 | // this stops the slider from being moved, thus | ||
250 | // does not stop stream when it reaches the end | ||
251 | slider->show(); | ||
252 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | ||
253 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | ||
254 | } | ||
255 | |||
248 | if ( view == 'v' ) { | 256 | if ( view == 'v' ) { |
249 | makeVisible(); | 257 | makeVisible(); |
250 | } else { | 258 | } else { |
251 | // Effectively blank the view next time we show it so it looks nicer | 259 | // Effectively blank the view next time we show it so it looks nicer |
252 | scaledWidth = 0; | 260 | scaledWidth = 0; |
253 | scaledHeight = 0; | 261 | scaledHeight = 0; |
254 | hide(); | 262 | hide(); |
255 | } | 263 | } |
256 | } | 264 | } |
257 | 265 | ||
258 | void VideoWidget::updateSlider( long i, long max ) { | 266 | void VideoWidget::updateSlider( long i, long max ) { |
259 | // Will flicker too much if we don't do this | 267 | // Will flicker too much if we don't do this |
260 | if ( max == 0 ) { | 268 | if ( max == 0 ) { |
261 | return; | 269 | return; |
262 | } | 270 | } |
263 | int width = slider->width(); | 271 | int width = slider->width(); |
264 | int val = int((double)i * width / max); | 272 | int val = int((double)i * width / max); |
265 | if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { | 273 | if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { |
266 | if ( slider->value() != val ) { | 274 | if ( slider->value() != val ) { |
267 | slider->setValue( val ); | 275 | slider->setValue( val ); |
268 | } | 276 | } |
269 | if ( slider->maxValue() != width ) { | 277 | if ( slider->maxValue() != width ) { |
270 | slider->setMaxValue( width ); | 278 | slider->setMaxValue( width ); |
271 | } | 279 | } |
272 | } | 280 | } |
273 | } | 281 | } |
274 | 282 | ||
275 | void VideoWidget::setToggleButton( int i, bool down ) { | 283 | void VideoWidget::setToggleButton( int i, bool down ) { |
276 | if ( down != videoButtons[i].isDown ) { | 284 | if ( down != videoButtons[i].isDown ) { |
277 | toggleButton( i ); | 285 | toggleButton( i ); |
278 | } | 286 | } |
279 | } | 287 | } |
280 | 288 | ||
281 | void VideoWidget::toggleButton( int i ) { | 289 | void VideoWidget::toggleButton( int i ) { |
282 | videoButtons[i].isDown = !videoButtons[i].isDown; | 290 | videoButtons[i].isDown = !videoButtons[i].isDown; |
283 | QPainter p(this); | 291 | QPainter p(this); |
284 | paintButton ( &p, i ); | 292 | paintButton ( &p, i ); |
285 | } | 293 | } |
286 | 294 | ||
287 | void VideoWidget::paintButton( QPainter *p, int i ) { | 295 | void VideoWidget::paintButton( QPainter *p, int i ) { |
288 | 296 | ||
289 | if ( videoButtons[i].isDown ) | 297 | if ( videoButtons[i].isDown ) { |
290 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | 298 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); |
291 | else | 299 | } else { |
292 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | 300 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); |
301 | } | ||
293 | } | 302 | } |
294 | 303 | ||
295 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 304 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
296 | for ( int i = 0; i < numVButtons; i++ ) { | 305 | for ( int i = 0; i < numVButtons; i++ ) { |
297 | if ( event->state() == QMouseEvent::LeftButton ) { | 306 | if ( event->state() == QMouseEvent::LeftButton ) { |
298 | // The test to see if the mouse click is inside the button or not | 307 | // The test to see if the mouse click is inside the button or not |
299 | int x = event->pos().x() - xoff; | 308 | int x = event->pos().x() - xoff; |
300 | int y = event->pos().y() - yoff; | 309 | int y = event->pos().y() - yoff; |
301 | 310 | ||
302 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() | 311 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() |
303 | && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); | 312 | && y < imgButtonMask->height() |
304 | if ( isOnButton != videoButtons[i].isHeld ) { | 313 | && imgButtonMask->pixelIndex( x, y ) == i + 1 ); |
305 | videoButtons[i].isHeld = isOnButton; | 314 | |
315 | if ( isOnButton && !videoButtons[i].isHeld ) { | ||
316 | videoButtons[i].isHeld = TRUE; | ||
306 | toggleButton(i); | 317 | toggleButton(i); |
307 | } | 318 | |
308 | |||
309 | // qDebug("mouseMove event switch1 %d", i); | ||
310 | if( isOnButton) | ||
311 | switch (i) { | 319 | switch (i) { |
312 | case VideoStop:{ | 320 | case VideoVolUp: |
313 | setToggleButton( i, FALSE ); | 321 | qDebug("more clicked"); |
314 | mediaPlayerState->setStop(TRUE); | 322 | emit moreClicked(); |
315 | mediaPlayerState->setPlaying(FALSE); | 323 | return; |
316 | return; | 324 | case VideoVolDown: |
317 | } | 325 | qDebug("less clicked"); |
318 | case VideoPlay: { | 326 | emit lessClicked(); |
319 | 327 | return; | |
320 | if( mediaPlayerState->isPaused) { | 328 | } |
321 | setToggleButton( i, FALSE ); | 329 | } else if ( !isOnButton && videoButtons[i].isHeld ) { |
322 | mediaPlayerState->setPaused( FALSE); | 330 | videoButtons[i].isHeld = FALSE; |
323 | return; | 331 | toggleButton(i); |
324 | } | 332 | } |
325 | else if( mediaPlayerState->isPlaying) { | ||
326 | setToggleButton( i, TRUE ); | ||
327 | mediaPlayerState->setPaused( TRUE); | ||
328 | return; | ||
329 | } | ||
330 | else { | ||
331 | setToggleButton( i, FALSE ); | ||
332 | mediaPlayerState->setPlaying( videoButtons[i].isDown ); | ||
333 | return; | ||
334 | } | ||
335 | } | ||
336 | case VideoNext: qDebug("next"); mediaPlayerState->setNext(); return; | ||
337 | case VideoPrevious: qDebug("previous"); mediaPlayerState->setPrev(); return; | ||
338 | case VideoVolUp: return; | ||
339 | case VideoVolDown: return; | ||
340 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | ||
341 | |||
342 | }; | ||
343 | |||
344 | } else { | 333 | } else { |
334 | |||
345 | if ( videoButtons[i].isHeld ) { | 335 | if ( videoButtons[i].isHeld ) { |
346 | videoButtons[i].isHeld = FALSE; | 336 | videoButtons[i].isHeld = FALSE; |
347 | if ( !videoButtons[i].isToggle ) { | 337 | if ( !videoButtons[i].isToggle ) { |
348 | setToggleButton( i, FALSE ); | 338 | setToggleButton( i, FALSE ); |
339 | qDebug("button toggled3 %d",i); | ||
349 | } | 340 | } |
350 | // qDebug("mouseMove event switch2 %d %d", i, VideoPlay); | 341 | |
351 | switch (i) { | 342 | switch(i) { |
352 | case VideoPlay: { | 343 | |
353 | if( mediaPlayerState->isPaused) { | 344 | case VideoPlay: { |
354 | mediaPlayerState->setPaused( FALSE); return; } | 345 | if( mediaPlayerState->isPaused ) { |
355 | else if( mediaPlayerState->isPlaying) { | 346 | qDebug("play again clicked"); |
356 | mediaPlayerState->setPaused( TRUE); return; } | 347 | setToggleButton( i, FALSE ); |
357 | else | 348 | mediaPlayerState->setPaused( FALSE ); |
358 | mediaPlayerState->setPlaying( TRUE /*videoButtons[i].isDown*/ ); return; | 349 | return; |
359 | } | 350 | } else if( !mediaPlayerState->isPaused ) { |
360 | case VideoStop: mediaPlayerState->setPlaying(FALSE); return; | 351 | qDebug("pause now clicked"); |
352 | setToggleButton( i, TRUE ); | ||
353 | mediaPlayerState->setPaused( TRUE ); | ||
354 | return; | ||
355 | } else { | ||
356 | // setToggleButton( i, TRUE ); | ||
357 | // mediaPlayerState->setPlaying( videoButtons[i].isDown ); | ||
358 | } | ||
359 | } | ||
360 | |||
361 | case VideoStop: mediaPlayerState->setPlaying( FALSE ); return; | ||
361 | // case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; | 362 | // case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; |
362 | case VideoNext: mediaPlayerState->setNext(); return; | 363 | case VideoNext: mediaPlayerState->setNext(); return; |
363 | case VideoPrevious: mediaPlayerState->setPrev(); return; | 364 | case VideoPrevious: mediaPlayerState->setPrev(); return; |
364 | case VideoVolUp: return; | 365 | case VideoVolUp: emit moreReleased(); return; |
365 | case VideoVolDown: return; | 366 | case VideoVolDown: emit lessReleased(); return; |
366 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | 367 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; |
367 | } | 368 | } |
368 | } | 369 | } |
369 | } | 370 | } |
370 | } | 371 | } |
371 | } | 372 | } |
372 | 373 | ||
373 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { | 374 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { |
374 | mouseMoveEvent( event ); | 375 | mouseMoveEvent( event ); |
375 | } | 376 | } |
376 | 377 | ||
377 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 378 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
378 | if ( mediaPlayerState->fullscreen() ) { | 379 | if ( mediaPlayerState->fullscreen() ) { |
379 | mediaPlayerState->setFullscreen( FALSE ); | 380 | mediaPlayerState->setFullscreen( FALSE ); |
380 | makeVisible(); | 381 | makeVisible(); |
381 | 382 | ||
382 | mouseMoveEvent( event ); | 383 | mouseMoveEvent( event ); |
383 | } | 384 | } |
384 | } | 385 | } |
385 | 386 | ||
387 | void VideoWidget::showEvent( QShowEvent* ) { | ||
388 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | ||
389 | mouseMoveEvent( &event ); | ||
390 | } | ||
391 | |||
386 | 392 | ||
387 | void VideoWidget::makeVisible() { | 393 | void VideoWidget::makeVisible() { |
388 | if ( mediaPlayerState->fullscreen() ) { | 394 | if ( mediaPlayerState->fullscreen() ) { |
389 | setBackgroundMode( QWidget::NoBackground ); | 395 | setBackgroundMode( QWidget::NoBackground ); |
390 | showFullScreen(); | 396 | showFullScreen(); |
391 | resize( qApp->desktop()->size() ); | 397 | resize( qApp->desktop()->size() ); |
392 | slider->hide(); | 398 | slider->hide(); |
393 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); | 399 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); |
394 | } else { | 400 | } else { |
395 | showNormal(); | 401 | showNormal(); |
396 | showMaximized(); | 402 | showMaximized(); |
397 | slider->show(); | 403 | slider->show(); |
398 | videoFrame->setGeometry( QRect( 10, 20, 220, 160 ) ); | 404 | videoFrame->setGeometry( QRect( 10, 20, 220, 160 ) ); |
399 | qApp->processEvents(); | 405 | qApp->processEvents(); |
400 | } | 406 | } |
401 | } | 407 | } |
402 | 408 | ||
403 | 409 | ||
404 | void VideoWidget::paintEvent( QPaintEvent * pe) { | 410 | void VideoWidget::paintEvent( QPaintEvent * pe) { |
405 | QPainter p( this ); | 411 | QPainter p( this ); |
406 | 412 | ||
407 | if ( mediaPlayerState->fullscreen() ) { | 413 | if ( mediaPlayerState->fullscreen() ) { |
408 | // Clear the background | 414 | // Clear the background |
409 | p.setBrush( QBrush( Qt::black ) ); | 415 | p.setBrush( QBrush( Qt::black ) ); |
410 | // videoFrame->setGeometry( QRect( 0, 0 , 240 ,320 ) ); | 416 | // videoFrame->setGeometry( QRect( 0, 0 , 240 ,320 ) ); |
411 | 417 | ||
412 | } else { | 418 | } else { |
413 | 419 | ||
414 | // videoFrame->setGeometry( QRect( 0, 15 , 240 ,170 ) ); | 420 | // videoFrame->setGeometry( QRect( 0, 15 , 240 ,170 ) ); |
415 | // draw the buttons | 421 | // draw the buttons |
416 | 422 | ||
417 | if ( !pe->erased() ) { | 423 | if ( !pe->erased() ) { |
418 | // Combine with background and double buffer | 424 | // Combine with background and double buffer |
419 | QPixmap pix( pe->rect().size() ); | 425 | QPixmap pix( pe->rect().size() ); |
420 | QPainter p( &pix ); | 426 | QPainter p( &pix ); |
421 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 427 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
422 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); | 428 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); |
423 | for ( int i = 0; i < numVButtons; i++ ) | 429 | for ( int i = 0; i < numVButtons; i++ ) { |
424 | paintButton( &p, i ); | 430 | paintButton( &p, i ); |
431 | } | ||
425 | QPainter p2( this ); | 432 | QPainter p2( this ); |
426 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 433 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
427 | } else { | 434 | } else { |
428 | QPainter p( this ); | 435 | QPainter p( this ); |
429 | for ( int i = 0; i < numVButtons; i++ ) | 436 | for ( int i = 0; i < numVButtons; i++ ) |
430 | paintButton( &p, i ); | 437 | paintButton( &p, i ); |
431 | } | 438 | } |
432 | // for ( int i = 0; i < numButtons; i++ ) { | 439 | // for ( int i = 0; i < numButtons; i++ ) { |
433 | // paintButton( &p, i ); | 440 | // paintButton( &p, i ); |
434 | // } | 441 | // } |
435 | // draw the slider | 442 | // draw the slider |
436 | slider->repaint( TRUE ); | 443 | slider->repaint( TRUE ); |
437 | } | 444 | } |
438 | } | 445 | } |
439 | 446 | ||
440 | 447 | ||
441 | void VideoWidget::closeEvent( QCloseEvent* ) { | 448 | void VideoWidget::closeEvent( QCloseEvent* ) { |
442 | mediaPlayerState->setList(); | 449 | mediaPlayerState->setList(); |
443 | } | 450 | } |
444 | 451 | ||
445 | 452 | ||
446 | bool VideoWidget::playVideo() { | ||
447 | bool result = FALSE; | ||
448 | |||
449 | int stream = 0; | ||
450 | |||
451 | int sw = 240; | ||
452 | int sh = 320; | ||
453 | int dd = QPixmap::defaultDepth(); | ||
454 | int w = height(); | ||
455 | int h = width(); | ||
456 | |||
457 | return true; | ||
458 | } | ||
459 | 453 | ||
460 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { | 454 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { |
461 | switch ( e->key() ) { | 455 | switch ( e->key() ) { |
462 | ////////////////////////////// Zaurus keys | 456 | ////////////////////////////// Zaurus keys |
463 | case Key_Home: | 457 | case Key_Home: |
464 | break; | 458 | break; |
465 | case Key_F9: //activity | 459 | case Key_F9: //activity |
466 | break; | 460 | break; |
467 | case Key_F10: //contacts | 461 | case Key_F10: //contacts |
468 | // hide(); | 462 | // hide(); |
469 | break; | 463 | break; |
470 | case Key_F11: //menu | 464 | case Key_F11: //menu |
471 | break; | 465 | break; |
472 | case Key_F12: //home | 466 | case Key_F12: //home |
473 | break; | 467 | break; |
474 | case Key_F13: //mail | 468 | case Key_F13: //mail |
475 | break; | 469 | break; |
476 | case Key_Space: { | 470 | case Key_Space: { |
477 | if(mediaPlayerState->playing()) { | 471 | if(mediaPlayerState->playing()) { |
478 | mediaPlayerState->setPlaying(FALSE); | 472 | mediaPlayerState->setPlaying(FALSE); |
479 | } else { | 473 | } else { |
480 | mediaPlayerState->setPlaying(TRUE); | 474 | mediaPlayerState->setPlaying(TRUE); |
481 | } | 475 | } |
482 | } | 476 | } |
483 | break; | 477 | break; |
484 | case Key_Down: | 478 | case Key_Down: |
485 | // toggleButton(6); | 479 | // toggleButton(6); |
486 | // emit lessClicked(); | 480 | // emit lessClicked(); |
487 | // emit lessReleased(); | 481 | // emit lessReleased(); |
488 | // toggleButton(6); | 482 | // toggleButton(6); |
489 | break; | 483 | break; |
490 | case Key_Up: | 484 | case Key_Up: |
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h index 92193a4..710ba9e 100644 --- a/noncore/multimedia/opieplayer2/videowidget.h +++ b/noncore/multimedia/opieplayer2/videowidget.h | |||
@@ -12,106 +12,112 @@ | |||
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 | #ifndef VIDEO_WIDGET_H | 34 | #ifndef VIDEO_WIDGET_H |
35 | #define VIDEO_WIDGET_H | 35 | #define VIDEO_WIDGET_H |
36 | 36 | ||
37 | #include <qwidget.h> | 37 | #include <qwidget.h> |
38 | #include "xinevideowidget.h" | 38 | #include "xinevideowidget.h" |
39 | 39 | ||
40 | class QPixmap; | 40 | class QPixmap; |
41 | class QSlider; | 41 | class QSlider; |
42 | 42 | ||
43 | enum VideoButtons { | 43 | enum VideoButtons { |
44 | VideoStop, | 44 | VideoStop = 0, |
45 | VideoPlay, | 45 | VideoPlay, |
46 | // VideoPause, | 46 | // VideoPause, |
47 | VideoPrevious, | 47 | VideoPrevious, |
48 | VideoNext, | 48 | VideoNext, |
49 | VideoVolUp, | 49 | VideoVolUp, |
50 | VideoVolDown, | 50 | VideoVolDown, |
51 | VideoFullscreen | 51 | VideoFullscreen |
52 | }; | 52 | }; |
53 | 53 | ||
54 | class VideoWidget : public QWidget { | 54 | class VideoWidget : public QWidget { |
55 | Q_OBJECT | 55 | Q_OBJECT |
56 | public: | 56 | public: |
57 | VideoWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); | 57 | VideoWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); |
58 | ~VideoWidget(); | 58 | ~VideoWidget(); |
59 | 59 | ||
60 | bool playVideo(); | 60 | |
61 | XineVideoWidget* vidWidget(); | 61 | XineVideoWidget* vidWidget(); |
62 | public slots: | 62 | public slots: |
63 | void updateSlider( long, long ); | 63 | void updateSlider( long, long ); |
64 | void sliderPressed( ); | 64 | void sliderPressed( ); |
65 | void sliderReleased( ); | 65 | void sliderReleased( ); |
66 | void setPaused( bool b); | 66 | void setPaused( bool b); |
67 | void setPlaying( bool b); | 67 | void setPlaying( bool b); |
68 | void setFullscreen( bool b ); | 68 | void setFullscreen( bool b ); |
69 | void makeVisible(); | 69 | void makeVisible(); |
70 | void setPosition( long ); | 70 | void setPosition( long ); |
71 | void setLength( long ); | 71 | void setLength( long ); |
72 | void setView( char ); | 72 | void setView( char ); |
73 | 73 | ||
74 | signals: | 74 | signals: |
75 | void moreClicked(); | ||
76 | void lessClicked(); | ||
77 | void moreReleased(); | ||
78 | void lessReleased(); | ||
75 | void sliderMoved( long ); | 79 | void sliderMoved( long ); |
76 | void videoResized ( const QSize &s ); | 80 | void videoResized ( const QSize &s ); |
77 | 81 | ||
78 | protected: | 82 | protected: |
79 | QString skin; | 83 | |
80 | void resizeEvent( QResizeEvent * ); | 84 | void resizeEvent( QResizeEvent * ); |
81 | void paintEvent( QPaintEvent *pe ); | 85 | void paintEvent( QPaintEvent *pe ); |
86 | void showEvent( QShowEvent *se ); | ||
82 | void mouseMoveEvent( QMouseEvent *event ); | 87 | void mouseMoveEvent( QMouseEvent *event ); |
83 | void mousePressEvent( QMouseEvent *event ); | 88 | void mousePressEvent( QMouseEvent *event ); |
84 | void mouseReleaseEvent( QMouseEvent *event ); | 89 | void mouseReleaseEvent( QMouseEvent *event ); |
85 | void closeEvent( QCloseEvent *event ); | 90 | void closeEvent( QCloseEvent *event ); |
86 | void keyReleaseEvent( QKeyEvent *e); | 91 | void keyReleaseEvent( QKeyEvent *e); |
87 | 92 | ||
88 | private: | 93 | private: |
89 | // Ticker songInfo; | 94 | // Ticker songInfo; |
90 | QPixmap *pixBg; | 95 | QPixmap *pixBg; |
91 | QImage *imgUp; | 96 | QImage *imgUp; |
92 | QImage *imgDn; | 97 | QImage *imgDn; |
93 | QImage *imgButtonMask; | 98 | QImage *imgButtonMask; |
94 | QBitmap *masks[7]; | 99 | QBitmap *masks[7]; |
95 | QPixmap *buttonPixUp[7]; | 100 | QPixmap *buttonPixUp[7]; |
96 | QPixmap *buttonPixDown[7]; | 101 | QPixmap *buttonPixDown[7]; |
102 | QString skin; | ||
97 | // QPixmap *pixmaps[4]; | 103 | // QPixmap *pixmaps[4]; |
98 | int xoff, yoff; | 104 | int xoff, yoff; |
99 | 105 | ||
100 | 106 | ||
101 | void paintButton( QPainter *p, int i ); | 107 | void paintButton( QPainter *p, int i ); |
102 | void toggleButton( int ); | 108 | void toggleButton( int ); |
103 | void setToggleButton( int, bool ); | 109 | void setToggleButton( int, bool ); |
104 | 110 | ||
105 | QString backgroundPix; | 111 | QString backgroundPix; |
106 | QSlider *slider; | 112 | QSlider *slider; |
107 | QPixmap *pixmaps[3]; | 113 | QPixmap *pixmaps[3]; |
108 | QImage *currentFrame; | 114 | QImage *currentFrame; |
109 | int scaledWidth; | 115 | int scaledWidth; |
110 | int scaledHeight; | 116 | int scaledHeight; |
111 | XineVideoWidget* videoFrame; | 117 | XineVideoWidget* videoFrame; |
112 | }; | 118 | }; |
113 | 119 | ||
114 | #endif // VIDEO_WIDGET_H | 120 | #endif // VIDEO_WIDGET_H |
115 | 121 | ||
116 | 122 | ||
117 | 123 | ||