summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-11 18:12:49 (UTC)
committer simon <simon>2002-12-11 18:12:49 (UTC)
commitd9a6575f931b288086da701c3094b475c73d2efc (patch) (unidiff)
tree652c2d51610750cc06de2e9e2c7690e1f347c886
parentf4865ac8e114baedd13c95160631e4574da9dc84 (diff)
downloadopie-d9a6575f931b288086da701c3094b475c73d2efc.zip
opie-d9a6575f931b288086da701c3094b475c73d2efc.tar.gz
opie-d9a6575f931b288086da701c3094b475c73d2efc.tar.bz2
- set the correct status on the fullscreen toggle button when returning
from fullscreen mode
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp1
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
@@ -1,316 +1,317 @@
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/qpeapplication.h> 34#include <qpe/qpeapplication.h>
35#include <qpe/resource.h> 35#include <qpe/resource.h>
36#include <qpe/config.h> 36#include <qpe/config.h>
37 37
38 38
39#include <qwidget.h> 39#include <qwidget.h>
40#include <qpainter.h> 40#include <qpainter.h>
41#include <qpixmap.h> 41#include <qpixmap.h>
42#include <qslider.h> 42#include <qslider.h>
43#include <qdrawutil.h> 43#include <qdrawutil.h>
44#include "videowidget.h" 44#include "videowidget.h"
45#include "mediaplayerstate.h" 45#include "mediaplayerstate.h"
46#include "playlistwidget.h" 46#include "playlistwidget.h"
47 47
48 48
49#ifdef Q_WS_QWS 49#ifdef Q_WS_QWS
50# define USE_DIRECT_PAINTER 50# define USE_DIRECT_PAINTER
51# include <qdirectpainter_qws.h> 51# include <qdirectpainter_qws.h>
52# include <qgfxraster_qws.h> 52# include <qgfxraster_qws.h>
53#endif 53#endif
54 54
55 55
56namespace 56namespace
57{ 57{
58 58
59const int xo = 2; // movable x offset 59const int xo = 2; // movable x offset
60const int yo = 0; // movable y offset 60const int yo = 0; // movable y offset
61 61
62const MediaWidget::SkinButtonInfo skinInfo[] = 62const MediaWidget::SkinButtonInfo skinInfo[] =
63{ 63{
64 { MediaWidget::Play, "play", MediaWidget::ToggleButton }, 64 { MediaWidget::Play, "play", MediaWidget::ToggleButton },
65 { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, 65 { MediaWidget::Stop, "stop", MediaWidget::NormalButton },
66 { MediaWidget::Next, "fwd", MediaWidget::NormalButton }, 66 { MediaWidget::Next, "fwd", MediaWidget::NormalButton },
67 { MediaWidget::Previous, "back", MediaWidget::NormalButton }, 67 { MediaWidget::Previous, "back", MediaWidget::NormalButton },
68 { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, 68 { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton },
69 { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, 69 { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton },
70 { MediaWidget::FullScreen, "full", MediaWidget::ToggleButton } 70 { MediaWidget::FullScreen, "full", MediaWidget::ToggleButton }
71}; 71};
72 72
73const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); 73const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] );
74 74
75} 75}
76 76
77VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) 77VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name )
78 : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ), videoSliderBeingMoved( false ) 78 : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ), videoSliderBeingMoved( false )
79{ 79{
80 setCaption( tr("OpiePlayer - Video") ); 80 setCaption( tr("OpiePlayer - Video") );
81 81
82 videoFrame = new XineVideoWidget ( this, "Video frame" ); 82 videoFrame = new XineVideoWidget ( this, "Video frame" );
83 83
84 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); 84 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & )));
85 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); 85 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) );
86 86
87 slider = 0; 87 slider = 0;
88 88
89 loadSkin(); 89 loadSkin();
90 90
91 setLength( mediaPlayerState.length() ); 91 setLength( mediaPlayerState.length() );
92 setPosition( mediaPlayerState.position() ); 92 setPosition( mediaPlayerState.position() );
93 setFullscreen( mediaPlayerState.isFullscreen() ); 93 setFullscreen( mediaPlayerState.isFullscreen() );
94 setPlaying( mediaPlayerState.isPlaying() ); 94 setPlaying( mediaPlayerState.isPlaying() );
95} 95}
96 96
97 97
98VideoWidget::~VideoWidget() 98VideoWidget::~VideoWidget()
99{ 99{
100} 100}
101 101
102MediaWidget::GUIInfo VideoWidget::guiInfo() 102MediaWidget::GUIInfo VideoWidget::guiInfo()
103{ 103{
104 return GUIInfo( "V" /* infix */, ::skinInfo, ::buttonCount ); 104 return GUIInfo( "V" /* infix */, ::skinInfo, ::buttonCount );
105} 105}
106 106
107void VideoWidget::resizeEvent( QResizeEvent *e ) { 107void VideoWidget::resizeEvent( QResizeEvent *e ) {
108 int h = height(); 108 int h = height();
109 int w = width(); 109 int w = width();
110 //int Vh = 160; 110 //int Vh = 160;
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
128void VideoWidget::sliderPressed() { 128void VideoWidget::sliderPressed() {
129 videoSliderBeingMoved = TRUE; 129 videoSliderBeingMoved = TRUE;
130} 130}
131 131
132void VideoWidget::sliderReleased() { 132void 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
141void VideoWidget::setPosition( long i ) { 141void VideoWidget::setPosition( long i ) {
142 updateSlider( i, mediaPlayerState.length() ); 142 updateSlider( i, mediaPlayerState.length() );
143} 143}
144 144
145 145
146void VideoWidget::setLength( long max ) { 146void VideoWidget::setLength( long max ) {
147 updateSlider( mediaPlayerState.position(), max ); 147 updateSlider( mediaPlayerState.position(), max );
148} 148}
149 149
150void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) 150void 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
163void VideoWidget::loadSkin() 163void 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
179void VideoWidget::updateSlider( long i, long max ) { 179void 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
196void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 196void 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
204void VideoWidget::backToNormal() { 204void VideoWidget::backToNormal() {
205 mediaPlayerState.setFullscreen( FALSE ); 205 mediaPlayerState.setFullscreen( FALSE );
206 makeVisible(); 206 makeVisible();
207 setToggleButton( FullScreen, false );
207} 208}
208 209
209void VideoWidget::makeVisible() { 210void 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
255void VideoWidget::keyReleaseEvent( QKeyEvent *e) { 256void 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
303XineVideoWidget* VideoWidget::vidWidget() { 304XineVideoWidget* VideoWidget::vidWidget() {
304 return videoFrame; 305 return videoFrame;
305} 306}
306 307
307 308
308void VideoWidget::setFullscreen ( bool b ) { 309void VideoWidget::setFullscreen ( bool b ) {
309 setToggleButton( FullScreen, b ); 310 setToggleButton( FullScreen, b );
310} 311}
311 312
312 313
313void VideoWidget::setPlaying( bool b) { 314void VideoWidget::setPlaying( bool b) {
314 setToggleButton( Play, b ); 315 setToggleButton( Play, b );
315} 316}
316 317