-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 2a345e3..2300630 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -111,192 +111,193 @@ void VideoWidget::resizeEvent( QResizeEvent *e ) { | |||
111 | //int Vw = 220; | 111 | //int Vw = 220; |
112 | 112 | ||
113 | slider->setFixedWidth( w - 20 ); | 113 | slider->setFixedWidth( w - 20 ); |
114 | slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); | 114 | slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); |
115 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); | 115 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); |
116 | slider->setFocusPolicy( QWidget::NoFocus ); | 116 | slider->setFocusPolicy( QWidget::NoFocus ); |
117 | slider->setBackgroundPixmap( backgroundPixmap ); | 117 | slider->setBackgroundPixmap( backgroundPixmap ); |
118 | 118 | ||
119 | upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; | 119 | upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; |
120 | if(w>h) | 120 | if(w>h) |
121 | upperLeftOfButtonMask.ry() = 0; | 121 | upperLeftOfButtonMask.ry() = 0; |
122 | else | 122 | else |
123 | upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; | 123 | upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; |
124 | 124 | ||
125 | MediaWidget::resizeEvent( e ); | 125 | MediaWidget::resizeEvent( e ); |
126 | } | 126 | } |
127 | 127 | ||
128 | void VideoWidget::sliderPressed() { | 128 | void VideoWidget::sliderPressed() { |
129 | videoSliderBeingMoved = TRUE; | 129 | videoSliderBeingMoved = TRUE; |
130 | } | 130 | } |
131 | 131 | ||
132 | void VideoWidget::sliderReleased() { | 132 | void VideoWidget::sliderReleased() { |
133 | videoSliderBeingMoved = FALSE; | 133 | videoSliderBeingMoved = FALSE; |
134 | if ( slider->width() == 0 ) { | 134 | if ( slider->width() == 0 ) { |
135 | return; | 135 | return; |
136 | } | 136 | } |
137 | long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); | 137 | long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); |
138 | mediaPlayerState.setPosition( val ); | 138 | mediaPlayerState.setPosition( val ); |
139 | } | 139 | } |
140 | 140 | ||
141 | void VideoWidget::setPosition( long i ) { | 141 | void VideoWidget::setPosition( long i ) { |
142 | updateSlider( i, mediaPlayerState.length() ); | 142 | updateSlider( i, mediaPlayerState.length() ); |
143 | } | 143 | } |
144 | 144 | ||
145 | 145 | ||
146 | void VideoWidget::setLength( long max ) { | 146 | void VideoWidget::setLength( long max ) { |
147 | updateSlider( mediaPlayerState.position(), max ); | 147 | updateSlider( mediaPlayerState.position(), max ); |
148 | } | 148 | } |
149 | 149 | ||
150 | void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) | 150 | void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) |
151 | { | 151 | { |
152 | if ( displayType == MediaPlayerState::Video ) { | 152 | if ( displayType == MediaPlayerState::Video ) { |
153 | makeVisible(); | 153 | makeVisible(); |
154 | return; | 154 | return; |
155 | } | 155 | } |
156 | 156 | ||
157 | // Effectively blank the view next time we show it so it looks nicer | 157 | // Effectively blank the view next time we show it so it looks nicer |
158 | scaledWidth = 0; | 158 | scaledWidth = 0; |
159 | scaledHeight = 0; | 159 | scaledHeight = 0; |
160 | hide(); | 160 | hide(); |
161 | } | 161 | } |
162 | 162 | ||
163 | void VideoWidget::loadSkin() | 163 | void VideoWidget::loadSkin() |
164 | { | 164 | { |
165 | loadDefaultSkin( guiInfo() ); | 165 | loadDefaultSkin( guiInfo() ); |
166 | 166 | ||
167 | setBackgroundPixmap( backgroundPixmap ); | 167 | setBackgroundPixmap( backgroundPixmap ); |
168 | 168 | ||
169 | delete slider; | 169 | delete slider; |
170 | slider = new QSlider( Qt::Horizontal, this ); | 170 | slider = new QSlider( Qt::Horizontal, this ); |
171 | slider->setMinValue( 0 ); | 171 | slider->setMinValue( 0 ); |
172 | slider->setMaxValue( 1 ); | 172 | slider->setMaxValue( 1 ); |
173 | slider->setBackgroundPixmap( backgroundPixmap ); | 173 | slider->setBackgroundPixmap( backgroundPixmap ); |
174 | //slider->setFocusPolicy( QWidget::NoFocus ); | 174 | //slider->setFocusPolicy( QWidget::NoFocus ); |
175 | 175 | ||
176 | resizeEvent( 0 ); | 176 | resizeEvent( 0 ); |
177 | } | 177 | } |
178 | 178 | ||
179 | void VideoWidget::updateSlider( long i, long max ) { | 179 | void VideoWidget::updateSlider( long i, long max ) { |
180 | // Will flicker too much if we don't do this | 180 | // Will flicker too much if we don't do this |
181 | if ( max == 0 ) { | 181 | if ( max == 0 ) { |
182 | return; | 182 | return; |
183 | } | 183 | } |
184 | int width = slider->width(); | 184 | int width = slider->width(); |
185 | int val = int((double)i * width / max); | 185 | int val = int((double)i * width / max); |
186 | if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { | 186 | if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { |
187 | if ( slider->value() != val ) { | 187 | if ( slider->value() != val ) { |
188 | slider->setValue( val ); | 188 | slider->setValue( val ); |
189 | } | 189 | } |
190 | if ( slider->maxValue() != width ) { | 190 | if ( slider->maxValue() != width ) { |
191 | slider->setMaxValue( width ); | 191 | slider->setMaxValue( width ); |
192 | } | 192 | } |
193 | } | 193 | } |
194 | } | 194 | } |
195 | 195 | ||
196 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 196 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
197 | if ( mediaPlayerState.isFullscreen() ) { | 197 | if ( mediaPlayerState.isFullscreen() ) { |
198 | mediaPlayerState.setFullscreen( FALSE ); | 198 | mediaPlayerState.setFullscreen( FALSE ); |
199 | makeVisible(); | 199 | makeVisible(); |
200 | } | 200 | } |
201 | MediaWidget::mouseReleaseEvent( event ); | 201 | MediaWidget::mouseReleaseEvent( event ); |
202 | } | 202 | } |
203 | 203 | ||
204 | void VideoWidget::backToNormal() { | 204 | void VideoWidget::backToNormal() { |
205 | mediaPlayerState.setFullscreen( FALSE ); | 205 | mediaPlayerState.setFullscreen( FALSE ); |
206 | makeVisible(); | 206 | makeVisible(); |
207 | setToggleButton( FullScreen, false ); | ||
207 | } | 208 | } |
208 | 209 | ||
209 | void VideoWidget::makeVisible() { | 210 | void VideoWidget::makeVisible() { |
210 | if ( mediaPlayerState.isFullscreen() ) { | 211 | if ( mediaPlayerState.isFullscreen() ) { |
211 | setBackgroundMode( QWidget::NoBackground ); | 212 | setBackgroundMode( QWidget::NoBackground ); |
212 | showFullScreen(); | 213 | showFullScreen(); |
213 | resize( qApp->desktop()->size() ); | 214 | resize( qApp->desktop()->size() ); |
214 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); | 215 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); |
215 | 216 | ||
216 | slider->hide(); | 217 | slider->hide(); |
217 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 218 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
218 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 219 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
219 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 220 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
220 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 221 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
221 | 222 | ||
222 | } else { | 223 | } else { |
223 | showNormal(); | 224 | showNormal(); |
224 | showMaximized(); | 225 | showMaximized(); |
225 | setBackgroundPixmap( backgroundPixmap ); | 226 | setBackgroundPixmap( backgroundPixmap ); |
226 | QWidget *d = QApplication::desktop(); | 227 | QWidget *d = QApplication::desktop(); |
227 | int w = d->width(); | 228 | int w = d->width(); |
228 | int h = d->height(); | 229 | int h = d->height(); |
229 | 230 | ||
230 | if(w>h) { | 231 | if(w>h) { |
231 | int newW=(w/2)-(246/2); //this will only work with 320x240 | 232 | int newW=(w/2)-(246/2); //this will only work with 320x240 |
232 | videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); | 233 | videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); |
233 | } else { | 234 | } else { |
234 | videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); | 235 | videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); |
235 | } | 236 | } |
236 | 237 | ||
237 | if ( !mediaPlayerState.isSeekable() ) { | 238 | if ( !mediaPlayerState.isSeekable() ) { |
238 | if( !slider->isHidden()) { | 239 | if( !slider->isHidden()) { |
239 | slider->hide(); | 240 | slider->hide(); |
240 | } | 241 | } |
241 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 242 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
242 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 243 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
243 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 244 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
244 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 245 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
245 | } else { | 246 | } else { |
246 | slider->show(); | 247 | slider->show(); |
247 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 248 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
248 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 249 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
249 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 250 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
250 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 251 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
251 | } | 252 | } |
252 | } | 253 | } |
253 | } | 254 | } |
254 | 255 | ||
255 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { | 256 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { |
256 | switch ( e->key() ) { | 257 | switch ( e->key() ) { |
257 | ////////////////////////////// Zaurus keys | 258 | ////////////////////////////// Zaurus keys |
258 | case Key_Home: | 259 | case Key_Home: |
259 | break; | 260 | break; |
260 | case Key_F9: //activity | 261 | case Key_F9: //activity |
261 | break; | 262 | break; |
262 | case Key_F10: //contacts | 263 | case Key_F10: //contacts |
263 | // hide(); | 264 | // hide(); |
264 | break; | 265 | break; |
265 | case Key_F11: //menu | 266 | case Key_F11: //menu |
266 | break; | 267 | break; |
267 | case Key_F12: //home | 268 | case Key_F12: //home |
268 | break; | 269 | break; |
269 | case Key_F13: //mail | 270 | case Key_F13: //mail |
270 | break; | 271 | break; |
271 | case Key_Space: { | 272 | case Key_Space: { |
272 | if(mediaPlayerState.isPlaying()) { | 273 | if(mediaPlayerState.isPlaying()) { |
273 | mediaPlayerState.setPlaying(FALSE); | 274 | mediaPlayerState.setPlaying(FALSE); |
274 | } else { | 275 | } else { |
275 | mediaPlayerState.setPlaying(TRUE); | 276 | mediaPlayerState.setPlaying(TRUE); |
276 | } | 277 | } |
277 | } | 278 | } |
278 | break; | 279 | break; |
279 | case Key_Down: | 280 | case Key_Down: |
280 | // toggleButton(6); | 281 | // toggleButton(6); |
281 | emit lessClicked(); | 282 | emit lessClicked(); |
282 | emit lessReleased(); | 283 | emit lessReleased(); |
283 | // toggleButton(6); | 284 | // toggleButton(6); |
284 | break; | 285 | break; |
285 | case Key_Up: | 286 | case Key_Up: |
286 | // toggleButton(5); | 287 | // toggleButton(5); |
287 | emit moreClicked(); | 288 | emit moreClicked(); |
288 | emit moreReleased(); | 289 | emit moreReleased(); |
289 | // toggleButton(5); | 290 | // toggleButton(5); |
290 | break; | 291 | break; |
291 | case Key_Right: | 292 | case Key_Right: |
292 | mediaPlayerState.setNext(); | 293 | mediaPlayerState.setNext(); |
293 | break; | 294 | break; |
294 | case Key_Left: | 295 | case Key_Left: |
295 | mediaPlayerState.setPrev(); | 296 | mediaPlayerState.setPrev(); |
296 | break; | 297 | break; |
297 | case Key_Escape: | 298 | case Key_Escape: |
298 | break; | 299 | break; |
299 | 300 | ||
300 | }; | 301 | }; |
301 | } | 302 | } |
302 | 303 | ||