Diffstat (limited to 'core/multimedia/opieplayer/playlistwidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 474 |
1 files changed, 247 insertions, 227 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 5be0d6d..6580a88 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -62,48 +62,49 @@ | |||
62 | 62 | ||
63 | #include <stdlib.h> | 63 | #include <stdlib.h> |
64 | #include "audiowidget.h" | 64 | #include "audiowidget.h" |
65 | #include "videowidget.h" | 65 | #include "videowidget.h" |
66 | 66 | ||
67 | #include <unistd.h> | 67 | #include <unistd.h> |
68 | #include <sys/file.h> | 68 | #include <sys/file.h> |
69 | #include <sys/ioctl.h> | 69 | #include <sys/ioctl.h> |
70 | #include <sys/soundcard.h> | 70 | #include <sys/soundcard.h> |
71 | 71 | ||
72 | // for setBacklight() | 72 | // for setBacklight() |
73 | #include <linux/fb.h> | 73 | #include <linux/fb.h> |
74 | #include <sys/types.h> | 74 | #include <sys/types.h> |
75 | #include <sys/stat.h> | 75 | #include <sys/stat.h> |
76 | #include <stdlib.h> | 76 | #include <stdlib.h> |
77 | 77 | ||
78 | #define BUTTONS_ON_TOOLBAR | 78 | #define BUTTONS_ON_TOOLBAR |
79 | #define SIDE_BUTTONS | 79 | #define SIDE_BUTTONS |
80 | #define CAN_SAVE_LOAD_PLAYLISTS | 80 | #define CAN_SAVE_LOAD_PLAYLISTS |
81 | 81 | ||
82 | extern AudioWidget *audioUI; | 82 | extern AudioWidget *audioUI; |
83 | extern VideoWidget *videoUI; | 83 | extern VideoWidget *videoUI; |
84 | extern MediaPlayerState *mediaPlayerState; | 84 | extern MediaPlayerState *mediaPlayerState; |
85 | 85 | ||
86 | QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg"; | ||
86 | // class myFileSelector { | 87 | // class myFileSelector { |
87 | 88 | ||
88 | // }; | 89 | // }; |
89 | class PlayListWidgetPrivate { | 90 | class PlayListWidgetPrivate { |
90 | public: | 91 | public: |
91 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | 92 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
92 | QFrame *playListFrame; | 93 | QFrame *playListFrame; |
93 | FileSelector *files; | 94 | FileSelector *files; |
94 | PlayListSelection *selectedFiles; | 95 | PlayListSelection *selectedFiles; |
95 | bool setDocumentUsed; | 96 | bool setDocumentUsed; |
96 | DocLnk *current; | 97 | DocLnk *current; |
97 | }; | 98 | }; |
98 | 99 | ||
99 | 100 | ||
100 | class ToolButton : public QToolButton { | 101 | class ToolButton : public QToolButton { |
101 | public: | 102 | public: |
102 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 103 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
103 | : QToolButton( parent, name ) { | 104 | : QToolButton( parent, name ) { |
104 | setTextLabel( name ); | 105 | setTextLabel( name ); |
105 | setPixmap( Resource::loadPixmap( icon ) ); | 106 | setPixmap( Resource::loadPixmap( icon ) ); |
106 | setAutoRaise( TRUE ); | 107 | setAutoRaise( TRUE ); |
107 | setFocusPolicy( QWidget::NoFocus ); | 108 | setFocusPolicy( QWidget::NoFocus ); |
108 | setToggleButton( t ); | 109 | setToggleButton( t ); |
109 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 110 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
@@ -158,50 +159,48 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
158 | tbDeletePlaylist->setFlat(TRUE); | 159 | tbDeletePlaylist->setFlat(TRUE); |
159 | tbDeletePlaylist->setFixedSize(20,20); | 160 | tbDeletePlaylist->setFixedSize(20,20); |
160 | 161 | ||
161 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", | 162 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", |
162 | this , SLOT(addSelected()) ); | 163 | this , SLOT(addSelected()) ); |
163 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", | 164 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", |
164 | this , SLOT(removeSelected()) ); | 165 | this , SLOT(removeSelected()) ); |
165 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); | 166 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); |
166 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", | 167 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", |
167 | this , SLOT( btnPlay(bool) ), TRUE ); | 168 | this , SLOT( btnPlay(bool) ), TRUE ); |
168 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", | 169 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", |
169 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 170 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); |
170 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", | 171 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", |
171 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 172 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); |
172 | tbDeletePlaylist->hide(); | 173 | tbDeletePlaylist->hide(); |
173 | 174 | ||
174 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 175 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
175 | menu->insertItem( tr( "File" ), pmPlayList ); | 176 | menu->insertItem( tr( "File" ), pmPlayList ); |
176 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 177 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
177 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 178 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
178 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 179 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
179 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 180 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
180 | pmPlayList->insertSeparator(-1); | 181 | pmPlayList->insertSeparator(-1); |
181 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 182 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
182 | new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); | ||
183 | pmPlayList->insertSeparator(-1); | ||
184 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); | 183 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); |
185 | pmPlayList->insertSeparator(-1); | 184 | pmPlayList->insertSeparator(-1); |
186 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); | 185 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); |
187 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); | 186 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); |
188 | 187 | ||
189 | QPopupMenu *pmView = new QPopupMenu( this ); | 188 | QPopupMenu *pmView = new QPopupMenu( this ); |
190 | menu->insertItem( tr( "View" ), pmView ); | 189 | menu->insertItem( tr( "View" ), pmView ); |
191 | 190 | ||
192 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); | 191 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); |
193 | fullScreenButton->addTo(pmView); | 192 | fullScreenButton->addTo(pmView); |
194 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); | 193 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); |
195 | scaleButton->addTo(pmView); | 194 | scaleButton->addTo(pmView); |
196 | 195 | ||
197 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 196 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
198 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | 197 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); |
199 | 198 | ||
200 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | 199 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); |
201 | 200 | ||
202 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 201 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
203 | tabWidget->setTabShape(QTabWidget::Triangular); | 202 | tabWidget->setTabShape(QTabWidget::Triangular); |
204 | 203 | ||
205 | QWidget *pTab; | 204 | QWidget *pTab; |
206 | pTab = new QWidget( tabWidget, "pTab" ); | 205 | pTab = new QWidget( tabWidget, "pTab" ); |
207 | // playlistView = new QListView( pTab, "playlistview" ); | 206 | // playlistView = new QListView( pTab, "playlistview" ); |
@@ -258,93 +257,93 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
258 | videoView->setMinimumSize(233,260); | 257 | videoView->setMinimumSize(233,260); |
259 | 258 | ||
260 | videoView->addColumn(tr("Title"),140); | 259 | videoView->addColumn(tr("Title"),140); |
261 | videoView->addColumn(tr("Size"),-1); | 260 | videoView->addColumn(tr("Size"),-1); |
262 | videoView->addColumn(tr("Media"),-1); | 261 | videoView->addColumn(tr("Media"),-1); |
263 | videoView->setColumnAlignment(1, Qt::AlignRight); | 262 | videoView->setColumnAlignment(1, Qt::AlignRight); |
264 | videoView->setColumnAlignment(2, Qt::AlignRight); | 263 | videoView->setColumnAlignment(2, Qt::AlignRight); |
265 | videoView->setAllColumnsShowFocus(TRUE); | 264 | videoView->setAllColumnsShowFocus(TRUE); |
266 | videoView->setMultiSelection( TRUE ); | 265 | videoView->setMultiSelection( TRUE ); |
267 | videoView->setSelectionMode( QListView::Extended); | 266 | videoView->setSelectionMode( QListView::Extended); |
268 | 267 | ||
269 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 268 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
270 | 269 | ||
271 | tabWidget->insertTab( vTab,tr("Video")); | 270 | tabWidget->insertTab( vTab,tr("Video")); |
272 | 271 | ||
273 | QWidget *LTab; | 272 | QWidget *LTab; |
274 | LTab = new QWidget( tabWidget, "LTab" ); | 273 | LTab = new QWidget( tabWidget, "LTab" ); |
275 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | 274 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy |
276 | playLists->setMinimumSize(233,260); | 275 | playLists->setMinimumSize(233,260); |
277 | tabWidget->insertTab(LTab,tr("Lists")); | 276 | tabWidget->insertTab(LTab,tr("Lists")); |
278 | 277 | ||
279 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); | 278 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); |
280 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); | 279 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); |
281 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); | 280 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); |
281 | |||
282 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 282 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
283 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); | 283 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); |
284 | 284 | ||
285 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 285 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
286 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 286 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
287 | 287 | ||
288 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), | 288 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), |
289 | this,SLOT( playIt( QListViewItem *)) ); | 289 | this,SLOT( playIt( QListViewItem *)) ); |
290 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 290 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
291 | 291 | ||
292 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 292 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
293 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 293 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
294 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), | 294 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), |
295 | this,SLOT( playIt( QListViewItem *)) ); | 295 | this,SLOT( playIt( QListViewItem *)) ); |
296 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 296 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
297 | 297 | ||
298 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 298 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
299 | 299 | ||
300 | 300 | ||
301 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 301 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
302 | 302 | ||
303 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 303 | // connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
304 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 304 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
305 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 305 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
306 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 306 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
307 | 307 | ||
308 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 308 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
309 | 309 | ||
310 | setCentralWidget( vbox5 ); | 310 | setCentralWidget( vbox5 ); |
311 | 311 | ||
312 | Config cfg( "OpiePlayer" ); | 312 | Config cfg( "OpiePlayer" ); |
313 | readConfig( cfg ); | 313 | readConfig( cfg ); |
314 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 314 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
315 | loadList(DocLnk( currentPlaylist)); | 315 | loadList(DocLnk( currentPlaylist)); |
316 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); | 316 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); |
317 | 317 | ||
318 | initializeStates(); | 318 | initializeStates(); |
319 | } | 319 | } |
320 | 320 | ||
321 | 321 | ||
322 | PlayListWidget::~PlayListWidget() { | 322 | PlayListWidget::~PlayListWidget() { |
323 | Config cfg( "OpiePlayer" ); | 323 | Config cfg( "OpiePlayer" ); |
324 | writeConfig( cfg ); | 324 | writeConfig( cfg ); |
325 | 325 | ||
326 | |||
327 | if ( d->current ) | 326 | if ( d->current ) |
328 | delete d->current; | 327 | delete d->current; |
329 | delete d; | 328 | delete d; |
330 | } | 329 | } |
331 | 330 | ||
332 | 331 | ||
333 | void PlayListWidget::initializeStates() { | 332 | void PlayListWidget::initializeStates() { |
334 | 333 | ||
335 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 334 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
336 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 335 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
337 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 336 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
338 | setPlaylist( true); | 337 | setPlaylist( true); |
339 | } | 338 | } |
340 | 339 | ||
341 | 340 | ||
342 | void PlayListWidget::readConfig( Config& cfg ) { | 341 | void PlayListWidget::readConfig( Config& cfg ) { |
343 | cfg.setGroup("PlayList"); | 342 | cfg.setGroup("PlayList"); |
344 | QString currentString = cfg.readEntry("current", "" ); | 343 | QString currentString = cfg.readEntry("current", "" ); |
345 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 344 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
346 | for ( int i = 0; i < noOfFiles; i++ ) { | 345 | for ( int i = 0; i < noOfFiles; i++ ) { |
347 | QString entryName; | 346 | QString entryName; |
348 | entryName.sprintf( "File%i", i + 1 ); | 347 | entryName.sprintf( "File%i", i + 1 ); |
349 | QString linkFile = cfg.readEntry( entryName ); | 348 | QString linkFile = cfg.readEntry( entryName ); |
350 | DocLnk lnk( linkFile ); | 349 | DocLnk lnk( linkFile ); |
@@ -372,55 +371,55 @@ void PlayListWidget::writeConfig( Config& cfg ) const { | |||
372 | // if this link does exist, add it so we have the file | 371 | // if this link does exist, add it so we have the file |
373 | // next time... | 372 | // next time... |
374 | if ( !QFile::exists( lnk->linkFile() ) ) { | 373 | if ( !QFile::exists( lnk->linkFile() ) ) { |
375 | // the way writing lnks doesn't really check for out | 374 | // the way writing lnks doesn't really check for out |
376 | // of disk space, but check it anyway. | 375 | // of disk space, but check it anyway. |
377 | if ( !lnk->writeLink() ) { | 376 | if ( !lnk->writeLink() ) { |
378 | QMessageBox::critical( 0, tr("Out of space"), | 377 | QMessageBox::critical( 0, tr("Out of space"), |
379 | tr( "There was a problem saving " | 378 | tr( "There was a problem saving " |
380 | "the playlist.\n" | 379 | "the playlist.\n" |
381 | "Your playlist " | 380 | "Your playlist " |
382 | "may be missing some entries\n" | 381 | "may be missing some entries\n" |
383 | "the next time you start it." ) | 382 | "the next time you start it." ) |
384 | ); | 383 | ); |
385 | } | 384 | } |
386 | } | 385 | } |
387 | noOfFiles++; | 386 | noOfFiles++; |
388 | } | 387 | } |
389 | } | 388 | } |
390 | while ( d->selectedFiles->next() ); | 389 | while ( d->selectedFiles->next() ); |
391 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 390 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
392 | } | 391 | } |
393 | 392 | ||
394 | 393 | ||
395 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 394 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
396 | d->setDocumentUsed = FALSE; | 395 | d->setDocumentUsed = false; |
397 | if ( mediaPlayerState->playlist() ) { | 396 | if ( mediaPlayerState->playlist() ) { |
398 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) | 397 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) |
399 | d->selectedFiles->addToSelection( lnk ); | 398 | d->selectedFiles->addToSelection( lnk ); |
400 | } | 399 | } |
401 | else | 400 | else |
402 | mediaPlayerState->setPlaying( TRUE ); | 401 | mediaPlayerState->setPlaying( true); |
403 | } | 402 | } |
404 | 403 | ||
405 | 404 | ||
406 | void PlayListWidget::clearList() { | 405 | void PlayListWidget::clearList() { |
407 | while ( first() ) | 406 | while ( first() ) |
408 | d->selectedFiles->removeSelected(); | 407 | d->selectedFiles->removeSelected(); |
409 | } | 408 | } |
410 | 409 | ||
411 | 410 | ||
412 | void PlayListWidget::addAllToList() { | 411 | void PlayListWidget::addAllToList() { |
413 | DocLnkSet filesAll; | 412 | DocLnkSet filesAll; |
414 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 413 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
415 | QListIterator<DocLnk> Adit( filesAll.children() ); | 414 | QListIterator<DocLnk> Adit( filesAll.children() ); |
416 | for ( ; Adit.current(); ++Adit ) | 415 | for ( ; Adit.current(); ++Adit ) |
417 | if(QFileInfo(Adit.current()->file()).exists()) | 416 | if(QFileInfo(Adit.current()->file()).exists()) |
418 | d->selectedFiles->addToSelection( **Adit ); | 417 | d->selectedFiles->addToSelection( **Adit ); |
419 | } | 418 | } |
420 | 419 | ||
421 | 420 | ||
422 | void PlayListWidget::addAllMusicToList() { | 421 | void PlayListWidget::addAllMusicToList() { |
423 | QListIterator<DocLnk> dit( files.children() ); | 422 | QListIterator<DocLnk> dit( files.children() ); |
424 | for ( ; dit.current(); ++dit ) | 423 | for ( ; dit.current(); ++dit ) |
425 | if(QFileInfo(dit.current()->file()).exists()) | 424 | if(QFileInfo(dit.current()->file()).exists()) |
426 | d->selectedFiles->addToSelection( **dit ); | 425 | d->selectedFiles->addToSelection( **dit ); |
@@ -475,48 +474,49 @@ void PlayListWidget::setActiveWindow() { | |||
475 | mediaPlayerState->setView( origView ); // now switch back | 474 | mediaPlayerState->setView( origView ); // now switch back |
476 | } | 475 | } |
477 | 476 | ||
478 | 477 | ||
479 | void PlayListWidget::useSelectedDocument() { | 478 | void PlayListWidget::useSelectedDocument() { |
480 | d->setDocumentUsed = FALSE; | 479 | d->setDocumentUsed = FALSE; |
481 | } | 480 | } |
482 | 481 | ||
483 | 482 | ||
484 | const DocLnk *PlayListWidget::current() { // this is fugly | 483 | const DocLnk *PlayListWidget::current() { // this is fugly |
485 | 484 | ||
486 | // if( fromSetDocument) { | 485 | // if( fromSetDocument) { |
487 | // qDebug("from setDoc"); | 486 | // qDebug("from setDoc"); |
488 | // DocLnkSet files; | 487 | // DocLnkSet files; |
489 | // Global::findDocuments(&files, "video/*;audio/*"); | 488 | // Global::findDocuments(&files, "video/*;audio/*"); |
490 | // QListIterator<DocLnk> dit( files.children() ); | 489 | // QListIterator<DocLnk> dit( files.children() ); |
491 | // for ( ; dit.current(); ++dit ) { | 490 | // for ( ; dit.current(); ++dit ) { |
492 | // if(dit.current()->linkFile() == setDocFileRef) { | 491 | // if(dit.current()->linkFile() == setDocFileRef) { |
493 | // qDebug(setDocFileRef); | 492 | // qDebug(setDocFileRef); |
494 | // return dit; | 493 | // return dit; |
495 | // } | 494 | // } |
496 | // } | 495 | // } |
497 | // } else | 496 | // } else |
498 | 497 | ||
498 | qDebug("current"); | ||
499 | 499 | ||
500 | switch (tabWidget->currentPageIndex()) { | 500 | switch (tabWidget->currentPageIndex()) { |
501 | case 0: //playlist | 501 | case 0: //playlist |
502 | { | 502 | { |
503 | qDebug("playlist"); | 503 | qDebug("playlist"); |
504 | if ( mediaPlayerState->playlist() ) { | 504 | if ( mediaPlayerState->playlist() ) { |
505 | return d->selectedFiles->current(); | 505 | return d->selectedFiles->current(); |
506 | } | 506 | } |
507 | else if ( d->setDocumentUsed && d->current ) { | 507 | else if ( d->setDocumentUsed && d->current ) { |
508 | return d->current; | 508 | return d->current; |
509 | } else { | 509 | } else { |
510 | return &(d->files->selectedDocument()); | 510 | return &(d->files->selectedDocument()); |
511 | } | 511 | } |
512 | } | 512 | } |
513 | break; | 513 | break; |
514 | case 1://audio | 514 | case 1://audio |
515 | { | 515 | { |
516 | qDebug("audioView"); | 516 | qDebug("audioView"); |
517 | QListIterator<DocLnk> dit( files.children() ); | 517 | QListIterator<DocLnk> dit( files.children() ); |
518 | for ( ; dit.current(); ++dit ) { | 518 | for ( ; dit.current(); ++dit ) { |
519 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { | 519 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { |
520 | qDebug("here"); | 520 | qDebug("here"); |
521 | insanityBool=TRUE; | 521 | insanityBool=TRUE; |
522 | return dit; | 522 | return dit; |
@@ -585,118 +585,84 @@ bool PlayListWidget::next() { | |||
585 | } | 585 | } |
586 | } else { | 586 | } else { |
587 | return mediaPlayerState->looping(); | 587 | return mediaPlayerState->looping(); |
588 | } | 588 | } |
589 | } | 589 | } |
590 | 590 | ||
591 | 591 | ||
592 | bool PlayListWidget::first() { | 592 | bool PlayListWidget::first() { |
593 | if ( mediaPlayerState->playlist() ) | 593 | if ( mediaPlayerState->playlist() ) |
594 | return d->selectedFiles->first(); | 594 | return d->selectedFiles->first(); |
595 | else | 595 | else |
596 | return mediaPlayerState->looping(); | 596 | return mediaPlayerState->looping(); |
597 | } | 597 | } |
598 | 598 | ||
599 | 599 | ||
600 | bool PlayListWidget::last() { | 600 | bool PlayListWidget::last() { |
601 | if ( mediaPlayerState->playlist() ) | 601 | if ( mediaPlayerState->playlist() ) |
602 | return d->selectedFiles->last(); | 602 | return d->selectedFiles->last(); |
603 | else | 603 | else |
604 | return mediaPlayerState->looping(); | 604 | return mediaPlayerState->looping(); |
605 | } | 605 | } |
606 | 606 | ||
607 | 607 | ||
608 | void PlayListWidget::saveList() { | 608 | void PlayListWidget::saveList() { |
609 | 609 | writem3u(); | |
610 | QString filename; | ||
611 | InputDialog *fileDlg; | ||
612 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); | ||
613 | fileDlg->exec(); | ||
614 | if( fileDlg->result() == 1 ) { | ||
615 | if ( d->current ) | ||
616 | delete d->current; | ||
617 | filename = fileDlg->LineEdit1->text();//+".playlist"; | ||
618 | // qDebug("saving playlist "+filename+".playlist"); | ||
619 | Config cfg( filename +".playlist"); | ||
620 | writeConfig( cfg ); | ||
621 | |||
622 | DocLnk lnk; | ||
623 | // lnk.setComment( ""); | ||
624 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property | ||
625 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | ||
626 | lnk.setIcon("opieplayer/playlist2"); | ||
627 | lnk.setName( filename); //sets file name | ||
628 | // qDebug(filename); | ||
629 | if(!lnk.writeLink()) | ||
630 | qDebug("Writing doclink did not work"); | ||
631 | } | ||
632 | Config config( "OpiePlayer" ); | ||
633 | config.writeEntry("CurrentPlaylist",filename); | ||
634 | setCaption(tr("OpiePlayer: ")+filename); | ||
635 | d->selectedFiles->first(); | ||
636 | if(fileDlg) | ||
637 | delete fileDlg; | ||
638 | } | 610 | } |
639 | 611 | ||
640 | void PlayListWidget::loadList( const DocLnk & lnk) { | 612 | void PlayListWidget::loadList( const DocLnk & lnk) { |
641 | QString name= lnk.name(); | 613 | QString name= lnk.name(); |
642 | // qDebug("currentList is "+name); | 614 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); |
643 | if( name.length()>1) { | 615 | |
616 | if( name.length()>0) { | ||
644 | setCaption("OpiePlayer: "+name); | 617 | setCaption("OpiePlayer: "+name); |
645 | // qDebug("load list "+ name+".playlist"); | 618 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); |
646 | clearList(); | 619 | clearList(); |
647 | Config cfg( name+".playlist"); | 620 | readm3u(lnk.file()); |
648 | readConfig(cfg); | ||
649 | |||
650 | tabWidget->setCurrentPage(0); | 621 | tabWidget->setCurrentPage(0); |
651 | |||
652 | Config config( "OpiePlayer" ); | ||
653 | config.writeEntry("CurrentPlaylist", name); | ||
654 | // d->selectedFiles->first(); | ||
655 | } | 622 | } |
656 | |||
657 | } | 623 | } |
658 | 624 | ||
659 | void PlayListWidget::setPlaylist( bool shown ) { | 625 | void PlayListWidget::setPlaylist( bool shown ) { |
660 | if ( shown ) | 626 | if ( shown ) |
661 | d->playListFrame->show(); | 627 | d->playListFrame->show(); |
662 | else | 628 | else |
663 | d->playListFrame->hide(); | 629 | d->playListFrame->hide(); |
664 | } | 630 | } |
665 | 631 | ||
666 | void PlayListWidget::setView( char view ) { | 632 | void PlayListWidget::setView( char view ) { |
667 | if ( view == 'l' ) | 633 | if ( view == 'l' ) |
668 | showMaximized(); | 634 | showMaximized(); |
669 | else | 635 | else |
670 | hide(); | 636 | hide(); |
671 | } | 637 | } |
672 | 638 | ||
673 | void PlayListWidget::addSelected() { | 639 | void PlayListWidget::addSelected() { |
674 | 640 | ||
675 | Config cfg( "OpiePlayer" ); | 641 | Config cfg( "OpiePlayer" ); |
676 | cfg.setGroup("PlayList"); | 642 | cfg.setGroup("PlayList"); |
677 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 643 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
678 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 644 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
679 | 645 | ||
680 | switch (tabWidget->currentPageIndex()) { | 646 | switch (tabWidget->currentPageIndex()) { |
681 | case 0: //playlist | 647 | case 0: //playlist |
682 | break; | 648 | break; |
683 | case 1: { //audio | 649 | case 1: { //audio |
684 | // QString entryName; | 650 | // QString entryName; |
685 | // entryName.sprintf( "File%i", i + 1 ); | 651 | // entryName.sprintf( "File%i", i + 1 ); |
686 | // QString linkFile = cfg.readEntry( entryName ); | 652 | // QString linkFile = cfg.readEntry( entryName ); |
687 | QListViewItemIterator it( audioView ); | 653 | QListViewItemIterator it( audioView ); |
688 | // iterate through all items of the listview | 654 | // iterate through all items of the listview |
689 | for ( ; it.current(); ++it ) { | 655 | for ( ; it.current(); ++it ) { |
690 | if ( it.current()->isSelected() ) { | 656 | if ( it.current()->isSelected() ) { |
691 | QListIterator<DocLnk> dit( files.children() ); | 657 | QListIterator<DocLnk> dit( files.children() ); |
692 | for ( ; dit.current(); ++dit ) { | 658 | for ( ; dit.current(); ++dit ) { |
693 | if( dit.current()->name() == it.current()->text(0) ) { | 659 | if( dit.current()->name() == it.current()->text(0) ) { |
694 | d->selectedFiles->addToSelection( **dit ); | 660 | d->selectedFiles->addToSelection( **dit ); |
695 | } | 661 | } |
696 | } | 662 | } |
697 | audioView->setSelected( it.current(),FALSE); | 663 | audioView->setSelected( it.current(),FALSE); |
698 | } | 664 | } |
699 | } | 665 | } |
700 | tabWidget->setCurrentPage(0); | 666 | tabWidget->setCurrentPage(0); |
701 | } | 667 | } |
702 | break; | 668 | break; |
@@ -717,390 +683,588 @@ void PlayListWidget::addSelected() { | |||
717 | } | 683 | } |
718 | // for ( int i = 0; i < noOfFiles; i++ ) { | 684 | // for ( int i = 0; i < noOfFiles; i++ ) { |
719 | // QString entryName; | 685 | // QString entryName; |
720 | // entryName.sprintf( "File%i", i + 1 ); | 686 | // entryName.sprintf( "File%i", i + 1 ); |
721 | // QString linkFile = cfg.readEntry( entryName ); | 687 | // QString linkFile = cfg.readEntry( entryName ); |
722 | // if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { | 688 | // if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { |
723 | // int result= QMessageBox::warning(this,tr("OpiePlayer"), | 689 | // int result= QMessageBox::warning(this,tr("OpiePlayer"), |
724 | // tr("This is all ready in your playlist.\nContinue?"), | 690 | // tr("This is all ready in your playlist.\nContinue?"), |
725 | // tr("Yes"),tr("No"),0,0,1); | 691 | // tr("Yes"),tr("No"),0,0,1); |
726 | // if (result !=0) | 692 | // if (result !=0) |
727 | // return; | 693 | // return; |
728 | // } | 694 | // } |
729 | // } | 695 | // } |
730 | // addToSelection( videoView->selectedItem() ); | 696 | // addToSelection( videoView->selectedItem() ); |
731 | tabWidget->setCurrentPage(0); | 697 | tabWidget->setCurrentPage(0); |
732 | } | 698 | } |
733 | break; | 699 | break; |
734 | }; | 700 | }; |
735 | } | 701 | } |
736 | 702 | ||
737 | void PlayListWidget::removeSelected() { | 703 | void PlayListWidget::removeSelected() { |
738 | d->selectedFiles->removeSelected( ); | 704 | d->selectedFiles->removeSelected( ); |
739 | } | 705 | } |
740 | 706 | ||
741 | void PlayListWidget::playIt( QListViewItem *it) { | 707 | void PlayListWidget::playIt( QListViewItem *) { |
742 | // d->setDocumentUsed = FALSE; | 708 | // d->setDocumentUsed = FALSE; |
743 | // mediaPlayerState->curPosition =0; | 709 | // mediaPlayerState->curPosition =0; |
744 | qDebug("playIt"); | 710 | qDebug("playIt"); |
745 | mediaPlayerState->setPlaying(FALSE); | 711 | mediaPlayerState->setPlaying(FALSE); |
746 | mediaPlayerState->setPlaying(TRUE); | 712 | mediaPlayerState->setPlaying(TRUE); |
747 | d->selectedFiles->unSelect(); | 713 | d->selectedFiles->unSelect(); |
748 | } | 714 | } |
749 | 715 | ||
750 | void PlayListWidget::addToSelection( QListViewItem *it) { | 716 | void PlayListWidget::addToSelection( QListViewItem *it) { |
751 | d->setDocumentUsed = FALSE; | 717 | d->setDocumentUsed = FALSE; |
752 | 718 | ||
753 | if(it) { | 719 | if(it) { |
754 | switch (tabWidget->currentPageIndex()) { | 720 | switch (tabWidget->currentPageIndex()) { |
755 | case 1: { | 721 | case 1: { |
756 | QListIterator<DocLnk> dit( files.children() ); | 722 | QListIterator<DocLnk> dit( files.children() ); |
757 | for ( ; dit.current(); ++dit ) { | 723 | for ( ; dit.current(); ++dit ) { |
758 | if( dit.current()->name() == it->text(0)) { | 724 | if( dit.current()->name() == it->text(0)) { |
759 | d->selectedFiles->addToSelection( **dit ); | 725 | d->selectedFiles->addToSelection( **dit ); |
760 | } | 726 | } |
761 | } | 727 | } |
762 | } | 728 | } |
763 | break; | 729 | break; |
764 | case 2: { | 730 | case 2: { |
765 | QListIterator<DocLnk> dit( vFiles.children() ); | 731 | QListIterator<DocLnk> dit( vFiles.children() ); |
766 | for ( ; dit.current(); ++dit ) { | 732 | for ( ; dit.current(); ++dit ) { |
767 | if( dit.current()->name() == it->text(0)) { | 733 | if( dit.current()->name() == it->text(0)) { |
768 | d->selectedFiles->addToSelection( **dit ); | 734 | d->selectedFiles->addToSelection( **dit ); |
769 | } | 735 | } |
770 | } | 736 | } |
771 | } | 737 | } |
772 | break; | 738 | break; |
773 | case 0: | 739 | case 0: |
774 | break; | 740 | break; |
775 | }; | 741 | }; |
776 | tabWidget->setCurrentPage(0); | 742 | tabWidget->setCurrentPage(0); |
777 | } | 743 | } |
778 | } | 744 | } |
779 | 745 | ||
780 | void PlayListWidget::tabChanged(QWidget *widg) { | 746 | void PlayListWidget::tabChanged(QWidget *) { |
781 | 747 | ||
782 | switch ( tabWidget->currentPageIndex()) { | 748 | switch ( tabWidget->currentPageIndex()) { |
783 | case 0: | 749 | case 0: |
784 | { | 750 | { |
785 | if( !tbDeletePlaylist->isHidden()) | 751 | if( !tbDeletePlaylist->isHidden()) |
786 | tbDeletePlaylist->hide(); | 752 | tbDeletePlaylist->hide(); |
787 | d->tbRemoveFromList->setEnabled(TRUE); | 753 | d->tbRemoveFromList->setEnabled(TRUE); |
788 | d->tbAddToList->setEnabled(FALSE); | 754 | d->tbAddToList->setEnabled(FALSE); |
789 | } | 755 | } |
790 | break; | 756 | break; |
791 | case 1: | 757 | case 1: |
792 | { | 758 | { |
793 | audioView->clear(); | 759 | audioView->clear(); |
794 | populateAudioView(); | 760 | populateAudioView(); |
795 | 761 | ||
796 | if( !tbDeletePlaylist->isHidden()) | 762 | if( !tbDeletePlaylist->isHidden()) |
797 | tbDeletePlaylist->hide(); | 763 | tbDeletePlaylist->hide(); |
798 | d->tbRemoveFromList->setEnabled(FALSE); | 764 | d->tbRemoveFromList->setEnabled(FALSE); |
799 | d->tbAddToList->setEnabled(TRUE); | 765 | d->tbAddToList->setEnabled(TRUE); |
800 | } | 766 | } |
801 | break; | 767 | break; |
802 | case 2: | 768 | case 2: |
803 | { | 769 | { |
804 | videoView->clear(); | 770 | videoView->clear(); |
805 | populateVideoView(); | 771 | populateVideoView(); |
806 | if( !tbDeletePlaylist->isHidden()) | 772 | if( !tbDeletePlaylist->isHidden()) |
807 | tbDeletePlaylist->hide(); | 773 | tbDeletePlaylist->hide(); |
808 | d->tbRemoveFromList->setEnabled(FALSE); | 774 | d->tbRemoveFromList->setEnabled(FALSE); |
809 | d->tbAddToList->setEnabled(TRUE); | 775 | d->tbAddToList->setEnabled(TRUE); |
810 | } | 776 | } |
811 | break; | 777 | break; |
812 | case 3: | 778 | case 3: |
813 | { | 779 | { |
814 | if( tbDeletePlaylist->isHidden()) | 780 | if( tbDeletePlaylist->isHidden()) |
815 | tbDeletePlaylist->show(); | 781 | tbDeletePlaylist->show(); |
816 | playLists->reread(); | 782 | playLists->reread(); |
817 | } | 783 | } |
818 | break; | 784 | break; |
819 | }; | 785 | }; |
820 | } | 786 | } |
821 | 787 | ||
822 | void PlayListWidget::btnPlay(bool b) { | 788 | void PlayListWidget::btnPlay(bool b) { |
823 | 789 | qDebug("<<<<<<<<<<<<<<<BtnPlay"); | |
824 | // mediaPlayerState->setPlaying(b); | 790 | // mediaPlayerState->setPlaying(b); |
825 | switch ( tabWidget->currentPageIndex()) { | 791 | switch ( tabWidget->currentPageIndex()) { |
826 | case 0: | 792 | case 0: |
827 | { | 793 | { |
794 | qDebug("1"); | ||
828 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 | 795 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 |
829 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { | 796 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { |
830 | // QMessageBox::message("Note","You are trying to play\na malformed url."); | 797 | // QMessageBox::message("Note","You are trying to play\na malformed url."); |
831 | // } else { | 798 | // } else { |
832 | mediaPlayerState->setPlaying(b); | 799 | mediaPlayerState->setPlaying(b); |
800 | insanityBool=FALSE; | ||
801 | qDebug("insanity"); | ||
833 | // } | 802 | // } |
834 | } | 803 | } |
835 | break; | 804 | break; |
836 | case 1: | 805 | case 1: |
837 | { | 806 | { |
807 | qDebug("2"); | ||
838 | addToSelection( audioView->currentItem() ); | 808 | addToSelection( audioView->currentItem() ); |
839 | mediaPlayerState->setPlaying(b); | 809 | mediaPlayerState->setPlaying(b); |
840 | d->selectedFiles->removeSelected( ); | 810 | d->selectedFiles->removeSelected( ); |
841 | tabWidget->setCurrentPage(1); | 811 | tabWidget->setCurrentPage(1); |
842 | d->selectedFiles->unSelect(); | 812 | d->selectedFiles->unSelect(); |
843 | insanityBool=FALSE; | 813 | insanityBool=FALSE; |
844 | }// audioView->clearSelection(); | 814 | }// audioView->clearSelection(); |
845 | break; | 815 | break; |
846 | case 2: | 816 | case 2: |
847 | { | 817 | { |
818 | qDebug("3"); | ||
819 | |||
848 | addToSelection( videoView->currentItem() ); | 820 | addToSelection( videoView->currentItem() ); |
849 | mediaPlayerState->setPlaying(b); | 821 | mediaPlayerState->setPlaying(b); |
850 | qApp->processEvents(); | 822 | qApp->processEvents(); |
851 | d->selectedFiles->removeSelected( ); | 823 | d->selectedFiles->removeSelected( ); |
852 | tabWidget->setCurrentPage(2); | 824 | tabWidget->setCurrentPage(2); |
853 | d->selectedFiles->unSelect(); | 825 | d->selectedFiles->unSelect(); |
854 | insanityBool=FALSE; | 826 | insanityBool=FALSE; |
855 | }// videoView->clearSelection(); | 827 | }// videoView->clearSelection(); |
856 | break; | 828 | break; |
857 | }; | 829 | }; |
858 | 830 | ||
859 | } | 831 | } |
860 | 832 | ||
861 | void PlayListWidget::deletePlaylist() { | 833 | void PlayListWidget::deletePlaylist() { |
862 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 834 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
863 | (tr("You really want to delete\nthis playlist?")), | 835 | (tr("You really want to delete\nthis playlist?")), |
864 | (tr("Yes")), (tr("No")), 0 )){ | 836 | (tr("Yes")), (tr("No")), 0 )){ |
865 | case 0: // Yes clicked, | 837 | case 0: // Yes clicked, |
866 | // QFile().remove(playLists->selected()->file()); | 838 | QFile().remove(playLists->selectedDocument().file()); |
867 | // QFile().remove(playLists->selected()->linkFile()); | 839 | QFile().remove(playLists->selectedDocument().linkFile()); |
868 | // playLists->reread(); | 840 | playLists->reread(); |
869 | break; | 841 | break; |
870 | case 1: // Cancel | 842 | case 1: // Cancel |
871 | break; | 843 | break; |
872 | }; | 844 | }; |
873 | } | 845 | } |
874 | 846 | ||
875 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 847 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) |
876 | { | 848 | { |
877 | switch (mouse) { | 849 | switch (mouse) { |
878 | case 1: | 850 | case 1: |
879 | break; | 851 | break; |
880 | case 2:{ | 852 | case 2:{ |
881 | 853 | ||
882 | QPopupMenu m; | 854 | QPopupMenu m; |
883 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 855 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
884 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 856 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
885 | m.insertSeparator(); | 857 | m.insertSeparator(); |
886 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) | 858 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) |
887 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 859 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
888 | 860 | ||
889 | m.exec( QCursor::pos() ); | 861 | m.exec( QCursor::pos() ); |
890 | } | 862 | } |
891 | break; | 863 | break; |
892 | }; | 864 | }; |
893 | } | 865 | } |
894 | 866 | ||
895 | void PlayListWidget::playSelected() | 867 | void PlayListWidget::playSelected() |
896 | { | 868 | { |
897 | btnPlay( TRUE); | 869 | qDebug("playSelected"); |
870 | btnPlay( true); | ||
898 | // d->selectedFiles->unSelect(); | 871 | // d->selectedFiles->unSelect(); |
899 | } | 872 | } |
900 | 873 | ||
901 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 874 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) |
902 | { | 875 | { |
903 | switch (mouse) { | 876 | switch (mouse) { |
904 | case 1: | 877 | case 1: |
905 | 878 | ||
906 | break; | 879 | break; |
907 | case 2:{ | 880 | case 2:{ |
908 | QPopupMenu m; | 881 | QPopupMenu m; |
909 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 882 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
910 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 883 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
911 | // m.insertSeparator(); | 884 | // m.insertSeparator(); |
912 | // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 885 | // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
913 | m.exec( QCursor::pos() ); | 886 | m.exec( QCursor::pos() ); |
914 | } | 887 | } |
915 | break; | 888 | break; |
916 | }; | 889 | }; |
917 | 890 | ||
918 | } | 891 | } |
919 | 892 | ||
920 | void PlayListWidget::listDelete() { | 893 | void PlayListWidget::listDelete() { |
921 | Config cfg( "OpiePlayer" ); | 894 | Config cfg( "OpiePlayer" ); |
922 | cfg.setGroup("PlayList"); | 895 | cfg.setGroup("PlayList"); |
923 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 896 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
924 | QString file; | 897 | QString file; |
925 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 898 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
926 | switch ( tabWidget->currentPageIndex()) { | 899 | switch ( tabWidget->currentPageIndex()) { |
927 | case 0: | 900 | case 0: |
928 | break; | 901 | break; |
929 | case 1: | 902 | case 1: |
930 | { | 903 | { |
931 | file = audioView->currentItem()->text(0); | 904 | file = audioView->currentItem()->text(0); |
932 | QListIterator<DocLnk> Pdit( files.children() ); | 905 | QListIterator<DocLnk> Pdit( files.children() ); |
933 | for ( ; Pdit.current(); ++Pdit ) { | 906 | for ( ; Pdit.current(); ++Pdit ) { |
934 | if( Pdit.current()->name() == file) { | 907 | if( Pdit.current()->name() == file) { |
935 | LnkProperties prop( Pdit.current() ); | 908 | LnkProperties prop( Pdit.current() ); |
936 | prop.showMaximized(); | 909 | prop.showMaximized(); |
937 | prop.exec(); | 910 | prop.exec(); |
938 | } | 911 | } |
939 | } | 912 | } |
940 | populateAudioView(); | 913 | populateAudioView(); |
941 | } | 914 | } |
942 | break; | 915 | break; |
943 | case 2: | 916 | case 2: |
944 | { | 917 | { |
945 | // file = videoView->selectedItem()->text(0); | 918 | // file = videoView->selectedItem()->text(0); |
946 | // for ( int i = 0; i < noOfFiles; i++ ) { | 919 | // for ( int i = 0; i < noOfFiles; i++ ) { |
947 | // QString entryName; | 920 | // QString entryName; |
948 | // entryName.sprintf( "File%i", i + 1 ); | 921 | // entryName.sprintf( "File%i", i + 1 ); |
949 | // QString linkFile = cfg.readEntry( entryName ); | 922 | // QString linkFile = cfg.readEntry( entryName ); |
950 | // AppLnk lnk( AppLnk(linkFile)); | 923 | // AppLnk lnk( AppLnk(linkFile)); |
951 | // if( lnk.name() == file ) { | 924 | // if( lnk.name() == file ) { |
952 | // LnkProperties prop( &lnk); | 925 | // LnkProperties prop( &lnk); |
953 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 926 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
954 | // prop.showMaximized(); | 927 | // prop.showMaximized(); |
955 | // prop.exec(); | 928 | // prop.exec(); |
956 | // } | 929 | // } |
957 | // } | 930 | // } |
958 | } | 931 | } |
959 | break; | 932 | break; |
960 | }; | 933 | }; |
961 | } | 934 | } |
962 | 935 | ||
963 | void PlayListWidget::scanForAudio() { | 936 | void PlayListWidget::scanForAudio() { |
964 | qDebug("scan for audio"); | 937 | // qDebug("scan for audio"); |
965 | files.detachChildren(); | 938 | files.detachChildren(); |
966 | QListIterator<DocLnk> sdit( files.children() ); | 939 | QListIterator<DocLnk> sdit( files.children() ); |
967 | for ( ; sdit.current(); ++sdit ) { | 940 | for ( ; sdit.current(); ++sdit ) { |
968 | delete sdit.current(); | 941 | delete sdit.current(); |
969 | } | 942 | } |
970 | Global::findDocuments(&files, "audio/*"); | 943 | Global::findDocuments( &files, audioMimes); |
971 | audioScan = TRUE; | 944 | audioScan = true; |
972 | } | 945 | } |
973 | void PlayListWidget::scanForVideo() { | 946 | void PlayListWidget::scanForVideo() { |
974 | qDebug("scan for video"); | 947 | // qDebug("scan for video"); |
975 | vFiles.detachChildren(); | 948 | vFiles.detachChildren(); |
976 | QListIterator<DocLnk> sdit( vFiles.children() ); | 949 | QListIterator<DocLnk> sdit( vFiles.children() ); |
977 | for ( ; sdit.current(); ++sdit ) { | 950 | for ( ; sdit.current(); ++sdit ) { |
978 | delete sdit.current(); | 951 | delete sdit.current(); |
979 | } | 952 | } |
980 | Global::findDocuments(&vFiles, "video/*"); | 953 | Global::findDocuments(&vFiles, "video/*"); |
981 | videoScan = TRUE; | 954 | videoScan = true; |
982 | } | 955 | } |
983 | 956 | ||
984 | void PlayListWidget::populateAudioView() { | 957 | void PlayListWidget::populateAudioView() { |
985 | 958 | ||
986 | audioView->clear(); | 959 | audioView->clear(); |
987 | StorageInfo storageInfo; | 960 | StorageInfo storageInfo; |
988 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 961 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
989 | if(!audioScan) scanForAudio(); | 962 | if(!audioScan) scanForAudio(); |
990 | 963 | ||
991 | QListIterator<DocLnk> dit( files.children() ); | 964 | QListIterator<DocLnk> dit( files.children() ); |
992 | QListIterator<FileSystem> it ( fs ); | 965 | QListIterator<FileSystem> it ( fs ); |
993 | 966 | ||
994 | QString storage; | 967 | QString storage; |
995 | for ( ; dit.current(); ++dit ) { | 968 | for ( ; dit.current(); ++dit ) { |
996 | for( ; it.current(); ++it ){ | 969 | for( ; it.current(); ++it ){ |
997 | const QString name = (*it)->name(); | 970 | const QString name = (*it)->name(); |
998 | const QString path = (*it)->path(); | 971 | const QString path = (*it)->path(); |
999 | if(dit.current()->file().find(path) != -1 ) storage=name; | 972 | if(dit.current()->file().find(path) != -1 ) storage=name; |
1000 | } | 973 | } |
1001 | 974 | ||
1002 | QListViewItem * newItem; | 975 | QListViewItem * newItem; |
1003 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { | 976 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { |
1004 | long size; | 977 | long size; |
1005 | if( dit.current()->file().left(4) == "http" ) | 978 | if( dit.current()->file().left(4) == "http" ) |
1006 | size=0; | 979 | size=0; |
1007 | else | 980 | else |
1008 | size = QFile( dit.current()->file() ).size(); | 981 | size = QFile( dit.current()->file() ).size(); |
1009 | qDebug(dit.current()->name()); | 982 | // qDebug(dit.current()->name()); |
1010 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 983 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
1011 | QString::number(size ), storage); | 984 | QString::number(size ), storage); |
1012 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); | 985 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); |
1013 | } | 986 | } |
1014 | } | 987 | } |
1015 | 988 | ||
1016 | } | 989 | } |
1017 | 990 | ||
1018 | void PlayListWidget::populateVideoView() { | 991 | void PlayListWidget::populateVideoView() { |
1019 | videoView->clear(); | 992 | videoView->clear(); |
1020 | StorageInfo storageInfo; | 993 | StorageInfo storageInfo; |
1021 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 994 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
1022 | 995 | ||
1023 | if(!videoScan ) scanForVideo(); | 996 | if(!videoScan ) scanForVideo(); |
1024 | 997 | ||
1025 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 998 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
1026 | QListIterator<FileSystem> it ( fs ); | 999 | QListIterator<FileSystem> it ( fs ); |
1027 | videoView->clear(); | 1000 | videoView->clear(); |
1028 | QString storage; | 1001 | QString storage; |
1029 | for ( ; Vdit.current(); ++Vdit ) { | 1002 | for ( ; Vdit.current(); ++Vdit ) { |
1030 | for( ; it.current(); ++it ){ | 1003 | for( ; it.current(); ++it ){ |
1031 | const QString name = (*it)->name(); | 1004 | const QString name = (*it)->name(); |
1032 | const QString path = (*it)->path(); | 1005 | const QString path = (*it)->path(); |
1033 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 1006 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
1034 | } | 1007 | } |
1035 | 1008 | ||
1036 | QListViewItem * newItem; | 1009 | QListViewItem * newItem; |
1037 | if ( QFile( Vdit.current()->file()).exists() ) { | 1010 | if ( QFile( Vdit.current()->file()).exists() ) { |
1038 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 1011 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
1039 | QString::number( QFile( Vdit.current()->file()).size() ), storage); | 1012 | QString::number( QFile( Vdit.current()->file()).size() ), storage); |
1040 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); | 1013 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); |
1041 | } | 1014 | } |
1042 | } | 1015 | } |
1043 | } | 1016 | } |
1044 | 1017 | ||
1045 | void PlayListWidget::openFile() { | 1018 | void PlayListWidget::openFile() { |
1019 | qDebug("<<<<<<<<<OPEN File"); | ||
1046 | QString filename, name; | 1020 | QString filename, name; |
1047 | InputDialog *fileDlg; | 1021 | InputDialog *fileDlg; |
1048 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 1022 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
1049 | fileDlg->exec(); | 1023 | fileDlg->exec(); |
1050 | if( fileDlg->result() == 1 ) { | 1024 | if( fileDlg->result() == 1 ) { |
1051 | filename = fileDlg->LineEdit1->text(); | 1025 | filename = fileDlg->text(); |
1052 | // http://205.188.234.129:8030 | ||
1053 | // http://66.28.68.70:8000 | ||
1054 | // filename.replace(QRegExp("%20")," "); | ||
1055 | qDebug("Selected filename is "+filename); | 1026 | qDebug("Selected filename is "+filename); |
1056 | if(filename.right(3) == "m3u") | 1027 | // Om3u *m3uList; |
1028 | DocLnk lnk; | ||
1029 | Config cfg( "OpiePlayer" ); | ||
1030 | cfg.setGroup("PlayList"); | ||
1031 | |||
1032 | if(filename.left(4) == "http") { | ||
1033 | QString m3uFile, m3uFilePath; | ||
1034 | if(filename.find(":",8,TRUE) != -1) { //found a port | ||
1035 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | ||
1036 | m3uFile = m3uFile.right( 7); | ||
1037 | } else if(filename.left(4) == "http"){ | ||
1038 | m3uFile=filename; | ||
1039 | m3uFile = m3uFile.right( m3uFile.length() - 7); | ||
1040 | } else{ | ||
1041 | m3uFile=filename; | ||
1042 | } | ||
1043 | |||
1044 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); | ||
1045 | lnk.setName( filename ); //sets name | ||
1046 | lnk.setFile( filename ); //sets file name | ||
1047 | lnk.setIcon("opieplayer2/musicfile"); | ||
1048 | d->selectedFiles->addToSelection( lnk ); | ||
1049 | writeCurrentM3u(); | ||
1050 | } | ||
1051 | else if( filename.right( 3) == "m3u" ) { | ||
1057 | readm3u( filename); | 1052 | readm3u( filename); |
1058 | else if(filename.right(3) == "pls") | 1053 | |
1054 | } else if( filename.right(3) == "pls" ) { | ||
1059 | readPls( filename); | 1055 | readPls( filename); |
1060 | else { | 1056 | } else { |
1057 | d->selectedFiles->addToSelection( DocLnk(filename) ); | ||
1058 | writeCurrentM3u(); | ||
1059 | } | ||
1060 | } | ||
1061 | |||
1062 | if( fileDlg ) { | ||
1063 | delete fileDlg; | ||
1064 | } | ||
1065 | } | ||
1066 | |||
1067 | |||
1068 | /* | ||
1069 | reads m3u and shows files/urls to playlist widget */ | ||
1070 | void PlayListWidget::readm3u( const QString &filename ) { | ||
1071 | qDebug( "read m3u filename " + filename ); | ||
1072 | |||
1073 | Om3u *m3uList; | ||
1074 | QString s, name; | ||
1075 | m3uList = new Om3u( filename, IO_ReadOnly ); | ||
1076 | m3uList->readM3u(); | ||
1061 | DocLnk lnk; | 1077 | DocLnk lnk; |
1078 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | ||
1079 | s = *it; | ||
1080 | // qDebug("reading "+ s); | ||
1081 | if(s.left(4)=="http") { | ||
1082 | lnk.setName( s ); //sets file name | ||
1083 | lnk.setIcon("opieplayer2/musicfile"); | ||
1084 | if(s.right(4) != '.' || s.right(5) != '.') | ||
1085 | lnk.setFile( s+"/"); //if url with no extension | ||
1086 | else | ||
1087 | lnk.setFile( s ); //sets file name | ||
1088 | |||
1089 | } else { | ||
1090 | // if( QFileInfo( s ).exists() ) { | ||
1091 | lnk.setName( QFileInfo(s).baseName()); | ||
1092 | // if(s.right(4) == '.') {//if regular file | ||
1093 | if(s.left(1) != "/") { | ||
1094 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | ||
1095 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | ||
1096 | lnk.setIcon("SoundPlayer"); | ||
1097 | } else { | ||
1098 | // qDebug("set link2 "+s); | ||
1099 | lnk.setFile( s); | ||
1100 | lnk.setIcon("SoundPlayer"); | ||
1101 | } | ||
1102 | } | ||
1103 | d->selectedFiles->addToSelection( lnk ); | ||
1104 | } | ||
1105 | Config config( "OpiePlayer" ); | ||
1106 | config.setGroup( "PlayList" ); | ||
1107 | |||
1108 | config.writeEntry("CurrentPlaylist",filename); | ||
1109 | config.write(); | ||
1110 | currentPlayList=filename; | ||
1111 | |||
1112 | // m3uList->write(); | ||
1113 | m3uList->close(); | ||
1114 | if(m3uList) delete m3uList; | ||
1062 | 1115 | ||
1063 | lnk.setName(filename); //sets file name | 1116 | d->selectedFiles->setSelectedItem( s); |
1064 | if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3") | 1117 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
1065 | filename += "/"; | 1118 | |
1066 | lnk.setFile(filename); //sets File property | 1119 | } |
1067 | 1120 | ||
1121 | /* | ||
1122 | reads pls and adds files/urls to playlist */ | ||
1123 | void PlayListWidget::readPls( const QString &filename ) { | ||
1124 | |||
1125 | qDebug( "pls filename is " + filename ); | ||
1126 | Om3u *m3uList; | ||
1127 | QString s, name; | ||
1128 | m3uList = new Om3u( filename, IO_ReadOnly ); | ||
1129 | m3uList->readPls(); | ||
1130 | |||
1131 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | ||
1132 | s = *it; | ||
1133 | // s.replace( QRegExp( "%20" )," " ); | ||
1134 | DocLnk lnk( s ); | ||
1135 | QFileInfo f( s ); | ||
1136 | QString name = f.baseName(); | ||
1137 | |||
1138 | if( name.left( 4 ) == "http" ) { | ||
1139 | name = s.right( s.length() - 7); | ||
1140 | } else { | ||
1141 | name = s; | ||
1142 | } | ||
1143 | |||
1144 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | ||
1145 | |||
1146 | lnk.setName( name ); | ||
1147 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | ||
1148 | lnk.setFile( s ); | ||
1149 | } else { //if its a url | ||
1150 | if( name.right( 1 ).find( '/' ) == -1) { | ||
1151 | s += "/"; | ||
1152 | } | ||
1153 | lnk.setFile( s ); | ||
1154 | } | ||
1068 | lnk.setType("audio/x-mpegurl"); | 1155 | lnk.setType("audio/x-mpegurl"); |
1069 | lnk.setExec("opieplayer"); | ||
1070 | lnk.setIcon("opieplayer/MPEGPlayer"); | ||
1071 | 1156 | ||
1072 | if(!lnk.writeLink()) | 1157 | lnk.writeLink(); |
1073 | qDebug("Writing doclink did not work"); | ||
1074 | d->selectedFiles->addToSelection( lnk); | 1158 | d->selectedFiles->addToSelection( lnk); |
1075 | // if(fileDlg2) | ||
1076 | // delete fileDlg2; | ||
1077 | } | 1159 | } |
1160 | |||
1161 | m3uList->close(); | ||
1162 | if(m3uList) delete m3uList; | ||
1078 | } | 1163 | } |
1079 | if(fileDlg) | 1164 | |
1080 | delete fileDlg; | 1165 | /* |
1166 | writes current playlist to current m3u file */ | ||
1167 | void PlayListWidget::writeCurrentM3u() { | ||
1168 | qDebug("writing to current m3u"); | ||
1169 | Config cfg( "OpiePlayer" ); | ||
1170 | cfg.setGroup("PlayList"); | ||
1171 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | ||
1172 | |||
1173 | if( d->selectedFiles->first()) { | ||
1174 | Om3u *m3uList; | ||
1175 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | ||
1176 | |||
1177 | do { | ||
1178 | qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); | ||
1179 | m3uList->add( d->selectedFiles->current()->file() ); | ||
1180 | } | ||
1181 | while ( d->selectedFiles->next() ); | ||
1182 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | ||
1183 | m3uList->write(); | ||
1184 | m3uList->close(); | ||
1185 | |||
1186 | if(m3uList) delete m3uList; | ||
1187 | } | ||
1188 | } | ||
1189 | |||
1190 | /* | ||
1191 | writes current playlist to m3u file */ | ||
1192 | void PlayListWidget::writem3u() { | ||
1193 | InputDialog *fileDlg; | ||
1194 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | ||
1195 | fileDlg->exec(); | ||
1196 | QString name, filename, list; | ||
1197 | Om3u *m3uList; | ||
1198 | |||
1199 | if( fileDlg->result() == 1 ) { | ||
1200 | name = fileDlg->text(); | ||
1201 | // qDebug( filename ); | ||
1202 | |||
1203 | if( name.left( 1) != "/" ) { | ||
1204 | filename = QPEApplication::documentDir() + "/" + name; | ||
1205 | } | ||
1206 | |||
1207 | if( name.right( 3 ) != "m3u" ) { | ||
1208 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; | ||
1209 | } | ||
1210 | |||
1211 | if( d->selectedFiles->first()) { | ||
1212 | m3uList = new Om3u(filename, IO_ReadWrite); | ||
1213 | |||
1214 | do { | ||
1215 | m3uList->add( d->selectedFiles->current()->file()); | ||
1216 | } | ||
1217 | while ( d->selectedFiles->next() ); | ||
1218 | // qDebug( list ); | ||
1219 | m3uList->write(); | ||
1220 | m3uList->close(); | ||
1221 | if(m3uList) delete m3uList; | ||
1222 | |||
1223 | if(fileDlg) delete fileDlg; | ||
1224 | |||
1225 | DocLnk lnk; | ||
1226 | lnk.setFile( filename); | ||
1227 | lnk.setIcon("opieplayer2/playlist2"); | ||
1228 | lnk.setName( name); //sets file name | ||
1229 | |||
1230 | // qDebug(filename); | ||
1231 | Config config( "OpiePlayer" ); | ||
1232 | config.setGroup( "PlayList" ); | ||
1233 | |||
1234 | config.writeEntry("CurrentPlaylist",filename); | ||
1235 | currentPlayList=filename; | ||
1236 | |||
1237 | if(!lnk.writeLink()) { | ||
1238 | qDebug("Writing doclink did not work"); | ||
1081 | } | 1239 | } |
1082 | 1240 | ||
1241 | setCaption(tr("OpiePlayer: ") + name); | ||
1242 | } | ||
1243 | } | ||
1244 | } | ||
1245 | |||
1246 | |||
1083 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | 1247 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) |
1084 | { | 1248 | { |
1085 | switch ( e->key() ) { | 1249 | switch ( e->key() ) { |
1086 | ////////////////////////////// Zaurus keys | 1250 | ////////////////////////////// Zaurus keys |
1087 | case Key_F9: //activity | 1251 | case Key_F9: //activity |
1088 | // if(audioUI->isHidden()) | 1252 | // if(audioUI->isHidden()) |
1089 | // audioUI->showMaximized(); | 1253 | // audioUI->showMaximized(); |
1090 | break; | 1254 | break; |
1091 | case Key_F10: //contacts | 1255 | case Key_F10: //contacts |
1092 | // if( videoUI->isHidden()) | 1256 | // if( videoUI->isHidden()) |
1093 | // videoUI->showMaximized(); | 1257 | // videoUI->showMaximized(); |
1094 | break; | 1258 | break; |
1095 | case Key_F11: //menu | 1259 | case Key_F11: //menu |
1096 | break; | 1260 | break; |
1097 | case Key_F12: //home | 1261 | case Key_F12: //home |
1098 | // doBlank(); | 1262 | // doBlank(); |
1099 | break; | 1263 | break; |
1100 | case Key_F13: //mail | 1264 | case Key_F13: //mail |
1101 | // doUnblank(); | 1265 | // doUnblank(); |
1102 | break; | 1266 | break; |
1103 | case Key_Q: //add to playlist | 1267 | case Key_Q: //add to playlist |
1104 | qDebug("Add"); | 1268 | qDebug("Add"); |
1105 | addSelected(); | 1269 | addSelected(); |
1106 | break; | 1270 | break; |
@@ -1120,213 +1284,69 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | |||
1120 | break; | 1284 | break; |
1121 | case Key_2: | 1285 | case Key_2: |
1122 | tabWidget->setCurrentPage(1); | 1286 | tabWidget->setCurrentPage(1); |
1123 | break; | 1287 | break; |
1124 | case Key_3: | 1288 | case Key_3: |
1125 | tabWidget->setCurrentPage(2); | 1289 | tabWidget->setCurrentPage(2); |
1126 | break; | 1290 | break; |
1127 | case Key_4: | 1291 | case Key_4: |
1128 | tabWidget->setCurrentPage(3); | 1292 | tabWidget->setCurrentPage(3); |
1129 | break; | 1293 | break; |
1130 | case Key_Down: | 1294 | case Key_Down: |
1131 | if ( !d->selectedFiles->next() ) | 1295 | if ( !d->selectedFiles->next() ) |
1132 | d->selectedFiles->first(); | 1296 | d->selectedFiles->first(); |
1133 | 1297 | ||
1134 | break; | 1298 | break; |
1135 | case Key_Up: | 1299 | case Key_Up: |
1136 | if ( !d->selectedFiles->prev() ) | 1300 | if ( !d->selectedFiles->prev() ) |
1137 | // d->selectedFiles->last(); | 1301 | // d->selectedFiles->last(); |
1138 | 1302 | ||
1139 | break; | 1303 | break; |
1140 | 1304 | ||
1141 | } | 1305 | } |
1142 | } | 1306 | } |
1143 | 1307 | ||
1144 | void PlayListWidget::keyPressEvent( QKeyEvent *e) | 1308 | void PlayListWidget::keyPressEvent( QKeyEvent *) |
1145 | { | 1309 | { |
1146 | // qDebug("Key press"); | 1310 | // qDebug("Key press"); |
1147 | // switch ( e->key() ) { | 1311 | // switch ( e->key() ) { |
1148 | // ////////////////////////////// Zaurus keys | 1312 | // ////////////////////////////// Zaurus keys |
1149 | // case Key_A: //add to playlist | 1313 | // case Key_A: //add to playlist |
1150 | // qDebug("Add"); | 1314 | // qDebug("Add"); |
1151 | // addSelected(); | 1315 | // addSelected(); |
1152 | // break; | 1316 | // break; |
1153 | // case Key_R: //remove from playlist | 1317 | // case Key_R: //remove from playlist |
1154 | // removeSelected(); | 1318 | // removeSelected(); |
1155 | // break; | 1319 | // break; |
1156 | // case Key_P: //play | 1320 | // case Key_P: //play |
1157 | // qDebug("Play"); | 1321 | // qDebug("Play"); |
1158 | // playSelected(); | 1322 | // playSelected(); |
1159 | // break; | 1323 | // break; |
1160 | // case Key_Space: | 1324 | // case Key_Space: |
1161 | // qDebug("Play"); | 1325 | // qDebug("Play"); |
1162 | // playSelected(); | 1326 | // playSelected(); |
1163 | // break; | 1327 | // break; |
1164 | // } | 1328 | // } |
1165 | } | 1329 | } |
1166 | 1330 | ||
1167 | void PlayListWidget::doBlank() { | 1331 | void PlayListWidget::doBlank() { |
1168 | qDebug("do blanking"); | 1332 | qDebug("do blanking"); |
1169 | fd=open("/dev/fb0",O_RDWR); | 1333 | fd=open("/dev/fb0",O_RDWR); |
1170 | if (fd != -1) { | 1334 | if (fd != -1) { |
1171 | ioctl(fd,FBIOBLANK,1); | 1335 | ioctl(fd,FBIOBLANK,1); |
1172 | // close(fd); | 1336 | // close(fd); |
1173 | } | 1337 | } |
1174 | } | 1338 | } |
1175 | 1339 | ||
1176 | void PlayListWidget::doUnblank() { | 1340 | void PlayListWidget::doUnblank() { |
1177 | // this crashes opieplayer with a segfault | 1341 | // this crashes opieplayer with a segfault |
1178 | // int fd; | 1342 | // int fd; |
1179 | // fd=open("/dev/fb0",O_RDWR); | 1343 | // fd=open("/dev/fb0",O_RDWR); |
1180 | qDebug("do unblanking"); | 1344 | qDebug("do unblanking"); |
1181 | if (fd != -1) { | 1345 | if (fd != -1) { |
1182 | ioctl(fd,FBIOBLANK,0); | 1346 | ioctl(fd,FBIOBLANK,0); |
1183 | close(fd); | 1347 | close(fd); |
1184 | } | 1348 | } |
1185 | QCopEnvelope h("QPE/System", "setBacklight(int)"); | 1349 | QCopEnvelope h("QPE/System", "setBacklight(int)"); |
1186 | h <<-3;// v[1]; // -3 Force on | 1350 | h <<-3;// v[1]; // -3 Force on |
1187 | } | 1351 | } |
1188 | 1352 | ||
1189 | void PlayListWidget::readm3u(const QString &filename) { | ||
1190 | |||
1191 | qDebug("m3u filename is "+filename); | ||
1192 | QFile f(filename); | ||
1193 | |||
1194 | if(f.open(IO_ReadOnly)) { | ||
1195 | QTextStream t(&f); | ||
1196 | QString s;//, first, second; | ||
1197 | int i=0; | ||
1198 | while ( !t.atEnd()) { | ||
1199 | // Lview->insertLine(t.readLine(),-1); | ||
1200 | s=t.readLine(); | ||
1201 | |||
1202 | if(s.find("#",0,TRUE) == -1) { | ||
1203 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat | ||
1204 | if(s.left(2) == "E:" || s.left(2) == "P:") { | ||
1205 | s=s.right(s.length()-2); | ||
1206 | DocLnk lnk( s ); | ||
1207 | QFileInfo f(s); | ||
1208 | QString name = f.baseName(); | ||
1209 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | ||
1210 | lnk.setName( name); | ||
1211 | s=s.replace( QRegExp("\\"),"/"); | ||
1212 | lnk.setFile( s); | ||
1213 | lnk.writeLink(); | ||
1214 | // lnk.setIcon(opieplayer/MPEGPlayer); | ||
1215 | qDebug("add "+name); | ||
1216 | d->selectedFiles->addToSelection( lnk); | ||
1217 | } else { // is url | ||
1218 | |||
1219 | s.replace(QRegExp("%20")," "); | ||
1220 | DocLnk lnk( s); | ||
1221 | QString name; | ||
1222 | if(name.left(4)=="http") | ||
1223 | name = s.right( s.length() - 7); | ||
1224 | else | ||
1225 | name=s; | ||
1226 | // name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | ||
1227 | lnk.setName(name); | ||
1228 | if(s.at(s.length()-4) == '.') | ||
1229 | lnk.setFile( s); | ||
1230 | else | ||
1231 | lnk.setFile( s+"/"); | ||
1232 | // lnk.setFile( filename); | ||
1233 | // lnk.setComment( s+"/"); | ||
1234 | lnk.setType("audio/x-mpegurl"); | ||
1235 | lnk.writeLink(); | ||
1236 | // lnk.setIcon( "opieplayer/MPEGPlayer"); | ||
1237 | // qDebug("add "+s); | ||
1238 | d->selectedFiles->addToSelection( lnk); | ||
1239 | } | ||
1240 | i++; | ||
1241 | } | ||
1242 | } | ||
1243 | } | ||
1244 | } | ||
1245 | f.close(); | ||
1246 | } | ||
1247 | |||
1248 | void PlayListWidget::writem3u() { | ||
1249 | |||
1250 | InputDialog *fileDlg; | ||
1251 | fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); | ||
1252 | fileDlg->exec(); | ||
1253 | QString filename,list; | ||
1254 | if( fileDlg->result() == 1 ) { | ||
1255 | filename = fileDlg->LineEdit1->text(); | ||
1256 | qDebug(filename); | ||
1257 | int noOfFiles = 0; | ||
1258 | d->selectedFiles->first(); | ||
1259 | do { | ||
1260 | // we dont check for existance because of url's | ||
1261 | // qDebug(d->selectedFiles->current()->file()); | ||
1262 | list += d->selectedFiles->current()->file()+"\n"; | ||
1263 | noOfFiles++; | ||
1264 | } | ||
1265 | while ( d->selectedFiles->next() ); | ||
1266 | qDebug(list); | ||
1267 | if(filename.left(1) != "/") | ||
1268 | filename=QPEApplication::documentDir()+"/"+filename; | ||
1269 | if(filename.right(3) != "m3u") | ||
1270 | filename=filename+".m3u"; | ||
1271 | |||
1272 | QFile f(filename); | ||
1273 | f.open(IO_WriteOnly); | ||
1274 | f.writeBlock(list, list.length()); | ||
1275 | f.close(); | ||
1276 | } | ||
1277 | if(fileDlg) delete fileDlg; | ||
1278 | } | ||
1279 | |||
1280 | void PlayListWidget::readPls(const QString &filename) { | ||
1281 | |||
1282 | qDebug("pls filename is "+filename); | ||
1283 | QFile f(filename); | ||
1284 | |||
1285 | if(f.open(IO_ReadOnly)) { | ||
1286 | QTextStream t(&f); | ||
1287 | QString s;//, first, second; | ||
1288 | int i=0; | ||
1289 | while ( !t.atEnd()) { | ||
1290 | s=t.readLine(); | ||
1291 | if(s.left(4) == "File") { | ||
1292 | s=s.right(s.length() - 6); | ||
1293 | s.replace(QRegExp("%20")," "); | ||
1294 | qDebug("adding "+s+" to playlist"); | ||
1295 | // numberofentries=2 | ||
1296 | // File1=http | ||
1297 | // Title | ||
1298 | // Length | ||
1299 | // Version | ||
1300 | // File2=http | ||
1301 | |||
1302 | s=s.replace( QRegExp("\\"),"/"); | ||
1303 | DocLnk lnk( s ); | ||
1304 | QFileInfo f(s); | ||
1305 | QString name = f.baseName(); | ||
1306 | if(name.left(4)=="http") | ||
1307 | name = s.right( s.length() - 7); | ||
1308 | else | ||
1309 | name=s; | ||
1310 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | ||
1311 | // QFileInfo f(s); | ||
1312 | // QString name = f.baseName(); | ||
1313 | // name = name.left(name.length()-4); | ||
1314 | // name = name.right(name.findRev("/",0,TRUE)); | ||
1315 | lnk.setName( name); | ||
1316 | if(s.at(s.length()-4) == '.') // if this is probably a file | ||
1317 | lnk.setFile( s); | ||
1318 | else { //if its a url | ||
1319 | if( name.right(1).find('/') == -1) | ||
1320 | s+="/"; | ||
1321 | lnk.setFile( s); | ||
1322 | } | ||
1323 | lnk.setType("audio/x-mpegurl"); | ||
1324 | |||
1325 | qDebug("DocLnk add "+name); | ||
1326 | d->selectedFiles->addToSelection( lnk); | ||
1327 | } | ||
1328 | } | ||
1329 | i++; | ||
1330 | } | ||
1331 | } | ||
1332 | |||