summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-08-03 14:19:05 (UTC)
committer llornkcor <llornkcor>2002-08-03 14:19:05 (UTC)
commitaa06a62511cabebeaad1d3dda34b30640f967dea (patch) (unidiff)
treea6887240b094f46de46b743135a2e918ba3254ad
parentd3c13036415713932f1706e46fa7c99ef38188df (diff)
downloadopie-aa06a62511cabebeaad1d3dda34b30640f967dea.zip
opie-aa06a62511cabebeaad1d3dda34b30640f967dea.tar.gz
opie-aa06a62511cabebeaad1d3dda34b30640f967dea.tar.bz2
audiowidget now shows time and slider moves.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp6
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayerstate.cpp1
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayerstate.h6
-rw-r--r--noncore/multimedia/opieplayer2/opieplayer2.pro12
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp3
-rw-r--r--noncore/multimedia/opieplayer2/xinecontrol.cpp9
-rw-r--r--noncore/multimedia/opieplayer2/xinecontrol.h5
7 files changed, 22 insertions, 20 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 303834a..23f4329 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -1,497 +1,497 @@
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 <stdlib.h> 13#include <stdlib.h>
14#include <stdio.h> 14#include <stdio.h>
15 15
16#include "audiowidget.h" 16#include "audiowidget.h"
17#include "mediaplayerstate.h" 17#include "mediaplayerstate.h"
18 18
19extern MediaPlayerState *mediaPlayerState; 19extern MediaPlayerState *mediaPlayerState;
20 20
21static const int xo = -2; // movable x offset 21static const int xo = -2; // movable x offset
22static const int yo = 22; // movable y offset 22static const int yo = 22; // movable y offset
23 23
24 24
25Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) { 25Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) {
26 setFrameStyle( WinPanel | Sunken ); 26 setFrameStyle( WinPanel | Sunken );
27 setText( "No Song" ); 27 setText( "No Song" );
28} 28}
29 29
30Ticker::~Ticker() { 30Ticker::~Ticker() {
31} 31}
32 32
33void Ticker::setText( const QString& text ) { 33void Ticker::setText( const QString& text ) {
34 pos = 0; // reset it everytime the text is changed 34 pos = 0; // reset it everytime the text is changed
35 scrollText = text; 35 scrollText = text;
36 pixelLen = fontMetrics().width( scrollText ); 36 pixelLen = fontMetrics().width( scrollText );
37 killTimers(); 37 killTimers();
38 if ( pixelLen > width() ) { 38 if ( pixelLen > width() ) {
39 startTimer( 50 ); 39 startTimer( 50 );
40 } 40 }
41 update(); 41 update();
42} 42}
43 43
44 44
45void Ticker::timerEvent( QTimerEvent * ) { 45void Ticker::timerEvent( QTimerEvent * ) {
46 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; 46 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1;
47 scroll( -1, 0, contentsRect() ); 47 scroll( -1, 0, contentsRect() );
48 repaint( FALSE ); 48 repaint( FALSE );
49} 49}
50 50
51void Ticker::drawContents( QPainter *p ) { 51void Ticker::drawContents( QPainter *p ) {
52 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) 52 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen )
53 p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); 53 p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
54 QPixmap pm( width(), height() ); 54 QPixmap pm( width(), height() );
55 pm.fill( colorGroup().base() ); 55 pm.fill( colorGroup().base() );
56 QPainter pmp( &pm ); 56 QPainter pmp( &pm );
57 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { 57 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) {
58 pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); 58 pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
59 } 59 }
60 p->drawPixmap( 0, 0, pm ); 60 p->drawPixmap( 0, 0, pm );
61} 61}
62 62
63struct MediaButton { 63struct MediaButton {
64 bool isToggle, isHeld, isDown; 64 bool isToggle, isHeld, isDown;
65}; 65};
66 66
67//Layout information for the audioButtons (and if it is a toggle button or not) 67//Layout information for the audioButtons (and if it is a toggle button or not)
68MediaButton audioButtons[] = { 68MediaButton audioButtons[] = {
69 { TRUE, FALSE, FALSE }, // play 69 { TRUE, FALSE, FALSE }, // play
70 { FALSE, FALSE, FALSE }, // stop 70 { FALSE, FALSE, FALSE }, // stop
71 { TRUE, FALSE, FALSE }, // pause 71 { TRUE, FALSE, FALSE }, // pause
72 { FALSE, FALSE, FALSE }, // next 72 { FALSE, FALSE, FALSE }, // next
73 { FALSE, FALSE, FALSE }, // previous 73 { FALSE, FALSE, FALSE }, // previous
74 { FALSE, FALSE, FALSE }, // volume up 74 { FALSE, FALSE, FALSE }, // volume up
75 { FALSE, FALSE, FALSE }, // volume down 75 { FALSE, FALSE, FALSE }, // volume down
76 { TRUE, FALSE, FALSE }, // repeat/loop 76 { TRUE, FALSE, FALSE }, // repeat/loop
77 { FALSE, FALSE, FALSE }, // playlist 77 { FALSE, FALSE, FALSE }, // playlist
78 { FALSE, FALSE, FALSE }, // forward 78 { FALSE, FALSE, FALSE }, // forward
79 { FALSE, FALSE, FALSE } // back 79 { FALSE, FALSE, FALSE } // back
80}; 80};
81 81
82const char *skin_mask_file_names[11] = { 82const char *skin_mask_file_names[11] = {
83 "play", "stop", "pause", "next", "prev", "up", 83 "play", "stop", "pause", "next", "prev", "up",
84 "down", "loop", "playlist", "forward", "back" 84 "down", "loop", "playlist", "forward", "back"
85}; 85};
86 86
87 87
88static void changeTextColor( QWidget *w ) { 88static void changeTextColor( QWidget *w ) {
89 QPalette p = w->palette(); 89 QPalette p = w->palette();
90 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); 90 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) );
91 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); 91 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) );
92 w->setPalette( p ); 92 w->setPalette( p );
93} 93}
94 94
95static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); 95static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
96 96
97 97
98AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : 98AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
99 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { 99 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) {
100 setCaption( tr("OpiePlayer") ); 100 setCaption( tr("OpiePlayer") );
101 101
102 Config cfg("OpiePlayer"); 102 Config cfg("OpiePlayer");
103 cfg.setGroup("AudioWidget"); 103 cfg.setGroup("AudioWidget");
104 skin = cfg.readEntry("Skin","default"); 104 skin = cfg.readEntry("Skin","default");
105 //skin = "scaleTest"; 105 //skin = "scaleTest";
106// color of background, frame, degree of transparency 106// color of background, frame, degree of transparency
107 107
108 QString skinPath = "opieplayer/skins/" + skin; 108 QString skinPath = "opieplayer/skins/" + skin;
109 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 109 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
110 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); 110 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
111 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); 111 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
112 112
113 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); 113 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
114 imgButtonMask->fill( 0 ); 114 imgButtonMask->fill( 0 );
115 115
116 for ( int i = 0; i < 11; i++ ) { 116 for ( int i = 0; i < 11; i++ ) {
117 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; 117 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png";
118 masks[i] = new QBitmap( filename ); 118 masks[i] = new QBitmap( filename );
119 119
120 if ( !masks[i]->isNull() ) { 120 if ( !masks[i]->isNull() ) {
121 QImage imgMask = masks[i]->convertToImage(); 121 QImage imgMask = masks[i]->convertToImage();
122 uchar **dest = imgButtonMask->jumpTable(); 122 uchar **dest = imgButtonMask->jumpTable();
123 for ( int y = 0; y < imgUp->height(); y++ ) { 123 for ( int y = 0; y < imgUp->height(); y++ ) {
124 uchar *line = dest[y]; 124 uchar *line = dest[y];
125 for ( int x = 0; x < imgUp->width(); x++ ) 125 for ( int x = 0; x < imgUp->width(); x++ )
126 if ( !qRed( imgMask.pixel( x, y ) ) ) 126 if ( !qRed( imgMask.pixel( x, y ) ) )
127 line[x] = i + 1; 127 line[x] = i + 1;
128 } 128 }
129 } 129 }
130 130
131 } 131 }
132 132
133 for ( int i = 0; i < 11; i++ ) { 133 for ( int i = 0; i < 11; i++ ) {
134 buttonPixUp[i] = NULL; 134 buttonPixUp[i] = NULL;
135 buttonPixDown[i] = NULL; 135 buttonPixDown[i] = NULL;
136 } 136 }
137 137
138 setBackgroundPixmap( *pixBg ); 138 setBackgroundPixmap( *pixBg );
139 139
140 songInfo.setFocusPolicy( QWidget::NoFocus ); 140 songInfo.setFocusPolicy( QWidget::NoFocus );
141 changeTextColor( &songInfo ); 141 changeTextColor( &songInfo );
142 142
143 slider.setFixedHeight( 20 ); 143 slider.setFixedHeight( 20 );
144 slider.setMinValue( 0 ); 144 slider.setMinValue( 0 );
145 slider.setMaxValue( 1 ); 145 slider.setMaxValue( 1 );
146 slider.setFocusPolicy( QWidget::NoFocus ); 146 slider.setFocusPolicy( QWidget::NoFocus );
147 slider.setBackgroundPixmap( *pixBg ); 147 slider.setBackgroundPixmap( *pixBg );
148 148
149 time.setFocusPolicy( QWidget::NoFocus ); 149 time.setFocusPolicy( QWidget::NoFocus );
150 time.setAlignment( Qt::AlignCenter ); 150 time.setAlignment( Qt::AlignCenter );
151 time.setFrame(FALSE); 151 time.setFrame(FALSE);
152 changeTextColor( &time ); 152 changeTextColor( &time );
153 153
154 resizeEvent( NULL ); 154 resizeEvent( NULL );
155 155
156 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 156 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
157 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 157 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
158 158
159 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 159 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
160 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 160 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
161 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 161 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
162 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 162 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
163 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 163 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
164 164
165 // Intialise state 165 // Intialise state
166 setLength( mediaPlayerState->length() ); 166 setLength( mediaPlayerState->length() );
167 setPosition( mediaPlayerState->position() ); 167 setPosition( mediaPlayerState->position() );
168 setLooping( mediaPlayerState->fullscreen() ); 168 setLooping( mediaPlayerState->fullscreen() );
169 setPaused( mediaPlayerState->paused() ); 169 setPaused( mediaPlayerState->paused() );
170 setPlaying( mediaPlayerState->playing() ); 170 setPlaying( mediaPlayerState->playing() );
171 171
172} 172}
173 173
174AudioWidget::~AudioWidget() { 174AudioWidget::~AudioWidget() {
175 175
176 for ( int i = 0; i < 11; i++ ) { 176 for ( int i = 0; i < 11; i++ ) {
177 delete buttonPixUp[i]; 177 delete buttonPixUp[i];
178 delete buttonPixDown[i]; 178 delete buttonPixDown[i];
179 } 179 }
180 delete pixBg; 180 delete pixBg;
181 delete imgUp; 181 delete imgUp;
182 delete imgDn; 182 delete imgDn;
183 delete imgButtonMask; 183 delete imgButtonMask;
184 for ( int i = 0; i < 11; i++ ) { 184 for ( int i = 0; i < 11; i++ ) {
185 delete masks[i]; 185 delete masks[i];
186 } 186 }
187} 187}
188 188
189QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 189QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
190 QPixmap pix( img.width(), img.height() ); 190 QPixmap pix( img.width(), img.height() );
191 QPainter p( &pix ); 191 QPainter p( &pix );
192 p.drawTiledPixmap( pix.rect(), bg, offset ); 192 p.drawTiledPixmap( pix.rect(), bg, offset );
193 p.drawImage( 0, 0, img ); 193 p.drawImage( 0, 0, img );
194 return new QPixmap( pix ); 194 return new QPixmap( pix );
195} 195}
196 196
197 197
198QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) 198QPixmap *maskPixToMask( QPixmap pix, QBitmap mask )
199{ 199{
200 QPixmap *pixmap = new QPixmap( pix ); 200 QPixmap *pixmap = new QPixmap( pix );
201 pixmap->setMask( mask ); 201 pixmap->setMask( mask );
202 return pixmap; 202 return pixmap;
203} 203}
204 204
205 205
206 206
207void AudioWidget::resizeEvent( QResizeEvent * ) { 207void AudioWidget::resizeEvent( QResizeEvent * ) {
208 int h = height(); 208 int h = height();
209 int w = width(); 209 int w = width();
210 210
211 songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); 211 songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) );
212 slider.setFixedWidth( w - 110 ); 212 slider.setFixedWidth( w - 110 );
213 slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); 213 slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) );
214 slider.setBackgroundOrigin( QWidget::ParentOrigin ); 214 slider.setBackgroundOrigin( QWidget::ParentOrigin );
215 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); 215 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
216 216
217 xoff = ( w - imgUp->width() ) / 2; 217 xoff = ( w - imgUp->width() ) / 2;
218 yoff = (( h - imgUp->height() ) / 2) - 10; 218 yoff = (( h - imgUp->height() ) / 2) - 10;
219 QPoint p( xoff, yoff ); 219 QPoint p( xoff, yoff );
220 220
221 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); 221 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p );
222 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); 222 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p );
223 223
224 for ( int i = 0; i < 11; i++ ) { 224 for ( int i = 0; i < 11; i++ ) {
225 if ( !masks[i]->isNull() ) { 225 if ( !masks[i]->isNull() ) {
226 delete buttonPixUp[i]; 226 delete buttonPixUp[i];
227 delete buttonPixDown[i]; 227 delete buttonPixDown[i];
228 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); 228 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] );
229 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); 229 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] );
230 } 230 }
231 } 231 }
232 232
233 delete pixUp; 233 delete pixUp;
234 delete pixDn; 234 delete pixDn;
235} 235}
236 236
237static bool audioSliderBeingMoved = FALSE; 237static bool audioSliderBeingMoved = FALSE;
238 238
239 239
240void AudioWidget::sliderPressed() { 240void AudioWidget::sliderPressed() {
241 audioSliderBeingMoved = TRUE; 241 audioSliderBeingMoved = TRUE;
242} 242}
243 243
244 244
245void AudioWidget::sliderReleased() { 245void AudioWidget::sliderReleased() {
246 audioSliderBeingMoved = FALSE; 246 audioSliderBeingMoved = FALSE;
247 if ( slider.width() == 0 ) 247 if ( slider.width() == 0 )
248 return; 248 return;
249 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); 249 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width());
250 mediaPlayerState->setPosition( val ); 250 mediaPlayerState->setPosition( val );
251} 251}
252 252
253void AudioWidget::setPosition( long i ) { 253void AudioWidget::setPosition( long i ) {
254 qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); 254// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i);
255 updateSlider( i, mediaPlayerState->length() ); 255 updateSlider( i, mediaPlayerState->length() );
256} 256}
257 257
258 258
259void AudioWidget::setLength( long max ) { 259void AudioWidget::setLength( long max ) {
260 updateSlider( mediaPlayerState->position(), max ); 260 updateSlider( mediaPlayerState->position(), max );
261} 261}
262 262
263 263
264void AudioWidget::setView( char view ) { 264void AudioWidget::setView( char view ) {
265 slider.show(); 265 slider.show();
266 266
267// this isnt working for some reason 267// this isnt working for some reason
268 268
269// if ( mediaPlayerState->streaming() ) { 269// if ( mediaPlayerState->streaming() ) {
270// qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); 270// qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>");
271// if( !slider.isHidden()) slider.hide(); 271// if( !slider.isHidden()) slider.hide();
272// disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 272// disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
273// disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 273// disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
274// } else { 274// } else {
275 // this stops the slider from being moved, thus 275 // this stops the slider from being moved, thus
276 // does not stop stream when it reaches the end 276 // does not stop stream when it reaches the end
277 slider.show(); 277 slider.show();
278 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 278 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
279 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 279 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
280// } 280// }
281 281
282 if ( view == 'a' ) { 282 if ( view == 'a' ) {
283 startTimer( 150 ); 283 startTimer( 150 );
284 showMaximized(); 284 showMaximized();
285 } else { 285 } else {
286 killTimers(); 286 killTimers();
287 hide(); 287 hide();
288 } 288 }
289} 289}
290 290
291 291
292static QString timeAsString( long length ) { 292static QString timeAsString( long length ) {
293 length /= 44100;
294 int minutes = length / 60; 293 int minutes = length / 60;
295 int seconds = length % 60; 294 int seconds = length % 60;
296 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); 295 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 );
297} 296}
298 297
299void AudioWidget::updateSlider( long i, long max ) { 298void AudioWidget::updateSlider( long i, long max ) {
300 299
301 time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); 300 time.setText( timeAsString( i ) + " / " + timeAsString( max ) );
302 301// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ;
302
303 if ( max == 0 ) { 303 if ( max == 0 ) {
304 return; 304 return;
305 } 305 }
306 // Will flicker too much if we don't do this 306 // Will flicker too much if we don't do this
307 // Scale to something reasonable 307 // Scale to something reasonable
308 int width = slider.width(); 308 int width = slider.width();
309 int val = int((double)i * width / max); 309 int val = int((double)i * width / max);
310 if ( !audioSliderBeingMoved ) { 310 if ( !audioSliderBeingMoved ) {
311 if ( slider.value() != val ) { 311 if ( slider.value() != val ) {
312 slider.setValue( val ); 312 slider.setValue( val );
313 } 313 }
314 314
315 if ( slider.maxValue() != width ) { 315 if ( slider.maxValue() != width ) {
316 slider.setMaxValue( width ); 316 slider.setMaxValue( width );
317 } 317 }
318 } 318 }
319} 319}
320 320
321 321
322void AudioWidget::setToggleButton( int i, bool down ) { 322void AudioWidget::setToggleButton( int i, bool down ) {
323 if ( down != audioButtons[i].isDown ) { 323 if ( down != audioButtons[i].isDown ) {
324 toggleButton( i ); 324 toggleButton( i );
325 } 325 }
326} 326}
327 327
328 328
329void AudioWidget::toggleButton( int i ) { 329void AudioWidget::toggleButton( int i ) {
330 audioButtons[i].isDown = !audioButtons[i].isDown; 330 audioButtons[i].isDown = !audioButtons[i].isDown;
331 QPainter p(this); 331 QPainter p(this);
332 paintButton ( &p, i ); 332 paintButton ( &p, i );
333} 333}
334 334
335 335
336void AudioWidget::paintButton( QPainter *p, int i ) { 336void AudioWidget::paintButton( QPainter *p, int i ) {
337 if ( audioButtons[i].isDown ) 337 if ( audioButtons[i].isDown )
338 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 338 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
339 else 339 else
340 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 340 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
341} 341}
342 342
343 343
344void AudioWidget::timerEvent( QTimerEvent * ) { 344void AudioWidget::timerEvent( QTimerEvent * ) {
345// static int frame = 0; 345// static int frame = 0;
346// if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { 346// if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) {
347// frame = frame >= 7 ? 0 : frame + 1; 347// frame = frame >= 7 ? 0 : frame + 1;
348// } 348// }
349} 349}
350 350
351 351
352void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 352void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
353 for ( int i = 0; i < numButtons; i++ ) { 353 for ( int i = 0; i < numButtons; i++ ) {
354 if ( event->state() == QMouseEvent::LeftButton ) { 354 if ( event->state() == QMouseEvent::LeftButton ) {
355 355
356 // The test to see if the mouse click is inside the button or not 356 // The test to see if the mouse click is inside the button or not
357 int x = event->pos().x() - xoff; 357 int x = event->pos().x() - xoff;
358 int y = event->pos().y() - yoff; 358 int y = event->pos().y() - yoff;
359 359
360 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() 360 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
361 && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); 361 && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 );
362 362
363 if ( isOnButton && i == AudioVolumeUp ) 363 if ( isOnButton && i == AudioVolumeUp )
364 qDebug("on up"); 364 qDebug("on up");
365 365
366 if ( isOnButton && !audioButtons[i].isHeld ) { 366 if ( isOnButton && !audioButtons[i].isHeld ) {
367 audioButtons[i].isHeld = TRUE; 367 audioButtons[i].isHeld = TRUE;
368 toggleButton(i); 368 toggleButton(i);
369 switch (i) { 369 switch (i) {
370 case AudioVolumeUp: 370 case AudioVolumeUp:
371 qDebug("more clicked"); 371 qDebug("more clicked");
372 emit moreClicked(); 372 emit moreClicked();
373 return; 373 return;
374 case AudioVolumeDown: emit lessClicked(); return; 374 case AudioVolumeDown: emit lessClicked(); return;
375 } 375 }
376 } else if ( !isOnButton && audioButtons[i].isHeld ) { 376 } else if ( !isOnButton && audioButtons[i].isHeld ) {
377 audioButtons[i].isHeld = FALSE; 377 audioButtons[i].isHeld = FALSE;
378 toggleButton(i); 378 toggleButton(i);
379 } 379 }
380 } else { 380 } else {
381 if ( audioButtons[i].isHeld ) { 381 if ( audioButtons[i].isHeld ) {
382 audioButtons[i].isHeld = FALSE; 382 audioButtons[i].isHeld = FALSE;
383 if ( !audioButtons[i].isToggle ) 383 if ( !audioButtons[i].isToggle )
384 setToggleButton( i, FALSE ); 384 setToggleButton( i, FALSE );
385 switch (i) { 385 switch (i) {
386 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; 386 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return;
387 case AudioStop: mediaPlayerState->setPlaying(FALSE); return; 387 case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
388 case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; 388 case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return;
389 case AudioNext: mediaPlayerState->setNext(); return; 389 case AudioNext: mediaPlayerState->setNext(); return;
390 case AudioPrevious: mediaPlayerState->setPrev(); return; 390 case AudioPrevious: mediaPlayerState->setPrev(); return;
391 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; 391 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return;
392 case AudioVolumeUp: emit moreReleased(); return; 392 case AudioVolumeUp: emit moreReleased(); return;
393 case AudioVolumeDown: emit lessReleased(); return; 393 case AudioVolumeDown: emit lessReleased(); return;
394 case AudioPlayList: mediaPlayerState->setList(); return; 394 case AudioPlayList: mediaPlayerState->setList(); return;
395 } 395 }
396 } 396 }
397 } 397 }
398 } 398 }
399} 399}
400 400
401 401
402void AudioWidget::mousePressEvent( QMouseEvent *event ) { 402void AudioWidget::mousePressEvent( QMouseEvent *event ) {
403 mouseMoveEvent( event ); 403 mouseMoveEvent( event );
404} 404}
405 405
406 406
407void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { 407void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
408 mouseMoveEvent( event ); 408 mouseMoveEvent( event );
409} 409}
410 410
411 411
412void AudioWidget::showEvent( QShowEvent* ) { 412void AudioWidget::showEvent( QShowEvent* ) {
413 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 413 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
414 mouseMoveEvent( &event ); 414 mouseMoveEvent( &event );
415} 415}
416 416
417 417
418void AudioWidget::closeEvent( QCloseEvent* ) { 418void AudioWidget::closeEvent( QCloseEvent* ) {
419 mediaPlayerState->setList(); 419 mediaPlayerState->setList();
420} 420}
421 421
422 422
423void AudioWidget::paintEvent( QPaintEvent * pe) { 423void AudioWidget::paintEvent( QPaintEvent * pe) {
424 if ( !pe->erased() ) { 424 if ( !pe->erased() ) {
425 // Combine with background and double buffer 425 // Combine with background and double buffer
426 QPixmap pix( pe->rect().size() ); 426 QPixmap pix( pe->rect().size() );
427 QPainter p( &pix ); 427 QPainter p( &pix );
428 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 428 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
429 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); 429 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
430 for ( int i = 0; i < numButtons; i++ ) 430 for ( int i = 0; i < numButtons; i++ )
431 paintButton( &p, i ); 431 paintButton( &p, i );
432 QPainter p2( this ); 432 QPainter p2( this );
433 p2.drawPixmap( pe->rect().topLeft(), pix ); 433 p2.drawPixmap( pe->rect().topLeft(), pix );
434 } else { 434 } else {
435 QPainter p( this ); 435 QPainter p( this );
436 for ( int i = 0; i < numButtons; i++ ) 436 for ( int i = 0; i < numButtons; i++ )
437 paintButton( &p, i ); 437 paintButton( &p, i );
438 } 438 }
439} 439}
440 440
441void AudioWidget::keyReleaseEvent( QKeyEvent *e) 441void AudioWidget::keyReleaseEvent( QKeyEvent *e)
442{ 442{
443 switch ( e->key() ) { 443 switch ( e->key() ) {
444////////////////////////////// Zaurus keys 444////////////////////////////// Zaurus keys
445 case Key_Home: 445 case Key_Home:
446 break; 446 break;
447 case Key_F9: //activity 447 case Key_F9: //activity
448 hide(); 448 hide();
449// qDebug("Audio F9"); 449// qDebug("Audio F9");
450 break; 450 break;
451 case Key_F10: //contacts 451 case Key_F10: //contacts
452 break; 452 break;
453 case Key_F11: //menu 453 case Key_F11: //menu
454 break; 454 break;
455 case Key_F12: //home 455 case Key_F12: //home
456 break; 456 break;
457 case Key_F13: //mail 457 case Key_F13: //mail
458 break; 458 break;
459 case Key_Space: { 459 case Key_Space: {
460 if(mediaPlayerState->playing()) { 460 if(mediaPlayerState->playing()) {
461// toggleButton(1); 461// toggleButton(1);
462 mediaPlayerState->setPlaying(FALSE); 462 mediaPlayerState->setPlaying(FALSE);
463// toggleButton(1); 463// toggleButton(1);
464 } else { 464 } else {
465// toggleButton(0); 465// toggleButton(0);
466 mediaPlayerState->setPlaying(TRUE); 466 mediaPlayerState->setPlaying(TRUE);
467// toggleButton(0); 467// toggleButton(0);
468 } 468 }
469 } 469 }
470 break; 470 break;
471 case Key_Down: 471 case Key_Down:
472 toggleButton(6); 472 toggleButton(6);
473 emit lessClicked(); 473 emit lessClicked();
474 emit lessReleased(); 474 emit lessReleased();
475 toggleButton(6); 475 toggleButton(6);
476 break; 476 break;
477 case Key_Up: 477 case Key_Up:
478 toggleButton(5); 478 toggleButton(5);
479 emit moreClicked(); 479 emit moreClicked();
480 emit moreReleased(); 480 emit moreReleased();
481 toggleButton(5); 481 toggleButton(5);
482 break; 482 break;
483 case Key_Right: 483 case Key_Right:
484// toggleButton(3); 484// toggleButton(3);
485 mediaPlayerState->setNext(); 485 mediaPlayerState->setNext();
486// toggleButton(3); 486// toggleButton(3);
487 break; 487 break;
488 case Key_Left: 488 case Key_Left:
489// toggleButton(4); 489// toggleButton(4);
490 mediaPlayerState->setPrev(); 490 mediaPlayerState->setPrev();
491// toggleButton(4); 491// toggleButton(4);
492 break; 492 break;
493 case Key_Escape: 493 case Key_Escape:
494 break; 494 break;
495 495
496 }; 496 };
497} 497}
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
index 778cd1e..135c67c 100644
--- a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
@@ -1,268 +1,269 @@
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 59
60 60
61bool MediaPlayerState::streaming() { 61bool MediaPlayerState::streaming() {
62 return isStreaming; 62 return isStreaming;
63} 63}
64 64
65bool MediaPlayerState::fullscreen() { 65bool MediaPlayerState::fullscreen() {
66 return isFullscreen; 66 return isFullscreen;
67} 67}
68 68
69bool MediaPlayerState::scaled() { 69bool MediaPlayerState::scaled() {
70 return isScaled; 70 return isScaled;
71} 71}
72 72
73bool MediaPlayerState::looping() { 73bool MediaPlayerState::looping() {
74 return isLooping; 74 return isLooping;
75} 75}
76 76
77bool MediaPlayerState::shuffled() { 77bool MediaPlayerState::shuffled() {
78 return isShuffled; 78 return isShuffled;
79} 79}
80 80
81 81
82bool MediaPlayerState:: playlist() { 82bool MediaPlayerState:: playlist() {
83 return usePlaylist; 83 return usePlaylist;
84} 84}
85 85
86bool MediaPlayerState::paused() { 86bool MediaPlayerState::paused() {
87 return isPaused; 87 return isPaused;
88} 88}
89 89
90bool MediaPlayerState::playing() { 90bool MediaPlayerState::playing() {
91 return isPlaying; 91 return isPlaying;
92} 92}
93 93
94bool MediaPlayerState::stop() { 94bool MediaPlayerState::stop() {
95 return isStoped; 95 return isStoped;
96} 96}
97 97
98long MediaPlayerState::position() { 98long MediaPlayerState::position() {
99 return curPosition; 99 return curPosition;
100} 100}
101 101
102long MediaPlayerState::length() { 102long MediaPlayerState::length() {
103 return curLength; 103 return curLength;
104} 104}
105 105
106char MediaPlayerState::view() { 106char MediaPlayerState::view() {
107 return curView; 107 return curView;
108} 108}
109 109
110// slots 110// slots
111void MediaPlayerState::setIsStreaming( bool b ) { 111void MediaPlayerState::setIsStreaming( bool b ) {
112
112 if ( isStreaming == b ) { 113 if ( isStreaming == b ) {
113 return; 114 return;
114 } 115 }
115 isStreaming = b; 116 isStreaming = b;
116} 117}
117 118
118 119
119void MediaPlayerState::setFullscreen( bool b ) { 120void MediaPlayerState::setFullscreen( bool b ) {
120 if ( isFullscreen == b ) { 121 if ( isFullscreen == b ) {
121 return; 122 return;
122 } 123 }
123 isFullscreen = b; 124 isFullscreen = b;
124 emit fullscreenToggled(b); 125 emit fullscreenToggled(b);
125} 126}
126 127
127 128
128void MediaPlayerState::setScaled( bool b ) { 129void MediaPlayerState::setScaled( bool b ) {
129 if ( isScaled == b ) { 130 if ( isScaled == b ) {
130 return; 131 return;
131 } 132 }
132 isScaled = b; 133 isScaled = b;
133 emit scaledToggled(b); 134 emit scaledToggled(b);
134} 135}
135 136
136void MediaPlayerState::setLooping( bool b ) { 137void MediaPlayerState::setLooping( bool b ) {
137 if ( isLooping == b ) { 138 if ( isLooping == b ) {
138 return; 139 return;
139 } 140 }
140 isLooping = b; 141 isLooping = b;
141 emit loopingToggled(b); 142 emit loopingToggled(b);
142} 143}
143 144
144void MediaPlayerState::setShuffled( bool b ) { 145void MediaPlayerState::setShuffled( bool b ) {
145 if ( isShuffled == b ) { 146 if ( isShuffled == b ) {
146 return; 147 return;
147 } 148 }
148 isShuffled = b; 149 isShuffled = b;
149 emit shuffledToggled(b); 150 emit shuffledToggled(b);
150} 151}
151 152
152void MediaPlayerState::setPlaylist( bool b ) { 153void MediaPlayerState::setPlaylist( bool b ) {
153 if ( usePlaylist == b ) { 154 if ( usePlaylist == b ) {
154 return; 155 return;
155 } 156 }
156 usePlaylist = b; 157 usePlaylist = b;
157 emit playlistToggled(b); 158 emit playlistToggled(b);
158} 159}
159 160
160void MediaPlayerState::setPaused( bool b ) { 161void MediaPlayerState::setPaused( bool b ) {
161 if ( isPaused == b ) { 162 if ( isPaused == b ) {
162 return; 163 return;
163 } 164 }
164 isPaused = b; 165 isPaused = b;
165 emit pausedToggled(b); 166 emit pausedToggled(b);
166} 167}
167 168
168void MediaPlayerState::setPlaying( bool b ) { 169void MediaPlayerState::setPlaying( bool b ) {
169 if ( isPlaying == b ) { 170 if ( isPlaying == b ) {
170 return; 171 return;
171 } 172 }
172 isPlaying = b; 173 isPlaying = b;
173 isStoped = !b; 174 isStoped = !b;
174 emit playingToggled(b); 175 emit playingToggled(b);
175} 176}
176 177
177void MediaPlayerState::setStop( bool b ) { 178void MediaPlayerState::setStop( bool b ) {
178 if ( isStoped == b ) { 179 if ( isStoped == b ) {
179 return; 180 return;
180 } 181 }
181 isStoped = b; 182 isStoped = b;
182 emit stopToggled(b); 183 emit stopToggled(b);
183} 184}
184 185
185void MediaPlayerState::setPosition( long p ) { 186void MediaPlayerState::setPosition( long p ) {
186 if ( curPosition == p ) { 187 if ( curPosition == p ) {
187 return; 188 return;
188 } 189 }
189 curPosition = p; 190 curPosition = p;
190 emit positionChanged(p); 191 emit positionChanged(p);
191} 192}
192 193
193void MediaPlayerState::updatePosition( long p ){ 194void MediaPlayerState::updatePosition( long p ){
194 if ( curPosition == p ) { 195 if ( curPosition == p ) {
195 return; 196 return;
196 } 197 }
197 curPosition = p; 198 curPosition = p;
198 emit positionUpdated(p); 199 emit positionUpdated(p);
199} 200}
200 201
201void MediaPlayerState::setLength( long l ) { 202void MediaPlayerState::setLength( long l ) {
202 if ( curLength == l ) { 203 if ( curLength == l ) {
203 return; 204 return;
204 } 205 }
205 curLength = l; 206 curLength = l;
206 emit lengthChanged(l); 207 emit lengthChanged(l);
207} 208}
208 209
209void MediaPlayerState::setView( char v ) { 210void MediaPlayerState::setView( char v ) {
210 if ( curView == v ) { 211 if ( curView == v ) {
211 return; 212 return;
212 } 213 }
213 curView = v; 214 curView = v;
214 emit viewChanged(v); 215 emit viewChanged(v);
215} 216}
216 217
217void MediaPlayerState::setPrev(){ 218void MediaPlayerState::setPrev(){
218 emit prev(); 219 emit prev();
219} 220}
220 221
221void MediaPlayerState::setNext() { 222void MediaPlayerState::setNext() {
222 emit next(); 223 emit next();
223} 224}
224 225
225void MediaPlayerState::setList() { 226void MediaPlayerState::setList() {
226 setPlaying( FALSE ); 227 setPlaying( FALSE );
227 setView('l'); 228 setView('l');
228} 229}
229 230
230void MediaPlayerState::setVideo() { 231void MediaPlayerState::setVideo() {
231 setView('v'); 232 setView('v');
232} 233}
233 234
234void MediaPlayerState::setAudio() { 235void MediaPlayerState::setAudio() {
235 setView('a'); 236 setView('a');
236} 237}
237 238
238void MediaPlayerState::toggleFullscreen() { 239void MediaPlayerState::toggleFullscreen() {
239 setFullscreen( !isFullscreen ); 240 setFullscreen( !isFullscreen );
240} 241}
241 242
242void MediaPlayerState::toggleScaled() { 243void MediaPlayerState::toggleScaled() {
243 setScaled( !isScaled); 244 setScaled( !isScaled);
244} 245}
245 246
246void MediaPlayerState::toggleLooping() { 247void MediaPlayerState::toggleLooping() {
247 setLooping( !isLooping); 248 setLooping( !isLooping);
248} 249}
249 250
250void MediaPlayerState::toggleShuffled() { 251void MediaPlayerState::toggleShuffled() {
251 setShuffled( !isShuffled); 252 setShuffled( !isShuffled);
252} 253}
253 254
254void MediaPlayerState::togglePlaylist() { 255void MediaPlayerState::togglePlaylist() {
255 setPlaylist( !usePlaylist); 256 setPlaylist( !usePlaylist);
256} 257}
257 258
258void MediaPlayerState::togglePaused() { 259void MediaPlayerState::togglePaused() {
259 setPaused( !isPaused); 260 setPaused( !isPaused);
260} 261}
261 262
262void MediaPlayerState::togglePlaying() { 263void MediaPlayerState::togglePlaying() {
263 setPlaying( !isPlaying); 264 setPlaying( !isPlaying);
264} 265}
265 266
266 267
267 268
268 269
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.h b/noncore/multimedia/opieplayer2/mediaplayerstate.h
index 79ba579..887c527 100644
--- a/noncore/multimedia/opieplayer2/mediaplayerstate.h
+++ b/noncore/multimedia/opieplayer2/mediaplayerstate.h
@@ -1,132 +1,132 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef MEDIA_PLAYER_STATE_H 34#ifndef MEDIA_PLAYER_STATE_H
35#define MEDIA_PLAYER_STATE_H 35#define MEDIA_PLAYER_STATE_H
36 36
37 37
38#include <qobject.h> 38#include <qobject.h>
39 39
40 40
41class MediaPlayerDecoder; 41class MediaPlayerDecoder;
42class Config; 42class Config;
43 43
44 44
45class MediaPlayerState : public QObject { 45class MediaPlayerState : public QObject {
46Q_OBJECT 46Q_OBJECT
47public: 47public:
48 MediaPlayerState( QObject *parent, const char *name ); 48 MediaPlayerState( QObject *parent, const char *name );
49 ~MediaPlayerState(); 49 ~MediaPlayerState();
50 50
51 bool isPaused;
52 bool isPlaying;
53 bool isStoped;
51 bool streaming(); 54 bool streaming();
52 bool fullscreen(); 55 bool fullscreen();
53 bool scaled(); 56 bool scaled();
54 bool looping(); 57 bool looping();
55 bool shuffled(); 58 bool shuffled();
56 bool playlist(); 59 bool playlist();
57 bool paused(); 60 bool paused();
58 bool playing(); 61 bool playing();
59 bool stop(); 62 bool stop();
60 long position(); 63 long position();
61 long length(); 64 long length();
62 char view(); 65 char view();
63 66
64public slots: 67public slots:
65 void setIsStreaming( bool b ); 68 void setIsStreaming( bool b );
66 void setFullscreen( bool b ); 69 void setFullscreen( bool b );
67 void setScaled( bool b ); 70 void setScaled( bool b );
68 void setLooping( bool b ); 71 void setLooping( bool b );
69 void setShuffled( bool b ); 72 void setShuffled( bool b );
70 void setPlaylist( bool b ); 73 void setPlaylist( bool b );
71 void setPaused( bool b ); 74 void setPaused( bool b );
72 void setPlaying( bool b ); 75 void setPlaying( bool b );
73 void setStop( bool b ); 76 void setStop( bool b );
74 void setPosition( long p ); 77 void setPosition( long p );
75 void updatePosition( long p ); 78 void updatePosition( long p );
76 void setLength( long l ); 79 void setLength( long l );
77 void setView( char v ); 80 void setView( char v );
78 81
79 void setPrev(); 82 void setPrev();
80 void setNext(); 83 void setNext();
81 void setList(); 84 void setList();
82 void setVideo(); 85 void setVideo();
83 void setAudio(); 86 void setAudio();
84 87
85 void toggleFullscreen(); 88 void toggleFullscreen();
86 void toggleScaled(); 89 void toggleScaled();
87 void toggleLooping(); 90 void toggleLooping();
88 void toggleShuffled(); 91 void toggleShuffled();
89 void togglePlaylist(); 92 void togglePlaylist();
90 void togglePaused(); 93 void togglePaused();
91 void togglePlaying(); 94 void togglePlaying();
92 95
93signals: 96signals:
94 void fullscreenToggled( bool ); 97 void fullscreenToggled( bool );
95 void scaledToggled( bool ); 98 void scaledToggled( bool );
96 void loopingToggled( bool ); 99 void loopingToggled( bool );
97 void shuffledToggled( bool ); 100 void shuffledToggled( bool );
98 void playlistToggled( bool ); 101 void playlistToggled( bool );
99 void pausedToggled( bool ); 102 void pausedToggled( bool );
100 void playingToggled( bool ); 103 void playingToggled( bool );
101 void stopToggled( bool ); 104 void stopToggled( bool );
102 void positionChanged( long ); // When the slider is moved 105 void positionChanged( long ); // When the slider is moved
103 void positionUpdated( long ); // When the media file progresses 106 void positionUpdated( long ); // When the media file progresses
104 void lengthChanged( long ); 107 void lengthChanged( long );
105 void viewChanged( char ); 108 void viewChanged( char );
106 109
107 void prev(); 110 void prev();
108 void next(); 111 void next();
109 112
110private: 113private:
111 bool isStreaming; 114 bool isStreaming;
112 bool isFullscreen; 115 bool isFullscreen;
113 bool isScaled; 116 bool isScaled;
114 bool isLooping; 117 bool isLooping;
115 bool isShuffled; 118 bool isShuffled;
116 bool usePlaylist; 119 bool usePlaylist;
117 bool isPaused;
118 bool isPlaying;
119 bool isStoped;
120 long curPosition; 120 long curPosition;
121 long curLength; 121 long curLength;
122 char curView; 122 char curView;
123 123
124 void readConfig( Config& cfg ); 124 void readConfig( Config& cfg );
125 void writeConfig( Config& cfg ) const; 125 void writeConfig( Config& cfg ) const;
126 126
127 127
128}; 128};
129 129
130 130
131#endif // MEDIA_PLAYER_STATE_H 131#endif // MEDIA_PLAYER_STATE_H
132 132
diff --git a/noncore/multimedia/opieplayer2/opieplayer2.pro b/noncore/multimedia/opieplayer2/opieplayer2.pro
index 448dd34..d8cacd0 100644
--- a/noncore/multimedia/opieplayer2/opieplayer2.pro
+++ b/noncore/multimedia/opieplayer2/opieplayer2.pro
@@ -1,21 +1,23 @@
1TEMPLATE = app 1TEMPLATE = app
2CONFIG = qt warn_on release 2CONFIG = qt warn_on release
3#release 3#release
4DESTDIR = $(OPIEDIR)/bin 4DESTDIR = $(OPIEDIR)/bin
5HEADERS = playlistselection.h mediaplayerstate.h xinecontrol.h mediadetect.h\ 5HEADERS = playlistselection.h mediaplayerstate.h xinecontrol.h mediadetect.h\
6 videowidget.h audiowidget.h playlistwidget.h mediaplayer.h inputDialog.h \ 6 videowidget.h audiowidget.h playlistwidget.h mediaplayer.h inputDialog.h \
7 frame.h lib.h xinevideowidget.h \ 7 frame.h lib.h xinevideowidget.h \
8 alphablend.h yuv2rgb.h 8 alphablend.h yuv2rgb.h
9SOURCES = main.cpp \ 9SOURCES = main.cpp \
10 playlistselection.cpp mediaplayerstate.cpp xinecontrol.cpp mediadetect.cpp\ 10 playlistselection.cpp mediaplayerstate.cpp xinecontrol.cpp mediadetect.cpp\
11 videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp inputDialog.cpp \ 11 videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp inputDialog.cpp \
12 frame.cpp lib.cpp nullvideo.c xinevideowidget.cpp \ 12 frame.cpp lib.cpp nullvideo.c xinevideowidget.cpp \
13 alphablend.c yuv2rgb.c yuv2rgb_mlib.c yuv2rgb_mmx.c 13 alphablend.c yuv2rgb.c yuv2rgb_mlib.c yuv2rgb_mmx.c
14TARGET = opieplayer2 14TARGET = opieplayer2
15INCLUDEPATH += $(OPIEDIR)/include 15INCLUDEPATH += $(OPIEDIR)/include
16DEPENDPATH += $(OPIEDIR)/include 16DEPENDPATH += $(OPIEDIR)/include
17LIBS += -lqpe -lpthread -lopie -lxine -lxineutils 17LIBS += -lqpe -lpthread -lopie -lxine -lxineutils
18MOC_DIR=qpeobj
19OBJECTS_DIR=qpeobj
18 20
19INCLUDEPATH += $(OPIEDIR)/include 21INCLUDEPATH += $(OPIEDIR)/include
20DEPENDPATH += $(OPIEDIR)/include 22DEPENDPATH += $(OPIEDIR)/include
21 23
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index cce445b..1dee422 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -1,812 +1,813 @@
1 1
2#define QTOPIA_INTERNAL_FSLP 2#define QTOPIA_INTERNAL_FSLP
3#include <qpe/qcopenvelope_qws.h> 3#include <qpe/qcopenvelope_qws.h>
4 4
5#include <qpe/qpemenubar.h> 5#include <qpe/qpemenubar.h>
6#include <qpe/qpetoolbar.h> 6#include <qpe/qpetoolbar.h>
7#include <qpe/fileselector.h> 7#include <qpe/fileselector.h>
8#include <qpe/qpeapplication.h> 8#include <qpe/qpeapplication.h>
9#include <qpe/lnkproperties.h> 9#include <qpe/lnkproperties.h>
10#include <qpe/storage.h> 10#include <qpe/storage.h>
11 11
12#include <qpe/applnk.h> 12#include <qpe/applnk.h>
13#include <qpe/config.h> 13#include <qpe/config.h>
14#include <qpe/global.h> 14#include <qpe/global.h>
15#include <qpe/resource.h> 15#include <qpe/resource.h>
16#include <qaction.h> 16#include <qaction.h>
17#include <qcursor.h> 17#include <qcursor.h>
18#include <qimage.h> 18#include <qimage.h>
19#include <qfile.h> 19#include <qfile.h>
20#include <qdir.h> 20#include <qdir.h>
21#include <qlayout.h> 21#include <qlayout.h>
22#include <qlabel.h> 22#include <qlabel.h>
23#include <qlist.h> 23#include <qlist.h>
24#include <qlistbox.h> 24#include <qlistbox.h>
25#include <qmainwindow.h> 25#include <qmainwindow.h>
26#include <qmessagebox.h> 26#include <qmessagebox.h>
27#include <qtoolbutton.h> 27#include <qtoolbutton.h>
28#include <qtabwidget.h> 28#include <qtabwidget.h>
29#include <qlistview.h> 29#include <qlistview.h>
30#include <qpoint.h> 30#include <qpoint.h>
31#include <qlineedit.h> 31#include <qlineedit.h>
32#include <qpushbutton.h> 32#include <qpushbutton.h>
33#include <qregexp.h> 33#include <qregexp.h>
34#include <qtextstream.h> 34#include <qtextstream.h>
35 35
36 36
37#include "playlistselection.h" 37#include "playlistselection.h"
38#include "playlistwidget.h" 38#include "playlistwidget.h"
39#include "mediaplayerstate.h" 39#include "mediaplayerstate.h"
40 40
41#include "inputDialog.h" 41#include "inputDialog.h"
42 42
43#include <stdlib.h> 43#include <stdlib.h>
44#include "audiowidget.h" 44#include "audiowidget.h"
45#include "videowidget.h" 45#include "videowidget.h"
46 46
47#include <unistd.h> 47#include <unistd.h>
48#include <sys/file.h> 48#include <sys/file.h>
49#include <sys/ioctl.h> 49#include <sys/ioctl.h>
50#include <sys/soundcard.h> 50#include <sys/soundcard.h>
51 51
52// for setBacklight() 52// for setBacklight()
53#include <linux/fb.h> 53#include <linux/fb.h>
54#include <sys/types.h> 54#include <sys/types.h>
55#include <sys/stat.h> 55#include <sys/stat.h>
56#include <stdlib.h> 56#include <stdlib.h>
57 57
58#define BUTTONS_ON_TOOLBAR 58#define BUTTONS_ON_TOOLBAR
59#define SIDE_BUTTONS 59#define SIDE_BUTTONS
60#define CAN_SAVE_LOAD_PLAYLISTS 60#define CAN_SAVE_LOAD_PLAYLISTS
61 61
62extern MediaPlayerState *mediaPlayerState; 62extern MediaPlayerState *mediaPlayerState;
63 63
64 64
65class PlayListWidgetPrivate { 65class PlayListWidgetPrivate {
66public: 66public:
67 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; 67 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
68 QFrame *playListFrame; 68 QFrame *playListFrame;
69 FileSelector *files; 69 FileSelector *files;
70 PlayListSelection *selectedFiles; 70 PlayListSelection *selectedFiles;
71 bool setDocumentUsed; 71 bool setDocumentUsed;
72 DocLnk *current; 72 DocLnk *current;
73}; 73};
74 74
75 75
76class ToolButton : public QToolButton { 76class ToolButton : public QToolButton {
77public: 77public:
78 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 78 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
79 : QToolButton( parent, name ) { 79 : QToolButton( parent, name ) {
80 setTextLabel( name ); 80 setTextLabel( name );
81 setPixmap( Resource::loadPixmap( icon ) ); 81 setPixmap( Resource::loadPixmap( icon ) );
82 setAutoRaise( TRUE ); 82 setAutoRaise( TRUE );
83 setFocusPolicy( QWidget::NoFocus ); 83 setFocusPolicy( QWidget::NoFocus );
84 setToggleButton( t ); 84 setToggleButton( t );
85 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 85 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
86 QPEMenuToolFocusManager::manager()->addWidget( this ); 86 QPEMenuToolFocusManager::manager()->addWidget( this );
87 } 87 }
88}; 88};
89 89
90 90
91class MenuItem : public QAction { 91class MenuItem : public QAction {
92public: 92public:
93 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) 93 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
94 : QAction( text, QString::null, 0, 0 ) { 94 : QAction( text, QString::null, 0, 0 ) {
95 connect( this, SIGNAL( activated() ), handler, slot ); 95 connect( this, SIGNAL( activated() ), handler, slot );
96 addTo( parent ); 96 addTo( parent );
97 } 97 }
98}; 98};
99 99
100 100
101PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 101PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
102 : QMainWindow( parent, name, fl ) { 102 : QMainWindow( parent, name, fl ) {
103 103
104 d = new PlayListWidgetPrivate; 104 d = new PlayListWidgetPrivate;
105 d->setDocumentUsed = FALSE; 105 d->setDocumentUsed = FALSE;
106 d->current = NULL; 106 d->current = NULL;
107 fromSetDocument = FALSE; 107 fromSetDocument = FALSE;
108 insanityBool=FALSE; 108 insanityBool=FALSE;
109 audioScan = FALSE; 109 audioScan = FALSE;
110 videoScan = FALSE; 110 videoScan = FALSE;
111 111
112 setBackgroundMode( PaletteButton ); 112 setBackgroundMode( PaletteButton );
113 113
114 setCaption( tr("OpiePlayer") ); 114 setCaption( tr("OpiePlayer") );
115 setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); 115 setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) );
116 116
117 setToolBarsMovable( FALSE ); 117 setToolBarsMovable( FALSE );
118 118
119 // Create Toolbar 119 // Create Toolbar
120 QPEToolBar *toolbar = new QPEToolBar( this ); 120 QPEToolBar *toolbar = new QPEToolBar( this );
121 toolbar->setHorizontalStretchable( TRUE ); 121 toolbar->setHorizontalStretchable( TRUE );
122 122
123 // Create Menubar 123 // Create Menubar
124 QPEMenuBar *menu = new QPEMenuBar( toolbar ); 124 QPEMenuBar *menu = new QPEMenuBar( toolbar );
125 menu->setMargin( 0 ); 125 menu->setMargin( 0 );
126 126
127 QPEToolBar *bar = new QPEToolBar( this ); 127 QPEToolBar *bar = new QPEToolBar( this );
128 bar->setLabel( tr( "Play Operations" ) ); 128 bar->setLabel( tr( "Play Operations" ) );
129 129
130 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); 130 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close");
131 tbDeletePlaylist->setFlat(TRUE); 131 tbDeletePlaylist->setFlat(TRUE);
132 tbDeletePlaylist->setFixedSize(20,20); 132 tbDeletePlaylist->setFixedSize(20,20);
133 133
134 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", 134 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist",
135 this , SLOT(addSelected()) ); 135 this , SLOT(addSelected()) );
136 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", 136 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist",
137 this , SLOT(removeSelected()) ); 137 this , SLOT(removeSelected()) );
138 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", 138 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play",
139 this , SLOT( btnPlay(bool) ), TRUE ); 139 this , SLOT( btnPlay(bool) ), TRUE );
140 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", 140 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle",
141 mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 141 mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
142 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", 142 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop",
143 mediaPlayerState, SLOT(setLooping(bool)), TRUE ); 143 mediaPlayerState, SLOT(setLooping(bool)), TRUE );
144 tbDeletePlaylist->hide(); 144 tbDeletePlaylist->hide();
145 145
146 QPopupMenu *pmPlayList = new QPopupMenu( this ); 146 QPopupMenu *pmPlayList = new QPopupMenu( this );
147 menu->insertItem( tr( "File" ), pmPlayList ); 147 menu->insertItem( tr( "File" ), pmPlayList );
148 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 148 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
149 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 149 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
150 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 150 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
151 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 151 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
152 pmPlayList->insertSeparator(-1); 152 pmPlayList->insertSeparator(-1);
153 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 153 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
154 new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); 154 new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) );
155 pmPlayList->insertSeparator(-1); 155 pmPlayList->insertSeparator(-1);
156 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); 156 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
157 pmPlayList->insertSeparator(-1); 157 pmPlayList->insertSeparator(-1);
158 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); 158 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) );
159 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); 159 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) );
160 160
161 QPopupMenu *pmView = new QPopupMenu( this ); 161 QPopupMenu *pmView = new QPopupMenu( this );
162 menu->insertItem( tr( "View" ), pmView ); 162 menu->insertItem( tr( "View" ), pmView );
163 163
164 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); 164 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0);
165 fullScreenButton->addTo(pmView); 165 fullScreenButton->addTo(pmView);
166 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); 166 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0);
167 scaleButton->addTo(pmView); 167 scaleButton->addTo(pmView);
168 168
169 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 169 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
170 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); 170 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
171 171
172 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); 172 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
173 173
174 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 174 tabWidget = new QTabWidget( hbox6, "tabWidget" );
175 tabWidget->setTabShape(QTabWidget::Triangular); 175// tabWidget->setTabShape(QTabWidget::Triangular);
176 176
177 QWidget *pTab; 177 QWidget *pTab;
178 pTab = new QWidget( tabWidget, "pTab" ); 178 pTab = new QWidget( tabWidget, "pTab" );
179 tabWidget->insertTab( pTab,"Playlist"); 179 tabWidget->insertTab( pTab,"Playlist");
180 180
181 181
182 // Add the playlist area 182 // Add the playlist area
183 183
184 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); 184 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
185 d->playListFrame = vbox3; 185 d->playListFrame = vbox3;
186 d->playListFrame ->setMinimumSize(235,260); 186 d->playListFrame ->setMinimumSize(235,260);
187 187
188 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); 188 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
189 189
190 d->selectedFiles = new PlayListSelection( hbox2); 190 d->selectedFiles = new PlayListSelection( hbox2);
191 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); 191 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
192 192
193 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); 193 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold);
194 194
195 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch 195 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
196 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); 196 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) );
197 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); 197 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) );
198 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); 198 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) );
199 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch 199 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
200 200
201 QWidget *aTab; 201 QWidget *aTab;
202 aTab = new QWidget( tabWidget, "aTab" ); 202 aTab = new QWidget( tabWidget, "aTab" );
203 audioView = new QListView( aTab, "Audioview" ); 203 audioView = new QListView( aTab, "Audioview" );
204 audioView->setMinimumSize(233,260); 204 audioView->setMinimumSize(233,260);
205 audioView->addColumn( tr("Title"),140); 205 audioView->addColumn( tr("Title"),140);
206 audioView->addColumn(tr("Size"), -1); 206 audioView->addColumn(tr("Size"), -1);
207 audioView->addColumn(tr("Media"),-1); 207 audioView->addColumn(tr("Media"),-1);
208 audioView->setColumnAlignment(1, Qt::AlignRight); 208 audioView->setColumnAlignment(1, Qt::AlignRight);
209 audioView->setColumnAlignment(2, Qt::AlignRight); 209 audioView->setColumnAlignment(2, Qt::AlignRight);
210 audioView->setAllColumnsShowFocus(TRUE); 210 audioView->setAllColumnsShowFocus(TRUE);
211 211
212 audioView->setMultiSelection( TRUE ); 212 audioView->setMultiSelection( TRUE );
213 audioView->setSelectionMode( QListView::Extended); 213 audioView->setSelectionMode( QListView::Extended);
214 214
215 tabWidget->insertTab(aTab,tr("Audio")); 215 tabWidget->insertTab(aTab,tr("Audio"));
216 216
217 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); 217 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold);
218 218
219 QWidget *vTab; 219 QWidget *vTab;
220 vTab = new QWidget( tabWidget, "vTab" ); 220 vTab = new QWidget( tabWidget, "vTab" );
221 videoView = new QListView( vTab, "Videoview" ); 221 videoView = new QListView( vTab, "Videoview" );
222 videoView->setMinimumSize(233,260); 222 videoView->setMinimumSize(233,260);
223 223
224 videoView->addColumn(tr("Title"),140); 224 videoView->addColumn(tr("Title"),140);
225 videoView->addColumn(tr("Size"),-1); 225 videoView->addColumn(tr("Size"),-1);
226 videoView->addColumn(tr("Media"),-1); 226 videoView->addColumn(tr("Media"),-1);
227 videoView->setColumnAlignment(1, Qt::AlignRight); 227 videoView->setColumnAlignment(1, Qt::AlignRight);
228 videoView->setColumnAlignment(2, Qt::AlignRight); 228 videoView->setColumnAlignment(2, Qt::AlignRight);
229 videoView->setAllColumnsShowFocus(TRUE); 229 videoView->setAllColumnsShowFocus(TRUE);
230 videoView->setMultiSelection( TRUE ); 230 videoView->setMultiSelection( TRUE );
231 videoView->setSelectionMode( QListView::Extended); 231 videoView->setSelectionMode( QListView::Extended);
232 232
233 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); 233 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold);
234 234
235 tabWidget->insertTab( vTab,tr("Video")); 235 tabWidget->insertTab( vTab,tr("Video"));
236 236
237 //playlists list 237 //playlists list
238 QWidget *LTab; 238 QWidget *LTab;
239 LTab = new QWidget( tabWidget, "LTab" ); 239 LTab = new QWidget( tabWidget, "LTab" );
240 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy 240 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy
241 playLists->setMinimumSize(233,260); 241 playLists->setMinimumSize(233,260);
242 tabWidget->insertTab(LTab,tr("Lists")); 242 tabWidget->insertTab(LTab,tr("Lists"));
243 243
244 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); 244 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
245 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); 245 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) );
246 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); 246 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) );
247 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 247 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
248 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); 248 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) );
249 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 249 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
250 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 250 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
251 connect( audioView, SIGNAL( returnPressed( QListViewItem *)), 251 connect( audioView, SIGNAL( returnPressed( QListViewItem *)),
252 this,SLOT( playIt( QListViewItem *)) ); 252 this,SLOT( playIt( QListViewItem *)) );
253 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 253 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
254 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 254 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
255 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 255 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
256 connect( videoView, SIGNAL( returnPressed( QListViewItem *)), 256 connect( videoView, SIGNAL( returnPressed( QListViewItem *)),
257 this,SLOT( playIt( QListViewItem *)) ); 257 this,SLOT( playIt( QListViewItem *)) );
258 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 258 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
259 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); 259 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
260 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); 260 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
261 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 261 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
262 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); 262 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
263 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 263 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
264 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 264 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
265 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 265 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
266 266
267 setCentralWidget( vbox5 ); 267 setCentralWidget( vbox5 );
268 268
269 Config cfg( "OpiePlayer" ); 269 Config cfg( "OpiePlayer" );
270 readConfig( cfg ); 270 readConfig( cfg );
271 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 271 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
272 loadList(DocLnk( currentPlaylist)); 272 loadList(DocLnk( currentPlaylist));
273 setCaption(tr("OpiePlayer: ")+ currentPlaylist ); 273 setCaption(tr("OpiePlayer: ")+ currentPlaylist );
274 274
275 initializeStates(); 275 initializeStates();
276} 276}
277 277
278 278
279PlayListWidget::~PlayListWidget() { 279PlayListWidget::~PlayListWidget() {
280 Config cfg( "OpiePlayer" ); 280 Config cfg( "OpiePlayer" );
281 writeConfig( cfg ); 281 writeConfig( cfg );
282 282
283 if ( d->current ) { 283 if ( d->current ) {
284 delete d->current; 284 delete d->current;
285 } 285 }
286 delete d; 286 delete d;
287} 287}
288 288
289 289
290void PlayListWidget::initializeStates() { 290void PlayListWidget::initializeStates() {
291 291
292 d->tbPlay->setOn( mediaPlayerState->playing() ); 292 d->tbPlay->setOn( mediaPlayerState->playing() );
293 d->tbLoop->setOn( mediaPlayerState->looping() ); 293 d->tbLoop->setOn( mediaPlayerState->looping() );
294 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 294 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
295 setPlaylist( true); 295 setPlaylist( true);
296} 296}
297 297
298 298
299void PlayListWidget::readConfig( Config& cfg ) { 299void PlayListWidget::readConfig( Config& cfg ) {
300 cfg.setGroup("PlayList"); 300 cfg.setGroup("PlayList");
301 QString currentString = cfg.readEntry("current", "" ); 301 QString currentString = cfg.readEntry("current", "" );
302 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 302 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
303 for ( int i = 0; i < noOfFiles; i++ ) { 303 for ( int i = 0; i < noOfFiles; i++ ) {
304 QString entryName; 304 QString entryName;
305 entryName.sprintf( "File%i", i + 1 ); 305 entryName.sprintf( "File%i", i + 1 );
306 QString linkFile = cfg.readEntry( entryName ); 306 QString linkFile = cfg.readEntry( entryName );
307 DocLnk lnk( linkFile ); 307 DocLnk lnk( linkFile );
308 if ( lnk.isValid() ) { 308 if ( lnk.isValid() ) {
309 d->selectedFiles->addToSelection( lnk ); 309 d->selectedFiles->addToSelection( lnk );
310 } 310 }
311 } 311 }
312 d->selectedFiles->setSelectedItem( currentString); 312 d->selectedFiles->setSelectedItem( currentString);
313} 313}
314 314
315 315
316void PlayListWidget::writeConfig( Config& cfg ) const { 316void PlayListWidget::writeConfig( Config& cfg ) const {
317 317
318 d->selectedFiles->writeCurrent( cfg); 318 d->selectedFiles->writeCurrent( cfg);
319 cfg.setGroup("PlayList"); 319 cfg.setGroup("PlayList");
320 int noOfFiles = 0; 320 int noOfFiles = 0;
321 d->selectedFiles->first(); 321 d->selectedFiles->first();
322 do { 322 do {
323 const DocLnk *lnk = d->selectedFiles->current(); 323 const DocLnk *lnk = d->selectedFiles->current();
324 if ( lnk ) { 324 if ( lnk ) {
325 QString entryName; 325 QString entryName;
326 entryName.sprintf( "File%i", noOfFiles + 1 ); 326 entryName.sprintf( "File%i", noOfFiles + 1 );
327 cfg.writeEntry( entryName, lnk->linkFile() ); 327 cfg.writeEntry( entryName, lnk->linkFile() );
328 // if this link does exist, add it so we have the file 328 // if this link does exist, add it so we have the file
329 // next time... 329 // next time...
330 if ( !QFile::exists( lnk->linkFile() ) ) { 330 if ( !QFile::exists( lnk->linkFile() ) ) {
331 // the way writing lnks doesn't really check for out 331 // the way writing lnks doesn't really check for out
332 // of disk space, but check it anyway. 332 // of disk space, but check it anyway.
333 if ( !lnk->writeLink() ) { 333 if ( !lnk->writeLink() ) {
334 QMessageBox::critical( 0, tr("Out of space"), 334 QMessageBox::critical( 0, tr("Out of space"),
335 tr( "There was a problem saving " 335 tr( "There was a problem saving "
336 "the playlist.\n" 336 "the playlist.\n"
337 "Your playlist " 337 "Your playlist "
338 "may be missing some entries\n" 338 "may be missing some entries\n"
339 "the next time you start it." ) 339 "the next time you start it." )
340 ); 340 );
341 } 341 }
342 } 342 }
343 noOfFiles++; 343 noOfFiles++;
344 } 344 }
345 } 345 }
346 while ( d->selectedFiles->next() ); 346 while ( d->selectedFiles->next() );
347 cfg.writeEntry("NumberOfFiles", noOfFiles ); 347 cfg.writeEntry("NumberOfFiles", noOfFiles );
348} 348}
349 349
350 350
351void PlayListWidget::addToSelection( const DocLnk& lnk ) { 351void PlayListWidget::addToSelection( const DocLnk& lnk ) {
352 d->setDocumentUsed = FALSE; 352 d->setDocumentUsed = FALSE;
353 if ( mediaPlayerState->playlist() ) { 353 if ( mediaPlayerState->playlist() ) {
354 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) 354 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" )
355 d->selectedFiles->addToSelection( lnk ); 355 d->selectedFiles->addToSelection( lnk );
356 } 356 }
357 else 357 else
358 mediaPlayerState->setPlaying( TRUE ); 358 mediaPlayerState->setPlaying( TRUE );
359} 359}
360 360
361 361
362void PlayListWidget::clearList() { 362void PlayListWidget::clearList() {
363 while ( first() ) { 363 while ( first() ) {
364 d->selectedFiles->removeSelected(); 364 d->selectedFiles->removeSelected();
365 } 365 }
366} 366}
367 367
368 368
369void PlayListWidget::addAllToList() { 369void PlayListWidget::addAllToList() {
370 DocLnkSet filesAll; 370 DocLnkSet filesAll;
371 Global::findDocuments(&filesAll, "video/*;audio/*"); 371 Global::findDocuments(&filesAll, "video/*;audio/*");
372 QListIterator<DocLnk> Adit( filesAll.children() ); 372 QListIterator<DocLnk> Adit( filesAll.children() );
373 for ( ; Adit.current(); ++Adit ) { 373 for ( ; Adit.current(); ++Adit ) {
374 if(QFileInfo(Adit.current()->file()).exists()) { 374 if(QFileInfo(Adit.current()->file()).exists()) {
375 d->selectedFiles->addToSelection( **Adit ); 375 d->selectedFiles->addToSelection( **Adit );
376 } 376 }
377 } 377 }
378} 378}
379 379
380 380
381void PlayListWidget::addAllMusicToList() { 381void PlayListWidget::addAllMusicToList() {
382 QListIterator<DocLnk> dit( files.children() ); 382 QListIterator<DocLnk> dit( files.children() );
383 for ( ; dit.current(); ++dit ) { 383 for ( ; dit.current(); ++dit ) {
384 if(QFileInfo(dit.current()->file()).exists()) { 384 if(QFileInfo(dit.current()->file()).exists()) {
385 d->selectedFiles->addToSelection( **dit ); 385 d->selectedFiles->addToSelection( **dit );
386 } 386 }
387 } 387 }
388} 388}
389 389
390 390
391void PlayListWidget::addAllVideoToList() { 391void PlayListWidget::addAllVideoToList() {
392 QListIterator<DocLnk> dit( vFiles.children() ); 392 QListIterator<DocLnk> dit( vFiles.children() );
393 for ( ; dit.current(); ++dit ) 393 for ( ; dit.current(); ++dit )
394 if(QFileInfo( dit.current()->file()).exists()) 394 if(QFileInfo( dit.current()->file()).exists())
395 d->selectedFiles->addToSelection( **dit ); 395 d->selectedFiles->addToSelection( **dit );
396} 396}
397 397
398 398
399void PlayListWidget::setDocument(const QString& fileref) { 399void PlayListWidget::setDocument(const QString& fileref) {
400 qDebug(fileref); 400 qDebug(fileref);
401 fromSetDocument = TRUE; 401 fromSetDocument = TRUE;
402 if ( fileref.isNull() ) { 402 if ( fileref.isNull() ) {
403 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); 403 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) );
404 return; 404 return;
405 } 405 }
406 406
407 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u 407 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u
408 readm3u( fileref); 408 readm3u( fileref);
409 } else if(fileref.find("pls",0,TRUE) != -1) { //is pls 409 } else if(fileref.find("pls",0,TRUE) != -1) { //is pls
410 readPls( fileref); 410 readPls( fileref);
411 } else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist 411 } else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist
412 clearList(); 412 clearList();
413 loadList(DocLnk(fileref)); 413 loadList(DocLnk(fileref));
414 d->selectedFiles->first(); 414 d->selectedFiles->first();
415 } else { 415 } else {
416 clearList(); 416 clearList();
417 addToSelection( DocLnk( fileref ) ); 417 addToSelection( DocLnk( fileref ) );
418 d->setDocumentUsed = TRUE; 418 d->setDocumentUsed = TRUE;
419 mediaPlayerState->setPlaying( FALSE ); 419 mediaPlayerState->setPlaying( FALSE );
420 qApp->processEvents(); 420 qApp->processEvents();
421 mediaPlayerState->setPlaying( TRUE ); 421 mediaPlayerState->setPlaying( TRUE );
422 qApp->processEvents(); 422 qApp->processEvents();
423 setCaption(tr("OpiePlayer")); 423 setCaption(tr("OpiePlayer"));
424 } 424 }
425} 425}
426 426
427 427
428void PlayListWidget::setActiveWindow() { 428void PlayListWidget::setActiveWindow() {
429 qDebug("SETTING active window");
429 // When we get raised we need to ensure that it switches views 430 // When we get raised we need to ensure that it switches views
430 char origView = mediaPlayerState->view(); 431 char origView = mediaPlayerState->view();
431 mediaPlayerState->setView( 'l' ); // invalidate 432 mediaPlayerState->setView( 'l' ); // invalidate
432 mediaPlayerState->setView( origView ); // now switch back 433 mediaPlayerState->setView( origView ); // now switch back
433} 434}
434 435
435 436
436void PlayListWidget::useSelectedDocument() { 437void PlayListWidget::useSelectedDocument() {
437 d->setDocumentUsed = FALSE; 438 d->setDocumentUsed = FALSE;
438} 439}
439 440
440 441
441const DocLnk *PlayListWidget::current() { // this is fugly 442const DocLnk *PlayListWidget::current() { // this is fugly
442 443
443 switch (tabWidget->currentPageIndex()) { 444 switch (tabWidget->currentPageIndex()) {
444 case 0: //playlist 445 case 0: //playlist
445 { 446 {
446 qDebug("playlist"); 447 qDebug("playlist");
447 if ( mediaPlayerState->playlist() ) { 448 if ( mediaPlayerState->playlist() ) {
448 return d->selectedFiles->current(); 449 return d->selectedFiles->current();
449 } else if ( d->setDocumentUsed && d->current ) { 450 } else if ( d->setDocumentUsed && d->current ) {
450 return d->current; 451 return d->current;
451 } else { 452 } else {
452 return d->files->selected(); 453 return d->files->selected();
453 } 454 }
454 } 455 }
455 break; 456 break;
456 case 1://audio 457 case 1://audio
457 { 458 {
458 qDebug("audioView"); 459 qDebug("audioView");
459 QListIterator<DocLnk> dit( files.children() ); 460 QListIterator<DocLnk> dit( files.children() );
460 for ( ; dit.current(); ++dit ) { 461 for ( ; dit.current(); ++dit ) {
461 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { 462 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) {
462 qDebug("here"); 463 qDebug("here");
463 insanityBool=TRUE; 464 insanityBool=TRUE;
464 return dit; 465 return dit;
465 } 466 }
466 } 467 }
467 } 468 }
468 break; 469 break;
469 case 2: // video 470 case 2: // video
470 { 471 {
471 qDebug("videoView"); 472 qDebug("videoView");
472 QListIterator<DocLnk> Vdit( vFiles.children() ); 473 QListIterator<DocLnk> Vdit( vFiles.children() );
473 for ( ; Vdit.current(); ++Vdit ) { 474 for ( ; Vdit.current(); ++Vdit ) {
474 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { 475 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) {
475 insanityBool=TRUE; 476 insanityBool=TRUE;
476 return Vdit; 477 return Vdit;
477 } 478 }
478 } 479 }
479 } 480 }
480 break; 481 break;
481 }; 482 };
482 return 0; 483 return 0;
483} 484}
484 485
485bool PlayListWidget::prev() { 486bool PlayListWidget::prev() {
486 if ( mediaPlayerState->playlist() ) { 487 if ( mediaPlayerState->playlist() ) {
487 if ( mediaPlayerState->shuffled() ) { 488 if ( mediaPlayerState->shuffled() ) {
488 const DocLnk *cur = current(); 489 const DocLnk *cur = current();
489 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 490 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
490 for ( int i = 0; i < j; i++ ) { 491 for ( int i = 0; i < j; i++ ) {
491 if ( !d->selectedFiles->next() ) 492 if ( !d->selectedFiles->next() )
492 d->selectedFiles->first(); 493 d->selectedFiles->first();
493 } 494 }
494 if ( cur == current() ) 495 if ( cur == current() )
495 if ( !d->selectedFiles->next() ) 496 if ( !d->selectedFiles->next() )
496 d->selectedFiles->first(); 497 d->selectedFiles->first();
497 return TRUE; 498 return TRUE;
498 } else { 499 } else {
499 if ( !d->selectedFiles->prev() ) { 500 if ( !d->selectedFiles->prev() ) {
500 if ( mediaPlayerState->looping() ) { 501 if ( mediaPlayerState->looping() ) {
501 return d->selectedFiles->last(); 502 return d->selectedFiles->last();
502 } else { 503 } else {
503 return FALSE; 504 return FALSE;
504 } 505 }
505 } 506 }
506 return TRUE; 507 return TRUE;
507 } 508 }
508 } else { 509 } else {
509 return mediaPlayerState->looping(); 510 return mediaPlayerState->looping();
510 } 511 }
511} 512}
512 513
513 514
514bool PlayListWidget::next() { 515bool PlayListWidget::next() {
515 if ( mediaPlayerState->playlist() ) { 516 if ( mediaPlayerState->playlist() ) {
516 if ( mediaPlayerState->shuffled() ) { 517 if ( mediaPlayerState->shuffled() ) {
517 return prev(); 518 return prev();
518 } else { 519 } else {
519 if ( !d->selectedFiles->next() ) { 520 if ( !d->selectedFiles->next() ) {
520 if ( mediaPlayerState->looping() ) { 521 if ( mediaPlayerState->looping() ) {
521 return d->selectedFiles->first(); 522 return d->selectedFiles->first();
522 } else { 523 } else {
523 return FALSE; 524 return FALSE;
524 } 525 }
525 } 526 }
526 return TRUE; 527 return TRUE;
527 } 528 }
528 } else { 529 } else {
529 return mediaPlayerState->looping(); 530 return mediaPlayerState->looping();
530 } 531 }
531} 532}
532 533
533 534
534bool PlayListWidget::first() { 535bool PlayListWidget::first() {
535 if ( mediaPlayerState->playlist() ) 536 if ( mediaPlayerState->playlist() )
536 return d->selectedFiles->first(); 537 return d->selectedFiles->first();
537 else 538 else
538 return mediaPlayerState->looping(); 539 return mediaPlayerState->looping();
539} 540}
540 541
541 542
542bool PlayListWidget::last() { 543bool PlayListWidget::last() {
543 if ( mediaPlayerState->playlist() ) 544 if ( mediaPlayerState->playlist() )
544 return d->selectedFiles->last(); 545 return d->selectedFiles->last();
545 else 546 else
546 return mediaPlayerState->looping(); 547 return mediaPlayerState->looping();
547} 548}
548 549
549 550
550void PlayListWidget::saveList() { 551void PlayListWidget::saveList() {
551 552
552 QString filename; 553 QString filename;
553 InputDialog *fileDlg; 554 InputDialog *fileDlg;
554 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); 555 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0);
555 fileDlg->exec(); 556 fileDlg->exec();
556 if( fileDlg->result() == 1 ) { 557 if( fileDlg->result() == 1 ) {
557 if ( d->current ) 558 if ( d->current )
558 delete d->current; 559 delete d->current;
559 filename = fileDlg->LineEdit1->text();//+".playlist"; 560 filename = fileDlg->LineEdit1->text();//+".playlist";
560 // qDebug("saving playlist "+filename+".playlist"); 561 // qDebug("saving playlist "+filename+".playlist");
561 Config cfg( filename +".playlist"); 562 Config cfg( filename +".playlist");
562 writeConfig( cfg ); 563 writeConfig( cfg );
563 564
564 DocLnk lnk; 565 DocLnk lnk;
565 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property 566 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property
566 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D 567 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D
567 lnk.setIcon("opieplayer/playlist2"); 568 lnk.setIcon("opieplayer/playlist2");
568 lnk.setName( filename); //sets file name 569 lnk.setName( filename); //sets file name
569 // qDebug(filename); 570 // qDebug(filename);
570 if(!lnk.writeLink()) { 571 if(!lnk.writeLink()) {
571 qDebug("Writing doclink did not work"); 572 qDebug("Writing doclink did not work");
572 } 573 }
573 } 574 }
574 Config config( "OpiePlayer" ); 575 Config config( "OpiePlayer" );
575 config.writeEntry("CurrentPlaylist",filename); 576 config.writeEntry("CurrentPlaylist",filename);
576 setCaption(tr("OpiePlayer: ")+filename); 577 setCaption(tr("OpiePlayer: ")+filename);
577 d->selectedFiles->first(); 578 d->selectedFiles->first();
578 if(fileDlg) { 579 if(fileDlg) {
579 delete fileDlg; 580 delete fileDlg;
580 } 581 }
581} 582}
582 583
583void PlayListWidget::loadList( const DocLnk & lnk) { 584void PlayListWidget::loadList( const DocLnk & lnk) {
584 QString name= lnk.name(); 585 QString name= lnk.name();
585 // qDebug("currentList is "+name); 586 // qDebug("currentList is "+name);
586 if( name.length()>1) { 587 if( name.length()>1) {
587 setCaption("OpiePlayer: "+name); 588 setCaption("OpiePlayer: "+name);
588 // qDebug("load list "+ name+".playlist"); 589 // qDebug("load list "+ name+".playlist");
589 clearList(); 590 clearList();
590 Config cfg( name+".playlist"); 591 Config cfg( name+".playlist");
591 readConfig(cfg); 592 readConfig(cfg);
592 593
593 tabWidget->setCurrentPage(0); 594 tabWidget->setCurrentPage(0);
594 595
595 Config config( "OpiePlayer" ); 596 Config config( "OpiePlayer" );
596 config.writeEntry("CurrentPlaylist", name); 597 config.writeEntry("CurrentPlaylist", name);
597 // d->selectedFiles->first(); 598 // d->selectedFiles->first();
598 } 599 }
599 600
600} 601}
601 602
602void PlayListWidget::setPlaylist( bool shown ) { 603void PlayListWidget::setPlaylist( bool shown ) {
603 if ( shown ) { 604 if ( shown ) {
604 d->playListFrame->show(); 605 d->playListFrame->show();
605 } else { 606 } else {
606 d->playListFrame->hide(); 607 d->playListFrame->hide();
607 } 608 }
608} 609}
609 610
610void PlayListWidget::setView( char view ) { 611void PlayListWidget::setView( char view ) {
611 if ( view == 'l' ) 612 if ( view == 'l' )
612 showMaximized(); 613 showMaximized();
613 else 614 else
614 hide(); 615 hide();
615} 616}
616 617
617void PlayListWidget::addSelected() { 618void PlayListWidget::addSelected() {
618 619
619 Config cfg( "OpiePlayer" ); 620 Config cfg( "OpiePlayer" );
620 cfg.setGroup("PlayList"); 621 cfg.setGroup("PlayList");
621 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 622 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
622 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 623 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
623 624
624 switch (tabWidget->currentPageIndex()) { 625 switch (tabWidget->currentPageIndex()) {
625 case 0: //playlist 626 case 0: //playlist
626 break; 627 break;
627 case 1: { //audio 628 case 1: { //audio
628 QListViewItemIterator it( audioView ); 629 QListViewItemIterator it( audioView );
629 // iterate through all items of the listview 630 // iterate through all items of the listview
630 for ( ; it.current(); ++it ) { 631 for ( ; it.current(); ++it ) {
631 if ( it.current()->isSelected() ) { 632 if ( it.current()->isSelected() ) {
632 QListIterator<DocLnk> dit( files.children() ); 633 QListIterator<DocLnk> dit( files.children() );
633 for ( ; dit.current(); ++dit ) { 634 for ( ; dit.current(); ++dit ) {
634 if( dit.current()->name() == it.current()->text(0) ) { 635 if( dit.current()->name() == it.current()->text(0) ) {
635 d->selectedFiles->addToSelection( **dit ); 636 d->selectedFiles->addToSelection( **dit );
636 } 637 }
637 } 638 }
638 audioView->setSelected( it.current(),FALSE); 639 audioView->setSelected( it.current(),FALSE);
639 } 640 }
640 } 641 }
641 tabWidget->setCurrentPage(0); 642 tabWidget->setCurrentPage(0);
642 } 643 }
643 break; 644 break;
644 case 2: { // video 645 case 2: { // video
645 QListViewItemIterator it( videoView ); 646 QListViewItemIterator it( videoView );
646 // iterate through all items of the listview 647 // iterate through all items of the listview
647 for ( ; it.current(); ++it ) { 648 for ( ; it.current(); ++it ) {
648 if ( it.current()->isSelected() ) { 649 if ( it.current()->isSelected() ) {
649 QListIterator<DocLnk> dit( vFiles.children() ); 650 QListIterator<DocLnk> dit( vFiles.children() );
650 for ( ; dit.current(); ++dit ) { 651 for ( ; dit.current(); ++dit ) {
651 if( dit.current()->name() == it.current()->text(0) ) { 652 if( dit.current()->name() == it.current()->text(0) ) {
652 d->selectedFiles->addToSelection( **dit ); 653 d->selectedFiles->addToSelection( **dit );
653 } 654 }
654 } 655 }
655 videoView->setSelected( it.current(),FALSE); 656 videoView->setSelected( it.current(),FALSE);
656 } 657 }
657 } 658 }
658 tabWidget->setCurrentPage(0); 659 tabWidget->setCurrentPage(0);
659 } 660 }
660 break; 661 break;
661 }; 662 };
662} 663}
663 664
664void PlayListWidget::removeSelected() { 665void PlayListWidget::removeSelected() {
665 d->selectedFiles->removeSelected( ); 666 d->selectedFiles->removeSelected( );
666} 667}
667 668
668void PlayListWidget::playIt( QListViewItem *it) { 669void PlayListWidget::playIt( QListViewItem *it) {
669 qDebug("playIt"); 670 qDebug("playIt");
670 mediaPlayerState->setPlaying(FALSE); 671 mediaPlayerState->setPlaying(FALSE);
671 mediaPlayerState->setPlaying(TRUE); 672 mediaPlayerState->setPlaying(TRUE);
672 d->selectedFiles->unSelect(); 673 d->selectedFiles->unSelect();
673} 674}
674 675
675void PlayListWidget::addToSelection( QListViewItem *it) { 676void PlayListWidget::addToSelection( QListViewItem *it) {
676 d->setDocumentUsed = FALSE; 677 d->setDocumentUsed = FALSE;
677 678
678 if(it) { 679 if(it) {
679 switch (tabWidget->currentPageIndex()) { 680 switch (tabWidget->currentPageIndex()) {
680 case 1: { 681 case 1: {
681 QListIterator<DocLnk> dit( files.children() ); 682 QListIterator<DocLnk> dit( files.children() );
682 for ( ; dit.current(); ++dit ) { 683 for ( ; dit.current(); ++dit ) {
683 if( dit.current()->name() == it->text(0)) { 684 if( dit.current()->name() == it->text(0)) {
684 d->selectedFiles->addToSelection( **dit ); 685 d->selectedFiles->addToSelection( **dit );
685 } 686 }
686 } 687 }
687 } 688 }
688 break; 689 break;
689 case 2: { 690 case 2: {
690 QListIterator<DocLnk> dit( vFiles.children() ); 691 QListIterator<DocLnk> dit( vFiles.children() );
691 for ( ; dit.current(); ++dit ) { 692 for ( ; dit.current(); ++dit ) {
692 if( dit.current()->name() == it->text(0)) { 693 if( dit.current()->name() == it->text(0)) {
693 d->selectedFiles->addToSelection( **dit ); 694 d->selectedFiles->addToSelection( **dit );
694 } 695 }
695 } 696 }
696 } 697 }
697 break; 698 break;
698 case 0: 699 case 0:
699 break; 700 break;
700 }; 701 };
701 tabWidget->setCurrentPage(0); 702 tabWidget->setCurrentPage(0);
702 } 703 }
703} 704}
704 705
705void PlayListWidget::tabChanged(QWidget *widg) { 706void PlayListWidget::tabChanged(QWidget *widg) {
706 707
707 switch ( tabWidget->currentPageIndex()) { 708 switch ( tabWidget->currentPageIndex()) {
708 case 0: 709 case 0:
709 { 710 {
710 if( !tbDeletePlaylist->isHidden()) 711 if( !tbDeletePlaylist->isHidden())
711 tbDeletePlaylist->hide(); 712 tbDeletePlaylist->hide();
712 d->tbRemoveFromList->setEnabled(TRUE); 713 d->tbRemoveFromList->setEnabled(TRUE);
713 d->tbAddToList->setEnabled(FALSE); 714 d->tbAddToList->setEnabled(FALSE);
714 } 715 }
715 break; 716 break;
716 case 1: 717 case 1:
717 { 718 {
718 audioView->clear(); 719 audioView->clear();
719 populateAudioView(); 720 populateAudioView();
720 721
721 if( !tbDeletePlaylist->isHidden()) 722 if( !tbDeletePlaylist->isHidden())
722 tbDeletePlaylist->hide(); 723 tbDeletePlaylist->hide();
723 d->tbRemoveFromList->setEnabled(FALSE); 724 d->tbRemoveFromList->setEnabled(FALSE);
724 d->tbAddToList->setEnabled(TRUE); 725 d->tbAddToList->setEnabled(TRUE);
725 } 726 }
726 break; 727 break;
727 case 2: 728 case 2:
728 { 729 {
729 videoView->clear(); 730 videoView->clear();
730 populateVideoView(); 731 populateVideoView();
731 if( !tbDeletePlaylist->isHidden()) 732 if( !tbDeletePlaylist->isHidden())
732 tbDeletePlaylist->hide(); 733 tbDeletePlaylist->hide();
733 d->tbRemoveFromList->setEnabled(FALSE); 734 d->tbRemoveFromList->setEnabled(FALSE);
734 d->tbAddToList->setEnabled(TRUE); 735 d->tbAddToList->setEnabled(TRUE);
735 } 736 }
736 break; 737 break;
737 case 3: 738 case 3:
738 { 739 {
739 if( tbDeletePlaylist->isHidden()) 740 if( tbDeletePlaylist->isHidden())
740 tbDeletePlaylist->show(); 741 tbDeletePlaylist->show();
741 playLists->reread(); 742 playLists->reread();
742 } 743 }
743 break; 744 break;
744 }; 745 };
745} 746}
746 747
747void PlayListWidget::btnPlay(bool b) { 748void PlayListWidget::btnPlay(bool b) {
748 749
749// mediaPlayerState->setPlaying(b); 750// mediaPlayerState->setPlaying(b);
750 switch ( tabWidget->currentPageIndex()) { 751 switch ( tabWidget->currentPageIndex()) {
751 case 0: 752 case 0:
752 { 753 {
753 mediaPlayerState->setPlaying(b); 754 mediaPlayerState->setPlaying(b);
754 } 755 }
755 break; 756 break;
756 case 1: 757 case 1:
757 { 758 {
758 addToSelection( audioView->currentItem() ); 759 addToSelection( audioView->currentItem() );
759 mediaPlayerState->setPlaying(b); 760 mediaPlayerState->setPlaying(b);
760 d->selectedFiles->removeSelected( ); 761 d->selectedFiles->removeSelected( );
761 tabWidget->setCurrentPage(1); 762 tabWidget->setCurrentPage(1);
762 d->selectedFiles->unSelect(); 763 d->selectedFiles->unSelect();
763 insanityBool=FALSE; 764 insanityBool=FALSE;
764 }// audioView->clearSelection(); 765 }// audioView->clearSelection();
765 break; 766 break;
766 case 2: 767 case 2:
767 { 768 {
768 addToSelection( videoView->currentItem() ); 769 addToSelection( videoView->currentItem() );
769 mediaPlayerState->setPlaying(b); 770 mediaPlayerState->setPlaying(b);
770 qApp->processEvents(); 771 qApp->processEvents();
771 d->selectedFiles->removeSelected( ); 772 d->selectedFiles->removeSelected( );
772 tabWidget->setCurrentPage(2); 773 tabWidget->setCurrentPage(2);
773 d->selectedFiles->unSelect(); 774 d->selectedFiles->unSelect();
774 insanityBool=FALSE; 775 insanityBool=FALSE;
775 }// videoView->clearSelection(); 776 }// videoView->clearSelection();
776 break; 777 break;
777 }; 778 };
778 779
779} 780}
780 781
781void PlayListWidget::deletePlaylist() { 782void PlayListWidget::deletePlaylist() {
782 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 783 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
783 (tr("You really want to delete\nthis playlist?")), 784 (tr("You really want to delete\nthis playlist?")),
784 (tr("Yes")), (tr("No")), 0 )){ 785 (tr("Yes")), (tr("No")), 0 )){
785 case 0: // Yes clicked, 786 case 0: // Yes clicked,
786 QFile().remove(playLists->selected()->file()); 787 QFile().remove(playLists->selected()->file());
787 QFile().remove(playLists->selected()->linkFile()); 788 QFile().remove(playLists->selected()->linkFile());
788 playLists->reread(); 789 playLists->reread();
789 break; 790 break;
790 case 1: // Cancel 791 case 1: // Cancel
791 break; 792 break;
792 }; 793 };
793} 794}
794 795
795void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) { 796void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) {
796 switch (mouse) { 797 switch (mouse) {
797 case 1: 798 case 1:
798 break; 799 break;
799 case 2:{ 800 case 2:{
800 QPopupMenu m; 801 QPopupMenu m;
801 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 802 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
802 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 803 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
803 m.insertSeparator(); 804 m.insertSeparator();
804 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 805 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
805 m.exec( QCursor::pos() ); 806 m.exec( QCursor::pos() );
806 } 807 }
807 break; 808 break;
808 }; 809 };
809} 810}
810 811
811void PlayListWidget::playSelected() { 812void PlayListWidget::playSelected() {
812 btnPlay( TRUE); 813 btnPlay( TRUE);
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp
index 878cd4a..19a9172 100644
--- a/noncore/multimedia/opieplayer2/xinecontrol.cpp
+++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp
@@ -1,131 +1,130 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34 34
35#include <qtimer.h> 35#include <qtimer.h>
36#include "xinecontrol.h" 36#include "xinecontrol.h"
37#include "mediaplayerstate.h" 37#include "mediaplayerstate.h"
38#include "videowidget.h" 38#include "videowidget.h"
39 39
40extern MediaPlayerState *mediaPlayerState; 40extern MediaPlayerState *mediaPlayerState;
41extern VideoWidget *videoUI; 41extern VideoWidget *videoUI;
42XineControl::XineControl( QObject *parent, const char *name ) 42XineControl::XineControl( QObject *parent, const char *name )
43 : QObject( parent, name ) { 43 : QObject( parent, name ) {
44 libXine = new XINE::Lib(videoUI->vidWidget() ); 44 libXine = new XINE::Lib(videoUI->vidWidget() );
45 45
46 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) ); 46 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( pause(bool) ) );
47 connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) ); 47 connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( updatePosition( long ) ) );
48 connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( setPosition( long ) ) ); 48 connect( this, SIGNAL( positionChanged( long ) ), mediaPlayerState, SLOT( setPosition( long ) ) );
49 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) ); 49 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( stop( bool ) ) );
50 connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) ); 50 connect( mediaPlayerState, SIGNAL( fullscreenToggled( bool ) ), this, SLOT( setFullscreen( bool ) ) );
51 connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) ); 51 connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( seekTo( long ) ) );
52 52
53} 53}
54 54
55XineControl::~XineControl() { 55XineControl::~XineControl() {
56 delete libXine; 56 delete libXine;
57} 57}
58 58
59void XineControl::play( const QString& fileName ) { 59void XineControl::play( const QString& fileName ) {
60 libXine->play( fileName ); 60 libXine->play( fileName );
61 mediaPlayerState->setPlaying( true ); 61 mediaPlayerState->setPlaying( true );
62 // default to audio view until we know how to handle video 62 // default to audio view until we know how to handle video
63 // MediaDetect mdetect; 63 // MediaDetect mdetect;
64 char whichGui = mdetect.videoOrAudio( fileName ); 64 char whichGui = mdetect.videoOrAudio( fileName );
65 if (whichGui == 'f') { 65 if (whichGui == 'f') {
66 qDebug("Nicht erkannter Dateityp"); 66 qDebug("Nicht erkannter Dateityp");
67 return; 67 return;
68 } 68 }
69 69
70 if (whichGui == 'a') { 70 if (whichGui == 'a') {
71 libXine->setShowVideo( false ); 71 libXine->setShowVideo( false );
72 } else { 72 } else {
73 libXine->setShowVideo( true ); 73 libXine->setShowVideo( true );
74 } 74 }
75 75
76 // determine if slider is shown 76 // determine if slider is shown
77 // mediaPlayerState->setIsStreaming( mdetect.isStreaming( fileName ) ); 77 // mediaPlayerState->setIsStreaming( mdetect.isStreaming( fileName ) );
78 mediaPlayerState->setIsStreaming( libXine->isSeekable() ); 78 mediaPlayerState->setIsStreaming( libXine->isSeekable() );
79 // which gui (video / audio) 79 // which gui (video / audio)
80 mediaPlayerState->setView( whichGui ); 80 mediaPlayerState->setView( whichGui );
81 length(); 81 length();
82 position(); 82 position();
83
84} 83}
85 84
86void XineControl::stop( bool isSet ) { 85void XineControl::stop( bool isSet ) {
87 if ( !isSet) { 86 if ( !isSet) {
88 libXine->stop(); 87 libXine->stop();
89 mediaPlayerState->setList(); 88 mediaPlayerState->setList();
90 //mediaPlayerState->setPlaying( false ); 89 //mediaPlayerState->setPlaying( false );
91 } else { 90 } else {
92 // play again 91 // play again
93 } 92 }
94} 93}
95 94
96void XineControl::pause( bool isSet) { 95void XineControl::pause( bool isSet) {
97 libXine->pause(); 96 libXine->pause();
98} 97}
99 98
100int XineControl::currentTime() { 99long XineControl::currentTime() {
101 // todo: jede sekunde überprüfen 100 // todo: jede sekunde überprüfen
102 m_currentTime = libXine->currentTime(); 101 m_currentTime = libXine->currentTime();
103 return m_currentTime; 102 return m_currentTime;
104 QTimer::singleShot( 1000, this, SLOT( currentTime() ) ); 103 QTimer::singleShot( 1000, this, SLOT( currentTime() ) );
105} 104}
106 105
107void XineControl::length() { 106void XineControl::length() {
108 m_length = libXine->length(); 107 m_length = libXine->length();
109 mediaPlayerState->setLength( m_length ); 108 mediaPlayerState->setLength( m_length );
110} 109}
111 110
112long XineControl::position() { 111long XineControl::position() {
113 qDebug("<<<<<<<<<<<< xinecontrol setPostion>>>>>>>>>"); 112 m_position = ( currentTime() );
114 m_position = (m_currentTime/m_length*100);
115 mediaPlayerState->setPosition( m_position ); 113 mediaPlayerState->setPosition( m_position );
116 long emitPos = (long)m_position; 114 long emitPos = (long)m_position;
117 emit positionChanged( emitPos ); 115 emit positionChanged( emitPos );
116 if(mediaPlayerState->isPlaying)
118 // needs to be stopped the media is stopped 117 // needs to be stopped the media is stopped
119 QTimer::singleShot( 1000, this, SLOT( position() ) ); 118 QTimer::singleShot( 1000, this, SLOT( position() ) );
120 qDebug("POSITION : " + m_position); 119// qDebug("POSITION : %d", m_position);
121 return m_position; 120 return m_position;
122} 121}
123 122
124void XineControl::setFullscreen( bool isSet ) { 123void XineControl::setFullscreen( bool isSet ) {
125 libXine->showVideoFullScreen( isSet); 124 libXine->showVideoFullScreen( isSet);
126} 125}
127 126
128void XineControl::seekTo( long second ) { 127void XineControl::seekTo( long second ) {
129 // libXine-> 128 // libXine->
130} 129}
131 130
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.h b/noncore/multimedia/opieplayer2/xinecontrol.h
index 07ad309..295d2b4 100644
--- a/noncore/multimedia/opieplayer2/xinecontrol.h
+++ b/noncore/multimedia/opieplayer2/xinecontrol.h
@@ -1,72 +1,71 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef XINECONTROL_H 34#ifndef XINECONTROL_H
35#define XINECONTROL_H 35#define XINECONTROL_H
36 36
37#include "lib.h" 37#include "lib.h"
38#include "mediadetect.h" 38#include "mediadetect.h"
39#include <qobject.h> 39#include <qobject.h>
40 40
41class XineControl : public QObject { 41class XineControl : public QObject {
42 Q_OBJECT 42 Q_OBJECT
43public: 43public:
44 XineControl( QObject *parent = 0, const char *name =0 ); 44 XineControl( QObject *parent = 0, const char *name =0 );
45 ~XineControl(); 45 ~XineControl();
46 int m_length; 46 int m_length;
47 47
48public slots: 48public slots:
49 void play( const QString& fileName ); 49 void play( const QString& fileName );
50 void stop( bool ); 50 void stop( bool );
51 void pause( bool ); 51 void pause( bool );
52 void setFullscreen( bool ); 52 void setFullscreen( bool );
53 int currentTime(); 53 long currentTime();
54 void seekTo( long ); 54 void seekTo( long );
55 // get length of media file and set it 55 // get length of media file and set it
56 void length(); 56 void length();
57
58 long position(); 57 long position();
59 58
60private: 59private:
61 XINE::Lib *libXine; 60 XINE::Lib *libXine;
62 MediaDetect mdetect; 61 MediaDetect mdetect;
63 int m_currentTime; 62 long m_currentTime;
64 long m_position; 63 long m_position;
65 64
66signals: 65signals:
67 void positionChanged( long ); 66 void positionChanged( long );
68 67
69}; 68};
70 69
71 70
72#endif 71#endif