author | harlekin <harlekin> | 2002-08-11 12:26:54 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-08-11 12:26:54 (UTC) |
commit | c7c84fd736d1ae29f0d9e51f781e1d94f0c39334 (patch) (unidiff) | |
tree | 830ed00d66ae074ca6db8ddd820ab2a68d1a1a2b | |
parent | c20e4302b915bcba07b468874e9795d37d2eaa03 (diff) | |
download | opie-c7c84fd736d1ae29f0d9e51f781e1d94f0c39334.zip opie-c7c84fd736d1ae29f0d9e51f781e1d94f0c39334.tar.gz opie-c7c84fd736d1ae29f0d9e51f781e1d94f0c39334.tar.bz2 |
make it compile again
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index a4e6b6e..9b88299 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -4,463 +4,463 @@ | |||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <qpe/resource.h> | 34 | #include <qpe/resource.h> |
35 | #include <qpe/mediaplayerplugininterface.h> | 35 | #include <qpe/mediaplayerplugininterface.h> |
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | 37 | ||
38 | #include <qwidget.h> | 38 | #include <qwidget.h> |
39 | #include <qpainter.h> | 39 | #include <qpainter.h> |
40 | #include <qpixmap.h> | 40 | #include <qpixmap.h> |
41 | #include <qslider.h> | 41 | #include <qslider.h> |
42 | #include <qdrawutil.h> | 42 | #include <qdrawutil.h> |
43 | #include "videowidget.h" | 43 | #include "videowidget.h" |
44 | #include "mediaplayerstate.h" | 44 | #include "mediaplayerstate.h" |
45 | 45 | ||
46 | 46 | ||
47 | #ifdef Q_WS_QWS | 47 | #ifdef Q_WS_QWS |
48 | # define USE_DIRECT_PAINTER | 48 | # define USE_DIRECT_PAINTER |
49 | # include <qdirectpainter_qws.h> | 49 | # include <qdirectpainter_qws.h> |
50 | # include <qgfxraster_qws.h> | 50 | # include <qgfxraster_qws.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | 53 | ||
54 | extern MediaPlayerState *mediaPlayerState; | 54 | extern MediaPlayerState *mediaPlayerState; |
55 | 55 | ||
56 | 56 | ||
57 | static const int xo = 2; // movable x offset | 57 | static const int xo = 2; // movable x offset |
58 | static const int yo = 0; // movable y offset | 58 | static const int yo = 0; // movable y offset |
59 | 59 | ||
60 | 60 | ||
61 | struct MediaButton { | 61 | struct MediaButton { |
62 | bool isToggle, isHeld, isDown; | 62 | bool isToggle, isHeld, isDown; |
63 | }; | 63 | }; |
64 | 64 | ||
65 | MediaButton videoButtons[] = { | 65 | MediaButton videoButtons[] = { |
66 | { FALSE, FALSE, FALSE }, // previous | 66 | { FALSE, FALSE, FALSE }, // previous |
67 | { FALSE, FALSE, FALSE }, // stop | 67 | { FALSE, FALSE, FALSE }, // stop |
68 | { TRUE, FALSE, FALSE }, // play | 68 | { TRUE, FALSE, FALSE }, // play |
69 | { TRUE, FALSE, FALSE }, // pause | 69 | { TRUE, FALSE, FALSE }, // pause |
70 | { FALSE, FALSE, FALSE }, // next | 70 | { FALSE, FALSE, FALSE }, // next |
71 | { FALSE, FALSE, FALSE }, // playlist | 71 | { FALSE, FALSE, FALSE }, // playlist |
72 | { TRUE, FALSE, FALSE } // fullscreen | 72 | { TRUE, FALSE, FALSE } // fullscreen |
73 | }; | 73 | }; |
74 | 74 | ||
75 | const char *skinV_mask_file_names[7] = { | 75 | const char *skinV_mask_file_names[7] = { |
76 | "stop","play","back","fwd","up","down","full" | 76 | "stop","play","back","fwd","up","down","full" |
77 | }; | 77 | }; |
78 | 78 | ||
79 | static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); | 79 | static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); |
80 | 80 | ||
81 | 81 | ||
82 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : | 82 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : |
83 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { | 83 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { |
84 | setCaption( tr("OpiePlayer - Video") ); | 84 | setCaption( tr("OpiePlayer - Video") ); |
85 | 85 | ||
86 | videoFrame = new XineVideoWidget ( this, "Video frame" ); | 86 | videoFrame = new XineVideoWidget ( this, "Video frame" ); |
87 | 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("VideoWidget"); | 90 | cfg.setGroup("VideoWidget"); |
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 | 116 | ||
117 | } | 117 | } |
118 | 118 | ||
119 | for ( int i = 0; i < 7; i++ ) { | 119 | for ( int i = 0; i < 7; i++ ) { |
120 | buttonPixUp[i] = NULL; | 120 | buttonPixUp[i] = NULL; |
121 | buttonPixDown[i] = NULL; | 121 | buttonPixDown[i] = NULL; |
122 | } | 122 | } |
123 | 123 | ||
124 | setBackgroundPixmap( *pixBg ); | 124 | setBackgroundPixmap( *pixBg ); |
125 | 125 | ||
126 | slider = new QSlider( Qt::Horizontal, this ); | 126 | slider = new QSlider( Qt::Horizontal, this ); |
127 | slider->setMinValue( 0 ); | 127 | slider->setMinValue( 0 ); |
128 | slider->setMaxValue( 1 ); | 128 | slider->setMaxValue( 1 ); |
129 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); | 129 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); |
130 | slider->setFocusPolicy( QWidget::NoFocus ); | 130 | slider->setFocusPolicy( QWidget::NoFocus ); |
131 | slider->setGeometry( QRect( 7, 250, 220, 20 ) ); | 131 | slider->setGeometry( QRect( 7, 250, 220, 20 ) ); |
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 | 135 | ||
136 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 136 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
137 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 137 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
138 | connect( mediaPlayerState, SIGNAL( positionUpdated(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) ) ); | 139 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
140 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 140 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
141 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 141 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
142 | 142 | ||
143 | setLength( mediaPlayerState->length() ); | 143 | setLength( mediaPlayerState->length() ); |
144 | setPosition( mediaPlayerState->position() ); | 144 | setPosition( mediaPlayerState->position() ); |
145 | 145 | ||
146 | ////////////////////////// FIXME | 146 | ////////////////////////// FIXME |
147 | // setFullscreen( mediaPlayerState->fullscreen() ); | 147 | // setFullscreen( mediaPlayerState->fullscreen() ); |
148 | setPaused( mediaPlayerState->paused() ); | 148 | setPaused( mediaPlayerState->paused() ); |
149 | setPlaying( mediaPlayerState->playing() ); | 149 | setPlaying( mediaPlayerState->playing() ); |
150 | qDebug("finished videowidget"); | 150 | qDebug("finished videowidget"); |
151 | } | 151 | } |
152 | 152 | ||
153 | 153 | ||
154 | VideoWidget::~VideoWidget() { | 154 | VideoWidget::~VideoWidget() { |
155 | for ( int i = 0; i < 7; i++ ) { | 155 | for ( int i = 0; i < 7; i++ ) { |
156 | delete buttonPixUp[i]; | 156 | delete buttonPixUp[i]; |
157 | delete buttonPixDown[i]; | 157 | delete buttonPixDown[i]; |
158 | } | 158 | } |
159 | 159 | ||
160 | delete pixBg; | 160 | delete pixBg; |
161 | delete imgUp; | 161 | delete imgUp; |
162 | delete imgDn; | 162 | delete imgDn; |
163 | delete imgButtonMask; | 163 | delete imgButtonMask; |
164 | for ( int i = 0; i < 7; i++ ) { | 164 | for ( int i = 0; i < 7; i++ ) { |
165 | delete masks[i]; | 165 | delete masks[i]; |
166 | } | 166 | } |
167 | } | 167 | } |
168 | 168 | ||
169 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 169 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
170 | QPixmap pix( img.width(), img.height() ); | 170 | QPixmap pix( img.width(), img.height() ); |
171 | QPainter p( &pix ); | 171 | QPainter p( &pix ); |
172 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 172 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
173 | p.drawImage( 0, 0, img ); | 173 | p.drawImage( 0, 0, img ); |
174 | return new QPixmap( pix ); | 174 | return new QPixmap( pix ); |
175 | } | 175 | } |
176 | 176 | ||
177 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { | 177 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { |
178 | QPixmap *pixmap = new QPixmap( pix ); | 178 | QPixmap *pixmap = new QPixmap( pix ); |
179 | pixmap->setMask( mask ); | 179 | pixmap->setMask( mask ); |
180 | return pixmap; | 180 | return pixmap; |
181 | } | 181 | } |
182 | 182 | ||
183 | void VideoWidget::resizeEvent( QResizeEvent * ) { | 183 | void VideoWidget::resizeEvent( QResizeEvent * ) { |
184 | int h = height(); | 184 | int h = height(); |
185 | int w = width(); | 185 | int w = width(); |
186 | int Vh = 160; | 186 | int Vh = 160; |
187 | //videoFrame->height(); | 187 | //videoFrame->height(); |
188 | int Vw = 220; | 188 | int Vw = 220; |
189 | //videoFrame->width(); | 189 | //videoFrame->width(); |
190 | // songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); | 190 | // songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); |
191 | 191 | ||
192 | slider->setFixedWidth( w - 110 ); | 192 | slider->setFixedWidth( w - 110 ); |
193 | slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); | 193 | slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); |
194 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); | 194 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); |
195 | slider->setFocusPolicy( QWidget::NoFocus ); | 195 | slider->setFocusPolicy( QWidget::NoFocus ); |
196 | make slider->setBackgroundPixmap( *pixBg ); | 196 | slider->setBackgroundPixmap( *pixBg ); |
197 | 197 | ||
198 | // time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); | 198 | // time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); |
199 | xoff = 0;// ( imgUp->width() ) / 2; | 199 | xoff = 0;// ( imgUp->width() ) / 2; |
200 | yoff = 180;//(( Vh - imgUp->height() ) / 2) - 10; | 200 | yoff = 180;//(( Vh - imgUp->height() ) / 2) - 10; |
201 | QPoint p( xoff, yoff ); | 201 | QPoint p( xoff, yoff ); |
202 | 202 | ||
203 | 203 | ||
204 | QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); | 204 | QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); |
205 | QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); | 205 | QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); |
206 | 206 | ||
207 | for ( int i = 0; i < 7; i++ ) { | 207 | for ( int i = 0; i < 7; i++ ) { |
208 | if ( !masks[i]->isNull() ) { | 208 | if ( !masks[i]->isNull() ) { |
209 | delete buttonPixUp[i]; | 209 | delete buttonPixUp[i]; |
210 | delete buttonPixDown[i]; | 210 | delete buttonPixDown[i]; |
211 | buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); | 211 | buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); |
212 | buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); | 212 | buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); |
213 | } | 213 | } |
214 | } | 214 | } |
215 | 215 | ||
216 | delete pixUp; | 216 | delete pixUp; |
217 | delete pixDn; | 217 | delete pixDn; |
218 | } | 218 | } |
219 | 219 | ||
220 | static bool videoSliderBeingMoved = FALSE; | 220 | static bool videoSliderBeingMoved = FALSE; |
221 | 221 | ||
222 | void VideoWidget::sliderPressed() { | 222 | void VideoWidget::sliderPressed() { |
223 | videoSliderBeingMoved = TRUE; | 223 | videoSliderBeingMoved = TRUE; |
224 | } | 224 | } |
225 | 225 | ||
226 | void VideoWidget::sliderReleased() { | 226 | void VideoWidget::sliderReleased() { |
227 | videoSliderBeingMoved = FALSE; | 227 | videoSliderBeingMoved = FALSE; |
228 | if ( slider->width() == 0 ) { | 228 | if ( slider->width() == 0 ) { |
229 | return; | 229 | return; |
230 | } | 230 | } |
231 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); | 231 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); |
232 | mediaPlayerState->setPosition( val ); | 232 | mediaPlayerState->setPosition( val ); |
233 | } | 233 | } |
234 | 234 | ||
235 | void VideoWidget::setPosition( long i ) { | 235 | void VideoWidget::setPosition( long i ) { |
236 | updateSlider( i, mediaPlayerState->length() ); | 236 | updateSlider( i, mediaPlayerState->length() ); |
237 | } | 237 | } |
238 | 238 | ||
239 | 239 | ||
240 | void VideoWidget::setLength( long max ) { | 240 | void VideoWidget::setLength( long max ) { |
241 | updateSlider( mediaPlayerState->position(), max ); | 241 | updateSlider( mediaPlayerState->position(), max ); |
242 | } | 242 | } |
243 | 243 | ||
244 | void VideoWidget::setView( char view ) { | 244 | void VideoWidget::setView( char view ) { |
245 | if ( view == 'v' ) { | 245 | if ( view == 'v' ) { |
246 | makeVisible(); | 246 | makeVisible(); |
247 | } else { | 247 | } else { |
248 | // Effectively blank the view next time we show it so it looks nicer | 248 | // Effectively blank the view next time we show it so it looks nicer |
249 | scaledWidth = 0; | 249 | scaledWidth = 0; |
250 | scaledHeight = 0; | 250 | scaledHeight = 0; |
251 | hide(); | 251 | hide(); |
252 | } | 252 | } |
253 | } | 253 | } |
254 | 254 | ||
255 | void VideoWidget::updateSlider( long i, long max ) { | 255 | void VideoWidget::updateSlider( long i, long max ) { |
256 | // Will flicker too much if we don't do this | 256 | // Will flicker too much if we don't do this |
257 | if ( max == 0 ) { | 257 | if ( max == 0 ) { |
258 | return; | 258 | return; |
259 | } | 259 | } |
260 | int width = slider->width(); | 260 | int width = slider->width(); |
261 | int val = int((double)i * width / max); | 261 | int val = int((double)i * width / max); |
262 | if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { | 262 | if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { |
263 | if ( slider->value() != val ) { | 263 | if ( slider->value() != val ) { |
264 | slider->setValue( val ); | 264 | slider->setValue( val ); |
265 | } | 265 | } |
266 | if ( slider->maxValue() != width ) { | 266 | if ( slider->maxValue() != width ) { |
267 | slider->setMaxValue( width ); | 267 | slider->setMaxValue( width ); |
268 | } | 268 | } |
269 | } | 269 | } |
270 | } | 270 | } |
271 | 271 | ||
272 | void VideoWidget::setToggleButton( int i, bool down ) { | 272 | void VideoWidget::setToggleButton( int i, bool down ) { |
273 | if ( down != videoButtons[i].isDown ) { | 273 | if ( down != videoButtons[i].isDown ) { |
274 | toggleButton( i ); | 274 | toggleButton( i ); |
275 | } | 275 | } |
276 | } | 276 | } |
277 | 277 | ||
278 | void VideoWidget::toggleButton( int i ) { | 278 | void VideoWidget::toggleButton( int i ) { |
279 | videoButtons[i].isDown = !videoButtons[i].isDown; | 279 | videoButtons[i].isDown = !videoButtons[i].isDown; |
280 | QPainter p(this); | 280 | QPainter p(this); |
281 | paintButton ( &p, i ); | 281 | paintButton ( &p, i ); |
282 | } | 282 | } |
283 | 283 | ||
284 | void VideoWidget::paintButton( QPainter *p, int i ) { | 284 | void VideoWidget::paintButton( QPainter *p, int i ) { |
285 | 285 | ||
286 | if ( videoButtons[i].isDown ) | 286 | if ( videoButtons[i].isDown ) |
287 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | 287 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); |
288 | else | 288 | else |
289 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | 289 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); |
290 | } | 290 | } |
291 | 291 | ||
292 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 292 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
293 | for ( int i = 0; i < numButtons; i++ ) { | 293 | for ( int i = 0; i < numButtons; i++ ) { |
294 | if ( event->state() == QMouseEvent::LeftButton ) { | 294 | if ( event->state() == QMouseEvent::LeftButton ) { |
295 | // The test to see if the mouse click is inside the button or not | 295 | // The test to see if the mouse click is inside the button or not |
296 | int x = event->pos().x() - xoff; | 296 | int x = event->pos().x() - xoff; |
297 | int y = event->pos().y() - yoff; | 297 | int y = event->pos().y() - yoff; |
298 | 298 | ||
299 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() | 299 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() |
300 | && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); | 300 | && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); |
301 | if ( isOnButton != videoButtons[i].isHeld ) { | 301 | if ( isOnButton != videoButtons[i].isHeld ) { |
302 | videoButtons[i].isHeld = isOnButton; | 302 | videoButtons[i].isHeld = isOnButton; |
303 | toggleButton(i); | 303 | toggleButton(i); |
304 | } | 304 | } |
305 | } else { | 305 | } else { |
306 | if ( videoButtons[i].isHeld ) { | 306 | if ( videoButtons[i].isHeld ) { |
307 | videoButtons[i].isHeld = FALSE; | 307 | videoButtons[i].isHeld = FALSE; |
308 | if ( !videoButtons[i].isToggle ) | 308 | if ( !videoButtons[i].isToggle ) |
309 | setToggleButton( i, FALSE ); | 309 | setToggleButton( i, FALSE ); |
310 | } | 310 | } |
311 | } | 311 | } |
312 | switch (i) { | 312 | switch (i) { |
313 | case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; | 313 | case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; |
314 | case VideoStop: mediaPlayerState->setPlaying(FALSE); return; | 314 | case VideoStop: mediaPlayerState->setPlaying(FALSE); return; |
315 | case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; | 315 | case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; |
316 | case VideoNext: mediaPlayerState->setNext(); return; | 316 | case VideoNext: mediaPlayerState->setNext(); return; |
317 | case VideoPrevious: mediaPlayerState->setPrev(); return; | 317 | case VideoPrevious: mediaPlayerState->setPrev(); return; |
318 | case VideoPlayList: mediaPlayerState->setList(); return; | 318 | case VideoPlayList: mediaPlayerState->setList(); return; |
319 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | 319 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; |
320 | } | 320 | } |
321 | 321 | ||
322 | } | 322 | } |
323 | } | 323 | } |
324 | 324 | ||
325 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { | 325 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { |
326 | mouseMoveEvent( event ); | 326 | mouseMoveEvent( event ); |
327 | } | 327 | } |
328 | 328 | ||
329 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 329 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
330 | if ( mediaPlayerState->fullscreen() ) { | 330 | if ( mediaPlayerState->fullscreen() ) { |
331 | mediaPlayerState->setFullscreen( FALSE ); | 331 | mediaPlayerState->setFullscreen( FALSE ); |
332 | makeVisible(); | 332 | makeVisible(); |
333 | 333 | ||
334 | mouseMoveEvent( event ); | 334 | mouseMoveEvent( event ); |
335 | } | 335 | } |
336 | } | 336 | } |
337 | 337 | ||
338 | 338 | ||
339 | void VideoWidget::makeVisible() { | 339 | void VideoWidget::makeVisible() { |
340 | if ( mediaPlayerState->fullscreen() ) { | 340 | if ( mediaPlayerState->fullscreen() ) { |
341 | setBackgroundMode( QWidget::NoBackground ); | 341 | setBackgroundMode( QWidget::NoBackground ); |
342 | showFullScreen(); | 342 | showFullScreen(); |
343 | resize( qApp->desktop()->size() ); | 343 | resize( qApp->desktop()->size() ); |
344 | slider->hide(); | 344 | slider->hide(); |
345 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); | 345 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); |
346 | } else { | 346 | } else { |
347 | showNormal(); | 347 | showNormal(); |
348 | showMaximized(); | 348 | showMaximized(); |
349 | slider->show(); | 349 | slider->show(); |
350 | videoFrame->setGeometry( QRect( 10, 20, 220, 160 ) ); | 350 | videoFrame->setGeometry( QRect( 10, 20, 220, 160 ) ); |
351 | } | 351 | } |
352 | } | 352 | } |
353 | 353 | ||
354 | 354 | ||
355 | void VideoWidget::paintEvent( QPaintEvent * pe) { | 355 | void VideoWidget::paintEvent( QPaintEvent * pe) { |
356 | QPainter p( this ); | 356 | QPainter p( this ); |
357 | 357 | ||
358 | if ( mediaPlayerState->fullscreen() ) { | 358 | if ( mediaPlayerState->fullscreen() ) { |
359 | // Clear the background | 359 | // Clear the background |
360 | p.setBrush( QBrush( Qt::black ) ); | 360 | p.setBrush( QBrush( Qt::black ) ); |
361 | // videoFrame->setGeometry( QRect( 0, 0 , 240 ,320 ) ); | 361 | // videoFrame->setGeometry( QRect( 0, 0 , 240 ,320 ) ); |
362 | 362 | ||
363 | } else { | 363 | } else { |
364 | 364 | ||
365 | // videoFrame->setGeometry( QRect( 0, 15 , 240 ,170 ) ); | 365 | // videoFrame->setGeometry( QRect( 0, 15 , 240 ,170 ) ); |
366 | // draw the buttons | 366 | // draw the buttons |
367 | 367 | ||
368 | if ( !pe->erased() ) { | 368 | if ( !pe->erased() ) { |
369 | // Combine with background and double buffer | 369 | // Combine with background and double buffer |
370 | QPixmap pix( pe->rect().size() ); | 370 | QPixmap pix( pe->rect().size() ); |
371 | QPainter p( &pix ); | 371 | QPainter p( &pix ); |
372 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 372 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
373 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); | 373 | p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); |
374 | for ( int i = 0; i < numButtons; i++ ) | 374 | for ( int i = 0; i < numButtons; i++ ) |
375 | paintButton( &p, i ); | 375 | paintButton( &p, i ); |
376 | QPainter p2( this ); | 376 | QPainter p2( this ); |
377 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 377 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
378 | } else { | 378 | } else { |
379 | QPainter p( this ); | 379 | QPainter p( this ); |
380 | for ( int i = 0; i < numButtons; i++ ) | 380 | for ( int i = 0; i < numButtons; i++ ) |
381 | paintButton( &p, i ); | 381 | paintButton( &p, i ); |
382 | } | 382 | } |
383 | // for ( int i = 0; i < numButtons; i++ ) { | 383 | // for ( int i = 0; i < numButtons; i++ ) { |
384 | // paintButton( &p, i ); | 384 | // paintButton( &p, i ); |
385 | // } | 385 | // } |
386 | // // draw the slider | 386 | // // draw the slider |
387 | // slider->repaint( TRUE ); | 387 | // slider->repaint( TRUE ); |
388 | } | 388 | } |
389 | } | 389 | } |
390 | 390 | ||
391 | 391 | ||
392 | void VideoWidget::closeEvent( QCloseEvent* ) { | 392 | void VideoWidget::closeEvent( QCloseEvent* ) { |
393 | mediaPlayerState->setList(); | 393 | mediaPlayerState->setList(); |
394 | } | 394 | } |
395 | 395 | ||
396 | 396 | ||
397 | bool VideoWidget::playVideo() { | 397 | bool VideoWidget::playVideo() { |
398 | bool result = FALSE; | 398 | bool result = FALSE; |
399 | 399 | ||
400 | int stream = 0; | 400 | int stream = 0; |
401 | 401 | ||
402 | int sw = 240; | 402 | int sw = 240; |
403 | int sh = 320; | 403 | int sh = 320; |
404 | int dd = QPixmap::defaultDepth(); | 404 | int dd = QPixmap::defaultDepth(); |
405 | int w = height(); | 405 | int w = height(); |
406 | int h = width(); | 406 | int h = width(); |
407 | 407 | ||
408 | return true; | 408 | return true; |
409 | } | 409 | } |
410 | 410 | ||
411 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { | 411 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) { |
412 | switch ( e->key() ) { | 412 | switch ( e->key() ) { |
413 | ////////////////////////////// Zaurus keys | 413 | ////////////////////////////// Zaurus keys |
414 | case Key_Home: | 414 | case Key_Home: |
415 | break; | 415 | break; |
416 | case Key_F9: //activity | 416 | case Key_F9: //activity |
417 | break; | 417 | break; |
418 | case Key_F10: //contacts | 418 | case Key_F10: //contacts |
419 | // hide(); | 419 | // hide(); |
420 | break; | 420 | break; |
421 | case Key_F11: //menu | 421 | case Key_F11: //menu |
422 | break; | 422 | break; |
423 | case Key_F12: //home | 423 | case Key_F12: //home |
424 | break; | 424 | break; |
425 | case Key_F13: //mail | 425 | case Key_F13: //mail |
426 | break; | 426 | break; |
427 | case Key_Space: { | 427 | case Key_Space: { |
428 | if(mediaPlayerState->playing()) { | 428 | if(mediaPlayerState->playing()) { |
429 | mediaPlayerState->setPlaying(FALSE); | 429 | mediaPlayerState->setPlaying(FALSE); |
430 | } else { | 430 | } else { |
431 | mediaPlayerState->setPlaying(TRUE); | 431 | mediaPlayerState->setPlaying(TRUE); |
432 | } | 432 | } |
433 | } | 433 | } |
434 | break; | 434 | break; |
435 | case Key_Down: | 435 | case Key_Down: |
436 | // toggleButton(6); | 436 | // toggleButton(6); |
437 | // emit lessClicked(); | 437 | // emit lessClicked(); |
438 | // emit lessReleased(); | 438 | // emit lessReleased(); |
439 | // toggleButton(6); | 439 | // toggleButton(6); |
440 | break; | 440 | break; |
441 | case Key_Up: | 441 | case Key_Up: |
442 | // toggleButton(5); | 442 | // toggleButton(5); |
443 | // emit moreClicked(); | 443 | // emit moreClicked(); |
444 | // emit moreReleased(); | 444 | // emit moreReleased(); |
445 | // toggleButton(5); | 445 | // toggleButton(5); |
446 | break; | 446 | break; |
447 | case Key_Right: | 447 | case Key_Right: |
448 | mediaPlayerState->setNext(); | 448 | mediaPlayerState->setNext(); |
449 | break; | 449 | break; |
450 | case Key_Left: | 450 | case Key_Left: |
451 | mediaPlayerState->setPrev(); | 451 | mediaPlayerState->setPrev(); |
452 | break; | 452 | break; |
453 | case Key_Escape: | 453 | case Key_Escape: |
454 | break; | 454 | break; |
455 | 455 | ||
456 | }; | 456 | }; |
457 | } | 457 | } |
458 | 458 | ||
459 | XineVideoWidget* VideoWidget::vidWidget() { | 459 | XineVideoWidget* VideoWidget::vidWidget() { |
460 | return videoFrame; | 460 | return videoFrame; |
461 | } | 461 | } |
462 | 462 | ||
463 | 463 | ||
464 | void VideoWidget::setFullscreen ( bool b ) { | 464 | void VideoWidget::setFullscreen ( bool b ) { |
465 | setToggleButton( VideoFullscreen, b ); | 465 | setToggleButton( VideoFullscreen, b ); |
466 | } | 466 | } |