-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 6 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.h | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 77eab71..2f51c82 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -1,339 +1,339 @@ | |||
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 | "stop","play","back","fwd","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 | defaultButton.isToggle = defaultButton.isHeld = defaultButton.isDown = false; | 74 | defaultButton.isToggle = defaultButton.isHeld = defaultButton.isDown = false; |
75 | Button toggleButton; | 75 | Button toggleButton; |
76 | toggleButton.isToggle = true; | 76 | toggleButton.isToggle = true; |
77 | toggleButton.isHeld = toggleButton.isDown = false; | 77 | toggleButton.isHeld = toggleButton.isDown = false; |
78 | 78 | ||
79 | buttons.reserve( 7 ); | 79 | buttons.reserve( 7 ); |
80 | buttons.push_back( defaultButton ); // stop | ||
81 | buttons.push_back( toggleButton ); // play | 80 | buttons.push_back( toggleButton ); // play |
82 | buttons.push_back( defaultButton ); // previous | 81 | buttons.push_back( defaultButton ); // stop |
83 | buttons.push_back( defaultButton ); // next | 82 | buttons.push_back( defaultButton ); // next |
83 | buttons.push_back( defaultButton ); // previous | ||
84 | buttons.push_back( defaultButton ); // volUp | 84 | buttons.push_back( defaultButton ); // volUp |
85 | buttons.push_back( defaultButton ); // volDown | 85 | buttons.push_back( defaultButton ); // volDown |
86 | buttons.push_back( toggleButton ); //fullscreen | 86 | buttons.push_back( toggleButton ); //fullscreen |
87 | 87 | ||
88 | videoFrame = new XineVideoWidget ( this, "Video frame" ); | 88 | videoFrame = new XineVideoWidget ( this, "Video frame" ); |
89 | 89 | ||
90 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); | 90 | connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); |
91 | connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); | 91 | connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); |
92 | 92 | ||
93 | Config cfg("OpiePlayer"); | 93 | Config cfg("OpiePlayer"); |
94 | cfg.setGroup("Options"); | 94 | cfg.setGroup("Options"); |
95 | skin = cfg.readEntry("Skin","default"); | 95 | skin = cfg.readEntry("Skin","default"); |
96 | 96 | ||
97 | QString skinPath = "opieplayer2/skins/" + skin; | 97 | QString skinPath = "opieplayer2/skins/" + skin; |
98 | pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 98 | pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
99 | imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); | 99 | imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); |
100 | imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); | 100 | imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); |
101 | 101 | ||
102 | buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); | 102 | buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); |
103 | buttonMask.fill( 0 ); | 103 | buttonMask.fill( 0 ); |
104 | 104 | ||
105 | for ( int i = 0; i < 7; i++ ) { | 105 | for ( int i = 0; i < 7; i++ ) { |
106 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); | 106 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); |
107 | masks[i] = new QBitmap( filename ); | 107 | masks[i] = new QBitmap( filename ); |
108 | 108 | ||
109 | if ( !masks[i]->isNull() ) { | 109 | if ( !masks[i]->isNull() ) { |
110 | QImage imgMask = masks[i]->convertToImage(); | 110 | QImage imgMask = masks[i]->convertToImage(); |
111 | uchar **dest = buttonMask.jumpTable(); | 111 | uchar **dest = buttonMask.jumpTable(); |
112 | for ( int y = 0; y < imgUp.height(); y++ ) { | 112 | for ( int y = 0; y < imgUp.height(); y++ ) { |
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 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 115 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
116 | line[x] = i + 1; | 116 | line[x] = i + 1; |
117 | } | 117 | } |
118 | } | 118 | } |
119 | } | 119 | } |
120 | } | 120 | } |
121 | 121 | ||
122 | for ( int i = 0; i < 7; i++ ) { | 122 | for ( int i = 0; i < 7; i++ ) { |
123 | buttonPixUp[i] = NULL; | 123 | buttonPixUp[i] = NULL; |
124 | buttonPixDown[i] = NULL; | 124 | buttonPixDown[i] = NULL; |
125 | } | 125 | } |
126 | 126 | ||
127 | setBackgroundPixmap( pixBg ); | 127 | setBackgroundPixmap( pixBg ); |
128 | 128 | ||
129 | slider = new QSlider( Qt::Horizontal, this ); | 129 | slider = new QSlider( Qt::Horizontal, this ); |
130 | slider->setMinValue( 0 ); | 130 | slider->setMinValue( 0 ); |
131 | slider->setMaxValue( 1 ); | 131 | slider->setMaxValue( 1 ); |
132 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); | 132 | slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); |
133 | //slider->setFocusPolicy( QWidget::NoFocus ); | 133 | //slider->setFocusPolicy( QWidget::NoFocus ); |
134 | 134 | ||
135 | resizeEvent( NULL ); | 135 | resizeEvent( NULL ); |
136 | 136 | ||
137 | setLength( mediaPlayerState.length() ); | 137 | setLength( mediaPlayerState.length() ); |
138 | setPosition( mediaPlayerState.position() ); | 138 | setPosition( mediaPlayerState.position() ); |
139 | setFullscreen( mediaPlayerState.isFullscreen() ); | 139 | setFullscreen( mediaPlayerState.isFullscreen() ); |
140 | setPlaying( mediaPlayerState.isPlaying() ); | 140 | setPlaying( mediaPlayerState.isPlaying() ); |
141 | } | 141 | } |
142 | 142 | ||
143 | 143 | ||
144 | VideoWidget::~VideoWidget() { | 144 | VideoWidget::~VideoWidget() { |
145 | 145 | ||
146 | for ( int i = 0; i < 7; i++ ) { | 146 | for ( int i = 0; i < 7; i++ ) { |
147 | delete buttonPixUp[i]; | 147 | delete buttonPixUp[i]; |
148 | delete buttonPixDown[i]; | 148 | delete buttonPixDown[i]; |
149 | } | 149 | } |
150 | 150 | ||
151 | for ( int i = 0; i < 7; i++ ) { | 151 | for ( int i = 0; i < 7; i++ ) { |
152 | delete masks[i]; | 152 | delete masks[i]; |
153 | } | 153 | } |
154 | 154 | ||
155 | } | 155 | } |
156 | 156 | ||
157 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 157 | QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
158 | QPixmap pix( img.width(), img.height() ); | 158 | QPixmap pix( img.width(), img.height() ); |
159 | QPainter p( &pix ); | 159 | QPainter p( &pix ); |
160 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 160 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
161 | p.drawImage( 0, 0, img ); | 161 | p.drawImage( 0, 0, img ); |
162 | return new QPixmap( pix ); | 162 | return new QPixmap( pix ); |
163 | } | 163 | } |
164 | 164 | ||
165 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { | 165 | QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { |
166 | QPixmap *pixmap = new QPixmap( pix ); | 166 | QPixmap *pixmap = new QPixmap( pix ); |
167 | pixmap->setMask( mask ); | 167 | pixmap->setMask( mask ); |
168 | return pixmap; | 168 | return pixmap; |
169 | } | 169 | } |
170 | 170 | ||
171 | void VideoWidget::resizeEvent( QResizeEvent * ) { | 171 | void VideoWidget::resizeEvent( QResizeEvent * ) { |
172 | int h = height(); | 172 | int h = height(); |
173 | int w = width(); | 173 | int w = width(); |
174 | //int Vh = 160; | 174 | //int Vh = 160; |
175 | //int Vw = 220; | 175 | //int Vw = 220; |
176 | 176 | ||
177 | slider->setFixedWidth( w - 20 ); | 177 | slider->setFixedWidth( w - 20 ); |
178 | slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); | 178 | slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); |
179 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); | 179 | slider->setBackgroundOrigin( QWidget::ParentOrigin ); |
180 | slider->setFocusPolicy( QWidget::NoFocus ); | 180 | slider->setFocusPolicy( QWidget::NoFocus ); |
181 | slider->setBackgroundPixmap( pixBg ); | 181 | slider->setBackgroundPixmap( pixBg ); |
182 | 182 | ||
183 | upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; | 183 | upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; |
184 | if(w>h) | 184 | if(w>h) |
185 | upperLeftOfButtonMask.ry() = 0; | 185 | upperLeftOfButtonMask.ry() = 0; |
186 | else | 186 | else |
187 | upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; | 187 | upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; |
188 | QPoint p = upperLeftOfButtonMask; | 188 | QPoint p = upperLeftOfButtonMask; |
189 | 189 | ||
190 | QPixmap *pixUp = combineVImageWithBackground( imgUp, pixBg, p ); | 190 | QPixmap *pixUp = combineVImageWithBackground( imgUp, pixBg, p ); |
191 | QPixmap *pixDn = combineVImageWithBackground( imgDn, pixBg, p ); | 191 | QPixmap *pixDn = combineVImageWithBackground( imgDn, pixBg, p ); |
192 | 192 | ||
193 | for ( int i = 0; i < 7; i++ ) { | 193 | for ( int i = 0; i < 7; i++ ) { |
194 | if ( !masks[i]->isNull() ) { | 194 | if ( !masks[i]->isNull() ) { |
195 | delete buttonPixUp[i]; | 195 | delete buttonPixUp[i]; |
196 | delete buttonPixDown[i]; | 196 | delete buttonPixDown[i]; |
197 | buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); | 197 | buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); |
198 | buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); | 198 | buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); |
199 | } | 199 | } |
200 | } | 200 | } |
201 | 201 | ||
202 | delete pixUp; | 202 | delete pixUp; |
203 | delete pixDn; | 203 | delete pixDn; |
204 | } | 204 | } |
205 | 205 | ||
206 | static bool videoSliderBeingMoved = FALSE; | 206 | static bool videoSliderBeingMoved = FALSE; |
207 | 207 | ||
208 | void VideoWidget::sliderPressed() { | 208 | void VideoWidget::sliderPressed() { |
209 | videoSliderBeingMoved = TRUE; | 209 | videoSliderBeingMoved = TRUE; |
210 | } | 210 | } |
211 | 211 | ||
212 | void VideoWidget::sliderReleased() { | 212 | void VideoWidget::sliderReleased() { |
213 | videoSliderBeingMoved = FALSE; | 213 | videoSliderBeingMoved = FALSE; |
214 | if ( slider->width() == 0 ) { | 214 | if ( slider->width() == 0 ) { |
215 | return; | 215 | return; |
216 | } | 216 | } |
217 | long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); | 217 | long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); |
218 | mediaPlayerState.setPosition( val ); | 218 | mediaPlayerState.setPosition( val ); |
219 | } | 219 | } |
220 | 220 | ||
221 | void VideoWidget::setPosition( long i ) { | 221 | void VideoWidget::setPosition( long i ) { |
222 | updateSlider( i, mediaPlayerState.length() ); | 222 | updateSlider( i, mediaPlayerState.length() ); |
223 | } | 223 | } |
224 | 224 | ||
225 | 225 | ||
226 | void VideoWidget::setLength( long max ) { | 226 | void VideoWidget::setLength( long max ) { |
227 | updateSlider( mediaPlayerState.position(), max ); | 227 | updateSlider( mediaPlayerState.position(), max ); |
228 | } | 228 | } |
229 | 229 | ||
230 | void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) | 230 | void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) |
231 | { | 231 | { |
232 | if ( displayType == MediaPlayerState::Video ) { | 232 | if ( displayType == MediaPlayerState::Video ) { |
233 | makeVisible(); | 233 | makeVisible(); |
234 | return; | 234 | return; |
235 | } | 235 | } |
236 | 236 | ||
237 | // Effectively blank the view next time we show it so it looks nicer | 237 | // Effectively blank the view next time we show it so it looks nicer |
238 | scaledWidth = 0; | 238 | scaledWidth = 0; |
239 | scaledHeight = 0; | 239 | scaledHeight = 0; |
240 | hide(); | 240 | hide(); |
241 | } | 241 | } |
242 | 242 | ||
243 | void VideoWidget::updateSlider( long i, long max ) { | 243 | void VideoWidget::updateSlider( long i, long max ) { |
244 | // Will flicker too much if we don't do this | 244 | // Will flicker too much if we don't do this |
245 | if ( max == 0 ) { | 245 | if ( max == 0 ) { |
246 | return; | 246 | return; |
247 | } | 247 | } |
248 | int width = slider->width(); | 248 | int width = slider->width(); |
249 | int val = int((double)i * width / max); | 249 | int val = int((double)i * width / max); |
250 | if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { | 250 | if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { |
251 | if ( slider->value() != val ) { | 251 | if ( slider->value() != val ) { |
252 | slider->setValue( val ); | 252 | slider->setValue( val ); |
253 | } | 253 | } |
254 | if ( slider->maxValue() != width ) { | 254 | if ( slider->maxValue() != width ) { |
255 | slider->setMaxValue( width ); | 255 | slider->setMaxValue( width ); |
256 | } | 256 | } |
257 | } | 257 | } |
258 | } | 258 | } |
259 | 259 | ||
260 | void VideoWidget::setToggleButton( int i, bool down ) { | 260 | void VideoWidget::setToggleButton( int i, bool down ) { |
261 | if ( down != buttons[i].isDown ) { | 261 | if ( down != buttons[i].isDown ) { |
262 | toggleButton( i ); | 262 | toggleButton( i ); |
263 | } | 263 | } |
264 | } | 264 | } |
265 | 265 | ||
266 | void VideoWidget::paintButton( QPainter &p, int i ) { | 266 | void VideoWidget::paintButton( QPainter &p, int i ) { |
267 | 267 | ||
268 | if ( buttons[i].isDown ) { | 268 | if ( buttons[i].isDown ) { |
269 | p.drawPixmap( upperLeftOfButtonMask, *buttonPixDown[i] ); | 269 | p.drawPixmap( upperLeftOfButtonMask, *buttonPixDown[i] ); |
270 | } else { | 270 | } else { |
271 | p.drawPixmap( upperLeftOfButtonMask, *buttonPixUp[i] ); | 271 | p.drawPixmap( upperLeftOfButtonMask, *buttonPixUp[i] ); |
272 | } | 272 | } |
273 | } | 273 | } |
274 | 274 | ||
275 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 275 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
276 | for ( unsigned int i = 0; i < buttons.size(); i++ ) { | 276 | for ( unsigned int i = 0; i < buttons.size(); i++ ) { |
277 | if ( event->state() == QMouseEvent::LeftButton ) { | 277 | if ( event->state() == QMouseEvent::LeftButton ) { |
278 | // The test to see if the mouse click is inside the button or not | 278 | // The test to see if the mouse click is inside the button or not |
279 | bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); | 279 | bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, i ); |
280 | 280 | ||
281 | if ( isOnButton && !buttons[i].isHeld ) { | 281 | if ( isOnButton && !buttons[i].isHeld ) { |
282 | buttons[i].isHeld = TRUE; | 282 | buttons[i].isHeld = TRUE; |
283 | toggleButton(i); | 283 | toggleButton(i); |
284 | 284 | ||
285 | switch (i) { | 285 | switch (i) { |
286 | case VideoVolUp: | 286 | case VideoVolUp: |
287 | emit moreClicked(); | 287 | emit moreClicked(); |
288 | return; | 288 | return; |
289 | case VideoVolDown: | 289 | case VideoVolDown: |
290 | emit lessClicked(); | 290 | emit lessClicked(); |
291 | return; | 291 | return; |
292 | } | 292 | } |
293 | } else if ( !isOnButton && buttons[i].isHeld ) { | 293 | } else if ( !isOnButton && buttons[i].isHeld ) { |
294 | buttons[i].isHeld = FALSE; | 294 | buttons[i].isHeld = FALSE; |
295 | toggleButton(i); | 295 | toggleButton(i); |
296 | } | 296 | } |
297 | } else { | 297 | } else { |
298 | 298 | ||
299 | if ( buttons[i].isHeld ) { | 299 | if ( buttons[i].isHeld ) { |
300 | buttons[i].isHeld = FALSE; | 300 | buttons[i].isHeld = FALSE; |
301 | if ( !buttons[i].isToggle ) { | 301 | if ( !buttons[i].isToggle ) { |
302 | setToggleButton( i, FALSE ); | 302 | setToggleButton( i, FALSE ); |
303 | } | 303 | } |
304 | 304 | ||
305 | switch(i) { | 305 | switch(i) { |
306 | 306 | ||
307 | case VideoPlay: { | 307 | case VideoPlay: { |
308 | if( mediaPlayerState.isPaused() ) { | 308 | if( mediaPlayerState.isPaused() ) { |
309 | setToggleButton( i, FALSE ); | 309 | setToggleButton( i, FALSE ); |
310 | mediaPlayerState.setPaused( FALSE ); | 310 | mediaPlayerState.setPaused( FALSE ); |
311 | return; | 311 | return; |
312 | } else if( !mediaPlayerState.isPaused() ) { | 312 | } else if( !mediaPlayerState.isPaused() ) { |
313 | setToggleButton( i, TRUE ); | 313 | setToggleButton( i, TRUE ); |
314 | mediaPlayerState.setPaused( TRUE ); | 314 | mediaPlayerState.setPaused( TRUE ); |
315 | return; | 315 | return; |
316 | } else { | 316 | } else { |
317 | return; | 317 | return; |
318 | } | 318 | } |
319 | } | 319 | } |
320 | 320 | ||
321 | case VideoStop: mediaPlayerState.setPlaying( FALSE ); return; | 321 | case VideoStop: mediaPlayerState.setPlaying( FALSE ); return; |
322 | case VideoNext: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; | 322 | case VideoNext: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; |
323 | case VideoPrevious: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; | 323 | case VideoPrevious: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; |
324 | case VideoVolUp: emit moreReleased(); return; | 324 | case VideoVolUp: emit moreReleased(); return; |
325 | case VideoVolDown: emit lessReleased(); return; | 325 | case VideoVolDown: emit lessReleased(); return; |
326 | case VideoFullscreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return; | 326 | case VideoFullscreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return; |
327 | } | 327 | } |
328 | } | 328 | } |
329 | } | 329 | } |
330 | } | 330 | } |
331 | } | 331 | } |
332 | 332 | ||
333 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { | 333 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { |
334 | mouseMoveEvent( event ); | 334 | mouseMoveEvent( event ); |
335 | } | 335 | } |
336 | 336 | ||
337 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 337 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
338 | if ( mediaPlayerState.isFullscreen() ) { | 338 | if ( mediaPlayerState.isFullscreen() ) { |
339 | mediaPlayerState.setFullscreen( FALSE ); | 339 | mediaPlayerState.setFullscreen( FALSE ); |
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h index 24e8741..cb6171c 100644 --- a/noncore/multimedia/opieplayer2/videowidget.h +++ b/noncore/multimedia/opieplayer2/videowidget.h | |||
@@ -1,125 +1,125 @@ | |||
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 | VideoStop = 0, | 48 | VideoPlay = 0, |
49 | VideoPlay, | 49 | VideoStop, |
50 | // VideoPause, | 50 | // VideoPause, |
51 | VideoPrevious, | ||
52 | VideoNext, | 51 | VideoNext, |
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]; | 103 | QBitmap *masks[7]; |
104 | QPixmap *buttonPixUp[7]; | 104 | QPixmap *buttonPixUp[7]; |
105 | QPixmap *buttonPixDown[7]; | 105 | QPixmap *buttonPixDown[7]; |
106 | QString skin; | 106 | QString skin; |
107 | // QPixmap *pixmaps[4]; | 107 | // QPixmap *pixmaps[4]; |
108 | 108 | ||
109 | 109 | ||
110 | virtual void paintButton( QPainter &p, int i ); | 110 | virtual void paintButton( QPainter &p, int i ); |
111 | void setToggleButton( int, bool ); | 111 | void setToggleButton( int, bool ); |
112 | 112 | ||
113 | QString backgroundPix; | 113 | QString backgroundPix; |
114 | QSlider *slider; | 114 | QSlider *slider; |
115 | QPixmap *pixmaps[3]; | 115 | QPixmap *pixmaps[3]; |
116 | QImage *currentFrame; | 116 | QImage *currentFrame; |
117 | int scaledWidth; | 117 | int scaledWidth; |
118 | int scaledHeight; | 118 | int scaledHeight; |
119 | XineVideoWidget* videoFrame; | 119 | XineVideoWidget* videoFrame; |
120 | }; | 120 | }; |
121 | 121 | ||
122 | #endif // VIDEO_WIDGET_H | 122 | #endif // VIDEO_WIDGET_H |
123 | 123 | ||
124 | 124 | ||
125 | 125 | ||