author | harlekin <harlekin> | 2002-04-20 21:39:03 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-04-20 21:39:03 (UTC) |
commit | e657b8203c7b649fd3df96afbe7f8b1d24b5b8ed (patch) (unidiff) | |
tree | 327c776a79f6444f38dc1bbddf1e530dabce8972 | |
parent | 22dc731f503383e95c49d88ca4e9c32c7ed4fb3a (diff) | |
download | opie-e657b8203c7b649fd3df96afbe7f8b1d24b5b8ed.zip opie-e657b8203c7b649fd3df96afbe7f8b1d24b5b8ed.tar.gz opie-e657b8203c7b649fd3df96afbe7f8b1d24b5b8ed.tar.bz2 |
updated paths for icons
-rw-r--r-- | core/multimedia/opieplayer/audiowidget.cpp | 16 | ||||
-rw-r--r-- | core/multimedia/opieplayer/videowidget.cpp | 36 |
2 files changed, 26 insertions, 26 deletions
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp index cda3f77..3212001 100644 --- a/core/multimedia/opieplayer/audiowidget.cpp +++ b/core/multimedia/opieplayer/audiowidget.cpp | |||
@@ -4,217 +4,217 @@ | |||
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/resource.h> | 21 | #include <qpe/resource.h> |
22 | 22 | ||
23 | #include <qwidget.h> | 23 | #include <qwidget.h> |
24 | #include <qpixmap.h> | 24 | #include <qpixmap.h> |
25 | #include <qbutton.h> | 25 | #include <qbutton.h> |
26 | #include <qpainter.h> | 26 | #include <qpainter.h> |
27 | #include <qframe.h> | 27 | #include <qframe.h> |
28 | 28 | ||
29 | #include "audiowidget.h" | 29 | #include "audiowidget.h" |
30 | #include "mediaplayerstate.h" | 30 | #include "mediaplayerstate.h" |
31 | 31 | ||
32 | extern MediaPlayerState *mediaPlayerState; | 32 | extern MediaPlayerState *mediaPlayerState; |
33 | 33 | ||
34 | 34 | ||
35 | static const int xo = -2; // movable x offset | 35 | static const int xo = -2; // movable x offset |
36 | static const int yo = 22; // movable y offset | 36 | static const int yo = 22; // movable y offset |
37 | 37 | ||
38 | 38 | ||
39 | struct MediaButton { | 39 | struct MediaButton { |
40 | int xPos, yPos; | 40 | int xPos, yPos; |
41 | int color; | 41 | int color; |
42 | bool isToggle, isBig, isHeld, isDown; | 42 | bool isToggle, isBig, isHeld, isDown; |
43 | }; | 43 | }; |
44 | 44 | ||
45 | 45 | ||
46 | // Layout information for the audioButtons (and if it is a toggle button or not) | 46 | // Layout information for the audioButtons (and if it is a toggle button or not) |
47 | MediaButton audioButtons[] = { | 47 | MediaButton audioButtons[] = { |
48 | { 3*30-15+xo, 3*30-13+yo, 0, TRUE, TRUE, FALSE, FALSE }, // play | 48 | { 3*30-15+xo, 3*30-13+yo, 0, TRUE, TRUE, FALSE, FALSE }, // play |
49 | { 1*30+xo, 5*30+yo, 2, FALSE, FALSE, FALSE, FALSE }, // stop | 49 | { 1*30+xo, 5*30+yo, 2, FALSE, FALSE, FALSE, FALSE }, // stop |
50 | { 5*30+xo, 5*30+yo, 2, TRUE, FALSE, FALSE, FALSE }, // pause | 50 | { 5*30+xo, 5*30+yo, 2, TRUE, FALSE, FALSE, FALSE }, // pause |
51 | { 6*30-5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // next | 51 | { 6*30-5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // next |
52 | { 0*30+5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // previous | 52 | { 0*30+5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // previous |
53 | { 3*30+xo, 0*30+5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume up | 53 | { 3*30+xo, 0*30+5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume up |
54 | { 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down | 54 | { 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down |
55 | { 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop | 55 | { 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop |
56 | { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist | 56 | { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist |
57 | }; | 57 | }; |
58 | 58 | ||
59 | 59 | ||
60 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); | 60 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); |
61 | 61 | ||
62 | 62 | ||
63 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | 63 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : |
64 | QWidget( parent, name, f ) | 64 | QWidget( parent, name, f ) |
65 | { | 65 | { |
66 | // QPEApplication::grabKeyboard(); | 66 | // QPEApplication::grabKeyboard(); |
67 | setCaption( tr("OpiePlayer") ); | 67 | setCaption( tr("OpiePlayer") ); |
68 | setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); | 68 | setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); |
69 | pixmaps[0] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsAll" ) ); | 69 | pixmaps[0] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaButtonsAll" ) ); |
70 | pixmaps[1] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButtonsBig" ) ); | 70 | pixmaps[1] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaButtonsBig" ) ); |
71 | pixmaps[2] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaControls" ) ); | 71 | pixmaps[2] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaControls" ) ); |
72 | pixmaps[3] = new QPixmap( Resource::loadPixmap( "mpegplayer/animatedButton" ) ); | 72 | pixmaps[3] = new QPixmap( Resource::loadPixmap( "opieplayer/animatedButton" ) ); |
73 | 73 | ||
74 | songInfo = new Ticker( this ); | 74 | songInfo = new Ticker( this ); |
75 | songInfo->setFocusPolicy( QWidget::NoFocus ); | 75 | songInfo->setFocusPolicy( QWidget::NoFocus ); |
76 | songInfo->setGeometry( QRect( 7, 3, 220, 20 ) ); | 76 | songInfo->setGeometry( QRect( 7, 3, 220, 20 ) ); |
77 | 77 | ||
78 | slider = new QSlider( Qt::Horizontal, this ); | 78 | slider = new QSlider( Qt::Horizontal, this ); |
79 | slider->setFixedWidth( 220 ); | 79 | slider->setFixedWidth( 220 ); |
80 | slider->setFixedHeight( 20 ); | 80 | slider->setFixedHeight( 20 ); |
81 | slider->setMinValue( 0 ); | 81 | slider->setMinValue( 0 ); |
82 | slider->setMaxValue( 1 ); | 82 | slider->setMaxValue( 1 ); |
83 | slider->setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); | 83 | slider->setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); |
84 | slider->setFocusPolicy( QWidget::NoFocus ); | 84 | slider->setFocusPolicy( QWidget::NoFocus ); |
85 | slider->setGeometry( QRect( 7, 262, 220, 20 ) ); | 85 | slider->setGeometry( QRect( 7, 262, 220, 20 ) ); |
86 | 86 | ||
87 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 87 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
88 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 88 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
89 | 89 | ||
90 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 90 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
91 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 91 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
92 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 92 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
93 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 93 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
94 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); | 94 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); |
95 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 95 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
96 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 96 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
97 | 97 | ||
98 | // Intialise state | 98 | // Intialise state |
99 | setLength( mediaPlayerState->length() ); | 99 | setLength( mediaPlayerState->length() ); |
100 | setPosition( mediaPlayerState->position() ); | 100 | setPosition( mediaPlayerState->position() ); |
101 | setLooping( mediaPlayerState->fullscreen() ); | 101 | setLooping( mediaPlayerState->fullscreen() ); |
102 | setPaused( mediaPlayerState->paused() ); | 102 | setPaused( mediaPlayerState->paused() ); |
103 | setPlaying( mediaPlayerState->playing() ); | 103 | setPlaying( mediaPlayerState->playing() ); |
104 | 104 | ||
105 | } | 105 | } |
106 | 106 | ||
107 | 107 | ||
108 | AudioWidget::~AudioWidget() { | 108 | AudioWidget::~AudioWidget() { |
109 | for ( int i = 0; i < 4; i++ ) | 109 | for ( int i = 0; i < 4; i++ ) |
110 | delete pixmaps[i]; | 110 | delete pixmaps[i]; |
111 | } | 111 | } |
112 | 112 | ||
113 | 113 | ||
114 | static bool audioSliderBeingMoved = FALSE; | 114 | static bool audioSliderBeingMoved = FALSE; |
115 | 115 | ||
116 | 116 | ||
117 | void AudioWidget::sliderPressed() { | 117 | void AudioWidget::sliderPressed() { |
118 | audioSliderBeingMoved = TRUE; | 118 | audioSliderBeingMoved = TRUE; |
119 | } | 119 | } |
120 | 120 | ||
121 | 121 | ||
122 | void AudioWidget::sliderReleased() { | 122 | void AudioWidget::sliderReleased() { |
123 | audioSliderBeingMoved = FALSE; | 123 | audioSliderBeingMoved = FALSE; |
124 | if ( slider->width() == 0 ) | 124 | if ( slider->width() == 0 ) |
125 | return; | 125 | return; |
126 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); | 126 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); |
127 | mediaPlayerState->setPosition( val ); | 127 | mediaPlayerState->setPosition( val ); |
128 | } | 128 | } |
129 | 129 | ||
130 | 130 | ||
131 | void AudioWidget::setPosition( long i ) { | 131 | void AudioWidget::setPosition( long i ) { |
132 | updateSlider( i, mediaPlayerState->length() ); | 132 | updateSlider( i, mediaPlayerState->length() ); |
133 | } | 133 | } |
134 | 134 | ||
135 | 135 | ||
136 | void AudioWidget::setLength( long max ) { | 136 | void AudioWidget::setLength( long max ) { |
137 | updateSlider( mediaPlayerState->position(), max ); | 137 | updateSlider( mediaPlayerState->position(), max ); |
138 | } | 138 | } |
139 | 139 | ||
140 | 140 | ||
141 | void AudioWidget::setView( char view ) { | 141 | void AudioWidget::setView( char view ) { |
142 | if ( view == 'a' ) { | 142 | if ( view == 'a' ) { |
143 | startTimer( 150 ); | 143 | startTimer( 150 ); |
144 | showMaximized(); | 144 | showMaximized(); |
145 | } else { | 145 | } else { |
146 | killTimers(); | 146 | killTimers(); |
147 | hide(); | 147 | hide(); |
148 | } | 148 | } |
149 | } | 149 | } |
150 | 150 | ||
151 | 151 | ||
152 | void AudioWidget::updateSlider( long i, long max ) { | 152 | void AudioWidget::updateSlider( long i, long max ) { |
153 | if ( max == 0 ) | 153 | if ( max == 0 ) |
154 | return; | 154 | return; |
155 | // Will flicker too much if we don't do this | 155 | // Will flicker too much if we don't do this |
156 | // Scale to something reasonable | 156 | // Scale to something reasonable |
157 | int width = slider->width(); | 157 | int width = slider->width(); |
158 | int val = int((double)i * width / max); | 158 | int val = int((double)i * width / max); |
159 | if ( !audioSliderBeingMoved ) { | 159 | if ( !audioSliderBeingMoved ) { |
160 | if ( slider->value() != val ) | 160 | if ( slider->value() != val ) |
161 | slider->setValue( val ); | 161 | slider->setValue( val ); |
162 | if ( slider->maxValue() != width ) | 162 | if ( slider->maxValue() != width ) |
163 | slider->setMaxValue( width ); | 163 | slider->setMaxValue( width ); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | 166 | ||
167 | 167 | ||
168 | void AudioWidget::setToggleButton( int i, bool down ) { | 168 | void AudioWidget::setToggleButton( int i, bool down ) { |
169 | if ( down != audioButtons[i].isDown ) | 169 | if ( down != audioButtons[i].isDown ) |
170 | toggleButton( i ); | 170 | toggleButton( i ); |
171 | } | 171 | } |
172 | 172 | ||
173 | 173 | ||
174 | void AudioWidget::toggleButton( int i ) { | 174 | void AudioWidget::toggleButton( int i ) { |
175 | audioButtons[i].isDown = !audioButtons[i].isDown; | 175 | audioButtons[i].isDown = !audioButtons[i].isDown; |
176 | QPainter p(this); | 176 | QPainter p(this); |
177 | paintButton ( &p, i ); | 177 | paintButton ( &p, i ); |
178 | } | 178 | } |
179 | 179 | ||
180 | 180 | ||
181 | void AudioWidget::paintButton( QPainter *p, int i ) { | 181 | void AudioWidget::paintButton( QPainter *p, int i ) { |
182 | int x = audioButtons[i].xPos; | 182 | int x = audioButtons[i].xPos; |
183 | int y = audioButtons[i].yPos; | 183 | int y = audioButtons[i].yPos; |
184 | int offset = 22 + 14 * audioButtons[i].isBig + audioButtons[i].isDown; | 184 | int offset = 22 + 14 * audioButtons[i].isBig + audioButtons[i].isDown; |
185 | int buttonSize = 64 + audioButtons[i].isBig * (90 - 64); | 185 | int buttonSize = 64 + audioButtons[i].isBig * (90 - 64); |
186 | p->drawPixmap( x, y, *pixmaps[audioButtons[i].isBig], buttonSize * (audioButtons[i].isDown + 2 * audioButtons[i].color), 0, buttonSize, buttonSize ); | 186 | p->drawPixmap( x, y, *pixmaps[audioButtons[i].isBig], buttonSize * (audioButtons[i].isDown + 2 * audioButtons[i].color), 0, buttonSize, buttonSize ); |
187 | p->drawPixmap( x + offset, y + offset, *pixmaps[2], 18 * i, 0, 18, 18 ); | 187 | p->drawPixmap( x + offset, y + offset, *pixmaps[2], 18 * i, 0, 18, 18 ); |
188 | } | 188 | } |
189 | 189 | ||
190 | 190 | ||
191 | void AudioWidget::timerEvent( QTimerEvent * ) { | 191 | void AudioWidget::timerEvent( QTimerEvent * ) { |
192 | static int frame = 0; | 192 | static int frame = 0; |
193 | if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { | 193 | if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { |
194 | frame = frame >= 7 ? 0 : frame + 1; | 194 | frame = frame >= 7 ? 0 : frame + 1; |
195 | int x = audioButtons[AudioPlay].xPos; | 195 | int x = audioButtons[AudioPlay].xPos; |
196 | int y = audioButtons[AudioPlay].yPos; | 196 | int y = audioButtons[AudioPlay].yPos; |
197 | QPainter p( this ); | 197 | QPainter p( this ); |
198 | // Optimize to only draw the little bit of the changing images which is different | 198 | // Optimize to only draw the little bit of the changing images which is different |
199 | p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 ); | 199 | p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 ); |
200 | p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 ); | 200 | p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 ); |
201 | } | 201 | } |
202 | } | 202 | } |
203 | 203 | ||
204 | 204 | ||
205 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | 205 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { |
206 | for ( int i = 0; i < numButtons; i++ ) { | 206 | for ( int i = 0; i < numButtons; i++ ) { |
207 | int size = audioButtons[i].isBig; | 207 | int size = audioButtons[i].isBig; |
208 | int x = audioButtons[i].xPos; | 208 | int x = audioButtons[i].xPos; |
209 | int y = audioButtons[i].yPos; | 209 | int y = audioButtons[i].yPos; |
210 | if ( event->state() == QMouseEvent::LeftButton ) { | 210 | if ( event->state() == QMouseEvent::LeftButton ) { |
211 | // The test to see if the mouse click is inside the circular button or not | 211 | // The test to see if the mouse click is inside the circular button or not |
212 | // (compared with the radius squared to avoid a square-root of our distance) | 212 | // (compared with the radius squared to avoid a square-root of our distance) |
213 | int radius = 32 + 13 * size; | 213 | int radius = 32 + 13 * size; |
214 | QPoint center = QPoint( x + radius, y + radius ); | 214 | QPoint center = QPoint( x + radius, y + radius ); |
215 | QPoint dXY = center - event->pos(); | 215 | QPoint dXY = center - event->pos(); |
216 | int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); | 216 | int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); |
217 | bool isOnButton = dist <= (radius * radius); | 217 | bool isOnButton = dist <= (radius * radius); |
218 | // QRect r( x, y, 64 + 22*size, 64 + 22*size ); | 218 | // QRect r( x, y, 64 + 22*size, 64 + 22*size ); |
219 | // bool isOnButton = r.contains( event->pos() ); // Rectangular Button code | 219 | // bool isOnButton = r.contains( event->pos() ); // Rectangular Button code |
220 | if ( isOnButton && !audioButtons[i].isHeld ) { | 220 | if ( isOnButton && !audioButtons[i].isHeld ) { |
@@ -272,67 +272,67 @@ void AudioWidget::showEvent( QShowEvent* ) { | |||
272 | void AudioWidget::closeEvent( QCloseEvent* ) { | 272 | void AudioWidget::closeEvent( QCloseEvent* ) { |
273 | mediaPlayerState->setList(); | 273 | mediaPlayerState->setList(); |
274 | } | 274 | } |
275 | 275 | ||
276 | 276 | ||
277 | void AudioWidget::paintEvent( QPaintEvent * ) { | 277 | void AudioWidget::paintEvent( QPaintEvent * ) { |
278 | QPainter p( this ); | 278 | QPainter p( this ); |
279 | for ( int i = 0; i < numButtons; i++ ) | 279 | for ( int i = 0; i < numButtons; i++ ) |
280 | paintButton( &p, i ); | 280 | paintButton( &p, i ); |
281 | } | 281 | } |
282 | 282 | ||
283 | 283 | ||
284 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) | 284 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) |
285 | { | 285 | { |
286 | switch ( e->key() ) { | 286 | switch ( e->key() ) { |
287 | ////////////////////////////// Zaurus keys | 287 | ////////////////////////////// Zaurus keys |
288 | case Key_Home: | 288 | case Key_Home: |
289 | break; | 289 | break; |
290 | case Key_F9: //activity | 290 | case Key_F9: //activity |
291 | break; | 291 | break; |
292 | case Key_F10: //contacts | 292 | case Key_F10: //contacts |
293 | break; | 293 | break; |
294 | case Key_F11: //menu | 294 | case Key_F11: //menu |
295 | break; | 295 | break; |
296 | case Key_F12: //home | 296 | case Key_F12: //home |
297 | break; | 297 | break; |
298 | case Key_F13: //mail | 298 | case Key_F13: //mail |
299 | break; | 299 | break; |
300 | case Key_Space: { | 300 | case Key_Space: { |
301 | if(mediaPlayerState->playing()) { | 301 | if(mediaPlayerState->playing()) { |
302 | // toggleButton(1); | 302 | // toggleButton(1); |
303 | mediaPlayerState->setPlaying(FALSE); | 303 | mediaPlayerState->setPlaying(FALSE); |
304 | // toggleButton(1); | 304 | // toggleButton(1); |
305 | } else { | 305 | } else { |
306 | // toggleButton(0); | 306 | // toggleButton(0); |
307 | mediaPlayerState->setPlaying(TRUE); | 307 | mediaPlayerState->setPlaying(TRUE); |
308 | // toggleButton(0); | 308 | // toggleButton(0); |
309 | } | 309 | } |
310 | } | 310 | } |
311 | break; | 311 | break; |
312 | case Key_Down: | 312 | case Key_Down: |
313 | toggleButton(6); | 313 | toggleButton(6); |
314 | emit lessClicked(); | 314 | emit lessClicked(); |
315 | emit lessReleased(); | 315 | emit lessReleased(); |
316 | toggleButton(6); | 316 | toggleButton(6); |
317 | break; | 317 | break; |
318 | case Key_Up: | 318 | case Key_Up: |
319 | toggleButton(5); | 319 | toggleButton(5); |
320 | emit moreClicked(); | 320 | emit moreClicked(); |
321 | emit moreReleased(); | 321 | emit moreReleased(); |
322 | toggleButton(5); | 322 | toggleButton(5); |
323 | break; | 323 | break; |
324 | case Key_Right: | 324 | case Key_Right: |
325 | // toggleButton(3); | 325 | // toggleButton(3); |
326 | mediaPlayerState->setNext(); | 326 | mediaPlayerState->setNext(); |
327 | // toggleButton(3); | 327 | // toggleButton(3); |
328 | break; | 328 | break; |
329 | case Key_Left: | 329 | case Key_Left: |
330 | // toggleButton(4); | 330 | // toggleButton(4); |
331 | mediaPlayerState->setPrev(); | 331 | mediaPlayerState->setPrev(); |
332 | // toggleButton(4); | 332 | // toggleButton(4); |
333 | break; | 333 | break; |
334 | case Key_Escape: | 334 | case Key_Escape: |
335 | break; | 335 | break; |
336 | 336 | ||
337 | }; | 337 | }; |
338 | } | 338 | } |
diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp index 23b36e5..70b4a95 100644 --- a/core/multimedia/opieplayer/videowidget.cpp +++ b/core/multimedia/opieplayer/videowidget.cpp | |||
@@ -6,467 +6,467 @@ | |||
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qpe/resource.h> | 20 | #include <qpe/resource.h> |
21 | #include <qpe/mediaplayerplugininterface.h> | 21 | #include <qpe/mediaplayerplugininterface.h> |
22 | #include <qwidget.h> | 22 | #include <qwidget.h> |
23 | #include <qpainter.h> | 23 | #include <qpainter.h> |
24 | #include <qpixmap.h> | 24 | #include <qpixmap.h> |
25 | #include <qslider.h> | 25 | #include <qslider.h> |
26 | #include <qdrawutil.h> | 26 | #include <qdrawutil.h> |
27 | #include "videowidget.h" | 27 | #include "videowidget.h" |
28 | #include "mediaplayerstate.h" | 28 | #include "mediaplayerstate.h" |
29 | 29 | ||
30 | 30 | ||
31 | #ifdef Q_WS_QWS | 31 | #ifdef Q_WS_QWS |
32 | # define USE_DIRECT_PAINTER | 32 | # define USE_DIRECT_PAINTER |
33 | # include <qdirectpainter_qws.h> | 33 | # include <qdirectpainter_qws.h> |
34 | # include <qgfxraster_qws.h> | 34 | # include <qgfxraster_qws.h> |
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | 37 | ||
38 | extern MediaPlayerState *mediaPlayerState; | 38 | extern MediaPlayerState *mediaPlayerState; |
39 | 39 | ||
40 | 40 | ||
41 | static const int xo = 2; // movable x offset | 41 | static const int xo = 2; // movable x offset |
42 | static const int yo = 0; // movable y offset | 42 | static const int yo = 0; // movable y offset |
43 | 43 | ||
44 | 44 | ||
45 | struct MediaButton { | 45 | struct MediaButton { |
46 | int xPos, yPos; | 46 | int xPos, yPos; |
47 | bool isToggle, isHeld, isDown; | 47 | bool isToggle, isHeld, isDown; |
48 | int controlType; | 48 | int controlType; |
49 | }; | 49 | }; |
50 | 50 | ||
51 | 51 | ||
52 | // Layout information for the videoButtons (and if it is a toggle button or not) | 52 | // Layout information for the videoButtons (and if it is a toggle button or not) |
53 | MediaButton videoButtons[] = { | 53 | MediaButton videoButtons[] = { |
54 | { 5+0*32+xo, 200+yo, FALSE, FALSE, FALSE, 4 }, // previous | 54 | { 5+0*32+xo, 200+yo, FALSE, FALSE, FALSE, 4 }, // previous |
55 | { 5+1*32+xo, 200+yo, FALSE, FALSE, FALSE, 1 }, // stop | 55 | { 5+1*32+xo, 200+yo, FALSE, FALSE, FALSE, 1 }, // stop |
56 | { 5+2*32+xo, 200+yo, TRUE, FALSE, FALSE, 0 }, // play | 56 | { 5+2*32+xo, 200+yo, TRUE, FALSE, FALSE, 0 }, // play |
57 | { 5+3*32+xo, 200+yo, TRUE, FALSE, FALSE, 2 }, // pause | 57 | { 5+3*32+xo, 200+yo, TRUE, FALSE, FALSE, 2 }, // pause |
58 | { 5+4*32+xo, 200+yo, FALSE, FALSE, FALSE, 3 }, // next | 58 | { 5+4*32+xo, 200+yo, FALSE, FALSE, FALSE, 3 }, // next |
59 | { 5+5*32+xo, 200+yo, FALSE, FALSE, FALSE, 8 }, // playlist | 59 | { 5+5*32+xo, 200+yo, FALSE, FALSE, FALSE, 8 }, // playlist |
60 | { 5+6*32+xo, 200+yo, TRUE, FALSE, FALSE, 9 } // fullscreen | 60 | { 5+6*32+xo, 200+yo, TRUE, FALSE, FALSE, 9 } // fullscreen |
61 | }; | 61 | }; |
62 | 62 | ||
63 | 63 | ||
64 | static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); | 64 | static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); |
65 | 65 | ||
66 | 66 | ||
67 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : | 67 | VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : |
68 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { | 68 | QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { |
69 | setCaption( tr("OpiePlayer") ); | 69 | setCaption( tr("OpiePlayer") ); |
70 | setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); | 70 | setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); |
71 | pixmaps[0] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButton0a" ) ); | 71 | pixmaps[0] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaButton0a" ) ); |
72 | pixmaps[1] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaButton0b" ) ); | 72 | pixmaps[1] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaButton0b" ) ); |
73 | pixmaps[2] = new QPixmap( Resource::loadPixmap( "mpegplayer/mediaControls0" ) ); | 73 | pixmaps[2] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaControls0" ) ); |
74 | currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); | 74 | currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); |
75 | 75 | ||
76 | slider = new QSlider( Qt::Horizontal, this ); | 76 | slider = new QSlider( Qt::Horizontal, this ); |
77 | slider->setMinValue( 0 ); | 77 | slider->setMinValue( 0 ); |
78 | slider->setMaxValue( 1 ); | 78 | slider->setMaxValue( 1 ); |
79 | slider->setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); | 79 | slider->setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); |
80 | slider->setFocusPolicy( QWidget::NoFocus ); | 80 | slider->setFocusPolicy( QWidget::NoFocus ); |
81 | slider->setGeometry( QRect( 7, 250, 220, 20 ) ); | 81 | slider->setGeometry( QRect( 7, 250, 220, 20 ) ); |
82 | 82 | ||
83 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 83 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
84 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 84 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
85 | 85 | ||
86 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 86 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
87 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 87 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
88 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 88 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
89 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 89 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); |
90 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); | 90 | connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); |
91 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 91 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
92 | 92 | ||
93 | // Intialise state | 93 | // Intialise state |
94 | setLength( mediaPlayerState->length() ); | 94 | setLength( mediaPlayerState->length() ); |
95 | setPosition( mediaPlayerState->position() ); | 95 | setPosition( mediaPlayerState->position() ); |
96 | setFullscreen( mediaPlayerState->fullscreen() ); | 96 | setFullscreen( mediaPlayerState->fullscreen() ); |
97 | setPaused( mediaPlayerState->paused() ); | 97 | setPaused( mediaPlayerState->paused() ); |
98 | setPlaying( mediaPlayerState->playing() ); | 98 | setPlaying( mediaPlayerState->playing() ); |
99 | } | 99 | } |
100 | 100 | ||
101 | 101 | ||
102 | VideoWidget::~VideoWidget() { | 102 | VideoWidget::~VideoWidget() { |
103 | for ( int i = 0; i < 3; i++ ) | 103 | for ( int i = 0; i < 3; i++ ) |
104 | delete pixmaps[i]; | 104 | delete pixmaps[i]; |
105 | delete currentFrame; | 105 | delete currentFrame; |
106 | } | 106 | } |
107 | 107 | ||
108 | 108 | ||
109 | static bool videoSliderBeingMoved = FALSE; | 109 | static bool videoSliderBeingMoved = FALSE; |
110 | 110 | ||
111 | 111 | ||
112 | void VideoWidget::sliderPressed() { | 112 | void VideoWidget::sliderPressed() { |
113 | videoSliderBeingMoved = TRUE; | 113 | videoSliderBeingMoved = TRUE; |
114 | } | 114 | } |
115 | 115 | ||
116 | 116 | ||
117 | void VideoWidget::sliderReleased() { | 117 | void VideoWidget::sliderReleased() { |
118 | videoSliderBeingMoved = FALSE; | 118 | videoSliderBeingMoved = FALSE; |
119 | if ( slider->width() == 0 ) | 119 | if ( slider->width() == 0 ) |
120 | return; | 120 | return; |
121 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); | 121 | long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); |
122 | mediaPlayerState->setPosition( val ); | 122 | mediaPlayerState->setPosition( val ); |
123 | } | 123 | } |
124 | 124 | ||
125 | 125 | ||
126 | void VideoWidget::setPosition( long i ) { | 126 | void VideoWidget::setPosition( long i ) { |
127 | updateSlider( i, mediaPlayerState->length() ); | 127 | updateSlider( i, mediaPlayerState->length() ); |
128 | } | 128 | } |
129 | 129 | ||
130 | 130 | ||
131 | void VideoWidget::setLength( long max ) { | 131 | void VideoWidget::setLength( long max ) { |
132 | updateSlider( mediaPlayerState->position(), max ); | 132 | updateSlider( mediaPlayerState->position(), max ); |
133 | } | 133 | } |
134 | 134 | ||
135 | 135 | ||
136 | void VideoWidget::setView( char view ) { | 136 | void VideoWidget::setView( char view ) { |
137 | if ( view == 'v' ) { | 137 | if ( view == 'v' ) { |
138 | makeVisible(); | 138 | makeVisible(); |
139 | } else { | 139 | } else { |
140 | // Effectively blank the view next time we show it so it looks nicer | 140 | // Effectively blank the view next time we show it so it looks nicer |
141 | scaledWidth = 0; | 141 | scaledWidth = 0; |
142 | scaledHeight = 0; | 142 | scaledHeight = 0; |
143 | hide(); | 143 | hide(); |
144 | } | 144 | } |
145 | } | 145 | } |
146 | 146 | ||
147 | 147 | ||
148 | void VideoWidget::updateSlider( long i, long max ) { | 148 | void VideoWidget::updateSlider( long i, long max ) { |
149 | // Will flicker too much if we don't do this | 149 | // Will flicker too much if we don't do this |
150 | if ( max == 0 ) | 150 | if ( max == 0 ) |
151 | return; | 151 | return; |
152 | int width = slider->width(); | 152 | int width = slider->width(); |
153 | int val = int((double)i * width / max); | 153 | int val = int((double)i * width / max); |
154 | if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { | 154 | if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { |
155 | if ( slider->value() != val ) | 155 | if ( slider->value() != val ) |
156 | slider->setValue( val ); | 156 | slider->setValue( val ); |
157 | if ( slider->maxValue() != width ) | 157 | if ( slider->maxValue() != width ) |
158 | slider->setMaxValue( width ); | 158 | slider->setMaxValue( width ); |
159 | } | 159 | } |
160 | } | 160 | } |
161 | 161 | ||
162 | 162 | ||
163 | void VideoWidget::setToggleButton( int i, bool down ) { | 163 | void VideoWidget::setToggleButton( int i, bool down ) { |
164 | if ( down != videoButtons[i].isDown ) | 164 | if ( down != videoButtons[i].isDown ) |
165 | toggleButton( i ); | 165 | toggleButton( i ); |
166 | } | 166 | } |
167 | 167 | ||
168 | 168 | ||
169 | void VideoWidget::toggleButton( int i ) { | 169 | void VideoWidget::toggleButton( int i ) { |
170 | videoButtons[i].isDown = !videoButtons[i].isDown; | 170 | videoButtons[i].isDown = !videoButtons[i].isDown; |
171 | QPainter p(this); | 171 | QPainter p(this); |
172 | paintButton ( &p, i ); | 172 | paintButton ( &p, i ); |
173 | } | 173 | } |
174 | 174 | ||
175 | 175 | ||
176 | void VideoWidget::paintButton( QPainter *p, int i ) { | 176 | void VideoWidget::paintButton( QPainter *p, int i ) { |
177 | int x = videoButtons[i].xPos; | 177 | int x = videoButtons[i].xPos; |
178 | int y = videoButtons[i].yPos; | 178 | int y = videoButtons[i].yPos; |
179 | int offset = 10 + videoButtons[i].isDown; | 179 | int offset = 10 + videoButtons[i].isDown; |
180 | p->drawPixmap( x, y, *pixmaps[videoButtons[i].isDown] ); | 180 | p->drawPixmap( x, y, *pixmaps[videoButtons[i].isDown] ); |
181 | p->drawPixmap( x + 1 + offset, y + offset, *pixmaps[2], 9 * videoButtons[i].controlType, 0, 9, 9 ); | 181 | p->drawPixmap( x + 1 + offset, y + offset, *pixmaps[2], 9 * videoButtons[i].controlType, 0, 9, 9 ); |
182 | } | 182 | } |
183 | 183 | ||
184 | 184 | ||
185 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { | 185 | void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { |
186 | for ( int i = 0; i < numButtons; i++ ) { | 186 | for ( int i = 0; i < numButtons; i++ ) { |
187 | int x = videoButtons[i].xPos; | 187 | int x = videoButtons[i].xPos; |
188 | int y = videoButtons[i].yPos; | 188 | int y = videoButtons[i].yPos; |
189 | if ( event->state() == QMouseEvent::LeftButton ) { | 189 | if ( event->state() == QMouseEvent::LeftButton ) { |
190 | // The test to see if the mouse click is inside the circular button or not | 190 | // The test to see if the mouse click is inside the circular button or not |
191 | // (compared with the radius squared to avoid a square-root of our distance) | 191 | // (compared with the radius squared to avoid a square-root of our distance) |
192 | int radius = 16; | 192 | int radius = 16; |
193 | QPoint center = QPoint( x + radius, y + radius ); | 193 | QPoint center = QPoint( x + radius, y + radius ); |
194 | QPoint dXY = center - event->pos(); | 194 | QPoint dXY = center - event->pos(); |
195 | int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); | 195 | int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); |
196 | bool isOnButton = dist <= (radius * radius); | 196 | bool isOnButton = dist <= (radius * radius); |
197 | if ( isOnButton != videoButtons[i].isHeld ) { | 197 | if ( isOnButton != videoButtons[i].isHeld ) { |
198 | videoButtons[i].isHeld = isOnButton; | 198 | videoButtons[i].isHeld = isOnButton; |
199 | toggleButton(i); | 199 | toggleButton(i); |
200 | } | 200 | } |
201 | } else { | 201 | } else { |
202 | if ( videoButtons[i].isHeld ) { | 202 | if ( videoButtons[i].isHeld ) { |
203 | videoButtons[i].isHeld = FALSE; | 203 | videoButtons[i].isHeld = FALSE; |
204 | if ( !videoButtons[i].isToggle ) | 204 | if ( !videoButtons[i].isToggle ) |
205 | setToggleButton( i, FALSE ); | 205 | setToggleButton( i, FALSE ); |
206 | } | 206 | } |
207 | } | 207 | } |
208 | switch (i) { | 208 | switch (i) { |
209 | case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; | 209 | case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; |
210 | case VideoStop: mediaPlayerState->setPlaying(FALSE); return; | 210 | case VideoStop: mediaPlayerState->setPlaying(FALSE); return; |
211 | case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; | 211 | case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; |
212 | case VideoNext: mediaPlayerState->setNext(); return; | 212 | case VideoNext: mediaPlayerState->setNext(); return; |
213 | case VideoPrevious: mediaPlayerState->setPrev(); return; | 213 | case VideoPrevious: mediaPlayerState->setPrev(); return; |
214 | case VideoPlayList: mediaPlayerState->setList(); return; | 214 | case VideoPlayList: mediaPlayerState->setList(); return; |
215 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; | 215 | case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; |
216 | } | 216 | } |
217 | 217 | ||
218 | } | 218 | } |
219 | } | 219 | } |
220 | 220 | ||
221 | 221 | ||
222 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { | 222 | void VideoWidget::mousePressEvent( QMouseEvent *event ) { |
223 | mouseMoveEvent( event ); | 223 | mouseMoveEvent( event ); |
224 | } | 224 | } |
225 | 225 | ||
226 | 226 | ||
227 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { | 227 | void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { |
228 | if ( mediaPlayerState->fullscreen() ) { | 228 | if ( mediaPlayerState->fullscreen() ) { |
229 | mediaPlayerState->setFullscreen( FALSE ); | 229 | mediaPlayerState->setFullscreen( FALSE ); |
230 | makeVisible(); | 230 | makeVisible(); |
231 | 231 | ||
232 | mouseMoveEvent( event ); | 232 | mouseMoveEvent( event ); |
233 | } | 233 | } |
234 | } | 234 | } |
235 | 235 | ||
236 | 236 | ||
237 | void VideoWidget::makeVisible() { | 237 | void VideoWidget::makeVisible() { |
238 | if ( mediaPlayerState->fullscreen() ) { | 238 | if ( mediaPlayerState->fullscreen() ) { |
239 | setBackgroundMode( QWidget::NoBackground ); | 239 | setBackgroundMode( QWidget::NoBackground ); |
240 | showFullScreen(); | 240 | showFullScreen(); |
241 | resize( qApp->desktop()->size() ); | 241 | resize( qApp->desktop()->size() ); |
242 | slider->hide(); | 242 | slider->hide(); |
243 | } else { | 243 | } else { |
244 | setBackgroundPixmap( Resource::loadPixmap( "mpegplayer/metalFinish" ) ); | 244 | setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); |
245 | showNormal(); | 245 | showNormal(); |
246 | showMaximized(); | 246 | showMaximized(); |
247 | slider->show(); | 247 | slider->show(); |
248 | } | 248 | } |
249 | } | 249 | } |
250 | 250 | ||
251 | 251 | ||
252 | void VideoWidget::paintEvent( QPaintEvent * ) { | 252 | void VideoWidget::paintEvent( QPaintEvent * ) { |
253 | QPainter p( this ); | 253 | QPainter p( this ); |
254 | 254 | ||
255 | if ( mediaPlayerState->fullscreen() ) { | 255 | if ( mediaPlayerState->fullscreen() ) { |
256 | // Clear the background | 256 | // Clear the background |
257 | p.setBrush( QBrush( Qt::black ) ); | 257 | p.setBrush( QBrush( Qt::black ) ); |
258 | p.drawRect( rect() ); | 258 | p.drawRect( rect() ); |
259 | 259 | ||
260 | // Draw the current frame | 260 | // Draw the current frame |
261 | //p.drawImage( ); // If using directpainter we won't have a copy except whats on the screen | 261 | //p.drawImage( ); // If using directpainter we won't have a copy except whats on the screen |
262 | } else { | 262 | } else { |
263 | // draw border | 263 | // draw border |
264 | qDrawShadePanel( &p, 4, 15, 230, 170, colorGroup(), TRUE, 5, NULL ); | 264 | qDrawShadePanel( &p, 4, 15, 230, 170, colorGroup(), TRUE, 5, NULL ); |
265 | 265 | ||
266 | // Clear the movie screen first | 266 | // Clear the movie screen first |
267 | p.setBrush( QBrush( Qt::black ) ); | 267 | p.setBrush( QBrush( Qt::black ) ); |
268 | p.drawRect( 9, 20, 220, 160 ); | 268 | p.drawRect( 9, 20, 220, 160 ); |
269 | 269 | ||
270 | // draw current frame (centrally positioned from scaling to maintain aspect ratio) | 270 | // draw current frame (centrally positioned from scaling to maintain aspect ratio) |
271 | p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); | 271 | p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); |
272 | 272 | ||
273 | // draw the buttons | 273 | // draw the buttons |
274 | for ( int i = 0; i < numButtons; i++ ) | 274 | for ( int i = 0; i < numButtons; i++ ) |
275 | paintButton( &p, i ); | 275 | paintButton( &p, i ); |
276 | 276 | ||
277 | // draw the slider | 277 | // draw the slider |
278 | slider->repaint( TRUE ); | 278 | slider->repaint( TRUE ); |
279 | } | 279 | } |
280 | } | 280 | } |
281 | 281 | ||
282 | 282 | ||
283 | void VideoWidget::closeEvent( QCloseEvent* ) { | 283 | void VideoWidget::closeEvent( QCloseEvent* ) { |
284 | mediaPlayerState->setList(); | 284 | mediaPlayerState->setList(); |
285 | } | 285 | } |
286 | 286 | ||
287 | 287 | ||
288 | bool VideoWidget::playVideo() { | 288 | bool VideoWidget::playVideo() { |
289 | bool result = FALSE; | 289 | bool result = FALSE; |
290 | 290 | ||
291 | int stream = 0; | 291 | int stream = 0; |
292 | 292 | ||
293 | int sw = mediaPlayerState->curDecoder()->videoWidth( stream ); | 293 | int sw = mediaPlayerState->curDecoder()->videoWidth( stream ); |
294 | int sh = mediaPlayerState->curDecoder()->videoHeight( stream ); | 294 | int sh = mediaPlayerState->curDecoder()->videoHeight( stream ); |
295 | int dd = QPixmap::defaultDepth(); | 295 | int dd = QPixmap::defaultDepth(); |
296 | int w = height(); | 296 | int w = height(); |
297 | int h = width(); | 297 | int h = width(); |
298 | 298 | ||
299 | ColorFormat format = (dd == 16) ? RGB565 : BGRA8888; | 299 | ColorFormat format = (dd == 16) ? RGB565 : BGRA8888; |
300 | 300 | ||
301 | if ( mediaPlayerState->fullscreen() ) { | 301 | if ( mediaPlayerState->fullscreen() ) { |
302 | #ifdef USE_DIRECT_PAINTER | 302 | #ifdef USE_DIRECT_PAINTER |
303 | QDirectPainter p(this); | 303 | QDirectPainter p(this); |
304 | 304 | ||
305 | if ( ( qt_screen->transformOrientation() == 3 ) && | 305 | if ( ( qt_screen->transformOrientation() == 3 ) && |
306 | ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) ) { | 306 | ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) ) { |
307 | 307 | ||
308 | w = 320; | 308 | w = 320; |
309 | h = 240; | 309 | h = 240; |
310 | 310 | ||
311 | if ( mediaPlayerState->scaled() ) { | 311 | if ( mediaPlayerState->scaled() ) { |
312 | // maintain aspect ratio | 312 | // maintain aspect ratio |
313 | if ( w * sh > sw * h ) | 313 | if ( w * sh > sw * h ) |
314 | w = sw * h / sh; | 314 | w = sw * h / sh; |
315 | else | 315 | else |
316 | h = sh * w / sw; | 316 | h = sh * w / sw; |
317 | } else { | 317 | } else { |
318 | w = sw; | 318 | w = sw; |
319 | h = sh; | 319 | h = sh; |
320 | } | 320 | } |
321 | 321 | ||
322 | w--; // we can't allow libmpeg to overwrite. | 322 | w--; // we can't allow libmpeg to overwrite. |
323 | QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) ); | 323 | QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) ); |
324 | 324 | ||
325 | int ox = roff.x() - height() + 2 + (height() - w) / 2; | 325 | int ox = roff.x() - height() + 2 + (height() - w) / 2; |
326 | int oy = roff.y() + (width() - h) / 2; | 326 | int oy = roff.y() + (width() - h) / 2; |
327 | int sx = 0, sy = 0; | 327 | int sx = 0, sy = 0; |
328 | 328 | ||
329 | uchar* fp = p.frameBuffer() + p.lineStep() * oy; | 329 | uchar* fp = p.frameBuffer() + p.lineStep() * oy; |
330 | fp += dd * ox / 8; | 330 | fp += dd * ox / 8; |
331 | uchar **jt = new uchar*[h]; | 331 | uchar **jt = new uchar*[h]; |
332 | for ( int i = h; i; i-- ) { | 332 | for ( int i = h; i; i-- ) { |
333 | jt[h - i] = fp; | 333 | jt[h - i] = fp; |
334 | fp += p.lineStep(); | 334 | fp += p.lineStep(); |
335 | } | 335 | } |
336 | 336 | ||
337 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0; | 337 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0; |
338 | 338 | ||
339 | delete [] jt; | 339 | delete [] jt; |
340 | } else { | 340 | } else { |
341 | #endif | 341 | #endif |
342 | QPainter p(this); | 342 | QPainter p(this); |
343 | 343 | ||
344 | w = 320; | 344 | w = 320; |
345 | h = 240; | 345 | h = 240; |
346 | 346 | ||
347 | if ( mediaPlayerState->scaled() ) { | 347 | if ( mediaPlayerState->scaled() ) { |
348 | // maintain aspect ratio | 348 | // maintain aspect ratio |
349 | if ( w * sh > sw * h ) | 349 | if ( w * sh > sw * h ) |
350 | w = sw * h / sh; | 350 | w = sw * h / sh; |
351 | else | 351 | else |
352 | h = sh * w / sw; | 352 | h = sh * w / sw; |
353 | } else { | 353 | } else { |
354 | w = sw; | 354 | w = sw; |
355 | h = sh; | 355 | h = sh; |
356 | } | 356 | } |
357 | 357 | ||
358 | int bytes = ( dd == 16 ) ? 2 : 4; | 358 | int bytes = ( dd == 16 ) ? 2 : 4; |
359 | QImage tempFrame( w, h, bytes << 3 ); | 359 | QImage tempFrame( w, h, bytes << 3 ); |
360 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(), | 360 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(), |
361 | 0, 0, sw, sh, w, h, format, 0) == 0; | 361 | 0, 0, sw, sh, w, h, format, 0) == 0; |
362 | if ( result && mediaPlayerState->fullscreen() ) { | 362 | if ( result && mediaPlayerState->fullscreen() ) { |
363 | 363 | ||
364 | int rw = h, rh = w; | 364 | int rw = h, rh = w; |
365 | QImage rotatedFrame( rw, rh, bytes << 3 ); | 365 | QImage rotatedFrame( rw, rh, bytes << 3 ); |
366 | 366 | ||
367 | ushort* in = (ushort*)tempFrame.bits(); | 367 | ushort* in = (ushort*)tempFrame.bits(); |
368 | ushort* out = (ushort*)rotatedFrame.bits(); | 368 | ushort* out = (ushort*)rotatedFrame.bits(); |
369 | int spl = rotatedFrame.bytesPerLine() / bytes; | 369 | int spl = rotatedFrame.bytesPerLine() / bytes; |
370 | for (int x=0; x<h; x++) { | 370 | for (int x=0; x<h; x++) { |
371 | if ( bytes == 2 ) { | 371 | if ( bytes == 2 ) { |
372 | ushort* lout = out++ + (w - 1)*spl; | 372 | ushort* lout = out++ + (w - 1)*spl; |
373 | for (int y=0; y<w; y++) { | 373 | for (int y=0; y<w; y++) { |
374 | *lout=*in++; | 374 | *lout=*in++; |
375 | lout-=spl; | 375 | lout-=spl; |
376 | } | 376 | } |
377 | } else { | 377 | } else { |
378 | ulong* lout = ((ulong *)out)++ + (w - 1)*spl; | 378 | ulong* lout = ((ulong *)out)++ + (w - 1)*spl; |
379 | for (int y=0; y<w; y++) { | 379 | for (int y=0; y<w; y++) { |
380 | *lout=*((ulong*)in)++; | 380 | *lout=*((ulong*)in)++; |
381 | lout-=spl; | 381 | lout-=spl; |
382 | } | 382 | } |
383 | } | 383 | } |
384 | } | 384 | } |
385 | 385 | ||
386 | p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh ); | 386 | p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh ); |
387 | } | 387 | } |
388 | #ifdef USE_DIRECT_PAINTER | 388 | #ifdef USE_DIRECT_PAINTER |
389 | } | 389 | } |
390 | #endif | 390 | #endif |
391 | } else { | 391 | } else { |
392 | 392 | ||
393 | w = 220; | 393 | w = 220; |
394 | h = 160; | 394 | h = 160; |
395 | 395 | ||
396 | // maintain aspect ratio | 396 | // maintain aspect ratio |
397 | if ( w * sh > sw * h ) | 397 | if ( w * sh > sw * h ) |
398 | w = sw * h / sh; | 398 | w = sw * h / sh; |
399 | else | 399 | else |
400 | h = sh * w / sw; | 400 | h = sh * w / sw; |
401 | 401 | ||
402 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0; | 402 | result = mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0; |
403 | 403 | ||
404 | QPainter p( this ); | 404 | QPainter p( this ); |
405 | 405 | ||
406 | // Image changed size, therefore need to blank the possibly unpainted regions first | 406 | // Image changed size, therefore need to blank the possibly unpainted regions first |
407 | if ( scaledWidth != w || scaledHeight != h ) { | 407 | if ( scaledWidth != w || scaledHeight != h ) { |
408 | p.setBrush( QBrush( Qt::black ) ); | 408 | p.setBrush( QBrush( Qt::black ) ); |
409 | p.drawRect( 9, 20, 220, 160 ); | 409 | p.drawRect( 9, 20, 220, 160 ); |
410 | } | 410 | } |
411 | 411 | ||
412 | scaledWidth = w; | 412 | scaledWidth = w; |
413 | scaledHeight = h; | 413 | scaledHeight = h; |
414 | 414 | ||
415 | if ( result ) { | 415 | if ( result ) { |
416 | p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); | 416 | p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); |
417 | } | 417 | } |
418 | 418 | ||
419 | } | 419 | } |
420 | 420 | ||
421 | return result; | 421 | return result; |
422 | } | 422 | } |
423 | 423 | ||
424 | 424 | ||
425 | 425 | ||
426 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) | 426 | void VideoWidget::keyReleaseEvent( QKeyEvent *e) |
427 | { | 427 | { |
428 | switch ( e->key() ) { | 428 | switch ( e->key() ) { |
429 | ////////////////////////////// Zaurus keys | 429 | ////////////////////////////// Zaurus keys |
430 | case Key_Home: | 430 | case Key_Home: |
431 | break; | 431 | break; |
432 | case Key_F9: //activity | 432 | case Key_F9: //activity |
433 | break; | 433 | break; |
434 | case Key_F10: //contacts | 434 | case Key_F10: //contacts |
435 | break; | 435 | break; |
436 | case Key_F11: //menu | 436 | case Key_F11: //menu |
437 | break; | 437 | break; |
438 | case Key_F12: //home | 438 | case Key_F12: //home |
439 | break; | 439 | break; |
440 | case Key_F13: //mail | 440 | case Key_F13: //mail |
441 | break; | 441 | break; |
442 | case Key_Space: { | 442 | case Key_Space: { |
443 | if(mediaPlayerState->playing()) { | 443 | if(mediaPlayerState->playing()) { |
444 | mediaPlayerState->setPlaying(FALSE); | 444 | mediaPlayerState->setPlaying(FALSE); |
445 | } else { | 445 | } else { |
446 | mediaPlayerState->setPlaying(TRUE); | 446 | mediaPlayerState->setPlaying(TRUE); |
447 | } | 447 | } |
448 | } | 448 | } |
449 | break; | 449 | break; |
450 | case Key_Down: | 450 | case Key_Down: |
451 | // toggleButton(6); | 451 | // toggleButton(6); |
452 | // emit lessClicked(); | 452 | // emit lessClicked(); |
453 | // emit lessReleased(); | 453 | // emit lessReleased(); |
454 | // toggleButton(6); | 454 | // toggleButton(6); |
455 | break; | 455 | break; |
456 | case Key_Up: | 456 | case Key_Up: |
457 | // toggleButton(5); | 457 | // toggleButton(5); |
458 | // emit moreClicked(); | 458 | // emit moreClicked(); |
459 | // emit moreReleased(); | 459 | // emit moreReleased(); |
460 | // toggleButton(5); | 460 | // toggleButton(5); |
461 | break; | 461 | break; |
462 | case Key_Right: | 462 | case Key_Right: |
463 | mediaPlayerState->setNext(); | 463 | mediaPlayerState->setNext(); |
464 | break; | 464 | break; |
465 | case Key_Left: | 465 | case Key_Left: |
466 | mediaPlayerState->setPrev(); | 466 | mediaPlayerState->setPrev(); |
467 | break; | 467 | break; |
468 | case Key_Escape: | 468 | case Key_Escape: |
469 | break; | 469 | break; |
470 | 470 | ||
471 | }; | 471 | }; |
472 | } | 472 | } |