author | llornkcor <llornkcor> | 2003-06-11 22:11:38 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-06-11 22:11:38 (UTC) |
commit | 24097a2790fd7bb241a0a8da24ef2996e4f4ad15 (patch) (unidiff) | |
tree | 142e0fb758067bc9a601b3bd2dabdff27675c0f3 /core/multimedia/opieplayer/playlistwidget.cpp | |
parent | 188319af82322c84f02e1abb848d908ca8f9e26c (diff) | |
download | opie-24097a2790fd7bb241a0a8da24ef2996e4f4ad15.zip opie-24097a2790fd7bb241a0a8da24ef2996e4f4ad15.tar.gz opie-24097a2790fd7bb241a0a8da24ef2996e4f4ad15.tar.bz2 |
fix setDoc for playlists and others. remove qDebugs
Diffstat (limited to 'core/multimedia/opieplayer/playlistwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 1300 |
1 files changed, 636 insertions, 664 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 7ea95ab..1fc7dd8 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -306,15 +306,14 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
306 | tabWidget->insertTab( vTab,tr("Video")); | 306 | tabWidget->insertTab( vTab,tr("Video")); |
307 | 307 | ||
308 | QWidget *LTab; | 308 | QWidget *LTab; |
309 | LTab = new QWidget( tabWidget, "LTab" ); | 309 | LTab = new QWidget( tabWidget, "LTab" ); |
310 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | 310 | playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE); |
311 | 311 | ||
312 | QGridLayout *layoutL = new QGridLayout( LTab ); | 312 | QGridLayout *layoutL = new QGridLayout( LTab ); |
313 | layoutL->setSpacing( 2); | 313 | layoutL->setSpacing( 2); |
314 | layoutL->setMargin( 2); | 314 | layoutL->setMargin( 2); |
315 | layoutL->addMultiCellWidget( playLists, 0, 0, 0, 1 ); | 315 | layoutL->addMultiCellWidget( playLists, 0, 0, 0, 1 ); |
316 | // playLists->setMinimumSize(233,260); | ||
317 | 316 | ||
318 | tabWidget->insertTab(LTab,tr("Lists")); | 317 | tabWidget->insertTab(LTab,tr("Lists")); |
319 | 318 | ||
320 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); | 319 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); |
@@ -357,14 +356,14 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
357 | setCentralWidget( vbox5 ); | 356 | setCentralWidget( vbox5 ); |
358 | 357 | ||
359 | Config cfg( "OpiePlayer" ); | 358 | Config cfg( "OpiePlayer" ); |
360 | readConfig( cfg ); | 359 | readConfig( cfg ); |
361 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 360 | |
362 | loadList(DocLnk( currentPlaylist)); | 361 | currentPlayList = cfg.readEntry("CurrentPlaylist","default"); |
363 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlaylist))); | 362 | loadList(DocLnk( currentPlayList)); |
363 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlayList))); | ||
364 | 364 | ||
365 | initializeStates(); | 365 | initializeStates(); |
366 | // audioUI->setFocus(); | ||
367 | } | 366 | } |
368 | 367 | ||
369 | 368 | ||
370 | PlayListWidget::~PlayListWidget() { | 369 | PlayListWidget::~PlayListWidget() { |
@@ -420,17 +419,18 @@ void PlayListWidget::writeConfig( Config& cfg ) const { | |||
420 | // next time... | 419 | // next time... |
421 | if ( !QFile::exists( lnk->linkFile() ) ) { | 420 | if ( !QFile::exists( lnk->linkFile() ) ) { |
422 | // the way writing lnks doesn't really check for out | 421 | // the way writing lnks doesn't really check for out |
423 | // of disk space, but check it anyway. | 422 | // of disk space, but check it anyway. |
424 | if ( !lnk->writeLink() ) { | 423 | // if ( !lnk->writeLink() ) { |
425 | QMessageBox::critical( 0, tr("Out of space"), | 424 | // QMessageBox::critical( 0, tr("Out of space"), |
426 | tr( "There was a problem saving " | 425 | // tr( "There was a problem saving " |
427 | "the playlist.\n" | 426 | // "the playlist.\n" |
428 | "Your playlist " | 427 | // "Your playlist " |
429 | "may be missing some entries\n" | 428 | // "may be missing some entries\n" |
430 | "the next time you start it." ) | 429 | // "the next time you start it." ) |
431 | ); | 430 | // ); |
432 | } | 431 | // } |
432 | |||
433 | } | 433 | } |
434 | noOfFiles++; | 434 | noOfFiles++; |
435 | } | 435 | } |
436 | } | 436 | } |
@@ -446,14 +446,20 @@ void PlayListWidget::addToSelection( const DocLnk& lnk ) { | |||
446 | d->selectedFiles->addToSelection( lnk ); | 446 | d->selectedFiles->addToSelection( lnk ); |
447 | } | 447 | } |
448 | else | 448 | else |
449 | mediaPlayerState->setPlaying( true); | 449 | mediaPlayerState->setPlaying( true); |
450 | |||
450 | } | 451 | } |
451 | 452 | ||
452 | 453 | ||
453 | void PlayListWidget::clearList() { | 454 | void PlayListWidget::clearList() { |
454 | while ( first() ) | 455 | while ( first() ) |
455 | d->selectedFiles->removeSelected(); | 456 | d->selectedFiles->removeSelected(); |
457 | Config cfg( "OpiePlayer" ); | ||
458 | cfg.setGroup("PlayList"); | ||
459 | cfg.writeEntry("CurrentPlaylist",""); | ||
460 | currentPlayList=""; | ||
461 | |||
456 | } | 462 | } |
457 | 463 | ||
458 | 464 | ||
459 | void PlayListWidget::addAllToList() { | 465 | void PlayListWidget::addAllToList() { |
@@ -496,59 +502,64 @@ void PlayListWidget::addAllVideoToList() { | |||
496 | 502 | ||
497 | void PlayListWidget::setDocument(const QString& fileref) { | 503 | void PlayListWidget::setDocument(const QString& fileref) { |
498 | fromSetDocument = true; | 504 | fromSetDocument = true; |
499 | d->setDocumentUsed = TRUE; | 505 | d->setDocumentUsed = TRUE; |
500 | d->selectedFiles->setSelected(d->selectedFiles->firstChild(),true ); | 506 | setDocumentEx(fileref); |
501 | mediaPlayerState->setPlaying( FALSE ); | ||
502 | qApp->processEvents(); | ||
503 | mediaPlayerState->setPlaying( TRUE ); | ||
504 | } | 507 | } |
505 | 508 | ||
506 | void PlayListWidget::setDocumentEx(const QString& fileref) { | 509 | void PlayListWidget::setDocumentEx(const QString& fileref) { |
507 | 510 | qDebug("opieplayer receive "+fileref); | |
508 | QFileInfo fileInfo(fileref); | 511 | clearList(); |
509 | if ( !fileInfo.exists() ) { | 512 | DocLnk lnk; |
510 | QMessageBox::critical( 0, tr( "Invalid File" ), | 513 | QFileInfo fileInfo(fileref); |
511 | tr( "There was a problem in getting the file." ) ); | 514 | if ( !fileInfo.exists() ) { |
512 | return; | 515 | QMessageBox::critical( 0, tr( "Invalid File" ), |
513 | } | 516 | tr( "There was a problem in getting the file." ) ); |
514 | qDebug("setDocument "+fileref); | 517 | return; |
515 | QString extension = fileInfo.extension(false); | 518 | } |
516 | if( extension.find( "m3u", 0, false) != -1) { //is m3u | 519 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<setDocument "+fileref); |
520 | QString extension = fileInfo.extension(false); | ||
521 | if( extension.find( "m3u", 0, false) != -1) { //is m3u | ||
517 | readm3u( fileref); | 522 | readm3u( fileref); |
518 | } | 523 | } |
519 | else if( extension.find( "pls", 0, false) != -1 ) { //is pls | 524 | else if( extension.find( "pls", 0, false) != -1 ) { //is pls |
520 | readPls( fileref); | 525 | readPls( fileref); |
521 | } | 526 | } |
522 | else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist | 527 | else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist |
523 | clearList(); | 528 | clearList(); |
524 | DocLnk lnk; | 529 | lnk.setName( fileInfo.baseName() ); //sets name |
525 | lnk.setName( fileInfo.baseName() ); //sets name | 530 | lnk.setFile( fileref ); //sets file name |
526 | lnk.setFile( fileref ); //sets file name | 531 | lnk.setIcon("Sound"); |
527 | //addToSelection( lnk ); | 532 | //addToSelection( lnk ); |
528 | 533 | ||
529 | loadList( lnk); | 534 | loadList( lnk); |
530 | d->selectedFiles->first(); | 535 | d->selectedFiles->first(); |
531 | } else { | 536 | } else { |
532 | clearList(); | 537 | if( fileref.find(".desktop",0,TRUE) != -1) { |
533 | DocLnk lnk; | 538 | lnk = DocLnk(fileref); |
534 | lnk.setName( fileInfo.baseName() ); //sets name | 539 | } else { |
535 | lnk.setFile( fileref ); //sets file name | 540 | lnk.setName( fileInfo.baseName() ); //sets name |
536 | addToSelection( lnk ); | 541 | lnk.setFile( fileref ); //sets file name |
537 | // addToSelection( DocLnk( fileref ) ); | 542 | lnk.setIcon("Sound"); |
538 | d->setDocumentUsed = TRUE; | 543 | } |
539 | mediaPlayerState->setPlaying( FALSE ); | 544 | |
540 | qApp->processEvents(); | 545 | addToSelection( lnk ); |
541 | mediaPlayerState->setPlaying( TRUE ); | 546 | // addToSelection( DocLnk( fileref ) ); |
542 | // qApp->processEvents(); | 547 | lnk.removeLinkFile(); |
543 | setCaption(tr("OpiePlayer")); | 548 | // qApp->processEvents(); |
544 | } | 549 | } |
550 | setCaption(tr("OpiePlayer")); | ||
551 | d->setDocumentUsed = TRUE; | ||
552 | d->selectedFiles->setSelected(d->selectedFiles->firstChild(),true ); | ||
553 | mediaPlayerState->setPlaying( FALSE ); | ||
554 | qApp->processEvents(); | ||
555 | mediaPlayerState->setPlaying( TRUE ); | ||
556 | |||
545 | } | 557 | } |
546 | 558 | ||
547 | 559 | ||
548 | void PlayListWidget::setActiveWindow() { | 560 | void PlayListWidget::setActiveWindow() { |
549 | qDebug("SETTING active window"); | 561 | // qDebug("SETTING active window"); |
550 | |||
551 | // When we get raised we need to ensure that it switches views | 562 | // When we get raised we need to ensure that it switches views |
552 | char origView = mediaPlayerState->view(); | 563 | char origView = mediaPlayerState->view(); |
553 | mediaPlayerState->setView( 'l' ); // invalidate | 564 | mediaPlayerState->setView( 'l' ); // invalidate |
554 | mediaPlayerState->setView( origView ); // now switch back | 565 | mediaPlayerState->setView( origView ); // now switch back |
@@ -560,488 +571,463 @@ void PlayListWidget::useSelectedDocument() { | |||
560 | } | 571 | } |
561 | 572 | ||
562 | 573 | ||
563 | const DocLnk *PlayListWidget::current() { // this is fugly | 574 | const DocLnk *PlayListWidget::current() { // this is fugly |
564 | 575 | switch (tabWidget->currentPageIndex()) { | |
565 | // if( fromSetDocument) { | 576 | case 0: //playlist |
566 | // qDebug("from setDoc"); | 577 | { |
567 | // DocLnkSet files; | 578 | // qDebug("playlist"); |
568 | // Global::findDocuments(&files, "video/*;audio/*"); | 579 | if ( mediaPlayerState->playlist() ) { |
569 | // QListIterator<DocLnk> dit( files.children() ); | 580 | return d->selectedFiles->current(); |
570 | // for ( ; dit.current(); ++dit ) { | ||
571 | // if(dit.current()->linkFile() == setDocFileRef) { | ||
572 | // qDebug(setDocFileRef); | ||
573 | // return dit; | ||
574 | // } | ||
575 | // } | ||
576 | // } else | ||
577 | |||
578 | qDebug("current"); | ||
579 | |||
580 | switch (tabWidget->currentPageIndex()) { | ||
581 | case 0: //playlist | ||
582 | { | ||
583 | qDebug("playlist"); | ||
584 | if ( mediaPlayerState->playlist() ) { | ||
585 | return d->selectedFiles->current(); | ||
586 | } | ||
587 | else if ( d->setDocumentUsed && d->current ) { | ||
588 | return d->current; | ||
589 | } else { | ||
590 | return &(d->files->selectedDocument()); | ||
591 | } | ||
592 | } | 581 | } |
593 | break; | 582 | else if ( d->setDocumentUsed && d->current ) { |
594 | case 1://audio | 583 | return d->current; |
595 | { | 584 | } else { |
596 | qDebug("audioView"); | 585 | return &(d->files->selectedDocument()); |
597 | QListIterator<DocLnk> dit( files.children() ); | ||
598 | for ( ; dit.current(); ++dit ) { | ||
599 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { | ||
600 | qDebug("here"); | ||
601 | insanityBool=TRUE; | ||
602 | return dit; | ||
603 | } | ||
604 | } | ||
605 | } | ||
606 | break; | ||
607 | case 2: // video | ||
608 | { | ||
609 | qDebug("videoView"); | ||
610 | QListIterator<DocLnk> Vdit( vFiles.children() ); | ||
611 | for ( ; Vdit.current(); ++Vdit ) { | ||
612 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { | ||
613 | insanityBool=TRUE; | ||
614 | return Vdit; | ||
615 | } | ||
616 | } | ||
617 | } | 586 | } |
618 | break; | 587 | } |
619 | }; | 588 | break; |
620 | return 0; | 589 | case 1://audio |
590 | { | ||
591 | // qDebug("audioView"); | ||
592 | QListIterator<DocLnk> dit( files.children() ); | ||
593 | for ( ; dit.current(); ++dit ) { | ||
594 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { | ||
595 | insanityBool=TRUE; | ||
596 | return dit; | ||
597 | } | ||
598 | } | ||
599 | } | ||
600 | break; | ||
601 | case 2: // video | ||
602 | { | ||
603 | QListIterator<DocLnk> Vdit( vFiles.children() ); | ||
604 | for ( ; Vdit.current(); ++Vdit ) { | ||
605 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { | ||
606 | insanityBool=TRUE; | ||
607 | return Vdit; | ||
608 | } | ||
609 | } | ||
610 | } | ||
611 | break; | ||
612 | }; | ||
613 | return 0; | ||
621 | } | 614 | } |
622 | 615 | ||
623 | bool PlayListWidget::prev() { | 616 | bool PlayListWidget::prev() { |
624 | if ( mediaPlayerState->playlist() ) { | 617 | if ( mediaPlayerState->playlist() ) { |
625 | if ( mediaPlayerState->shuffled() ) { | 618 | if ( mediaPlayerState->shuffled() ) { |
626 | const DocLnk *cur = current(); | 619 | const DocLnk *cur = current(); |
627 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 620 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
628 | for ( int i = 0; i < j; i++ ) { | 621 | for ( int i = 0; i < j; i++ ) { |
629 | if ( !d->selectedFiles->next() ) | 622 | if ( !d->selectedFiles->next() ) |
630 | d->selectedFiles->first(); | 623 | d->selectedFiles->first(); |
624 | } | ||
625 | if ( cur == current() ) | ||
626 | if ( !d->selectedFiles->next() ) | ||
627 | d->selectedFiles->first(); | ||
628 | return TRUE; | ||
629 | } else { | ||
630 | if ( !d->selectedFiles->prev() ) { | ||
631 | if ( mediaPlayerState->looping() ) { | ||
632 | return d->selectedFiles->last(); | ||
633 | } else { | ||
634 | return FALSE; | ||
631 | } | 635 | } |
632 | if ( cur == current() ) | 636 | } |
633 | if ( !d->selectedFiles->next() ) | 637 | return TRUE; |
634 | d->selectedFiles->first(); | 638 | } |
635 | return TRUE; | 639 | } else { |
636 | } else { | 640 | return mediaPlayerState->looping(); |
637 | if ( !d->selectedFiles->prev() ) { | 641 | } |
638 | if ( mediaPlayerState->looping() ) { | ||
639 | return d->selectedFiles->last(); | ||
640 | } else { | ||
641 | return FALSE; | ||
642 | } | ||
643 | } | ||
644 | return TRUE; | ||
645 | } | ||
646 | } else { | ||
647 | return mediaPlayerState->looping(); | ||
648 | } | ||
649 | } | 642 | } |
650 | 643 | ||
651 | 644 | ||
652 | bool PlayListWidget::next() { | 645 | bool PlayListWidget::next() { |
653 | if ( mediaPlayerState->playlist() ) { | 646 | if ( mediaPlayerState->playlist() ) { |
654 | if ( mediaPlayerState->shuffled() ) { | 647 | if ( mediaPlayerState->shuffled() ) { |
655 | return prev(); | 648 | return prev(); |
656 | } else { | 649 | } else { |
657 | if ( !d->selectedFiles->next() ) { | 650 | if ( !d->selectedFiles->next() ) { |
658 | if ( mediaPlayerState->looping() ) { | 651 | if ( mediaPlayerState->looping() ) { |
659 | return d->selectedFiles->first(); | 652 | return d->selectedFiles->first(); |
660 | } else { | 653 | } else { |
661 | return FALSE; | 654 | return FALSE; |
662 | } | ||
663 | } | 655 | } |
664 | return TRUE; | 656 | } |
665 | } | 657 | return TRUE; |
666 | } else { | 658 | } |
667 | return mediaPlayerState->looping(); | 659 | } else { |
668 | } | 660 | return mediaPlayerState->looping(); |
661 | } | ||
669 | } | 662 | } |
670 | 663 | ||
671 | 664 | ||
672 | bool PlayListWidget::first() { | 665 | bool PlayListWidget::first() { |
673 | if ( mediaPlayerState->playlist() ) | 666 | if ( mediaPlayerState->playlist() ) |
674 | return d->selectedFiles->first(); | 667 | return d->selectedFiles->first(); |
675 | else | 668 | else |
676 | return mediaPlayerState->looping(); | 669 | return mediaPlayerState->looping(); |
677 | } | 670 | } |
678 | 671 | ||
679 | 672 | ||
680 | bool PlayListWidget::last() { | 673 | bool PlayListWidget::last() { |
681 | if ( mediaPlayerState->playlist() ) | 674 | if ( mediaPlayerState->playlist() ) |
682 | return d->selectedFiles->last(); | 675 | return d->selectedFiles->last(); |
683 | else | 676 | else |
684 | return mediaPlayerState->looping(); | 677 | return mediaPlayerState->looping(); |
685 | } | 678 | } |
686 | 679 | ||
687 | 680 | ||
688 | void PlayListWidget::saveList() { | 681 | void PlayListWidget::saveList() { |
689 | writem3u(); | 682 | writem3u(); |
690 | } | 683 | } |
691 | 684 | ||
692 | void PlayListWidget::loadList( const DocLnk & lnk) { | 685 | void PlayListWidget::loadList( const DocLnk & lnk) { |
693 | QString name = lnk.name(); | 686 | QString name = lnk.name(); |
694 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); | 687 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); |
695 | 688 | ||
696 | if( name.length()>0) { | 689 | if( name.length()>0) { |
697 | setCaption("OpiePlayer: "+name); | 690 | setCaption("OpiePlayer: "+name); |
698 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); | 691 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); |
699 | clearList(); | 692 | clearList(); |
700 | readm3u(lnk.file()); | 693 | readm3u(lnk.file()); |
701 | tabWidget->setCurrentPage(0); | 694 | tabWidget->setCurrentPage(0); |
702 | } | 695 | } |
703 | } | 696 | } |
704 | 697 | ||
705 | void PlayListWidget::setPlaylist( bool shown ) { | 698 | void PlayListWidget::setPlaylist( bool shown ) { |
706 | if ( shown ) | 699 | if ( shown ) |
707 | d->playListFrame->show(); | 700 | d->playListFrame->show(); |
708 | else | 701 | else |
709 | d->playListFrame->hide(); | 702 | d->playListFrame->hide(); |
710 | } | 703 | } |
711 | 704 | ||
712 | void PlayListWidget::setView( char view ) { | 705 | void PlayListWidget::setView( char view ) { |
713 | if ( view == 'l' ) | 706 | if ( view == 'l' ) |
714 | showMaximized(); | 707 | showMaximized(); |
715 | else | 708 | else |
716 | hide(); | 709 | hide(); |
717 | } | 710 | } |
718 | 711 | ||
719 | void PlayListWidget::addSelected() { | 712 | void PlayListWidget::addSelected() { |
720 | qDebug("addSelected"); | 713 | DocLnk lnk; |
721 | DocLnk lnk; | 714 | QString filename; |
722 | QString filename; | 715 | switch (tabWidget->currentPageIndex()) { |
723 | switch (tabWidget->currentPageIndex()) { | 716 | |
724 | 717 | case 0: //playlist | |
725 | case 0: //playlist | 718 | return; |
726 | return; | 719 | break; |
727 | break; | 720 | case 1: { //audio |
728 | case 1: { //audio | ||
729 | QListViewItemIterator it( audioView ); | 721 | QListViewItemIterator it( audioView ); |
730 | for ( ; it.current(); ++it ) { | 722 | for ( ; it.current(); ++it ) { |
731 | if ( it.current()->isSelected() ) { | 723 | if ( it.current()->isSelected() ) { |
732 | filename = it.current()->text(3); | 724 | filename = it.current()->text(3); |
733 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 725 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
734 | lnk.setFile( filename ); //sets file name | 726 | lnk.setFile( filename ); //sets file name |
735 | d->selectedFiles->addToSelection( lnk); | 727 | d->selectedFiles->addToSelection( lnk); |
736 | } | 728 | } |
737 | } | 729 | } |
738 | audioView->clearSelection(); | 730 | audioView->clearSelection(); |
739 | // d->selectedFiles->next(); | 731 | // d->selectedFiles->next(); |
740 | } | 732 | } |
741 | break; | 733 | break; |
742 | 734 | ||
743 | case 2: { // video | 735 | case 2: { // video |
744 | QListViewItemIterator it( videoView ); | 736 | QListViewItemIterator it( videoView ); |
745 | for ( ; it.current(); ++it ) { | 737 | for ( ; it.current(); ++it ) { |
746 | if ( it.current()->isSelected() ) { | 738 | if ( it.current()->isSelected() ) { |
747 | 739 | ||
748 | filename = it.current()->text(3); | 740 | filename = it.current()->text(3); |
749 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 741 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
750 | lnk.setFile( filename ); //sets file name | 742 | lnk.setFile( filename ); //sets file name |
751 | d->selectedFiles->addToSelection( lnk); | 743 | d->selectedFiles->addToSelection( lnk); |
752 | } | 744 | } |
753 | } | 745 | } |
754 | videoView->clearSelection(); | 746 | videoView->clearSelection(); |
755 | } | 747 | } |
756 | break; | 748 | break; |
757 | }; | 749 | }; |
758 | // tabWidget->setCurrentPage(0); | 750 | // tabWidget->setCurrentPage(0); |
759 | writeCurrentM3u(); | 751 | writeCurrentM3u(); |
760 | 752 | ||
761 | } | 753 | } |
762 | 754 | ||
763 | void PlayListWidget::removeSelected() { | 755 | void PlayListWidget::removeSelected() { |
764 | d->selectedFiles->removeSelected( ); | 756 | d->selectedFiles->removeSelected( ); |
765 | } | 757 | } |
766 | 758 | ||
767 | void PlayListWidget::playIt( QListViewItem *) { | 759 | void PlayListWidget::playIt( QListViewItem *) { |
768 | // d->setDocumentUsed = FALSE; | 760 | // d->setDocumentUsed = FALSE; |
769 | // mediaPlayerState->curPosition =0; | 761 | // mediaPlayerState->curPosition =0; |
770 | qDebug("playIt"); | 762 | // mediaPlayerState->setPlaying(FALSE); |
771 | // mediaPlayerState->setPlaying(FALSE); | 763 | mediaPlayerState->setPlaying(TRUE); |
772 | mediaPlayerState->setPlaying(TRUE); | 764 | d->selectedFiles->unSelect(); |
773 | d->selectedFiles->unSelect(); | ||
774 | } | 765 | } |
775 | 766 | ||
776 | void PlayListWidget::addToSelection( QListViewItem *it) { | 767 | void PlayListWidget::addToSelection( QListViewItem *it) { |
777 | d->setDocumentUsed = FALSE; | 768 | d->setDocumentUsed = FALSE; |
778 | 769 | ||
779 | if(it) { | 770 | if(it) { |
780 | switch ( tabWidget->currentPageIndex()) { | 771 | switch ( tabWidget->currentPageIndex()) { |
781 | case 0: //playlist | 772 | case 0: //playlist |
782 | return; | 773 | return; |
783 | break; | 774 | break; |
784 | }; | 775 | }; |
785 | // case 1: { | 776 | // case 1: { |
786 | DocLnk lnk; | 777 | DocLnk lnk; |
787 | QString filename; | 778 | QString filename; |
788 | 779 | ||
789 | filename=it->text(3); | 780 | filename=it->text(3); |
790 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name | 781 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name |
791 | lnk.setFile( filename ); //sets file name | 782 | lnk.setFile( filename ); //sets file name |
792 | d->selectedFiles->addToSelection( lnk); | 783 | d->selectedFiles->addToSelection( lnk); |
793 | 784 | ||
794 | if(tabWidget->currentPageIndex() == 0) | 785 | if(tabWidget->currentPageIndex() == 0) |
795 | writeCurrentM3u(); | 786 | writeCurrentM3u(); |
796 | // tabWidget->setCurrentPage(0); | 787 | // tabWidget->setCurrentPage(0); |
797 | 788 | ||
798 | } | 789 | } |
799 | } | 790 | } |
800 | 791 | ||
801 | void PlayListWidget::tabChanged(QWidget *) { | 792 | void PlayListWidget::tabChanged(QWidget *) { |
802 | 793 | ||
803 | switch ( tabWidget->currentPageIndex()) { | 794 | switch ( tabWidget->currentPageIndex()) { |
804 | case 0: | 795 | case 0: |
805 | { | 796 | { |
806 | if( !tbDeletePlaylist->isHidden()) | 797 | if( !tbDeletePlaylist->isHidden()) |
807 | tbDeletePlaylist->hide(); | 798 | tbDeletePlaylist->hide(); |
808 | d->tbRemoveFromList->setEnabled(TRUE); | 799 | d->tbRemoveFromList->setEnabled(TRUE); |
809 | d->tbAddToList->setEnabled(FALSE); | 800 | d->tbAddToList->setEnabled(FALSE); |
810 | } | 801 | } |
811 | break; | 802 | break; |
812 | case 1: | 803 | case 1: |
813 | { | 804 | { |
814 | audioView->clear(); | 805 | audioView->clear(); |
815 | populateAudioView(); | 806 | populateAudioView(); |
816 | 807 | ||
817 | if( !tbDeletePlaylist->isHidden()) | 808 | if( !tbDeletePlaylist->isHidden()) |
818 | tbDeletePlaylist->hide(); | 809 | tbDeletePlaylist->hide(); |
819 | d->tbRemoveFromList->setEnabled(FALSE); | 810 | d->tbRemoveFromList->setEnabled(FALSE); |
820 | d->tbAddToList->setEnabled(TRUE); | 811 | d->tbAddToList->setEnabled(TRUE); |
821 | } | 812 | } |
822 | break; | 813 | break; |
823 | case 2: | 814 | case 2: |
824 | { | 815 | { |
825 | videoView->clear(); | 816 | videoView->clear(); |
826 | populateVideoView(); | 817 | populateVideoView(); |
827 | if( !tbDeletePlaylist->isHidden()) | 818 | if( !tbDeletePlaylist->isHidden()) |
828 | tbDeletePlaylist->hide(); | 819 | tbDeletePlaylist->hide(); |
829 | d->tbRemoveFromList->setEnabled(FALSE); | 820 | d->tbRemoveFromList->setEnabled(FALSE); |
830 | d->tbAddToList->setEnabled(TRUE); | 821 | d->tbAddToList->setEnabled(TRUE); |
831 | } | 822 | } |
832 | break; | 823 | break; |
833 | case 3: | 824 | case 3: |
834 | { | 825 | { |
835 | if( tbDeletePlaylist->isHidden()) | 826 | if( tbDeletePlaylist->isHidden()) |
836 | tbDeletePlaylist->show(); | 827 | tbDeletePlaylist->show(); |
837 | playLists->reread(); | 828 | playLists->reread(); |
838 | } | 829 | } |
839 | break; | 830 | break; |
840 | }; | 831 | }; |
841 | } | 832 | } |
842 | 833 | ||
843 | void PlayListWidget::btnPlay(bool b) { | 834 | void PlayListWidget::btnPlay(bool b) { |
844 | qDebug("<<<<<<<<<<<<<<<BtnPlay %d", b); | 835 | // mediaPlayerState->setPlaying(b); |
845 | // mediaPlayerState->setPlaying(b); | 836 | switch ( tabWidget->currentPageIndex()) { |
846 | switch ( tabWidget->currentPageIndex()) { | 837 | case 0: |
847 | case 0: | 838 | { |
848 | { | 839 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 |
849 | qDebug("1"); | 840 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { |
850 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 | 841 | // QMessageBox::message("Note","You are trying to play\na malformed url."); |
851 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { | 842 | // } else { |
852 | // QMessageBox::message("Note","You are trying to play\na malformed url."); | 843 | mediaPlayerState->setPlaying(b); |
853 | // } else { | 844 | insanityBool=FALSE; |
854 | mediaPlayerState->setPlaying(b); | 845 | qDebug("insanity"); |
855 | insanityBool=FALSE; | 846 | // } |
856 | qDebug("insanity"); | 847 | } |
857 | // } | 848 | break; |
858 | } | 849 | case 1: |
859 | break; | 850 | { |
860 | case 1: | 851 | // d->selectedFiles->unSelect(); |
861 | { | 852 | addToSelection( audioView->currentItem() ); |
862 | qDebug("2"); | 853 | mediaPlayerState->setPlaying( b); |
863 | // d->selectedFiles->unSelect(); | 854 | d->selectedFiles->removeSelected( ); |
864 | addToSelection( audioView->currentItem() ); | 855 | d->selectedFiles->unSelect(); |
865 | mediaPlayerState->setPlaying( b); | 856 | tabWidget->setCurrentPage(1); |
866 | d->selectedFiles->removeSelected( ); | 857 | insanityBool=FALSE; |
867 | d->selectedFiles->unSelect(); | 858 | }// audioView->clearSelection(); |
868 | tabWidget->setCurrentPage(1); | 859 | break; |
869 | insanityBool=FALSE; | 860 | case 2: |
870 | }// audioView->clearSelection(); | 861 | { |
871 | break; | ||
872 | case 2: | ||
873 | { | ||
874 | qDebug("3"); | ||
875 | 862 | ||
876 | addToSelection( videoView->currentItem() ); | 863 | addToSelection( videoView->currentItem() ); |
877 | mediaPlayerState->setPlaying( b); | 864 | mediaPlayerState->setPlaying( b); |
878 | // qApp->processEvents(); | 865 | // qApp->processEvents(); |
879 | d->selectedFiles->removeSelected( ); | 866 | d->selectedFiles->removeSelected( ); |
880 | d->selectedFiles->unSelect(); | 867 | d->selectedFiles->unSelect(); |
881 | tabWidget->setCurrentPage(2); | 868 | tabWidget->setCurrentPage(2); |
882 | insanityBool=FALSE; | 869 | insanityBool=FALSE; |
883 | }// videoView->clearSelection(); | 870 | }// videoView->clearSelection(); |
884 | break; | 871 | break; |
885 | }; | 872 | }; |
886 | 873 | ||
887 | } | 874 | } |
888 | 875 | ||
889 | void PlayListWidget::deletePlaylist() { | 876 | void PlayListWidget::deletePlaylist() { |
890 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 877 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
891 | (tr("You really want to delete\nthis playlist?")), | 878 | (tr("You really want to delete\nthis playlist?")), |
892 | (tr("Yes")), (tr("No")), 0 )){ | 879 | (tr("Yes")), (tr("No")), 0 )){ |
893 | case 0: // Yes clicked, | 880 | case 0: // Yes clicked, |
894 | QFile().remove(playLists->selectedDocument().file()); | 881 | QFile().remove(playLists->selectedDocument().file()); |
895 | QFile().remove(playLists->selectedDocument().linkFile()); | 882 | QFile().remove(playLists->selectedDocument().linkFile()); |
896 | playLists->reread(); | 883 | playLists->reread(); |
897 | break; | 884 | break; |
898 | case 1: // Cancel | 885 | case 1: // Cancel |
899 | break; | 886 | break; |
900 | }; | 887 | }; |
901 | } | 888 | } |
902 | 889 | ||
903 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) | 890 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) |
904 | { | 891 | { |
905 | switch (mouse) { | 892 | switch (mouse) { |
906 | case 1: | 893 | case 1: |
907 | break; | 894 | break; |
908 | case 2:{ | 895 | case 2:{ |
909 | 896 | ||
910 | QPopupMenu m; | 897 | QPopupMenu m; |
911 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 898 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
912 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 899 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
913 | m.insertSeparator(); | 900 | m.insertSeparator(); |
914 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) | 901 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) |
915 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 902 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
916 | 903 | ||
917 | m.exec( QCursor::pos() ); | 904 | m.exec( QCursor::pos() ); |
918 | } | 905 | } |
919 | break; | 906 | break; |
920 | }; | 907 | }; |
921 | } | 908 | } |
922 | 909 | ||
923 | void PlayListWidget::playSelected() | 910 | void PlayListWidget::playSelected() |
924 | { | 911 | { |
925 | qDebug("playSelected"); | ||
926 | btnPlay( true); | 912 | btnPlay( true); |
927 | // d->selectedFiles->unSelect(); | 913 | // d->selectedFiles->unSelect(); |
928 | } | 914 | } |
929 | 915 | ||
930 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) | 916 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) |
931 | { | 917 | { |
932 | switch (mouse) { | 918 | switch (mouse) { |
933 | case 1: | 919 | case 1: |
934 | 920 | ||
935 | break; | ||
936 | case 2:{ | ||
937 | QPopupMenu m; | ||
938 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | ||
939 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | ||
940 | // m.insertSeparator(); | ||
941 | // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | ||
942 | m.exec( QCursor::pos() ); | ||
943 | } | ||
944 | break; | 921 | break; |
945 | }; | 922 | case 2:{ |
923 | QPopupMenu m; | ||
924 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | ||
925 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | ||
926 | // m.insertSeparator(); | ||
927 | // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | ||
928 | m.exec( QCursor::pos() ); | ||
929 | } | ||
930 | break; | ||
931 | }; | ||
946 | 932 | ||
947 | } | 933 | } |
948 | 934 | ||
949 | void PlayListWidget::listDelete() { | 935 | void PlayListWidget::listDelete() { |
950 | Config cfg( "OpiePlayer" ); | 936 | Config cfg( "OpiePlayer" ); |
951 | cfg.setGroup("PlayList"); | 937 | cfg.setGroup("PlayList"); |
952 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 938 | currentPlayList = cfg.readEntry("CurrentPlaylist",""); |
953 | QString file; | 939 | QString file; |
954 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 940 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
955 | switch ( tabWidget->currentPageIndex()) { | 941 | switch ( tabWidget->currentPageIndex()) { |
956 | case 0: | 942 | case 0: |
957 | break; | ||
958 | case 1: | ||
959 | { | ||
960 | file = audioView->currentItem()->text(0); | ||
961 | QListIterator<DocLnk> Pdit( files.children() ); | ||
962 | for ( ; Pdit.current(); ++Pdit ) { | ||
963 | if( Pdit.current()->name() == file) { | ||
964 | LnkProperties prop( Pdit.current() ); | ||
965 | prop.showMaximized(); | ||
966 | prop.exec(); | ||
967 | } | ||
968 | } | ||
969 | populateAudioView(); | ||
970 | } | ||
971 | break; | 943 | break; |
972 | case 2: | 944 | case 1: |
973 | { | 945 | { |
974 | // file = videoView->selectedItem()->text(0); | 946 | file = audioView->currentItem()->text(0); |
975 | // for ( int i = 0; i < noOfFiles; i++ ) { | 947 | QListIterator<DocLnk> Pdit( files.children() ); |
976 | // QString entryName; | 948 | for ( ; Pdit.current(); ++Pdit ) { |
977 | // entryName.sprintf( "File%i", i + 1 ); | 949 | if( Pdit.current()->name() == file) { |
978 | // QString linkFile = cfg.readEntry( entryName ); | 950 | LnkProperties prop( Pdit.current() ); |
979 | // AppLnk lnk( AppLnk(linkFile)); | 951 | prop.showMaximized(); |
980 | // if( lnk.name() == file ) { | 952 | prop.exec(); |
981 | // LnkProperties prop( &lnk); | 953 | } |
982 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | ||
983 | // prop.showMaximized(); | ||
984 | // prop.exec(); | ||
985 | // } | ||
986 | // } | ||
987 | } | 954 | } |
988 | break; | 955 | populateAudioView(); |
989 | }; | 956 | } |
957 | break; | ||
958 | case 2: | ||
959 | { | ||
960 | // file = videoView->selectedItem()->text(0); | ||
961 | // for ( int i = 0; i < noOfFiles; i++ ) { | ||
962 | // QString entryName; | ||
963 | // entryName.sprintf( "File%i", i + 1 ); | ||
964 | // QString linkFile = cfg.readEntry( entryName ); | ||
965 | // AppLnk lnk( AppLnk(linkFile)); | ||
966 | // if( lnk.name() == file ) { | ||
967 | // LnkProperties prop( &lnk); | ||
968 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | ||
969 | // prop.showMaximized(); | ||
970 | // prop.exec(); | ||
971 | // } | ||
972 | // } | ||
973 | } | ||
974 | break; | ||
975 | }; | ||
990 | } | 976 | } |
991 | 977 | ||
992 | void PlayListWidget::scanForAudio() { | 978 | void PlayListWidget::scanForAudio() { |
993 | // qDebug("scan for audio"); | 979 | // qDebug("scan for audio"); |
994 | files.detachChildren(); | 980 | files.detachChildren(); |
995 | QListIterator<DocLnk> sdit( files.children() ); | 981 | QListIterator<DocLnk> sdit( files.children() ); |
996 | for ( ; sdit.current(); ++sdit ) { | 982 | for ( ; sdit.current(); ++sdit ) { |
997 | delete sdit.current(); | 983 | delete sdit.current(); |
998 | } | 984 | } |
999 | Global::findDocuments( &files, audioMimes); | 985 | Global::findDocuments( &files, audioMimes); |
1000 | audioScan = true; | 986 | audioScan = true; |
1001 | } | 987 | } |
1002 | void PlayListWidget::scanForVideo() { | 988 | void PlayListWidget::scanForVideo() { |
1003 | // qDebug("scan for video"); | 989 | // qDebug("scan for video"); |
1004 | vFiles.detachChildren(); | 990 | vFiles.detachChildren(); |
1005 | QListIterator<DocLnk> sdit( vFiles.children() ); | 991 | QListIterator<DocLnk> sdit( vFiles.children() ); |
1006 | for ( ; sdit.current(); ++sdit ) { | 992 | for ( ; sdit.current(); ++sdit ) { |
1007 | delete sdit.current(); | 993 | delete sdit.current(); |
1008 | } | 994 | } |
1009 | Global::findDocuments(&vFiles, "video/*"); | 995 | Global::findDocuments(&vFiles, "video/*"); |
1010 | videoScan = true; | 996 | videoScan = true; |
1011 | } | 997 | } |
1012 | 998 | ||
1013 | void PlayListWidget::populateAudioView() { | 999 | void PlayListWidget::populateAudioView() { |
1014 | 1000 | ||
1015 | audioView->clear(); | 1001 | audioView->clear(); |
1016 | StorageInfo storageInfo; | 1002 | StorageInfo storageInfo; |
1017 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 1003 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
1018 | if(!audioScan) scanForAudio(); | 1004 | if(!audioScan) scanForAudio(); |
1019 | 1005 | ||
1020 | QListIterator<DocLnk> dit( files.children() ); | 1006 | QListIterator<DocLnk> dit( files.children() ); |
1021 | QListIterator<FileSystem> it ( fs ); | 1007 | QListIterator<FileSystem> it ( fs ); |
1022 | 1008 | ||
1023 | QString storage; | 1009 | QString storage; |
1024 | for ( ; dit.current(); ++dit ) { | 1010 | for ( ; dit.current(); ++dit ) { |
1025 | for( ; it.current(); ++it ){ | 1011 | for( ; it.current(); ++it ){ |
1026 | const QString name = (*it)->name(); | 1012 | const QString name = (*it)->name(); |
1027 | const QString path = (*it)->path(); | 1013 | const QString path = (*it)->path(); |
1028 | if(dit.current()->file().find(path) != -1 ) storage=name; | 1014 | if(dit.current()->file().find(path) != -1 ) storage=name; |
1029 | } | 1015 | } |
1030 | 1016 | ||
1031 | QListViewItem * newItem; | 1017 | QListViewItem * newItem; |
1032 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { | 1018 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { |
1033 | long size; | 1019 | long size; |
1034 | if( dit.current()->file().left(4) == "http" ) | 1020 | if( dit.current()->file().left(4) == "http" ) |
1035 | size=0; | 1021 | size=0; |
1036 | else | 1022 | else |
1037 | size = QFile( dit.current()->file() ).size(); | 1023 | size = QFile( dit.current()->file() ).size(); |
1038 | // qDebug(dit.current()->name()); | 1024 | // qDebug(dit.current()->name()); |
1039 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 1025 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
1040 | QString::number(size ), storage, dit.current()->file()); | 1026 | QString::number(size ), storage, dit.current()->file()); |
1041 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); | 1027 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); |
1042 | } | 1028 | } |
1043 | } | 1029 | } |
1044 | 1030 | ||
1045 | } | 1031 | } |
1046 | 1032 | ||
1047 | void PlayListWidget::populateVideoView() { | 1033 | void PlayListWidget::populateVideoView() { |
@@ -1072,183 +1058,173 @@ void PlayListWidget::populateVideoView() { | |||
1072 | } | 1058 | } |
1073 | } | 1059 | } |
1074 | 1060 | ||
1075 | void PlayListWidget::openFile() { | 1061 | void PlayListWidget::openFile() { |
1076 | qDebug("<<<<<<<<<OPEN File"); | 1062 | QString filename, name; |
1077 | QString filename, name; | 1063 | InputDialog *fileDlg; |
1078 | InputDialog *fileDlg; | 1064 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
1079 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 1065 | fileDlg->exec(); |
1080 | fileDlg->exec(); | 1066 | if( fileDlg->result() == 1 ) { |
1081 | if( fileDlg->result() == 1 ) { | 1067 | filename = fileDlg->text(); |
1082 | filename = fileDlg->text(); | 1068 | // qDebug( "Selected filename is " + filename ); |
1083 | qDebug( "Selected filename is " + filename ); | 1069 | DocLnk lnk; |
1084 | // Om3u *m3uList; | 1070 | Config cfg( "OpiePlayer" ); |
1085 | DocLnk lnk; | 1071 | cfg.setGroup("PlayList"); |
1086 | Config cfg( "OpiePlayer" ); | ||
1087 | cfg.setGroup("PlayList"); | ||
1088 | |||
1089 | QString m3uFile; | ||
1090 | m3uFile = filename; | ||
1091 | if(filename.left(4) == "http") { | ||
1092 | if(filename.find(":",8,TRUE) != -1) { //found a port | ||
1093 | |||
1094 | // m3uFile = filename.left( filename.find( ":",8,TRUE)); | ||
1095 | m3uFile = filename; | ||
1096 | if( m3uFile.right( 1 ).find( '/' ) == -1) { | ||
1097 | m3uFile += "/"; | ||
1098 | } | ||
1099 | filename = m3uFile; | ||
1100 | // qDebug("1 "+m3uFile); | ||
1101 | // } else if(filename.left(4) == "http"){ | ||
1102 | // m3uFile=filename; | ||
1103 | // m3uFile = m3uFile.right( m3uFile.length() - 7); | ||
1104 | // qDebug("2 "+m3uFile); | ||
1105 | // } else{ | ||
1106 | // m3uFile=filename; | ||
1107 | // qDebug("3 "+m3uFile); | ||
1108 | } | ||
1109 | lnk.setName( m3uFile ); //sets name | ||
1110 | lnk.setFile( filename ); //sets file name | ||
1111 | lnk.setIcon("opieplayer2/musicfile"); | ||
1112 | d->selectedFiles->addToSelection( lnk ); | ||
1113 | writeCurrentM3u(); | ||
1114 | } | ||
1115 | else if( filename.right( 3) == "m3u" ) { | ||
1116 | readm3u( filename ); | ||
1117 | 1072 | ||
1118 | } else if( filename.right(3) == "pls" ) { | 1073 | QString m3uFile; |
1119 | readPls( filename ); | 1074 | m3uFile = filename; |
1120 | } else { | 1075 | if(filename.left(4) == "http") { |
1121 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name | 1076 | if(filename.find(":",8,TRUE) != -1) { //found a port |
1122 | lnk.setFile( filename ); //sets file name | 1077 | |
1123 | d->selectedFiles->addToSelection( lnk); | 1078 | m3uFile = filename; |
1124 | writeCurrentM3u(); | 1079 | if( m3uFile.right( 1 ).find( '/' ) == -1) { |
1125 | } | 1080 | m3uFile += "/"; |
1126 | } | 1081 | } |
1082 | filename = m3uFile; | ||
1083 | = } | ||
1084 | lnk.setName( m3uFile ); //sets name | ||
1085 | lnk.setFile( filename ); //sets file name | ||
1086 | lnk.setIcon("opieplayer2/musicfile"); | ||
1087 | d->selectedFiles->addToSelection( lnk ); | ||
1088 | writeCurrentM3u(); | ||
1089 | } | ||
1090 | else if( filename.right( 3) == "m3u" ) { | ||
1091 | readm3u( filename ); | ||
1092 | |||
1093 | } else if( filename.right(3) == "pls" ) { | ||
1094 | readPls( filename ); | ||
1095 | } else { | ||
1096 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name | ||
1097 | lnk.setFile( filename ); //sets file name | ||
1098 | d->selectedFiles->addToSelection( lnk); | ||
1099 | lnk.removeLinkFile(); | ||
1100 | writeCurrentM3u(); | ||
1101 | } | ||
1102 | } | ||
1127 | 1103 | ||
1128 | if( fileDlg ) { | 1104 | if( fileDlg ) { |
1129 | delete fileDlg; | 1105 | delete fileDlg; |
1130 | } | 1106 | } |
1131 | } | 1107 | } |
1132 | 1108 | ||
1133 | 1109 | ||
1134 | /* | 1110 | /* |
1135 | reads m3u and shows files/urls to playlist widget */ | 1111 | reads m3u and shows files/urls to playlist widget */ |
1136 | void PlayListWidget::readm3u( const QString &filename ) { | 1112 | void PlayListWidget::readm3u( const QString &filename ) { |
1137 | qDebug( "read m3u filename " + filename ); | 1113 | // qDebug( "read m3u filename " + filename ); |
1138 | 1114 | ||
1139 | Om3u *m3uList; | 1115 | Om3u *m3uList; |
1140 | QString s, name; | 1116 | QString s, name; |
1141 | m3uList = new Om3u( filename, IO_ReadOnly ); | 1117 | m3uList = new Om3u( filename, IO_ReadOnly ); |
1142 | m3uList->readM3u(); | 1118 | m3uList->readM3u(); |
1143 | DocLnk lnk; | 1119 | DocLnk lnk; |
1144 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 1120 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
1145 | s = *it; | 1121 | s = *it; |
1146 | // qDebug("reading "+ s); | 1122 | // qDebug("reading "+ s); |
1147 | if(s.left(4)=="http") { | 1123 | if(s.left(4)=="http") { |
1148 | lnk.setName( s ); //sets file name | 1124 | lnk.setName( s ); //sets file name |
1149 | lnk.setIcon("opieplayer2/musicfile"); | 1125 | lnk.setIcon("opieplayer2/musicfile"); |
1150 | 1126 | ||
1151 | // if(s.right(4) != '.' || s.right(5) != '.') | 1127 | // if(s.right(4) != '.' || s.right(5) != '.') |
1152 | if(s.right(4) != '.' || s.right(5) != '.' ) | 1128 | if(s.right(4) != '.' || s.right(5) != '.' ) |
1153 | if( s.right(1) != "/") | 1129 | if( s.right(1) != "/") |
1154 | lnk.setFile( s+"/"); //if url with no extension | 1130 | lnk.setFile( s+"/"); //if url with no extension |
1155 | else | 1131 | else |
1156 | lnk.setFile( s ); //sets file name | 1132 | lnk.setFile( s ); //sets file name |
1157 | 1133 | ||
1158 | } else { | 1134 | } else { |
1159 | // if( QFileInfo( s ).exists() ) { | 1135 | // if( QFileInfo( s ).exists() ) { |
1160 | lnk.setName( fullBaseName ( QFileInfo(s))); | 1136 | lnk.setName( fullBaseName ( QFileInfo(s))); |
1161 | // if(s.right(4) == '.') {//if regular file | 1137 | // if(s.right(4) == '.') {//if regular file |
1162 | if(s.left(1) != "/") { | 1138 | if(s.left(1) != "/") { |
1163 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | 1139 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); |
1164 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 1140 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
1165 | lnk.setIcon("SoundPlayer"); | 1141 | lnk.setIcon("SoundPlayer"); |
1166 | } else { | 1142 | } else { |
1167 | // qDebug("set link2 "+s); | 1143 | // qDebug("set link2 "+s); |
1168 | lnk.setFile( s); | 1144 | lnk.setFile( s); |
1169 | lnk.setIcon("SoundPlayer"); | 1145 | lnk.setIcon("SoundPlayer"); |
1170 | } | 1146 | } |
1171 | } | 1147 | } |
1172 | d->selectedFiles->addToSelection( lnk ); | 1148 | d->selectedFiles->addToSelection( lnk ); |
1173 | } | 1149 | } |
1174 | Config config( "OpiePlayer" ); | 1150 | Config config( "OpiePlayer" ); |
1175 | config.setGroup( "PlayList" ); | 1151 | config.setGroup( "PlayList" ); |
1176 | 1152 | ||
1177 | config.writeEntry("CurrentPlaylist",filename); | 1153 | config.writeEntry("CurrentPlaylist",filename); |
1178 | config.write(); | 1154 | config.write(); |
1179 | currentPlayList=filename; | 1155 | currentPlayList=filename; |
1180 | 1156 | ||
1181 | // m3uList->write(); | 1157 | // m3uList->write(); |
1182 | m3uList->close(); | 1158 | m3uList->close(); |
1183 | if(m3uList) delete m3uList; | 1159 | if(m3uList) delete m3uList; |
1184 | 1160 | ||
1185 | d->selectedFiles->setSelectedItem( s); | 1161 | d->selectedFiles->setSelectedItem( s); |
1186 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename))); | 1162 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename))); |
1187 | 1163 | ||
1188 | } | 1164 | } |
1189 | 1165 | ||
1190 | /* | 1166 | /* |
1191 | reads pls and adds files/urls to playlist */ | 1167 | reads pls and adds files/urls to playlist */ |
1192 | void PlayListWidget::readPls( const QString &filename ) { | 1168 | void PlayListWidget::readPls( const QString &filename ) { |
1193 | 1169 | ||
1194 | qDebug( "pls filename is " + filename ); | 1170 | // qDebug( "pls filename is " + filename ); |
1195 | Om3u *m3uList; | 1171 | Om3u *m3uList; |
1196 | QString s, name; | 1172 | QString s, name; |
1197 | m3uList = new Om3u( filename, IO_ReadOnly ); | 1173 | m3uList = new Om3u( filename, IO_ReadOnly ); |
1198 | m3uList->readPls(); | 1174 | m3uList->readPls(); |
1199 | 1175 | ||
1200 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 1176 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
1201 | s = *it; | 1177 | s = *it; |
1202 | // s.replace( QRegExp( "%20" )," " ); | 1178 | // s.replace( QRegExp( "%20" )," " ); |
1203 | DocLnk lnk( s ); | 1179 | DocLnk lnk( s ); |
1204 | QFileInfo f( s ); | 1180 | QFileInfo f( s ); |
1205 | QString name = fullBaseName ( f); | 1181 | QString name = fullBaseName ( f); |
1206 | 1182 | ||
1207 | if( name.left( 4 ) == "http" ) { | 1183 | if( name.left( 4 ) == "http" ) { |
1208 | name = s.right( s.length() - 7); | 1184 | name = s.right( s.length() - 7); |
1209 | } else { | 1185 | } else { |
1210 | name = s; | 1186 | name = s; |
1211 | } | 1187 | } |
1212 | 1188 | ||
1213 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 1189 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
1214 | 1190 | ||
1215 | lnk.setName( name ); | 1191 | lnk.setName( name ); |
1216 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | 1192 | if( s.at( s.length() - 4) == '.') {// if this is probably a file |
1217 | lnk.setFile( s ); | 1193 | lnk.setFile( s ); |
1218 | } else { //if its a url | 1194 | } else { //if its a url |
1219 | if( name.right( 1 ).find( '/' ) == -1) { | 1195 | if( name.right( 1 ).find( '/' ) == -1) { |
1220 | s += "/"; | 1196 | s += "/"; |
1221 | } | 1197 | } |
1222 | lnk.setFile( s ); | 1198 | lnk.setFile( s ); |
1223 | } | 1199 | } |
1224 | lnk.setType( "audio/x-mpegurl" ); | 1200 | lnk.setType( "audio/x-mpegurl" ); |
1225 | 1201 | ||
1226 | lnk.writeLink(); | 1202 | lnk.writeLink(); |
1227 | d->selectedFiles->addToSelection( lnk ); | 1203 | d->selectedFiles->addToSelection( lnk ); |
1228 | } | 1204 | } |
1229 | 1205 | ||
1230 | m3uList->close(); | 1206 | m3uList->close(); |
1231 | if(m3uList) delete m3uList; | 1207 | if(m3uList) delete m3uList; |
1232 | } | 1208 | } |
1233 | 1209 | ||
1234 | /* | 1210 | /* |
1235 | writes current playlist to current m3u file */ | 1211 | writes current playlist to current m3u file */ |
1236 | void PlayListWidget::writeCurrentM3u() { | 1212 | void PlayListWidget::writeCurrentM3u() { |
1237 | qDebug("writing to current m3u"); | 1213 | // qDebug("writing to current m3u"); |
1238 | Config cfg( "OpiePlayer" ); | 1214 | Config cfg( "OpiePlayer" ); |
1239 | cfg.setGroup("PlayList"); | 1215 | cfg.setGroup("PlayList"); |
1240 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 1216 | currentPlayList = cfg.readEntry("CurrentPlaylist",""); |
1241 | Om3u *m3uList; | 1217 | Om3u *m3uList; |
1242 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 1218 | m3uList = new Om3u( currentPlayList, IO_ReadWrite | IO_Truncate ); |
1243 | 1219 | ||
1244 | if( d->selectedFiles->first()) { | 1220 | if( d->selectedFiles->first()) { |
1245 | do { | 1221 | do { |
1246 | qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); | 1222 | // qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); |
1247 | m3uList->add( d->selectedFiles->current()->file() ); | 1223 | m3uList->add( d->selectedFiles->current()->file() ); |
1248 | } | 1224 | } |
1249 | while ( d->selectedFiles->next() ); | 1225 | while ( d->selectedFiles->next() ); |
1250 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 1226 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
1251 | m3uList->write(); | 1227 | m3uList->write(); |
1252 | m3uList->close(); | 1228 | m3uList->close(); |
1253 | 1229 | ||
1254 | if(m3uList) delete m3uList; | 1230 | if(m3uList) delete m3uList; |
@@ -1257,60 +1233,60 @@ void PlayListWidget::writeCurrentM3u() { | |||
1257 | 1233 | ||
1258 | /* | 1234 | /* |
1259 | writes current playlist to m3u file */ | 1235 | writes current playlist to m3u file */ |
1260 | void PlayListWidget::writem3u() { | 1236 | void PlayListWidget::writem3u() { |
1261 | InputDialog *fileDlg; | 1237 | InputDialog *fileDlg; |
1262 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 1238 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
1263 | fileDlg->exec(); | 1239 | fileDlg->exec(); |
1264 | QString name, filename, list; | 1240 | QString name, filename, list; |
1265 | Om3u *m3uList; | 1241 | Om3u *m3uList; |
1266 | 1242 | ||
1267 | if( fileDlg->result() == 1 ) { | 1243 | if( fileDlg->result() == 1 ) { |
1268 | name = fileDlg->text(); | 1244 | name = fileDlg->text(); |
1269 | // qDebug( filename ); | 1245 | // qDebug( filename ); |
1270 | if( name.find("/",0,true) != -1) {// assume they specify a file path | 1246 | if( name.find("/",0,true) != -1) {// assume they specify a file path |
1271 | filename = name; | 1247 | filename = name; |
1272 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); | 1248 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); |
1273 | } | 1249 | } |
1274 | else //otherwise dump it somewhere noticable | 1250 | else //otherwise dump it somewhere noticable |
1275 | filename = QPEApplication::documentDir() + "/" + name; | 1251 | filename = QPEApplication::documentDir() + "/" + name; |
1276 | 1252 | ||
1277 | if( filename.right( 3 ) != "m3u" ) //needs filename extension | 1253 | if( filename.right( 3 ) != "m3u" ) //needs filename extension |
1278 | filename += ".m3u"; | 1254 | filename += ".m3u"; |
1279 | 1255 | ||
1280 | if( d->selectedFiles->first()) { | 1256 | if( d->selectedFiles->first()) { |
1281 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 1257 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
1282 | 1258 | ||
1283 | do { | 1259 | do { |
1284 | m3uList->add( d->selectedFiles->current()->file()); | 1260 | m3uList->add( d->selectedFiles->current()->file()); |
1285 | } | 1261 | } |
1286 | while ( d->selectedFiles->next() ); | 1262 | while ( d->selectedFiles->next() ); |
1287 | // qDebug( list ); | 1263 | // qDebug( list ); |
1288 | m3uList->write(); | 1264 | m3uList->write(); |
1289 | m3uList->close(); | 1265 | m3uList->close(); |
1290 | if(m3uList) delete m3uList; | 1266 | if(m3uList) delete m3uList; |
1291 | 1267 | ||
1292 | if(fileDlg) delete fileDlg; | 1268 | if(fileDlg) delete fileDlg; |
1293 | 1269 | ||
1294 | DocLnk lnk; | 1270 | DocLnk lnk; |
1295 | lnk.setFile( filename); | 1271 | lnk.setFile( filename); |
1296 | lnk.setIcon("opieplayer2/playlist2"); | 1272 | lnk.setIcon("opieplayer2/playlist2"); |
1297 | lnk.setName( name); //sets file name | 1273 | lnk.setName( name); //sets file name |
1298 | 1274 | ||
1299 | // qDebug(filename); | 1275 | // qDebug(filename); |
1300 | Config config( "OpiePlayer" ); | 1276 | Config config( "OpiePlayer" ); |
1301 | config.setGroup( "PlayList" ); | 1277 | config.setGroup( "PlayList" ); |
1302 | 1278 | ||
1303 | config.writeEntry("CurrentPlaylist",filename); | 1279 | config.writeEntry("CurrentPlaylist",filename); |
1304 | currentPlayList=filename; | 1280 | currentPlayList=filename; |
1305 | 1281 | ||
1306 | if(!lnk.writeLink()) { | 1282 | if(!lnk.writeLink()) { |
1307 | qDebug("Writing doclink did not work"); | 1283 | // qDebug("Writing doclink did not work"); |
1308 | } | 1284 | } |
1309 | 1285 | ||
1310 | setCaption(tr("OpiePlayer: ") + name); | 1286 | setCaption(tr("OpiePlayer: ") + name); |
1311 | } | 1287 | } |
1312 | } | 1288 | } |
1313 | } | 1289 | } |
1314 | 1290 | ||
1315 | 1291 | ||
1316 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | 1292 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) |
@@ -1333,9 +1309,8 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | |||
1333 | case Key_F13: //mail | 1309 | case Key_F13: //mail |
1334 | // doUnblank(); | 1310 | // doUnblank(); |
1335 | break; | 1311 | break; |
1336 | case Key_Q: //add to playlist | 1312 | case Key_Q: //add to playlist |
1337 | qDebug("Add"); | ||
1338 | addSelected(); | 1313 | addSelected(); |
1339 | break; | 1314 | break; |
1340 | case Key_R: //remove from playlist | 1315 | case Key_R: //remove from playlist |
1341 | removeSelected(); | 1316 | removeSelected(); |
@@ -1344,9 +1319,8 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | |||
1344 | // qDebug("Play"); | 1319 | // qDebug("Play"); |
1345 | // playSelected(); | 1320 | // playSelected(); |
1346 | // break; | 1321 | // break; |
1347 | case Key_Space: | 1322 | case Key_Space: |
1348 | qDebug("Play"); | ||
1349 | // playSelected(); puh | 1323 | // playSelected(); puh |
1350 | break; | 1324 | break; |
1351 | case Key_1: | 1325 | case Key_1: |
1352 | tabWidget->setCurrentPage(0); | 1326 | tabWidget->setCurrentPage(0); |
@@ -1397,72 +1371,72 @@ void PlayListWidget::keyPressEvent( QKeyEvent *) | |||
1397 | // } | 1371 | // } |
1398 | } | 1372 | } |
1399 | 1373 | ||
1400 | void PlayListWidget::doBlank() { | 1374 | void PlayListWidget::doBlank() { |
1401 | qDebug("do blanking"); | 1375 | // qDebug("do blanking"); |
1402 | fd=open("/dev/fb0",O_RDWR); | 1376 | fd=open("/dev/fb0",O_RDWR); |
1403 | if (fd != -1) { | 1377 | if (fd != -1) { |
1404 | ioctl(fd,FBIOBLANK,1); | 1378 | ioctl(fd,FBIOBLANK,1); |
1405 | // close(fd); | 1379 | // close(fd); |
1406 | } | 1380 | } |
1407 | } | 1381 | } |
1408 | 1382 | ||
1409 | void PlayListWidget::doUnblank() { | 1383 | void PlayListWidget::doUnblank() { |
1410 | // this crashes opieplayer with a segfault | 1384 | // this crashes opieplayer with a segfault |
1411 | // int fd; | 1385 | // int fd; |
1412 | // fd=open("/dev/fb0",O_RDWR); | 1386 | // fd=open("/dev/fb0",O_RDWR); |
1413 | qDebug("do unblanking"); | 1387 | // qDebug("do unblanking"); |
1414 | if (fd != -1) { | 1388 | if (fd != -1) { |
1415 | ioctl(fd,FBIOBLANK,0); | 1389 | ioctl(fd,FBIOBLANK,0); |
1416 | close(fd); | 1390 | close(fd); |
1417 | } | 1391 | } |
1418 | QCopEnvelope h("QPE/System", "setBacklight(int)"); | 1392 | QCopEnvelope h("QPE/System", "setBacklight(int)"); |
1419 | h <<-3;// v[1]; // -3 Force on | 1393 | h <<-3;// v[1]; // -3 Force on |
1420 | } | 1394 | } |
1421 | 1395 | ||
1422 | void PlayListWidget::populateSkinsMenu() { | 1396 | void PlayListWidget::populateSkinsMenu() { |
1423 | int item = 0; | 1397 | int item = 0; |
1424 | defaultSkinIndex = 0; | 1398 | defaultSkinIndex = 0; |
1425 | QString skinName; | 1399 | QString skinName; |
1426 | Config cfg( "OpiePlayer" ); | 1400 | Config cfg( "OpiePlayer" ); |
1427 | cfg.setGroup("Options" ); | 1401 | cfg.setGroup("Options" ); |
1428 | QString skin = cfg.readEntry( "Skin", "default" ); | 1402 | QString skin = cfg.readEntry( "Skin", "default" ); |
1429 | 1403 | ||
1430 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 1404 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
1431 | skinsDir.setFilter( QDir::Dirs ); | 1405 | skinsDir.setFilter( QDir::Dirs ); |
1432 | skinsDir.setSorting(QDir::Name ); | 1406 | skinsDir.setSorting(QDir::Name ); |
1433 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 1407 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
1434 | QFileInfoListIterator it( *skinslist ); | 1408 | QFileInfoListIterator it( *skinslist ); |
1435 | QFileInfo *fi; | 1409 | QFileInfo *fi; |
1436 | while ( ( fi = it.current() ) ) { | 1410 | while ( ( fi = it.current() ) ) { |
1437 | skinName = fi->fileName(); | 1411 | skinName = fi->fileName(); |
1438 | // qDebug( fi->fileName() ); | 1412 | // qDebug( fi->fileName() ); |
1439 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 1413 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
1440 | item = skinsMenu->insertItem( fi->fileName() ) ; | 1414 | item = skinsMenu->insertItem( fi->fileName() ) ; |
1441 | } | 1415 | } |
1442 | if( skinName == "default" ) { | 1416 | if( skinName == "default" ) { |
1443 | defaultSkinIndex = item; | 1417 | defaultSkinIndex = item; |
1444 | } | 1418 | } |
1445 | if( skinName == skin ) { | 1419 | if( skinName == skin ) { |
1446 | skinsMenu->setItemChecked( item, TRUE ); | 1420 | skinsMenu->setItemChecked( item, TRUE ); |
1447 | } | 1421 | } |
1448 | ++it; | 1422 | ++it; |
1449 | } | 1423 | } |
1450 | } | 1424 | } |
1451 | 1425 | ||
1452 | void PlayListWidget::skinsMenuActivated( int item ) { | 1426 | void PlayListWidget::skinsMenuActivated( int item ) { |
1453 | for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 1427 | for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
1454 | skinsMenu->setItemChecked( i, FALSE ); | 1428 | skinsMenu->setItemChecked( i, FALSE ); |
1455 | } | 1429 | } |
1456 | skinsMenu->setItemChecked( item, TRUE ); | 1430 | skinsMenu->setItemChecked( item, TRUE ); |
1457 | 1431 | ||
1458 | Config cfg( "OpiePlayer" ); | 1432 | Config cfg( "OpiePlayer" ); |
1459 | cfg.setGroup("Options"); | 1433 | cfg.setGroup("Options"); |
1460 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 1434 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
1461 | } | 1435 | } |
1462 | 1436 | ||
1463 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { | 1437 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { |
1464 | qDebug("qcop message "+msg ); | 1438 | // qDebug("qcop message "+msg ); |
1465 | QDataStream stream ( data, IO_ReadOnly ); | 1439 | QDataStream stream ( data, IO_ReadOnly ); |
1466 | if ( msg == "play()" ) { //plays current selection | 1440 | if ( msg == "play()" ) { //plays current selection |
1467 | btnPlay( true); | 1441 | btnPlay( true); |
1468 | } else if ( msg == "stop()" ) { | 1442 | } else if ( msg == "stop()" ) { |
@@ -1477,13 +1451,13 @@ void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { | |||
1477 | mediaPlayerState->toggleLooping(); | 1451 | mediaPlayerState->toggleLooping(); |
1478 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled | 1452 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled |
1479 | mediaPlayerState->toggleShuffled(); | 1453 | mediaPlayerState->toggleShuffled(); |
1480 | } else if ( msg == "volUp()" ) { //volume more | 1454 | } else if ( msg == "volUp()" ) { //volume more |
1481 | // emit moreClicked(); | 1455 | // emit moreClicked(); |
1482 | // emit moreReleased(); | 1456 | // emit moreReleased(); |
1483 | } else if ( msg == "volDown()" ) { //volume less | 1457 | } else if ( msg == "volDown()" ) { //volume less |
1484 | // emit lessClicked(); | 1458 | // emit lessClicked(); |
1485 | // emit lessReleased(); | 1459 | // emit lessReleased(); |
1486 | } else if ( msg == "play(QString)" ) { //play this now | 1460 | } else if ( msg == "play(QString)" ) { //play this now |
1487 | QString file; | 1461 | QString file; |
1488 | stream >> file; | 1462 | stream >> file; |
1489 | setDocumentEx( (const QString &) file); | 1463 | setDocumentEx( (const QString &) file); |
@@ -1497,10 +1471,8 @@ void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { | |||
1497 | addToSelection( lnk ); | 1471 | addToSelection( lnk ); |
1498 | } else if ( msg == "rem(QString)" ) { //remove from playlist | 1472 | } else if ( msg == "rem(QString)" ) { //remove from playlist |
1499 | QString file; | 1473 | QString file; |
1500 | stream >> file; | 1474 | stream >> file; |
1501 | |||
1502 | } else if ( msg == "setDocument(QString)" ) { //loop or not loop | 1475 | } else if ( msg == "setDocument(QString)" ) { //loop or not loop |
1503 | QCopEnvelope h("QPE/Application/opieplayer", "raise()"); | 1476 | QCopEnvelope h("QPE/Application/opieplayer", "raise()"); |
1504 | } | 1477 | } |
1505 | |||
1506 | } | 1478 | } |