-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 22 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.h | 2 |
2 files changed, 10 insertions, 14 deletions
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 7d85d63..089ef6a 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -1,387 +1,385 @@ | |||
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 | ||
56 | namespace | 56 | namespace |
57 | { | 57 | { |
58 | 58 | ||
59 | const int xo = 2; // movable x offset | 59 | const int xo = 2; // movable x offset |
60 | const int yo = 0; // movable y offset | 60 | const int yo = 0; // movable y offset |
61 | 61 | ||
62 | const char * const skinV_mask_file_names[7] = { | 62 | const char * const skinV_mask_file_names[7] = { |
63 | "play","stop","fwd","back","up","down","full" | 63 | "play","stop","fwd","back","up","down","full" |
64 | }; | 64 | }; |
65 | 65 | ||
66 | } | 66 | } |
67 | 67 | ||
68 | VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) | 68 | VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) |
69 | : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) | 69 | : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) |
70 | { | 70 | { |
71 | setCaption( tr("OpiePlayer - Video") ); | 71 | setCaption( tr("OpiePlayer - Video") ); |
72 | 72 | ||
73 | Button defaultButton; | 73 | Button defaultButton; |
74 | Button toggleButton = defaultButton; | 74 | Button toggleButton = defaultButton; |
75 | toggleButton.type = ToggleButton; | 75 | toggleButton.type = ToggleButton; |
76 | 76 | ||
77 | buttons.insert( 0, toggleButton ); // play | 77 | buttons.insert( 0, toggleButton ); // play |
78 | buttons.insert( 1, toggleButton ); // stop | 78 | buttons.insert( 1, toggleButton ); // stop |
79 | buttons.insert( 2, toggleButton ); // next | 79 | buttons.insert( 2, toggleButton ); // next |
80 | buttons.insert( 3, toggleButton ); // previous | 80 | buttons.insert( 3, toggleButton ); // previous |
81 | buttons.insert( 4, toggleButton ); // volUp | 81 | buttons.insert( 4, toggleButton ); // volUp |
82 | buttons.insert( 5, toggleButton ); // volDown | 82 | buttons.insert( 5, toggleButton ); // volDown |
83 | buttons.insert( 6, toggleButton ); // fullscreen | 83 | buttons.insert( 6, toggleButton ); // fullscreen |
84 | 84 | ||
85 | videoFrame = new XineVideoWidget ( this, "Video frame" ); | 85 | videoFrame = new XineVideoWidget ( this, "Video frame" ); |
86 | 86 | ||
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 | connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); | 88 | connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); |
89 | 89 | ||
90 | Config cfg("OpiePlayer"); | 90 | Config cfg("OpiePlayer"); |
91 | cfg.setGroup("Options"); | 91 | cfg.setGroup("Options"); |
92 | skin = cfg.readEntry("Skin","default"); | 92 | skin = cfg.readEntry("Skin","default"); |
93 | 93 | ||
94 | QString skinPath = "opieplayer2/skins/" + skin; | 94 | QString skinPath = "opieplayer2/skins/" + skin; |
95 | pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 95 | pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
96 | imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); | 96 | imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); |
97 | imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); | 97 | imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); |
98 | 98 | ||
99 | buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); | 99 | buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); |
100 | buttonMask.fill( 0 ); | 100 | buttonMask.fill( 0 ); |
101 | 101 | ||
102 | for ( int i = 0; i < 7; i++ ) { | 102 | for ( int i = 0; i < 7; i++ ) { |
103 | Button &button = buttons[ i ]; | ||
104 | |||
103 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); | 105 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); |
104 | masks[i] = new QBitmap( filename ); | 106 | button.mask = QBitmap( filename ); |
105 | 107 | ||
106 | if ( !masks[i]->isNull() ) { | 108 | if ( !button.mask.isNull() ) { |
107 | QImage imgMask = masks[i]->convertToImage(); | 109 | QImage imgMask = button.mask.convertToImage(); |
108 | uchar **dest = buttonMask.jumpTable(); | 110 | uchar **dest = buttonMask.jumpTable(); |
109 | for ( int y = 0; y < imgUp.height(); y++ ) { | 111 | for ( int y = 0; y < imgUp.height(); y++ ) { |
110 | uchar *line = dest[y]; | 112 | uchar *line = dest[y]; |
111 | for ( int x = 0; x < imgUp.width(); x++ ) { | 113 | for ( int x = 0; x < imgUp.width(); x++ ) { |
112 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 114 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
113 | line[x] = i + 1; | 115 | line[x] = i + 1; |
114 | } | 116 | } |
115 | } | 117 | } |
116 | } | 118 | } |
117 | } | 119 | } |
118 | 120 | ||
119 | for ( int i = 0; i < 7; i++ ) { | 121 | for ( int i = 0; i < 7; i++ ) { |
120 | buttonPixUp[i] = NULL; | 122 | buttonPixUp[i] = NULL; |
121 | buttonPixDown[i] = NULL; | 123 | buttonPixDown[i] = NULL; |
122 | } | 124 | } |
123 | 125 | ||
124 | setBackgroundPixmap( pixBg ); | 126 | setBackgroundPixmap( pixBg ); |
125 | 127 | ||
126 | slider = new QSlider( Qt::Horizontal, this ); | 128 | slider = new QSlider( Qt::Horizontal, this ); |
127 | slider->setMinValue( 0 ); | 129 | slider->setMinValue( 0 ); |
128 | slider->setMaxValue( 1 ); | 130 | slider->setMaxValue( 1 ); |
129 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); | 131 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); |
130 | //slider->setFocusPolicy( QWidget::NoFocus ); | 132 | //slider->setFocusPolicy( QWidget::NoFocus ); |
131 | 133 | ||
132 | resizeEvent( NULL ); | 134 | resizeEvent( NULL ); |
133 | 135 | ||
134 | setLength( mediaPlayerState.length() ); | 136 | setLength( mediaPlayerState.length() ); |
135 | setPosition( mediaPlayerState.position() ); | 137 | setPosition( mediaPlayerState.position() ); |
136 | setFullscreen( mediaPlayerState.isFullscreen() ); | 138 | setFullscreen( mediaPlayerState.isFullscreen() ); |
137 | setPlaying( mediaPlayerState.isPlaying() ); | 139 | setPlaying( mediaPlayerState.isPlaying() ); |
138 | } | 140 | } |
139 | 141 | ||
140 | 142 | ||
141 | VideoWidget::~VideoWidget() { | 143 | VideoWidget::~VideoWidget() { |
142 | |||
143 | for ( int i = 0; i < 7; i++ ) { | 144 | for ( int i = 0; i < 7; i++ ) { |
144 | delete buttonPixUp[i]; | 145 | delete buttonPixUp[i]; |
145 | delete buttonPixDown[i]; | 146 | delete buttonPixDown[i]; |
146 | } | 147 | } |
147 | |||
148 | for ( int i = 0; i < 7; i++ ) { | ||
149 | delete masks[i]; | ||
150 | } | ||
151 | |||
152 | } | 148 | } |
153 | 149 | ||
154 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 150 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
155 | QPixmap pix( img.width(), img.height() ); | 151 | QPixmap pix( img.width(), img.height() ); |
156 | QPainter p( &pix ); | 152 | QPainter p( &pix ); |
157 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 153 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
158 | p.drawImage( 0, 0, img ); | 154 | p.drawImage( 0, 0, img ); |
159 | return new QPixmap( pix ); | 155 | return new QPixmap( pix ); |
160 | } | 156 | } |
161 | 157 | ||
162 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { | 158 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { |
163 | QPixmap *pixmap = new QPixmap( pix ); | 159 | QPixmap *pixmap = new QPixmap( pix ); |
164 | pixmap->setMask( mask ); | 160 | pixmap->setMask( mask ); |
165 | return pixmap; | 161 | return pixmap; |
166 | } | 162 | } |
167 | 163 | ||
168 | void VideoWidget::resizeEvent( QResizeEvent * ) { | 164 | void VideoWidget::resizeEvent( QResizeEvent * ) { |
169 | int h = height(); | 165 | int h = height(); |
170 | int w = width(); | 166 | int w = width(); |
171 | //int Vh = 160; | 167 | //int Vh = 160; |
172 | //int Vw = 220; | 168 | //int Vw = 220; |
173 | 169 | ||
174 | slider->setFixedWidth( w - 20 ); | 170 | slider->setFixedWidth( w - 20 ); |
175 | slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); | 171 | slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); |
176 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); | 172 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); |
177 | slider->setFocusPolicy( QWidget::NoFocus ); | 173 | slider->setFocusPolicy( QWidget::NoFocus ); |
178 | slider->setBackgroundPixmap( pixBg ); | 174 | slider->setBackgroundPixmap( pixBg ); |
179 | 175 | ||
180 | upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; | 176 | upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; |
181 | if(w>h) | 177 | if(w>h) |
182 | upperLeftOfButtonMask.ry() = 0; | 178 | upperLeftOfButtonMask.ry() = 0; |
183 | else | 179 | else |
184 | upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; | 180 | upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; |
185 | QPoint p = upperLeftOfButtonMask; | 181 | QPoint p = upperLeftOfButtonMask; |
186 | 182 | ||
187 | QPixmap *pixUp = combineVImageWithBackground( imgUp, pixBg, p ); | 183 | QPixmap *pixUp = combineVImageWithBackground( imgUp, pixBg, p ); |
188 | QPixmap *pixDn = combineVImageWithBackground( imgDn, pixBg, p ); | 184 | QPixmap *pixDn = combineVImageWithBackground( imgDn, pixBg, p ); |
189 | 185 | ||
190 | for ( int i = 0; i < 7; i++ ) { | 186 | for ( int i = 0; i < 7; i++ ) { |
191 | if ( !masks[i]->isNull() ) { | 187 | Button &button = buttons[ i ]; |
188 | |||
189 | if ( !button.mask.isNull() ) { | ||
192 | delete buttonPixUp[i]; | 190 | delete buttonPixUp[i]; |
193 | delete buttonPixDown[i]; | 191 | delete buttonPixDown[i]; |
194 | buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); | 192 | buttonPixUp[i] = maskVPixToMask( *pixUp, button.mask ); |
195 | buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); | 193 | buttonPixDown[i] = maskVPixToMask( *pixDn, button.mask ); |
196 | } | 194 | } |
197 | } | 195 | } |
198 | 196 | ||
199 | delete pixUp; | 197 | delete pixUp; |
200 | delete pixDn; | 198 | delete pixDn; |
201 | } | 199 | } |
202 | 200 | ||
203 | static bool videoSliderBeingMoved = FALSE; | 201 | static bool videoSliderBeingMoved = FALSE; |
204 | 202 | ||
205 | void VideoWidget::sliderPressed() { | 203 | void VideoWidget::sliderPressed() { |
206 | videoSliderBeingMoved = TRUE; | 204 | videoSliderBeingMoved = TRUE; |
207 | } | 205 | } |
208 | 206 | ||
209 | void VideoWidget::sliderReleased() { | 207 | void VideoWidget::sliderReleased() { |
210 | videoSliderBeingMoved = FALSE; | 208 | videoSliderBeingMoved = FALSE; |
211 | if ( slider->width() == 0 ) { | 209 | if ( slider->width() == 0 ) { |
212 | return; | 210 | return; |
213 | } | 211 | } |
214 | long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); | 212 | long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); |
215 | mediaPlayerState.setPosition( val ); | 213 | mediaPlayerState.setPosition( val ); |
216 | } | 214 | } |
217 | 215 | ||
218 | void VideoWidget::setPosition( long i ) { | 216 | void VideoWidget::setPosition( long i ) { |
219 | updateSlider( i, mediaPlayerState.length() ); | 217 | updateSlider( i, mediaPlayerState.length() ); |
220 | } | 218 | } |
221 | 219 | ||
222 | 220 | ||
223 | void VideoWidget::setLength( long max ) { | 221 | void VideoWidget::setLength( long max ) { |
224 | updateSlider( mediaPlayerState.position(), max ); | 222 | updateSlider( mediaPlayerState.position(), max ); |
225 | } | 223 | } |
226 | 224 | ||
227 | void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) | 225 | void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) |
228 | { | 226 | { |
229 | if ( displayType == MediaPlayerState::Video ) { | 227 | if ( displayType == MediaPlayerState::Video ) { |
230 | makeVisible(); | 228 | makeVisible(); |
231 | return; | 229 | return; |
232 | } | 230 | } |
233 | 231 | ||
234 | // Effectively blank the view next time we show it so it looks nicer | 232 | // Effectively blank the view next time we show it so it looks nicer |
235 | scaledWidth = 0; | 233 | scaledWidth = 0; |
236 | scaledHeight = 0; | 234 | scaledHeight = 0; |
237 | hide(); | 235 | hide(); |
238 | } | 236 | } |
239 | 237 | ||
240 | void VideoWidget::updateSlider( long i, long max ) { | 238 | void VideoWidget::updateSlider( long i, long max ) { |
241 | // Will flicker too much if we don't do this | 239 | // Will flicker too much if we don't do this |
242 | if ( max == 0 ) { | 240 | if ( max == 0 ) { |
243 | return; | 241 | return; |
244 | } | 242 | } |
245 | int width = slider->width(); | 243 | int width = slider->width(); |
246 | int val = int((double)i * width / max); | 244 | int val = int((double)i * width / max); |
247 | if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { | 245 | if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { |
248 | if ( slider->value() != val ) { | 246 | if ( slider->value() != val ) { |
249 | slider->setValue( val ); | 247 | slider->setValue( val ); |
250 | } | 248 | } |
251 | if ( slider->maxValue() != width ) { | 249 | if ( slider->maxValue() != width ) { |
252 | slider->setMaxValue( width ); | 250 | slider->setMaxValue( width ); |
253 | } | 251 | } |
254 | } | 252 | } |
255 | } | 253 | } |
256 | 254 | ||
257 | void VideoWidget::setToggleButton( int i, bool down ) { | 255 | void VideoWidget::setToggleButton( int i, bool down ) { |
258 | if ( down != buttons[i].isDown ) { | 256 | if ( down != buttons[i].isDown ) { |
259 | toggleButton( i ); | 257 | toggleButton( i ); |
260 | } | 258 | } |
261 | } | 259 | } |
262 | 260 | ||
263 | void VideoWidget::paintButton( QPainter &p, int i ) { | 261 | void VideoWidget::paintButton( QPainter &p, int i ) { |
264 | 262 | ||
265 | if ( buttons[i].isDown ) { | 263 | if ( buttons[i].isDown ) { |
266 | p.drawPixmap( upperLeftOfButtonMask, *buttonPixDown[i] ); | 264 | p.drawPixmap( upperLeftOfButtonMask, *buttonPixDown[i] ); |
267 | } else { | 265 | } else { |
268 | p.drawPixmap( upperLeftOfButtonMask, *buttonPixUp[i] ); | 266 | p.drawPixmap( upperLeftOfButtonMask, *buttonPixUp[i] ); |
269 | } | 267 | } |
270 | } | 268 | } |
271 | 269 | ||
272 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 270 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
273 | for ( unsigned int i = 0; i < buttons.count(); i++ ) { | 271 | for ( unsigned int i = 0; i < buttons.count(); i++ ) { |
274 | if ( event->state() == QMouseEvent::LeftButton ) { | 272 | if ( event->state() == QMouseEvent::LeftButton ) { |
275 | // The test to see if the mouse click is inside the button or not | 273 | // The test to see if the mouse click is inside the button or not |
276 | bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); | 274 | bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); |
277 | 275 | ||
278 | if ( isOnButton && !buttons[i].isHeld ) { | 276 | if ( isOnButton && !buttons[i].isHeld ) { |
279 | buttons[i].isHeld = TRUE; | 277 | buttons[i].isHeld = TRUE; |
280 | toggleButton(i); | 278 | toggleButton(i); |
281 | 279 | ||
282 | switch (i) { | 280 | switch (i) { |
283 | case VideoVolUp: | 281 | case VideoVolUp: |
284 | emit moreClicked(); | 282 | emit moreClicked(); |
285 | return; | 283 | return; |
286 | case VideoVolDown: | 284 | case VideoVolDown: |
287 | emit lessClicked(); | 285 | emit lessClicked(); |
288 | return; | 286 | return; |
289 | } | 287 | } |
290 | } else if ( !isOnButton && buttons[i].isHeld ) { | 288 | } else if ( !isOnButton && buttons[i].isHeld ) { |
291 | buttons[i].isHeld = FALSE; | 289 | buttons[i].isHeld = FALSE; |
292 | toggleButton(i); | 290 | toggleButton(i); |
293 | } | 291 | } |
294 | } else { | 292 | } else { |
295 | 293 | ||
296 | if ( buttons[i].isHeld ) { | 294 | if ( buttons[i].isHeld ) { |
297 | buttons[i].isHeld = FALSE; | 295 | buttons[i].isHeld = FALSE; |
298 | if ( buttons[i].type != ToggleButton ) { | 296 | if ( buttons[i].type != ToggleButton ) { |
299 | setToggleButton( i, FALSE ); | 297 | setToggleButton( i, FALSE ); |
300 | } | 298 | } |
301 | 299 | ||
302 | switch(i) { | 300 | switch(i) { |
303 | 301 | ||
304 | case VideoPlay: { | 302 | case VideoPlay: { |
305 | if( mediaPlayerState.isPaused() ) { | 303 | if( mediaPlayerState.isPaused() ) { |
306 | setToggleButton( i, FALSE ); | 304 | setToggleButton( i, FALSE ); |
307 | mediaPlayerState.setPaused( FALSE ); | 305 | mediaPlayerState.setPaused( FALSE ); |
308 | return; | 306 | return; |
309 | } else if( !mediaPlayerState.isPaused() ) { | 307 | } else if( !mediaPlayerState.isPaused() ) { |
310 | setToggleButton( i, TRUE ); | 308 | setToggleButton( i, TRUE ); |
311 | mediaPlayerState.setPaused( TRUE ); | 309 | mediaPlayerState.setPaused( TRUE ); |
312 | return; | 310 | return; |
313 | } else { | 311 | } else { |
314 | return; | 312 | return; |
315 | } | 313 | } |
316 | } | 314 | } |
317 | 315 | ||
318 | case VideoStop: mediaPlayerState.setPlaying( FALSE ); return; | 316 | case VideoStop: mediaPlayerState.setPlaying( FALSE ); return; |
319 | case VideoNext: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; | 317 | case VideoNext: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; |
320 | case VideoPrevious: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; | 318 | case VideoPrevious: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; |
321 | case VideoVolUp: emit moreReleased(); return; | 319 | case VideoVolUp: emit moreReleased(); return; |
322 | case VideoVolDown: emit lessReleased(); return; | 320 | case VideoVolDown: emit lessReleased(); return; |
323 | case VideoFullscreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return; | 321 | case VideoFullscreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return; |
324 | } | 322 | } |
325 | } | 323 | } |
326 | } | 324 | } |
327 | } | 325 | } |
328 | } | 326 | } |
329 | 327 | ||
330 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { | 328 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { |
331 | mouseMoveEvent( event ); | 329 | mouseMoveEvent( event ); |
332 | } | 330 | } |
333 | 331 | ||
334 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 332 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
335 | if ( mediaPlayerState.isFullscreen() ) { | 333 | if ( mediaPlayerState.isFullscreen() ) { |
336 | mediaPlayerState.setFullscreen( FALSE ); | 334 | mediaPlayerState.setFullscreen( FALSE ); |
337 | makeVisible(); | 335 | makeVisible(); |
338 | } | 336 | } |
339 | mouseMoveEvent( event ); | 337 | mouseMoveEvent( event ); |
340 | } | 338 | } |
341 | 339 | ||
342 | void VideoWidget::showEvent( QShowEvent* ) { | 340 | void VideoWidget::showEvent( QShowEvent* ) { |
343 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 341 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
344 | mouseMoveEvent( &event ); | 342 | mouseMoveEvent( &event ); |
345 | } | 343 | } |
346 | 344 | ||
347 | 345 | ||
348 | void VideoWidget::backToNormal() { | 346 | void VideoWidget::backToNormal() { |
349 | mediaPlayerState.setFullscreen( FALSE ); | 347 | mediaPlayerState.setFullscreen( FALSE ); |
350 | makeVisible(); | 348 | makeVisible(); |
351 | } | 349 | } |
352 | 350 | ||
353 | void VideoWidget::makeVisible() { | 351 | void VideoWidget::makeVisible() { |
354 | if ( mediaPlayerState.isFullscreen() ) { | 352 | if ( mediaPlayerState.isFullscreen() ) { |
355 | setBackgroundMode( QWidget::NoBackground ); | 353 | setBackgroundMode( QWidget::NoBackground ); |
356 | showFullScreen(); | 354 | showFullScreen(); |
357 | resize( qApp->desktop()->size() ); | 355 | resize( qApp->desktop()->size() ); |
358 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); | 356 | videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); |
359 | 357 | ||
360 | slider->hide(); | 358 | slider->hide(); |
361 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 359 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
362 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 360 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
363 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 361 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
364 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 362 | disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
365 | 363 | ||
366 | } else { | 364 | } else { |
367 | showNormal(); | 365 | showNormal(); |
368 | showMaximized(); | 366 | showMaximized(); |
369 | setBackgroundPixmap( pixBg ); | 367 | setBackgroundPixmap( pixBg ); |
370 | QWidget *d = QApplication::desktop(); | 368 | QWidget *d = QApplication::desktop(); |
371 | int w = d->width(); | 369 | int w = d->width(); |
372 | int h = d->height(); | 370 | int h = d->height(); |
373 | 371 | ||
374 | if(w>h) { | 372 | if(w>h) { |
375 | int newW=(w/2)-(246/2); //this will only work with 320x240 | 373 | int newW=(w/2)-(246/2); //this will only work with 320x240 |
376 | videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); | 374 | videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); |
377 | } else { | 375 | } else { |
378 | videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); | 376 | videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); |
379 | } | 377 | } |
380 | 378 | ||
381 | if ( !mediaPlayerState.isSeekable() ) { | 379 | if ( !mediaPlayerState.isSeekable() ) { |
382 | if( !slider->isHidden()) { | 380 | if( !slider->isHidden()) { |
383 | slider->hide(); | 381 | slider->hide(); |
384 | } | 382 | } |
385 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 383 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
386 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 384 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
387 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 385 | disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h index cb6171c..fd301f9 100644 --- a/noncore/multimedia/opieplayer2/videowidget.h +++ b/noncore/multimedia/opieplayer2/videowidget.h | |||
@@ -1,125 +1,123 @@ | |||
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 | #ifndef VIDEO_WIDGET_H | 34 | #ifndef VIDEO_WIDGET_H |
35 | #define VIDEO_WIDGET_H | 35 | #define VIDEO_WIDGET_H |
36 | 36 | ||
37 | #include <qwidget.h> | 37 | #include <qwidget.h> |
38 | #include <qimage.h> | 38 | #include <qimage.h> |
39 | #include <qpixmap.h> | 39 | #include <qpixmap.h> |
40 | #include "xinevideowidget.h" | 40 | #include "xinevideowidget.h" |
41 | 41 | ||
42 | #include "mediawidget.h" | 42 | #include "mediawidget.h" |
43 | 43 | ||
44 | class QPixmap; | 44 | class QPixmap; |
45 | class QSlider; | 45 | class QSlider; |
46 | 46 | ||
47 | enum VideoButtons { | 47 | enum VideoButtons { |
48 | VideoPlay = 0, | 48 | VideoPlay = 0, |
49 | VideoStop, | 49 | VideoStop, |
50 | // VideoPause, | 50 | // VideoPause, |
51 | VideoNext, | 51 | VideoNext, |
52 | VideoPrevious, | 52 | VideoPrevious, |
53 | VideoVolUp, | 53 | VideoVolUp, |
54 | VideoVolDown, | 54 | VideoVolDown, |
55 | VideoFullscreen | 55 | VideoFullscreen |
56 | }; | 56 | }; |
57 | 57 | ||
58 | class VideoWidget : public MediaWidget { | 58 | class VideoWidget : public MediaWidget { |
59 | Q_OBJECT | 59 | Q_OBJECT |
60 | public: | 60 | public: |
61 | VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); | 61 | VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); |
62 | ~VideoWidget(); | 62 | ~VideoWidget(); |
63 | 63 | ||
64 | 64 | ||
65 | XineVideoWidget* vidWidget(); | 65 | XineVideoWidget* vidWidget(); |
66 | public slots: | 66 | public slots: |
67 | void updateSlider( long, long ); | 67 | void updateSlider( long, long ); |
68 | void sliderPressed( ); | 68 | void sliderPressed( ); |
69 | void sliderReleased( ); | 69 | void sliderReleased( ); |
70 | void setFullscreen( bool b ); | 70 | void setFullscreen( bool b ); |
71 | void makeVisible(); | 71 | void makeVisible(); |
72 | void backToNormal(); | 72 | void backToNormal(); |
73 | void setPosition( long ); | 73 | void setPosition( long ); |
74 | 74 | ||
75 | public: | 75 | public: |
76 | virtual void setPlaying( bool b); | 76 | virtual void setPlaying( bool b); |
77 | virtual void setLength( long ); | 77 | virtual void setLength( long ); |
78 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); | 78 | virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); |
79 | 79 | ||
80 | signals: | 80 | signals: |
81 | void moreClicked(); | 81 | void moreClicked(); |
82 | void lessClicked(); | 82 | void lessClicked(); |
83 | void moreReleased(); | 83 | void moreReleased(); |
84 | void lessReleased(); | 84 | void lessReleased(); |
85 | void sliderMoved( long ); | 85 | void sliderMoved( long ); |
86 | void videoResized ( const QSize &s ); | 86 | void videoResized ( const QSize &s ); |
87 | 87 | ||
88 | protected: | 88 | protected: |
89 | 89 | ||
90 | void resizeEvent( QResizeEvent * ); | 90 | void resizeEvent( QResizeEvent * ); |
91 | void paintEvent( QPaintEvent *pe ); | 91 | void paintEvent( QPaintEvent *pe ); |
92 | void showEvent( QShowEvent *se ); | 92 | void showEvent( QShowEvent *se ); |
93 | void mouseMoveEvent( QMouseEvent *event ); | 93 | void mouseMoveEvent( QMouseEvent *event ); |
94 | void mousePressEvent( QMouseEvent *event ); | 94 | void mousePressEvent( QMouseEvent *event ); |
95 | void mouseReleaseEvent( QMouseEvent *event ); | 95 | void mouseReleaseEvent( QMouseEvent *event ); |
96 | void keyReleaseEvent( QKeyEvent *e); | 96 | void keyReleaseEvent( QKeyEvent *e); |
97 | 97 | ||
98 | private: | 98 | private: |
99 | // Ticker songInfo; | 99 | // Ticker songInfo; |
100 | QPixmap pixBg; | 100 | QPixmap pixBg; |
101 | QImage imgUp; | 101 | QImage imgUp; |
102 | QImage imgDn; | 102 | QImage imgDn; |
103 | QBitmap *masks[7]; | ||
104 | QPixmap *buttonPixUp[7]; | 103 | QPixmap *buttonPixUp[7]; |
105 | QPixmap *buttonPixDown[7]; | 104 | QPixmap *buttonPixDown[7]; |
106 | QString skin; | 105 | QString skin; |
107 | // QPixmap *pixmaps[4]; | ||
108 | 106 | ||
109 | 107 | ||
110 | virtual void paintButton( QPainter &p, int i ); | 108 | virtual void paintButton( QPainter &p, int i ); |
111 | void setToggleButton( int, bool ); | 109 | void setToggleButton( int, bool ); |
112 | 110 | ||
113 | QString backgroundPix; | 111 | QString backgroundPix; |
114 | QSlider *slider; | 112 | QSlider *slider; |
115 | QPixmap *pixmaps[3]; | 113 | QPixmap *pixmaps[3]; |
116 | QImage *currentFrame; | 114 | QImage *currentFrame; |
117 | int scaledWidth; | 115 | int scaledWidth; |
118 | int scaledHeight; | 116 | int scaledHeight; |
119 | XineVideoWidget* videoFrame; | 117 | XineVideoWidget* videoFrame; |
120 | }; | 118 | }; |
121 | 119 | ||
122 | #endif // VIDEO_WIDGET_H | 120 | #endif // VIDEO_WIDGET_H |
123 | 121 | ||
124 | 122 | ||
125 | 123 | ||