author | llornkcor <llornkcor> | 2003-04-20 04:15:39 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-04-20 04:15:39 (UTC) |
commit | 138fbbf45ce46228f2bec63099e0bc3a4e0537e2 (patch) (unidiff) | |
tree | 424f7bffb331270f5888f3659d02f447fbae0794 | |
parent | 0bc47585aef17477ca5564dde4da4a41cf57a1c0 (diff) | |
download | opie-138fbbf45ce46228f2bec63099e0bc3a4e0537e2.zip opie-138fbbf45ce46228f2bec63099e0bc3a4e0537e2.tar.gz opie-138fbbf45ce46228f2bec63099e0bc3a4e0537e2.tar.bz2 |
remove commentout code
-rw-r--r-- | core/multimedia/opieplayer/videowidget.cpp | 107 |
1 files changed, 0 insertions, 107 deletions
diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp index 6ed0108..48104ca 100644 --- a/core/multimedia/opieplayer/videowidget.cpp +++ b/core/multimedia/opieplayer/videowidget.cpp | |||
@@ -1,778 +1,671 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qpe/resource.h> | 20 | #include <qpe/resource.h> |
21 | #include <qpe/mediaplayerplugininterface.h> | 21 | #include <qpe/mediaplayerplugininterface.h> |
22 | #include <qpe/config.h> | 22 | #include <qpe/config.h> |
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | 24 | ||
25 | #include <qdir.h> | 25 | #include <qdir.h> |
26 | #include <qwidget.h> | 26 | #include <qwidget.h> |
27 | #include <qpainter.h> | 27 | #include <qpainter.h> |
28 | #include <qpixmap.h> | 28 | #include <qpixmap.h> |
29 | #include <qslider.h> | 29 | #include <qslider.h> |
30 | #include <qdrawutil.h> | 30 | #include <qdrawutil.h> |
31 | #include "videowidget.h" | 31 | #include "videowidget.h" |
32 | #include "mediaplayerstate.h" | 32 | #include "mediaplayerstate.h" |
33 | 33 | ||
34 | 34 | ||
35 | #ifdef Q_WS_QWS | 35 | #ifdef Q_WS_QWS |
36 | # define USE_DIRECT_PAINTER | 36 | # define USE_DIRECT_PAINTER |
37 | # include <qdirectpainter_qws.h> | 37 | # include <qdirectpainter_qws.h> |
38 | # include <qgfxraster_qws.h> | 38 | # include <qgfxraster_qws.h> |
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | 41 | ||
42 | extern MediaPlayerState *mediaPlayerState; | 42 | extern MediaPlayerState *mediaPlayerState; |
43 | 43 | ||
44 | 44 | ||
45 | static const int xo = 2; // movable x offset | 45 | static const int xo = 2; // movable x offset |
46 | static const int yo = 0; // movable y offset | 46 | static const int yo = 0; // movable y offset |
47 | 47 | ||
48 | 48 | ||
49 | struct MediaButton { | 49 | struct MediaButton { |
50 | // int xPos, yPos; | 50 | // int xPos, yPos; |
51 | bool isToggle, isHeld, isDown; | 51 | bool isToggle, isHeld, isDown; |
52 | // int controlType; | 52 | // int controlType; |
53 | }; | 53 | }; |
54 | 54 | ||
55 | 55 | ||
56 | // Layout information for the videoButtons (and if it is a toggle button or not) | 56 | // Layout information for the videoButtons (and if it is a toggle button or not) |
57 | MediaButton videoButtons[] = { | 57 | MediaButton videoButtons[] = { |
58 | { FALSE, FALSE, FALSE }, // stop | 58 | { FALSE, FALSE, FALSE }, // stop |
59 | { FALSE, FALSE, FALSE }, // play | 59 | { FALSE, FALSE, FALSE }, // play |
60 | { FALSE, FALSE, FALSE }, // previous | 60 | { FALSE, FALSE, FALSE }, // previous |
61 | { FALSE, FALSE, FALSE }, // next | 61 | { FALSE, FALSE, FALSE }, // next |
62 | { FALSE, FALSE, FALSE }, // volUp | 62 | { FALSE, FALSE, FALSE }, // volUp |
63 | { FALSE, FALSE, FALSE }, // volDown | 63 | { FALSE, FALSE, FALSE }, // volDown |
64 | { TRUE, FALSE, FALSE } // fullscreen | 64 | { TRUE, FALSE, FALSE } // fullscreen |
65 | }; | 65 | }; |
66 | 66 | ||
67 | //static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); | 67 | //static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); |
68 | 68 | ||
69 | const char *skinV_mask_file_names[7] = { | 69 | const char *skinV_mask_file_names[7] = { |
70 | "stop","play","back","fwd","up","down","full" | 70 | "stop","play","back","fwd","up","down","full" |
71 | }; | 71 | }; |
72 | 72 | ||
73 | static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); | 73 | static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); |
74 | 74 | ||
75 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : | 75 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : |
76 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) | 76 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) |
77 | { | 77 | { |
78 | setCaption( tr("OpiePlayer") ); | 78 | setCaption( tr("OpiePlayer") ); |
79 | Config cfg("OpiePlayer"); | 79 | Config cfg("OpiePlayer"); |
80 | 80 | ||
81 | cfg.setGroup("Options"); | 81 | cfg.setGroup("Options"); |
82 | skin = cfg.readEntry("Skin","default"); | 82 | skin = cfg.readEntry("Skin","default"); |
83 | 83 | ||
84 | QString skinPath; | 84 | QString skinPath; |
85 | skinPath = "opieplayer2/skins/" + skin; | 85 | skinPath = "opieplayer2/skins/" + skin; |
86 | if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists()) | 86 | if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists()) |
87 | skinPath = "opieplayer2/skins/default"; | 87 | skinPath = "opieplayer2/skins/default"; |
88 | 88 | ||
89 | qDebug("skin path " + skinPath); | 89 | qDebug("skin path " + skinPath); |
90 | 90 | ||
91 | // QString skinPath = "opieplayer2/skins/" + skin; | 91 | // QString skinPath = "opieplayer2/skins/" + skin; |
92 | 92 | ||
93 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 93 | pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
94 | imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); | 94 | imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); |
95 | imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); | 95 | imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); |
96 | 96 | ||
97 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); | 97 | imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); |
98 | imgButtonMask->fill( 0 ); | 98 | imgButtonMask->fill( 0 ); |
99 | 99 | ||
100 | for ( int i = 0; i < 7; i++ ) | 100 | for ( int i = 0; i < 7; i++ ) |
101 | { | 101 | { |
102 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + | 102 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + |
103 | "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); | 103 | "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); |
104 | qDebug("loading "+filename); | 104 | qDebug("loading "+filename); |
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 | { | 108 | { |
109 | QImage imgMask = masks[i]->convertToImage(); | 109 | QImage imgMask = masks[i]->convertToImage(); |
110 | uchar **dest = imgButtonMask->jumpTable(); | 110 | uchar **dest = imgButtonMask->jumpTable(); |
111 | for ( int y = 0; y < imgUp->height(); y++ ) | 111 | for ( int y = 0; y < imgUp->height(); y++ ) |
112 | { | 112 | { |
113 | uchar *line = dest[y]; | 113 | uchar *line = dest[y]; |
114 | for ( int x = 0; x < imgUp->width(); x++ ) | 114 | for ( int x = 0; x < imgUp->width(); x++ ) |
115 | { | 115 | { |
116 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 116 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
117 | line[x] = i + 1; | 117 | line[x] = i + 1; |
118 | } | 118 | } |
119 | } | 119 | } |
120 | } | 120 | } |
121 | } | 121 | } |
122 | qDebug("finished loading first pics"); | 122 | qDebug("finished loading first pics"); |
123 | for ( int i = 0; i < 7; i++ ) | 123 | for ( int i = 0; i < 7; i++ ) |
124 | { | 124 | { |
125 | buttonPixUp[i] = NULL; | 125 | buttonPixUp[i] = NULL; |
126 | buttonPixDown[i] = NULL; | 126 | buttonPixDown[i] = NULL; |
127 | } | 127 | } |
128 | 128 | ||
129 | setBackgroundPixmap( *pixBg ); | 129 | setBackgroundPixmap( *pixBg ); |
130 | 130 | ||
131 | currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); | 131 | currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); |
132 | 132 | ||
133 | slider = new QSlider( Qt::Horizontal, this ); | 133 | slider = new QSlider( Qt::Horizontal, this ); |
134 | slider->setMinValue( 0 ); | 134 | slider->setMinValue( 0 ); |
135 | slider->setMaxValue( 1 ); | 135 | slider->setMaxValue( 1 ); |
136 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); | 136 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); |
137 | slider->setFocusPolicy( QWidget::NoFocus ); | 137 | slider->setFocusPolicy( QWidget::NoFocus ); |
138 | // slider->setGeometry( QRect( 7, 250, 220, 20 ) ); | 138 | // slider->setGeometry( QRect( 7, 250, 220, 20 ) ); |
139 | 139 | ||
140 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 140 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
141 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 141 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
142 | 142 | ||
143 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 143 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
144 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 144 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
145 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 145 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
146 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 146 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
147 | // connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 147 | // connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
148 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 148 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
149 | 149 | ||
150 | // Intialise state | 150 | // Intialise state |
151 | setLength( mediaPlayerState->length() ); | 151 | setLength( mediaPlayerState->length() ); |
152 | setPosition( mediaPlayerState->position() ); | 152 | setPosition( mediaPlayerState->position() ); |
153 | setFullscreen( mediaPlayerState->fullscreen() ); | 153 | setFullscreen( mediaPlayerState->fullscreen() ); |
154 | // setPaused( mediaPlayerState->paused() ); | 154 | // setPaused( mediaPlayerState->paused() ); |
155 | setPlaying( mediaPlayerState->playing() ); | 155 | setPlaying( mediaPlayerState->playing() ); |
156 | } | 156 | } |
157 | 157 | ||
158 | 158 | ||
159 | VideoWidget::~VideoWidget() { | 159 | VideoWidget::~VideoWidget() { |
160 | 160 | ||
161 | for ( int i = 0; i < 7; i++ ) | 161 | for ( int i = 0; i < 7; i++ ) |
162 | { | 162 | { |
163 | delete buttonPixUp[i]; | 163 | delete buttonPixUp[i]; |
164 | delete buttonPixDown[i]; | 164 | delete buttonPixDown[i]; |
165 | } | 165 | } |
166 | 166 | ||
167 | delete pixBg; | 167 | delete pixBg; |
168 | delete imgUp; | 168 | delete imgUp; |
169 | delete imgDn; | 169 | delete imgDn; |
170 | delete imgButtonMask; | 170 | delete imgButtonMask; |
171 | for ( int i = 0; i < 7; i++ ) | 171 | for ( int i = 0; i < 7; i++ ) |
172 | { | 172 | { |
173 | delete masks[i]; | 173 | delete masks[i]; |
174 | } | 174 | } |
175 | 175 | ||
176 | // for ( int i = 0; i < 3; i++ ) | 176 | // for ( int i = 0; i < 3; i++ ) |
177 | // delete pixmaps[i]; | 177 | // delete pixmaps[i]; |
178 | // delete currentFrame; | 178 | // delete currentFrame; |
179 | } | 179 | } |
180 | 180 | ||
181 | 181 | ||
182 | static bool videoSliderBeingMoved = FALSE; | 182 | static bool videoSliderBeingMoved = FALSE; |
183 | 183 | ||
184 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 184 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
185 | QPixmap pix( img.width(), img.height() ); | 185 | QPixmap pix( img.width(), img.height() ); |
186 | QPainter p( &pix ); | 186 | QPainter p( &pix ); |
187 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 187 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
188 | p.drawImage( 0, 0, img ); | 188 | p.drawImage( 0, 0, img ); |
189 | return new QPixmap( pix ); | 189 | return new QPixmap( pix ); |
190 | } | 190 | } |
191 | 191 | ||
192 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { | 192 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { |
193 | QPixmap *pixmap = new QPixmap( pix ); | 193 | QPixmap *pixmap = new QPixmap( pix ); |
194 | pixmap->setMask( mask ); | 194 | pixmap->setMask( mask ); |
195 | return pixmap; | 195 | return pixmap; |
196 | } | 196 | } |
197 | 197 | ||
198 | void VideoWidget::resizeEvent( QResizeEvent * ) { | 198 | void VideoWidget::resizeEvent( QResizeEvent * ) { |
199 | int h = height(); | 199 | int h = height(); |
200 | int w = width(); | 200 | int w = width(); |
201 | //int Vh = 160; | 201 | //int Vh = 160; |
202 | //int Vw = 220; | 202 | //int Vw = 220; |
203 | 203 | ||
204 | slider->setFixedWidth( w - 20 ); | 204 | slider->setFixedWidth( w - 20 ); |
205 | slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); | 205 | slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); |
206 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); | 206 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); |
207 | slider->setFocusPolicy( QWidget::NoFocus ); | 207 | slider->setFocusPolicy( QWidget::NoFocus ); |
208 | slider->setBackgroundPixmap( *pixBg ); | 208 | slider->setBackgroundPixmap( *pixBg ); |
209 | 209 | ||
210 | xoff = 0;// ( imgUp->width() ) / 2; | 210 | xoff = 0;// ( imgUp->width() ) / 2; |
211 | if(w>h) | 211 | if(w>h) |
212 | yoff = 0; | 212 | yoff = 0; |
213 | else | 213 | else |
214 | yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; | 214 | yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; |
215 | QPoint p( xoff, yoff ); | 215 | QPoint p( xoff, yoff ); |
216 | 216 | ||
217 | QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); | 217 | QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); |
218 | QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); | 218 | QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); |
219 | 219 | ||
220 | for ( int i = 0; i < 7; i++ ) | 220 | for ( int i = 0; i < 7; i++ ) |
221 | { | 221 | { |
222 | if ( !masks[i]->isNull() ) | 222 | if ( !masks[i]->isNull() ) |
223 | { | 223 | { |
224 | delete buttonPixUp[i]; | 224 | delete buttonPixUp[i]; |
225 | delete buttonPixDown[i]; | 225 | delete buttonPixDown[i]; |
226 | buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); | 226 | buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); |
227 | buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); | 227 | buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); |
228 | } | 228 | } |
229 | } | 229 | } |
230 | 230 | ||
231 | delete pixUp; | 231 | delete pixUp; |
232 | delete pixDn; | 232 | delete pixDn; |
233 | } | 233 | } |
234 | 234 | ||
235 | 235 | ||
236 | void VideoWidget::sliderPressed() { | 236 | void VideoWidget::sliderPressed() { |
237 | videoSliderBeingMoved = TRUE; | 237 | videoSliderBeingMoved = TRUE; |
238 | } | 238 | } |
239 | 239 | ||
240 | 240 | ||
241 | void VideoWidget::sliderReleased() { | 241 | void VideoWidget::sliderReleased() { |
242 | videoSliderBeingMoved = FALSE; | 242 | videoSliderBeingMoved = FALSE; |
243 | if ( slider->width() == 0 ) | 243 | if ( slider->width() == 0 ) |
244 | return; | 244 | return; |
245 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); | 245 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); |
246 | mediaPlayerState->setPosition( val ); | 246 | mediaPlayerState->setPosition( val ); |
247 | } | 247 | } |
248 | 248 | ||
249 | 249 | ||
250 | void VideoWidget::setPosition( long i ) { | 250 | void VideoWidget::setPosition( long i ) { |
251 | updateSlider( i, mediaPlayerState->length() ); | 251 | updateSlider( i, mediaPlayerState->length() ); |
252 | } | 252 | } |
253 | 253 | ||
254 | 254 | ||
255 | void VideoWidget::setLength( long max ) { | 255 | void VideoWidget::setLength( long max ) { |
256 | updateSlider( mediaPlayerState->position(), max ); | 256 | updateSlider( mediaPlayerState->position(), max ); |
257 | } | 257 | } |
258 | 258 | ||
259 | 259 | ||
260 | void VideoWidget::setView( char view ) { | 260 | void VideoWidget::setView( char view ) { |
261 | if ( view == 'v' ) | 261 | if ( view == 'v' ) |
262 | { | 262 | { |
263 | makeVisible(); | 263 | makeVisible(); |
264 | } | 264 | } |
265 | else | 265 | else |
266 | { | 266 | { |
267 | // Effectively blank the view next time we show it so it looks nicer | 267 | // Effectively blank the view next time we show it so it looks nicer |
268 | scaledWidth = 0; | 268 | scaledWidth = 0; |
269 | scaledHeight = 0; | 269 | scaledHeight = 0; |
270 | hide(); | 270 | hide(); |
271 | } | 271 | } |
272 | } | 272 | } |
273 | 273 | ||
274 | 274 | ||
275 | void VideoWidget::updateSlider( long i, long max ) { | 275 | void VideoWidget::updateSlider( long i, long max ) { |
276 | // Will flicker too much if we don't do this | 276 | // Will flicker too much if we don't do this |
277 | if ( max == 0 ) | 277 | if ( max == 0 ) |
278 | return; | 278 | return; |
279 | int width = slider->width(); | 279 | int width = slider->width(); |
280 | int val = int((double)i * width / max); | 280 | int val = int((double)i * width / max); |
281 | if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) | 281 | if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) |
282 | { | 282 | { |
283 | if ( slider->value() != val ) | 283 | if ( slider->value() != val ) |
284 | slider->setValue( val ); | 284 | slider->setValue( val ); |
285 | if ( slider->maxValue() != width ) | 285 | if ( slider->maxValue() != width ) |
286 | slider->setMaxValue( width ); | 286 | slider->setMaxValue( width ); |
287 | } | 287 | } |
288 | } | 288 | } |
289 | 289 | ||
290 | 290 | ||
291 | void VideoWidget::setToggleButton( int i, bool down ) { | 291 | void VideoWidget::setToggleButton( int i, bool down ) { |
292 | if ( down != videoButtons[i].isDown ) | 292 | if ( down != videoButtons[i].isDown ) |
293 | toggleButton( i ); | 293 | toggleButton( i ); |
294 | } | 294 | } |
295 | 295 | ||
296 | 296 | ||
297 | void VideoWidget::toggleButton( int i ) { | 297 | void VideoWidget::toggleButton( int i ) { |
298 | videoButtons[i].isDown = !videoButtons[i].isDown; | 298 | videoButtons[i].isDown = !videoButtons[i].isDown; |
299 | QPainter p(this); | 299 | QPainter p(this); |
300 | paintButton ( &p, i ); | 300 | paintButton ( &p, i ); |
301 | } | 301 | } |
302 | 302 | ||
303 | 303 | ||
304 | void VideoWidget::paintButton( QPainter *p, int i ) { | 304 | void VideoWidget::paintButton( QPainter *p, int i ) { |
305 | if ( videoButtons[i].isDown ) | 305 | if ( videoButtons[i].isDown ) |
306 | { | 306 | { |
307 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | 307 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); |
308 | } | 308 | } |
309 | else | 309 | else |
310 | { | 310 | { |
311 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | 311 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); |
312 | } | 312 | } |
313 | // int x = videoButtons[i].xPos; | ||
314 | // int y = videoButtons[i].yPos; | ||
315 | // int offset = 10 + videoButtons[i].isDown; | ||
316 | // p->drawPixmap( x, y, *pixmaps[videoButtons[i].isDown] ); | ||
317 | // p->drawPixmap( x + 1 + offset, y + offset, *pixmaps[2], 9 * videoButtons[i].controlType, 0, 9, 9 ); | ||
318 | } | 313 | } |
319 | 314 | ||
320 | 315 | ||
321 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 316 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
322 | for ( int i = 0; i < numVButtons; i++ ) { | 317 | for ( int i = 0; i < numVButtons; i++ ) { |
323 | if ( event->state() == QMouseEvent::LeftButton ) { | 318 | if ( event->state() == QMouseEvent::LeftButton ) { |
324 | // The test to see if the mouse click is inside the button or not | 319 | // The test to see if the mouse click is inside the button or not |
325 | int x = event->pos().x() - xoff; | 320 | int x = event->pos().x() - xoff; |
326 | int y = event->pos().y() - yoff; | 321 | int y = event->pos().y() - yoff; |
327 | 322 | ||
328 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() | 323 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() |
329 | && y < imgButtonMask->height() | 324 | && y < imgButtonMask->height() |
330 | && imgButtonMask->pixelIndex( x, y ) == i + 1 ); | 325 | && imgButtonMask->pixelIndex( x, y ) == i + 1 ); |
331 | 326 | ||
332 | if ( isOnButton && !videoButtons[i].isHeld ) { | 327 | if ( isOnButton && !videoButtons[i].isHeld ) { |
333 | videoButtons[i].isHeld = TRUE; | 328 | videoButtons[i].isHeld = TRUE; |
334 | toggleButton(i); | 329 | toggleButton(i); |
335 | 330 | ||
336 | switch (i) { | 331 | switch (i) { |
337 | case VideoVolUp: | 332 | case VideoVolUp: |
338 | emit moreClicked(); | 333 | emit moreClicked(); |
339 | return; | 334 | return; |
340 | case VideoVolDown: | 335 | case VideoVolDown: |
341 | emit lessClicked(); | 336 | emit lessClicked(); |
342 | return; | 337 | return; |
343 | } | 338 | } |
344 | } else if ( !isOnButton && videoButtons[i].isHeld ) { | 339 | } else if ( !isOnButton && videoButtons[i].isHeld ) { |
345 | videoButtons[i].isHeld = FALSE; | 340 | videoButtons[i].isHeld = FALSE; |
346 | toggleButton(i); | 341 | toggleButton(i); |
347 | } | 342 | } |
348 | } else { | 343 | } else { |
349 | 344 | ||
350 | if ( videoButtons[i].isHeld ) { | 345 | if ( videoButtons[i].isHeld ) { |
351 | videoButtons[i].isHeld = FALSE; | 346 | videoButtons[i].isHeld = FALSE; |
352 | if ( !videoButtons[i].isToggle ) { | 347 | if ( !videoButtons[i].isToggle ) { |
353 | setToggleButton( i, FALSE ); | 348 | setToggleButton( i, FALSE ); |
354 | } | 349 | } |
355 | 350 | ||
356 | switch(i) { | 351 | switch(i) { |
357 | 352 | ||
358 | case VideoPlay: { | 353 | case VideoPlay: { |
359 | qDebug("play"); | 354 | qDebug("play"); |
360 | if( !mediaPlayerState->playing()) { | 355 | if( !mediaPlayerState->playing()) { |
361 | mediaPlayerState->setPlaying( true); | 356 | mediaPlayerState->setPlaying( true); |
362 | setToggleButton( i-1, false ); | 357 | setToggleButton( i-1, false ); |
363 | setToggleButton( i, false ); | 358 | setToggleButton( i, false ); |
364 | return; | 359 | return; |
365 | } | 360 | } |
366 | if( mediaPlayerState->isPaused ) { | 361 | if( mediaPlayerState->isPaused ) { |
367 | qDebug("isPaused"); | 362 | qDebug("isPaused"); |
368 | setToggleButton( i, FALSE ); | 363 | setToggleButton( i, FALSE ); |
369 | mediaPlayerState->setPaused( FALSE ); | 364 | mediaPlayerState->setPaused( FALSE ); |
370 | return; | 365 | return; |
371 | } else if( !mediaPlayerState->isPaused ) { | 366 | } else if( !mediaPlayerState->isPaused ) { |
372 | qDebug("is not paused"); | 367 | qDebug("is not paused"); |
373 | setToggleButton( i, TRUE ); | 368 | setToggleButton( i, TRUE ); |
374 | mediaPlayerState->setPaused( TRUE ); | 369 | mediaPlayerState->setPaused( TRUE ); |
375 | return; | 370 | return; |
376 | } else { | 371 | } else { |
377 | return; | 372 | return; |
378 | } | 373 | } |
379 | } | 374 | } |
380 | 375 | ||
381 | case VideoStop: qDebug("stop"); mediaPlayerState->setPlaying( FALSE ); setToggleButton( i+1, true); setToggleButton( i, true ); return; | 376 | case VideoStop: qDebug("stop"); mediaPlayerState->setPlaying( FALSE ); setToggleButton( i+1, true); setToggleButton( i, true ); return; |
382 | case VideoNext: mediaPlayerState->setNext(); return; | 377 | case VideoNext: mediaPlayerState->setNext(); return; |
383 | case VideoPrevious: mediaPlayerState->setPrev(); return; | 378 | case VideoPrevious: mediaPlayerState->setPrev(); return; |
384 | case VideoVolUp: emit moreReleased(); return; | 379 | case VideoVolUp: emit moreReleased(); return; |
385 | case VideoVolDown: emit lessReleased(); return; | 380 | case VideoVolDown: emit lessReleased(); return; |
386 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | 381 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; |
387 | } | 382 | } |
388 | } | 383 | } |
389 | } | 384 | } |
390 | } | 385 | } |
391 | |||
392 | // for ( int i = 0; i < numVButtons; i++ ) | ||
393 | // { | ||
394 | // if ( event->state() == QMouseEvent::LeftButton ) | ||
395 | // { | ||
396 | // // The test to see if the mouse click is inside the button or not | ||
397 | // int x = event->pos().x() - xoff; | ||
398 | // int y = event->pos().y() - yoff; | ||
399 | |||
400 | // bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() | ||
401 | // && y < imgButtonMask->height() | ||
402 | // && imgButtonMask->pixelIndex( x, y ) == i + 1 ); | ||
403 | |||
404 | // if ( isOnButton && !videoButtons[i].isHeld ) | ||
405 | // { | ||
406 | // qDebug("key %d", i); | ||
407 | |||
408 | // videoButtons[i].isHeld = TRUE; | ||
409 | // toggleButton(i); | ||
410 | // switch (i) { | ||
411 | // case VideoVolUp: | ||
412 | // emit moreClicked(); | ||
413 | // return; | ||
414 | // case VideoVolDown: | ||
415 | // emit lessClicked(); | ||
416 | // return; | ||
417 | // } | ||
418 | // } else if ( !isOnButton && videoButtons[i].isHeld ) { | ||
419 | // videoButtons[i].isHeld = FALSE; | ||
420 | // toggleButton(i); | ||
421 | // } | ||
422 | |||
423 | |||
424 | // } else { | ||
425 | |||
426 | // if ( videoButtons[i].isHeld ) | ||
427 | // { | ||
428 | // videoButtons[i].isHeld = FALSE; | ||
429 | // if ( !videoButtons[i].isToggle ) { | ||
430 | // setToggleButton( i, FALSE ); | ||
431 | // } | ||
432 | // qDebug("key %d", i); | ||
433 | // switch(i) { | ||
434 | // case VideoPlay: | ||
435 | // { | ||
436 | // if( mediaPlayerState->isPaused ) { | ||
437 | // setToggleButton( i, FALSE ); | ||
438 | // mediaPlayerState->setPaused( FALSE ); | ||
439 | // return; | ||
440 | // } | ||
441 | // else if( !mediaPlayerState->isPaused ) { | ||
442 | // setToggleButton( i, TRUE ); | ||
443 | // mediaPlayerState->setPaused( TRUE ); | ||
444 | // return; | ||
445 | // } else { | ||
446 | // return; | ||
447 | // } | ||
448 | // } | ||
449 | |||
450 | // case VideoStop: mediaPlayerState->setPlaying(FALSE); return; | ||
451 | // // case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; | ||
452 | // // case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; | ||
453 | // case VideoNext: mediaPlayerState->setNext(); return; | ||
454 | // case VideoPrevious: mediaPlayerState->setPrev(); return; | ||
455 | // case VideoVolUp: emit moreReleased(); return; | ||
456 | // case VideoVolDown: emit lessReleased(); return; | ||
457 | // // case VideoPlayList: mediaPlayerState->setList(); return; | ||
458 | // case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | ||
459 | // } | ||
460 | // } | ||
461 | // } | ||
462 | // } | ||
463 | |||
464 | |||
465 | |||
466 | |||
467 | |||
468 | // for ( int i = 0; i < numButtons; i++ ) { | ||
469 | // int x = videoButtons[i].xPos; | ||
470 | // int y = videoButtons[i].yPos; | ||
471 | // if ( event->state() == QMouseEvent::LeftButton ) { | ||
472 | // // The test to see if the mouse click is inside the circular button or not | ||
473 | // // (compared with the radius squared to avoid a square-root of our distance) | ||
474 | // int radius = 16; | ||
475 | // QPoint center = QPoint( x + radius, y + radius ); | ||
476 | // QPoint dXY = center - event->pos(); | ||
477 | // int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); | ||
478 | // bool isOnButton = dist <= (radius * radius); | ||
479 | // if ( isOnButton != videoButtons[i].isHeld ) { | ||
480 | // videoButtons[i].isHeld = isOnButton; | ||
481 | // toggleButton(i); | ||
482 | // } | ||
483 | // } else { | ||
484 | // if ( videoButtons[i].isHeld ) { | ||
485 | // videoButtons[i].isHeld = FALSE; | ||
486 | // if ( !videoButtons[i].isToggle ) | ||
487 | // setToggleButton( i, FALSE ); | ||
488 | // } | ||
489 | // } | ||
490 | |||
491 | |||
492 | // } | ||
493 | } | 386 | } |
494 | 387 | ||
495 | 388 | ||
496 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { | 389 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { |
497 | mouseMoveEvent( event ); | 390 | mouseMoveEvent( event ); |
498 | } | 391 | } |
499 | 392 | ||
500 | 393 | ||
501 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 394 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
502 | if ( mediaPlayerState->fullscreen() ) | 395 | if ( mediaPlayerState->fullscreen() ) |
503 | { | 396 | { |
504 | mediaPlayerState->setFullscreen( FALSE ); | 397 | mediaPlayerState->setFullscreen( FALSE ); |
505 | makeVisible(); | 398 | makeVisible(); |
506 | } | 399 | } |
507 | mouseMoveEvent( event ); | 400 | mouseMoveEvent( event ); |
508 | // } | 401 | // } |
509 | } | 402 | } |
510 | 403 | ||
511 | 404 | ||
512 | void VideoWidget::makeVisible() { | 405 | void VideoWidget::makeVisible() { |
513 | if ( mediaPlayerState->fullscreen() ) | 406 | if ( mediaPlayerState->fullscreen() ) |
514 | { | 407 | { |
515 | setBackgroundMode( QWidget::NoBackground ); | 408 | setBackgroundMode( QWidget::NoBackground ); |
516 | showFullScreen(); | 409 | showFullScreen(); |
517 | resize( qApp->desktop()->size() ); | 410 | resize( qApp->desktop()->size() ); |
518 | slider->hide(); | 411 | slider->hide(); |
519 | } | 412 | } |
520 | else | 413 | else |
521 | { | 414 | { |
522 | setBackgroundPixmap( *pixBg ); | 415 | setBackgroundPixmap( *pixBg ); |
523 | showNormal(); | 416 | showNormal(); |
524 | showMaximized(); | 417 | showMaximized(); |
525 | slider->show(); | 418 | slider->show(); |
526 | } | 419 | } |
527 | } | 420 | } |
528 | 421 | ||
529 | 422 | ||
530 | void VideoWidget::paintEvent( QPaintEvent * pe) { | 423 | void VideoWidget::paintEvent( QPaintEvent * pe) { |
531 | QPainter p( this ); | 424 | QPainter p( this ); |
532 | 425 | ||
533 | if ( mediaPlayerState->fullscreen() ) { | 426 | if ( mediaPlayerState->fullscreen() ) { |
534 | // Clear the background | 427 | // Clear the background |
535 | p.setBrush( QBrush( Qt::black ) ); | 428 | p.setBrush( QBrush( Qt::black ) ); |
536 | p.drawRect( rect() ); | 429 | p.drawRect( rect() ); |
537 | } else { | 430 | } else { |
538 | if ( !pe->erased() ) { | 431 | if ( !pe->erased() ) { |
539 | // Combine with background and double buffer | 432 | // Combine with background and double buffer |
540 | QPixmap pix( pe->rect().size() ); | 433 | QPixmap pix( pe->rect().size() ); |
541 | QPainter p( &pix ); | 434 | QPainter p( &pix ); |
542 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 435 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
543 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); | 436 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); |
544 | for ( int i = 0; i < numVButtons; i++ ) { | 437 | for ( int i = 0; i < numVButtons; i++ ) { |
545 | paintButton( &p, i ); | 438 | paintButton( &p, i ); |
546 | } | 439 | } |
547 | QPainter p2( this ); | 440 | QPainter p2( this ); |
548 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 441 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
549 | } else { | 442 | } else { |
550 | QPainter p( this ); | 443 | QPainter p( this ); |
551 | for ( int i = 0; i < numVButtons; i++ ) | 444 | for ( int i = 0; i < numVButtons; i++ ) |
552 | paintButton( &p, i ); | 445 | paintButton( &p, i ); |
553 | } | 446 | } |
554 | slider->repaint( TRUE ); | 447 | slider->repaint( TRUE ); |
555 | } | 448 | } |
556 | } | 449 | } |
557 | 450 | ||
558 | 451 | ||
559 | void VideoWidget::closeEvent( QCloseEvent* ) { | 452 | void VideoWidget::closeEvent( QCloseEvent* ) { |
560 | mediaPlayerState->setList(); | 453 | mediaPlayerState->setList(); |
561 | } | 454 | } |
562 | 455 | ||
563 | 456 | ||
564 | bool VideoWidget::playVideo() { | 457 | bool VideoWidget::playVideo() { |
565 | bool result = FALSE; | 458 | bool result = FALSE; |
566 | // qDebug("<<<<<<<<<<<<<<<< play video"); | 459 | // qDebug("<<<<<<<<<<<<<<<< play video"); |
567 | int stream = 0; | 460 | int stream = 0; |
568 | 461 | ||
569 | int sw = mediaPlayerState->curDecoder()->videoWidth( stream ); | 462 | int sw = mediaPlayerState->curDecoder()->videoWidth( stream ); |
570 | int sh = mediaPlayerState->curDecoder()->videoHeight( stream ); | 463 | int sh = mediaPlayerState->curDecoder()->videoHeight( stream ); |
571 | int dd = QPixmap::defaultDepth(); | 464 | int dd = QPixmap::defaultDepth(); |
572 | int w = height(); | 465 | int w = height(); |
573 | int h = width(); | 466 | int h = width(); |
574 | 467 | ||
575 | ColorFormat format = (dd == 16) ? RGB565 : BGRA8888; | 468 | ColorFormat format = (dd == 16) ? RGB565 : BGRA8888; |
576 | 469 | ||
577 | if ( mediaPlayerState->fullscreen() ) | 470 | if ( mediaPlayerState->fullscreen() ) |
578 | { | 471 | { |
579 | #ifdef USE_DIRECT_PAINTER | 472 | #ifdef USE_DIRECT_PAINTER |
580 | QDirectPainter p(this); | 473 | QDirectPainter p(this); |
581 | 474 | ||
582 | if ( ( qt_screen->transformOrientation() == 3 ) && | 475 | if ( ( qt_screen->transformOrientation() == 3 ) && |
583 | ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) ) | 476 | ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) ) |
584 | { | 477 | { |
585 | 478 | ||
586 | w = 320; | 479 | w = 320; |
587 | h = 240; | 480 | h = 240; |
588 | 481 | ||
589 | if ( mediaPlayerState->scaled() ) | 482 | if ( mediaPlayerState->scaled() ) |
590 | { | 483 | { |
591 | // maintain aspect ratio | 484 | // maintain aspect ratio |
592 | if ( w * sh > sw * h ) | 485 | if ( w * sh > sw * h ) |
593 | w = sw * h / sh; | 486 | w = sw * h / sh; |
594 | else | 487 | else |
595 | h = sh * w / sw; | 488 | h = sh * w / sw; |
596 | } | 489 | } |
597 | else | 490 | else |
598 | { | 491 | { |
599 | w = sw; | 492 | w = sw; |
600 | h = sh; | 493 | h = sh; |
601 | } | 494 | } |
602 | 495 | ||
603 | w--; // we can't allow libmpeg to overwrite. | 496 | w--; // we can't allow libmpeg to overwrite. |
604 | QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) ); | 497 | QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) ); |
605 | 498 | ||
606 | int ox = roff.x() - height() + 2 + (height() - w) / 2; | 499 | int ox = roff.x() - height() + 2 + (height() - w) / 2; |
607 | int oy = roff.y() + (width() - h) / 2; | 500 | int oy = roff.y() + (width() - h) / 2; |
608 | int sx = 0, sy = 0; | 501 | int sx = 0, sy = 0; |
609 | 502 | ||
610 | uchar* fp = p.frameBuffer() + p.lineStep() * oy; | 503 | uchar* fp = p.frameBuffer() + p.lineStep() * oy; |
611 | fp += dd * ox / 8; | 504 | fp += dd * ox / 8; |
612 | uchar **jt = new uchar*[h]; | 505 | uchar **jt = new uchar*[h]; |
613 | 506 | ||
614 | for ( int i = h; i; i-- ) | 507 | for ( int i = h; i; i-- ) |
615 | { | 508 | { |
616 | jt[h - i] = fp; | 509 | jt[h - i] = fp; |
617 | fp += p.lineStep(); | 510 | fp += p.lineStep(); |
618 | } | 511 | } |
619 | 512 | ||
620 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0; | 513 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0; |
621 | 514 | ||
622 | delete [] jt; | 515 | delete [] jt; |
623 | } | 516 | } |
624 | else | 517 | else |
625 | { | 518 | { |
626 | #endif | 519 | #endif |
627 | QPainter p(this); | 520 | QPainter p(this); |
628 | 521 | ||
629 | w = 320; | 522 | w = 320; |
630 | h = 240; | 523 | h = 240; |
631 | 524 | ||
632 | if ( mediaPlayerState->scaled() ) | 525 | if ( mediaPlayerState->scaled() ) |
633 | { | 526 | { |
634 | // maintain aspect ratio | 527 | // maintain aspect ratio |
635 | if ( w * sh > sw * h ) | 528 | if ( w * sh > sw * h ) |
636 | w = sw * h / sh; | 529 | w = sw * h / sh; |
637 | else | 530 | else |
638 | h = sh * w / sw; | 531 | h = sh * w / sw; |
639 | } | 532 | } |
640 | else | 533 | else |
641 | { | 534 | { |
642 | w = sw; | 535 | w = sw; |
643 | h = sh; | 536 | h = sh; |
644 | } | 537 | } |
645 | 538 | ||
646 | int bytes = ( dd == 16 ) ? 2 : 4; | 539 | int bytes = ( dd == 16 ) ? 2 : 4; |
647 | QImage tempFrame( w, h, bytes << 3 ); | 540 | QImage tempFrame( w, h, bytes << 3 ); |
648 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(), | 541 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(), |
649 | 0, 0, sw, sh, w, h, format, 0) == 0; | 542 | 0, 0, sw, sh, w, h, format, 0) == 0; |
650 | 543 | ||
651 | if ( result && mediaPlayerState->fullscreen() ) | 544 | if ( result && mediaPlayerState->fullscreen() ) |
652 | { | 545 | { |
653 | 546 | ||
654 | int rw = h, rh = w; | 547 | int rw = h, rh = w; |
655 | QImage rotatedFrame( rw, rh, bytes << 3 ); | 548 | QImage rotatedFrame( rw, rh, bytes << 3 ); |
656 | 549 | ||
657 | ushort* in = (ushort*)tempFrame.bits(); | 550 | ushort* in = (ushort*)tempFrame.bits(); |
658 | ushort* out = (ushort*)rotatedFrame.bits(); | 551 | ushort* out = (ushort*)rotatedFrame.bits(); |
659 | int spl = rotatedFrame.bytesPerLine() / bytes; | 552 | int spl = rotatedFrame.bytesPerLine() / bytes; |
660 | 553 | ||
661 | for (int x=0; x<h; x++) | 554 | for (int x=0; x<h; x++) |
662 | { | 555 | { |
663 | if ( bytes == 2 ) | 556 | if ( bytes == 2 ) |
664 | { | 557 | { |
665 | ushort* lout = out++ + (w - 1)*spl; | 558 | ushort* lout = out++ + (w - 1)*spl; |
666 | for (int y=0; y<w; y++) { | 559 | for (int y=0; y<w; y++) { |
667 | *lout=*in++; | 560 | *lout=*in++; |
668 | lout-=spl; | 561 | lout-=spl; |
669 | } | 562 | } |
670 | } | 563 | } |
671 | else | 564 | else |
672 | { | 565 | { |
673 | ulong* lout = ((ulong *)out)++ + (w - 1)*spl; | 566 | ulong* lout = ((ulong *)out)++ + (w - 1)*spl; |
674 | for (int y=0; y<w; y++) | 567 | for (int y=0; y<w; y++) |
675 | { | 568 | { |
676 | *lout=*((ulong*)in)++; | 569 | *lout=*((ulong*)in)++; |
677 | lout-=spl; | 570 | lout-=spl; |
678 | } | 571 | } |
679 | } | 572 | } |
680 | } | 573 | } |
681 | 574 | ||
682 | p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh ); | 575 | p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh ); |
683 | } | 576 | } |
684 | #ifdef USE_DIRECT_PAINTER | 577 | #ifdef USE_DIRECT_PAINTER |
685 | } | 578 | } |
686 | #endif | 579 | #endif |
687 | } | 580 | } |
688 | else | 581 | else |
689 | { | 582 | { |
690 | 583 | ||
691 | w = 220; | 584 | w = 220; |
692 | h = 160; | 585 | h = 160; |
693 | 586 | ||
694 | // maintain aspect ratio | 587 | // maintain aspect ratio |
695 | if ( w * sh > sw * h ) | 588 | if ( w * sh > sw * h ) |
696 | w = sw * h / sh; | 589 | w = sw * h / sh; |
697 | else | 590 | else |
698 | h = sh * w / sw; | 591 | h = sh * w / sw; |
699 | 592 | ||
700 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0; | 593 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0; |
701 | 594 | ||
702 | QPainter p( this ); | 595 | QPainter p( this ); |
703 | int deskW = qApp->desktop()->width(); | 596 | int deskW = qApp->desktop()->width(); |
704 | // Image changed size, therefore need to blank the possibly unpainted regions first | 597 | // Image changed size, therefore need to blank the possibly unpainted regions first |
705 | if ( scaledWidth != w || scaledHeight != h ) | 598 | if ( scaledWidth != w || scaledHeight != h ) |
706 | { | 599 | { |
707 | p.setBrush( QBrush( Qt::black ) ); | 600 | p.setBrush( QBrush( Qt::black ) ); |
708 | p.drawRect( ( deskW -scaledWidth)/2, 20, scaledWidth, 160 ); | 601 | p.drawRect( ( deskW -scaledWidth)/2, 20, scaledWidth, 160 ); |
709 | } | 602 | } |
710 | 603 | ||
711 | scaledWidth = w; | 604 | scaledWidth = w; |
712 | scaledHeight = h; | 605 | scaledHeight = h; |
713 | 606 | ||
714 | if ( result ) | 607 | if ( result ) |
715 | { | 608 | { |
716 | p.drawImage( (deskW - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); | 609 | p.drawImage( (deskW - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); |
717 | } | 610 | } |
718 | 611 | ||
719 | } | 612 | } |
720 | 613 | ||
721 | return result; | 614 | return result; |
722 | } | 615 | } |
723 | 616 | ||
724 | 617 | ||
725 | 618 | ||
726 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) | 619 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) |
727 | { | 620 | { |
728 | switch ( e->key() ) | 621 | switch ( e->key() ) |
729 | { | 622 | { |
730 | ////////////////////////////// Zaurus keys | 623 | ////////////////////////////// Zaurus keys |
731 | case Key_Home: | 624 | case Key_Home: |
732 | break; | 625 | break; |
733 | case Key_F9: //activity | 626 | case Key_F9: //activity |
734 | break; | 627 | break; |
735 | case Key_F10: //contacts | 628 | case Key_F10: //contacts |
736 | // hide(); | 629 | // hide(); |
737 | break; | 630 | break; |
738 | case Key_F11: //menu | 631 | case Key_F11: //menu |
739 | break; | 632 | break; |
740 | case Key_F12: //home | 633 | case Key_F12: //home |
741 | break; | 634 | break; |
742 | case Key_F13: //mail | 635 | case Key_F13: //mail |
743 | break; | 636 | break; |
744 | case Key_Space: | 637 | case Key_Space: |
745 | { | 638 | { |
746 | if(mediaPlayerState->playing()) | 639 | if(mediaPlayerState->playing()) |
747 | { | 640 | { |
748 | mediaPlayerState->setPlaying(FALSE); | 641 | mediaPlayerState->setPlaying(FALSE); |
749 | } | 642 | } |
750 | else | 643 | else |
751 | { | 644 | { |
752 | mediaPlayerState->setPlaying(TRUE); | 645 | mediaPlayerState->setPlaying(TRUE); |
753 | } | 646 | } |
754 | } | 647 | } |
755 | break; | 648 | break; |
756 | case Key_Down: | 649 | case Key_Down: |
757 | // toggleButton(6); | 650 | // toggleButton(6); |
758 | // emit lessClicked(); | 651 | // emit lessClicked(); |
759 | // emit lessReleased(); | 652 | // emit lessReleased(); |
760 | // toggleButton(6); | 653 | // toggleButton(6); |
761 | break; | 654 | break; |
762 | case Key_Up: | 655 | case Key_Up: |
763 | // toggleButton(5); | 656 | // toggleButton(5); |
764 | // emit moreClicked(); | 657 | // emit moreClicked(); |
765 | // emit moreReleased(); | 658 | // emit moreReleased(); |
766 | // toggleButton(5); | 659 | // toggleButton(5); |
767 | break; | 660 | break; |
768 | case Key_Right: | 661 | case Key_Right: |
769 | mediaPlayerState->setNext(); | 662 | mediaPlayerState->setNext(); |
770 | break; | 663 | break; |
771 | case Key_Left: | 664 | case Key_Left: |
772 | mediaPlayerState->setPrev(); | 665 | mediaPlayerState->setPrev(); |
773 | break; | 666 | break; |
774 | case Key_Escape: | 667 | case Key_Escape: |
775 | break; | 668 | break; |
776 | 669 | ||
777 | }; | 670 | }; |
778 | } | 671 | } |