summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp10
-rw-r--r--noncore/multimedia/opieplayer2/inputDialog.cpp14
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayerstate.cpp195
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayerstate.h75
4 files changed, 227 insertions, 67 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 1b0de5d..125fd72 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -1,287 +1,279 @@
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
58
59
60struct MediaButton { 58struct MediaButton {
61 int xPos, yPos; 59 int xPos, yPos;
62 int color; 60 int color;
63 bool isToggle, isBig, isHeld, isDown; 61 bool isToggle, isBig, isHeld, isDown;
64}; 62};
65 63
66 64
67
68
69// 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)
70MediaButton audioButtons[] = { 66MediaButton audioButtons[] = {
71 { 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
72 { 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
73 { 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
74 { 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
75 { 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
76 { 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
77 { 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
78 { 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
79 { 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
80}; 76};
81 77
82static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); 78static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
83 79
84 80
85AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : 81AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
86 QWidget( parent, name, f ) 82 QWidget( parent, name, f ) {
87{
88 setCaption( tr("OpiePlayer - Audio") ); 83 setCaption( tr("OpiePlayer - Audio") );
89 Config cfg("OpiePlayer"); 84 Config cfg("OpiePlayer");
90 cfg.setGroup("AudioWidget"); 85 cfg.setGroup("AudioWidget");
91 86
92 QString backgroundPix, buttonsAllPix, buttonsBigPix, controlsPix, animatedPix; 87 QString backgroundPix, buttonsAllPix, buttonsBigPix, controlsPix, animatedPix;
93 backgroundPix=cfg.readEntry( " backgroundPix", "opieplayer/metalFinish"); 88 backgroundPix=cfg.readEntry( " backgroundPix", "opieplayer/metalFinish");
94 buttonsAllPix=cfg.readEntry( "buttonsAllPix","opieplayer/mediaButtonsAll"); 89 buttonsAllPix=cfg.readEntry( "buttonsAllPix","opieplayer/mediaButtonsAll");
95 buttonsBigPix=cfg.readEntry( "buttonsBigPix","opieplayer/mediaButtonsBig"); 90 buttonsBigPix=cfg.readEntry( "buttonsBigPix","opieplayer/mediaButtonsBig");
96 controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls"); 91 controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls");
97 92
98 setBackgroundPixmap( Resource::loadPixmap( backgroundPix) ); 93 setBackgroundPixmap( Resource::loadPixmap( backgroundPix) );
99 pixmaps[0] = new QPixmap( Resource::loadPixmap( buttonsAllPix ) ); 94 pixmaps[0] = new QPixmap( Resource::loadPixmap( buttonsAllPix ) );
100 pixmaps[1] = new QPixmap( Resource::loadPixmap( buttonsBigPix ) ); 95 pixmaps[1] = new QPixmap( Resource::loadPixmap( buttonsBigPix ) );
101 pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix ) ); 96 pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix ) );
102 97
103 songInfo = new Ticker( this ); 98 songInfo = new Ticker( this );
104 songInfo->setFocusPolicy( QWidget::NoFocus ); 99 songInfo->setFocusPolicy( QWidget::NoFocus );
105 songInfo->setGeometry( QRect( 7, 3, 220, 20 ) ); 100 songInfo->setGeometry( QRect( 7, 3, 220, 20 ) );
106 101
107 slider = new QSlider( Qt::Horizontal, this ); 102 slider = new QSlider( Qt::Horizontal, this );
108 slider->setFixedWidth( 220 ); 103 slider->setFixedWidth( 220 );
109 slider->setFixedHeight( 20 ); 104 slider->setFixedHeight( 20 );
110 slider->setMinValue( 0 ); 105 slider->setMinValue( 0 );
111 slider->setMaxValue( 1 ); 106 slider->setMaxValue( 1 );
112 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 107 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
113 slider->setFocusPolicy( QWidget::NoFocus ); 108 slider->setFocusPolicy( QWidget::NoFocus );
114 slider->setGeometry( QRect( 7, 262, 220, 20 ) ); 109 slider->setGeometry( QRect( 7, 262, 220, 20 ) );
115 110
116 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 111 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
117 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 112 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
118 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 113 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
119 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 114 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
120 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 115 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
121 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 116 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
122 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 117 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
123 118
124 // Intialise state 119 // Intialise state
125 setLength( mediaPlayerState->length() ); 120 setLength( mediaPlayerState->length() );
126 setPosition( mediaPlayerState->position() ); 121 setPosition( mediaPlayerState->position() );
127 setLooping( mediaPlayerState->fullscreen() ); 122 setLooping( mediaPlayerState->fullscreen() );
128 setPaused( mediaPlayerState->paused() ); 123 setPaused( mediaPlayerState->paused() );
129 setPlaying( mediaPlayerState->playing() ); 124 setPlaying( mediaPlayerState->playing() );
130
131} 125}
132 126
133
134AudioWidget::~AudioWidget() { 127AudioWidget::~AudioWidget() {
135 mediaPlayerState->isStreaming = FALSE; 128 mediaPlayerState->isStreaming = FALSE;
136 for ( int i = 0; i < 3; i++ ) { 129 for ( int i = 0; i < 3; i++ ) {
137 delete pixmaps[i]; 130 delete pixmaps[i];
138 } 131 }
139} 132}
140 133
141 134
142static bool audioSliderBeingMoved = FALSE; 135static bool audioSliderBeingMoved = FALSE;
143 136
144 137
145void AudioWidget::sliderPressed() { 138void AudioWidget::sliderPressed() {
146 audioSliderBeingMoved = TRUE; 139 audioSliderBeingMoved = TRUE;
147} 140}
148 141
149 142
150void AudioWidget::sliderReleased() { 143void AudioWidget::sliderReleased() {
151 audioSliderBeingMoved = FALSE; 144 audioSliderBeingMoved = FALSE;
152 if ( slider->width() == 0 ) { 145 if ( slider->width() == 0 ) {
153 return; 146 return;
154 } 147 }
155 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); 148 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width());
156 mediaPlayerState->setPosition( val ); 149 mediaPlayerState->setPosition( val );
157} 150}
158 151
159
160void AudioWidget::setPosition( long i ) { 152void AudioWidget::setPosition( long i ) {
161 // qDebug("set position %d",i); 153 // qDebug("set position %d",i);
162 updateSlider( i, mediaPlayerState->length() ); 154 updateSlider( i, mediaPlayerState->length() );
163} 155}
164 156
165 157
166void AudioWidget::setLength( long max ) { 158void AudioWidget::setLength( long max ) {
167 updateSlider( mediaPlayerState->position(), max ); 159 updateSlider( mediaPlayerState->position(), max );
168} 160}
169 161
170 162
171void AudioWidget::setView( char view ) { 163void AudioWidget::setView( char view ) {
172 if (mediaPlayerState->isStreaming) { 164 if (mediaPlayerState->isStreaming) {
173 if( !slider->isHidden()) slider->hide(); 165 if( !slider->isHidden()) slider->hide();
174 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 166 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
175 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 167 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
176 } else { 168 } else {
177 // this stops the slider from being moved, thus 169 // this stops the slider from being moved, thus
178 // does not stop stream when it reaches the end 170 // does not stop stream when it reaches the end
179 slider->show(); 171 slider->show();
180 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 172 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
181 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 173 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
182 } 174 }
183 175
184 if ( view == 'a' ) { 176 if ( view == 'a' ) {
185 startTimer( 150 ); 177 startTimer( 150 );
186 showMaximized(); 178 showMaximized();
187 } else { 179 } else {
188 killTimers(); 180 killTimers();
189 hide(); 181 hide();
190 } 182 }
191} 183}
192 184
193 185
194void AudioWidget::updateSlider( long i, long max ) { 186void AudioWidget::updateSlider( long i, long max ) {
195 if ( max == 0 ) { 187 if ( max == 0 ) {
196 return; 188 return;
197 } 189 }
198 // Will flicker too much if we don't do this 190 // Will flicker too much if we don't do this
199 // Scale to something reasonable 191 // Scale to something reasonable
200 int width = slider->width(); 192 int width = slider->width();
201 int val = int((double)i * width / max); 193 int val = int((double)i * width / max);
202 if ( !audioSliderBeingMoved ) { 194 if ( !audioSliderBeingMoved ) {
203 if ( slider->value() != val ) { 195 if ( slider->value() != val ) {
204 slider->setValue( val ); 196 slider->setValue( val );
205 } 197 }
206 198
207 if ( slider->maxValue() != width ) { 199 if ( slider->maxValue() != width ) {
208 slider->setMaxValue( width ); 200 slider->setMaxValue( width );
209 } 201 }
210 } 202 }
211} 203}
212 204
213 205
214void AudioWidget::setToggleButton( int i, bool down ) { 206void AudioWidget::setToggleButton( int i, bool down ) {
215 if ( down != audioButtons[i].isDown ) { 207 if ( down != audioButtons[i].isDown ) {
216 toggleButton( i ); 208 toggleButton( i );
217 } 209 }
218} 210}
219 211
220 212
221void AudioWidget::toggleButton( int i ) { 213void AudioWidget::toggleButton( int i ) {
222 audioButtons[i].isDown = !audioButtons[i].isDown; 214 audioButtons[i].isDown = !audioButtons[i].isDown;
223 QPainter p(this); 215 QPainter p(this);
224 paintButton ( &p, i ); 216 paintButton ( &p, i );
225} 217}
226 218
227 219
228void AudioWidget::paintButton( QPainter *p, int i ) { 220void AudioWidget::paintButton( QPainter *p, int i ) {
229 int x = audioButtons[i].xPos; 221 int x = audioButtons[i].xPos;
230 int y = audioButtons[i].yPos; 222 int y = audioButtons[i].yPos;
231 int offset = 22 + 14 * audioButtons[i].isBig + audioButtons[i].isDown; 223 int offset = 22 + 14 * audioButtons[i].isBig + audioButtons[i].isDown;
232 int buttonSize = 64 + audioButtons[i].isBig * (90 - 64); 224 int buttonSize = 64 + audioButtons[i].isBig * (90 - 64);
233 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 );
234 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 );
235} 227}
236 228
237 229
238void AudioWidget::timerEvent( QTimerEvent * ) { 230void AudioWidget::timerEvent( QTimerEvent * ) {
239 static int frame = 0; 231 static int frame = 0;
240 if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { 232 if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) {
241 frame = frame >= 7 ? 0 : frame + 1; 233 frame = frame >= 7 ? 0 : frame + 1;
242 } 234 }
243} 235}
244 236
245 237
246void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 238void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
247 for ( int i = 0; i < numButtons; i++ ) { 239 for ( int i = 0; i < numButtons; i++ ) {
248 int size = audioButtons[i].isBig; 240 int size = audioButtons[i].isBig;
249 int x = audioButtons[i].xPos; 241 int x = audioButtons[i].xPos;
250 int y = audioButtons[i].yPos; 242 int y = audioButtons[i].yPos;
251 if ( event->state() == QMouseEvent::LeftButton ) { 243 if ( event->state() == QMouseEvent::LeftButton ) {
252 // 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
253 // (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)
254 int radius = 32 + 13 * size; 246 int radius = 32 + 13 * size;
255 QPoint center = QPoint( x + radius, y + radius ); 247 QPoint center = QPoint( x + radius, y + radius );
256 QPoint dXY = center - event->pos(); 248 QPoint dXY = center - event->pos();
257 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); 249 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y();
258 bool isOnButton = dist <= (radius * radius); 250 bool isOnButton = dist <= (radius * radius);
259 if ( isOnButton && !audioButtons[i].isHeld ) { 251 if ( isOnButton && !audioButtons[i].isHeld ) {
260 audioButtons[i].isHeld = TRUE; 252 audioButtons[i].isHeld = TRUE;
261 toggleButton(i); 253 toggleButton(i);
262 qDebug("button toggled1 %d",i); 254 qDebug("button toggled1 %d",i);
263 switch (i) { 255 switch (i) {
264 case AudioVolumeUp: emit moreClicked(); return; 256 case AudioVolumeUp: emit moreClicked(); return;
265 case AudioVolumeDown: emit lessClicked(); return; 257 case AudioVolumeDown: emit lessClicked(); return;
266 } 258 }
267 } else if ( !isOnButton && audioButtons[i].isHeld ) { 259 } else if ( !isOnButton && audioButtons[i].isHeld ) {
268 audioButtons[i].isHeld = FALSE; 260 audioButtons[i].isHeld = FALSE;
269 toggleButton(i); 261 toggleButton(i);
270 qDebug("button toggled2 %d",i); 262 qDebug("button toggled2 %d",i);
271 } 263 }
272 } else { 264 } else {
273 if ( audioButtons[i].isHeld ) { 265 if ( audioButtons[i].isHeld ) {
274 audioButtons[i].isHeld = FALSE; 266 audioButtons[i].isHeld = FALSE;
275 if ( !audioButtons[i].isToggle ) 267 if ( !audioButtons[i].isToggle )
276 setToggleButton( i, FALSE ); 268 setToggleButton( i, FALSE );
277 qDebug("button toggled3 %d",i); 269 qDebug("button toggled3 %d",i);
278 switch (i) { 270 switch (i) {
279 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; 271 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return;
280 case AudioStop: mediaPlayerState->setPlaying(FALSE); return; 272 case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
281 case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; 273 case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return;
282 case AudioNext: mediaPlayerState->setNext(); return; 274 case AudioNext: mediaPlayerState->setNext(); return;
283 case AudioPrevious: mediaPlayerState->setPrev(); return; 275 case AudioPrevious: mediaPlayerState->setPrev(); return;
284 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; 276 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return;
285 case AudioVolumeUp: emit moreReleased(); return; 277 case AudioVolumeUp: emit moreReleased(); return;
286 case AudioVolumeDown: emit lessReleased(); return; 278 case AudioVolumeDown: emit lessReleased(); return;
287 case AudioPlayList: mediaPlayerState->setList(); return; 279 case AudioPlayList: mediaPlayerState->setList(); return;
diff --git a/noncore/multimedia/opieplayer2/inputDialog.cpp b/noncore/multimedia/opieplayer2/inputDialog.cpp
index 687aff6..c13ea63 100644
--- a/noncore/multimedia/opieplayer2/inputDialog.cpp
+++ b/noncore/multimedia/opieplayer2/inputDialog.cpp
@@ -1,59 +1,57 @@
1#include "inputDialog.h" 1#include "inputDialog.h"
2 2
3#include <qpe/resource.h> 3#include <qpe/resource.h>
4 4
5#include <opie/ofiledialog.h> 5#include <opie/ofiledialog.h>
6 6
7#include <qlineedit.h> 7#include <qlineedit.h>
8#include <qlayout.h> 8#include <qlayout.h>
9#include <qvariant.h> 9#include <qvariant.h>
10#include <qpushbutton.h> 10#include <qpushbutton.h>
11#include <qwhatsthis.h> 11#include <qwhatsthis.h>
12 12
13InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) 13InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
14 : QDialog( parent, name, modal, fl ) 14 : QDialog( parent, name, modal, fl ) {
15{ 15 if ( !name ) {
16 if ( !name ) 16 setName( "InputDialog" );
17 setName( "InputDialog" ); 17 }
18 resize( 234, 115); 18 resize( 234, 115);
19 setMaximumSize( QSize( 240, 40)); 19 setMaximumSize( QSize( 240, 40));
20 setCaption( tr(name ) ); 20 setCaption( tr( name ) );
21 21
22 QPushButton *browserButton; 22 QPushButton *browserButton;
23 browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton"); 23 browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton");
24 browserButton->setGeometry( QRect( 205, 10, 22, 22)); 24 browserButton->setGeometry( QRect( 205, 10, 22, 22));
25 connect( browserButton, SIGNAL(released()),this,SLOT(browse())); 25 connect( browserButton, SIGNAL(released()),this,SLOT(browse()));
26 LineEdit1 = new QLineEdit( this, "LineEdit1" ); 26 LineEdit1 = new QLineEdit( this, "LineEdit1" );
27 LineEdit1->setGeometry( QRect( 4, 10, 190, 22 ) ); 27 LineEdit1->setGeometry( QRect( 4, 10, 190, 22 ) );
28} 28}
29 29
30/* 30/*
31 * Destroys the object and frees any allocated resources 31 * Destroys the object and frees any allocated resources
32 */ 32 */
33InputDialog::~InputDialog() 33InputDialog::~InputDialog() {
34{
35 inputText= LineEdit1->text(); 34 inputText= LineEdit1->text();
36
37} 35}
38 36
39void InputDialog::browse() { 37void InputDialog::browse() {
40 38
41 MimeTypes types; 39 MimeTypes types;
42 QStringList audio, video, all; 40 QStringList audio, video, all;
43 audio << "audio/*"; 41 audio << "audio/*";
44 audio << "playlist/plain"; 42 audio << "playlist/plain";
45 audio << "audio/x-mpegurl"; 43 audio << "audio/x-mpegurl";
46 44
47 video << "video/*"; 45 video << "video/*";
48 video << "playlist/plain"; 46 video << "playlist/plain";
49 47
50 all += audio; 48 all += audio;
51 all += video; 49 all += video;
52 types.insert("All Media Files", all ); 50 types.insert("All Media Files", all );
53 types.insert("Audio", audio ); 51 types.insert("Audio", audio );
54 types.insert("Video", video ); 52 types.insert("Video", video );
55 53
56 QString str = OFileDialog::getOpenFileName( 1,"/","", types, 0 ); 54 QString str = OFileDialog::getOpenFileName( 1,"/","", types, 0 );
57 LineEdit1->setText(str); 55 LineEdit1->setText(str);
58} 56}
59 57
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
index d1d30e4..2f24b00 100644
--- a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
@@ -1,70 +1,245 @@
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//#define MediaPlayerDebug(x) qDebug x 15//#define MediaPlayerDebug(x) qDebug x
16#define MediaPlayerDebug(x) 16#define MediaPlayerDebug(x)
17 17
18 18
19MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) 19MediaPlayerState::MediaPlayerState( QObject *parent, const char *name )
20 : QObject( parent, name ), decoder( NULL ) { 20 : QObject( parent, name ) {
21 Config cfg( "OpiePlayer" ); 21 Config cfg( "OpiePlayer" );
22 readConfig( cfg ); 22 readConfig( cfg );
23} 23}
24 24
25 25
26MediaPlayerState::~MediaPlayerState() { 26MediaPlayerState::~MediaPlayerState() {
27 Config cfg( "OpiePlayer" ); 27 Config cfg( "OpiePlayer" );
28 writeConfig( cfg ); 28 writeConfig( cfg );
29} 29}
30 30
31 31
32void MediaPlayerState::readConfig( Config& cfg ) { 32void MediaPlayerState::readConfig( Config& cfg ) {
33 cfg.setGroup("Options"); 33 cfg.setGroup("Options");
34 isFullscreen = cfg.readBoolEntry( "FullScreen" ); 34 isFullscreen = cfg.readBoolEntry( "FullScreen" );
35 isScaled = cfg.readBoolEntry( "Scaling" ); 35 isScaled = cfg.readBoolEntry( "Scaling" );
36 isLooping = cfg.readBoolEntry( "Looping" ); 36 isLooping = cfg.readBoolEntry( "Looping" );
37 isShuffled = cfg.readBoolEntry( "Shuffle" ); 37 isShuffled = cfg.readBoolEntry( "Shuffle" );
38 usePlaylist = cfg.readBoolEntry( "UsePlayList" ); 38 usePlaylist = cfg.readBoolEntry( "UsePlayList" );
39 usePlaylist = TRUE; 39 usePlaylist = TRUE;
40 isPlaying = FALSE; 40 isPlaying = FALSE;
41 isPaused = FALSE; 41 isPaused = FALSE;
42 curPosition = 0; 42 curPosition = 0;
43 curLength = 0; 43 curLength = 0;
44 curView = 'l'; 44 curView = 'l';
45} 45}
46 46
47 47
48void MediaPlayerState::writeConfig( Config& cfg ) const { 48void MediaPlayerState::writeConfig( Config& cfg ) const {
49 cfg.setGroup("Options"); 49 cfg.setGroup("Options");
50 cfg.writeEntry("FullScreen", isFullscreen ); 50 cfg.writeEntry("FullScreen", isFullscreen );
51 cfg.writeEntry("Scaling", isScaled ); 51 cfg.writeEntry("Scaling", isScaled );
52 cfg.writeEntry("Looping", isLooping ); 52 cfg.writeEntry("Looping", isLooping );
53 cfg.writeEntry("Shuffle", isShuffled ); 53 cfg.writeEntry("Shuffle", isShuffled );
54 cfg.writeEntry("UsePlayList", usePlaylist ); 54 cfg.writeEntry("UsePlayList", usePlaylist );
55} 55}
56 56
57 57
58struct MediaPlayerPlugin {
59#ifndef QT_NO_COMPONENT
60 QLibrary *library;
61#endif
62 MediaPlayerPluginInterface *iface;
63 MediaPlayerDecoder *decoder;
64 MediaPlayerEncoder *encoder;
65};
66 58
67 59
68static QValueList<MediaPlayerPlugin> pluginList; 60// public stuff
61bool MediaPlayerState::fullscreen() {
62 return isFullscreen;
63}
64
65bool MediaPlayerState::scaled() {
66 return isScaled;
67}
68
69bool MediaPlayerState::looping() {
70 return isLooping;
71}
72
73bool MediaPlayerState::shuffled() {
74 return isShuffled;
75}
76
77
78bool MediaPlayerState:: playlist() {
79 return usePlaylist;
80}
81
82bool MediaPlayerState::paused() {
83 return isPaused;
84}
85
86bool MediaPlayerState::playing() {
87 return isPlaying;
88}
89
90long MediaPlayerState::position() {
91 return curPosition;
92}
93
94long MediaPlayerState::length() {
95 return curLength;
96}
97
98char MediaPlayerState::view() {
99 return curView;
100}
101
102// slots
103void MediaPlayerState::setFullscreen( bool b ) {
104 if ( isFullscreen == b ) {
105 return;
106 }
107 isFullscreen = b;
108 emit fullscreenToggled(b);
109}
110
111
112void MediaPlayerState::setScaled( bool b ) {
113 if ( isScaled == b ) {
114 return;
115 }
116 isScaled = b;
117 emit scaledToggled(b);
118}
119
120void MediaPlayerState::setLooping( bool b ) {
121 if ( isLooping == b ) {
122 return;
123 }
124 isLooping = b;
125 emit loopingToggled(b);
126}
127
128void MediaPlayerState::setShuffled( bool b ) {
129 if ( isShuffled == b ) {
130 return;
131 }
132 isShuffled = b;
133 emit shuffledToggled(b);
134}
135
136void MediaPlayerState::setPlaylist( bool b ) {
137 if ( usePlaylist == b ) {
138 return;
139 }
140 usePlaylist = b;
141 emit playlistToggled(b);
142}
143
144void MediaPlayerState::setPaused( bool b ) {
145 if ( isPaused == b ) {
146 return;
147 }
148 isPaused = b;
149 emit pausedToggled(b);
150}
151
152void MediaPlayerState::setPlaying( bool b ) {
153 if ( isPlaying == b ) {
154 return;
155 }
156 isPlaying = b;
157 emit playingToggled(b);
158}
159
160void MediaPlayerState::setPosition( long p ) {
161 if ( curPosition == p ) {
162 return;
163 }
164 curPosition = p;
165 emit positionChanged(p);
166}
167
168void MediaPlayerState::updatePosition( long p ){
169 if ( curPosition == p ) {
170 return;
171 }
172 curPosition = p;
173 emit positionUpdated(p);
174}
175
176void MediaPlayerState::setLength( long l ) {
177 if ( curLength == l ) {
178 return;
179 }
180 curLength = l;
181 emit lengthChanged(l);
182}
183
184void MediaPlayerState::setView( char v ) {
185 if ( curView == v ) {
186 return;
187 }
188 curView = v;
189 emit viewChanged(v);
190}
191
192void MediaPlayerState::setPrev(){
193 emit prev();
194}
195
196void MediaPlayerState::setNext() {
197 emit next();
198}
199
200void MediaPlayerState::setList() {
201 setPlaying( FALSE );
202 setView('l');
203}
204
205void MediaPlayerState::setVideo() {
206 setView('v');
207}
208
209void MediaPlayerState::setAudio() {
210 setView('a');
211}
212
213
214
215void MediaPlayerState::toggleFullscreen() {
216 setFullscreen( !isFullscreen );
217}
218
219void MediaPlayerState::toggleScaled() {
220 setScaled( !isScaled);
221}
222
223void MediaPlayerState::toggleLooping() {
224 setLooping( !isLooping);
225}
226
227void MediaPlayerState::toggleShuffled() {
228 setShuffled( !isShuffled);
229}
230
231void MediaPlayerState::togglePlaylist() {
232 setPlaylist( !usePlaylist);
233}
234
235void MediaPlayerState::togglePaused() {
236 setPaused( !isPaused);
237}
238
239void MediaPlayerState::togglePlaying() {
240 setPlaying( !isPlaying);
241}
242
243
69 244
70 245
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.h b/noncore/multimedia/opieplayer2/mediaplayerstate.h
index 8a64939..7aa0ff2 100644
--- a/noncore/multimedia/opieplayer2/mediaplayerstate.h
+++ b/noncore/multimedia/opieplayer2/mediaplayerstate.h
@@ -1,97 +1,92 @@
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();
21 bool scaled() { return isScaled; } 21 bool scaled();
22 bool looping() { return isLooping; } 22 bool looping();
23 bool shuffled() { return isShuffled; } 23 bool shuffled();
24 bool playlist() { return usePlaylist; } 24 bool playlist();
25 bool paused() { return isPaused; } 25 bool paused();
26 bool playing() { return isPlaying; } 26 bool playing();
27 long position() { return curPosition; } 27 long position();
28 long length() { return curLength; } 28 long length();
29 char view() { return curView; } 29 char view();
30
31 MediaPlayerDecoder *newDecoder( const QString& file );
32 MediaPlayerDecoder *curDecoder();
33 30
34public slots: 31public slots:
35 void setFullscreen( bool b ) { if ( isFullscreen == b ) return; isFullscreen = b; emit fullscreenToggled(b); } 32 void setFullscreen( bool b );
36 void setScaled( bool b ) { if ( isScaled == b ) return; isScaled = b; emit scaledToggled(b); } 33 void setScaled( bool b );
37 void setLooping( bool b ) { if ( isLooping == b ) return; isLooping = b; emit loopingToggled(b); } 34 void setLooping( bool b );
38 void setShuffled( bool b ) { if ( isShuffled == b ) return; isShuffled = b; emit shuffledToggled(b); } 35 void setShuffled( bool b );
39 void setPlaylist( bool b ) { if ( usePlaylist == b ) return; usePlaylist = b; emit playlistToggled(b); } 36 void setPlaylist( bool b );
40 void setPaused( bool b ) { if ( isPaused == b ) return; isPaused = b; emit pausedToggled(b); } 37 void setPaused( bool b );
41 void setPlaying( bool b ) { if ( isPlaying == b ) return; isPlaying = b; emit playingToggled(b); } 38 void setPlaying( bool b );
42 void setPosition( long p ) { if ( curPosition == p ) return; curPosition = p; emit positionChanged(p); } 39 void setPosition( long p );
43 void updatePosition( long p ){ if ( curPosition == p ) return; curPosition = p; emit positionUpdated(p); } 40 void updatePosition( long p );
44 void setLength( long l ) { if ( curLength == l ) return; curLength = l; emit lengthChanged(l); } 41 void setLength( long l );
45 void setView( char v ) { if ( curView == v ) return; curView = v; emit viewChanged(v); } 42 void setView( char v );
46 43
47 void setPrev() { emit prev(); } 44 void setPrev() ;
48 void setNext() { emit next(); } 45 void setNext();
49 void setList() { setPlaying( FALSE ); setView('l'); } 46 void setList();
50 void setVideo() { setView('v'); } 47 void setVideo();
51 void setAudio() { setView('a'); } 48 void setAudio();
52 49
53 void toggleFullscreen() { setFullscreen( !isFullscreen ); } 50 void toggleFullscreen();
54 void toggleScaled() { setScaled( !isScaled); } 51 void toggleScaled();
55 void toggleLooping() { setLooping( !isLooping); } 52 void toggleLooping();
56 void toggleShuffled() { setShuffled( !isShuffled); } 53 void toggleShuffled();
57 void togglePlaylist() { setPlaylist( !usePlaylist); } 54 void togglePlaylist();
58 void togglePaused() { setPaused( !isPaused); } 55 void togglePaused();
59 void togglePlaying() { setPlaying( !isPlaying); } 56 void togglePlaying();
60 57
61signals: 58signals:
62 void fullscreenToggled( bool ); 59 void fullscreenToggled( bool );
63 void scaledToggled( bool ); 60 void scaledToggled( bool );
64 void loopingToggled( bool ); 61 void loopingToggled( bool );
65 void shuffledToggled( bool ); 62 void shuffledToggled( bool );
66 void playlistToggled( bool ); 63 void playlistToggled( bool );
67 void pausedToggled( bool ); 64 void pausedToggled( bool );
68 void playingToggled( bool ); 65 void playingToggled( bool );
69 void positionChanged( long ); // When the slider is moved 66 void positionChanged( long ); // When the slider is moved
70 void positionUpdated( long ); // When the media file progresses 67 void positionUpdated( long ); // When the media file progresses
71 void lengthChanged( long ); 68 void lengthChanged( long );
72 void viewChanged( char ); 69 void viewChanged( char );
73 70
74 void prev(); 71 void prev();
75 void next(); 72 void next();
76 73
77private: 74private:
78 bool isFullscreen; 75 bool isFullscreen;
79 bool isScaled; 76 bool isScaled;
80 bool isLooping; 77 bool isLooping;
81 bool isShuffled; 78 bool isShuffled;
82 bool usePlaylist; 79 bool usePlaylist;
83 bool isPaused; 80 bool isPaused;
84 bool isPlaying; 81 bool isPlaying;
85 long curPosition; 82 long curPosition;
86 long curLength; 83 long curLength;
87 char curView; 84 char curView;
88 85
89 MediaPlayerDecoder *decoder;
90
91 void readConfig( Config& cfg ); 86 void readConfig( Config& cfg );
92 void writeConfig( Config& cfg ) const; 87 void writeConfig( Config& cfg ) const;
93}; 88};
94 89
95 90
96#endif // MEDIA_PLAYER_STATE_H 91#endif // MEDIA_PLAYER_STATE_H
97 92