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