summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-07-09 01:02:37 (UTC)
committer harlekin <harlekin>2002-07-09 01:02:37 (UTC)
commit577841e20b5657411194d74a143b0319fc05cda3 (patch) (unidiff)
tree0e41da19fff8e2f47d43612a96d503b49b6a6a0b
parent56554891922367c5d4e7d0f6965daa1026c0cc54 (diff)
downloadopie-577841e20b5657411194d74a143b0319fc05cda3.zip
opie-577841e20b5657411194d74a143b0319fc05cda3.tar.gz
opie-577841e20b5657411194d74a143b0319fc05cda3.tar.bz2
more gui updates
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp4
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp7
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayerstate.cpp29
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayerstate.h8
-rw-r--r--noncore/multimedia/opieplayer2/xinecontrol.cpp9
5 files changed, 42 insertions, 15 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 125fd72..303e56e 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -1,370 +1,370 @@
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
18static const int xo = -2; // movable x offset 18static const int xo = -2; // movable x offset
19static const int yo = 22; // movable y offset 19static const int yo = 22; // movable y offset
20 20
21 21
22Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) { 22Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) {
23 setFrameStyle( WinPanel | Sunken ); 23 setFrameStyle( WinPanel | Sunken );
24 setText( "No Song" ); 24 setText( "No Song" );
25} 25}
26 26
27Ticker::~Ticker() { 27Ticker::~Ticker() {
28} 28}
29 29
30void Ticker::setText( const QString& text ) { 30void Ticker::setText( const QString& text ) {
31 pos = 0; // reset it everytime the text is changed 31 pos = 0; // reset it everytime the text is changed
32 scrollText = text; 32 scrollText = text;
33 pixelLen = fontMetrics().width( scrollText ); 33 pixelLen = fontMetrics().width( scrollText );
34 killTimers(); 34 killTimers();
35 if ( pixelLen > width() ) { 35 if ( pixelLen > width() ) {
36 startTimer( 50 ); 36 startTimer( 50 );
37 } 37 }
38 update(); 38 update();
39} 39}
40 40
41 41
42void Ticker::timerEvent( QTimerEvent * ) { 42void Ticker::timerEvent( QTimerEvent * ) {
43 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; 43 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1;
44 repaint( FALSE ); 44 repaint( FALSE );
45} 45}
46 46
47void Ticker::drawContents( QPainter *p ) { 47void Ticker::drawContents( QPainter *p ) {
48 QPixmap pm( width(), height() ); 48 QPixmap pm( width(), height() );
49 pm.fill( colorGroup().base() ); 49 pm.fill( colorGroup().base() );
50 QPainter pmp( &pm ); 50 QPainter pmp( &pm );
51 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { 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 ); 52 pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
53 } 53 }
54 p->drawPixmap( 0, 0, pm ); 54 p->drawPixmap( 0, 0, pm );
55} 55}
56 56
57 57
58struct MediaButton { 58struct MediaButton {
59 int xPos, yPos; 59 int xPos, yPos;
60 int color; 60 int color;
61 bool isToggle, isBig, isHeld, isDown; 61 bool isToggle, isBig, isHeld, isDown;
62}; 62};
63 63
64 64
65// Layout information for the audioButtons (and if it is a toggle button or not) 65// Layout information for the audioButtons (and if it is a toggle button or not)
66MediaButton audioButtons[] = { 66MediaButton audioButtons[] = {
67 { 3*30-15+xo, 3*30-13+yo, 0, TRUE, TRUE, FALSE, FALSE }, // play 67 { 3*30-15+xo, 3*30-13+yo, 0, TRUE, TRUE, FALSE, FALSE }, // play
68 { 1*30+xo, 5*30+yo, 2, FALSE, FALSE, FALSE, FALSE }, // stop 68 { 1*30+xo, 5*30+yo, 2, FALSE, FALSE, FALSE, FALSE }, // stop
69 { 5*30+xo, 5*30+yo, 2, TRUE, FALSE, FALSE, FALSE }, // pause 69 { 5*30+xo, 5*30+yo, 2, TRUE, FALSE, FALSE, FALSE }, // pause
70 { 6*30-5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // next 70 { 6*30-5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // next
71 { 0*30+5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // previous 71 { 0*30+5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // previous
72 { 3*30+xo, 0*30+5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume up 72 { 3*30+xo, 0*30+5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume up
73 { 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down 73 { 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down
74 { 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop 74 { 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop
75 { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist 75 { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist
76}; 76};
77 77
78static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); 78static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
79 79
80 80
81AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : 81AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
82 QWidget( parent, name, f ) { 82 QWidget( parent, name, f ) {
83 setCaption( tr("OpiePlayer - Audio") ); 83 setCaption( tr("OpiePlayer - Audio") );
84 Config cfg("OpiePlayer"); 84 Config cfg("OpiePlayer");
85 cfg.setGroup("AudioWidget"); 85 cfg.setGroup("AudioWidget");
86 86
87 QString backgroundPix, buttonsAllPix, buttonsBigPix, controlsPix, animatedPix; 87 QString backgroundPix, buttonsAllPix, buttonsBigPix, controlsPix, animatedPix;
88 backgroundPix=cfg.readEntry( " backgroundPix", "opieplayer/metalFinish"); 88 backgroundPix=cfg.readEntry( " backgroundPix", "opieplayer/metalFinish");
89 buttonsAllPix=cfg.readEntry( "buttonsAllPix","opieplayer/mediaButtonsAll"); 89 buttonsAllPix=cfg.readEntry( "buttonsAllPix","opieplayer/mediaButtonsAll");
90 buttonsBigPix=cfg.readEntry( "buttonsBigPix","opieplayer/mediaButtonsBig"); 90 buttonsBigPix=cfg.readEntry( "buttonsBigPix","opieplayer/mediaButtonsBig");
91 controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls"); 91 controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls");
92 92
93 setBackgroundPixmap( Resource::loadPixmap( backgroundPix) ); 93 setBackgroundPixmap( Resource::loadPixmap( backgroundPix) );
94 pixmaps[0] = new QPixmap( Resource::loadPixmap( buttonsAllPix ) ); 94 pixmaps[0] = new QPixmap( Resource::loadPixmap( buttonsAllPix ) );
95 pixmaps[1] = new QPixmap( Resource::loadPixmap( buttonsBigPix ) ); 95 pixmaps[1] = new QPixmap( Resource::loadPixmap( buttonsBigPix ) );
96 pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix ) ); 96 pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix ) );
97 97
98 songInfo = new Ticker( this ); 98 songInfo = new Ticker( this );
99 songInfo->setFocusPolicy( QWidget::NoFocus ); 99 songInfo->setFocusPolicy( QWidget::NoFocus );
100 songInfo->setGeometry( QRect( 7, 3, 220, 20 ) ); 100 songInfo->setGeometry( QRect( 7, 3, 220, 20 ) );
101 101
102 slider = new QSlider( Qt::Horizontal, this ); 102 slider = new QSlider( Qt::Horizontal, this );
103 slider->setFixedWidth( 220 ); 103 slider->setFixedWidth( 220 );
104 slider->setFixedHeight( 20 ); 104 slider->setFixedHeight( 20 );
105 slider->setMinValue( 0 ); 105 slider->setMinValue( 0 );
106 slider->setMaxValue( 1 ); 106 slider->setMaxValue( 1 );
107 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 107 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
108 slider->setFocusPolicy( QWidget::NoFocus ); 108 slider->setFocusPolicy( QWidget::NoFocus );
109 slider->setGeometry( QRect( 7, 262, 220, 20 ) ); 109 slider->setGeometry( QRect( 7, 262, 220, 20 ) );
110 110
111 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 111 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
112 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 112 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
113 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 113 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
114 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 114 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
115 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 115 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
116 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 116 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
117 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 117 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
118 118
119 // Intialise state 119 // Intialise state
120 setLength( mediaPlayerState->length() ); 120 setLength( mediaPlayerState->length() );
121 setPosition( mediaPlayerState->position() ); 121 setPosition( mediaPlayerState->position() );
122 setLooping( mediaPlayerState->fullscreen() ); 122 setLooping( mediaPlayerState->fullscreen() );
123 setPaused( mediaPlayerState->paused() ); 123 setPaused( mediaPlayerState->paused() );
124 setPlaying( mediaPlayerState->playing() ); 124 setPlaying( mediaPlayerState->playing() );
125} 125}
126 126
127AudioWidget::~AudioWidget() { 127AudioWidget::~AudioWidget() {
128 mediaPlayerState->isStreaming = FALSE; 128 mediaPlayerState->setIsStreaming( FALSE );
129 for ( int i = 0; i < 3; i++ ) { 129 for ( int i = 0; i < 3; i++ ) {
130 delete pixmaps[i]; 130 delete pixmaps[i];
131 } 131 }
132} 132}
133 133
134 134
135static bool audioSliderBeingMoved = FALSE; 135static bool audioSliderBeingMoved = FALSE;
136 136
137 137
138void AudioWidget::sliderPressed() { 138void AudioWidget::sliderPressed() {
139 audioSliderBeingMoved = TRUE; 139 audioSliderBeingMoved = TRUE;
140} 140}
141 141
142 142
143void AudioWidget::sliderReleased() { 143void AudioWidget::sliderReleased() {
144 audioSliderBeingMoved = FALSE; 144 audioSliderBeingMoved = FALSE;
145 if ( slider->width() == 0 ) { 145 if ( slider->width() == 0 ) {
146 return; 146 return;
147 } 147 }
148 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); 148 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width());
149 mediaPlayerState->setPosition( val ); 149 mediaPlayerState->setPosition( val );
150} 150}
151 151
152void AudioWidget::setPosition( long i ) { 152void AudioWidget::setPosition( long i ) {
153 // qDebug("set position %d",i); 153 // qDebug("set position %d",i);
154 updateSlider( i, mediaPlayerState->length() ); 154 updateSlider( i, mediaPlayerState->length() );
155} 155}
156 156
157 157
158void AudioWidget::setLength( long max ) { 158void AudioWidget::setLength( long max ) {
159 updateSlider( mediaPlayerState->position(), max ); 159 updateSlider( mediaPlayerState->position(), max );
160} 160}
161 161
162 162
163void AudioWidget::setView( char view ) { 163void AudioWidget::setView( char view ) {
164 if (mediaPlayerState->isStreaming) { 164 if (mediaPlayerState->streaming() ) {
165 if( !slider->isHidden()) slider->hide(); 165 if( !slider->isHidden()) slider->hide();
166 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 166 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
167 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 167 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
168 } else { 168 } else {
169 // this stops the slider from being moved, thus 169 // this stops the slider from being moved, thus
170 // does not stop stream when it reaches the end 170 // does not stop stream when it reaches the end
171 slider->show(); 171 slider->show();
172 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 172 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
173 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 173 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
174 } 174 }
175 175
176 if ( view == 'a' ) { 176 if ( view == 'a' ) {
177 startTimer( 150 ); 177 startTimer( 150 );
178 showMaximized(); 178 showMaximized();
179 } else { 179 } else {
180 killTimers(); 180 killTimers();
181 hide(); 181 hide();
182 } 182 }
183} 183}
184 184
185 185
186void AudioWidget::updateSlider( long i, long max ) { 186void AudioWidget::updateSlider( long i, long max ) {
187 if ( max == 0 ) { 187 if ( max == 0 ) {
188 return; 188 return;
189 } 189 }
190 // Will flicker too much if we don't do this 190 // Will flicker too much if we don't do this
191 // Scale to something reasonable 191 // Scale to something reasonable
192 int width = slider->width(); 192 int width = slider->width();
193 int val = int((double)i * width / max); 193 int val = int((double)i * width / max);
194 if ( !audioSliderBeingMoved ) { 194 if ( !audioSliderBeingMoved ) {
195 if ( slider->value() != val ) { 195 if ( slider->value() != val ) {
196 slider->setValue( val ); 196 slider->setValue( val );
197 } 197 }
198 198
199 if ( slider->maxValue() != width ) { 199 if ( slider->maxValue() != width ) {
200 slider->setMaxValue( width ); 200 slider->setMaxValue( width );
201 } 201 }
202 } 202 }
203} 203}
204 204
205 205
206void AudioWidget::setToggleButton( int i, bool down ) { 206void AudioWidget::setToggleButton( int i, bool down ) {
207 if ( down != audioButtons[i].isDown ) { 207 if ( down != audioButtons[i].isDown ) {
208 toggleButton( i ); 208 toggleButton( i );
209 } 209 }
210} 210}
211 211
212 212
213void AudioWidget::toggleButton( int i ) { 213void AudioWidget::toggleButton( int i ) {
214 audioButtons[i].isDown = !audioButtons[i].isDown; 214 audioButtons[i].isDown = !audioButtons[i].isDown;
215 QPainter p(this); 215 QPainter p(this);
216 paintButton ( &p, i ); 216 paintButton ( &p, i );
217} 217}
218 218
219 219
220void AudioWidget::paintButton( QPainter *p, int i ) { 220void AudioWidget::paintButton( QPainter *p, int i ) {
221 int x = audioButtons[i].xPos; 221 int x = audioButtons[i].xPos;
222 int y = audioButtons[i].yPos; 222 int y = audioButtons[i].yPos;
223 int offset = 22 + 14 * audioButtons[i].isBig + audioButtons[i].isDown; 223 int offset = 22 + 14 * audioButtons[i].isBig + audioButtons[i].isDown;
224 int buttonSize = 64 + audioButtons[i].isBig * (90 - 64); 224 int buttonSize = 64 + audioButtons[i].isBig * (90 - 64);
225 p->drawPixmap( x, y, *pixmaps[audioButtons[i].isBig], buttonSize * (audioButtons[i].isDown + 2 * audioButtons[i].color), 0, buttonSize, buttonSize ); 225 p->drawPixmap( x, y, *pixmaps[audioButtons[i].isBig], buttonSize * (audioButtons[i].isDown + 2 * audioButtons[i].color), 0, buttonSize, buttonSize );
226 p->drawPixmap( x + offset, y + offset, *pixmaps[2], 18 * i, 0, 18, 18 ); 226 p->drawPixmap( x + offset, y + offset, *pixmaps[2], 18 * i, 0, 18, 18 );
227} 227}
228 228
229 229
230void AudioWidget::timerEvent( QTimerEvent * ) { 230void AudioWidget::timerEvent( QTimerEvent * ) {
231 static int frame = 0; 231 static int frame = 0;
232 if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { 232 if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) {
233 frame = frame >= 7 ? 0 : frame + 1; 233 frame = frame >= 7 ? 0 : frame + 1;
234 } 234 }
235} 235}
236 236
237 237
238void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 238void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
239 for ( int i = 0; i < numButtons; i++ ) { 239 for ( int i = 0; i < numButtons; i++ ) {
240 int size = audioButtons[i].isBig; 240 int size = audioButtons[i].isBig;
241 int x = audioButtons[i].xPos; 241 int x = audioButtons[i].xPos;
242 int y = audioButtons[i].yPos; 242 int y = audioButtons[i].yPos;
243 if ( event->state() == QMouseEvent::LeftButton ) { 243 if ( event->state() == QMouseEvent::LeftButton ) {
244 // The test to see if the mouse click is inside the circular button or not 244 // The test to see if the mouse click is inside the circular button or not
245 // (compared with the radius squared to avoid a square-root of our distance) 245 // (compared with the radius squared to avoid a square-root of our distance)
246 int radius = 32 + 13 * size; 246 int radius = 32 + 13 * size;
247 QPoint center = QPoint( x + radius, y + radius ); 247 QPoint center = QPoint( x + radius, y + radius );
248 QPoint dXY = center - event->pos(); 248 QPoint dXY = center - event->pos();
249 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); 249 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y();
250 bool isOnButton = dist <= (radius * radius); 250 bool isOnButton = dist <= (radius * radius);
251 if ( isOnButton && !audioButtons[i].isHeld ) { 251 if ( isOnButton && !audioButtons[i].isHeld ) {
252 audioButtons[i].isHeld = TRUE; 252 audioButtons[i].isHeld = TRUE;
253 toggleButton(i); 253 toggleButton(i);
254 qDebug("button toggled1 %d",i); 254 qDebug("button toggled1 %d",i);
255 switch (i) { 255 switch (i) {
256 case AudioVolumeUp: emit moreClicked(); return; 256 case AudioVolumeUp: emit moreClicked(); return;
257 case AudioVolumeDown: emit lessClicked(); return; 257 case AudioVolumeDown: emit lessClicked(); return;
258 } 258 }
259 } else if ( !isOnButton && audioButtons[i].isHeld ) { 259 } else if ( !isOnButton && audioButtons[i].isHeld ) {
260 audioButtons[i].isHeld = FALSE; 260 audioButtons[i].isHeld = FALSE;
261 toggleButton(i); 261 toggleButton(i);
262 qDebug("button toggled2 %d",i); 262 qDebug("button toggled2 %d",i);
263 } 263 }
264 } else { 264 } else {
265 if ( audioButtons[i].isHeld ) { 265 if ( audioButtons[i].isHeld ) {
266 audioButtons[i].isHeld = FALSE; 266 audioButtons[i].isHeld = FALSE;
267 if ( !audioButtons[i].isToggle ) 267 if ( !audioButtons[i].isToggle )
268 setToggleButton( i, FALSE ); 268 setToggleButton( i, FALSE );
269 qDebug("button toggled3 %d",i); 269 qDebug("button toggled3 %d",i);
270 switch (i) { 270 switch (i) {
271 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; 271 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return;
272 case AudioStop: mediaPlayerState->setPlaying(FALSE); return; 272 case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
273 case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; 273 case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return;
274 case AudioNext: mediaPlayerState->setNext(); return; 274 case AudioNext: mediaPlayerState->setNext(); return;
275 case AudioPrevious: mediaPlayerState->setPrev(); return; 275 case AudioPrevious: mediaPlayerState->setPrev(); return;
276 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; 276 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return;
277 case AudioVolumeUp: emit moreReleased(); return; 277 case AudioVolumeUp: emit moreReleased(); return;
278 case AudioVolumeDown: emit lessReleased(); return; 278 case AudioVolumeDown: emit lessReleased(); return;
279 case AudioPlayList: mediaPlayerState->setList(); return; 279 case AudioPlayList: mediaPlayerState->setList(); return;
280 } 280 }
281 } 281 }
282 } 282 }
283 } 283 }
284} 284}
285 285
286 286
287void AudioWidget::mousePressEvent( QMouseEvent *event ) { 287void AudioWidget::mousePressEvent( QMouseEvent *event ) {
288 mouseMoveEvent( event ); 288 mouseMoveEvent( event );
289} 289}
290 290
291 291
292void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { 292void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
293 mouseMoveEvent( event ); 293 mouseMoveEvent( event );
294} 294}
295 295
296 296
297void AudioWidget::showEvent( QShowEvent* ) { 297void AudioWidget::showEvent( QShowEvent* ) {
298 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 298 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
299 mouseMoveEvent( &event ); 299 mouseMoveEvent( &event );
300} 300}
301 301
302 302
303void AudioWidget::closeEvent( QCloseEvent* ) { 303void AudioWidget::closeEvent( QCloseEvent* ) {
304 mediaPlayerState->setList(); 304 mediaPlayerState->setList();
305} 305}
306 306
307 307
308void AudioWidget::paintEvent( QPaintEvent * ) { 308void AudioWidget::paintEvent( QPaintEvent * ) {
309 QPainter p( this ); 309 QPainter p( this );
310 for ( int i = 0; i < numButtons; i++ ) 310 for ( int i = 0; i < numButtons; i++ )
311 paintButton( &p, i ); 311 paintButton( &p, i );
312} 312}
313 313
314void AudioWidget::keyReleaseEvent( QKeyEvent *e) 314void AudioWidget::keyReleaseEvent( QKeyEvent *e)
315{ 315{
316 switch ( e->key() ) { 316 switch ( e->key() ) {
317////////////////////////////// Zaurus keys 317////////////////////////////// Zaurus keys
318 case Key_Home: 318 case Key_Home:
319 break; 319 break;
320 case Key_F9: //activity 320 case Key_F9: //activity
321 hide(); 321 hide();
322// qDebug("Audio F9"); 322// qDebug("Audio F9");
323 break; 323 break;
324 case Key_F10: //contacts 324 case Key_F10: //contacts
325 break; 325 break;
326 case Key_F11: //menu 326 case Key_F11: //menu
327 break; 327 break;
328 case Key_F12: //home 328 case Key_F12: //home
329 break; 329 break;
330 case Key_F13: //mail 330 case Key_F13: //mail
331 break; 331 break;
332 case Key_Space: { 332 case Key_Space: {
333 if(mediaPlayerState->playing()) { 333 if(mediaPlayerState->playing()) {
334// toggleButton(1); 334// toggleButton(1);
335 mediaPlayerState->setPlaying(FALSE); 335 mediaPlayerState->setPlaying(FALSE);
336// toggleButton(1); 336// toggleButton(1);
337 } else { 337 } else {
338// toggleButton(0); 338// toggleButton(0);
339 mediaPlayerState->setPlaying(TRUE); 339 mediaPlayerState->setPlaying(TRUE);
340// toggleButton(0); 340// toggleButton(0);
341 } 341 }
342 } 342 }
343 break; 343 break;
344 case Key_Down: 344 case Key_Down:
345 toggleButton(6); 345 toggleButton(6);
346 emit lessClicked(); 346 emit lessClicked();
347 emit lessReleased(); 347 emit lessReleased();
348 toggleButton(6); 348 toggleButton(6);
349 break; 349 break;
350 case Key_Up: 350 case Key_Up:
351 toggleButton(5); 351 toggleButton(5);
352 emit moreClicked(); 352 emit moreClicked();
353 emit moreReleased(); 353 emit moreReleased();
354 toggleButton(5); 354 toggleButton(5);
355 break; 355 break;
356 case Key_Right: 356 case Key_Right:
357// toggleButton(3); 357// toggleButton(3);
358 mediaPlayerState->setNext(); 358 mediaPlayerState->setNext();
359// toggleButton(3); 359// toggleButton(3);
360 break; 360 break;
361 case Key_Left: 361 case Key_Left:
362// toggleButton(4); 362// toggleButton(4);
363 mediaPlayerState->setPrev(); 363 mediaPlayerState->setPrev();
364// toggleButton(4); 364// toggleButton(4);
365 break; 365 break;
366 case Key_Escape: 366 case Key_Escape:
367 break; 367 break;
368 368
369 }; 369 };
370} 370}
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index 0ab0124..38ba08f 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -1,172 +1,165 @@
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
18 18
19extern AudioWidget *audioUI; 19extern AudioWidget *audioUI;
20extern PlayListWidget *playList; 20extern PlayListWidget *playList;
21extern MediaPlayerState *mediaPlayerState; 21extern MediaPlayerState *mediaPlayerState;
22 22
23 23
24MediaPlayer::MediaPlayer( QObject *parent, const char *name ) 24MediaPlayer::MediaPlayer( QObject *parent, const char *name )
25 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { 25 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) {
26 26
27 27
28 xineControl = new XineControl(); 28 xineControl = new XineControl();
29// QPEApplication::grabKeyboard(); // EVIL 29// QPEApplication::grabKeyboard(); // EVIL
30 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 30 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
31 31
32 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); 32 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) );
33 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); 33 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) );
34 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); 34 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) );
35 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); 35 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) );
36 36
37 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 37 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
38 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 38 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
39 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 39 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
40 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 40 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
41 41
42} 42}
43 43
44MediaPlayer::~MediaPlayer() { 44MediaPlayer::~MediaPlayer() {
45} 45}
46 46
47void MediaPlayer::pauseCheck( bool b ) { 47void MediaPlayer::pauseCheck( bool b ) {
48 // Only pause if playing 48 // Only pause if playing
49 if ( b && !mediaPlayerState->playing() ) { 49 if ( b && !mediaPlayerState->playing() ) {
50 mediaPlayerState->setPaused( FALSE ); 50 mediaPlayerState->setPaused( FALSE );
51 } 51 }
52} 52}
53 53
54void MediaPlayer::play() { 54void MediaPlayer::play() {
55 mediaPlayerState->setPlaying( FALSE ); 55 mediaPlayerState->setPlaying( FALSE );
56 mediaPlayerState->setPlaying( TRUE ); 56 mediaPlayerState->setPlaying( TRUE );
57} 57}
58 58
59void MediaPlayer::setPlaying( bool play ) { 59void MediaPlayer::setPlaying( bool play ) {
60 if ( !play ) { 60 if ( !play ) {
61 mediaPlayerState->setPaused( FALSE ); 61 mediaPlayerState->setPaused( FALSE );
62 return; 62 return;
63 } 63 }
64 64
65 if ( mediaPlayerState->paused() ) { 65 if ( mediaPlayerState->paused() ) {
66 mediaPlayerState->setPaused( FALSE ); 66 mediaPlayerState->setPaused( FALSE );
67 return; 67 return;
68 } 68 }
69 69
70 const DocLnk *playListCurrent = playList->current(); 70 const DocLnk *playListCurrent = playList->current();
71 if ( playListCurrent != NULL ) { 71 if ( playListCurrent != NULL ) {
72 currentFile = playListCurrent; 72 currentFile = playListCurrent;
73 } 73 }
74 74
75 audioUI->setTickerText( currentFile->file( ) ); 75 audioUI->setTickerText( currentFile->file( ) );
76 76
77 xineControl->play( currentFile->file() ); 77 xineControl->play( currentFile->file() );
78
79 // alles nicht nötig, xine kümmert sich drum, man muss nur den return andio oder video gui geben
80
81 // Ob auch video 'v' : 'a'
82 // mediaPlayerState->setView( 'v' );
83
84 // abspielen starten.
85} 78}
86 79
87 80
88void MediaPlayer::prev() { 81void MediaPlayer::prev() {
89 if ( playList->prev() ) { 82 if ( playList->prev() ) {
90 play(); 83 play();
91 } else if ( mediaPlayerState->looping() ) { 84 } else if ( mediaPlayerState->looping() ) {
92 if ( playList->last() ) { 85 if ( playList->last() ) {
93 play(); 86 play();
94 } 87 }
95 } else { 88 } else {
96 mediaPlayerState->setList(); 89 mediaPlayerState->setList();
97 } 90 }
98} 91}
99 92
100 93
101void MediaPlayer::next() { 94void MediaPlayer::next() {
102 if ( playList->next() ) { 95 if ( playList->next() ) {
103 play(); 96 play();
104 } else if ( mediaPlayerState->looping() ) { 97 } else if ( mediaPlayerState->looping() ) {
105 if ( playList->first() ) { 98 if ( playList->first() ) {
106 play(); 99 play();
107 } 100 }
108 } else { 101 } else {
109 mediaPlayerState->setList(); 102 mediaPlayerState->setList();
110 } 103 }
111} 104}
112 105
113 106
114void MediaPlayer::startDecreasingVolume() { 107void MediaPlayer::startDecreasingVolume() {
115 volumeDirection = -1; 108 volumeDirection = -1;
116 startTimer( 100 ); 109 startTimer( 100 );
117 // da kommt demnächst osound denk ich mal 110 // da kommt demnächst osound denk ich mal
118 // AudioDevice::decreaseVolume(); 111 // AudioDevice::decreaseVolume();
119} 112}
120 113
121 114
122void MediaPlayer::startIncreasingVolume() { 115void MediaPlayer::startIncreasingVolume() {
123 volumeDirection = +1; 116 volumeDirection = +1;
124 startTimer( 100 ); 117 startTimer( 100 );
125 // AudioDevice::increaseVolume(); 118 // AudioDevice::increaseVolume();
126} 119}
127 120
128 121
129void MediaPlayer::stopChangingVolume() { 122void MediaPlayer::stopChangingVolume() {
130 killTimers(); 123 killTimers();
131} 124}
132 125
133 126
134void MediaPlayer::timerEvent( QTimerEvent * ) { 127void MediaPlayer::timerEvent( QTimerEvent * ) {
135 // if ( volumeDirection == +1 ) 128 // if ( volumeDirection == +1 )
136 // AudioDevice::increaseVolume(); 129 // AudioDevice::increaseVolume();
137 // else if ( volumeDirection == -1 ) 130 // else if ( volumeDirection == -1 )
138 // AudioDevice::decreaseVolume(); 131 // AudioDevice::decreaseVolume();
139} 132}
140 133
141void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { 134void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {
142 switch ( e->key() ) { 135 switch ( e->key() ) {
143////////////////////////////// Zaurus keys 136////////////////////////////// Zaurus keys
144 case Key_Home: 137 case Key_Home:
145 break; 138 break;
146 case Key_F9: //activity 139 case Key_F9: //activity
147 break; 140 break;
148 case Key_F10: //contacts 141 case Key_F10: //contacts
149 break; 142 break;
150 case Key_F11: //menu 143 case Key_F11: //menu
151 break; 144 break;
152 case Key_F12: //home 145 case Key_F12: //home
153 qDebug("Blank here"); 146 qDebug("Blank here");
154 break; 147 break;
155 case Key_F13: //mail 148 case Key_F13: //mail
156 break; 149 break;
157 } 150 }
158} 151}
159 152
160void MediaPlayer::doBlank() { 153void MediaPlayer::doBlank() {
161 154
162} 155}
163 156
164void MediaPlayer::doUnblank() { 157void MediaPlayer::doUnblank() {
165 158
166} 159}
167 160
168void MediaPlayer::cleanUp() { 161void MediaPlayer::cleanUp() {
169// QPEApplication::grabKeyboard(); 162// QPEApplication::grabKeyboard();
170// QPEApplication::ungrabKeyboard(); 163// QPEApplication::ungrabKeyboard();
171 164
172} 165}
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
index 3090b08..778cd1e 100644
--- a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
@@ -1,243 +1,268 @@
1#include <qpe/qpeapplication.h> 1#include <qpe/qpeapplication.h>
2#include <qpe/qlibrary.h> 2#include <qpe/qlibrary.h>
3#include <qpe/config.h> 3#include <qpe/config.h>
4#include <qvaluelist.h> 4#include <qvaluelist.h>
5#include <qobject.h> 5#include <qobject.h>
6#include <qdir.h> 6#include <qdir.h>
7#include "mediaplayerstate.h" 7#include "mediaplayerstate.h"
8 8
9 9
10 10
11//#define MediaPlayerDebug(x) qDebug x 11//#define MediaPlayerDebug(x) qDebug x
12#define MediaPlayerDebug(x) 12#define MediaPlayerDebug(x)
13 13
14 14
15MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) 15MediaPlayerState::MediaPlayerState( QObject *parent, const char *name )
16 : QObject( parent, name ) { 16 : QObject( parent, name ) {
17 Config cfg( "OpiePlayer" ); 17 Config cfg( "OpiePlayer" );
18 readConfig( cfg ); 18 readConfig( cfg );
19 19
20} 20}
21 21
22 22
23MediaPlayerState::~MediaPlayerState() { 23MediaPlayerState::~MediaPlayerState() {
24 Config cfg( "OpiePlayer" ); 24 Config cfg( "OpiePlayer" );
25 writeConfig( cfg ); 25 writeConfig( cfg );
26 26
27} 27}
28 28
29 29
30void MediaPlayerState::readConfig( Config& cfg ) { 30void MediaPlayerState::readConfig( Config& cfg ) {
31 cfg.setGroup("Options"); 31 cfg.setGroup("Options");
32 isFullscreen = cfg.readBoolEntry( "FullScreen" ); 32 isFullscreen = cfg.readBoolEntry( "FullScreen" );
33 isScaled = cfg.readBoolEntry( "Scaling" ); 33 isScaled = cfg.readBoolEntry( "Scaling" );
34 isLooping = cfg.readBoolEntry( "Looping" ); 34 isLooping = cfg.readBoolEntry( "Looping" );
35 isShuffled = cfg.readBoolEntry( "Shuffle" ); 35 isShuffled = cfg.readBoolEntry( "Shuffle" );
36 usePlaylist = cfg.readBoolEntry( "UsePlayList" ); 36 usePlaylist = cfg.readBoolEntry( "UsePlayList" );
37 usePlaylist = TRUE; 37 usePlaylist = TRUE;
38 isPlaying = FALSE; 38 isPlaying = FALSE;
39 isPaused = FALSE; 39 isPaused = FALSE;
40 curPosition = 0; 40 curPosition = 0;
41 curLength = 0; 41 curLength = 0;
42 curView = 'l'; 42 curView = 'l';
43} 43}
44 44
45 45
46void MediaPlayerState::writeConfig( Config& cfg ) const { 46void MediaPlayerState::writeConfig( Config& cfg ) const {
47 cfg.setGroup("Options"); 47 cfg.setGroup("Options");
48 cfg.writeEntry("FullScreen", isFullscreen ); 48 cfg.writeEntry("FullScreen", isFullscreen );
49 cfg.writeEntry("Scaling", isScaled ); 49 cfg.writeEntry("Scaling", isScaled );
50 cfg.writeEntry("Looping", isLooping ); 50 cfg.writeEntry("Looping", isLooping );
51 cfg.writeEntry("Shuffle", isShuffled ); 51 cfg.writeEntry("Shuffle", isShuffled );
52 cfg.writeEntry("UsePlayList", usePlaylist ); 52 cfg.writeEntry("UsePlayList", usePlaylist );
53} 53}
54 54
55 55
56 56
57 57
58// public stuff 58// public stuff
59
60
61bool MediaPlayerState::streaming() {
62 return isStreaming;
63}
64
59bool MediaPlayerState::fullscreen() { 65bool MediaPlayerState::fullscreen() {
60 return isFullscreen; 66 return isFullscreen;
61} 67}
62 68
63bool MediaPlayerState::scaled() { 69bool MediaPlayerState::scaled() {
64 return isScaled; 70 return isScaled;
65} 71}
66 72
67bool MediaPlayerState::looping() { 73bool MediaPlayerState::looping() {
68 return isLooping; 74 return isLooping;
69} 75}
70 76
71bool MediaPlayerState::shuffled() { 77bool MediaPlayerState::shuffled() {
72 return isShuffled; 78 return isShuffled;
73} 79}
74 80
75 81
76bool MediaPlayerState:: playlist() { 82bool MediaPlayerState:: playlist() {
77 return usePlaylist; 83 return usePlaylist;
78} 84}
79 85
80bool MediaPlayerState::paused() { 86bool MediaPlayerState::paused() {
81 return isPaused; 87 return isPaused;
82} 88}
83 89
84bool MediaPlayerState::playing() { 90bool MediaPlayerState::playing() {
85 return isPlaying; 91 return isPlaying;
86} 92}
87 93
94bool MediaPlayerState::stop() {
95 return isStoped;
96}
97
88long MediaPlayerState::position() { 98long MediaPlayerState::position() {
89 return curPosition; 99 return curPosition;
90} 100}
91 101
92long MediaPlayerState::length() { 102long MediaPlayerState::length() {
93 return curLength; 103 return curLength;
94} 104}
95 105
96char MediaPlayerState::view() { 106char MediaPlayerState::view() {
97 return curView; 107 return curView;
98} 108}
99 109
100// slots 110// slots
111void MediaPlayerState::setIsStreaming( bool b ) {
112 if ( isStreaming == b ) {
113 return;
114 }
115 isStreaming = b;
116}
117
118
101void MediaPlayerState::setFullscreen( bool b ) { 119void MediaPlayerState::setFullscreen( bool b ) {
102 if ( isFullscreen == b ) { 120 if ( isFullscreen == b ) {
103 return; 121 return;
104 } 122 }
105 isFullscreen = b; 123 isFullscreen = b;
106 emit fullscreenToggled(b); 124 emit fullscreenToggled(b);
107} 125}
108 126
109 127
110void MediaPlayerState::setScaled( bool b ) { 128void MediaPlayerState::setScaled( bool b ) {
111 if ( isScaled == b ) { 129 if ( isScaled == b ) {
112 return; 130 return;
113 } 131 }
114 isScaled = b; 132 isScaled = b;
115 emit scaledToggled(b); 133 emit scaledToggled(b);
116} 134}
117 135
118void MediaPlayerState::setLooping( bool b ) { 136void MediaPlayerState::setLooping( bool b ) {
119 if ( isLooping == b ) { 137 if ( isLooping == b ) {
120 return; 138 return;
121 } 139 }
122 isLooping = b; 140 isLooping = b;
123 emit loopingToggled(b); 141 emit loopingToggled(b);
124} 142}
125 143
126void MediaPlayerState::setShuffled( bool b ) { 144void MediaPlayerState::setShuffled( bool b ) {
127 if ( isShuffled == b ) { 145 if ( isShuffled == b ) {
128 return; 146 return;
129 } 147 }
130 isShuffled = b; 148 isShuffled = b;
131 emit shuffledToggled(b); 149 emit shuffledToggled(b);
132} 150}
133 151
134void MediaPlayerState::setPlaylist( bool b ) { 152void MediaPlayerState::setPlaylist( bool b ) {
135 if ( usePlaylist == b ) { 153 if ( usePlaylist == b ) {
136 return; 154 return;
137 } 155 }
138 usePlaylist = b; 156 usePlaylist = b;
139 emit playlistToggled(b); 157 emit playlistToggled(b);
140} 158}
141 159
142void MediaPlayerState::setPaused( bool b ) { 160void MediaPlayerState::setPaused( bool b ) {
143 if ( isPaused == b ) { 161 if ( isPaused == b ) {
144 return; 162 return;
145 } 163 }
146 isPaused = b; 164 isPaused = b;
147 emit pausedToggled(b); 165 emit pausedToggled(b);
148} 166}
149 167
150void MediaPlayerState::setPlaying( bool b ) { 168void MediaPlayerState::setPlaying( bool b ) {
151 if ( isPlaying == b ) { 169 if ( isPlaying == b ) {
152 return; 170 return;
153 } 171 }
154 isPlaying = b; 172 isPlaying = b;
173 isStoped = !b;
155 emit playingToggled(b); 174 emit playingToggled(b);
156} 175}
157 176
177void MediaPlayerState::setStop( bool b ) {
178 if ( isStoped == b ) {
179 return;
180 }
181 isStoped = b;
182 emit stopToggled(b);
183}
184
158void MediaPlayerState::setPosition( long p ) { 185void MediaPlayerState::setPosition( long p ) {
159 if ( curPosition == p ) { 186 if ( curPosition == p ) {
160 return; 187 return;
161 } 188 }
162 curPosition = p; 189 curPosition = p;
163 emit positionChanged(p); 190 emit positionChanged(p);
164} 191}
165 192
166void MediaPlayerState::updatePosition( long p ){ 193void MediaPlayerState::updatePosition( long p ){
167 if ( curPosition == p ) { 194 if ( curPosition == p ) {
168 return; 195 return;
169 } 196 }
170 curPosition = p; 197 curPosition = p;
171 emit positionUpdated(p); 198 emit positionUpdated(p);
172} 199}
173 200
174void MediaPlayerState::setLength( long l ) { 201void MediaPlayerState::setLength( long l ) {
175 if ( curLength == l ) { 202 if ( curLength == l ) {
176 return; 203 return;
177 } 204 }
178 curLength = l; 205 curLength = l;
179 emit lengthChanged(l); 206 emit lengthChanged(l);
180} 207}
181 208
182void MediaPlayerState::setView( char v ) { 209void MediaPlayerState::setView( char v ) {
183 if ( curView == v ) { 210 if ( curView == v ) {
184 return; 211 return;
185 } 212 }
186 curView = v; 213 curView = v;
187 emit viewChanged(v); 214 emit viewChanged(v);
188} 215}
189 216
190void MediaPlayerState::setPrev(){ 217void MediaPlayerState::setPrev(){
191 emit prev(); 218 emit prev();
192} 219}
193 220
194void MediaPlayerState::setNext() { 221void MediaPlayerState::setNext() {
195 emit next(); 222 emit next();
196} 223}
197 224
198void MediaPlayerState::setList() { 225void MediaPlayerState::setList() {
199 setPlaying( FALSE ); 226 setPlaying( FALSE );
200 setView('l'); 227 setView('l');
201} 228}
202 229
203void MediaPlayerState::setVideo() { 230void MediaPlayerState::setVideo() {
204 setView('v'); 231 setView('v');
205} 232}
206 233
207void MediaPlayerState::setAudio() { 234void MediaPlayerState::setAudio() {
208 setView('a'); 235 setView('a');
209} 236}
210 237
211
212
213void MediaPlayerState::toggleFullscreen() { 238void MediaPlayerState::toggleFullscreen() {
214 setFullscreen( !isFullscreen ); 239 setFullscreen( !isFullscreen );
215} 240}
216 241
217void MediaPlayerState::toggleScaled() { 242void MediaPlayerState::toggleScaled() {
218 setScaled( !isScaled); 243 setScaled( !isScaled);
219} 244}
220 245
221void MediaPlayerState::toggleLooping() { 246void MediaPlayerState::toggleLooping() {
222 setLooping( !isLooping); 247 setLooping( !isLooping);
223} 248}
224 249
225void MediaPlayerState::toggleShuffled() { 250void MediaPlayerState::toggleShuffled() {
226 setShuffled( !isShuffled); 251 setShuffled( !isShuffled);
227} 252}
228 253
229void MediaPlayerState::togglePlaylist() { 254void MediaPlayerState::togglePlaylist() {
230 setPlaylist( !usePlaylist); 255 setPlaylist( !usePlaylist);
231} 256}
232 257
233void MediaPlayerState::togglePaused() { 258void MediaPlayerState::togglePaused() {
234 setPaused( !isPaused); 259 setPaused( !isPaused);
235} 260}
236 261
237void MediaPlayerState::togglePlaying() { 262void MediaPlayerState::togglePlaying() {
238 setPlaying( !isPlaying); 263 setPlaying( !isPlaying);
239} 264}
240 265
241 266
242 267
243 268
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.h b/noncore/multimedia/opieplayer2/mediaplayerstate.h
index dbbb0f2..20e3552 100644
--- a/noncore/multimedia/opieplayer2/mediaplayerstate.h
+++ b/noncore/multimedia/opieplayer2/mediaplayerstate.h
@@ -1,94 +1,100 @@
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 streaming();
20 bool fullscreen(); 20 bool fullscreen();
21 bool scaled(); 21 bool scaled();
22 bool looping(); 22 bool looping();
23 bool shuffled(); 23 bool shuffled();
24 bool playlist(); 24 bool playlist();
25 bool paused(); 25 bool paused();
26 bool playing(); 26 bool playing();
27 bool stop();
27 long position(); 28 long position();
28 long length(); 29 long length();
29 char view(); 30 char view();
30 31
31public slots: 32public slots:
33 void setIsStreaming( bool b );
32 void setFullscreen( bool b ); 34 void setFullscreen( bool b );
33 void setScaled( bool b ); 35 void setScaled( bool b );
34 void setLooping( bool b ); 36 void setLooping( bool b );
35 void setShuffled( bool b ); 37 void setShuffled( bool b );
36 void setPlaylist( bool b ); 38 void setPlaylist( bool b );
37 void setPaused( bool b ); 39 void setPaused( bool b );
38 void setPlaying( bool b ); 40 void setPlaying( bool b );
41 void setStop( bool b );
39 void setPosition( long p ); 42 void setPosition( long p );
40 void updatePosition( long p ); 43 void updatePosition( long p );
41 void setLength( long l ); 44 void setLength( long l );
42 void setView( char v ); 45 void setView( char v );
43 46
44 void setPrev(); 47 void setPrev();
45 void setNext(); 48 void setNext();
46 void setList(); 49 void setList();
47 void setVideo(); 50 void setVideo();
48 void setAudio(); 51 void setAudio();
49 52
50 void toggleFullscreen(); 53 void toggleFullscreen();
51 void toggleScaled(); 54 void toggleScaled();
52 void toggleLooping(); 55 void toggleLooping();
53 void toggleShuffled(); 56 void toggleShuffled();
54 void togglePlaylist(); 57 void togglePlaylist();
55 void togglePaused(); 58 void togglePaused();
56 void togglePlaying(); 59 void togglePlaying();
57 60
58signals: 61signals:
59 void fullscreenToggled( bool ); 62 void fullscreenToggled( bool );
60 void scaledToggled( bool ); 63 void scaledToggled( bool );
61 void loopingToggled( bool ); 64 void loopingToggled( bool );
62 void shuffledToggled( bool ); 65 void shuffledToggled( bool );
63 void playlistToggled( bool ); 66 void playlistToggled( bool );
64 void pausedToggled( bool ); 67 void pausedToggled( bool );
65 void playingToggled( bool ); 68 void playingToggled( bool );
69 void stopToggled( bool );
66 void positionChanged( long ); // When the slider is moved 70 void positionChanged( long ); // When the slider is moved
67 void positionUpdated( long ); // When the media file progresses 71 void positionUpdated( long ); // When the media file progresses
68 void lengthChanged( long ); 72 void lengthChanged( long );
69 void viewChanged( char ); 73 void viewChanged( char );
70 74
71 void prev(); 75 void prev();
72 void next(); 76 void next();
73 77
74private: 78private:
79 bool isStreaming;
75 bool isFullscreen; 80 bool isFullscreen;
76 bool isScaled; 81 bool isScaled;
77 bool isLooping; 82 bool isLooping;
78 bool isShuffled; 83 bool isShuffled;
79 bool usePlaylist; 84 bool usePlaylist;
80 bool isPaused; 85 bool isPaused;
81 bool isPlaying; 86 bool isPlaying;
87 bool isStoped;
82 long curPosition; 88 long curPosition;
83 long curLength; 89 long curLength;
84 char curView; 90 char curView;
85 91
86 void readConfig( Config& cfg ); 92 void readConfig( Config& cfg );
87 void writeConfig( Config& cfg ) const; 93 void writeConfig( Config& cfg ) const;
88 94
89 95
90}; 96};
91 97
92 98
93#endif // MEDIA_PLAYER_STATE_H 99#endif // MEDIA_PLAYER_STATE_H
94 100
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp
index cda9be2..5b674f8 100644
--- a/noncore/multimedia/opieplayer2/xinecontrol.cpp
+++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp
@@ -1,59 +1,62 @@
1 1
2#include "xinecontrol.h" 2#include "xinecontrol.h"
3#include "mediaplayerstate.h" 3#include "mediaplayerstate.h"
4 4
5extern MediaPlayerState *mediaPlayerState; 5extern MediaPlayerState *mediaPlayerState;
6 6
7XineControl::XineControl( QObject *parent, const char *name ) 7XineControl::XineControl( QObject *parent, const char *name )
8 : QObject( parent, name ) { 8 : QObject( parent, name ) {
9 libXine = new XINE::Lib(); 9 libXine = new XINE::Lib();
10 10
11 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); 11 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) );
12 connect( this, SIGNAL( positionChanged( int position ) ), mediaPlayerState, SLOT( updatePosition( long p ) ) ); 12 connect( this, SIGNAL( positionChanged( int position ) ), mediaPlayerState, SLOT( updatePosition( long p ) ) );
13 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); 13 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) );
14 14
15} 15}
16 16
17XineControl::~XineControl() { 17XineControl::~XineControl() {
18 delete libXine; 18 delete libXine;
19} 19}
20 20
21void XineControl::play( const QString& fileName ) { 21void XineControl::play( const QString& fileName ) {
22 libXine->play( fileName ); 22 libXine->play( fileName );
23 mediaPlayerState->setPlaying( true ); 23 mediaPlayerState->setPlaying( true );
24 // default to audio view until we know how to handle video 24 // default to audio view until we know how to handle video
25 mediaPlayerState->setView('a'); 25 mediaPlayerState->setView('a');
26 // determines of slider is shown 26 // determines of slider is shown
27 mediaPlayerState->isStreaming = false; 27 // mediaPlayerState->setIsStreaming( false );
28 // hier dann schaun welcher view 28 // hier dann schaun welcher view
29} 29}
30 30
31void XineControl::stop( bool isSet ) { 31void XineControl::stop( bool isSet ) {
32 if ( isSet) { 32 if ( !isSet) {
33 libXine->stop(); 33 libXine->stop();
34 mediaPlayerState->setNext();
35 //mediaPlayerState->setPlaying( false );
36 } else {
37 // play again
34 } 38 }
35 // mediaPlayerState->setPlaying( false );
36} 39}
37 40
38void XineControl::pause( bool isSet) { 41void XineControl::pause( bool isSet) {
39 42
40 libXine->pause(); 43 libXine->pause();
41} 44}
42 45
43int XineControl::currentTime() { 46int XineControl::currentTime() {
44 // todo: jede sekunde überprüfen 47 // todo: jede sekunde überprüfen
45 m_currentTime = libXine->currentTime(); 48 m_currentTime = libXine->currentTime();
46 return m_currentTime; 49 return m_currentTime;
47} 50}
48 51
49void XineControl::length() { 52void XineControl::length() {
50 m_length = libXine->length(); 53 m_length = libXine->length();
51 mediaPlayerState->setLength( m_length ); 54 mediaPlayerState->setLength( m_length );
52} 55}
53 56
54int XineControl::position() { 57int XineControl::position() {
55 m_position = (m_currentTime/m_length*100); 58 m_position = (m_currentTime/m_length*100);
56 mediaPlayerState->setPosition( m_position ); 59 mediaPlayerState->setPosition( m_position );
57 return m_position; 60 return m_position;
58 emit positionChanged( m_position ); 61 emit positionChanged( m_position );
59} 62}