summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-07-03 14:44:22 (UTC)
committer harlekin <harlekin>2002-07-03 14:44:22 (UTC)
commite1e4956ec7ffa9a07f98b03e831f0f9627556a6c (patch) (unidiff)
treec0545c6a22732f05804bda7704227132f64b7239
parent61770de77f2abe8012d44cce49d04489e4187644 (diff)
downloadopie-e1e4956ec7ffa9a07f98b03e831f0f9627556a6c.zip
opie-e1e4956ec7ffa9a07f98b03e831f0f9627556a6c.tar.gz
opie-e1e4956ec7ffa9a07f98b03e831f0f9627556a6c.tar.bz2
much more code cleanup, make if look more like c++ code
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp43
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.h44
-rw-r--r--noncore/multimedia/opieplayer2/inputDialog.cpp8
-rw-r--r--noncore/multimedia/opieplayer2/inputDialog.h12
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp68
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayerstate.cpp10
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayerstate.h5
7 files changed, 65 insertions, 125 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 8d3963a..1b0de5d 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -1,340 +1,377 @@
1 1
2#include <qpe/qpeapplication.h> 2#include <qpe/qpeapplication.h>
3#include <qpe/resource.h> 3#include <qpe/resource.h>
4#include <qpe/config.h> 4#include <qpe/config.h>
5 5
6#include <qwidget.h> 6#include <qwidget.h>
7#include <qpixmap.h> 7#include <qpixmap.h>
8#include <qbutton.h> 8#include <qbutton.h>
9#include <qpainter.h> 9#include <qpainter.h>
10#include <qframe.h> 10#include <qframe.h>
11#include <qlayout.h> 11#include <qlayout.h>
12 12
13#include "audiowidget.h" 13#include "audiowidget.h"
14#include "mediaplayerstate.h" 14#include "mediaplayerstate.h"
15 15
16extern MediaPlayerState *mediaPlayerState; 16extern MediaPlayerState *mediaPlayerState;
17 17
18
19static const int xo = -2; // movable x offset 18static const int xo = -2; // movable x offset
20static const int yo = 22; // movable y offset 19static const int yo = 22; // movable y offset
21 20
22 21
22Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) {
23 setFrameStyle( WinPanel | Sunken );
24 setText( "No Song" );
25}
26
27Ticker::~Ticker() {
28}
29
30void Ticker::setText( const QString& text ) {
31 pos = 0; // reset it everytime the text is changed
32 scrollText = text;
33 pixelLen = fontMetrics().width( scrollText );
34 killTimers();
35 if ( pixelLen > width() ) {
36 startTimer( 50 );
37 }
38 update();
39}
40
41
42void Ticker::timerEvent( QTimerEvent * ) {
43 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1;
44 repaint( FALSE );
45}
46
47void Ticker::drawContents( QPainter *p ) {
48 QPixmap pm( width(), height() );
49 pm.fill( colorGroup().base() );
50 QPainter pmp( &pm );
51 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) {
52 pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
53 }
54 p->drawPixmap( 0, 0, pm );
55}
56
57
58
59
23struct MediaButton { 60struct MediaButton {
24 int xPos, yPos; 61 int xPos, yPos;
25 int color; 62 int color;
26 bool isToggle, isBig, isHeld, isDown; 63 bool isToggle, isBig, isHeld, isDown;
27}; 64};
28 65
29 66
67
68
30// Layout information for the audioButtons (and if it is a toggle button or not) 69// Layout information for the audioButtons (and if it is a toggle button or not)
31MediaButton audioButtons[] = { 70MediaButton audioButtons[] = {
32 { 3*30-15+xo, 3*30-13+yo, 0, TRUE, TRUE, FALSE, FALSE }, // play 71 { 3*30-15+xo, 3*30-13+yo, 0, TRUE, TRUE, FALSE, FALSE }, // play
33 { 1*30+xo, 5*30+yo, 2, FALSE, FALSE, FALSE, FALSE }, // stop 72 { 1*30+xo, 5*30+yo, 2, FALSE, FALSE, FALSE, FALSE }, // stop
34 { 5*30+xo, 5*30+yo, 2, TRUE, FALSE, FALSE, FALSE }, // pause 73 { 5*30+xo, 5*30+yo, 2, TRUE, FALSE, FALSE, FALSE }, // pause
35 { 6*30-5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // next 74 { 6*30-5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // next
36 { 0*30+5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // previous 75 { 0*30+5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // previous
37 { 3*30+xo, 0*30+5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume up 76 { 3*30+xo, 0*30+5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume up
38 { 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down 77 { 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down
39 { 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop 78 { 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop
40 { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist 79 { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist
41}; 80};
42 81
43
44static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); 82static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
45 83
46 84
47AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : 85AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
48 QWidget( parent, name, f ) 86 QWidget( parent, name, f )
49{ 87{
50 setCaption( tr("OpiePlayer - Audio") ); 88 setCaption( tr("OpiePlayer - Audio") );
51 Config cfg("OpiePlayer"); 89 Config cfg("OpiePlayer");
52 cfg.setGroup("AudioWidget"); 90 cfg.setGroup("AudioWidget");
53 91
54 QString backgroundPix, buttonsAllPix, buttonsBigPix, controlsPix, animatedPix; 92 QString backgroundPix, buttonsAllPix, buttonsBigPix, controlsPix, animatedPix;
55 backgroundPix=cfg.readEntry( " backgroundPix", "opieplayer/metalFinish"); 93 backgroundPix=cfg.readEntry( " backgroundPix", "opieplayer/metalFinish");
56 buttonsAllPix=cfg.readEntry( "buttonsAllPix","opieplayer/mediaButtonsAll"); 94 buttonsAllPix=cfg.readEntry( "buttonsAllPix","opieplayer/mediaButtonsAll");
57 buttonsBigPix=cfg.readEntry( "buttonsBigPix","opieplayer/mediaButtonsBig"); 95 buttonsBigPix=cfg.readEntry( "buttonsBigPix","opieplayer/mediaButtonsBig");
58 controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls"); 96 controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls");
59 97
60 setBackgroundPixmap( Resource::loadPixmap( backgroundPix) ); 98 setBackgroundPixmap( Resource::loadPixmap( backgroundPix) );
61 pixmaps[0] = new QPixmap( Resource::loadPixmap( buttonsAllPix ) ); 99 pixmaps[0] = new QPixmap( Resource::loadPixmap( buttonsAllPix ) );
62 pixmaps[1] = new QPixmap( Resource::loadPixmap( buttonsBigPix ) ); 100 pixmaps[1] = new QPixmap( Resource::loadPixmap( buttonsBigPix ) );
63 pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix ) ); 101 pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix ) );
64 102
65 songInfo = new Ticker( this ); 103 songInfo = new Ticker( this );
66 songInfo->setFocusPolicy( QWidget::NoFocus ); 104 songInfo->setFocusPolicy( QWidget::NoFocus );
67 songInfo->setGeometry( QRect( 7, 3, 220, 20 ) ); 105 songInfo->setGeometry( QRect( 7, 3, 220, 20 ) );
68 106
69 slider = new QSlider( Qt::Horizontal, this ); 107 slider = new QSlider( Qt::Horizontal, this );
70 slider->setFixedWidth( 220 ); 108 slider->setFixedWidth( 220 );
71 slider->setFixedHeight( 20 ); 109 slider->setFixedHeight( 20 );
72 slider->setMinValue( 0 ); 110 slider->setMinValue( 0 );
73 slider->setMaxValue( 1 ); 111 slider->setMaxValue( 1 );
74 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 112 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
75 slider->setFocusPolicy( QWidget::NoFocus ); 113 slider->setFocusPolicy( QWidget::NoFocus );
76 slider->setGeometry( QRect( 7, 262, 220, 20 ) ); 114 slider->setGeometry( QRect( 7, 262, 220, 20 ) );
77 115
78 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 116 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
79 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 117 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
80 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 118 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
81 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 119 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
82 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 120 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
83 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 121 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
84 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 122 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
85 123
86 // Intialise state 124 // Intialise state
87 setLength( mediaPlayerState->length() ); 125 setLength( mediaPlayerState->length() );
88 setPosition( mediaPlayerState->position() ); 126 setPosition( mediaPlayerState->position() );
89 setLooping( mediaPlayerState->fullscreen() ); 127 setLooping( mediaPlayerState->fullscreen() );
90 setPaused( mediaPlayerState->paused() ); 128 setPaused( mediaPlayerState->paused() );
91 setPlaying( mediaPlayerState->playing() ); 129 setPlaying( mediaPlayerState->playing() );
92 130
93} 131}
94 132
95 133
96AudioWidget::~AudioWidget() { 134AudioWidget::~AudioWidget() {
97 mediaPlayerState->isStreaming = FALSE; 135 mediaPlayerState->isStreaming = FALSE;
98 for ( int i = 0; i < 3; i++ ) { 136 for ( int i = 0; i < 3; i++ ) {
99 delete pixmaps[i]; 137 delete pixmaps[i];
100 } 138 }
101} 139}
102 140
103 141
104static bool audioSliderBeingMoved = FALSE; 142static bool audioSliderBeingMoved = FALSE;
105 143
106 144
107void AudioWidget::sliderPressed() { 145void AudioWidget::sliderPressed() {
108 audioSliderBeingMoved = TRUE; 146 audioSliderBeingMoved = TRUE;
109} 147}
110 148
111 149
112void AudioWidget::sliderReleased() { 150void AudioWidget::sliderReleased() {
113 audioSliderBeingMoved = FALSE; 151 audioSliderBeingMoved = FALSE;
114 if ( slider->width() == 0 ) { 152 if ( slider->width() == 0 ) {
115 return; 153 return;
116 } 154 }
117 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); 155 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width());
118 mediaPlayerState->setPosition( val ); 156 mediaPlayerState->setPosition( val );
119} 157}
120 158
121 159
122void AudioWidget::setPosition( long i ) { 160void AudioWidget::setPosition( long i ) {
123 // qDebug("set position %d",i); 161 // qDebug("set position %d",i);
124 updateSlider( i, mediaPlayerState->length() ); 162 updateSlider( i, mediaPlayerState->length() );
125} 163}
126 164
127 165
128void AudioWidget::setLength( long max ) { 166void AudioWidget::setLength( long max ) {
129 updateSlider( mediaPlayerState->position(), max ); 167 updateSlider( mediaPlayerState->position(), max );
130} 168}
131 169
132 170
133void AudioWidget::setView( char view ) { 171void AudioWidget::setView( char view ) {
134 if (mediaPlayerState->isStreaming) { 172 if (mediaPlayerState->isStreaming) {
135 if( !slider->isHidden()) slider->hide(); 173 if( !slider->isHidden()) slider->hide();
136 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 174 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
137 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 175 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
138 } else { 176 } else {
139 // this stops the slider from being moved, thus 177 // this stops the slider from being moved, thus
140 // does not stop stream when it reaches the end 178 // does not stop stream when it reaches the end
141 slider->show(); 179 slider->show();
142 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 180 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
143 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 181 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
144 } 182 }
145 183
146 if ( view == 'a' ) { 184 if ( view == 'a' ) {
147 startTimer( 150 ); 185 startTimer( 150 );
148 // show();
149 showMaximized(); 186 showMaximized();
150 } else { 187 } else {
151 killTimers(); 188 killTimers();
152 hide(); 189 hide();
153 } 190 }
154} 191}
155 192
156 193
157void AudioWidget::updateSlider( long i, long max ) { 194void AudioWidget::updateSlider( long i, long max ) {
158 if ( max == 0 ) { 195 if ( max == 0 ) {
159 return; 196 return;
160 } 197 }
161 // Will flicker too much if we don't do this 198 // Will flicker too much if we don't do this
162 // Scale to something reasonable 199 // Scale to something reasonable
163 int width = slider->width(); 200 int width = slider->width();
164 int val = int((double)i * width / max); 201 int val = int((double)i * width / max);
165 if ( !audioSliderBeingMoved ) { 202 if ( !audioSliderBeingMoved ) {
166 if ( slider->value() != val ) { 203 if ( slider->value() != val ) {
167 slider->setValue( val ); 204 slider->setValue( val );
168 } 205 }
169 206
170 if ( slider->maxValue() != width ) { 207 if ( slider->maxValue() != width ) {
171 slider->setMaxValue( width ); 208 slider->setMaxValue( width );
172 } 209 }
173 } 210 }
174} 211}
175 212
176 213
177void AudioWidget::setToggleButton( int i, bool down ) { 214void AudioWidget::setToggleButton( int i, bool down ) {
178 if ( down != audioButtons[i].isDown ) { 215 if ( down != audioButtons[i].isDown ) {
179 toggleButton( i ); 216 toggleButton( i );
180 } 217 }
181} 218}
182 219
183 220
184void AudioWidget::toggleButton( int i ) { 221void AudioWidget::toggleButton( int i ) {
185 audioButtons[i].isDown = !audioButtons[i].isDown; 222 audioButtons[i].isDown = !audioButtons[i].isDown;
186 QPainter p(this); 223 QPainter p(this);
187 paintButton ( &p, i ); 224 paintButton ( &p, i );
188} 225}
189 226
190 227
191void AudioWidget::paintButton( QPainter *p, int i ) { 228void AudioWidget::paintButton( QPainter *p, int i ) {
192 int x = audioButtons[i].xPos; 229 int x = audioButtons[i].xPos;
193 int y = audioButtons[i].yPos; 230 int y = audioButtons[i].yPos;
194 int offset = 22 + 14 * audioButtons[i].isBig + audioButtons[i].isDown; 231 int offset = 22 + 14 * audioButtons[i].isBig + audioButtons[i].isDown;
195 int buttonSize = 64 + audioButtons[i].isBig * (90 - 64); 232 int buttonSize = 64 + audioButtons[i].isBig * (90 - 64);
196 p->drawPixmap( x, y, *pixmaps[audioButtons[i].isBig], buttonSize * (audioButtons[i].isDown + 2 * audioButtons[i].color), 0, buttonSize, buttonSize ); 233 p->drawPixmap( x, y, *pixmaps[audioButtons[i].isBig], buttonSize * (audioButtons[i].isDown + 2 * audioButtons[i].color), 0, buttonSize, buttonSize );
197 p->drawPixmap( x + offset, y + offset, *pixmaps[2], 18 * i, 0, 18, 18 ); 234 p->drawPixmap( x + offset, y + offset, *pixmaps[2], 18 * i, 0, 18, 18 );
198} 235}
199 236
200 237
201void AudioWidget::timerEvent( QTimerEvent * ) { 238void AudioWidget::timerEvent( QTimerEvent * ) {
202 static int frame = 0; 239 static int frame = 0;
203 if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { 240 if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) {
204 frame = frame >= 7 ? 0 : frame + 1; 241 frame = frame >= 7 ? 0 : frame + 1;
205 } 242 }
206} 243}
207 244
208 245
209void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 246void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
210 for ( int i = 0; i < numButtons; i++ ) { 247 for ( int i = 0; i < numButtons; i++ ) {
211 int size = audioButtons[i].isBig; 248 int size = audioButtons[i].isBig;
212 int x = audioButtons[i].xPos; 249 int x = audioButtons[i].xPos;
213 int y = audioButtons[i].yPos; 250 int y = audioButtons[i].yPos;
214 if ( event->state() == QMouseEvent::LeftButton ) { 251 if ( event->state() == QMouseEvent::LeftButton ) {
215 // The test to see if the mouse click is inside the circular button or not 252 // The test to see if the mouse click is inside the circular button or not
216 // (compared with the radius squared to avoid a square-root of our distance) 253 // (compared with the radius squared to avoid a square-root of our distance)
217 int radius = 32 + 13 * size; 254 int radius = 32 + 13 * size;
218 QPoint center = QPoint( x + radius, y + radius ); 255 QPoint center = QPoint( x + radius, y + radius );
219 QPoint dXY = center - event->pos(); 256 QPoint dXY = center - event->pos();
220 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); 257 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y();
221 bool isOnButton = dist <= (radius * radius); 258 bool isOnButton = dist <= (radius * radius);
222 if ( isOnButton && !audioButtons[i].isHeld ) { 259 if ( isOnButton && !audioButtons[i].isHeld ) {
223 audioButtons[i].isHeld = TRUE; 260 audioButtons[i].isHeld = TRUE;
224 toggleButton(i); 261 toggleButton(i);
225 qDebug("button toggled1 %d",i); 262 qDebug("button toggled1 %d",i);
226 switch (i) { 263 switch (i) {
227 case AudioVolumeUp: emit moreClicked(); return; 264 case AudioVolumeUp: emit moreClicked(); return;
228 case AudioVolumeDown: emit lessClicked(); return; 265 case AudioVolumeDown: emit lessClicked(); return;
229 } 266 }
230 } else if ( !isOnButton && audioButtons[i].isHeld ) { 267 } else if ( !isOnButton && audioButtons[i].isHeld ) {
231 audioButtons[i].isHeld = FALSE; 268 audioButtons[i].isHeld = FALSE;
232 toggleButton(i); 269 toggleButton(i);
233 qDebug("button toggled2 %d",i); 270 qDebug("button toggled2 %d",i);
234 } 271 }
235 } else { 272 } else {
236 if ( audioButtons[i].isHeld ) { 273 if ( audioButtons[i].isHeld ) {
237 audioButtons[i].isHeld = FALSE; 274 audioButtons[i].isHeld = FALSE;
238 if ( !audioButtons[i].isToggle ) 275 if ( !audioButtons[i].isToggle )
239 setToggleButton( i, FALSE ); 276 setToggleButton( i, FALSE );
240 qDebug("button toggled3 %d",i); 277 qDebug("button toggled3 %d",i);
241 switch (i) { 278 switch (i) {
242 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; 279 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return;
243 case AudioStop: mediaPlayerState->setPlaying(FALSE); return; 280 case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
244 case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; 281 case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return;
245 case AudioNext: mediaPlayerState->setNext(); return; 282 case AudioNext: mediaPlayerState->setNext(); return;
246 case AudioPrevious: mediaPlayerState->setPrev(); return; 283 case AudioPrevious: mediaPlayerState->setPrev(); return;
247 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; 284 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return;
248 case AudioVolumeUp: emit moreReleased(); return; 285 case AudioVolumeUp: emit moreReleased(); return;
249 case AudioVolumeDown: emit lessReleased(); return; 286 case AudioVolumeDown: emit lessReleased(); return;
250 case AudioPlayList: mediaPlayerState->setList(); return; 287 case AudioPlayList: mediaPlayerState->setList(); return;
251 } 288 }
252 } 289 }
253 } 290 }
254 } 291 }
255} 292}
256 293
257 294
258void AudioWidget::mousePressEvent( QMouseEvent *event ) { 295void AudioWidget::mousePressEvent( QMouseEvent *event ) {
259 mouseMoveEvent( event ); 296 mouseMoveEvent( event );
260} 297}
261 298
262 299
263void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { 300void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
264 mouseMoveEvent( event ); 301 mouseMoveEvent( event );
265} 302}
266 303
267 304
268void AudioWidget::showEvent( QShowEvent* ) { 305void AudioWidget::showEvent( QShowEvent* ) {
269 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 306 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
270 mouseMoveEvent( &event ); 307 mouseMoveEvent( &event );
271} 308}
272 309
273 310
274void AudioWidget::closeEvent( QCloseEvent* ) { 311void AudioWidget::closeEvent( QCloseEvent* ) {
275 mediaPlayerState->setList(); 312 mediaPlayerState->setList();
276} 313}
277 314
278 315
279void AudioWidget::paintEvent( QPaintEvent * ) { 316void AudioWidget::paintEvent( QPaintEvent * ) {
280 QPainter p( this ); 317 QPainter p( this );
281 for ( int i = 0; i < numButtons; i++ ) 318 for ( int i = 0; i < numButtons; i++ )
282 paintButton( &p, i ); 319 paintButton( &p, i );
283} 320}
284 321
285void AudioWidget::keyReleaseEvent( QKeyEvent *e) 322void AudioWidget::keyReleaseEvent( QKeyEvent *e)
286{ 323{
287 switch ( e->key() ) { 324 switch ( e->key() ) {
288////////////////////////////// Zaurus keys 325////////////////////////////// Zaurus keys
289 case Key_Home: 326 case Key_Home:
290 break; 327 break;
291 case Key_F9: //activity 328 case Key_F9: //activity
292 hide(); 329 hide();
293// qDebug("Audio F9"); 330// qDebug("Audio F9");
294 break; 331 break;
295 case Key_F10: //contacts 332 case Key_F10: //contacts
296 break; 333 break;
297 case Key_F11: //menu 334 case Key_F11: //menu
298 break; 335 break;
299 case Key_F12: //home 336 case Key_F12: //home
300 break; 337 break;
301 case Key_F13: //mail 338 case Key_F13: //mail
302 break; 339 break;
303 case Key_Space: { 340 case Key_Space: {
304 if(mediaPlayerState->playing()) { 341 if(mediaPlayerState->playing()) {
305// toggleButton(1); 342// toggleButton(1);
306 mediaPlayerState->setPlaying(FALSE); 343 mediaPlayerState->setPlaying(FALSE);
307// toggleButton(1); 344// toggleButton(1);
308 } else { 345 } else {
309// toggleButton(0); 346// toggleButton(0);
310 mediaPlayerState->setPlaying(TRUE); 347 mediaPlayerState->setPlaying(TRUE);
311// toggleButton(0); 348// toggleButton(0);
312 } 349 }
313 } 350 }
314 break; 351 break;
315 case Key_Down: 352 case Key_Down:
316 toggleButton(6); 353 toggleButton(6);
317 emit lessClicked(); 354 emit lessClicked();
318 emit lessReleased(); 355 emit lessReleased();
319 toggleButton(6); 356 toggleButton(6);
320 break; 357 break;
321 case Key_Up: 358 case Key_Up:
322 toggleButton(5); 359 toggleButton(5);
323 emit moreClicked(); 360 emit moreClicked();
324 emit moreReleased(); 361 emit moreReleased();
325 toggleButton(5); 362 toggleButton(5);
326 break; 363 break;
327 case Key_Right: 364 case Key_Right:
328// toggleButton(3); 365// toggleButton(3);
329 mediaPlayerState->setNext(); 366 mediaPlayerState->setNext();
330// toggleButton(3); 367// toggleButton(3);
331 break; 368 break;
332 case Key_Left: 369 case Key_Left:
333// toggleButton(4); 370// toggleButton(4);
334 mediaPlayerState->setPrev(); 371 mediaPlayerState->setPrev();
335// toggleButton(4); 372// toggleButton(4);
336 break; 373 break;
337 case Key_Escape: 374 case Key_Escape:
338 break; 375 break;
339 376
340 }; 377 };
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h
index eab5df4..441eb6e 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.h
+++ b/noncore/multimedia/opieplayer2/audiowidget.h
@@ -1,125 +1,95 @@
1#ifndef AUDIO_WIDGET_H 1#ifndef AUDIO_WIDGET_H
2#define AUDIO_WIDGET_H 2#define AUDIO_WIDGET_H
3 3
4#include <qwidget.h> 4#include <qwidget.h>
5#include <qpainter.h> 5#include <qpainter.h>
6#include <qdrawutil.h> 6#include <qdrawutil.h>
7#include <qpixmap.h> 7#include <qpixmap.h>
8#include <qstring.h> 8#include <qstring.h>
9#include <qslider.h> 9#include <qslider.h>
10#include <qframe.h> 10#include <qframe.h>
11 11
12 12
13class QPixmap; 13class QPixmap;
14 14
15enum AudioButtons { 15enum AudioButtons {
16 AudioPlay, 16 AudioPlay,
17 AudioStop, 17 AudioStop,
18 AudioPause, 18 AudioPause,
19 AudioNext, 19 AudioNext,
20 AudioPrevious, 20 AudioPrevious,
21 AudioVolumeUp, 21 AudioVolumeUp,
22 AudioVolumeDown, 22 AudioVolumeDown,
23 AudioLoop, 23 AudioLoop,
24 AudioPlayList 24 AudioPlayList
25}; 25};
26 26
27 27
28#define USE_DBLBUF 28#define USE_DBLBUF
29 29
30 30
31class Ticker : public QFrame { 31class Ticker : public QFrame {
32 Q_OBJECT 32 Q_OBJECT
33
33public: 34public:
34 Ticker( QWidget* parent=0 ) : QFrame( parent ) { 35 Ticker( QWidget* parent=0 );
35 setFrameStyle( WinPanel | Sunken ); 36 ~Ticker();
36 setText( "No Song" ); 37 void setText( const QString& text ) ;
37 } 38
38 ~Ticker() { }
39 void setText( const QString& text ) {
40 pos = 0; // reset it everytime the text is changed
41 scrollText = text;
42 pixelLen = fontMetrics().width( scrollText );
43 killTimers();
44 if ( pixelLen > width() )
45 startTimer( 50 );
46 update();
47 }
48protected: 39protected:
49 void timerEvent( QTimerEvent * ) { 40 void timerEvent( QTimerEvent * );
50 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; 41 void drawContents( QPainter *p );
51#ifndef USE_DBLBUF
52 scroll( -1, 0, contentsRect() );
53#else
54 repaint( FALSE );
55#endif
56 }
57 void drawContents( QPainter *p ) {
58#ifndef USE_DBLBUF
59 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen )
60 p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
61#else
62 // Double buffering code.
63 // Looks like qvfb makes it look like it flickers but I don't think it really is
64 QPixmap pm( width(), height() );
65 pm.fill( colorGroup().base() );
66 QPainter pmp( &pm );
67 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen )
68 pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
69 p->drawPixmap( 0, 0, pm );
70#endif
71 }
72private: 42private:
73 QString scrollText; 43 QString scrollText;
74 int pos, pixelLen; 44 int pos, pixelLen;
75}; 45};
76 46
77 47
78class AudioWidget : public QWidget { 48class AudioWidget : public QWidget {
79 Q_OBJECT 49 Q_OBJECT
80public: 50public:
81 AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); 51 AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 );
82 ~AudioWidget(); 52 ~AudioWidget();
83 void setTickerText( const QString &text ) { songInfo->setText( text ); } 53 void setTickerText( const QString &text ) { songInfo->setText( text ); }
84 bool isStreaming; 54 bool isStreaming;
85public slots: 55public slots:
86 void updateSlider( long, long ); 56 void updateSlider( long, long );
87 void sliderPressed( ); 57 void sliderPressed( );
88 void sliderReleased( ); 58 void sliderReleased( );
89 void setPaused( bool b) { setToggleButton( AudioPause, b ); } 59 void setPaused( bool b) { setToggleButton( AudioPause, b ); }
90 void setLooping( bool b) { setToggleButton( AudioLoop, b ); } 60 void setLooping( bool b) { setToggleButton( AudioLoop, b ); }
91 void setPlaying( bool b) { setToggleButton( AudioPlay, b ); } 61 void setPlaying( bool b) { setToggleButton( AudioPlay, b ); }
92 void setPosition( long ); 62 void setPosition( long );
93 void setLength( long ); 63 void setLength( long );
94 void setView( char ); 64 void setView( char );
95 65
96signals: 66signals:
97 void moreClicked(); 67 void moreClicked();
98 void lessClicked(); 68 void lessClicked();
99 void moreReleased(); 69 void moreReleased();
100 void lessReleased(); 70 void lessReleased();
101 void sliderMoved(long); 71 void sliderMoved(long);
102 72
103protected: 73protected:
104 void doBlank(); 74 void doBlank();
105 void doUnblank(); 75 void doUnblank();
106 void paintEvent( QPaintEvent *pe ); 76 void paintEvent( QPaintEvent *pe );
107 void showEvent( QShowEvent *se ); 77 void showEvent( QShowEvent *se );
108 void mouseMoveEvent( QMouseEvent *event ); 78 void mouseMoveEvent( QMouseEvent *event );
109 void mousePressEvent( QMouseEvent *event ); 79 void mousePressEvent( QMouseEvent *event );
110 void mouseReleaseEvent( QMouseEvent *event ); 80 void mouseReleaseEvent( QMouseEvent *event );
111 void timerEvent( QTimerEvent *event ); 81 void timerEvent( QTimerEvent *event );
112 void closeEvent( QCloseEvent *event ); 82 void closeEvent( QCloseEvent *event );
113 void keyReleaseEvent( QKeyEvent *e); 83 void keyReleaseEvent( QKeyEvent *e);
114private: 84private:
115 void toggleButton( int ); 85 void toggleButton( int );
116 void setToggleButton( int, bool ); 86 void setToggleButton( int, bool );
117 void paintButton( QPainter *p, int i ); 87 void paintButton( QPainter *p, int i );
118 QPixmap *pixmaps[4]; 88 QPixmap *pixmaps[4];
119 Ticker *songInfo; 89 Ticker *songInfo;
120 QSlider *slider; 90 QSlider *slider;
121}; 91};
122 92
123 93
124#endif // AUDIO_WIDGET_H 94#endif // AUDIO_WIDGET_H
125 95
diff --git a/noncore/multimedia/opieplayer2/inputDialog.cpp b/noncore/multimedia/opieplayer2/inputDialog.cpp
index da8e276..687aff6 100644
--- a/noncore/multimedia/opieplayer2/inputDialog.cpp
+++ b/noncore/multimedia/opieplayer2/inputDialog.cpp
@@ -1,67 +1,59 @@
1/****************************************************************************
2** Form implementation generated from reading ui file 'inputDialog.ui'
3**
4** Created: Sat Mar 2 07:55:03 2002
5** by: The User Interface Compiler (uic)
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9#include "inputDialog.h" 1#include "inputDialog.h"
10 2
11#include <qpe/resource.h> 3#include <qpe/resource.h>
12 4
13#include <opie/ofiledialog.h> 5#include <opie/ofiledialog.h>
14 6
15#include <qlineedit.h> 7#include <qlineedit.h>
16#include <qlayout.h> 8#include <qlayout.h>
17#include <qvariant.h> 9#include <qvariant.h>
18#include <qpushbutton.h> 10#include <qpushbutton.h>
19#include <qwhatsthis.h> 11#include <qwhatsthis.h>
20 12
21InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) 13InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
22 : QDialog( parent, name, modal, fl ) 14 : QDialog( parent, name, modal, fl )
23{ 15{
24 if ( !name ) 16 if ( !name )
25 setName( "InputDialog" ); 17 setName( "InputDialog" );
26 resize( 234, 115); 18 resize( 234, 115);
27 setMaximumSize( QSize( 240, 40)); 19 setMaximumSize( QSize( 240, 40));
28 setCaption( tr(name ) ); 20 setCaption( tr(name ) );
29 21
30 QPushButton *browserButton; 22 QPushButton *browserButton;
31 browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton"); 23 browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton");
32 browserButton->setGeometry( QRect( 205, 10, 22, 22)); 24 browserButton->setGeometry( QRect( 205, 10, 22, 22));
33 connect( browserButton, SIGNAL(released()),this,SLOT(browse())); 25 connect( browserButton, SIGNAL(released()),this,SLOT(browse()));
34 LineEdit1 = new QLineEdit( this, "LineEdit1" ); 26 LineEdit1 = new QLineEdit( this, "LineEdit1" );
35 LineEdit1->setGeometry( QRect( 4, 10, 190, 22 ) ); 27 LineEdit1->setGeometry( QRect( 4, 10, 190, 22 ) );
36} 28}
37 29
38/* 30/*
39 * Destroys the object and frees any allocated resources 31 * Destroys the object and frees any allocated resources
40 */ 32 */
41InputDialog::~InputDialog() 33InputDialog::~InputDialog()
42{ 34{
43 inputText= LineEdit1->text(); 35 inputText= LineEdit1->text();
44 36
45} 37}
46 38
47void InputDialog::browse() { 39void InputDialog::browse() {
48 40
49 MimeTypes types; 41 MimeTypes types;
50 QStringList audio, video, all; 42 QStringList audio, video, all;
51 audio << "audio/*"; 43 audio << "audio/*";
52 audio << "playlist/plain"; 44 audio << "playlist/plain";
53 audio << "audio/x-mpegurl"; 45 audio << "audio/x-mpegurl";
54 46
55 video << "video/*"; 47 video << "video/*";
56 video << "playlist/plain"; 48 video << "playlist/plain";
57 49
58 all += audio; 50 all += audio;
59 all += video; 51 all += video;
60 types.insert("All Media Files", all ); 52 types.insert("All Media Files", all );
61 types.insert("Audio", audio ); 53 types.insert("Audio", audio );
62 types.insert("Video", video ); 54 types.insert("Video", video );
63 55
64 QString str = OFileDialog::getOpenFileName( 1,"/","", types, 0 ); 56 QString str = OFileDialog::getOpenFileName( 1,"/","", types, 0 );
65 LineEdit1->setText(str); 57 LineEdit1->setText(str);
66} 58}
67 59
diff --git a/noncore/multimedia/opieplayer2/inputDialog.h b/noncore/multimedia/opieplayer2/inputDialog.h
index 3e3e36f..d4f5e12 100644
--- a/noncore/multimedia/opieplayer2/inputDialog.h
+++ b/noncore/multimedia/opieplayer2/inputDialog.h
@@ -1,30 +1,22 @@
1/**************************************************************************** 1
2** Form interface generated from reading ui file 'inputDialog.ui'
3**
4** Created: Sat Mar 2 07:54:46 2002
5** by: The User Interface Compiler (uic)
6**
7** WARNING! All changes made in this file will be lost!
8****************************************************************************/
9#ifndef INPUTDIALOG_H 2#ifndef INPUTDIALOG_H
10#define INPUTDIALOG_H 3#define INPUTDIALOG_H
11 4
12#include <qvariant.h> 5#include <qvariant.h>
13#include <qdialog.h> 6#include <qdialog.h>
14 7
15class QLineEdit; 8class QLineEdit;
16 9
17class InputDialog : public QDialog 10class InputDialog : public QDialog {
18{
19 Q_OBJECT 11 Q_OBJECT
20 12
21public: 13public:
22 InputDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); 14 InputDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
23 ~InputDialog(); 15 ~InputDialog();
24 QString inputText; 16 QString inputText;
25 QLineEdit* LineEdit1; 17 QLineEdit* LineEdit1;
26protected slots: 18protected slots:
27 void browse(); 19 void browse();
28}; 20};
29 21
30#endif // INPUTDIALOG_H 22#endif // INPUTDIALOG_H
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index e6d0525..87184ba 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -1,203 +1,163 @@
1#include <qpe/qpeapplication.h> 1#include <qpe/qpeapplication.h>
2#include <qpe/qlibrary.h> 2#include <qpe/qlibrary.h>
3#include <qpe/resource.h> 3#include <qpe/resource.h>
4#include <qpe/config.h> 4#include <qpe/config.h>
5 5
6#include <qmainwindow.h> 6#include <qmainwindow.h>
7#include <qmessagebox.h> 7#include <qmessagebox.h>
8#include <qwidgetstack.h> 8#include <qwidgetstack.h>
9#include <qfile.h> 9#include <qfile.h>
10 10
11#include "mediaplayer.h" 11#include "mediaplayer.h"
12#include "playlistwidget.h" 12#include "playlistwidget.h"
13#include "audiowidget.h" 13#include "audiowidget.h"
14 14
15#include "mediaplayerstate.h" 15#include "mediaplayerstate.h"
16 16
17 17
18extern AudioWidget *audioUI; 18extern AudioWidget *audioUI;
19extern PlayListWidget *playList; 19extern PlayListWidget *playList;
20extern MediaPlayerState *mediaPlayerState; 20extern MediaPlayerState *mediaPlayerState;
21 21
22 22
23MediaPlayer::MediaPlayer( QObject *parent, const char *name ) 23MediaPlayer::MediaPlayer( QObject *parent, const char *name )
24 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { 24 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) {
25 25
26 26
27// QPEApplication::grabKeyboard(); // EVIL 27// QPEApplication::grabKeyboard(); // EVIL
28 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 28 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
29 29
30 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); 30 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) );
31 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); 31 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) );
32 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); 32 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) );
33 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); 33 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) );
34 34
35 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 35 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
36 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 36 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
37 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 37 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
38 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 38 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
39} 39}
40 40
41MediaPlayer::~MediaPlayer() { 41MediaPlayer::~MediaPlayer() {
42} 42}
43 43
44void MediaPlayer::pauseCheck( bool b ) { 44void MediaPlayer::pauseCheck( bool b ) {
45 // Only pause if playing 45 // Only pause if playing
46 if ( b && !mediaPlayerState->playing() ) 46 if ( b && !mediaPlayerState->playing() )
47 mediaPlayerState->setPaused( FALSE ); 47 mediaPlayerState->setPaused( FALSE );
48} 48}
49 49
50void MediaPlayer::play() { 50void MediaPlayer::play() {
51 mediaPlayerState->setPlaying( FALSE ); 51 mediaPlayerState->setPlaying( FALSE );
52 mediaPlayerState->setPlaying( TRUE ); 52 mediaPlayerState->setPlaying( TRUE );
53} 53}
54 54
55void MediaPlayer::setPlaying( bool play ) { 55void MediaPlayer::setPlaying( bool play ) {
56 if ( !play ) { 56 if ( !play ) {
57 mediaPlayerState->setPaused( FALSE ); 57 mediaPlayerState->setPaused( FALSE );
58// loopControl->stop( FALSE ); 58 return;
59 return;
60 } 59 }
61 60
62 if ( mediaPlayerState->paused() ) { 61 if ( mediaPlayerState->paused() ) {
63 mediaPlayerState->setPaused( FALSE ); 62 mediaPlayerState->setPaused( FALSE );
64 return; 63 return;
65 } 64 }
66 65
67 const DocLnk *playListCurrent = playList->current(); 66 const DocLnk *playListCurrent = playList->current();
68 if ( playListCurrent != NULL ) { 67 if ( playListCurrent != NULL ) {
69// loopControl->stop( TRUE ); 68 currentFile = playListCurrent;
70 currentFile = playListCurrent;
71 }
72
73 /*
74
75 if ( currentFile == NULL ) {
76 QMessageBox::critical( 0, tr( "No file"), tr( "Error: There is no file selected" ) );
77 mediaPlayerState->setPlaying( FALSE );
78 return;
79 }
80
81 if ( ((currentFile->file()).left(4) != "http") && !QFile::exists( currentFile->file() ) ) {
82 QMessageBox::critical( 0, tr( "File not found"), tr( "The following file was not found: <i>" ) + currentFile->file() + "</i>" );
83 mediaPlayerState->setPlaying( FALSE );
84 return;
85 }
86
87 if ( !mediaPlayerState->newDecoder( currentFile->file() ) ) {
88 QMessageBox::critical( 0, tr( "No decoder found"), tr( "Sorry, no appropriate decoders found for this file: <i>" ) + currentFile->file() + "</i>" );
89 mediaPlayerState->setPlaying( FALSE );
90 return;
91 } 69 }
92 70
93// if ( !loopControl->init( currentFile->file() ) ) { 71 audioUI->setTickerText( currentFile->file() );
94// QMessageBox::critical( 0, tr( "Error opening file"), tr( "Sorry, an error occured trying to play the file: <i>" ) + currentFile->file() + "</i>" );
95// mediaPlayerState->setPlaying( FALSE );
96// return;
97// }
98// long seconds = loopControl->totalPlaytime();
99 long seconds = 120;
100 QString time;
101 time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
102 QString tickerText;
103 if( currentFile->file().left(4) == "http" )
104 tickerText= tr( " File: " ) + currentFile->name();
105 else
106 tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time;
107 72
108 QString fileInfo = mediaPlayerState->curDecoder()->fileInfo();
109 if ( !fileInfo.isEmpty() )
110 tickerText += ", " + fileInfo;
111 audioUI->setTickerText( tickerText + "." );
112 73
74 // alles nicht nötig, xine kümmert sich drum, man muss nur den return andio oder video gui geben
113 75
114 */ // alles nicht nötig, xine kümmert sich drum, man muss nur den return andio oder video gui geben 76 // Ob auch video 'v' : 'a'
77 // mediaPlayerState->setView( 'v' );
115 78
116 79 // abspielen starten.
117 // loopControl->play();
118
119 // mediaPlayerState->setView( loopControl->hasVideo() ? 'v' : 'a' );
120} 80}
121 81
122 82
123void MediaPlayer::prev() { 83void MediaPlayer::prev() {
124 if ( playList->prev() ) 84 if ( playList->prev() )
125 play(); 85 play();
126 else if ( mediaPlayerState->looping() ) { 86 else if ( mediaPlayerState->looping() ) {
127 if ( playList->last() ) 87 if ( playList->last() )
128 play(); 88 play();
129 } else 89 } else
130 mediaPlayerState->setList(); 90 mediaPlayerState->setList();
131} 91}
132 92
133 93
134void MediaPlayer::next() { 94void MediaPlayer::next() {
135 if ( playList->next() ) 95 if ( playList->next() )
136 play(); 96 play();
137 else if ( mediaPlayerState->looping() ) { 97 else if ( mediaPlayerState->looping() ) {
138 if ( playList->first() ) 98 if ( playList->first() )
139 play(); 99 play();
140 } else 100 } else
141 mediaPlayerState->setList(); 101 mediaPlayerState->setList();
142} 102}
143 103
144 104
145void MediaPlayer::startDecreasingVolume() { 105void MediaPlayer::startDecreasingVolume() {
146 volumeDirection = -1; 106 volumeDirection = -1;
147 startTimer( 100 ); 107 startTimer( 100 );
148 // sollte volumeapplet machen 108 // da kommt demchst osound denk ich mal
149 // AudioDevice::decreaseVolume(); 109 // AudioDevice::decreaseVolume();
150} 110}
151 111
152 112
153void MediaPlayer::startIncreasingVolume() { 113void MediaPlayer::startIncreasingVolume() {
154 volumeDirection = +1; 114 volumeDirection = +1;
155 startTimer( 100 ); 115 startTimer( 100 );
156 // AudioDevice::increaseVolume(); 116 // AudioDevice::increaseVolume();
157} 117}
158 118
159 119
160void MediaPlayer::stopChangingVolume() { 120void MediaPlayer::stopChangingVolume() {
161 killTimers(); 121 killTimers();
162} 122}
163 123
164 124
165void MediaPlayer::timerEvent( QTimerEvent * ) { 125void MediaPlayer::timerEvent( QTimerEvent * ) {
166// if ( volumeDirection == +1 ) 126 // if ( volumeDirection == +1 )
167// AudioDevice::increaseVolume(); 127 // AudioDevice::increaseVolume();
168// else if ( volumeDirection == -1 ) 128 // else if ( volumeDirection == -1 )
169 // AudioDevice::decreaseVolume(); 129 // AudioDevice::decreaseVolume();
170} 130}
171 131
172void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { 132void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {
173 switch ( e->key() ) { 133 switch ( e->key() ) {
174////////////////////////////// Zaurus keys 134////////////////////////////// Zaurus keys
175 case Key_Home: 135 case Key_Home:
176 break; 136 break;
177 case Key_F9: //activity 137 case Key_F9: //activity
178 break; 138 break;
179 case Key_F10: //contacts 139 case Key_F10: //contacts
180 break; 140 break;
181 case Key_F11: //menu 141 case Key_F11: //menu
182 break; 142 break;
183 case Key_F12: //home 143 case Key_F12: //home
184 qDebug("Blank here"); 144 qDebug("Blank here");
185 break; 145 break;
186 case Key_F13: //mail 146 case Key_F13: //mail
187 break; 147 break;
188 } 148 }
189} 149}
190 150
191void MediaPlayer::doBlank() { 151void MediaPlayer::doBlank() {
192 152
193} 153}
194 154
195void MediaPlayer::doUnblank() { 155void MediaPlayer::doUnblank() {
196 156
197} 157}
198 158
199void MediaPlayer::cleanUp() { 159void MediaPlayer::cleanUp() {
200// QPEApplication::grabKeyboard(); 160// QPEApplication::grabKeyboard();
201// QPEApplication::ungrabKeyboard(); 161// QPEApplication::ungrabKeyboard();
202 162
203} 163}
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
index 9b5f70e..d1d30e4 100644
--- a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
@@ -1,78 +1,70 @@
1 1
2 2
3 3
4#include <qpe/qpeapplication.h> 4#include <qpe/qpeapplication.h>
5#include <qpe/qlibrary.h> 5#include <qpe/qlibrary.h>
6#include <qpe/config.h> 6#include <qpe/config.h>
7#include <qvaluelist.h> 7#include <qvaluelist.h>
8#include <qobject.h> 8#include <qobject.h>
9#include <qdir.h> 9#include <qdir.h>
10#include <qpe/mediaplayerplugininterface.h> 10#include <qpe/mediaplayerplugininterface.h>
11#include "mediaplayerstate.h" 11#include "mediaplayerstate.h"
12 12
13 13
14 14
15#ifdef QT_NO_COMPONENT
16// Plugins which are compiled in when no plugin architecture available
17#include "libmad/libmadpluginimpl.h"
18#include "libmpeg3/libmpeg3pluginimpl.h"
19#include "wavplugin/wavpluginimpl.h"
20#endif
21
22
23//#define MediaPlayerDebug(x) qDebug x 15//#define MediaPlayerDebug(x) qDebug x
24#define MediaPlayerDebug(x) 16#define MediaPlayerDebug(x)
25 17
26 18
27MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) 19MediaPlayerState::MediaPlayerState( QObject *parent, const char *name )
28 : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) { 20 : QObject( parent, name ), decoder( NULL ) {
29 Config cfg( "OpiePlayer" ); 21 Config cfg( "OpiePlayer" );
30 readConfig( cfg ); 22 readConfig( cfg );
31} 23}
32 24
33 25
34MediaPlayerState::~MediaPlayerState() { 26MediaPlayerState::~MediaPlayerState() {
35 Config cfg( "OpiePlayer" ); 27 Config cfg( "OpiePlayer" );
36 writeConfig( cfg ); 28 writeConfig( cfg );
37} 29}
38 30
39 31
40void MediaPlayerState::readConfig( Config& cfg ) { 32void MediaPlayerState::readConfig( Config& cfg ) {
41 cfg.setGroup("Options"); 33 cfg.setGroup("Options");
42 isFullscreen = cfg.readBoolEntry( "FullScreen" ); 34 isFullscreen = cfg.readBoolEntry( "FullScreen" );
43 isScaled = cfg.readBoolEntry( "Scaling" ); 35 isScaled = cfg.readBoolEntry( "Scaling" );
44 isLooping = cfg.readBoolEntry( "Looping" ); 36 isLooping = cfg.readBoolEntry( "Looping" );
45 isShuffled = cfg.readBoolEntry( "Shuffle" ); 37 isShuffled = cfg.readBoolEntry( "Shuffle" );
46 usePlaylist = cfg.readBoolEntry( "UsePlayList" ); 38 usePlaylist = cfg.readBoolEntry( "UsePlayList" );
47 usePlaylist = TRUE; 39 usePlaylist = TRUE;
48 isPlaying = FALSE; 40 isPlaying = FALSE;
49 isPaused = FALSE; 41 isPaused = FALSE;
50 curPosition = 0; 42 curPosition = 0;
51 curLength = 0; 43 curLength = 0;
52 curView = 'l'; 44 curView = 'l';
53} 45}
54 46
55 47
56void MediaPlayerState::writeConfig( Config& cfg ) const { 48void MediaPlayerState::writeConfig( Config& cfg ) const {
57 cfg.setGroup("Options"); 49 cfg.setGroup("Options");
58 cfg.writeEntry("FullScreen", isFullscreen ); 50 cfg.writeEntry("FullScreen", isFullscreen );
59 cfg.writeEntry("Scaling", isScaled ); 51 cfg.writeEntry("Scaling", isScaled );
60 cfg.writeEntry("Looping", isLooping ); 52 cfg.writeEntry("Looping", isLooping );
61 cfg.writeEntry("Shuffle", isShuffled ); 53 cfg.writeEntry("Shuffle", isShuffled );
62 cfg.writeEntry("UsePlayList", usePlaylist ); 54 cfg.writeEntry("UsePlayList", usePlaylist );
63} 55}
64 56
65 57
66struct MediaPlayerPlugin { 58struct MediaPlayerPlugin {
67#ifndef QT_NO_COMPONENT 59#ifndef QT_NO_COMPONENT
68 QLibrary *library; 60 QLibrary *library;
69#endif 61#endif
70 MediaPlayerPluginInterface *iface; 62 MediaPlayerPluginInterface *iface;
71 MediaPlayerDecoder *decoder; 63 MediaPlayerDecoder *decoder;
72 MediaPlayerEncoder *encoder; 64 MediaPlayerEncoder *encoder;
73}; 65};
74 66
75 67
76static QValueList<MediaPlayerPlugin> pluginList; 68static QValueList<MediaPlayerPlugin> pluginList;
77 69
78 70
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.h b/noncore/multimedia/opieplayer2/mediaplayerstate.h
index 374e780..8a64939 100644
--- a/noncore/multimedia/opieplayer2/mediaplayerstate.h
+++ b/noncore/multimedia/opieplayer2/mediaplayerstate.h
@@ -1,100 +1,97 @@
1 1
2#ifndef MEDIA_PLAYER_STATE_H 2#ifndef MEDIA_PLAYER_STATE_H
3#define MEDIA_PLAYER_STATE_H 3#define MEDIA_PLAYER_STATE_H
4 4
5 5
6#include <qobject.h> 6#include <qobject.h>
7 7
8 8
9class MediaPlayerDecoder; 9class MediaPlayerDecoder;
10class Config; 10class Config;
11 11
12 12
13class MediaPlayerState : public QObject { 13class MediaPlayerState : public QObject {
14Q_OBJECT 14Q_OBJECT
15public: 15public:
16 MediaPlayerState( QObject *parent, const char *name ); 16 MediaPlayerState( QObject *parent, const char *name );
17 ~MediaPlayerState(); 17 ~MediaPlayerState();
18 18
19 bool isStreaming; 19 bool isStreaming;
20 bool fullscreen() { return isFullscreen; } 20 bool fullscreen() { return isFullscreen; }
21 bool scaled() { return isScaled; } 21 bool scaled() { return isScaled; }
22 bool looping() { return isLooping; } 22 bool looping() { return isLooping; }
23 bool shuffled() { return isShuffled; } 23 bool shuffled() { return isShuffled; }
24 bool playlist() { return usePlaylist; } 24 bool playlist() { return usePlaylist; }
25 bool paused() { return isPaused; } 25 bool paused() { return isPaused; }
26 bool playing() { return isPlaying; } 26 bool playing() { return isPlaying; }
27 long position() { return curPosition; } 27 long position() { return curPosition; }
28 long length() { return curLength; } 28 long length() { return curLength; }
29 char view() { return curView; } 29 char view() { return curView; }
30 30
31 MediaPlayerDecoder *newDecoder( const QString& file ); 31 MediaPlayerDecoder *newDecoder( const QString& file );
32 MediaPlayerDecoder *curDecoder(); 32 MediaPlayerDecoder *curDecoder();
33 MediaPlayerDecoder *libMpeg3Decoder(); // ### Yucky hack needed to use libmpeg3plugin to get the 33
34 // number of audio samples if we are using the libmad plugin
35public slots: 34public slots:
36 void setFullscreen( bool b ) { if ( isFullscreen == b ) return; isFullscreen = b; emit fullscreenToggled(b); } 35 void setFullscreen( bool b ) { if ( isFullscreen == b ) return; isFullscreen = b; emit fullscreenToggled(b); }
37 void setScaled( bool b ) { if ( isScaled == b ) return; isScaled = b; emit scaledToggled(b); } 36 void setScaled( bool b ) { if ( isScaled == b ) return; isScaled = b; emit scaledToggled(b); }
38 void setLooping( bool b ) { if ( isLooping == b ) return; isLooping = b; emit loopingToggled(b); } 37 void setLooping( bool b ) { if ( isLooping == b ) return; isLooping = b; emit loopingToggled(b); }
39 void setShuffled( bool b ) { if ( isShuffled == b ) return; isShuffled = b; emit shuffledToggled(b); } 38 void setShuffled( bool b ) { if ( isShuffled == b ) return; isShuffled = b; emit shuffledToggled(b); }
40 void setPlaylist( bool b ) { if ( usePlaylist == b ) return; usePlaylist = b; emit playlistToggled(b); } 39 void setPlaylist( bool b ) { if ( usePlaylist == b ) return; usePlaylist = b; emit playlistToggled(b); }
41 void setPaused( bool b ) { if ( isPaused == b ) return; isPaused = b; emit pausedToggled(b); } 40 void setPaused( bool b ) { if ( isPaused == b ) return; isPaused = b; emit pausedToggled(b); }
42 void setPlaying( bool b ) { if ( isPlaying == b ) return; isPlaying = b; emit playingToggled(b); } 41 void setPlaying( bool b ) { if ( isPlaying == b ) return; isPlaying = b; emit playingToggled(b); }
43 void setPosition( long p ) { if ( curPosition == p ) return; curPosition = p; emit positionChanged(p); } 42 void setPosition( long p ) { if ( curPosition == p ) return; curPosition = p; emit positionChanged(p); }
44 void updatePosition( long p ){ if ( curPosition == p ) return; curPosition = p; emit positionUpdated(p); } 43 void updatePosition( long p ){ if ( curPosition == p ) return; curPosition = p; emit positionUpdated(p); }
45 void setLength( long l ) { if ( curLength == l ) return; curLength = l; emit lengthChanged(l); } 44 void setLength( long l ) { if ( curLength == l ) return; curLength = l; emit lengthChanged(l); }
46 void setView( char v ) { if ( curView == v ) return; curView = v; emit viewChanged(v); } 45 void setView( char v ) { if ( curView == v ) return; curView = v; emit viewChanged(v); }
47 46
48 void setPrev() { emit prev(); } 47 void setPrev() { emit prev(); }
49 void setNext() { emit next(); } 48 void setNext() { emit next(); }
50 void setList() { setPlaying( FALSE ); setView('l'); } 49 void setList() { setPlaying( FALSE ); setView('l'); }
51 void setVideo() { setView('v'); } 50 void setVideo() { setView('v'); }
52 void setAudio() { setView('a'); } 51 void setAudio() { setView('a'); }
53 52
54 void toggleFullscreen() { setFullscreen( !isFullscreen ); } 53 void toggleFullscreen() { setFullscreen( !isFullscreen ); }
55 void toggleScaled() { setScaled( !isScaled); } 54 void toggleScaled() { setScaled( !isScaled); }
56 void toggleLooping() { setLooping( !isLooping); } 55 void toggleLooping() { setLooping( !isLooping); }
57 void toggleShuffled() { setShuffled( !isShuffled); } 56 void toggleShuffled() { setShuffled( !isShuffled); }
58 void togglePlaylist() { setPlaylist( !usePlaylist); } 57 void togglePlaylist() { setPlaylist( !usePlaylist); }
59 void togglePaused() { setPaused( !isPaused); } 58 void togglePaused() { setPaused( !isPaused); }
60 void togglePlaying() { setPlaying( !isPlaying); } 59 void togglePlaying() { setPlaying( !isPlaying); }
61 60
62signals: 61signals:
63 void fullscreenToggled( bool ); 62 void fullscreenToggled( bool );
64 void scaledToggled( bool ); 63 void scaledToggled( bool );
65 void loopingToggled( bool ); 64 void loopingToggled( bool );
66 void shuffledToggled( bool ); 65 void shuffledToggled( bool );
67 void playlistToggled( bool ); 66 void playlistToggled( bool );
68 void pausedToggled( bool ); 67 void pausedToggled( bool );
69 void playingToggled( bool ); 68 void playingToggled( bool );
70 void positionChanged( long ); // When the slider is moved 69 void positionChanged( long ); // When the slider is moved
71 void positionUpdated( long ); // When the media file progresses 70 void positionUpdated( long ); // When the media file progresses
72 void lengthChanged( long ); 71 void lengthChanged( long );
73 void viewChanged( char ); 72 void viewChanged( char );
74 73
75 void prev(); 74 void prev();
76 void next(); 75 void next();
77 76
78private: 77private:
79 bool isFullscreen; 78 bool isFullscreen;
80 bool isScaled; 79 bool isScaled;
81 bool isLooping; 80 bool isLooping;
82 bool isShuffled; 81 bool isShuffled;
83 bool usePlaylist; 82 bool usePlaylist;
84 bool isPaused; 83 bool isPaused;
85 bool isPlaying; 84 bool isPlaying;
86 long curPosition; 85 long curPosition;
87 long curLength; 86 long curLength;
88 char curView; 87 char curView;
89 88
90 MediaPlayerDecoder *decoder; 89 MediaPlayerDecoder *decoder;
91 MediaPlayerDecoder *libmpeg3decoder;
92// MediaPlayerDecoder *libwavdecoder;
93 90
94 void readConfig( Config& cfg ); 91 void readConfig( Config& cfg );
95 void writeConfig( Config& cfg ) const; 92 void writeConfig( Config& cfg ) const;
96}; 93};
97 94
98 95
99#endif // MEDIA_PLAYER_STATE_H 96#endif // MEDIA_PLAYER_STATE_H
100 97