author | zecke <zecke> | 2004-09-23 21:38:02 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-09-23 21:38:02 (UTC) |
commit | 97ab73d99688443d02086b4f00d1de7c81faa3c7 (patch) (unidiff) | |
tree | 63864e847abc41442d2ed88ca27a27ad1942c15a /noncore/multimedia/opieplayer2/playlistwidget.cpp | |
parent | 3080b2095fd9dddc4937cbf74037ce1dbc7fa6b2 (diff) | |
download | opie-97ab73d99688443d02086b4f00d1de7c81faa3c7.zip opie-97ab73d99688443d02086b4f00d1de7c81faa3c7.tar.gz opie-97ab73d99688443d02086b4f00d1de7c81faa3c7.tar.bz2 |
-Remove bogus whitespaces
-Remove stl dependency
-Make switching from fullscreen video to audio work
-Remove debug output
Diffstat (limited to 'noncore/multimedia/opieplayer2/playlistwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 36f77be..d73f0cd 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -163,73 +163,70 @@ PlayListWidget::PlayListWidget(QWidget* parent, const char* name, WFlags fl ) | |||
163 | tabWidget->showPage( playListTab ); | 163 | tabWidget->showPage( playListTab ); |
164 | } | 164 | } |
165 | 165 | ||
166 | 166 | ||
167 | PlayListWidget::~PlayListWidget() { | 167 | PlayListWidget::~PlayListWidget() { |
168 | delete d; | 168 | delete d; |
169 | delete m_mp; | 169 | delete m_mp; |
170 | } | 170 | } |
171 | 171 | ||
172 | 172 | ||
173 | void PlayListWidget::initializeStates() { | 173 | void PlayListWidget::initializeStates() { |
174 | d->tbPlay->setOn( mediaPlayerState->isPlaying() ); | 174 | d->tbPlay->setOn( mediaPlayerState->isPlaying() ); |
175 | d->tbLoop->setOn( mediaPlayerState->isLooping() ); | 175 | d->tbLoop->setOn( mediaPlayerState->isLooping() ); |
176 | d->tbShuffle->setOn( mediaPlayerState->isShuffled() ); | 176 | d->tbShuffle->setOn( mediaPlayerState->isShuffled() ); |
177 | d->playListFrame->show(); | 177 | d->playListFrame->show(); |
178 | } | 178 | } |
179 | 179 | ||
180 | void PlayListWidget::writeDefaultPlaylist() { | 180 | void PlayListWidget::writeDefaultPlaylist() { |
181 | 181 | ||
182 | Config config( "OpiePlayer" ); | 182 | Config config( "OpiePlayer" ); |
183 | config.setGroup( "PlayList" ); | 183 | config.setGroup( "PlayList" ); |
184 | QString filename=QPEApplication::documentDir() + "/default.m3u"; | 184 | QString filename=QPEApplication::documentDir() + "/default.m3u"; |
185 | QString currentString = config.readEntry( "CurrentPlaylist", filename); | 185 | QString currentString = config.readEntry( "CurrentPlaylist", filename); |
186 | if( currentString == filename) { | 186 | if( currentString == filename) { |
187 | Om3u *m3uList; | 187 | Om3u *m3uList; |
188 | // odebug << "<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>" << oendl; | ||
189 | if( d->selectedFiles->first() ) { | 188 | if( d->selectedFiles->first() ) { |
190 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 189 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
191 | do { | 190 | do { |
192 | // odebug << d->selectedFiles->current()->file() << oendl; | ||
193 | m3uList->add( d->selectedFiles->current()->file() ); | 191 | m3uList->add( d->selectedFiles->current()->file() ); |
194 | } | 192 | } |
195 | while ( d->selectedFiles->next() ); | 193 | while ( d->selectedFiles->next() ); |
196 | 194 | ||
197 | m3uList->write(); | 195 | m3uList->write(); |
198 | m3uList->close(); | 196 | m3uList->close(); |
199 | delete m3uList; | 197 | delete m3uList; |
200 | 198 | ||
201 | } | 199 | } |
202 | } | 200 | } |
203 | } | 201 | } |
204 | 202 | ||
205 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 203 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
206 | d->setDocumentUsed = FALSE; | 204 | d->setDocumentUsed = FALSE; |
207 | if( QFileInfo( lnk.file() ).exists() || | 205 | if( QFileInfo( lnk.file() ).exists() || |
208 | lnk.file().left(4) == "http" ) { | 206 | lnk.file().left(4) == "http" ) { |
209 | d->selectedFiles->addToSelection( lnk ); | 207 | d->selectedFiles->addToSelection( lnk ); |
210 | } | 208 | } |
211 | // writeCurrentM3u(); | ||
212 | } | 209 | } |
213 | 210 | ||
214 | 211 | ||
215 | void PlayListWidget::clearList() { | 212 | void PlayListWidget::clearList() { |
216 | while ( first() ) { | 213 | while ( first() ) { |
217 | d->selectedFiles->removeSelected(); | 214 | d->selectedFiles->removeSelected(); |
218 | } | 215 | } |
219 | Config cfg( "OpiePlayer" ); | 216 | Config cfg( "OpiePlayer" ); |
220 | cfg.setGroup("PlayList"); | 217 | cfg.setGroup("PlayList"); |
221 | cfg.writeEntry("CurrentPlaylist","default"); | 218 | cfg.writeEntry("CurrentPlaylist","default"); |
222 | setCaption("OpiePlayer"); | 219 | setCaption("OpiePlayer"); |
223 | } | 220 | } |
224 | 221 | ||
225 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 222 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
226 | switch (mouse) { | 223 | switch (mouse) { |
227 | case LeftButton: | 224 | case LeftButton: |
228 | break; | 225 | break; |
229 | case RightButton: | 226 | case RightButton: |
230 | { | 227 | { |
231 | QPopupMenu m; | 228 | QPopupMenu m; |
232 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 229 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
233 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 230 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
234 | m.exec( QCursor::pos() ); | 231 | m.exec( QCursor::pos() ); |
235 | } | 232 | } |
@@ -307,56 +304,56 @@ void PlayListWidget::addAllMusicToList() { | |||
307 | d->selectedFiles->first(); | 304 | d->selectedFiles->first(); |
308 | } | 305 | } |
309 | 306 | ||
310 | 307 | ||
311 | void PlayListWidget::addAllVideoToList() { | 308 | void PlayListWidget::addAllVideoToList() { |
312 | 309 | ||
313 | videoView->populateView(); | 310 | videoView->populateView(); |
314 | 311 | ||
315 | QListViewItemIterator videoIt( videoView ); | 312 | QListViewItemIterator videoIt( videoView ); |
316 | DocLnk lnk; | 313 | DocLnk lnk; |
317 | QString filename; | 314 | QString filename; |
318 | for ( ; videoIt.current(); ++videoIt ) { | 315 | for ( ; videoIt.current(); ++videoIt ) { |
319 | filename = videoIt.current()->text(3); | 316 | filename = videoIt.current()->text(3); |
320 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 317 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
321 | lnk.setFile( filename ); //sets file name | 318 | lnk.setFile( filename ); //sets file name |
322 | d->selectedFiles->addToSelection( lnk); | 319 | d->selectedFiles->addToSelection( lnk); |
323 | } | 320 | } |
324 | tabWidget->setCurrentPage(0); | 321 | tabWidget->setCurrentPage(0); |
325 | writeCurrentM3u(); | 322 | writeCurrentM3u(); |
326 | d->selectedFiles->first(); | 323 | d->selectedFiles->first(); |
327 | } | 324 | } |
328 | 325 | ||
329 | 326 | ||
330 | void PlayListWidget::setDocument( const QString& _fileref ) { | 327 | void PlayListWidget::setDocument( const QString& _fileref ) { |
331 | // odebug << "<<<<<<<<set document>>>>>>>>>> "+fileref << oendl; | 328 | // odebug << "<<<<<<<<set document>>>>>>>>>> "+fileref << oendl; |
332 | QString fileref = _fileref; | 329 | QString fileref = _fileref; |
333 | fromSetDocument = TRUE; | 330 | fromSetDocument = TRUE; |
334 | 331 | ||
335 | DocLnk lnk(_fileref); | 332 | DocLnk lnk(_fileref); |
336 | if(lnk.isValid()) | 333 | if(lnk.isValid()) |
337 | fileref = lnk.file(); | 334 | fileref = lnk.file(); |
338 | 335 | ||
339 | QFileInfo fileInfo(fileref); | 336 | QFileInfo fileInfo(fileref); |
340 | 337 | ||
341 | if ( !fileInfo.exists() ) { | 338 | if ( !fileInfo.exists() ) { |
342 | QMessageBox::warning( this, tr( "Invalid File" ), | 339 | QMessageBox::warning( this, tr( "Invalid File" ), |
343 | tr( "There was a problem in getting the file." ) ); | 340 | tr( "There was a problem in getting the file." ) ); |
344 | return; | 341 | return; |
345 | } | 342 | } |
346 | 343 | ||
347 | clearList(); | 344 | clearList(); |
348 | QString extension = fileInfo.extension(false); | 345 | QString extension = fileInfo.extension(false); |
349 | 346 | ||
350 | if( extension.find( "m3u", 0, false) != -1 | 347 | if( extension.find( "m3u", 0, false) != -1 |
351 | || extension.find( "pls", 0, false) != -1 ) { | 348 | || extension.find( "pls", 0, false) != -1 ) { |
352 | readListFromFile( fileref ); | 349 | readListFromFile( fileref ); |
353 | } else { | 350 | } else { |
354 | clearList(); | 351 | clearList(); |
355 | DocLnk lnk; | 352 | DocLnk lnk; |
356 | lnk.setName( fileInfo.baseName() ); //sets name | 353 | lnk.setName( fileInfo.baseName() ); //sets name |
357 | lnk.setFile( fileref ); //sets file name | 354 | lnk.setFile( fileref ); //sets file name |
358 | addToSelection( lnk ); | 355 | addToSelection( lnk ); |
359 | writeCurrentM3u(); | 356 | writeCurrentM3u(); |
360 | 357 | ||
361 | d->setDocumentUsed = TRUE; | 358 | d->setDocumentUsed = TRUE; |
362 | mediaPlayerState->setPlaying( FALSE ); | 359 | mediaPlayerState->setPlaying( FALSE ); |
@@ -389,49 +386,49 @@ bool PlayListWidget::prev() { | |||
389 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 386 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
390 | for ( int i = 0; i < j; i++ ) { | 387 | for ( int i = 0; i < j; i++ ) { |
391 | if ( !d->selectedFiles->next() ) | 388 | if ( !d->selectedFiles->next() ) |
392 | d->selectedFiles->first(); | 389 | d->selectedFiles->first(); |
393 | } | 390 | } |
394 | if ( cur == current() ) | 391 | if ( cur == current() ) |
395 | if ( !d->selectedFiles->next() ) { | 392 | if ( !d->selectedFiles->next() ) { |
396 | d->selectedFiles->first(); | 393 | d->selectedFiles->first(); |
397 | } | 394 | } |
398 | return TRUE; | 395 | return TRUE; |
399 | } else { | 396 | } else { |
400 | if ( !d->selectedFiles->prev() ) { | 397 | if ( !d->selectedFiles->prev() ) { |
401 | if ( mediaPlayerState->isLooping() ) { | 398 | if ( mediaPlayerState->isLooping() ) { |
402 | return d->selectedFiles->last(); | 399 | return d->selectedFiles->last(); |
403 | } else { | 400 | } else { |
404 | return FALSE; | 401 | return FALSE; |
405 | } | 402 | } |
406 | } | 403 | } |
407 | return TRUE; | 404 | return TRUE; |
408 | } | 405 | } |
409 | } | 406 | } |
410 | 407 | ||
411 | 408 | ||
412 | bool PlayListWidget::next() { | 409 | bool PlayListWidget::next() { |
413 | //odebug << "<<<<<<<<<<<<next()" << oendl; | 410 | //odebug << "<<<<<<<<<<<<next()" << oendl; |
414 | if ( mediaPlayerState->isShuffled() ) { | 411 | if ( mediaPlayerState->isShuffled() ) { |
415 | return prev(); | 412 | return prev(); |
416 | } else { | 413 | } else { |
417 | if ( !d->selectedFiles->next() ) { | 414 | if ( !d->selectedFiles->next() ) { |
418 | if ( mediaPlayerState->isLooping() ) { | 415 | if ( mediaPlayerState->isLooping() ) { |
419 | return d->selectedFiles->first(); | 416 | return d->selectedFiles->first(); |
420 | } else { | 417 | } else { |
421 | return FALSE; | 418 | return FALSE; |
422 | } | 419 | } |
423 | } | 420 | } |
424 | return TRUE; | 421 | return TRUE; |
425 | } | 422 | } |
426 | } | 423 | } |
427 | 424 | ||
428 | 425 | ||
429 | bool PlayListWidget::first() { | 426 | bool PlayListWidget::first() { |
430 | return d->selectedFiles->first(); | 427 | return d->selectedFiles->first(); |
431 | } | 428 | } |
432 | 429 | ||
433 | 430 | ||
434 | bool PlayListWidget::last() { | 431 | bool PlayListWidget::last() { |
435 | return d->selectedFiles->last(); | 432 | return d->selectedFiles->last(); |
436 | } | 433 | } |
437 | 434 | ||
@@ -600,49 +597,49 @@ void PlayListWidget::deletePlaylist() { | |||
600 | break; | 597 | break; |
601 | }; | 598 | }; |
602 | } | 599 | } |
603 | 600 | ||
604 | 601 | ||
605 | void PlayListWidget::playSelected() { | 602 | void PlayListWidget::playSelected() { |
606 | btnPlay( TRUE); | 603 | btnPlay( TRUE); |
607 | } | 604 | } |
608 | 605 | ||
609 | bool PlayListWidget::inFileListMode() const | 606 | bool PlayListWidget::inFileListMode() const |
610 | { | 607 | { |
611 | TabType tab = currentTab(); | 608 | TabType tab = currentTab(); |
612 | return tab == AudioFiles || tab == VideoFiles; | 609 | return tab == AudioFiles || tab == VideoFiles; |
613 | } | 610 | } |
614 | 611 | ||
615 | void PlayListWidget::openURL() { | 612 | void PlayListWidget::openURL() { |
616 | // http://66.28.164.33:2080 | 613 | // http://66.28.164.33:2080 |
617 | // http://somafm.com/star0242.m3u | 614 | // http://somafm.com/star0242.m3u |
618 | QString filename, name; | 615 | QString filename, name; |
619 | InputDialog *fileDlg; | 616 | InputDialog *fileDlg; |
620 | fileDlg = new InputDialog(this,tr("Add URL"),TRUE, 0); | 617 | fileDlg = new InputDialog(this,tr("Add URL"),TRUE, 0); |
621 | fileDlg->exec(); | 618 | fileDlg->exec(); |
622 | if( fileDlg->result() == 1 ) { | 619 | if( fileDlg->result() == 1 ) { |
623 | filename = fileDlg->text(); | 620 | filename = fileDlg->text(); |
624 | odebug << "Selected filename is " + filename << oendl; | 621 | odebug << "Selected filename is " + filename << oendl; |
625 | // Om3u *m3uList; | 622 | // Om3u *m3uList; |
626 | DocLnk lnk; | 623 | DocLnk lnk; |
627 | Config cfg( "OpiePlayer" ); | 624 | Config cfg( "OpiePlayer" ); |
628 | cfg.setGroup("PlayList"); | 625 | cfg.setGroup("PlayList"); |
629 | 626 | ||
630 | if(filename.left(4) == "http") { | 627 | if(filename.left(4) == "http") { |
631 | QString m3uFile, m3uFilePath; | 628 | QString m3uFile, m3uFilePath; |
632 | if(filename.find(":",8,TRUE) != -1) { //found a port | 629 | if(filename.find(":",8,TRUE) != -1) { //found a port |
633 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 630 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
634 | m3uFile = m3uFile.right( 7); | 631 | m3uFile = m3uFile.right( 7); |
635 | } else if(filename.left(4) == "http"){ | 632 | } else if(filename.left(4) == "http"){ |
636 | m3uFile=filename; | 633 | m3uFile=filename; |
637 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 634 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
638 | } else{ | 635 | } else{ |
639 | m3uFile=filename; | 636 | m3uFile=filename; |
640 | } | 637 | } |
641 | 638 | ||
642 | lnk.setName( filename ); //sets name | 639 | lnk.setName( filename ); //sets name |
643 | lnk.setFile( filename ); //sets file name | 640 | lnk.setFile( filename ); //sets file name |
644 | 641 | ||
645 | // lnk.setIcon("opieplayer2/musicfile"); | 642 | // lnk.setIcon("opieplayer2/musicfile"); |
646 | 643 | ||
647 | d->selectedFiles->addToSelection( lnk ); | 644 | d->selectedFiles->addToSelection( lnk ); |
648 | writeCurrentM3u(); | 645 | writeCurrentM3u(); |
@@ -676,305 +673,305 @@ void PlayListWidget::openFile() { | |||
676 | audio << "playlist/plain"; | 673 | audio << "playlist/plain"; |
677 | audio << "audio/x-ogg"; | 674 | audio << "audio/x-ogg"; |
678 | audio << "audio/x-mpegurl"; | 675 | audio << "audio/x-mpegurl"; |
679 | 676 | ||
680 | video << "video/*"; | 677 | video << "video/*"; |
681 | video << "playlist/plain"; | 678 | video << "playlist/plain"; |
682 | 679 | ||
683 | all += audio; | 680 | all += audio; |
684 | all += video; | 681 | all += video; |
685 | types.insert("All Media Files", all ); | 682 | types.insert("All Media Files", all ); |
686 | types.insert("Audio", audio ); | 683 | types.insert("Audio", audio ); |
687 | types.insert("Video", video ); | 684 | types.insert("Video", video ); |
688 | 685 | ||
689 | QString str = OFileDialog::getOpenFileName( 1, | 686 | QString str = OFileDialog::getOpenFileName( 1, |
690 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", | 687 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", |
691 | types, 0 ); | 688 | types, 0 ); |
692 | 689 | ||
693 | if(str.left(2) == "//") { | 690 | if(str.left(2) == "//") { |
694 | str=str.right(str.length()-1); | 691 | str=str.right(str.length()-1); |
695 | } | 692 | } |
696 | cfg.writeEntry( "LastDirectory" ,QFileInfo( str ).dirPath() ); | 693 | cfg.writeEntry( "LastDirectory" ,QFileInfo( str ).dirPath() ); |
697 | 694 | ||
698 | if( !str.isEmpty() ) { | 695 | if( !str.isEmpty() ) { |
699 | 696 | ||
700 | odebug << "Selected filename is " + str << oendl; | 697 | odebug << "Selected filename is " + str << oendl; |
701 | filename = str; | 698 | filename = str; |
702 | DocLnk lnk; | 699 | DocLnk lnk; |
703 | 700 | ||
704 | if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { | 701 | if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { |
705 | readListFromFile( filename ); | 702 | readListFromFile( filename ); |
706 | } else { | 703 | } else { |
707 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 704 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
708 | lnk.setFile( filename ); //sets file name | 705 | lnk.setFile( filename ); //sets file name |
709 | d->selectedFiles->addToSelection( lnk ); | 706 | d->selectedFiles->addToSelection( lnk ); |
710 | writeCurrentM3u(); | 707 | writeCurrentM3u(); |
711 | d->selectedFiles->setSelectedItem( lnk.name() ); | 708 | d->selectedFiles->setSelectedItem( lnk.name() ); |
712 | } | 709 | } |
713 | } | 710 | } |
714 | } | 711 | } |
715 | 712 | ||
716 | 713 | ||
717 | void PlayListWidget::readListFromFile( const QString &filename ) { | 714 | void PlayListWidget::readListFromFile( const QString &filename ) { |
718 | odebug << "read list filename " + filename << oendl; | 715 | odebug << "read list filename " + filename << oendl; |
719 | QFileInfo fi(filename); | 716 | QFileInfo fi(filename); |
720 | Om3u *m3uList; | 717 | Om3u *m3uList; |
721 | QString s, name; | 718 | QString s, name; |
722 | m3uList = new Om3u( filename, IO_ReadOnly ); | 719 | m3uList = new Om3u( filename, IO_ReadOnly ); |
723 | if(fi.extension(false).find("m3u",0,false) != -1 ) | 720 | if(fi.extension(false).find("m3u",0,false) != -1 ) |
724 | m3uList->readM3u(); | 721 | m3uList->readM3u(); |
725 | else if(fi.extension(false).find("pls",0,false) != -1 ) | 722 | else if(fi.extension(false).find("pls",0,false) != -1 ) |
726 | m3uList->readPls(); | 723 | m3uList->readPls(); |
727 | 724 | ||
728 | DocLnk lnk; | 725 | DocLnk lnk; |
729 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 726 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
730 | s = *it; | 727 | s = *it; |
731 | // odebug << s << oendl; | 728 | // odebug << s << oendl; |
732 | if(s.left(4)=="http") { | 729 | if(s.left(4)=="http") { |
733 | lnk.setName( s ); //sets file name | 730 | lnk.setName( s ); //sets file name |
734 | lnk.setIcon("opieplayer2/musicfile"); | 731 | lnk.setIcon("opieplayer2/musicfile"); |
735 | lnk.setFile( s ); //sets file name | 732 | lnk.setFile( s ); //sets file name |
736 | 733 | ||
737 | } else { //is file | 734 | } else { //is file |
738 | lnk.setName( QFileInfo(s).baseName()); | 735 | lnk.setName( QFileInfo(s).baseName()); |
739 | if(s.left(1) != "/") { | 736 | if(s.left(1) != "/") { |
740 | 737 | ||
741 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 738 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
742 | } else { | 739 | } else { |
743 | lnk.setFile( s); | 740 | lnk.setFile( s); |
744 | } | 741 | } |
745 | } | 742 | } |
746 | d->selectedFiles->addToSelection( lnk ); | 743 | d->selectedFiles->addToSelection( lnk ); |
747 | } | 744 | } |
748 | Config config( "OpiePlayer" ); | 745 | Config config( "OpiePlayer" ); |
749 | config.setGroup( "PlayList" ); | 746 | config.setGroup( "PlayList" ); |
750 | 747 | ||
751 | config.writeEntry("CurrentPlaylist",filename); | 748 | config.writeEntry("CurrentPlaylist",filename); |
752 | config.write(); | 749 | config.write(); |
753 | currentPlayList=filename; | 750 | currentPlayList=filename; |
754 | 751 | ||
755 | m3uList->close(); | 752 | m3uList->close(); |
756 | delete m3uList; | 753 | delete m3uList; |
757 | 754 | ||
758 | d->selectedFiles->setSelectedItem( s); | 755 | d->selectedFiles->setSelectedItem( s); |
759 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 756 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
760 | 757 | ||
761 | } | 758 | } |
762 | 759 | ||
763 | // writes current playlist to current m3u file */ | 760 | // writes current playlist to current m3u file */ |
764 | void PlayListWidget::writeCurrentM3u() { | 761 | void PlayListWidget::writeCurrentM3u() { |
765 | odebug << "writing to current m3u" << oendl; | 762 | odebug << "writing to current m3u" << oendl; |
766 | Config cfg( "OpiePlayer" ); | 763 | Config cfg( "OpiePlayer" ); |
767 | cfg.setGroup("PlayList"); | 764 | cfg.setGroup("PlayList"); |
768 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 765 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
769 | 766 | ||
770 | Om3u *m3uList; | 767 | Om3u *m3uList; |
771 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 768 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
772 | if( d->selectedFiles->first()) { | 769 | if( d->selectedFiles->first()) { |
773 | 770 | ||
774 | do { | 771 | do { |
775 | // odebug << "add writeCurrentM3u " +d->selectedFiles->current()->file() << oendl; | 772 | // odebug << "add writeCurrentM3u " +d->selectedFiles->current()->file() << oendl; |
776 | m3uList->add( d->selectedFiles->current()->file() ); | 773 | m3uList->add( d->selectedFiles->current()->file() ); |
777 | } | 774 | } |
778 | while ( d->selectedFiles->next() ); | 775 | while ( d->selectedFiles->next() ); |
779 | // odebug << "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" << oendl; | 776 | // odebug << "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" << oendl; |
780 | m3uList->write(); | 777 | m3uList->write(); |
781 | m3uList->close(); | 778 | m3uList->close(); |
782 | } | 779 | } |
783 | delete m3uList; | 780 | delete m3uList; |
784 | 781 | ||
785 | } | 782 | } |
786 | 783 | ||
787 | /* | 784 | /* |
788 | writes current playlist to m3u file */ | 785 | writes current playlist to m3u file */ |
789 | void PlayListWidget::writem3u() { | 786 | void PlayListWidget::writem3u() { |
790 | //InputDilog *fileDlg; | 787 | //InputDilog *fileDlg; |
791 | //fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 788 | //fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
792 | //fileDlg->exec(); | 789 | //fileDlg->exec(); |
793 | 790 | ||
794 | Config cfg( "OpiePlayer" ); | 791 | Config cfg( "OpiePlayer" ); |
795 | cfg.setGroup("Dialog"); | 792 | cfg.setGroup("Dialog"); |
796 | MimeTypes types; | 793 | MimeTypes types; |
797 | QStringList audio, video, all; | 794 | QStringList audio, video, all; |
798 | audio << "audio/*"; | 795 | audio << "audio/*"; |
799 | audio << "playlist/plain"; | 796 | audio << "playlist/plain"; |
800 | audio << "audio/x-mpegurl"; | 797 | audio << "audio/x-mpegurl"; |
801 | 798 | ||
802 | video << "video/*"; | 799 | video << "video/*"; |
803 | video << "playlist/plain"; | 800 | video << "playlist/plain"; |
804 | 801 | ||
805 | all += audio; | 802 | all += audio; |
806 | all += video; | 803 | all += video; |
807 | types.insert("All Media Files", all ); | 804 | types.insert("All Media Files", all ); |
808 | types.insert("Audio", audio ); | 805 | types.insert("Audio", audio ); |
809 | types.insert("Video", video ); | 806 | types.insert("Video", video ); |
810 | 807 | ||
811 | QString str = OFileDialog::getOpenFileName( 1, | 808 | QString str = OFileDialog::getOpenFileName( 1, |
812 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", | 809 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", |
813 | types, 0 ); | 810 | types, 0 ); |
814 | if(str.left(2) == "//") str=str.right(str.length()-1); | 811 | if(str.left(2) == "//") str=str.right(str.length()-1); |
815 | cfg.writeEntry("LastDirectory" ,QFileInfo(str).dirPath()); | 812 | cfg.writeEntry("LastDirectory" ,QFileInfo(str).dirPath()); |
816 | 813 | ||
817 | 814 | ||
818 | QString name, filename, list; | 815 | QString name, filename, list; |
819 | Om3u *m3uList; | 816 | Om3u *m3uList; |
820 | 817 | ||
821 | if( !str.isEmpty() ) { | 818 | if( !str.isEmpty() ) { |
822 | name = str; | 819 | name = str; |
823 | // name = fileDlg->text(); | 820 | // name = fileDlg->text(); |
824 | // odebug << filename << oendl; | 821 | // odebug << filename << oendl; |
825 | if( name.find("/",0,true) != -1) {// assume they specify a file path | 822 | if( name.find("/",0,true) != -1) {// assume they specify a file path |
826 | filename = name; | 823 | filename = name; |
827 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); | 824 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); |
828 | } | 825 | } |
829 | else //otherwise dump it somewhere noticable | 826 | else //otherwise dump it somewhere noticable |
830 | filename = QPEApplication::documentDir() + "/" + name; | 827 | filename = QPEApplication::documentDir() + "/" + name; |
831 | 828 | ||
832 | if( filename.right( 3 ) != "m3u" ) //needs filename extension | 829 | if( filename.right( 3 ) != "m3u" ) //needs filename extension |
833 | filename += ".m3u"; | 830 | filename += ".m3u"; |
834 | 831 | ||
835 | if( d->selectedFiles->first()) { //ramble through playlist view | 832 | if( d->selectedFiles->first()) { //ramble through playlist view |
836 | m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate); | 833 | m3uList = new Om3u( filename, IO_ReadWrite | IO_Truncate); |
837 | 834 | ||
838 | do { | 835 | do { |
839 | m3uList->add( d->selectedFiles->current()->file()); | 836 | m3uList->add( d->selectedFiles->current()->file()); |
840 | } | 837 | } |
841 | while ( d->selectedFiles->next() ); | 838 | while ( d->selectedFiles->next() ); |
842 | // odebug << list << oendl; | 839 | // odebug << list << oendl; |
843 | m3uList->write(); | 840 | m3uList->write(); |
844 | m3uList->close(); | 841 | m3uList->close(); |
845 | delete m3uList; | 842 | delete m3uList; |
846 | 843 | ||
847 | //delete fileDlg; | 844 | //delete fileDlg; |
848 | 845 | ||
849 | DocLnk lnk; | 846 | DocLnk lnk; |
850 | lnk.setFile( filename); | 847 | lnk.setFile( filename); |
851 | lnk.setIcon("opieplayer2/playlist2"); | 848 | lnk.setIcon("opieplayer2/playlist2"); |
852 | lnk.setName( name); //sets file name | 849 | lnk.setName( name); //sets file name |
853 | 850 | ||
854 | // odebug << filename << oendl; | 851 | // odebug << filename << oendl; |
855 | Config config( "OpiePlayer" ); | 852 | Config config( "OpiePlayer" ); |
856 | config.setGroup( "PlayList" ); | 853 | config.setGroup( "PlayList" ); |
857 | 854 | ||
858 | config.writeEntry("CurrentPlaylist",filename); | 855 | config.writeEntry("CurrentPlaylist",filename); |
859 | currentPlayList=filename; | 856 | currentPlayList=filename; |
860 | 857 | ||
861 | if(!lnk.writeLink()) { | 858 | if(!lnk.writeLink()) { |
862 | odebug << "Writing doclink did not work" << oendl; | 859 | odebug << "Writing doclink did not work" << oendl; |
863 | } | 860 | } |
864 | 861 | ||
865 | setCaption(tr("OpiePlayer: ") + name); | 862 | setCaption(tr("OpiePlayer: ") + name); |
866 | } | 863 | } |
867 | } | 864 | } |
868 | } | 865 | } |
869 | 866 | ||
870 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 867 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
871 | switch ( e->key() ) { | 868 | switch ( e->key() ) { |
872 | ////////////////////////////// Zaurus keys | 869 | ////////////////////////////// Zaurus keys |
873 | case Key_F9: //activity | 870 | case Key_F9: //activity |
874 | // if(audioUI->isHidden()) | 871 | // if(audioUI->isHidden()) |
875 | // audioUI->showMaximized(); | 872 | // audioUI->showMaximized(); |
876 | break; | 873 | break; |
877 | case Key_F10: //contacts | 874 | case Key_F10: //contacts |
878 | // if( videoUI->isHidden()) | 875 | // if( videoUI->isHidden()) |
879 | // videoUI->showMaximized(); | 876 | // videoUI->showMaximized(); |
880 | break; | 877 | break; |
881 | case Key_F11: //menu | 878 | case Key_F11: //menu |
882 | break; | 879 | break; |
883 | case Key_F12: //home | 880 | case Key_F12: //home |
884 | // doBlank(); | 881 | // doBlank(); |
885 | break; | 882 | break; |
886 | case Key_F13: //mail | 883 | case Key_F13: //mail |
887 | // doUnblank(); | 884 | // doUnblank(); |
888 | break; | 885 | break; |
889 | case Key_Q: //add to playlist | 886 | case Key_Q: //add to playlist |
890 | addSelected(); | 887 | addSelected(); |
891 | break; | 888 | break; |
892 | case Key_R: //remove from playlist | 889 | case Key_R: //remove from playlist |
893 | removeSelected(); | 890 | removeSelected(); |
894 | break; | 891 | break; |
895 | // case Key_P: //play | 892 | // case Key_P: //play |
896 | // odebug << "Play" << oendl; | 893 | // odebug << "Play" << oendl; |
897 | // playSelected(); | 894 | // playSelected(); |
898 | // break; | 895 | // break; |
899 | case Key_Space: | 896 | case Key_Space: |
900 | // playSelected(); puh | 897 | // playSelected(); puh |
901 | break; | 898 | break; |
902 | case Key_1: | 899 | case Key_1: |
903 | tabWidget->setCurrentPage( 0 ); | 900 | tabWidget->setCurrentPage( 0 ); |
904 | break; | 901 | break; |
905 | case Key_2: | 902 | case Key_2: |
906 | tabWidget->setCurrentPage( 1 ); | 903 | tabWidget->setCurrentPage( 1 ); |
907 | break; | 904 | break; |
908 | case Key_3: | 905 | case Key_3: |
909 | tabWidget->setCurrentPage( 2 ); | 906 | tabWidget->setCurrentPage( 2 ); |
910 | break; | 907 | break; |
911 | case Key_4: | 908 | case Key_4: |
912 | tabWidget->setCurrentPage( 3 ); | 909 | tabWidget->setCurrentPage( 3 ); |
913 | break; | 910 | break; |
914 | case Key_Down: | 911 | case Key_Down: |
915 | if ( !d->selectedFiles->next() ) | 912 | if ( !d->selectedFiles->next() ) |
916 | d->selectedFiles->first(); | 913 | d->selectedFiles->first(); |
917 | break; | 914 | break; |
918 | case Key_Up: | 915 | case Key_Up: |
919 | if ( !d->selectedFiles->prev() ) | 916 | if ( !d->selectedFiles->prev() ) |
920 | // d->selectedFiles->last(); | 917 | // d->selectedFiles->last(); |
921 | break; | 918 | break; |
922 | } | 919 | } |
923 | } | 920 | } |
924 | 921 | ||
925 | void PlayListWidget::pmViewActivated(int index) { | 922 | void PlayListWidget::pmViewActivated(int index) { |
926 | // odebug << "" << index << "" << oendl; | 923 | // odebug << "" << index << "" << oendl; |
927 | switch(index) { | 924 | switch(index) { |
928 | case -16: | 925 | case -16: |
929 | { | 926 | { |
930 | mediaPlayerState->toggleFullscreen(); | 927 | mediaPlayerState->toggleFullscreen(); |
931 | bool b=mediaPlayerState->isFullscreen(); | 928 | bool b=mediaPlayerState->isFullscreen(); |
932 | pmView->setItemChecked( index, b); | 929 | pmView->setItemChecked( index, b); |
933 | Config cfg( "OpiePlayer" ); | 930 | Config cfg( "OpiePlayer" ); |
934 | cfg.writeEntry( "FullScreen", b ); | 931 | cfg.writeEntry( "FullScreen", b ); |
935 | } | 932 | } |
936 | break; | 933 | break; |
937 | }; | 934 | }; |
938 | } | 935 | } |
939 | 936 | ||
940 | void PlayListWidget::populateSkinsMenu() { | 937 | void PlayListWidget::populateSkinsMenu() { |
941 | int item = 0; | 938 | int item = 0; |
942 | defaultSkinIndex = 0; | 939 | defaultSkinIndex = 0; |
943 | QString skinName; | 940 | QString skinName; |
944 | Config cfg( "OpiePlayer" ); | 941 | Config cfg( "OpiePlayer" ); |
945 | cfg.setGroup("Options" ); | 942 | cfg.setGroup("Options" ); |
946 | QString skin = cfg.readEntry( "Skin", "default" ); | 943 | QString skin = cfg.readEntry( "Skin", "default" ); |
947 | 944 | ||
948 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 945 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
949 | skinsDir.setFilter( QDir::Dirs ); | 946 | skinsDir.setFilter( QDir::Dirs ); |
950 | skinsDir.setSorting(QDir::Name ); | 947 | skinsDir.setSorting(QDir::Name ); |
951 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 948 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
952 | QFileInfoListIterator it( *skinslist ); | 949 | QFileInfoListIterator it( *skinslist ); |
953 | QFileInfo *fi; | 950 | QFileInfo *fi; |
954 | while ( ( fi = it.current() ) ) { | 951 | while ( ( fi = it.current() ) ) { |
955 | skinName = fi->fileName(); | 952 | skinName = fi->fileName(); |
956 | // odebug << fi->fileName() << oendl; | 953 | // odebug << fi->fileName() << oendl; |
957 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 954 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
958 | item = skinsMenu->insertItem( fi->fileName() ) ; | 955 | item = skinsMenu->insertItem( fi->fileName() ) ; |
959 | } | 956 | } |
960 | if( skinName == "default" ) { | 957 | if( skinName == "default" ) { |
961 | defaultSkinIndex = item; | 958 | defaultSkinIndex = item; |
962 | } | 959 | } |
963 | if( skinName == skin ) { | 960 | if( skinName == skin ) { |
964 | skinsMenu->setItemChecked( item, TRUE ); | 961 | skinsMenu->setItemChecked( item, TRUE ); |
965 | } | 962 | } |
966 | ++it; | 963 | ++it; |
967 | } | 964 | } |
968 | } | 965 | } |
969 | 966 | ||
970 | void PlayListWidget::skinsMenuActivated( int item ) { | 967 | void PlayListWidget::skinsMenuActivated( int item ) { |
971 | for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 968 | for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
972 | skinsMenu->setItemChecked( i, FALSE ); | 969 | skinsMenu->setItemChecked( i, FALSE ); |
973 | } | 970 | } |
974 | skinsMenu->setItemChecked( item, TRUE ); | 971 | skinsMenu->setItemChecked( item, TRUE ); |
975 | 972 | ||
976 | { | 973 | { |
977 | Config cfg( "OpiePlayer" ); | 974 | Config cfg( "OpiePlayer" ); |
978 | cfg.setGroup("Options"); | 975 | cfg.setGroup("Options"); |
979 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 976 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
980 | } | 977 | } |
@@ -988,49 +985,49 @@ PlayListWidget::TabType PlayListWidget::currentTab() const | |||
988 | { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; | 985 | { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; |
989 | 986 | ||
990 | int index = tabWidget->currentPageIndex(); | 987 | int index = tabWidget->currentPageIndex(); |
991 | assert( index < TabTypeCount && index >= 0 ); | 988 | assert( index < TabTypeCount && index >= 0 ); |
992 | 989 | ||
993 | return indexToTabType[ index ]; | 990 | return indexToTabType[ index ]; |
994 | } | 991 | } |
995 | 992 | ||
996 | PlayListWidget::Entry PlayListWidget::currentEntry() const | 993 | PlayListWidget::Entry PlayListWidget::currentEntry() const |
997 | { | 994 | { |
998 | if ( currentTab() == CurrentPlayList ) { | 995 | if ( currentTab() == CurrentPlayList ) { |
999 | const DocLnk *lnk = current(); | 996 | const DocLnk *lnk = current(); |
1000 | return Entry( lnk->name(), lnk->file() ); | 997 | return Entry( lnk->name(), lnk->file() ); |
1001 | } | 998 | } |
1002 | 999 | ||
1003 | return Entry( currentFileListPathName() ); | 1000 | return Entry( currentFileListPathName() ); |
1004 | } | 1001 | } |
1005 | 1002 | ||
1006 | QString PlayListWidget::currentFileListPathName() const { | 1003 | QString PlayListWidget::currentFileListPathName() const { |
1007 | return currentFileListView->currentItem()->text( 3 ); | 1004 | return currentFileListView->currentItem()->text( 3 ); |
1008 | } | 1005 | } |
1009 | 1006 | ||
1010 | 1007 | ||
1011 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { | 1008 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { |
1012 | odebug << "qcop message "+msg << oendl; | 1009 | odebug << "qcop message "+msg << oendl; |
1013 | QDataStream stream ( data, IO_ReadOnly ); | 1010 | QDataStream stream ( data, IO_ReadOnly ); |
1014 | if ( msg == "play()" ) { //plays current selection | 1011 | if ( msg == "play()" ) { //plays current selection |
1015 | btnPlay( true); | 1012 | btnPlay( true); |
1016 | } else if ( msg == "stop()" ) { | 1013 | } else if ( msg == "stop()" ) { |
1017 | mediaPlayerState->setPlaying( false); | 1014 | mediaPlayerState->setPlaying( false); |
1018 | } else if ( msg == "togglePause()" ) { | 1015 | } else if ( msg == "togglePause()" ) { |
1019 | mediaPlayerState->togglePaused(); | 1016 | mediaPlayerState->togglePaused(); |
1020 | } else if ( msg == "next()" ) { //select next in list | 1017 | } else if ( msg == "next()" ) { //select next in list |
1021 | mediaPlayerState->setNext(); | 1018 | mediaPlayerState->setNext(); |
1022 | } else if ( msg == "prev()" ) { //select previous in list | 1019 | } else if ( msg == "prev()" ) { //select previous in list |
1023 | mediaPlayerState->setPrev(); | 1020 | mediaPlayerState->setPrev(); |
1024 | } else if ( msg == "toggleLooping()" ) { //loop or not loop | 1021 | } else if ( msg == "toggleLooping()" ) { //loop or not loop |
1025 | mediaPlayerState->toggleLooping(); | 1022 | mediaPlayerState->toggleLooping(); |
1026 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled | 1023 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled |
1027 | mediaPlayerState->toggleShuffled(); | 1024 | mediaPlayerState->toggleShuffled(); |
1028 | } else if ( msg == "volUp()" ) { //volume more | 1025 | } else if ( msg == "volUp()" ) { //volume more |
1029 | // emit moreClicked(); | 1026 | // emit moreClicked(); |
1030 | // emit moreReleased(); | 1027 | // emit moreReleased(); |
1031 | } else if ( msg == "volDown()" ) { //volume less | 1028 | } else if ( msg == "volDown()" ) { //volume less |
1032 | // emit lessClicked(); | 1029 | // emit lessClicked(); |
1033 | // emit lessReleased(); | 1030 | // emit lessReleased(); |
1034 | } else if ( msg == "play(QString)" ) { //play this now | 1031 | } else if ( msg == "play(QString)" ) { //play this now |
1035 | QString file; | 1032 | QString file; |
1036 | stream >> file; | 1033 | stream >> file; |