-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index efb5df3..3609f5d 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -1,165 +1,165 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 | 20 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 |
21 | #define QTOPIA_INTERNAL_FSLP | 21 | #define QTOPIA_INTERNAL_FSLP |
22 | 22 | ||
23 | #include <qtoolbar.h> | 23 | #include <qtoolbar.h> |
24 | #include <qpe/qpemenubar.h> | 24 | #include <qpe/qpemenubar.h> |
25 | #include <qpe/lnkproperties.h> | 25 | #include <qpe/lnkproperties.h> |
26 | 26 | ||
27 | #include <qaction.h> | 27 | #include <qaction.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qmessagebox.h> | 29 | #include <qmessagebox.h> |
30 | 30 | ||
31 | //#include <qtimer.h> | 31 | //#include <qtimer.h> |
32 | 32 | ||
33 | #include "playlistselection.h" | 33 | #include "playlistselection.h" |
34 | #include "playlistwidget.h" | 34 | #include "playlistwidget.h" |
35 | #include "mediaplayerstate.h" | 35 | #include "mediaplayerstate.h" |
36 | 36 | ||
37 | #include "inputDialog.h" | 37 | #include "inputDialog.h" |
38 | 38 | ||
39 | #include <stdlib.h> | 39 | #include <stdlib.h> |
40 | #include "audiowidget.h" | 40 | #include "audiowidget.h" |
41 | #include "videowidget.h" | 41 | #include "videowidget.h" |
42 | 42 | ||
43 | #include <unistd.h> | 43 | #include <unistd.h> |
44 | #include <sys/file.h> | 44 | #include <sys/file.h> |
45 | #include <sys/ioctl.h> | 45 | #include <sys/ioctl.h> |
46 | #include <sys/soundcard.h> | 46 | #include <sys/soundcard.h> |
47 | 47 | ||
48 | // for setBacklight() | 48 | // for setBacklight() |
49 | #include <linux/fb.h> | 49 | #include <linux/fb.h> |
50 | #include <sys/types.h> | 50 | #include <sys/types.h> |
51 | #include <sys/stat.h> | 51 | #include <sys/stat.h> |
52 | #include <stdlib.h> | 52 | #include <stdlib.h> |
53 | 53 | ||
54 | #define BUTTONS_ON_TOOLBAR | 54 | #define BUTTONS_ON_TOOLBAR |
55 | #define SIDE_BUTTONS | 55 | #define SIDE_BUTTONS |
56 | #define CAN_SAVE_LOAD_PLAYLISTS | 56 | #define CAN_SAVE_LOAD_PLAYLISTS |
57 | 57 | ||
58 | extern AudioWidget *audioUI; | 58 | extern AudioWidget *audioUI; |
59 | extern VideoWidget *videoUI; | 59 | extern VideoWidget *videoUI; |
60 | extern MediaPlayerState *mediaPlayerState; | 60 | extern MediaPlayerState *mediaPlayerState; |
61 | 61 | ||
62 | static inline QString fullBaseName ( const QFileInfo &fi ) | 62 | static inline QString fullBaseName ( const QFileInfo &fi ) |
63 | { | 63 | { |
64 | QString str = fi. fileName ( ); | 64 | QString str = fi. fileName ( ); |
65 | return str. left ( str. findRev ( '.' )); | 65 | return str. left ( str. findRev ( '.' )); |
66 | } | 66 | } |
67 | 67 | ||
68 | 68 | ||
69 | QString audioMimes ="audio/mpeg;audio/x-wav;application/ogg;audio/x-mod"; | 69 | QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg;audio/x-mod"; |
70 | // class myFileSelector { | 70 | // class myFileSelector { |
71 | 71 | ||
72 | // }; | 72 | // }; |
73 | class PlayListWidgetPrivate { | 73 | class PlayListWidgetPrivate { |
74 | public: | 74 | public: |
75 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | 75 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
76 | QFrame *playListFrame; | 76 | QFrame *playListFrame; |
77 | FileSelector *files; | 77 | FileSelector *files; |
78 | PlayListSelection *selectedFiles; | 78 | PlayListSelection *selectedFiles; |
79 | bool setDocumentUsed; | 79 | bool setDocumentUsed; |
80 | DocLnk *current; | 80 | DocLnk *current; |
81 | }; | 81 | }; |
82 | 82 | ||
83 | 83 | ||
84 | class ToolButton : public QToolButton { | 84 | class ToolButton : public QToolButton { |
85 | public: | 85 | public: |
86 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 86 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
87 | : QToolButton( parent, name ) { | 87 | : QToolButton( parent, name ) { |
88 | setTextLabel( name ); | 88 | setTextLabel( name ); |
89 | setPixmap( Resource::loadPixmap( icon ) ); | 89 | setPixmap( Resource::loadPixmap( icon ) ); |
90 | setAutoRaise( TRUE ); | 90 | setAutoRaise( TRUE ); |
91 | setFocusPolicy( QWidget::NoFocus ); | 91 | setFocusPolicy( QWidget::NoFocus ); |
92 | setToggleButton( t ); | 92 | setToggleButton( t ); |
93 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 93 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
94 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 94 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
95 | } | 95 | } |
96 | }; | 96 | }; |
97 | 97 | ||
98 | 98 | ||
99 | class MenuItem : public QAction { | 99 | class MenuItem : public QAction { |
100 | public: | 100 | public: |
101 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 101 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
102 | : QAction( text, QString::null, 0, 0 ) { | 102 | : QAction( text, QString::null, 0, 0 ) { |
103 | connect( this, SIGNAL( activated() ), handler, slot ); | 103 | connect( this, SIGNAL( activated() ), handler, slot ); |
104 | addTo( parent ); | 104 | addTo( parent ); |
105 | } | 105 | } |
106 | }; | 106 | }; |
107 | 107 | ||
108 | 108 | ||
109 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 109 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
110 | : QMainWindow( parent, name, fl ) { | 110 | : QMainWindow( parent, name, fl ) { |
111 | 111 | ||
112 | d = new PlayListWidgetPrivate; | 112 | d = new PlayListWidgetPrivate; |
113 | d->setDocumentUsed = FALSE; | 113 | d->setDocumentUsed = FALSE; |
114 | d->current = NULL; | 114 | d->current = NULL; |
115 | fromSetDocument = FALSE; | 115 | fromSetDocument = FALSE; |
116 | insanityBool=FALSE; | 116 | insanityBool=FALSE; |
117 | audioScan = FALSE; | 117 | audioScan = FALSE; |
118 | videoScan = FALSE; | 118 | videoScan = FALSE; |
119 | // menuTimer = new QTimer( this ,"menu timer"), | 119 | // menuTimer = new QTimer( this ,"menu timer"), |
120 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); | 120 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); |
121 | channel = new QCopChannel( "QPE/Application/opieplayer", this ); | 121 | channel = new QCopChannel( "QPE/Application/opieplayer", this ); |
122 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), | 122 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
123 | this, SLOT( qcopReceive(const QCString&,const QByteArray&)) ); | 123 | this, SLOT( qcopReceive(const QCString&,const QByteArray&)) ); |
124 | 124 | ||
125 | setBackgroundMode( PaletteButton ); | 125 | setBackgroundMode( PaletteButton ); |
126 | 126 | ||
127 | setCaption( tr("OpiePlayer") ); | 127 | setCaption( tr("OpiePlayer") ); |
128 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); | 128 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); |
129 | 129 | ||
130 | setToolBarsMovable( FALSE ); | 130 | setToolBarsMovable( FALSE ); |
131 | 131 | ||
132 | // Create Toolbar | 132 | // Create Toolbar |
133 | QToolBar *toolbar = new QToolBar( this ); | 133 | QToolBar *toolbar = new QToolBar( this ); |
134 | toolbar->setHorizontalStretchable( TRUE ); | 134 | toolbar->setHorizontalStretchable( TRUE ); |
135 | 135 | ||
136 | // Create Menubar | 136 | // Create Menubar |
137 | QMenuBar *menu = new QMenuBar( toolbar ); | 137 | QMenuBar *menu = new QMenuBar( toolbar ); |
138 | menu->setMargin( 0 ); | 138 | menu->setMargin( 0 ); |
139 | 139 | ||
140 | QToolBar *bar = new QToolBar( this ); | 140 | QToolBar *bar = new QToolBar( this ); |
141 | bar->setLabel( tr( "Play Operations" ) ); | 141 | bar->setLabel( tr( "Play Operations" ) ); |
142 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", | 142 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", |
143 | // this , SLOT( addSelected()) ); | 143 | // this , SLOT( addSelected()) ); |
144 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); | 144 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); |
145 | tbDeletePlaylist->setFlat(TRUE); | 145 | tbDeletePlaylist->setFlat(TRUE); |
146 | 146 | ||
147 | tbDeletePlaylist->setFixedSize(20,20); | 147 | tbDeletePlaylist->setFixedSize(20,20); |
148 | 148 | ||
149 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", | 149 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", |
150 | this , SLOT(addSelected()) ); | 150 | this , SLOT(addSelected()) ); |
151 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", | 151 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", |
152 | this , SLOT(removeSelected()) ); | 152 | this , SLOT(removeSelected()) ); |
153 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool)/*btnPlay()*/), TRUE ); | 153 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool)/*btnPlay()*/), TRUE ); |
154 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", | 154 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", |
155 | this , SLOT( btnPlay(bool) ), TRUE ); | 155 | this , SLOT( btnPlay(bool) ), TRUE ); |
156 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", | 156 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", |
157 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 157 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); |
158 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", | 158 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", |
159 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 159 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); |
160 | tbDeletePlaylist->hide(); | 160 | tbDeletePlaylist->hide(); |
161 | 161 | ||
162 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 162 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
163 | menu->insertItem( tr( "File" ), pmPlayList ); | 163 | menu->insertItem( tr( "File" ), pmPlayList ); |
164 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 164 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
165 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 165 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 1a5e474..4460833 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -572,193 +572,193 @@ void PlayListWidget::tabChanged(QWidget *) { | |||
572 | } | 572 | } |
573 | 573 | ||
574 | 574 | ||
575 | void PlayListWidget::btnPlay(bool b) { | 575 | void PlayListWidget::btnPlay(bool b) { |
576 | // mediaPlayerState->setPlaying(false); | 576 | // mediaPlayerState->setPlaying(false); |
577 | mediaPlayerState->setPlaying(b); | 577 | mediaPlayerState->setPlaying(b); |
578 | insanityBool=FALSE; | 578 | insanityBool=FALSE; |
579 | } | 579 | } |
580 | 580 | ||
581 | void PlayListWidget::deletePlaylist() { | 581 | void PlayListWidget::deletePlaylist() { |
582 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 582 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
583 | (tr("You really want to delete\nthis playlist?")), | 583 | (tr("You really want to delete\nthis playlist?")), |
584 | (tr("Yes")), (tr("No")), 0 )){ | 584 | (tr("Yes")), (tr("No")), 0 )){ |
585 | case 0: // Yes clicked, | 585 | case 0: // Yes clicked, |
586 | QFile().remove(playLists->selectedDocument().file()); | 586 | QFile().remove(playLists->selectedDocument().file()); |
587 | QFile().remove(playLists->selectedDocument().linkFile()); | 587 | QFile().remove(playLists->selectedDocument().linkFile()); |
588 | playLists->reread(); | 588 | playLists->reread(); |
589 | break; | 589 | break; |
590 | case 1: // Cancel | 590 | case 1: // Cancel |
591 | break; | 591 | break; |
592 | }; | 592 | }; |
593 | } | 593 | } |
594 | 594 | ||
595 | 595 | ||
596 | void PlayListWidget::playSelected() { | 596 | void PlayListWidget::playSelected() { |
597 | btnPlay( TRUE); | 597 | btnPlay( TRUE); |
598 | } | 598 | } |
599 | 599 | ||
600 | bool PlayListWidget::inFileListMode() const | 600 | bool PlayListWidget::inFileListMode() const |
601 | { | 601 | { |
602 | TabType tab = currentTab(); | 602 | TabType tab = currentTab(); |
603 | return tab == AudioFiles || tab == VideoFiles; | 603 | return tab == AudioFiles || tab == VideoFiles; |
604 | } | 604 | } |
605 | 605 | ||
606 | void PlayListWidget::openURL() { | 606 | void PlayListWidget::openURL() { |
607 | // http://66.28.164.33:2080 | 607 | // http://66.28.164.33:2080 |
608 | // http://somafm.com/star0242.m3u | 608 | // http://somafm.com/star0242.m3u |
609 | QString filename, name; | 609 | QString filename, name; |
610 | InputDialog *fileDlg; | 610 | InputDialog *fileDlg; |
611 | fileDlg = new InputDialog(this,tr("Add URL"),TRUE, 0); | 611 | fileDlg = new InputDialog(this,tr("Add URL"),TRUE, 0); |
612 | fileDlg->exec(); | 612 | fileDlg->exec(); |
613 | if( fileDlg->result() == 1 ) { | 613 | if( fileDlg->result() == 1 ) { |
614 | filename = fileDlg->text(); | 614 | filename = fileDlg->text(); |
615 | qDebug( "Selected filename is " + filename ); | 615 | qDebug( "Selected filename is " + filename ); |
616 | // Om3u *m3uList; | 616 | // Om3u *m3uList; |
617 | DocLnk lnk; | 617 | DocLnk lnk; |
618 | Config cfg( "OpiePlayer" ); | 618 | Config cfg( "OpiePlayer" ); |
619 | cfg.setGroup("PlayList"); | 619 | cfg.setGroup("PlayList"); |
620 | 620 | ||
621 | if(filename.left(4) == "http") { | 621 | if(filename.left(4) == "http") { |
622 | QString m3uFile, m3uFilePath; | 622 | QString m3uFile, m3uFilePath; |
623 | if(filename.find(":",8,TRUE) != -1) { //found a port | 623 | if(filename.find(":",8,TRUE) != -1) { //found a port |
624 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 624 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
625 | m3uFile = m3uFile.right( 7); | 625 | m3uFile = m3uFile.right( 7); |
626 | } else if(filename.left(4) == "http"){ | 626 | } else if(filename.left(4) == "http"){ |
627 | m3uFile=filename; | 627 | m3uFile=filename; |
628 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 628 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
629 | } else{ | 629 | } else{ |
630 | m3uFile=filename; | 630 | m3uFile=filename; |
631 | } | 631 | } |
632 | 632 | ||
633 | lnk.setName( filename ); //sets name | 633 | lnk.setName( filename ); //sets name |
634 | lnk.setFile( filename ); //sets file name | 634 | lnk.setFile( filename ); //sets file name |
635 | 635 | ||
636 | // lnk.setIcon("opieplayer2/musicfile"); | 636 | // lnk.setIcon("opieplayer2/musicfile"); |
637 | 637 | ||
638 | d->selectedFiles->addToSelection( lnk ); | 638 | d->selectedFiles->addToSelection( lnk ); |
639 | writeCurrentM3u(); | 639 | writeCurrentM3u(); |
640 | d->selectedFiles->setSelectedItem( lnk.name()); | 640 | d->selectedFiles->setSelectedItem( lnk.name()); |
641 | } | 641 | } |
642 | else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { | 642 | else if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { |
643 | readListFromFile( filename ); | 643 | readListFromFile( filename ); |
644 | } else { | 644 | } else { |
645 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 645 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
646 | lnk.setFile( filename ); //sets file name | 646 | lnk.setFile( filename ); //sets file name |
647 | d->selectedFiles->addToSelection( lnk); | 647 | d->selectedFiles->addToSelection( lnk); |
648 | writeCurrentM3u(); | 648 | writeCurrentM3u(); |
649 | d->selectedFiles->setSelectedItem( lnk.name()); | 649 | d->selectedFiles->setSelectedItem( lnk.name()); |
650 | } | 650 | } |
651 | } | 651 | } |
652 | 652 | ||
653 | 653 | ||
654 | delete fileDlg; | 654 | delete fileDlg; |
655 | } | 655 | } |
656 | 656 | ||
657 | 657 | ||
658 | void PlayListWidget::openFile() { | 658 | void PlayListWidget::openFile() { |
659 | 659 | ||
660 | QString filename, name; | 660 | QString filename, name; |
661 | 661 | ||
662 | Config cfg( "OpiePlayer" ); | 662 | Config cfg( "OpiePlayer" ); |
663 | cfg.setGroup("Dialog"); | 663 | cfg.setGroup("Dialog"); |
664 | MimeTypes types; | 664 | MimeTypes types; |
665 | QStringList audio, video, all; | 665 | QStringList audio, video, all; |
666 | audio << "audio/*"; | 666 | audio << "audio/*"; |
667 | audio << "playlist/plain"; | 667 | audio << "playlist/plain"; |
668 | audio << "application/ogg"; | 668 | audio << "audio/x-ogg"; |
669 | audio << "audio/x-mpegurl"; | 669 | audio << "audio/x-mpegurl"; |
670 | 670 | ||
671 | video << "video/*"; | 671 | video << "video/*"; |
672 | video << "playlist/plain"; | 672 | video << "playlist/plain"; |
673 | 673 | ||
674 | all += audio; | 674 | all += audio; |
675 | all += video; | 675 | all += video; |
676 | types.insert("All Media Files", all ); | 676 | types.insert("All Media Files", all ); |
677 | types.insert("Audio", audio ); | 677 | types.insert("Audio", audio ); |
678 | types.insert("Video", video ); | 678 | types.insert("Video", video ); |
679 | 679 | ||
680 | QString str = OFileDialog::getOpenFileName( 1, | 680 | QString str = OFileDialog::getOpenFileName( 1, |
681 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", | 681 | cfg.readEntry("LastDirectory",QPEApplication::documentDir()),"", |
682 | types, 0 ); | 682 | types, 0 ); |
683 | 683 | ||
684 | if(str.left(2) == "//") { | 684 | if(str.left(2) == "//") { |
685 | str=str.right(str.length()-1); | 685 | str=str.right(str.length()-1); |
686 | } | 686 | } |
687 | cfg.writeEntry( "LastDirectory" ,QFileInfo( str ).dirPath() ); | 687 | cfg.writeEntry( "LastDirectory" ,QFileInfo( str ).dirPath() ); |
688 | 688 | ||
689 | if( !str.isEmpty() ) { | 689 | if( !str.isEmpty() ) { |
690 | 690 | ||
691 | qDebug( "Selected filename is " + str ); | 691 | qDebug( "Selected filename is " + str ); |
692 | filename = str; | 692 | filename = str; |
693 | DocLnk lnk; | 693 | DocLnk lnk; |
694 | 694 | ||
695 | if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { | 695 | if( filename.right( 3) == "m3u" || filename.right(3) == "pls" ) { |
696 | readListFromFile( filename ); | 696 | readListFromFile( filename ); |
697 | } else { | 697 | } else { |
698 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 698 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
699 | lnk.setFile( filename ); //sets file name | 699 | lnk.setFile( filename ); //sets file name |
700 | d->selectedFiles->addToSelection( lnk ); | 700 | d->selectedFiles->addToSelection( lnk ); |
701 | writeCurrentM3u(); | 701 | writeCurrentM3u(); |
702 | d->selectedFiles->setSelectedItem( lnk.name() ); | 702 | d->selectedFiles->setSelectedItem( lnk.name() ); |
703 | } | 703 | } |
704 | } | 704 | } |
705 | } | 705 | } |
706 | 706 | ||
707 | 707 | ||
708 | void PlayListWidget::readListFromFile( const QString &filename ) { | 708 | void PlayListWidget::readListFromFile( const QString &filename ) { |
709 | qDebug( "read list filename " + filename ); | 709 | qDebug( "read list filename " + filename ); |
710 | QFileInfo fi(filename); | 710 | QFileInfo fi(filename); |
711 | Om3u *m3uList; | 711 | Om3u *m3uList; |
712 | QString s, name; | 712 | QString s, name; |
713 | m3uList = new Om3u( filename, IO_ReadOnly ); | 713 | m3uList = new Om3u( filename, IO_ReadOnly ); |
714 | if(fi.extension(false).find("m3u",0,false) != -1 ) | 714 | if(fi.extension(false).find("m3u",0,false) != -1 ) |
715 | m3uList->readM3u(); | 715 | m3uList->readM3u(); |
716 | else if(fi.extension(false).find("pls",0,false) != -1 ) | 716 | else if(fi.extension(false).find("pls",0,false) != -1 ) |
717 | m3uList->readPls(); | 717 | m3uList->readPls(); |
718 | 718 | ||
719 | DocLnk lnk; | 719 | DocLnk lnk; |
720 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 720 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
721 | s = *it; | 721 | s = *it; |
722 | // qDebug(s); | 722 | // qDebug(s); |
723 | if(s.left(4)=="http") { | 723 | if(s.left(4)=="http") { |
724 | lnk.setName( s ); //sets file name | 724 | lnk.setName( s ); //sets file name |
725 | lnk.setIcon("opieplayer2/musicfile"); | 725 | lnk.setIcon("opieplayer2/musicfile"); |
726 | lnk.setFile( s ); //sets file name | 726 | lnk.setFile( s ); //sets file name |
727 | 727 | ||
728 | } else { //is file | 728 | } else { //is file |
729 | lnk.setName( QFileInfo(s).baseName()); | 729 | lnk.setName( QFileInfo(s).baseName()); |
730 | if(s.left(1) != "/") { | 730 | if(s.left(1) != "/") { |
731 | 731 | ||
732 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 732 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
733 | } else { | 733 | } else { |
734 | lnk.setFile( s); | 734 | lnk.setFile( s); |
735 | } | 735 | } |
736 | } | 736 | } |
737 | d->selectedFiles->addToSelection( lnk ); | 737 | d->selectedFiles->addToSelection( lnk ); |
738 | } | 738 | } |
739 | Config config( "OpiePlayer" ); | 739 | Config config( "OpiePlayer" ); |
740 | config.setGroup( "PlayList" ); | 740 | config.setGroup( "PlayList" ); |
741 | 741 | ||
742 | config.writeEntry("CurrentPlaylist",filename); | 742 | config.writeEntry("CurrentPlaylist",filename); |
743 | config.write(); | 743 | config.write(); |
744 | currentPlayList=filename; | 744 | currentPlayList=filename; |
745 | 745 | ||
746 | m3uList->close(); | 746 | m3uList->close(); |
747 | delete m3uList; | 747 | delete m3uList; |
748 | 748 | ||
749 | d->selectedFiles->setSelectedItem( s); | 749 | d->selectedFiles->setSelectedItem( s); |
750 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 750 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
751 | 751 | ||
752 | } | 752 | } |
753 | 753 | ||
754 | // writes current playlist to current m3u file */ | 754 | // writes current playlist to current m3u file */ |
755 | void PlayListWidget::writeCurrentM3u() { | 755 | void PlayListWidget::writeCurrentM3u() { |
756 | qDebug("writing to current m3u"); | 756 | qDebug("writing to current m3u"); |
757 | Config cfg( "OpiePlayer" ); | 757 | Config cfg( "OpiePlayer" ); |
758 | cfg.setGroup("PlayList"); | 758 | cfg.setGroup("PlayList"); |
759 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 759 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
760 | 760 | ||
761 | Om3u *m3uList; | 761 | Om3u *m3uList; |
762 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 762 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
763 | if( d->selectedFiles->first()) { | 763 | if( d->selectedFiles->first()) { |
764 | 764 | ||