summaryrefslogtreecommitdiff
authorzecke <zecke>2004-09-24 16:03:38 (UTC)
committer zecke <zecke>2004-09-24 16:03:38 (UTC)
commit0b9478d52735eb62a4ead580344b989ecf03d356 (patch) (unidiff)
tree1f95262623d3513dc6a061a62be65f891d023217
parent2911cb18af1fad00bc3557cffe2d2d2ec3a9d346 (diff)
downloadopie-0b9478d52735eb62a4ead580344b989ecf03d356.zip
opie-0b9478d52735eb62a4ead580344b989ecf03d356.tar.gz
opie-0b9478d52735eb62a4ead580344b989ecf03d356.tar.bz2
-remove qApp->processEvents when starting playing
Revamp Adding Files and Add Directory -Remove custom code to save the last Directory Used -Share MimeType creating code -Add Method to add a File to the Playlist and use it for AddFile and Add Directory
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp1
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp108
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.h2
3 files changed, 64 insertions, 47 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index b8023ca..043d8ba 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -1,367 +1,366 @@
1#include "mediaplayer.h" 1#include "mediaplayer.h"
2#include "audiowidget.h" 2#include "audiowidget.h"
3#include "videowidget.h" 3#include "videowidget.h"
4#include "volumecontrol.h" 4#include "volumecontrol.h"
5 5
6/* OPIE */ 6/* OPIE */
7#include <opie2/odebug.h> 7#include <opie2/odebug.h>
8#include <opie2/odevice.h> 8#include <opie2/odevice.h>
9#include <qpe/qpeapplication.h> 9#include <qpe/qpeapplication.h>
10#include <qpe/config.h> 10#include <qpe/config.h>
11 11
12/* QT */ 12/* QT */
13#include <qfileinfo.h> 13#include <qfileinfo.h>
14 14
15/* STD */ 15/* STD */
16#include <linux/fb.h> 16#include <linux/fb.h>
17#include <sys/file.h> 17#include <sys/file.h>
18#include <sys/ioctl.h> 18#include <sys/ioctl.h>
19 19
20#define FBIOBLANK 0x4611 20#define FBIOBLANK 0x4611
21 21
22MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name ) 22MediaPlayer::MediaPlayer( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QObject *parent, const char *name )
23 : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) { 23 : QObject( parent, name ), volumeDirection( 0 ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) {
24 24
25 m_audioUI = 0; 25 m_audioUI = 0;
26 m_videoUI = 0; 26 m_videoUI = 0;
27 m_xineControl = 0; 27 m_xineControl = 0;
28 xine = new XINE::Lib( XINE::Lib::InitializeInThread ); 28 xine = new XINE::Lib( XINE::Lib::InitializeInThread );
29 29
30 fd=-1;fl=-1; 30 fd=-1;fl=-1;
31 playList.setCaption( tr( "OpiePlayer: Initializating" ) ); 31 playList.setCaption( tr( "OpiePlayer: Initializating" ) );
32 32
33 qApp->processEvents(); 33 qApp->processEvents();
34 // QPEApplication::grabKeyboard(); // EVIL 34 // QPEApplication::grabKeyboard(); // EVIL
35 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 35 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
36 36
37 connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 37 connect( &mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
38 connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); 38 connect( &mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) );
39 connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); 39 connect( &mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) );
40 connect( &mediaPlayerState, SIGNAL( blankToggled(bool) ), this, SLOT ( blank(bool) ) ); 40 connect( &mediaPlayerState, SIGNAL( blankToggled(bool) ), this, SLOT ( blank(bool) ) );
41 41
42 volControl = new VolumeControl; 42 volControl = new VolumeControl;
43 Config cfg( "OpiePlayer" ); 43 Config cfg( "OpiePlayer" );
44 cfg.setGroup("PlayList"); 44 cfg.setGroup("PlayList");
45 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); 45 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
46 playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() ); 46 playList.setCaption( tr( "OpiePlayer: " ) + QFileInfo(currentPlaylist).baseName() );
47 47
48 m_skinLoader = new SkinLoader; 48 m_skinLoader = new SkinLoader;
49 m_skinLoader->schedule( AudioWidget::guiInfo() ); 49 m_skinLoader->schedule( AudioWidget::guiInfo() );
50 m_skinLoader->schedule( VideoWidget::guiInfo() ); 50 m_skinLoader->schedule( VideoWidget::guiInfo() );
51 m_skinLoader->start(); 51 m_skinLoader->start();
52} 52}
53 53
54MediaPlayer::~MediaPlayer() { 54MediaPlayer::~MediaPlayer() {
55 // this shold never happen, but one never knows... 55 // this shold never happen, but one never knows...
56 if ( xine ) { 56 if ( xine ) {
57 xine->ensureInitialized(); 57 xine->ensureInitialized();
58 delete xine; 58 delete xine;
59 } 59 }
60 delete m_xineControl; 60 delete m_xineControl;
61 delete m_audioUI; 61 delete m_audioUI;
62 delete m_videoUI; 62 delete m_videoUI;
63 delete volControl; 63 delete volControl;
64} 64}
65 65
66void MediaPlayer::pauseCheck( bool b ) { 66void MediaPlayer::pauseCheck( bool b ) {
67 if ( b && !mediaPlayerState.isPlaying() ) { 67 if ( b && !mediaPlayerState.isPlaying() ) {
68 mediaPlayerState.setPaused( FALSE ); 68 mediaPlayerState.setPaused( FALSE );
69 } 69 }
70} 70}
71 71
72void MediaPlayer::play() { 72void MediaPlayer::play() {
73 mediaPlayerState.setPlaying( FALSE ); 73 mediaPlayerState.setPlaying( FALSE );
74 mediaPlayerState.setPlaying( TRUE ); 74 mediaPlayerState.setPlaying( TRUE );
75} 75}
76 76
77void MediaPlayer::setPlaying( bool play ) { 77void MediaPlayer::setPlaying( bool play ) {
78 if ( !play ) { 78 if ( !play ) {
79 return; 79 return;
80 } 80 }
81 81
82 if ( mediaPlayerState.isPaused() ) { 82 if ( mediaPlayerState.isPaused() ) {
83 mediaPlayerState.setPaused( FALSE ); 83 mediaPlayerState.setPaused( FALSE );
84 return; 84 return;
85 } 85 }
86 86
87 QString tickerText, time, fileName; 87 QString tickerText, time, fileName;
88 if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) { 88 if ( playList.currentTab() != PlayListWidget::CurrentPlayList ) {
89 //if playing in file list.. play in a different way 89 //if playing in file list.. play in a different way
90 // random and looping settings enabled causes problems here, 90 // random and looping settings enabled causes problems here,
91 // since there is no selected file in the playlist, but a selected file in the file list, 91 // since there is no selected file in the playlist, but a selected file in the file list,
92 // so we remember and shutoff 92 // so we remember and shutoff
93 l = mediaPlayerState.isLooping(); 93 l = mediaPlayerState.isLooping();
94 if(l) { 94 if(l) {
95 mediaPlayerState.setLooping( false ); 95 mediaPlayerState.setLooping( false );
96 } 96 }
97 r = mediaPlayerState.isShuffled(); 97 r = mediaPlayerState.isShuffled();
98 mediaPlayerState.setShuffled( false ); 98 mediaPlayerState.setShuffled( false );
99 } 99 }
100 100
101 PlayListWidget::Entry playListEntry = playList.currentEntry(); 101 PlayListWidget::Entry playListEntry = playList.currentEntry();
102 fileName = playListEntry.name; 102 fileName = playListEntry.name;
103 xineControl()->play( playListEntry.file ); 103 xineControl()->play( playListEntry.file );
104 104
105 long seconds = mediaPlayerState.length(); 105 long seconds = mediaPlayerState.length();
106 time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); 106 time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
107 107
108 if( fileName.left(4) == "http" ) { 108 if( fileName.left(4) == "http" ) {
109 fileName = QFileInfo( fileName ).baseName(); 109 fileName = QFileInfo( fileName ).baseName();
110 if ( xineControl()->getMetaInfo().isEmpty() ) { 110 if ( xineControl()->getMetaInfo().isEmpty() ) {
111 tickerText = tr( " File: " ) + fileName; 111 tickerText = tr( " File: " ) + fileName;
112 } else { 112 } else {
113 tickerText = xineControl()->getMetaInfo(); 113 tickerText = xineControl()->getMetaInfo();
114 } 114 }
115 } else { 115 } else {
116 if ( xineControl()->getMetaInfo().isEmpty() ) { 116 if ( xineControl()->getMetaInfo().isEmpty() ) {
117 tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " "; 117 tickerText = tr( " File: " ) + fileName + tr( ", Length: " ) + time + " ";
118 } else { 118 } else {
119 tickerText = xineControl()->getMetaInfo() + " Length: " + time + " "; 119 tickerText = xineControl()->getMetaInfo() + " Length: " + time + " ";
120 } 120 }
121 } 121 }
122 audioUI()->setTickerText( tickerText ); 122 audioUI()->setTickerText( tickerText );
123} 123}
124 124
125 125
126void MediaPlayer::prev() { 126void MediaPlayer::prev() {
127 if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist 127 if( playList.currentTab() == PlayListWidget::CurrentPlayList ) { //if using the playlist
128 if ( playList.prev() ) { 128 if ( playList.prev() ) {
129 play(); 129 play();
130 } else if ( mediaPlayerState.isLooping() ) { 130 } else if ( mediaPlayerState.isLooping() ) {
131 if ( playList.last() ) { 131 if ( playList.last() ) {
132 play(); 132 play();
133 } 133 }
134 } else { 134 } else {
135 mediaPlayerState.setList(); 135 mediaPlayerState.setList();
136 } 136 }
137 } 137 }
138} 138}
139 139
140 140
141void MediaPlayer::next() { 141void MediaPlayer::next() {
142 142
143 if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist 143 if(playList.currentTab() == PlayListWidget::CurrentPlayList) { //if using the playlist
144 if ( playList.next() ) { 144 if ( playList.next() ) {
145 play(); 145 play();
146 } else if ( mediaPlayerState.isLooping() ) { 146 } else if ( mediaPlayerState.isLooping() ) {
147 if ( playList.first() ) { 147 if ( playList.first() ) {
148 play(); 148 play();
149 } 149 }
150 } else { 150 } else {
151 mediaPlayerState.setList(); 151 mediaPlayerState.setList();
152 } 152 }
153 } else { //if playing from file list, let's just stop 153 } else { //if playing from file list, let's just stop
154 odebug << "<<<<<<<<<<<<<<<<<stop for filelists" << oendl; 154 odebug << "<<<<<<<<<<<<<<<<<stop for filelists" << oendl;
155 mediaPlayerState.setPlaying(false); 155 mediaPlayerState.setPlaying(false);
156 mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); 156 mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection );
157 if(l) mediaPlayerState.setLooping(l); 157 if(l) mediaPlayerState.setLooping(l);
158 if(r) mediaPlayerState.setShuffled(r); 158 if(r) mediaPlayerState.setShuffled(r);
159 } 159 }
160 qApp->processEvents();
161} 160}
162 161
163 162
164void MediaPlayer::startDecreasingVolume() { 163void MediaPlayer::startDecreasingVolume() {
165 volumeDirection = -1; 164 volumeDirection = -1;
166 startTimer( 100 ); 165 startTimer( 100 );
167 volControl->decVol(2); 166 volControl->decVol(2);
168} 167}
169 168
170 169
171void MediaPlayer::startIncreasingVolume() { 170void MediaPlayer::startIncreasingVolume() {
172 volumeDirection = +1; 171 volumeDirection = +1;
173 startTimer( 100 ); 172 startTimer( 100 );
174 volControl->incVol(2); 173 volControl->incVol(2);
175} 174}
176 175
177 176
178bool drawnOnScreenDisplay = FALSE; 177bool drawnOnScreenDisplay = FALSE;
179unsigned int onScreenDisplayVolume = 0; 178unsigned int onScreenDisplayVolume = 0;
180const int yoff = 110; 179const int yoff = 110;
181 180
182void MediaPlayer::stopChangingVolume() { 181void MediaPlayer::stopChangingVolume() {
183 killTimers(); 182 killTimers();
184 // Get rid of the on-screen display stuff 183 // Get rid of the on-screen display stuff
185 drawnOnScreenDisplay = FALSE; 184 drawnOnScreenDisplay = FALSE;
186 onScreenDisplayVolume = 0; 185 onScreenDisplayVolume = 0;
187 int w=0; 186 int w=0;
188 int h=0; 187 int h=0;
189 if( !xineControl()->hasVideo() ) { 188 if( !xineControl()->hasVideo() ) {
190 w = audioUI()->width(); 189 w = audioUI()->width();
191 h = audioUI()->height(); 190 h = audioUI()->height();
192 audioUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); 191 audioUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE );
193 } else { 192 } else {
194 w = videoUI()->width(); 193 w = videoUI()->width();
195 h = videoUI()->height(); 194 h = videoUI()->height();
196 videoUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE ); 195 videoUI()->repaint( ( w - 200 ) / 2, h - yoff, 200 + 9, 70, FALSE );
197 } 196 }
198} 197}
199 198
200 199
201void MediaPlayer::timerEvent( QTimerEvent * ) { 200void MediaPlayer::timerEvent( QTimerEvent * ) {
202 if ( volumeDirection == +1 ) { 201 if ( volumeDirection == +1 ) {
203 volControl->incVol( 2 ); 202 volControl->incVol( 2 );
204 } else if ( volumeDirection == -1 ) { 203 } else if ( volumeDirection == -1 ) {
205 volControl->decVol( 2 ); 204 volControl->decVol( 2 );
206 } 205 }
207 206
208 207
209 // TODO FIXME 208 // TODO FIXME
210 // huh?? 209 // huh??
211 unsigned int v= 0; 210 unsigned int v= 0;
212 v = volControl->volume(); 211 v = volControl->volume();
213 v = v / 10; 212 v = v / 10;
214 213
215 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { 214 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) {
216 return; 215 return;
217 } 216 }
218 217
219 int w=0; int h=0; 218 int w=0; int h=0;
220 if( !xineControl()->hasVideo() ) { 219 if( !xineControl()->hasVideo() ) {
221 w = audioUI()->width(); 220 w = audioUI()->width();
222 h = audioUI()->height(); 221 h = audioUI()->height();
223 222
224 if ( drawnOnScreenDisplay ) { 223 if ( drawnOnScreenDisplay ) {
225 if ( onScreenDisplayVolume > v ) { 224 if ( onScreenDisplayVolume > v ) {
226 audioUI()->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); 225 audioUI()->repaint( ( w - 200 ) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE );
227 } 226 }
228 } 227 }
229 drawnOnScreenDisplay = TRUE; 228 drawnOnScreenDisplay = TRUE;
230 onScreenDisplayVolume = v; 229 onScreenDisplayVolume = v;
231 QPainter p( audioUI() ); 230 QPainter p( audioUI() );
232 p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); 231 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
233 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); 232 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
234 233
235 QFont f; 234 QFont f;
236 f.setPixelSize( 20 ); 235 f.setPixelSize( 20 );
237 f.setBold( TRUE ); 236 f.setBold( TRUE );
238 p.setFont( f ); 237 p.setFont( f );
239 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); 238 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") );
240 239
241 for ( unsigned int i = 0; i < 10; i++ ) { 240 for ( unsigned int i = 0; i < 10; i++ ) {
242 if ( v > i ) { 241 if ( v > i ) {
243 p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); 242 p.drawRect( ( w - 200 ) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
244 } else { 243 } else {
245 p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); 244 p.drawRect( ( w - 200 ) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
246 } 245 }
247 } 246 }
248 } else { 247 } else {
249 w = videoUI()->width(); 248 w = videoUI()->width();
250 h = videoUI()->height(); 249 h = videoUI()->height();
251 250
252 if ( drawnOnScreenDisplay ) { 251 if ( drawnOnScreenDisplay ) {
253 if ( onScreenDisplayVolume > v ) { 252 if ( onScreenDisplayVolume > v ) {
254 videoUI()->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE ); 253 videoUI()->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, ( onScreenDisplayVolume - v ) * 20 + 9, 30, FALSE );
255 } 254 }
256 } 255 }
257 drawnOnScreenDisplay = TRUE; 256 drawnOnScreenDisplay = TRUE;
258 onScreenDisplayVolume = v; 257 onScreenDisplayVolume = v;
259 QPainter p( videoUI() ); 258 QPainter p( videoUI() );
260 p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); 259 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
261 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); 260 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
262 261
263 QFont f; 262 QFont f;
264 f.setPixelSize( 20 ); 263 f.setPixelSize( 20 );
265 f.setBold( TRUE ); 264 f.setBold( TRUE );
266 p.setFont( f ); 265 p.setFont( f );
267 p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) ); 266 p.drawText( (w - 200) / 2, h - yoff + 20, tr( "Volume" ) );
268 267
269 for ( unsigned int i = 0; i < 10; i++ ) { 268 for ( unsigned int i = 0; i < 10; i++ ) {
270 if ( v > i ) { 269 if ( v > i ) {
271 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); 270 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
272 } else { 271 } else {
273 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); 272 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
274 } 273 }
275 } 274 }
276 } 275 }
277} 276}
278 277
279 278
280void MediaPlayer::blank( bool b ) { 279void MediaPlayer::blank( bool b ) {
281 Opie::Core::ODevice::inst()->setDisplayStatus( b ); 280 Opie::Core::ODevice::inst()->setDisplayStatus( b );
282} 281}
283 282
284void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { 283void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {
285 switch ( e->key() ) { 284 switch ( e->key() ) {
286////////////////////////////// Zaurus keys 285////////////////////////////// Zaurus keys
287 case Key_Home: 286 case Key_Home:
288 break; 287 break;
289 case Key_F9: //activity 288 case Key_F9: //activity
290 break; 289 break;
291 case Key_F10: //contacts 290 case Key_F10: //contacts
292 break; 291 break;
293 case Key_F11: //menu 292 case Key_F11: //menu
294 break; 293 break;
295 case Key_F12: //home 294 case Key_F12: //home
296 odebug << "Blank here" << oendl; 295 odebug << "Blank here" << oendl;
297// mediaPlayerState->toggleBlank(); 296// mediaPlayerState->toggleBlank();
298 break; 297 break;
299 case Key_F13: //mail 298 case Key_F13: //mail
300 odebug << "Blank here" << oendl; 299 odebug << "Blank here" << oendl;
301 // mediaPlayerState->toggleBlank(); 300 // mediaPlayerState->toggleBlank();
302 break; 301 break;
303 } 302 }
304} 303}
305 304
306void MediaPlayer::cleanUp() {// this happens on closing 305void MediaPlayer::cleanUp() {// this happens on closing
307 Config cfg( "OpiePlayer" ); 306 Config cfg( "OpiePlayer" );
308 mediaPlayerState.writeConfig( cfg ); 307 mediaPlayerState.writeConfig( cfg );
309 playList.writeDefaultPlaylist( ); 308 playList.writeDefaultPlaylist( );
310 309
311} 310}
312 311
313void MediaPlayer::recreateAudioAndVideoWidgets() const 312void MediaPlayer::recreateAudioAndVideoWidgets() const
314{ 313{
315 delete m_skinLoader; 314 delete m_skinLoader;
316 315
317 delete m_xineControl; 316 delete m_xineControl;
318 delete m_audioUI; 317 delete m_audioUI;
319 delete m_videoUI; 318 delete m_videoUI;
320 m_audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" ); 319 m_audioUI = new AudioWidget( playList, mediaPlayerState, 0, "audioUI" );
321 m_videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" ); 320 m_videoUI = new VideoWidget( playList, mediaPlayerState, 0, "videoUI" );
322 321
323 connect( m_audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 322 connect( m_audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
324 connect( m_audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 323 connect( m_audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
325 connect( m_audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 324 connect( m_audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
326 connect( m_audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 325 connect( m_audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
327 326
328 connect( m_videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 327 connect( m_videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
329 connect( m_videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 328 connect( m_videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
330 connect( m_videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 329 connect( m_videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
331 connect( m_videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 330 connect( m_videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
332 331
333 if ( !xine ) 332 if ( !xine )
334 xine = new XINE::Lib( XINE::Lib::InitializeImmediately ); 333 xine = new XINE::Lib( XINE::Lib::InitializeImmediately );
335 334
336 m_xineControl = new XineControl( xine, m_videoUI->vidWidget(), mediaPlayerState ); 335 m_xineControl = new XineControl( xine, m_videoUI->vidWidget(), mediaPlayerState );
337 336
338 xine = 0; 337 xine = 0;
339} 338}
340 339
341AudioWidget *MediaPlayer::audioUI() const 340AudioWidget *MediaPlayer::audioUI() const
342{ 341{
343 if ( !m_audioUI ) 342 if ( !m_audioUI )
344 recreateAudioAndVideoWidgets(); 343 recreateAudioAndVideoWidgets();
345 return m_audioUI; 344 return m_audioUI;
346} 345}
347 346
348VideoWidget *MediaPlayer::videoUI() const 347VideoWidget *MediaPlayer::videoUI() const
349{ 348{
350 if ( !m_videoUI ) 349 if ( !m_videoUI )
351 recreateAudioAndVideoWidgets(); 350 recreateAudioAndVideoWidgets();
352 return m_videoUI; 351 return m_videoUI;
353} 352}
354 353
355XineControl *MediaPlayer::xineControl() const 354XineControl *MediaPlayer::xineControl() const
356{ 355{
357 if ( !m_xineControl ) 356 if ( !m_xineControl )
358 recreateAudioAndVideoWidgets(); 357 recreateAudioAndVideoWidgets();
359 return m_xineControl; 358 return m_xineControl;
360} 359}
361 360
362void MediaPlayer::reloadSkins() 361void MediaPlayer::reloadSkins()
363{ 362{
364 audioUI()->loadSkin(); 363 audioUI()->loadSkin();
365 videoUI()->loadSkin(); 364 videoUI()->loadSkin();
366} 365}
367 366
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 37b998f..dc2c496 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -1,1050 +1,1066 @@
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,2003 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002,2003 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..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; 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  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = 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#include "playlistselection.h" 34#include "playlistselection.h"
35#include "playlistwidget.h" 35#include "playlistwidget.h"
36#include "mediaplayer.h" 36#include "mediaplayer.h"
37#include "inputDialog.h" 37#include "inputDialog.h"
38#include "om3u.h" 38#include "om3u.h"
39#include "playlistfileview.h" 39#include "playlistfileview.h"
40 40
41/* OPIE */ 41/* OPIE */
42#include <opie2/odebug.h> 42#include <opie2/odebug.h>
43#include <opie2/ofiledialog.h> 43#include <opie2/ofiledialog.h>
44using namespace Opie::Core; 44using namespace Opie::Core;
45using namespace Opie::Ui; 45using namespace Opie::Ui;
46 46
47/* QT */ 47/* QT */
48#include <qmessagebox.h> 48#include <qmessagebox.h>
49#include <qtoolbar.h> 49#include <qtoolbar.h>
50 50
51/* STD */ 51/* STD */
52#include <assert.h> 52#include <assert.h>
53 53
54PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl ) 54PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl )
55 : PlayListWidgetGui( parent, "playList" ) , currentFileListView( 0 ) 55 : PlayListWidgetGui( parent, "playList" ) , currentFileListView( 0 )
56{ 56{
57 Global::statusMessage( tr( "Loading of Skin started" ) ); 57 Global::statusMessage( tr( "Loading of Skin started" ) );
58 mediaPlayerState = new MediaPlayerState(0, "mediaPlayerState" ); 58 mediaPlayerState = new MediaPlayerState(0, "mediaPlayerState" );
59 m_mp = new MediaPlayer(*this, *mediaPlayerState, 0, "mediaPlayer"); 59 m_mp = new MediaPlayer(*this, *mediaPlayerState, 0, "mediaPlayer");
60 60
61 61
62 62
63 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), 63 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ),
64 "opieplayer2/add_to_playlist", 64 "opieplayer2/add_to_playlist",
65 this , SLOT(addSelected() ) ); 65 this , SLOT(addSelected() ) );
66 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), 66 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ),
67 "opieplayer2/remove_from_playlist", 67 "opieplayer2/remove_from_playlist",
68 this , SLOT(removeSelected() ) ); 68 this , SLOT(removeSelected() ) );
69 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", 69 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play",
70 this , SLOT( btnPlay(bool) ), TRUE ); 70 this , SLOT( btnPlay(bool) ), TRUE );
71 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", 71 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle",
72 mediaPlayerState, SLOT( setShuffled(bool) ), TRUE ); 72 mediaPlayerState, SLOT( setShuffled(bool) ), TRUE );
73 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", 73 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop",
74 mediaPlayerState, SLOT( setLooping(bool) ), TRUE ); 74 mediaPlayerState, SLOT( setLooping(bool) ), TRUE );
75 75
76 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 76 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
77 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), 77 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ),
78 this, SLOT( addAllMusicToList() ) ); 78 this, SLOT( addAllMusicToList() ) );
79 (void)new MenuItem( pmPlayList, tr( "Add all video files" ), 79 (void)new MenuItem( pmPlayList, tr( "Add all video files" ),
80 this, SLOT( addAllVideoToList() ) ); 80 this, SLOT( addAllVideoToList() ) );
81 (void)new MenuItem( pmPlayList, tr( "Add all files" ), 81 (void)new MenuItem( pmPlayList, tr( "Add all files" ),
82 this, SLOT( addAllToList() ) ); 82 this, SLOT( addAllToList() ) );
83 pmPlayList->insertSeparator(-1); 83 pmPlayList->insertSeparator(-1);
84 (void)new MenuItem( pmPlayList, tr( "Add File" ), 84 (void)new MenuItem( pmPlayList, tr( "Add File" ),
85 this,SLOT( openFile() ) ); 85 this,SLOT( openFile() ) );
86 (void)new MenuItem( pmPlayList, tr("Add URL"), 86 (void)new MenuItem( pmPlayList, tr("Add URL"),
87 this,SLOT( openURL() ) ); 87 this,SLOT( openURL() ) );
88 (void)new MenuItem( pmPlayList, tr( "Add Directory"),
89 this, SLOT(openDirectory()));
88 pmPlayList->insertSeparator(-1); 90 pmPlayList->insertSeparator(-1);
89 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), 91 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ),
90 this, SLOT(writem3u() ) ); 92 this, SLOT(writem3u() ) );
91 pmPlayList->insertSeparator(-1); 93 pmPlayList->insertSeparator(-1);
92 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), 94 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ),
93 audioView, SLOT( scanFiles() ) ); 95 audioView, SLOT( scanFiles() ) );
94 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), 96 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ),
95 videoView, SLOT( scanFiles() ) ); 97 videoView, SLOT( scanFiles() ) );
96 98
97 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), 99 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"),
98 mediaPlayerState, SLOT( toggleFullscreen() ) ); 100 mediaPlayerState, SLOT( toggleFullscreen() ) );
99 101
100 Config cfg( "OpiePlayer" ); 102 Config cfg( "OpiePlayer" );
101 bool b= cfg.readBoolEntry("FullScreen", 0); 103 bool b= cfg.readBoolEntry("FullScreen", 0);
102 mediaPlayerState->setFullscreen( b ); 104 mediaPlayerState->setFullscreen( b );
103 pmView->setItemChecked( -16, b ); 105 pmView->setItemChecked( -16, b );
104 106
105 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", 107 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up",
106 d->selectedFiles, SLOT(moveSelectedUp() ) ); 108 d->selectedFiles, SLOT(moveSelectedUp() ) );
107 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", 109 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut",
108 d->selectedFiles, SLOT(removeSelected() ) ); 110 d->selectedFiles, SLOT(removeSelected() ) );
109 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", 111 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down",
110 d->selectedFiles, SLOT(moveSelectedDown() ) ); 112 d->selectedFiles, SLOT(moveSelectedDown() ) );
111 QVBox *stretch2 = new QVBox( vbox1 ); 113 QVBox *stretch2 = new QVBox( vbox1 );
112 114
113 connect( tbDeletePlaylist, ( SIGNAL( released() ) ), 115 connect( tbDeletePlaylist, ( SIGNAL( released() ) ),
114 SLOT( deletePlaylist() ) ); 116 SLOT( deletePlaylist() ) );
115 connect( pmView, SIGNAL( activated(int) ), 117 connect( pmView, SIGNAL( activated(int) ),
116 this, SLOT( pmViewActivated(int) ) ); 118 this, SLOT( pmViewActivated(int) ) );
117 connect( skinsMenu, SIGNAL( activated(int) ) , 119 connect( skinsMenu, SIGNAL( activated(int) ) ,
118 this, SLOT( skinsMenuActivated(int) ) ); 120 this, SLOT( skinsMenuActivated(int) ) );
119 connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), 121 connect( d->selectedFiles, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),
120 this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int) ) ); 122 this,SLOT( playlistViewPressed(int,QListViewItem*,const QPoint&,int) ) );
121 connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), 123 connect( audioView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),
122 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) ); 124 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) );
123 connect( audioView, SIGNAL( returnPressed(QListViewItem*) ), 125 connect( audioView, SIGNAL( returnPressed(QListViewItem*) ),
124 this,SLOT( playIt(QListViewItem*) ) ); 126 this,SLOT( playIt(QListViewItem*) ) );
125 connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ), 127 connect( audioView, SIGNAL( doubleClicked(QListViewItem*) ),
126 this, SLOT( addToSelection(QListViewItem*) ) ); 128 this, SLOT( addToSelection(QListViewItem*) ) );
127 connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ), 129 connect( videoView, SIGNAL( mouseButtonPressed(int,QListViewItem*,const QPoint&,int) ),
128 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) ); 130 this,SLOT( viewPressed(int,QListViewItem*,const QPoint&,int) ) );
129 connect( videoView, SIGNAL( returnPressed(QListViewItem*) ), 131 connect( videoView, SIGNAL( returnPressed(QListViewItem*) ),
130 this,SLOT( playIt(QListViewItem*) ) ); 132 this,SLOT( playIt(QListViewItem*) ) );
131 connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ), 133 connect( videoView, SIGNAL( doubleClicked(QListViewItem*) ),
132 this, SLOT( addToSelection(QListViewItem*) ) ); 134 this, SLOT( addToSelection(QListViewItem*) ) );
133 connect( playLists, SIGNAL( fileSelected(const DocLnk&) ), 135 connect( playLists, SIGNAL( fileSelected(const DocLnk&) ),
134 this, SLOT( loadList(const DocLnk&) ) ); 136 this, SLOT( loadList(const DocLnk&) ) );
135 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), 137 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ),
136 this, SLOT( tabChanged(QWidget*) ) ); 138 this, SLOT( tabChanged(QWidget*) ) );
137 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), 139 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ),
138 d->tbPlay, SLOT( setOn(bool) ) ); 140 d->tbPlay, SLOT( setOn(bool) ) );
139 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), 141 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ),
140 d->tbLoop, SLOT( setOn(bool) ) ); 142 d->tbLoop, SLOT( setOn(bool) ) );
141 connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ), 143 connect( mediaPlayerState, SIGNAL( shuffledToggled(bool) ),
142 d->tbShuffle, SLOT( setOn(bool) ) ); 144 d->tbShuffle, SLOT( setOn(bool) ) );
143 connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ), 145 connect( d->selectedFiles, SIGNAL( doubleClicked(QListViewItem*) ),
144 this, SLOT( playIt(QListViewItem*) ) ); 146 this, SLOT( playIt(QListViewItem*) ) );
145 connect ( gammaSlider, SIGNAL( valueChanged(int) ), 147 connect ( gammaSlider, SIGNAL( valueChanged(int) ),
146 mediaPlayerState, SLOT( setVideoGamma(int) ) ); 148 mediaPlayerState, SLOT( setVideoGamma(int) ) );
147 149
148 connect( this, SIGNAL(skinSelected() ), 150 connect( this, SIGNAL(skinSelected() ),
149 m_mp, SLOT( reloadSkins() ) ); 151 m_mp, SLOT( reloadSkins() ) );
150 152
151 // see which skins are installed 153 // see which skins are installed
152 populateSkinsMenu(); 154 populateSkinsMenu();
153 initializeStates(); 155 initializeStates();
154 156
155 channel = new QCopChannel( "QPE/Application/opieplayer2", this ); 157 channel = new QCopChannel( "QPE/Application/opieplayer2", this );
156 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), 158 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
157 this, SLOT( qcopReceive(const QCString&,const QByteArray&)) ); 159 this, SLOT( qcopReceive(const QCString&,const QByteArray&)) );
158 160
159 161
160 cfg.setGroup("PlayList"); 162 cfg.setGroup("PlayList");
161 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); 163 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
162 loadList(DocLnk( currentPlaylist ) ); 164 loadList(DocLnk( currentPlaylist ) );
163 165
164 tabWidget->showPage( playListTab ); 166 tabWidget->showPage( playListTab );
165} 167}
166 168
167 169
168PlayListWidget::~PlayListWidget() { 170PlayListWidget::~PlayListWidget() {
169 delete d; 171 delete d;
170 delete m_mp; 172 delete m_mp;
171} 173}
172 174
173 175
174void PlayListWidget::initializeStates() { 176void PlayListWidget::initializeStates() {
175 d->tbPlay->setOn( mediaPlayerState->isPlaying() ); 177 d->tbPlay->setOn( mediaPlayerState->isPlaying() );
176 d->tbLoop->setOn( mediaPlayerState->isLooping() ); 178 d->tbLoop->setOn( mediaPlayerState->isLooping() );
177 d->tbShuffle->setOn( mediaPlayerState->isShuffled() ); 179 d->tbShuffle->setOn( mediaPlayerState->isShuffled() );
178 d->playListFrame->show(); 180 d->playListFrame->show();
179} 181}
180 182
181void PlayListWidget::writeDefaultPlaylist() { 183void PlayListWidget::writeDefaultPlaylist() {
182 184
183 Config config( "OpiePlayer" ); 185 Config config( "OpiePlayer" );
184 config.setGroup( "PlayList" ); 186 config.setGroup( "PlayList" );
185 QString filename=QPEApplication::documentDir() + "/default.m3u"; 187 QString filename=QPEApplication::documentDir() + "/default.m3u";
186 QString currentString = config.readEntry( "CurrentPlaylist", filename); 188 QString currentString = config.readEntry( "CurrentPlaylist", filename);
187 if( currentString == filename) { 189 if( currentString == filename) {
188 Om3u *m3uList; 190 Om3u *m3uList;
189 if( d->selectedFiles->first() ) { 191 if( d->selectedFiles->first() ) {
190 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); 192 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate);
191 do { 193 do {
192 m3uList->add( d->selectedFiles->current()->file() ); 194 m3uList->add( d->selectedFiles->current()->file() );
193 } 195 }
194 while ( d->selectedFiles->next() ); 196 while ( d->selectedFiles->next() );
195 197
196 m3uList->write(); 198 m3uList->write();
197 m3uList->close(); 199 m3uList->close();
198 delete m3uList; 200 delete m3uList;
199 201
200 } 202 }
201 } 203 }
202} 204}
203 205
204void PlayListWidget::addToSelection( const DocLnk& lnk ) { 206void PlayListWidget::addToSelection( const DocLnk& lnk ) {
205 d->setDocumentUsed = FALSE; 207 d->setDocumentUsed = FALSE;
206 if( QFileInfo( lnk.file() ).exists() || 208 if( QFileInfo( lnk.file() ).exists() ||
207 lnk.file().left(4) == "http" ) { 209 lnk.file().left(4) == "http" ) {
208 d->selectedFiles->addToSelection( lnk ); 210 d->selectedFiles->addToSelection( lnk );
209 } 211 }
210} 212}
211 213
212 214
213void PlayListWidget::clearList() { 215void PlayListWidget::clearList() {
214 while ( first() ) { 216 while ( first() ) {
215 d->selectedFiles->removeSelected(); 217 d->selectedFiles->removeSelected();
216 } 218 }
217 Config cfg( "OpiePlayer" ); 219 Config cfg( "OpiePlayer" );
218 cfg.setGroup("PlayList"); 220 cfg.setGroup("PlayList");
219 cfg.writeEntry("CurrentPlaylist","default"); 221 cfg.writeEntry("CurrentPlaylist","default");
220 setCaption("OpiePlayer"); 222 setCaption("OpiePlayer");
221} 223}
222 224
223void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { 225void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
224 switch (mouse) { 226 switch (mouse) {
225 case LeftButton: 227 case LeftButton:
226 break; 228 break;
227 case RightButton: 229 case RightButton:
228 { 230 {
229 QPopupMenu m; 231 QPopupMenu m;
230 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 232 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
231 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 233 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
232 m.exec( QCursor::pos() ); 234 m.exec( QCursor::pos() );
233 } 235 }
234 break; 236 break;
235 } 237 }
236} 238}
237 239
238 240
239void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { 241void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) {
240 switch (mouse) { 242 switch (mouse) {
241 case LeftButton: 243 case LeftButton:
242 break; 244 break;
243 case RightButton: 245 case RightButton:
244 { 246 {
245 QPopupMenu m; 247 QPopupMenu m;
246 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 248 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
247 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 249 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
248 m.exec( QCursor::pos() ); 250 m.exec( QCursor::pos() );
249 } 251 }
250 break; 252 break;
251 } 253 }
252} 254}
253 255
254 256
255void PlayListWidget::addAllToList() { 257void PlayListWidget::addAllToList() {
256 258
257 259
258 audioView->populateView(); 260 audioView->populateView();
259 261
260 QListViewItemIterator audioIt( audioView ); 262 QListViewItemIterator audioIt( audioView );
261 DocLnk lnk; 263 DocLnk lnk;
262 QString filename; 264 QString filename;
263 // iterate through all items of the listview 265 // iterate through all items of the listview
264 for ( ; audioIt.current(); ++audioIt ) { 266 for ( ; audioIt.current(); ++audioIt ) {
265 filename = audioIt.current()->text(3); 267 filename = audioIt.current()->text(3);
266 lnk.setName( QFileInfo(filename).baseName() ); //sets name 268 lnk.setName( QFileInfo(filename).baseName() ); //sets name
267 lnk.setFile( filename ); //sets file name 269 lnk.setFile( filename ); //sets file name
268 d->selectedFiles->addToSelection( lnk); 270 d->selectedFiles->addToSelection( lnk);
269 } 271 }
270 272
271 videoView->populateView(); 273 videoView->populateView();
272 274
273 QListViewItemIterator videoIt( videoView ); 275 QListViewItemIterator videoIt( videoView );
274 for ( ; videoIt.current(); ++videoIt ) { 276 for ( ; videoIt.current(); ++videoIt ) {
275 filename = videoIt.current()->text(3); 277 filename = videoIt.current()->text(3);
276 lnk.setName( QFileInfo(filename).baseName() ); //sets name 278 lnk.setName( QFileInfo(filename).baseName() ); //sets name
277 lnk.setFile( filename ); //sets file name 279 lnk.setFile( filename ); //sets file name
278 d->selectedFiles->addToSelection( lnk); 280 d->selectedFiles->addToSelection( lnk);
279 } 281 }
280 282
281 tabWidget->setCurrentPage(0); 283 tabWidget->setCurrentPage(0);
282 284
283 writeCurrentM3u(); 285 writeCurrentM3u();
284 d->selectedFiles->first(); 286 d->selectedFiles->first();
285} 287}
286 288
287 289
288void PlayListWidget::addAllMusicToList() { 290void PlayListWidget::addAllMusicToList() {
289 291
290 audioView->populateView(); 292 audioView->populateView();
291 293
292 QListViewItemIterator audioIt( audioView ); 294 QListViewItemIterator audioIt( audioView );
293 DocLnk lnk; 295 DocLnk lnk;
294 QString filename; 296 QString filename;
295 // iterate through all items of the listview 297 // iterate through all items of the listview
296 for ( ; audioIt.current(); ++audioIt ) { 298 for ( ; audioIt.current(); ++audioIt ) {
297 filename = audioIt.current()->text(3); 299 filename = audioIt.current()->text(3);
298 lnk.setName( QFileInfo(filename).baseName() ); //sets name 300 lnk.setName( QFileInfo(filename).baseName() ); //sets name
299 lnk.setFile( filename ); //sets file name 301 lnk.setFile( filename ); //sets file name
300 d->selectedFiles->addToSelection( lnk); 302 d->selectedFiles->addToSelection( lnk);
301 } 303 }
302 304
303 tabWidget->setCurrentPage(0); 305 tabWidget->setCurrentPage(0);
304 writeCurrentM3u(); 306 writeCurrentM3u();
305 d->selectedFiles->first(); 307 d->selectedFiles->first();
306} 308}
307 309
308 310
309void PlayListWidget::addAllVideoToList() { 311void PlayListWidget::addAllVideoToList() {
310 312
311 videoView->populateView(); 313 videoView->populateView();
312 314
313 QListViewItemIterator videoIt( videoView ); 315 QListViewItemIterator videoIt( videoView );
314 DocLnk lnk; 316 DocLnk lnk;
315 QString filename; 317 QString filename;
316 for ( ; videoIt.current(); ++videoIt ) { 318 for ( ; videoIt.current(); ++videoIt ) {
317 filename = videoIt.current()->text(3); 319 filename = videoIt.current()->text(3);
318 lnk.setName( QFileInfo(filename).baseName() ); //sets name 320 lnk.setName( QFileInfo(filename).baseName() ); //sets name
319 lnk.setFile( filename ); //sets file name 321 lnk.setFile( filename ); //sets file name
320 d->selectedFiles->addToSelection( lnk); 322 d->selectedFiles->addToSelection( lnk);
321 } 323 }
322 tabWidget->setCurrentPage(0); 324 tabWidget->setCurrentPage(0);
323 writeCurrentM3u(); 325 writeCurrentM3u();
324 d->selectedFiles->first(); 326 d->selectedFiles->first();
325} 327}
326 328
327 329
328void PlayListWidget::setDocument( const QString& _fileref ) { 330void PlayListWidget::setDocument( const QString& _fileref ) {
329 // odebug << "<<<<<<<<set document>>>>>>>>>> "+fileref << oendl; 331 // odebug << "<<<<<<<<set document>>>>>>>>>> "+fileref << oendl;
330 QString fileref = _fileref; 332 QString fileref = _fileref;
331 fromSetDocument = TRUE; 333 fromSetDocument = TRUE;
332 334
333 DocLnk lnk(_fileref); 335 DocLnk lnk(_fileref);
334 if(lnk.isValid()) 336 if(lnk.isValid())
335 fileref = lnk.file(); 337 fileref = lnk.file();
336 338
337 QFileInfo fileInfo(fileref); 339 QFileInfo fileInfo(fileref);
338 340
339 if ( !fileInfo.exists() ) { 341 if ( !fileInfo.exists() ) {
340 QMessageBox::warning( this, tr( "Invalid File" ), 342 QMessageBox::warning( this, tr( "Invalid File" ),
341 tr( "There was a problem in getting the file." ) ); 343 tr( "There was a problem in getting the file." ) );
342 return; 344 return;
343 } 345 }
344 346
345 clearList(); 347 clearList();
346 QString extension = fileInfo.extension(false); 348 QString extension = fileInfo.extension(false);
347 349
348 if( extension.find( "m3u", 0, false) != -1 350 if( extension.find( "m3u", 0, false) != -1
349 || extension.find( "pls", 0, false) != -1 ) { 351 || extension.find( "pls", 0, false) != -1 ) {
350 readListFromFile( fileref ); 352 readListFromFile( fileref );
351 } else { 353 } else {
352 clearList(); 354 clearList();
353 DocLnk lnk; 355 DocLnk lnk;
354 lnk.setName( fileInfo.baseName() ); //sets name 356 lnk.setName( fileInfo.baseName() ); //sets name
355 lnk.setFile( fileref ); //sets file name 357 lnk.setFile( fileref ); //sets file name
356 addToSelection( lnk ); 358 addToSelection( lnk );
357 writeCurrentM3u(); 359 writeCurrentM3u();
358 360
359 d->setDocumentUsed = TRUE; 361 d->setDocumentUsed = TRUE;
360 mediaPlayerState->setPlaying( FALSE ); 362 mediaPlayerState->setPlaying( FALSE );
361 mediaPlayerState->setPlaying( TRUE ); 363 mediaPlayerState->setPlaying( TRUE );
362 } 364 }
363} 365}
364 366
365 367
366void PlayListWidget::useSelectedDocument() { 368void PlayListWidget::useSelectedDocument() {
367 d->setDocumentUsed = FALSE; 369 d->setDocumentUsed = FALSE;
368} 370}
369 371
370 372
371const DocLnk *PlayListWidget::current() const { // this is fugly 373const DocLnk *PlayListWidget::current() const { // this is fugly
372 assert( currentTab() == CurrentPlayList ); 374 assert( currentTab() == CurrentPlayList );
373 375
374 const DocLnk *lnk = d->selectedFiles->current(); 376 const DocLnk *lnk = d->selectedFiles->current();
375 if ( !lnk ) { 377 if ( !lnk ) {
376 d->selectedFiles->first(); 378 d->selectedFiles->first();
377 lnk = d->selectedFiles->current(); 379 lnk = d->selectedFiles->current();
378 } 380 }
379 assert( lnk ); 381 assert( lnk );
380 return lnk; 382 return lnk;
381} 383}
382 384
383 385
384bool PlayListWidget::prev() { 386bool PlayListWidget::prev() {
385 if ( mediaPlayerState->isShuffled() ) { 387 if ( mediaPlayerState->isShuffled() ) {
386 const DocLnk *cur = current(); 388 const DocLnk *cur = current();
387 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 389 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
388 for ( int i = 0; i < j; i++ ) { 390 for ( int i = 0; i < j; i++ ) {
389 if ( !d->selectedFiles->next() ) 391 if ( !d->selectedFiles->next() )
390 d->selectedFiles->first(); 392 d->selectedFiles->first();
391 } 393 }
392 if ( cur == current() ) 394 if ( cur == current() )
393 if ( !d->selectedFiles->next() ) { 395 if ( !d->selectedFiles->next() ) {
394 d->selectedFiles->first(); 396 d->selectedFiles->first();
395 } 397 }
396 return TRUE; 398 return TRUE;
397 } else { 399 } else {
398 if ( !d->selectedFiles->prev() ) { 400 if ( !d->selectedFiles->prev() ) {
399 if ( mediaPlayerState->isLooping() ) { 401 if ( mediaPlayerState->isLooping() ) {
400 return d->selectedFiles->last(); 402 return d->selectedFiles->last();
401 } else { 403 } else {
402 return FALSE; 404 return FALSE;
403 } 405 }
404 } 406 }
405 return TRUE; 407 return TRUE;
406 } 408 }
407} 409}
408 410
409 411
410bool PlayListWidget::next() { 412bool PlayListWidget::next() {
411//odebug << "<<<<<<<<<<<<next()" << oendl; 413//odebug << "<<<<<<<<<<<<next()" << oendl;
412 if ( mediaPlayerState->isShuffled() ) { 414 if ( mediaPlayerState->isShuffled() ) {
413 return prev(); 415 return prev();
414 } else { 416 } else {
415 if ( !d->selectedFiles->next() ) { 417 if ( !d->selectedFiles->next() ) {
416 if ( mediaPlayerState->isLooping() ) { 418 if ( mediaPlayerState->isLooping() ) {
417 return d->selectedFiles->first(); 419 return d->selectedFiles->first();
418 } else { 420 } else {
419 return FALSE; 421 return FALSE;
420 } 422 }
421 } 423 }
422 return TRUE; 424 return TRUE;
423 } 425 }
424} 426}
425 427
426 428
427bool PlayListWidget::first() { 429bool PlayListWidget::first() {
428 return d->selectedFiles->first(); 430 return d->selectedFiles->first();
429} 431}
430 432
431 433
432bool PlayListWidget::last() { 434bool PlayListWidget::last() {
433 return d->selectedFiles->last(); 435 return d->selectedFiles->last();
434} 436}
435 437
436 438
437 void PlayListWidget::saveList() { 439 void PlayListWidget::saveList() {
438 writem3u(); 440 writem3u();
439 } 441 }
440 442
441 443
442void PlayListWidget::loadList( const DocLnk & lnk) { 444void PlayListWidget::loadList( const DocLnk & lnk) {
443 QString name = lnk.name(); 445 QString name = lnk.name();
444 446
445 if( name.length()>0) { 447 if( name.length()>0) {
446 setCaption("OpiePlayer: "+name); 448 setCaption("OpiePlayer: "+name);
447 clearList(); 449 clearList();
448 readListFromFile(lnk.file()); 450 readListFromFile(lnk.file());
449 tabWidget->setCurrentPage(0); 451 tabWidget->setCurrentPage(0);
450 } 452 }
451} 453}
452 454
453void PlayListWidget::addSelected() { 455void PlayListWidget::addSelected() {
454 assert( inFileListMode() ); 456 assert( inFileListMode() );
455 457
456 QListViewItemIterator it( currentFileListView ); 458 QListViewItemIterator it( currentFileListView );
457 for ( ; it.current(); ++it ) 459 for ( ; it.current(); ++it )
458 if ( it.current()->isSelected() ) { 460 if ( it.current()->isSelected() ) {
459 QString filename = it.current()->text(3); 461 QString filename = it.current()->text(3);
460 462
461 DocLnk lnk; 463 DocLnk lnk;
462 lnk.setName( QFileInfo( filename ).baseName() ); //sets name 464 lnk.setName( QFileInfo( filename ).baseName() ); //sets name
463 lnk.setFile( filename ); //sets file name 465 lnk.setFile( filename ); //sets file name
464 466
465 d->selectedFiles->addToSelection( lnk ); 467 d->selectedFiles->addToSelection( lnk );
466 } 468 }
467 469
468 currentFileListView->clearSelection(); 470 currentFileListView->clearSelection();
469 471
470 writeCurrentM3u(); 472 writeCurrentM3u();
471} 473}
472 474
473 475
474void PlayListWidget::removeSelected() { 476void PlayListWidget::removeSelected() {
475 d->selectedFiles->removeSelected( ); 477 d->selectedFiles->removeSelected( );
476 writeCurrentM3u(); 478 writeCurrentM3u();
477} 479}
478 480
479 481
480void PlayListWidget::playIt( QListViewItem *it) { 482void PlayListWidget::playIt( QListViewItem *it) {
481 if(!it) return; 483 if(!it) return;
482 mediaPlayerState->setPlaying(FALSE); 484 mediaPlayerState->setPlaying(FALSE);
483 mediaPlayerState->setPlaying(TRUE); 485 mediaPlayerState->setPlaying(TRUE);
484 d->selectedFiles->unSelect(); 486 d->selectedFiles->unSelect();
485} 487}
486 488
487 489
488void PlayListWidget::addToSelection( QListViewItem *it) { 490void PlayListWidget::addToSelection( QListViewItem *it) {
489 d->setDocumentUsed = FALSE; 491 d->setDocumentUsed = FALSE;
490 492
491 if(it) { 493 if(it) {
492 if ( currentTab() == CurrentPlayList ) 494 if ( currentTab() == CurrentPlayList )
493 return; 495 return;
494 DocLnk lnk; 496 DocLnk lnk;
495 QString filename; 497 QString filename;
496 498
497 filename=it->text(3); 499 filename=it->text(3);
498 lnk.setName( QFileInfo(filename).baseName() ); //sets name 500 lnk.setName( QFileInfo(filename).baseName() ); //sets name
499 lnk.setFile( filename ); //sets file name 501 lnk.setFile( filename ); //sets file name
500 d->selectedFiles->addToSelection( lnk); 502 d->selectedFiles->addToSelection( lnk);
501 503
502 writeCurrentM3u(); 504 writeCurrentM3u();
503// tabWidget->setCurrentPage(0); 505// tabWidget->setCurrentPage(0);
504 506
505 } 507 }
506} 508}
507 509
508 510
509void PlayListWidget::tabChanged(QWidget *) { 511void PlayListWidget::tabChanged(QWidget *) {
510 512
511 d->tbPlay->setEnabled( true ); 513 d->tbPlay->setEnabled( true );
512 514
513 disconnect( audioView, SIGNAL( itemsSelected(bool) ), 515 disconnect( audioView, SIGNAL( itemsSelected(bool) ),
514 d->tbPlay, SLOT( setEnabled(bool) ) ); 516 d->tbPlay, SLOT( setEnabled(bool) ) );
515 disconnect( videoView, SIGNAL( itemsSelected(bool) ), 517 disconnect( videoView, SIGNAL( itemsSelected(bool) ),
516 d->tbPlay, SLOT( setEnabled(bool) ) ); 518 d->tbPlay, SLOT( setEnabled(bool) ) );
517 519
518 currentFileListView = 0; 520 currentFileListView = 0;
519 521
520 switch ( currentTab() ) { 522 switch ( currentTab() ) {
521 case CurrentPlayList: 523 case CurrentPlayList:
522 { 524 {
523 if( !tbDeletePlaylist->isHidden() ) { 525 if( !tbDeletePlaylist->isHidden() ) {
524 tbDeletePlaylist->hide(); 526 tbDeletePlaylist->hide();
525 } 527 }
526 d->tbRemoveFromList->setEnabled(TRUE); 528 d->tbRemoveFromList->setEnabled(TRUE);
527 d->tbAddToList->setEnabled(FALSE); 529 d->tbAddToList->setEnabled(FALSE);
528 530
529 d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); 531 d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() );
530 } 532 }
531 break; 533 break;
532 case AudioFiles: 534 case AudioFiles:
533 { 535 {
534 audioView->populateView(); 536 audioView->populateView();
535 537
536 if( !tbDeletePlaylist->isHidden() ) { 538 if( !tbDeletePlaylist->isHidden() ) {
537 tbDeletePlaylist->hide(); 539 tbDeletePlaylist->hide();
538 } 540 }
539 d->tbRemoveFromList->setEnabled(FALSE); 541 d->tbRemoveFromList->setEnabled(FALSE);
540 d->tbAddToList->setEnabled(TRUE); 542 d->tbAddToList->setEnabled(TRUE);
541 543
542 connect( audioView, SIGNAL( itemsSelected(bool) ), 544 connect( audioView, SIGNAL( itemsSelected(bool) ),
543 d->tbPlay, SLOT( setEnabled(bool) ) ); 545 d->tbPlay, SLOT( setEnabled(bool) ) );
544 546
545 d->tbPlay->setEnabled( audioView->hasSelection() ); 547 d->tbPlay->setEnabled( audioView->hasSelection() );
546 548
547 currentFileListView = audioView; 549 currentFileListView = audioView;
548 } 550 }
549 break; 551 break;
550 case VideoFiles: 552 case VideoFiles:
551 { 553 {
552 videoView->populateView(); 554 videoView->populateView();
553 if( !tbDeletePlaylist->isHidden() ) { 555 if( !tbDeletePlaylist->isHidden() ) {
554 tbDeletePlaylist->hide(); 556 tbDeletePlaylist->hide();
555 } 557 }
556 d->tbRemoveFromList->setEnabled(FALSE); 558 d->tbRemoveFromList->setEnabled(FALSE);
557 d->tbAddToList->setEnabled(TRUE); 559 d->tbAddToList->setEnabled(TRUE);
558 560
559 connect( videoView, SIGNAL( itemsSelected(bool) ), 561 connect( videoView, SIGNAL( itemsSelected(bool) ),
560 d->tbPlay, SLOT( setEnabled(bool) ) ); 562 d->tbPlay, SLOT( setEnabled(bool) ) );
561 563
562 d->tbPlay->setEnabled( videoView->hasSelection() ); 564 d->tbPlay->setEnabled( videoView->hasSelection() );
563 565
564 currentFileListView = videoView; 566 currentFileListView = videoView;
565 } 567 }
566 break; 568 break;
567 case PlayLists: 569 case PlayLists:
568 { 570 {
569 if( tbDeletePlaylist->isHidden() ) { 571 if( tbDeletePlaylist->isHidden() ) {
570 tbDeletePlaylist->show(); 572 tbDeletePlaylist->show();
571 } 573 }
572 playLists->reread(); 574 playLists->reread();
573 d->tbAddToList->setEnabled(FALSE); 575 d->tbAddToList->setEnabled(FALSE);
574 576
575 d->tbPlay->setEnabled( false ); 577 d->tbPlay->setEnabled( false );
576 } 578 }
577 break; 579 break;
578 }; 580 };
579} 581}
580 582
581 583
582void PlayListWidget::btnPlay(bool b) { 584void PlayListWidget::btnPlay(bool b) {
583// mediaPlayerState->setPlaying(false); 585// mediaPlayerState->setPlaying(false);
584 mediaPlayerState->setPlaying(b); 586 mediaPlayerState->setPlaying(b);
585 insanityBool=FALSE; 587 insanityBool=FALSE;
586} 588}
587 589
588void PlayListWidget::deletePlaylist() { 590void PlayListWidget::deletePlaylist() {
589 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 591 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
590 (tr("You really want to delete\nthis playlist?")), 592 (tr("You really want to delete\nthis playlist?")),
591 (tr("Yes")), (tr("No")), 0 )){ 593 (tr("Yes")), (tr("No")), 0 )){
592 case 0: // Yes clicked, 594 case 0: // Yes clicked,
593 QFile().remove(playLists->selectedDocument().file()); 595 QFile().remove(playLists->selectedDocument().file());
594 QFile().remove(playLists->selectedDocument().linkFile()); 596 QFile().remove(playLists->selectedDocument().linkFile());
595 playLists->reread(); 597 playLists->reread();
596 break; 598 break;
597 case 1: // Cancel 599 case 1: // Cancel
598 break; 600 break;
599 }; 601 };
600} 602}
601 603
602 604
603void PlayListWidget::playSelected() { 605void PlayListWidget::playSelected() {
604 btnPlay( TRUE); 606 btnPlay( TRUE);
605} 607}
606 608
607bool PlayListWidget::inFileListMode() const 609bool PlayListWidget::inFileListMode() const
608{ 610{
609 TabType tab = currentTab(); 611 TabType tab = currentTab();
610 return tab == AudioFiles || tab == VideoFiles; 612 return tab == AudioFiles || tab == VideoFiles;
611} 613}
612 614
613void PlayListWidget::openURL() { 615void PlayListWidget::openURL() {
614 // http://66.28.164.33:2080 616 // http://66.28.164.33:2080
615 // http://somafm.com/star0242.m3u 617 // http://somafm.com/star0242.m3u
616 QString filename, name; 618 QString filename, name;
617 InputDialog *fileDlg; 619 InputDialog *fileDlg;
618 fileDlg = new InputDialog(this,tr("Add URL"),TRUE, 0); 620 fileDlg = new InputDialog(this,tr("Add URL"),TRUE, 0);
619 fileDlg->exec(); 621 fileDlg->exec();
620 if( fileDlg->result() == 1 ) { 622 if( fileDlg->result() == 1 ) {
621 filename = fileDlg->text(); 623 filename = fileDlg->text();
622 odebug << "Selected filename is " + filename << oendl; 624 odebug << "Selected filename is " + filename << oendl;
623 // Om3u *m3uList; 625 // Om3u *m3uList;
624 DocLnk lnk; 626 DocLnk lnk;
625 Config cfg( "OpiePlayer" ); 627 Config cfg( "OpiePlayer" );
626 cfg.setGroup("PlayList"); 628 cfg.setGroup("PlayList");
627 629
628 if(filename.left(4) == "http") { 630 if(filename.left(4) == "http") {
629 QString m3uFile, m3uFilePath; 631 QString m3uFile, m3uFilePath;
630 if(filename.find(":",8,TRUE) != -1) { //found a port 632 if(filename.find(":",8,TRUE) != -1) { //found a port
631 m3uFile = filename.left( filename.find( ":",8,TRUE)); 633 m3uFile = filename.left( filename.find( ":",8,TRUE));
632 m3uFile = m3uFile.right( 7); 634 m3uFile = m3uFile.right( 7);
633 } else if(filename.left(4) == "http"){ 635 } else if(filename.left(4) == "http"){
634 m3uFile=filename; 636 m3uFile=filename;
635 m3uFile = m3uFile.right( m3uFile.length() - 7); 637 m3uFile = m3uFile.right( m3uFile.length() - 7);
636 } else{ 638 } else{
637 m3uFile=filename; 639 m3uFile=filename;
638 } 640 }
639 641
640 lnk.setName( filename ); //sets name 642 lnk.setName( filename ); //sets name
641 lnk.setFile( filename ); //sets file name 643 lnk.setFile( filename ); //sets file name
642 644
643// lnk.setIcon("opieplayer2/musicfile"); 645// lnk.setIcon("opieplayer2/musicfile");
644 646
645 d->selectedFiles->addToSelection( lnk ); 647 d->selectedFiles->addToSelection( lnk );
646 writeCurrentM3u(); 648 writeCurrentM3u();
647 d->selectedFiles->setSelectedItem( lnk.name()); 649 d->selectedFiles->setSelectedItem( lnk.name());
648 } 650 }
649 else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { 651 else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) {
650 readListFromFile( filename ); 652 readListFromFile( filename );
651 } else { 653 } else {
652 lnk.setName( QFileInfo(filename).baseName() ); //sets name 654 lnk.setName( QFileInfo(filename).baseName() ); //sets name
653 lnk.setFile( filename ); //sets file name 655 lnk.setFile( filename ); //sets file name
654 d->selectedFiles->addToSelection( lnk); 656 d->selectedFiles->addToSelection( lnk);
655 writeCurrentM3u(); 657 writeCurrentM3u();
656 d->selectedFiles->setSelectedItem( lnk.name()); 658 d->selectedFiles->setSelectedItem( lnk.name());
657 } 659 }
658 } 660 }
659 661
660 662
661 delete fileDlg; 663 delete fileDlg;
662} 664}
663 665
664 666
665void PlayListWidget::openFile() { 667static MimeTypes fileSelectorMimeTypes() {
666
667 QString filename, name;
668
669 Config cfg( "OpiePlayer" );
670 cfg.setGroup("Dialog");
671 MimeTypes types; 668 MimeTypes types;
672 QStringList audio, video, all; 669 QStringList audio, video, all;
673 audio << "audio/*"; 670 audio << "audio/*";
674 audio << "playlist/plain"; 671 audio << "playlist/plain";
675 audio << "audio/x-ogg"; 672 audio << "audio/x-ogg";
676 audio << "audio/x-mpegurl"; 673 audio << "audio/x-mpegurl";
677 674
678 video << "video/*"; 675 video << "video/*";
679 video << "playlist/plain"; 676 video << "playlist/plain";
680 677
681 all += audio; 678 all += audio;
682 all += video; 679 all += video;
683 types.insert("All Media Files", all ); 680 types.insert("All Media Files", all );
684 types.insert("Audio", audio ); 681 types.insert("Audio", audio );
685 types.insert("Video", video ); 682 types.insert("Video", video );
686 683
687 QString str = OFileDialog::getOpenFileName( 1, 684 return types;
688 cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", 685}
689 types, 0 ); 686
687void PlayListWidget::openFile() {
688
689 QString filename, name;
690
691 Config cfg( "OpiePlayer" );
692 cfg.setGroup("Dialog");
693 MimeTypes types = fileSelectorMimeTypes();
694
695
696 QString str = OFileDialog::getOpenFileName( 1, QString::null,
697 QString::null, types, 0,
698 tr("Add File to Playlist") );
699
700 if( str.isEmpty() )
701 return;
702
703 if(str.left(2) == "//") str=str.right(str.length()-1);
704
690 705
691 if(str.left(2) == "//") { 706 if( str.right( 3) == "m3u" || str.right(3) == "pls" ) {
692 str=str.right(str.length()-1); 707 readListFromFile( str );
708 } else {
709 QFileInfo info( str );
710 DocLnk lnk = addFileToPlaylist( str, info.baseName() );
711 d->selectedFiles->setSelectedItem( lnk.name() );
693 } 712 }
694 cfg.writeEntry( "LastDirectory" ,QFileInfo( str ).dirPath() ); 713}
695 714
696 if( !str.isEmpty() ) { 715void PlayListWidget::openDirectory() {
716 QString str = OFileDialog::getDirectory( OFileSelector::DirectorySelector,
717 QString::null, 0,
718 tr( "Add Files from Directory"));
697 719
698 odebug << "Selected filename is " + str << oendl; 720 if(str.isEmpty() )
699 filename = str; 721 return;
700 DocLnk lnk; 722
723 if(str.left(2) == "//") str=str.right(str.length()-1);
724 QDir dir( str );
725 QStringList lst = dir.entryList(QDir::Files|QDir::Readable);
701 726
702 if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { 727 for ( QStringList::Iterator it = lst.begin(); it != lst.end(); ++it ) {
728 QString filename = str + "/" + *it;
729
730 if( filename.right( 3) == "m3u" || filename.right(3) == "pls" )
703 readListFromFile( filename ); 731 readListFromFile( filename );
704 } else { 732 else {
705 lnk.setName( QFileInfo(filename).baseName() ); //sets name 733 addFileToPlaylist( filename, QFileInfo(*it).baseName() );
706 lnk.setFile( filename ); //sets file name
707 d->selectedFiles->addToSelection( lnk );
708 writeCurrentM3u();
709 d->selectedFiles->setSelectedItem( lnk.name() );
710 } 734 }
711 } 735 }
712} 736}
713 737
714
715void PlayListWidget::readListFromFile( const QString &filename ) { 738void PlayListWidget::readListFromFile( const QString &filename ) {
716 odebug << "read list filename " + filename << oendl; 739 odebug << "read list filename " + filename << oendl;
717 QFileInfo fi(filename); 740 QFileInfo fi(filename);
718 Om3u *m3uList; 741 Om3u *m3uList;
719 QString s, name; 742 QString s, name;
720 m3uList = new Om3u( filename, IO_ReadOnly ); 743 m3uList = new Om3u( filename, IO_ReadOnly );
721 if(fi.extension(false).find("m3u",0,false) != -1 ) 744 if(fi.extension(false).find("m3u",0,false) != -1 )
722 m3uList->readM3u(); 745 m3uList->readM3u();
723 else if(fi.extension(false).find("pls",0,false) != -1 ) 746 else if(fi.extension(false).find("pls",0,false) != -1 )
724 m3uList->readPls(); 747 m3uList->readPls();
725 748
726 DocLnk lnk; 749 DocLnk lnk;
727 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 750 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
728 s = *it; 751 s = *it;
729 // odebug << s << oendl; 752 // odebug << s << oendl;
730 if(s.left(4)=="http") { 753 if(s.left(4)=="http") {
731 lnk.setName( s ); //sets file name 754 lnk.setName( s ); //sets file name
732 lnk.setIcon("opieplayer2/musicfile"); 755 lnk.setIcon("opieplayer2/musicfile");
733 lnk.setFile( s ); //sets file name 756 lnk.setFile( s ); //sets file name
734 757
735 } else { //is file 758 } else { //is file
736 lnk.setName( QFileInfo(s).baseName()); 759 lnk.setName( QFileInfo(s).baseName());
737 if(s.left(1) != "/") { 760 if(s.left(1) != "/") {
738 761
739 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); 762 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
740 } else { 763 } else {
741 lnk.setFile( s); 764 lnk.setFile( s);
742 } 765 }
743 } 766 }
744 d->selectedFiles->addToSelection( lnk ); 767 d->selectedFiles->addToSelection( lnk );
745 } 768 }
746 Config config( "OpiePlayer" ); 769 Config config( "OpiePlayer" );
747 config.setGroup( "PlayList" ); 770 config.setGroup( "PlayList" );
748 771
749 config.writeEntry("CurrentPlaylist",filename); 772 config.writeEntry("CurrentPlaylist",filename);
750 config.write(); 773 config.write();
751 currentPlayList=filename; 774 currentPlayList=filename;
752 775
753 m3uList->close(); 776 m3uList->close();
754 delete m3uList; 777 delete m3uList;
755 778
756 d->selectedFiles->setSelectedItem( s); 779 d->selectedFiles->setSelectedItem( s);
757 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); 780 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
758 781
759} 782}
760 783
761// writes current playlist to current m3u file */ 784// writes current playlist to current m3u file */
762 void PlayListWidget::writeCurrentM3u() { 785 void PlayListWidget::writeCurrentM3u() {
763 odebug << "writing to current m3u" << oendl; 786 odebug << "writing to current m3u" << oendl;
764 Config cfg( "OpiePlayer" ); 787 Config cfg( "OpiePlayer" );
765 cfg.setGroup("PlayList"); 788 cfg.setGroup("PlayList");
766 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); 789 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
767 790
768 Om3u *m3uList; 791 Om3u *m3uList;
769 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); 792 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
770 if( d->selectedFiles->first()) { 793 if( d->selectedFiles->first()) {
771 794
772 do { 795 do {
773 // odebug << "add writeCurrentM3u " +d->selectedFiles->current()->file() << oendl; 796 // odebug << "add writeCurrentM3u " +d->selectedFiles->current()->file() << oendl;
774 m3uList->add( d->selectedFiles->current()->file() ); 797 m3uList->add( d->selectedFiles->current()->file() );
775 } 798 }
776 while ( d->selectedFiles->next() ); 799 while ( d->selectedFiles->next() );
777 // odebug << "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" << oendl; 800 // odebug << "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" << oendl;
778 m3uList->write(); 801 m3uList->write();
779 m3uList->close(); 802 m3uList->close();
780 } 803 }
781 delete m3uList; 804 delete m3uList;
782 805
783 } 806 }
784 807
785 /* 808 /*
786 writes current playlist to m3u file */ 809 writes current playlist to m3u file */
787void PlayListWidget::writem3u() { 810void PlayListWidget::writem3u() {
788 //InputDilog *fileDlg;
789 //fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
790 //fileDlg->exec();
791 811
792 Config cfg( "OpiePlayer" ); 812 Config cfg( "OpiePlayer" );
793 cfg.setGroup("Dialog"); 813 cfg.setGroup("Dialog");
794 MimeTypes types; 814 MimeTypes types = fileSelectorMimeTypes();
795 QStringList audio, video, all;
796 audio << "audio/*";
797 audio << "playlist/plain";
798 audio << "audio/x-mpegurl";
799 815
800 video << "video/*"; 816 QString str = OFileDialog::getOpenFileName( 1, QString::null,
801 video << "playlist/plain"; 817 QString::null, types, 0,
818 tr( "Save Playlist" ));
802 819
803 all += audio;
804 all += video;
805 types.insert("All Media Files", all );
806 types.insert("Audio", audio );
807 types.insert("Video", video );
808
809 QString str = OFileDialog::getOpenFileName( 1,
810 cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"",
811 types, 0 );
812 if(str.left(2) == "//") str=str.right(str.length()-1); 820 if(str.left(2) == "//") str=str.right(str.length()-1);
813 cfg.writeEntry("LastDirectory" ,QFileInfo(str).dirPath());
814
815 821
816 QString name, filename, list; 822 QString name, filename, list;
817 Om3u *m3uList; 823 Om3u *m3uList;
818 824
819 if( !str.isEmpty() ) { 825 if( !str.isEmpty() ) {
820 name = str; 826 name = str;
821 // name = fileDlg->text(); 827 // name = fileDlg->text();
822// odebug << filename << oendl; 828// odebug << filename << oendl;
823 if( name.find("/",0,true) != -1) {// assume they specify a file path 829 if( name.find("/",0,true) != -1) {// assume they specify a file path
824 filename = name; 830 filename = name;
825 name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); 831 name = name.right(name.length()- name.findRev("/",-1,true) - 1 );
826 } 832 }
827 else //otherwise dump it somewhere noticable 833 else //otherwise dump it somewhere noticable
828 filename = QPEApplication::documentDir() + "/" + name; 834 filename = QPEApplication::documentDir() + "/" + name;
829 835
830 if( filename.right( 3 ) != "m3u" ) //needs filename extension 836 if( filename.right( 3 ) != "m3u" ) //needs filename extension
831 filename += ".m3u"; 837 filename += ".m3u";
832 838
833 if( d->selectedFiles->first()) { //ramble through playlist view 839 if( d->selectedFiles->first()) { //ramble through playlist view
834 m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate); 840 m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate);
835 841
836 do { 842 do {
837 m3uList->add( d->selectedFiles->current()->file()); 843 m3uList->add( d->selectedFiles->current()->file());
838 } 844 }
839 while ( d->selectedFiles->next() ); 845 while ( d->selectedFiles->next() );
840 // odebug << list << oendl; 846 // odebug << list << oendl;
841 m3uList->write(); 847 m3uList->write();
842 m3uList->close(); 848 m3uList->close();
843 delete m3uList; 849 delete m3uList;
844 850
845 //delete fileDlg; 851 //delete fileDlg;
846 852
847 DocLnk lnk; 853 DocLnk lnk;
848 lnk.setFile( filename); 854 lnk.setFile( filename);
849 lnk.setIcon("opieplayer2/playlist2"); 855 lnk.setIcon("opieplayer2/playlist2");
850 lnk.setName( name); //sets file name 856 lnk.setName( name); //sets file name
851 857
852 // odebug << filename << oendl; 858 // odebug << filename << oendl;
853 Config config( "OpiePlayer" ); 859 Config config( "OpiePlayer" );
854 config.setGroup( "PlayList" ); 860 config.setGroup( "PlayList" );
855 861
856 config.writeEntry("CurrentPlaylist",filename); 862 config.writeEntry("CurrentPlaylist",filename);
857 currentPlayList=filename; 863 currentPlayList=filename;
858 864
859 if(!lnk.writeLink()) { 865 if(!lnk.writeLink()) {
860 odebug << "Writing doclink did not work" << oendl; 866 odebug << "Writing doclink did not work" << oendl;
861 } 867 }
862 868
863 setCaption(tr("OpiePlayer: ") + name); 869 setCaption(tr("OpiePlayer: ") + name);
864 } 870 }
865 } 871 }
866} 872}
867 873
868void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { 874void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
869 switch ( e->key() ) { 875 switch ( e->key() ) {
870 ////////////////////////////// Zaurus keys 876 ////////////////////////////// Zaurus keys
871 case Key_F9: //activity 877 case Key_F9: //activity
872 // if(audioUI->isHidden()) 878 // if(audioUI->isHidden())
873 // audioUI->showMaximized(); 879 // audioUI->showMaximized();
874 break; 880 break;
875 case Key_F10: //contacts 881 case Key_F10: //contacts
876 // if( videoUI->isHidden()) 882 // if( videoUI->isHidden())
877 // videoUI->showMaximized(); 883 // videoUI->showMaximized();
878 break; 884 break;
879 case Key_F11: //menu 885 case Key_F11: //menu
880 break; 886 break;
881 case Key_F12: //home 887 case Key_F12: //home
882 // doBlank(); 888 // doBlank();
883 break; 889 break;
884 case Key_F13: //mail 890 case Key_F13: //mail
885 // doUnblank(); 891 // doUnblank();
886 break; 892 break;
887 case Key_Q: //add to playlist 893 case Key_Q: //add to playlist
888 addSelected(); 894 addSelected();
889 break; 895 break;
890 case Key_R: //remove from playlist 896 case Key_R: //remove from playlist
891 removeSelected(); 897 removeSelected();
892 break; 898 break;
893 // case Key_P: //play 899 // case Key_P: //play
894 // odebug << "Play" << oendl; 900 // odebug << "Play" << oendl;
895 // playSelected(); 901 // playSelected();
896 // break; 902 // break;
897 case Key_Space: 903 case Key_Space:
898 // playSelected(); puh 904 // playSelected(); puh
899 break; 905 break;
900 case Key_1: 906 case Key_1:
901 tabWidget->setCurrentPage( 0 ); 907 tabWidget->setCurrentPage( 0 );
902 break; 908 break;
903 case Key_2: 909 case Key_2:
904 tabWidget->setCurrentPage( 1 ); 910 tabWidget->setCurrentPage( 1 );
905 break; 911 break;
906 case Key_3: 912 case Key_3:
907 tabWidget->setCurrentPage( 2 ); 913 tabWidget->setCurrentPage( 2 );
908 break; 914 break;
909 case Key_4: 915 case Key_4:
910 tabWidget->setCurrentPage( 3 ); 916 tabWidget->setCurrentPage( 3 );
911 break; 917 break;
912 case Key_Down: 918 case Key_Down:
913 if ( !d->selectedFiles->next() ) 919 if ( !d->selectedFiles->next() )
914 d->selectedFiles->first(); 920 d->selectedFiles->first();
915 break; 921 break;
916 case Key_Up: 922 case Key_Up:
917 if ( !d->selectedFiles->prev() ) 923 if ( !d->selectedFiles->prev() )
918 // d->selectedFiles->last(); 924 // d->selectedFiles->last();
919 break; 925 break;
920 } 926 }
921} 927}
922 928
923void PlayListWidget::pmViewActivated(int index) { 929void PlayListWidget::pmViewActivated(int index) {
924// odebug << "" << index << "" << oendl; 930// odebug << "" << index << "" << oendl;
925 switch(index) { 931 switch(index) {
926 case -16: 932 case -16:
927 { 933 {
928 mediaPlayerState->toggleFullscreen(); 934 mediaPlayerState->toggleFullscreen();
929 bool b=mediaPlayerState->isFullscreen(); 935 bool b=mediaPlayerState->isFullscreen();
930 pmView->setItemChecked( index, b); 936 pmView->setItemChecked( index, b);
931 Config cfg( "OpiePlayer" ); 937 Config cfg( "OpiePlayer" );
932 cfg.writeEntry( "FullScreen", b ); 938 cfg.writeEntry( "FullScreen", b );
933 } 939 }
934 break; 940 break;
935 }; 941 };
936} 942}
937 943
938void PlayListWidget::populateSkinsMenu() { 944void PlayListWidget::populateSkinsMenu() {
939 int item = 0; 945 int item = 0;
940 defaultSkinIndex = 0; 946 defaultSkinIndex = 0;
941 QString skinName; 947 QString skinName;
942 Config cfg( "OpiePlayer" ); 948 Config cfg( "OpiePlayer" );
943 cfg.setGroup("Options" ); 949 cfg.setGroup("Options" );
944 QString skin = cfg.readEntry( "Skin", "default" ); 950 QString skin = cfg.readEntry( "Skin", "default" );
945 951
946 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); 952 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" );
947 skinsDir.setFilter( QDir::Dirs ); 953 skinsDir.setFilter( QDir::Dirs );
948 skinsDir.setSorting(QDir::Name ); 954 skinsDir.setSorting(QDir::Name );
949 const QFileInfoList *skinslist = skinsDir.entryInfoList(); 955 const QFileInfoList *skinslist = skinsDir.entryInfoList();
950 QFileInfoListIterator it( *skinslist ); 956 QFileInfoListIterator it( *skinslist );
951 QFileInfo *fi; 957 QFileInfo *fi;
952 while ( ( fi = it.current() ) ) { 958 while ( ( fi = it.current() ) ) {
953 skinName = fi->fileName(); 959 skinName = fi->fileName();
954// odebug << fi->fileName() << oendl; 960// odebug << fi->fileName() << oendl;
955 if( skinName != "." && skinName != ".." && skinName !="CVS" ) { 961 if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
956 item = skinsMenu->insertItem( fi->fileName() ) ; 962 item = skinsMenu->insertItem( fi->fileName() ) ;
957 } 963 }
958 if( skinName == "default" ) { 964 if( skinName == "default" ) {
959 defaultSkinIndex = item; 965 defaultSkinIndex = item;
960 } 966 }
961 if( skinName == skin ) { 967 if( skinName == skin ) {
962 skinsMenu->setItemChecked( item, TRUE ); 968 skinsMenu->setItemChecked( item, TRUE );
963 } 969 }
964 ++it; 970 ++it;
965 } 971 }
966} 972}
967 973
968void PlayListWidget::skinsMenuActivated( int item ) { 974void PlayListWidget::skinsMenuActivated( int item ) {
969 for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { 975 for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) {
970 skinsMenu->setItemChecked( i, FALSE ); 976 skinsMenu->setItemChecked( i, FALSE );
971 } 977 }
972 skinsMenu->setItemChecked( item, TRUE ); 978 skinsMenu->setItemChecked( item, TRUE );
973 979
974 { 980 {
975 Config cfg( "OpiePlayer" ); 981 Config cfg( "OpiePlayer" );
976 cfg.setGroup("Options"); 982 cfg.setGroup("Options");
977 cfg.writeEntry("Skin", skinsMenu->text( item ) ); 983 cfg.writeEntry("Skin", skinsMenu->text( item ) );
978 } 984 }
979 985
980 emit skinSelected(); 986 emit skinSelected();
981} 987}
982 988
983PlayListWidget::TabType PlayListWidget::currentTab() const 989PlayListWidget::TabType PlayListWidget::currentTab() const
984{ 990{
985 static const TabType indexToTabType[ TabTypeCount ] = 991 static const TabType indexToTabType[ TabTypeCount ] =
986 { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; 992 { CurrentPlayList, AudioFiles, VideoFiles, PlayLists };
987 993
988 int index = tabWidget->currentPageIndex(); 994 int index = tabWidget->currentPageIndex();
989 assert( index < TabTypeCount && index >= 0 ); 995 assert( index < TabTypeCount && index >= 0 );
990 996
991 return indexToTabType[ index ]; 997 return indexToTabType[ index ];
992} 998}
993 999
994PlayListWidget::Entry PlayListWidget::currentEntry() const 1000PlayListWidget::Entry PlayListWidget::currentEntry() const
995{ 1001{
996 if ( currentTab() == CurrentPlayList ) { 1002 if ( currentTab() == CurrentPlayList ) {
997 const DocLnk *lnk = current(); 1003 const DocLnk *lnk = current();
998 return Entry( lnk->name(), lnk->file() ); 1004 return Entry( lnk->name(), lnk->file() );
999 } 1005 }
1000 1006
1001 return Entry( currentFileListPathName() ); 1007 return Entry( currentFileListPathName() );
1002} 1008}
1003 1009
1004QString PlayListWidget::currentFileListPathName() const { 1010QString PlayListWidget::currentFileListPathName() const {
1005 return currentFileListView->currentItem()->text( 3 ); 1011 return currentFileListView->currentItem()->text( 3 );
1006} 1012}
1007 1013
1008 1014
1009void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { 1015void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) {
1010 odebug << "qcop message "+msg << oendl;
1011 QDataStream stream ( data, IO_ReadOnly ); 1016 QDataStream stream ( data, IO_ReadOnly );
1012 if ( msg == "play()" ) { //plays current selection 1017 if ( msg == "play()" ) { //plays current selection
1013 btnPlay( true); 1018 btnPlay( true);
1014 } else if ( msg == "stop()" ) { 1019 } else if ( msg == "stop()" ) {
1015 mediaPlayerState->setPlaying( false); 1020 mediaPlayerState->setPlaying( false);
1016 } else if ( msg == "togglePause()" ) { 1021 } else if ( msg == "togglePause()" ) {
1017 mediaPlayerState->togglePaused(); 1022 mediaPlayerState->togglePaused();
1018 } else if ( msg == "next()" ) { //select next in list 1023 } else if ( msg == "next()" ) { //select next in list
1019 mediaPlayerState->setNext(); 1024 mediaPlayerState->setNext();
1020 } else if ( msg == "prev()" ) { //select previous in list 1025 } else if ( msg == "prev()" ) { //select previous in list
1021 mediaPlayerState->setPrev(); 1026 mediaPlayerState->setPrev();
1022 } else if ( msg == "toggleLooping()" ) { //loop or not loop 1027 } else if ( msg == "toggleLooping()" ) { //loop or not loop
1023 mediaPlayerState->toggleLooping(); 1028 mediaPlayerState->toggleLooping();
1024 } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled 1029 } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled
1025 mediaPlayerState->toggleShuffled(); 1030 mediaPlayerState->toggleShuffled();
1026 } else if ( msg == "volUp()" ) { //volume more 1031 } else if ( msg == "volUp()" ) { //volume more
1027// emit moreClicked(); 1032// emit moreClicked();
1028// emit moreReleased(); 1033// emit moreReleased();
1029 } else if ( msg == "volDown()" ) { //volume less 1034 } else if ( msg == "volDown()" ) { //volume less
1030// emit lessClicked(); 1035// emit lessClicked();
1031// emit lessReleased(); 1036// emit lessReleased();
1032 } else if ( msg == "play(QString)" ) { //play this now 1037 } else if ( msg == "play(QString)" ) { //play this now
1033 QString file; 1038 QString file;
1034 stream >> file; 1039 stream >> file;
1035 setDocument( (const QString &) file); 1040 setDocument( (const QString &) file);
1036 } else if ( msg == "add(QString)" ) { //add to playlist 1041 } else if ( msg == "add(QString)" ) { //add to playlist
1037 QString file; 1042 QString file;
1038 stream >> file; 1043 stream >> file;
1039 QFileInfo fileInfo(file); 1044 QFileInfo fileInfo(file);
1040 DocLnk lnk; 1045 DocLnk lnk;
1041 lnk.setName( fileInfo.baseName() ); //sets name 1046 lnk.setName( fileInfo.baseName() ); //sets name
1042 lnk.setFile( file ); //sets file name 1047 lnk.setFile( file ); //sets file name
1043 addToSelection( lnk ); 1048 addToSelection( lnk );
1044 } else if ( msg == "rem(QString)" ) { //remove from playlist 1049 } else if ( msg == "rem(QString)" ) { //remove from playlist
1045 QString file; 1050 QString file;
1046 stream >> file; 1051 stream >> file;
1047 1052
1048 } 1053 }
1049 1054
1050} 1055}
1056
1057DocLnk PlayListWidget::addFileToPlaylist( const QString& file,
1058 const QString& name ) {
1059 DocLnk lnk;
1060 lnk.setName( name ); //sets name
1061 lnk.setFile( file ); //sets file name
1062 d->selectedFiles->addToSelection( lnk );
1063 writeCurrentM3u();
1064
1065 return lnk;
1066}
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h
index 29f3e8d..1f5ba92 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.h
+++ b/noncore/multimedia/opieplayer2/playlistwidget.h
@@ -1,143 +1,145 @@
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,2003 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002,2003 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..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; 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  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = 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 PLAY_LIST_WIDGET_H 34#ifndef PLAY_LIST_WIDGET_H
35#define PLAY_LIST_WIDGET_H 35#define PLAY_LIST_WIDGET_H
36 36
37 37
38#include <qpushbutton.h> 38#include <qpushbutton.h>
39#include <qpopupmenu.h> 39#include <qpopupmenu.h>
40#include <qpe/qcopenvelope_qws.h> 40#include <qpe/qcopenvelope_qws.h>
41 41
42#include "playlistwidgetgui.h" 42#include "playlistwidgetgui.h"
43 43
44class Config; 44class Config;
45class QListViewItem; 45class QListViewItem;
46class QListView; 46class QListView;
47class QPoint; 47class QPoint;
48class QAction; 48class QAction;
49class QLabel; 49class QLabel;
50class MediaPlayerState; 50class MediaPlayerState;
51class MediaPlayer; 51class MediaPlayer;
52 52
53class PlayListWidget : public PlayListWidgetGui { 53class PlayListWidget : public PlayListWidgetGui {
54 Q_OBJECT 54 Q_OBJECT
55public: 55public:
56 enum TabType { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; 56 enum TabType { CurrentPlayList, AudioFiles, VideoFiles, PlayLists };
57 enum { TabTypeCount = 4 }; 57 enum { TabTypeCount = 4 };
58 58
59 struct Entry 59 struct Entry
60 { 60 {
61 Entry( const QString &_name, const QString &_fileName ) 61 Entry( const QString &_name, const QString &_fileName )
62 : name( _name ), file( _fileName ) {} 62 : name( _name ), file( _fileName ) {}
63 Entry( const QString &_fileName ) 63 Entry( const QString &_fileName )
64 : name( _fileName ), file( _fileName ) {} 64 : name( _fileName ), file( _fileName ) {}
65 65
66 QString name; 66 QString name;
67 QString file; 67 QString file;
68 }; 68 };
69 69
70 static QString appName() { return QString::fromLatin1("opieplayer2"); } 70 static QString appName() { return QString::fromLatin1("opieplayer2"); }
71 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags = 0 ); 71 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags = 0 );
72 ~PlayListWidget(); 72 ~PlayListWidget();
73 73
74 // retrieve the current playlist entry (media file link) 74 // retrieve the current playlist entry (media file link)
75 const DocLnk *current() const; 75 const DocLnk *current() const;
76 void useSelectedDocument(); 76 void useSelectedDocument();
77 TabType currentTab() const; 77 TabType currentTab() const;
78 78
79 Entry currentEntry() const; 79 Entry currentEntry() const;
80 80
81public slots: 81public slots:
82 bool first(); 82 bool first();
83 bool last(); 83 bool last();
84 bool next(); 84 bool next();
85 bool prev(); 85 bool prev();
86 void writeDefaultPlaylist( ); 86 void writeDefaultPlaylist( );
87 QString currentFileListPathName() const; 87 QString currentFileListPathName() const;
88protected: 88protected:
89 QCopChannel * channel; 89 QCopChannel * channel;
90 void keyReleaseEvent( QKeyEvent *e); 90 void keyReleaseEvent( QKeyEvent *e);
91 91
92signals: 92signals:
93 void skinSelected(); 93 void skinSelected();
94 94
95private: 95private:
96 int defaultSkinIndex; 96 int defaultSkinIndex;
97/* void readm3u(const QString &); */ 97/* void readm3u(const QString &); */
98/* void readPls(const QString &); */ 98/* void readPls(const QString &); */
99 void readListFromFile(const QString &); 99 void readListFromFile(const QString &);
100 void initializeStates(); 100 void initializeStates();
101 101
102 bool inFileListMode() const; 102 bool inFileListMode() const;
103 103
104private slots: 104private slots:
105 void qcopReceive(const QCString&, const QByteArray&); 105 void qcopReceive(const QCString&, const QByteArray&);
106 void populateSkinsMenu(); 106 void populateSkinsMenu();
107 void skinsMenuActivated(int); 107 void skinsMenuActivated(int);
108 void pmViewActivated(int); 108 void pmViewActivated(int);
109 void writem3u(); 109 void writem3u();
110 void writeCurrentM3u(); 110 void writeCurrentM3u();
111 void openFile(); 111 void openFile();
112 void openURL(); 112 void openURL();
113 void openDirectory();
113 void setDocument( const QString& fileref ); 114 void setDocument( const QString& fileref );
114 void addToSelection( const DocLnk& ); // Add a media file to the playlist 115 void addToSelection( const DocLnk& ); // Add a media file to the playlist
115 void addToSelection( QListViewItem* ); // Add a media file to the playlist 116 void addToSelection( QListViewItem* ); // Add a media file to the playlist
116 void clearList(); 117 void clearList();
117 void addAllToList(); 118 void addAllToList();
118 void addAllMusicToList(); 119 void addAllMusicToList();
119 void addAllVideoToList(); 120 void addAllVideoToList();
120 void saveList(); // Save the playlist 121 void saveList(); // Save the playlist
121 void loadList( const DocLnk &); // Load a playlist 122 void loadList( const DocLnk &); // Load a playlist
122 void playIt( QListViewItem *); 123 void playIt( QListViewItem *);
123 void btnPlay(bool); 124 void btnPlay(bool);
124 void deletePlaylist(); 125 void deletePlaylist();
125 void addSelected(); 126 void addSelected();
126 void removeSelected(); 127 void removeSelected();
127 void tabChanged(QWidget*); 128 void tabChanged(QWidget*);
128 void viewPressed( int, QListViewItem *, const QPoint&, int); 129 void viewPressed( int, QListViewItem *, const QPoint&, int);
129 void playlistViewPressed( int, QListViewItem *, const QPoint&, int); 130 void playlistViewPressed( int, QListViewItem *, const QPoint&, int);
130 void playSelected(); 131 void playSelected();
131 132
132private: 133private:
134 DocLnk addFileToPlaylist(const QString& directory, const QString& name);
133 bool fromSetDocument; 135 bool fromSetDocument;
134 bool insanityBool; 136 bool insanityBool;
135 QString setDocFileRef, currentPlayList; 137 QString setDocFileRef, currentPlayList;
136 int selected; 138 int selected;
137 QListView *currentFileListView; 139 QListView *currentFileListView;
138 140
139 MediaPlayer *m_mp; 141 MediaPlayer *m_mp;
140}; 142};
141 143
142#endif // PLAY_LIST_WIDGET_H 144#endif // PLAY_LIST_WIDGET_H
143 145