-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 147 |
1 files changed, 58 insertions, 89 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 8e88e9b..a6a9eca 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -1,1083 +1,1052 @@ | |||
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 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 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 <qpe/qpetoolbar.h> | 34 | #include <qpe/qpetoolbar.h> |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | #include <qpe/storage.h> | 36 | #include <qpe/storage.h> |
37 | #include <qpe/mimetype.h> | 37 | #include <qpe/mimetype.h> |
38 | #include <qpe/global.h> | 38 | #include <qpe/global.h> |
39 | #include <qpe/resource.h> | 39 | #include <qpe/resource.h> |
40 | 40 | ||
41 | #include <qdir.h> | 41 | #include <qdir.h> |
42 | #include <qmessagebox.h> | 42 | #include <qmessagebox.h> |
43 | #include <qregexp.h> | 43 | #include <qregexp.h> |
44 | #include <qtextstream.h> | 44 | #include <qtextstream.h> |
45 | 45 | ||
46 | #include "playlistselection.h" | 46 | #include "playlistselection.h" |
47 | #include "playlistwidget.h" | 47 | #include "playlistwidget.h" |
48 | #include "mediaplayerstate.h" | 48 | #include "mediaplayerstate.h" |
49 | #include "inputDialog.h" | 49 | #include "inputDialog.h" |
50 | #include "om3u.h" | 50 | #include "om3u.h" |
51 | 51 | ||
52 | //only needed for the random play | 52 | //only needed for the random play |
53 | #include <stdlib.h> | 53 | #include <stdlib.h> |
54 | 54 | ||
55 | #include "audiowidget.h" | 55 | #include "audiowidget.h" |
56 | #include "videowidget.h" | 56 | #include "videowidget.h" |
57 | 57 | ||
58 | extern MediaPlayerState *mediaPlayerState; | 58 | extern MediaPlayerState *mediaPlayerState; |
59 | // extern AudioWidget *audioUI; | 59 | // extern AudioWidget *audioUI; |
60 | // extern VideoWidget *videoUI; | 60 | // extern VideoWidget *videoUI; |
61 | 61 | ||
62 | QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg"; | 62 | QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg"; |
63 | // no m3u's here please | 63 | // no m3u's here please |
64 | 64 | ||
65 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 65 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
66 | : PlayListWidgetGui( parent, name, fl ) { | 66 | : PlayListWidgetGui( parent, name, fl ) { |
67 | 67 | ||
68 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), | 68 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), |
69 | "opieplayer2/add_to_playlist", | 69 | "opieplayer2/add_to_playlist", |
70 | this , SLOT(addSelected() ) ); | 70 | this , SLOT(addSelected() ) ); |
71 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), | 71 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), |
72 | "opieplayer2/remove_from_playlist", | 72 | "opieplayer2/remove_from_playlist", |
73 | this , SLOT(removeSelected() ) ); | 73 | this , SLOT(removeSelected() ) ); |
74 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", | 74 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", |
75 | this , SLOT( btnPlay( bool) ), TRUE ); | 75 | this , SLOT( btnPlay( bool) ), TRUE ); |
76 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", | 76 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", |
77 | mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); | 77 | mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); |
78 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", | 78 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", |
79 | mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); | 79 | mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); |
80 | 80 | ||
81 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 81 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
82 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), | 82 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), |
83 | this, SLOT( addAllMusicToList() ) ); | 83 | this, SLOT( addAllMusicToList() ) ); |
84 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), | 84 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), |
85 | this, SLOT( addAllVideoToList() ) ); | 85 | this, SLOT( addAllVideoToList() ) ); |
86 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), | 86 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), |
87 | this, SLOT( addAllToList() ) ); | 87 | this, SLOT( addAllToList() ) ); |
88 | pmPlayList->insertSeparator(-1); | 88 | pmPlayList->insertSeparator(-1); |
89 | // (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), | 89 | // (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), |
90 | // this, SLOT( saveList() ) ); | 90 | // this, SLOT( saveList() ) ); |
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( "Open File or URL" ), | 94 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), |
95 | this,SLOT( openFile() ) ); | 95 | this,SLOT( openFile() ) ); |
96 | pmPlayList->insertSeparator(-1); | 96 | pmPlayList->insertSeparator(-1); |
97 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), | 97 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), |
98 | this,SLOT( scanForAudio() ) ); | 98 | this,SLOT( scanForAudio() ) ); |
99 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), | 99 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), |
100 | this,SLOT( scanForVideo() ) ); | 100 | this,SLOT( scanForVideo() ) ); |
101 | 101 | ||
102 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), | 102 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), |
103 | mediaPlayerState, SLOT( toggleFullscreen() ) ); | 103 | mediaPlayerState, SLOT( toggleFullscreen() ) ); |
104 | 104 | ||
105 | Config cfg( "OpiePlayer" ); | 105 | Config cfg( "OpiePlayer" ); |
106 | bool b= cfg.readBoolEntry("FullScreen", 0); | 106 | bool b= cfg.readBoolEntry("FullScreen", 0); |
107 | mediaPlayerState->setFullscreen( b ); | 107 | mediaPlayerState->setFullscreen( b ); |
108 | pmView->setItemChecked( -16, b ); | 108 | pmView->setItemChecked( -16, b ); |
109 | 109 | ||
110 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", | 110 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", |
111 | d->selectedFiles, SLOT(moveSelectedUp() ) ); | 111 | d->selectedFiles, SLOT(moveSelectedUp() ) ); |
112 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", | 112 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", |
113 | d->selectedFiles, SLOT(removeSelected() ) ); | 113 | d->selectedFiles, SLOT(removeSelected() ) ); |
114 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", | 114 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", |
115 | d->selectedFiles, SLOT(moveSelectedDown() ) ); | 115 | d->selectedFiles, SLOT(moveSelectedDown() ) ); |
116 | QVBox *stretch2 = new QVBox( vbox1 ); | 116 | QVBox *stretch2 = new QVBox( vbox1 ); |
117 | 117 | ||
118 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), | 118 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), |
119 | SLOT( deletePlaylist() ) ); | 119 | SLOT( deletePlaylist() ) ); |
120 | connect( pmView, SIGNAL( activated( int ) ), | 120 | connect( pmView, SIGNAL( activated( int ) ), |
121 | this, SLOT( pmViewActivated( int ) ) ); | 121 | this, SLOT( pmViewActivated( int ) ) ); |
122 | connect( skinsMenu, SIGNAL( activated( int ) ) , | 122 | connect( skinsMenu, SIGNAL( activated( int ) ) , |
123 | this, SLOT( skinsMenuActivated( int ) ) ); | 123 | this, SLOT( skinsMenuActivated( int ) ) ); |
124 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 124 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
125 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 125 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
126 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), | 126 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), |
127 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 127 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
128 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), | 128 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), |
129 | this,SLOT( playIt( QListViewItem *) ) ); | 129 | this,SLOT( playIt( QListViewItem *) ) ); |
130 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), | 130 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), |
131 | this, SLOT( addToSelection( QListViewItem *) ) ); | 131 | this, SLOT( addToSelection( QListViewItem *) ) ); |
132 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 132 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
133 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); | 133 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); |
134 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), | 134 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), |
135 | this,SLOT( playIt( QListViewItem *) ) ); | 135 | this,SLOT( playIt( QListViewItem *) ) ); |
136 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), | 136 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), |
137 | this, SLOT( addToSelection( QListViewItem *) ) ); | 137 | this, SLOT( addToSelection( QListViewItem *) ) ); |
138 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), | 138 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), |
139 | this, SLOT( loadList( const DocLnk & ) ) ); | 139 | this, SLOT( loadList( const DocLnk & ) ) ); |
140 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), | 140 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), |
141 | this, SLOT( tabChanged( QWidget* ) ) ); | 141 | this, SLOT( tabChanged( QWidget* ) ) ); |
142 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), | 142 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), |
143 | d->tbPlay, SLOT( setOn( bool ) ) ); | 143 | d->tbPlay, SLOT( setOn( bool ) ) ); |
144 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), | 144 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), |
145 | d->tbLoop, SLOT( setOn( bool ) ) ); | 145 | d->tbLoop, SLOT( setOn( bool ) ) ); |
146 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), | 146 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), |
147 | d->tbShuffle, SLOT( setOn( bool ) ) ); | 147 | d->tbShuffle, SLOT( setOn( bool ) ) ); |
148 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), | 148 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), |
149 | this, SLOT( setPlaylist( bool ) ) ); | 149 | this, SLOT( setPlaylist( bool ) ) ); |
150 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), | 150 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), |
151 | this, SLOT( playIt( QListViewItem *) ) ); | 151 | this, SLOT( playIt( QListViewItem *) ) ); |
152 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), | 152 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), |
153 | mediaPlayerState, SLOT( setVideoGamma( int ) ) ); | 153 | mediaPlayerState, SLOT( setVideoGamma( int ) ) ); |
154 | 154 | ||
155 | // see which skins are installed | 155 | // see which skins are installed |
156 | videoScan=FALSE; | 156 | videoScan=FALSE; |
157 | audioScan=FALSE; | 157 | audioScan=FALSE; |
158 | populateSkinsMenu(); | 158 | populateSkinsMenu(); |
159 | initializeStates(); | 159 | initializeStates(); |
160 | 160 | ||
161 | cfg.setGroup("PlayList"); | 161 | cfg.setGroup("PlayList"); |
162 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); | 162 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); |
163 | loadList(DocLnk( currentPlaylist ) ); | 163 | loadList(DocLnk( currentPlaylist ) ); |
164 | 164 | ||
165 | } | 165 | } |
166 | 166 | ||
167 | 167 | ||
168 | PlayListWidget::~PlayListWidget() { | 168 | PlayListWidget::~PlayListWidget() { |
169 | if ( d->current ) { | 169 | if ( d->current ) { |
170 | delete d->current; | 170 | delete d->current; |
171 | } | 171 | } |
172 | delete d; | 172 | delete d; |
173 | } | 173 | } |
174 | 174 | ||
175 | 175 | ||
176 | void PlayListWidget::initializeStates() { | 176 | void PlayListWidget::initializeStates() { |
177 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 177 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
178 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 178 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
179 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 179 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
180 | setPlaylist( true ); | 180 | setPlaylist( true ); |
181 | } | 181 | } |
182 | 182 | ||
183 | void PlayListWidget::writeDefaultPlaylist() { | 183 | void PlayListWidget::writeDefaultPlaylist() { |
184 | 184 | ||
185 | Config config( "OpiePlayer" ); | 185 | Config config( "OpiePlayer" ); |
186 | config.setGroup( "PlayList" ); | 186 | config.setGroup( "PlayList" ); |
187 | QString filename=QPEApplication::documentDir() + "/default.m3u"; | 187 | QString filename=QPEApplication::documentDir() + "/default.m3u"; |
188 | QString currentString = config.readEntry( "CurrentPlaylist", filename); | 188 | QString currentString = config.readEntry( "CurrentPlaylist", filename); |
189 | if( currentString == filename) { | 189 | if( currentString == filename) { |
190 | Om3u *m3uList; | 190 | Om3u *m3uList; |
191 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); | 191 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); |
192 | if( d->selectedFiles->first() ) { | 192 | if( d->selectedFiles->first() ) { |
193 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 193 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
194 | do { | 194 | do { |
195 | // qDebug(d->selectedFiles->current()->file()); | 195 | // qDebug(d->selectedFiles->current()->file()); |
196 | m3uList->add( d->selectedFiles->current()->file() ); | 196 | m3uList->add( d->selectedFiles->current()->file() ); |
197 | } | 197 | } |
198 | while ( d->selectedFiles->next() ); | 198 | while ( d->selectedFiles->next() ); |
199 | 199 | ||
200 | m3uList->write(); | 200 | m3uList->write(); |
201 | m3uList->close(); | 201 | m3uList->close(); |
202 | if(m3uList) delete m3uList; | 202 | if(m3uList) delete m3uList; |
203 | 203 | ||
204 | } | 204 | } |
205 | } | 205 | } |
206 | } | 206 | } |
207 | 207 | ||
208 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 208 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
209 | d->setDocumentUsed = FALSE; | 209 | d->setDocumentUsed = FALSE; |
210 | if ( mediaPlayerState->playlist() ) { | 210 | if ( mediaPlayerState->playlist() ) { |
211 | if( QFileInfo( lnk.file() ).exists() || | 211 | if( QFileInfo( lnk.file() ).exists() || |
212 | lnk.file().left(4) == "http" ) | 212 | lnk.file().left(4) == "http" ) { |
213 | d->selectedFiles->addToSelection( lnk ); | 213 | d->selectedFiles->addToSelection( lnk ); |
214 | } | ||
214 | // writeCurrentM3u(); | 215 | // writeCurrentM3u(); |
215 | } | 216 | } |
216 | else | 217 | else |
217 | mediaPlayerState->setPlaying( TRUE ); | 218 | mediaPlayerState->setPlaying( TRUE ); |
218 | } | 219 | } |
219 | 220 | ||
220 | 221 | ||
221 | void PlayListWidget::clearList() { | 222 | void PlayListWidget::clearList() { |
222 | while ( first() ) { | 223 | while ( first() ) { |
223 | d->selectedFiles->removeSelected(); | 224 | d->selectedFiles->removeSelected(); |
224 | } | 225 | } |
225 | } | 226 | } |
226 | 227 | ||
227 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 228 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
228 | switch (mouse) { | 229 | switch (mouse) { |
229 | case 1: | 230 | case 1: |
230 | break; | 231 | break; |
231 | case 2: | 232 | case 2: |
232 | { | 233 | { |
233 | QPopupMenu m; | 234 | QPopupMenu m; |
234 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 235 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
235 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 236 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
236 | m.exec( QCursor::pos() ); | 237 | m.exec( QCursor::pos() ); |
237 | } | 238 | } |
238 | break; | 239 | break; |
239 | } | 240 | } |
240 | } | 241 | } |
241 | 242 | ||
242 | 243 | ||
243 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 244 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
244 | switch (mouse) { | 245 | switch (mouse) { |
245 | case 1: | 246 | case 1: |
246 | break; | 247 | break; |
247 | case 2: | 248 | case 2: |
248 | { | 249 | { |
249 | QPopupMenu m; | 250 | QPopupMenu m; |
250 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 251 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
251 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 252 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
252 | m.exec( QCursor::pos() ); | 253 | m.exec( QCursor::pos() ); |
253 | } | 254 | } |
254 | break; | 255 | break; |
255 | } | 256 | } |
256 | } | 257 | } |
257 | 258 | ||
258 | 259 | ||
259 | void PlayListWidget::addAllToList() { | 260 | void PlayListWidget::addAllToList() { |
260 | DocLnkSet filesAll; | 261 | DocLnkSet filesAll; |
261 | Global::findDocuments(&filesAll, "video/*;"+audioMimes); | 262 | Global::findDocuments(&filesAll, "video/*;"+audioMimes); |
262 | QListIterator<DocLnk> Adit( filesAll.children() ); | 263 | QListIterator<DocLnk> Adit( filesAll.children() ); |
263 | for ( ; Adit.current(); ++Adit ) { | 264 | for ( ; Adit.current(); ++Adit ) { |
264 | if( QFileInfo( Adit.current()->file() ).exists() ) { | 265 | if( QFileInfo( Adit.current()->file() ).exists() ) { |
265 | d->selectedFiles->addToSelection( **Adit ); | 266 | d->selectedFiles->addToSelection( **Adit ); |
266 | } | 267 | } |
267 | } | 268 | } |
268 | writeCurrentM3u(); | 269 | tabWidget->setCurrentPage(0); |
270 | |||
271 | writeCurrentM3u(); | ||
272 | d->selectedFiles->first(); | ||
269 | } | 273 | } |
270 | 274 | ||
271 | 275 | ||
272 | void PlayListWidget::addAllMusicToList() { | 276 | void PlayListWidget::addAllMusicToList() { |
273 | if(!audioScan) | 277 | if(!audioScan) |
274 | scanForAudio(); | 278 | scanForAudio(); |
275 | QListIterator<DocLnk> dit( files.children() ); | 279 | QListIterator<DocLnk> dit( files.children() ); |
276 | for ( ; dit.current(); ++dit ) { | 280 | for ( ; dit.current(); ++dit ) { |
277 | if( QFileInfo(dit.current()->file() ).exists() ) { | 281 | if( QFileInfo(dit.current()->file() ).exists() ) { |
278 | d->selectedFiles->addToSelection( **dit ); | 282 | d->selectedFiles->addToSelection( **dit ); |
279 | } | 283 | } |
280 | } | 284 | } |
281 | writeCurrentM3u(); | 285 | tabWidget->setCurrentPage(0); |
286 | writeCurrentM3u(); | ||
287 | d->selectedFiles->first(); | ||
282 | } | 288 | } |
283 | 289 | ||
284 | 290 | ||
285 | void PlayListWidget::addAllVideoToList() { | 291 | void PlayListWidget::addAllVideoToList() { |
286 | if(!videoScan) | 292 | if(!videoScan) |
287 | scanForVideo(); | 293 | scanForVideo(); |
288 | QListIterator<DocLnk> dit( vFiles.children() ); | 294 | QListIterator<DocLnk> dit( vFiles.children() ); |
289 | for ( ; dit.current(); ++dit ) { | 295 | for ( ; dit.current(); ++dit ) { |
290 | if( QFileInfo( dit.current()->file() ).exists() ) { | 296 | if( QFileInfo( dit.current()->file() ).exists() ) { |
291 | d->selectedFiles->addToSelection( **dit ); | 297 | d->selectedFiles->addToSelection( **dit ); |
292 | } | 298 | } |
293 | } | 299 | } |
300 | tabWidget->setCurrentPage(0); | ||
294 | writeCurrentM3u(); | 301 | writeCurrentM3u(); |
302 | d->selectedFiles->first(); | ||
295 | } | 303 | } |
296 | 304 | ||
297 | 305 | ||
298 | void PlayListWidget::setDocument( const QString& fileref ) { | 306 | void PlayListWidget::setDocument( const QString& fileref ) { |
299 | qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); | 307 | qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); |
300 | fromSetDocument = TRUE; | 308 | fromSetDocument = TRUE; |
301 | if ( fileref.isNull() ) { | 309 | if ( fileref.isNull() ) { |
302 | QMessageBox::warning( this, tr( "Invalid File" ), | 310 | QMessageBox::warning( this, tr( "Invalid File" ), |
303 | tr( "There was a problem in getting the file." ) ); | 311 | tr( "There was a problem in getting the file." ) ); |
304 | return; | 312 | return; |
305 | } | 313 | } |
306 | 314 | ||
307 | clearList(); | 315 | clearList(); |
308 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u | 316 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u |
309 | readm3u( fileref ); | 317 | readm3u( fileref ); |
310 | } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { | 318 | } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { |
311 | readm3u( DocLnk( fileref).file() ); | 319 | readm3u( DocLnk( fileref).file() ); |
312 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls | 320 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls |
313 | readPls( fileref ); | 321 | readPls( fileref ); |
314 | } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { | 322 | } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { |
315 | readPls( DocLnk( fileref).file() ); | 323 | readPls( DocLnk( fileref).file() ); |
316 | } else { | 324 | } else { |
317 | clearList(); | 325 | clearList(); |
318 | addToSelection( DocLnk( fileref ) ); | 326 | addToSelection( DocLnk( fileref ) ); |
319 | writeCurrentM3u(); | 327 | writeCurrentM3u(); |
320 | 328 | ||
321 | d->setDocumentUsed = TRUE; | 329 | d->setDocumentUsed = TRUE; |
322 | mediaPlayerState->setPlaying( FALSE ); | 330 | mediaPlayerState->setPlaying( FALSE ); |
323 | mediaPlayerState->setPlaying( TRUE ); | 331 | mediaPlayerState->setPlaying( TRUE ); |
324 | } | 332 | } |
325 | } | 333 | } |
326 | 334 | ||
327 | 335 | ||
328 | void PlayListWidget::useSelectedDocument() { | 336 | void PlayListWidget::useSelectedDocument() { |
329 | d->setDocumentUsed = FALSE; | 337 | d->setDocumentUsed = FALSE; |
330 | } | 338 | } |
331 | 339 | ||
332 | 340 | ||
333 | const DocLnk *PlayListWidget::current() { // this is fugly | 341 | const DocLnk *PlayListWidget::current() { // this is fugly |
334 | switch ( whichList() ) { | 342 | switch ( whichList() ) { |
335 | case 0: //playlist | 343 | case 0: //playlist |
336 | { | 344 | { |
337 | // qDebug("playlist"); | 345 | // qDebug("playlist"); |
338 | if ( mediaPlayerState->playlist() ) { | 346 | if ( mediaPlayerState->playlist() ) { |
339 | return d->selectedFiles->current(); | 347 | return d->selectedFiles->current(); |
340 | } else if ( d->setDocumentUsed && d->current ) { | 348 | } else if ( d->setDocumentUsed && d->current ) { |
341 | return d->current; | 349 | return d->current; |
342 | } else { | 350 | } else { |
343 | return &(d->files->selectedDocument()); | 351 | return &(d->files->selectedDocument()); |
344 | } | 352 | } |
345 | } | 353 | } |
346 | break; | 354 | break; |
347 | }; | 355 | }; |
348 | return 0; | 356 | return 0; |
349 | } | 357 | } |
350 | 358 | ||
351 | 359 | ||
352 | bool PlayListWidget::prev() { | 360 | bool PlayListWidget::prev() { |
353 | if ( mediaPlayerState->playlist() ) { | 361 | if ( mediaPlayerState->playlist() ) { |
354 | if ( mediaPlayerState->shuffled() ) { | 362 | if ( mediaPlayerState->shuffled() ) { |
355 | const DocLnk *cur = current(); | 363 | const DocLnk *cur = current(); |
356 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 364 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
357 | for ( int i = 0; i < j; i++ ) { | 365 | for ( int i = 0; i < j; i++ ) { |
358 | if ( !d->selectedFiles->next() ) | 366 | if ( !d->selectedFiles->next() ) |
359 | d->selectedFiles->first(); | 367 | d->selectedFiles->first(); |
360 | } | 368 | } |
361 | if ( cur == current() ) | 369 | if ( cur == current() ) |
362 | if ( !d->selectedFiles->next() ) { | 370 | if ( !d->selectedFiles->next() ) { |
363 | d->selectedFiles->first(); | 371 | d->selectedFiles->first(); |
364 | } | 372 | } |
365 | return TRUE; | 373 | return TRUE; |
366 | } else { | 374 | } else { |
367 | if ( !d->selectedFiles->prev() ) { | 375 | if ( !d->selectedFiles->prev() ) { |
368 | if ( mediaPlayerState->looping() ) { | 376 | if ( mediaPlayerState->looping() ) { |
369 | return d->selectedFiles->last(); | 377 | return d->selectedFiles->last(); |
370 | } else { | 378 | } else { |
371 | return FALSE; | 379 | return FALSE; |
372 | } | 380 | } |
373 | } | 381 | } |
374 | return TRUE; | 382 | return TRUE; |
375 | } | 383 | } |
376 | } else { | 384 | } else { |
377 | return mediaPlayerState->looping(); | 385 | return mediaPlayerState->looping(); |
378 | } | 386 | } |
379 | } | 387 | } |
380 | 388 | ||
381 | 389 | ||
382 | bool PlayListWidget::next() { | 390 | bool PlayListWidget::next() { |
383 | //qDebug("<<<<<<<<<<<<next()"); | 391 | //qDebug("<<<<<<<<<<<<next()"); |
384 | if ( mediaPlayerState->playlist() ) { | 392 | if ( mediaPlayerState->playlist() ) { |
385 | if ( mediaPlayerState->shuffled() ) { | 393 | if ( mediaPlayerState->shuffled() ) { |
386 | return prev(); | 394 | return prev(); |
387 | } else { | 395 | } else { |
388 | if ( !d->selectedFiles->next() ) { | 396 | if ( !d->selectedFiles->next() ) { |
389 | if ( mediaPlayerState->looping() ) { | 397 | if ( mediaPlayerState->looping() ) { |
390 | return d->selectedFiles->first(); | 398 | return d->selectedFiles->first(); |
391 | } else { | 399 | } else { |
392 | return FALSE; | 400 | return FALSE; |
393 | } | 401 | } |
394 | } | 402 | } |
395 | return TRUE; | 403 | return TRUE; |
396 | } | 404 | } |
397 | } else { | 405 | } else { |
398 | return mediaPlayerState->looping(); | 406 | return mediaPlayerState->looping(); |
399 | } | 407 | } |
400 | } | 408 | } |
401 | 409 | ||
402 | 410 | ||
403 | bool PlayListWidget::first() { | 411 | bool PlayListWidget::first() { |
404 | if ( mediaPlayerState->playlist() ) | 412 | if ( mediaPlayerState->playlist() ) |
405 | return d->selectedFiles->first(); | 413 | return d->selectedFiles->first(); |
406 | else | 414 | else |
407 | return mediaPlayerState->looping(); | 415 | return mediaPlayerState->looping(); |
408 | } | 416 | } |
409 | 417 | ||
410 | 418 | ||
411 | bool PlayListWidget::last() { | 419 | bool PlayListWidget::last() { |
412 | if ( mediaPlayerState->playlist() ) | 420 | if ( mediaPlayerState->playlist() ) |
413 | return d->selectedFiles->last(); | 421 | return d->selectedFiles->last(); |
414 | else | 422 | else |
415 | return mediaPlayerState->looping(); | 423 | return mediaPlayerState->looping(); |
416 | } | 424 | } |
417 | 425 | ||
418 | 426 | ||
419 | void PlayListWidget::saveList() { | 427 | void PlayListWidget::saveList() { |
420 | writem3u(); | 428 | writem3u(); |
421 | } | 429 | } |
422 | 430 | ||
423 | 431 | ||
424 | void PlayListWidget::loadList( const DocLnk & lnk) { | 432 | void PlayListWidget::loadList( const DocLnk & lnk) { |
425 | QString name = lnk.name(); | 433 | QString name = lnk.name(); |
426 | qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); | 434 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); |
427 | 435 | ||
428 | if( name.length()>0) { | 436 | if( name.length()>0) { |
429 | setCaption("OpiePlayer: "+name); | 437 | setCaption("OpiePlayer: "+name); |
430 | qDebug("<<<<<<<<<<<<load list "+ lnk.file()); | 438 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); |
431 | clearList(); | 439 | clearList(); |
432 | readm3u(lnk.file()); | 440 | readm3u(lnk.file()); |
433 | tabWidget->setCurrentPage(0); | 441 | tabWidget->setCurrentPage(0); |
434 | } | 442 | } |
435 | } | 443 | } |
436 | 444 | ||
437 | 445 | ||
438 | void PlayListWidget::setPlaylist( bool shown ) { | 446 | void PlayListWidget::setPlaylist( bool shown ) { |
439 | if ( shown ) { | 447 | if ( shown ) { |
440 | d->playListFrame->show(); | 448 | d->playListFrame->show(); |
441 | } else { | 449 | } else { |
442 | d->playListFrame->hide(); | 450 | d->playListFrame->hide(); |
443 | } | 451 | } |
444 | } | 452 | } |
445 | 453 | ||
446 | 454 | ||
447 | void PlayListWidget::addSelected() { | 455 | void PlayListWidget::addSelected() { |
448 | qDebug("addSelected"); | 456 | qDebug("addSelected"); |
449 | switch (whichList()) { | 457 | DocLnk lnk; |
450 | case 0: //playlist | 458 | QString filename; |
451 | break; | 459 | switch (whichList()) { |
452 | case 1: { //audio | 460 | |
453 | QListViewItemIterator it( audioView ); | 461 | case 0: //playlist |
454 | // iterate through all items of the listview | 462 | return; |
455 | for ( ; it.current(); ++it ) { | 463 | break; |
456 | if ( it.current()->isSelected() ) { | 464 | case 1: { //audio |
457 | QListIterator<DocLnk> dit( files.children() ); | 465 | filename=audioView->currentItem()->text(3); |
458 | for ( ; dit.current(); ++dit ) { | 466 | // d->selectedFiles->next(); |
459 | if( dit.current()->name() == it.current()->text(0) ) { | 467 | } |
460 | if( QFileInfo( dit.current()->file()).exists()) { | 468 | break; |
461 | d->selectedFiles->addToSelection( **dit ); | ||
462 | audioView->setSelected( it.current(),FALSE); | ||
463 | } | ||
464 | } | ||
465 | } | ||
466 | } | ||
467 | } | ||
468 | // tabWidget->setCurrentPage(0); | ||
469 | writeCurrentM3u(); | ||
470 | d->selectedFiles->next(); | ||
471 | } | ||
472 | break; | ||
473 | case 2: { // video | ||
474 | QListViewItemIterator it( videoView ); | ||
475 | // iterate through all items of the listview | ||
476 | for ( ; it.current(); ++it ) { | ||
477 | if ( it.current()->isSelected() ) { | ||
478 | QListIterator<DocLnk> dit( vFiles.children() ); | ||
479 | for ( ; dit.current(); ++dit ) { | ||
480 | if( dit.current()->name() == it.current()->text(0) ) { | ||
481 | if(QFileInfo( dit.current()->file()).exists()) { | ||
482 | d->selectedFiles->addToSelection( **dit ); | ||
483 | videoView->setSelected( it.current(),FALSE); | ||
484 | } | ||
485 | } | ||
486 | } | ||
487 | } | ||
488 | } | ||
489 | // tabWidget->setCurrentPage(0); | ||
490 | writeCurrentM3u(); | ||
491 | 469 | ||
492 | } | 470 | case 2: { // video |
493 | break; | 471 | filename=videoView->currentItem()->text(3); |
494 | }; | 472 | // tabWidget->setCurrentPage(0); |
473 | |||
474 | } | ||
475 | break; | ||
476 | }; | ||
477 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | ||
478 | lnk.setFile( filename ); //sets file name | ||
479 | d->selectedFiles->addToSelection( lnk); | ||
480 | tabWidget->setCurrentPage(0); | ||
481 | writeCurrentM3u(); | ||
495 | } | 482 | } |
496 | 483 | ||
497 | 484 | ||
498 | void PlayListWidget::removeSelected() { | 485 | void PlayListWidget::removeSelected() { |
499 | d->selectedFiles->removeSelected( ); | 486 | d->selectedFiles->removeSelected( ); |
500 | writeCurrentM3u(); | 487 | writeCurrentM3u(); |
501 | } | 488 | } |
502 | 489 | ||
503 | 490 | ||
504 | void PlayListWidget::playIt( QListViewItem *it) { | 491 | void PlayListWidget::playIt( QListViewItem *it) { |
505 | if(!it) return; | 492 | if(!it) return; |
506 | mediaPlayerState->setPlaying(FALSE); | 493 | mediaPlayerState->setPlaying(FALSE); |
507 | mediaPlayerState->setPlaying(TRUE); | 494 | mediaPlayerState->setPlaying(TRUE); |
508 | d->selectedFiles->unSelect(); | 495 | d->selectedFiles->unSelect(); |
509 | } | 496 | } |
510 | 497 | ||
511 | 498 | ||
512 | void PlayListWidget::addToSelection( QListViewItem *it) { | 499 | void PlayListWidget::addToSelection( QListViewItem *it) { |
513 | d->setDocumentUsed = FALSE; | 500 | d->setDocumentUsed = FALSE; |
514 | 501 | ||
515 | if(it) { | 502 | if(it) { |
516 | switch ( whichList()) { | 503 | switch ( whichList()) { |
517 | case 1: { | 504 | case 0: //playlist |
518 | QListIterator<DocLnk> dit( files.children() ); | 505 | return; |
519 | for ( ; dit.current(); ++dit ) { | 506 | break; |
520 | if( dit.current()->name() == it->text(0)) { | 507 | }; |
521 | if(QFileInfo( dit.current()->file()).exists()) { | 508 | // case 1: { |
522 | d->selectedFiles->addToSelection( **dit ); | 509 | DocLnk lnk; |
523 | // qDebug("blah "+ dit.current()->name()); | 510 | QString filename; |
524 | // d->selectedFiles->setSelectedItem( dit.current()->name()); | 511 | |
525 | } | 512 | filename=it->text(3); |
526 | } | 513 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
527 | } | 514 | lnk.setFile( filename ); //sets file name |
528 | writeCurrentM3u(); | 515 | d->selectedFiles->addToSelection( lnk); |
529 | } | 516 | |
530 | break; | 517 | writeCurrentM3u(); |
531 | case 2: { | 518 | tabWidget->setCurrentPage(0); |
532 | QListIterator<DocLnk> dit( vFiles.children() ); | ||
533 | for ( ; dit.current(); ++dit ) { | ||
534 | if( dit.current()->name() == it->text(0)) { | ||
535 | if( QFileInfo( dit.current()->file()).exists() ) { | ||
536 | d->selectedFiles->addToSelection( **dit ); | ||
537 | // qDebug("blah "+ dit.current()->name()); | ||
538 | // d->selectedFiles->setSelectedItem( dit.current()->name()); | ||
539 | } | ||
540 | } | ||
541 | } | ||
542 | writeCurrentM3u(); | ||
543 | |||
544 | } | ||
545 | break; | ||
546 | case 0: | ||
547 | break; | ||
548 | }; | ||
549 | tabWidget->setCurrentPage(0); | ||
550 | 519 | ||
551 | } | 520 | } |
552 | } | 521 | } |
553 | 522 | ||
554 | 523 | ||
555 | void PlayListWidget::tabChanged(QWidget *) { | 524 | void PlayListWidget::tabChanged(QWidget *) { |
556 | 525 | ||
557 | switch ( whichList()) { | 526 | switch ( whichList()) { |
558 | case 0: | 527 | case 0: |
559 | { | 528 | { |
560 | if( !tbDeletePlaylist->isHidden() ) { | 529 | if( !tbDeletePlaylist->isHidden() ) { |
561 | tbDeletePlaylist->hide(); | 530 | tbDeletePlaylist->hide(); |
562 | } | 531 | } |
563 | d->tbRemoveFromList->setEnabled(TRUE); | 532 | d->tbRemoveFromList->setEnabled(TRUE); |
564 | d->tbAddToList->setEnabled(FALSE); | 533 | d->tbAddToList->setEnabled(FALSE); |
565 | } | 534 | } |
566 | break; | 535 | break; |
567 | case 1: | 536 | case 1: |
568 | { | 537 | { |
569 | audioView->clear(); | 538 | audioView->clear(); |
570 | populateAudioView(); | 539 | populateAudioView(); |
571 | 540 | ||
572 | if( !tbDeletePlaylist->isHidden() ) { | 541 | if( !tbDeletePlaylist->isHidden() ) { |
573 | tbDeletePlaylist->hide(); | 542 | tbDeletePlaylist->hide(); |
574 | } | 543 | } |
575 | d->tbRemoveFromList->setEnabled(FALSE); | 544 | d->tbRemoveFromList->setEnabled(FALSE); |
576 | d->tbAddToList->setEnabled(TRUE); | 545 | d->tbAddToList->setEnabled(TRUE); |
577 | } | 546 | } |
578 | break; | 547 | break; |
579 | case 2: | 548 | case 2: |
580 | { | 549 | { |
581 | videoView->clear(); | 550 | videoView->clear(); |
582 | populateVideoView(); | 551 | populateVideoView(); |
583 | if( !tbDeletePlaylist->isHidden() ) { | 552 | if( !tbDeletePlaylist->isHidden() ) { |
584 | tbDeletePlaylist->hide(); | 553 | tbDeletePlaylist->hide(); |
585 | } | 554 | } |
586 | d->tbRemoveFromList->setEnabled(FALSE); | 555 | d->tbRemoveFromList->setEnabled(FALSE); |
587 | d->tbAddToList->setEnabled(TRUE); | 556 | d->tbAddToList->setEnabled(TRUE); |
588 | } | 557 | } |
589 | break; | 558 | break; |
590 | case 3: | 559 | case 3: |
591 | { | 560 | { |
592 | if( tbDeletePlaylist->isHidden() ) { | 561 | if( tbDeletePlaylist->isHidden() ) { |
593 | tbDeletePlaylist->show(); | 562 | tbDeletePlaylist->show(); |
594 | } | 563 | } |
595 | playLists->reread(); | 564 | playLists->reread(); |
596 | } | 565 | } |
597 | break; | 566 | break; |
598 | }; | 567 | }; |
599 | } | 568 | } |
600 | 569 | ||
601 | 570 | ||
602 | void PlayListWidget::btnPlay(bool b) { | 571 | void PlayListWidget::btnPlay(bool b) { |
603 | // mediaPlayerState->setPlaying(false); | 572 | // mediaPlayerState->setPlaying(false); |
604 | mediaPlayerState->setPlaying(b); | 573 | mediaPlayerState->setPlaying(b); |
605 | insanityBool=FALSE; | 574 | insanityBool=FALSE; |
606 | } | 575 | } |
607 | 576 | ||
608 | void PlayListWidget::deletePlaylist() { | 577 | void PlayListWidget::deletePlaylist() { |
609 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 578 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
610 | (tr("You really want to delete\nthis playlist?")), | 579 | (tr("You really want to delete\nthis playlist?")), |
611 | (tr("Yes")), (tr("No")), 0 )){ | 580 | (tr("Yes")), (tr("No")), 0 )){ |
612 | case 0: // Yes clicked, | 581 | case 0: // Yes clicked, |
613 | QFile().remove(playLists->selectedDocument().file()); | 582 | QFile().remove(playLists->selectedDocument().file()); |
614 | QFile().remove(playLists->selectedDocument().linkFile()); | 583 | QFile().remove(playLists->selectedDocument().linkFile()); |
615 | playLists->reread(); | 584 | playLists->reread(); |
616 | break; | 585 | break; |
617 | case 1: // Cancel | 586 | case 1: // Cancel |
618 | break; | 587 | break; |
619 | }; | 588 | }; |
620 | } | 589 | } |
621 | 590 | ||
622 | 591 | ||
623 | void PlayListWidget::playSelected() { | 592 | void PlayListWidget::playSelected() { |
624 | btnPlay( TRUE); | 593 | btnPlay( TRUE); |
625 | } | 594 | } |
626 | 595 | ||
627 | 596 | ||
628 | void PlayListWidget::scanForAudio() { | 597 | void PlayListWidget::scanForAudio() { |
629 | // qDebug("scan for audio"); | 598 | // qDebug("scan for audio"); |
630 | files.detachChildren(); | 599 | files.detachChildren(); |
631 | QListIterator<DocLnk> sdit( files.children() ); | 600 | QListIterator<DocLnk> sdit( files.children() ); |
632 | for ( ; sdit.current(); ++sdit ) { | 601 | for ( ; sdit.current(); ++sdit ) { |
633 | delete sdit.current(); | 602 | delete sdit.current(); |
634 | } | 603 | } |
635 | // Global::findDocuments( &files, "audio/*"); | 604 | // Global::findDocuments( &files, "audio/*"); |
636 | Global::findDocuments( &files, audioMimes); | 605 | Global::findDocuments( &files, audioMimes); |
637 | audioScan = TRUE; | 606 | audioScan = TRUE; |
638 | } | 607 | } |
639 | 608 | ||
640 | void PlayListWidget::scanForVideo() { | 609 | void PlayListWidget::scanForVideo() { |
641 | // qDebug("scan for video"); | 610 | // qDebug("scan for video"); |
642 | vFiles.detachChildren(); | 611 | vFiles.detachChildren(); |
643 | QListIterator<DocLnk> sdit( vFiles.children() ); | 612 | QListIterator<DocLnk> sdit( vFiles.children() ); |
644 | for ( ; sdit.current(); ++sdit ) { | 613 | for ( ; sdit.current(); ++sdit ) { |
645 | delete sdit.current(); | 614 | delete sdit.current(); |
646 | } | 615 | } |
647 | Global::findDocuments(&vFiles, "video/*"); | 616 | Global::findDocuments(&vFiles, "video/*"); |
648 | videoScan = TRUE; | 617 | videoScan = TRUE; |
649 | } | 618 | } |
650 | 619 | ||
651 | void PlayListWidget::populateAudioView() { | 620 | void PlayListWidget::populateAudioView() { |
652 | audioView->clear(); | 621 | audioView->clear(); |
653 | StorageInfo storageInfo; | 622 | StorageInfo storageInfo; |
654 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 623 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
655 | if(!audioScan) { | 624 | if(!audioScan) { |
656 | scanForAudio(); | 625 | scanForAudio(); |
657 | } | 626 | } |
658 | 627 | ||
659 | QListIterator<DocLnk> dit( files.children() ); | 628 | QListIterator<DocLnk> dit( files.children() ); |
660 | QListIterator<FileSystem> it ( fs ); | 629 | QListIterator<FileSystem> it ( fs ); |
661 | 630 | ||
662 | QString storage; | 631 | QString storage; |
663 | for ( ; dit.current(); ++dit ) { | 632 | for ( ; dit.current(); ++dit ) { |
664 | for( ; it.current(); ++it ){ | 633 | for( ; it.current(); ++it ){ |
665 | const QString name = (*it)->name(); | 634 | const QString name = (*it)->name(); |
666 | const QString path = (*it)->path(); | 635 | const QString path = (*it)->path(); |
667 | if(dit.current()->file().find(path) != -1 ) { | 636 | if(dit.current()->file().find(path) != -1 ) { |
668 | storage = name; | 637 | storage = name; |
669 | } | 638 | } |
670 | } | 639 | } |
671 | 640 | ||
672 | QListViewItem * newItem; | 641 | QListViewItem * newItem; |
673 | if ( QFile( dit.current()->file()).exists() || | 642 | if ( QFile( dit.current()->file()).exists() || |
674 | dit.current()->file().left(4) == "http" ) { | 643 | dit.current()->file().left(4) == "http" ) { |
675 | long size; | 644 | long size; |
676 | if( dit.current()->file().left(4) == "http" ) | 645 | if( dit.current()->file().left(4) == "http" ) |
677 | size=0; | 646 | size=0; |
678 | else | 647 | else |
679 | size = QFile( dit.current()->file() ).size(); | 648 | size = QFile( dit.current()->file() ).size(); |
680 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 649 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
681 | QString::number(size ), storage, dit.current()->file()); | 650 | QString::number(size ), storage, dit.current()->file()); |
682 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); | 651 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); |
683 | } | 652 | } |
684 | } | 653 | } |
685 | } | 654 | } |
686 | 655 | ||
687 | 656 | ||
688 | void PlayListWidget::populateVideoView() { | 657 | void PlayListWidget::populateVideoView() { |
689 | videoView->clear(); | 658 | videoView->clear(); |
690 | StorageInfo storageInfo; | 659 | StorageInfo storageInfo; |
691 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 660 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
692 | 661 | ||
693 | if(!videoScan ) { | 662 | if(!videoScan ) { |
694 | scanForVideo(); | 663 | scanForVideo(); |
695 | } | 664 | } |
696 | 665 | ||
697 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 666 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
698 | QListIterator<FileSystem> it ( fs ); | 667 | QListIterator<FileSystem> it ( fs ); |
699 | videoView->clear(); | 668 | videoView->clear(); |
700 | QString storage, pathName; | 669 | QString storage, pathName; |
701 | for ( ; Vdit.current(); ++Vdit ) { | 670 | for ( ; Vdit.current(); ++Vdit ) { |
702 | for( ; it.current(); ++it ) { | 671 | for( ; it.current(); ++it ) { |
703 | const QString name = (*it)->name(); | 672 | const QString name = (*it)->name(); |
704 | const QString path = (*it)->path(); | 673 | const QString path = (*it)->path(); |
705 | if( Vdit.current()->file().find(path) != -1 ) { | 674 | if( Vdit.current()->file().find(path) != -1 ) { |
706 | storage=name; | 675 | storage=name; |
707 | pathName=path; | 676 | pathName=path; |
708 | } | 677 | } |
709 | } | 678 | } |
710 | 679 | ||
711 | QListViewItem * newItem; | 680 | QListViewItem * newItem; |
712 | if ( QFile( Vdit.current()->file() ).exists() ) { | 681 | if ( QFile( Vdit.current()->file() ).exists() ) { |
713 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 682 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
714 | QString::number( QFile( Vdit.current()->file() ).size() ), | 683 | QString::number( QFile( Vdit.current()->file() ).size() ), |
715 | storage, Vdit.current()->file()); | 684 | storage, Vdit.current()->file()); |
716 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); | 685 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); |
717 | } | 686 | } |
718 | } | 687 | } |
719 | } | 688 | } |
720 | 689 | ||
721 | 690 | ||
722 | void PlayListWidget::openFile() { | 691 | void PlayListWidget::openFile() { |
723 | // http://66.28.164.33:2080 | 692 | // http://66.28.164.33:2080 |
724 | // http://somafm.com/star0242.m3u | 693 | // http://somafm.com/star0242.m3u |
725 | QString filename, name; | 694 | QString filename, name; |
726 | InputDialog *fileDlg; | 695 | InputDialog *fileDlg; |
727 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 696 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
728 | fileDlg->exec(); | 697 | fileDlg->exec(); |
729 | if( fileDlg->result() == 1 ) { | 698 | if( fileDlg->result() == 1 ) { |
730 | filename = fileDlg->text(); | 699 | filename = fileDlg->text(); |
731 | qDebug( "Selected filename is " + filename ); | 700 | qDebug( "Selected filename is " + filename ); |
732 | Om3u *m3uList; | 701 | Om3u *m3uList; |
733 | DocLnk lnk; | 702 | DocLnk lnk; |
734 | Config cfg( "OpiePlayer" ); | 703 | Config cfg( "OpiePlayer" ); |
735 | cfg.setGroup("PlayList"); | 704 | cfg.setGroup("PlayList"); |
736 | 705 | ||
737 | if(filename.left(4) == "http") { | 706 | if(filename.left(4) == "http") { |
738 | QString m3uFile, m3uFilePath; | 707 | QString m3uFile, m3uFilePath; |
739 | if(filename.find(":",8,TRUE) != -1) { //found a port | 708 | if(filename.find(":",8,TRUE) != -1) { //found a port |
740 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 709 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
741 | m3uFile = m3uFile.right( 7); | 710 | m3uFile = m3uFile.right( 7); |
742 | } else if(filename.left(4) == "http"){ | 711 | } else if(filename.left(4) == "http"){ |
743 | m3uFile=filename; | 712 | m3uFile=filename; |
744 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 713 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
745 | } else{ | 714 | } else{ |
746 | m3uFile=filename; | 715 | m3uFile=filename; |
747 | } | 716 | } |
748 | 717 | ||
749 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); | 718 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); |
750 | lnk.setName( filename ); //sets name | 719 | lnk.setName( filename ); //sets name |
751 | lnk.setFile( filename ); //sets file name | 720 | lnk.setFile( filename ); //sets file name |
752 | 721 | ||
753 | // lnk.setIcon("opieplayer2/musicfile"); | 722 | // lnk.setIcon("opieplayer2/musicfile"); |
754 | 723 | ||
755 | d->selectedFiles->addToSelection( lnk ); | 724 | d->selectedFiles->addToSelection( lnk ); |
756 | writeCurrentM3u(); | 725 | writeCurrentM3u(); |
757 | d->selectedFiles->setSelectedItem( lnk.name()); | 726 | d->selectedFiles->setSelectedItem( lnk.name()); |
758 | } | 727 | } |
759 | else if( filename.right( 3) == "m3u" ) { | 728 | else if( filename.right( 3) == "m3u" ) { |
760 | readm3u( filename ); | 729 | readm3u( filename ); |
761 | 730 | ||
762 | } else if( filename.right(3) == "pls" ) { | 731 | } else if( filename.right(3) == "pls" ) { |
763 | readPls( filename ); | 732 | readPls( filename ); |
764 | } else { | 733 | } else { |
765 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 734 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
766 | lnk.setFile( filename ); //sets file name | 735 | lnk.setFile( filename ); //sets file name |
767 | d->selectedFiles->addToSelection( lnk); | 736 | d->selectedFiles->addToSelection( lnk); |
768 | writeCurrentM3u(); | 737 | writeCurrentM3u(); |
769 | d->selectedFiles->setSelectedItem( lnk.name()); | 738 | d->selectedFiles->setSelectedItem( lnk.name()); |
770 | } | 739 | } |
771 | } | 740 | } |
772 | 741 | ||
773 | if( fileDlg ) { | 742 | if( fileDlg ) { |
774 | delete fileDlg; | 743 | delete fileDlg; |
775 | } | 744 | } |
776 | } | 745 | } |
777 | 746 | ||
778 | /* | 747 | /* |
779 | reads m3u and shows files/urls to playlist widget */ | 748 | reads m3u and shows files/urls to playlist widget */ |
780 | void PlayListWidget::readm3u( const QString &filename ) { | 749 | void PlayListWidget::readm3u( const QString &filename ) { |
781 | qDebug( "read m3u filename " + filename ); | 750 | qDebug( "read m3u filename " + filename ); |
782 | 751 | ||
783 | Om3u *m3uList; | 752 | Om3u *m3uList; |
784 | QString s, name; | 753 | QString s, name; |
785 | m3uList = new Om3u( filename, IO_ReadOnly ); | 754 | m3uList = new Om3u( filename, IO_ReadOnly ); |
786 | m3uList->readM3u(); | 755 | m3uList->readM3u(); |
787 | DocLnk lnk; | 756 | DocLnk lnk; |
788 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 757 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
789 | s = *it; | 758 | s = *it; |
790 | // qDebug("reading "+ s); | 759 | // qDebug("reading "+ s); |
791 | if(s.left(4)=="http") { | 760 | if(s.left(4)=="http") { |
792 | lnk.setName( s ); //sets file name | 761 | lnk.setName( s ); //sets file name |
793 | lnk.setIcon("opieplayer2/musicfile"); | 762 | lnk.setIcon("opieplayer2/musicfile"); |
794 | lnk.setFile( s ); //sets file name | 763 | lnk.setFile( s ); //sets file name |
795 | 764 | ||
796 | } else { | 765 | } else { |
797 | // if( QFileInfo( s ).exists() ) { | 766 | // if( QFileInfo( s ).exists() ) { |
798 | lnk.setName( QFileInfo(s).baseName()); | 767 | lnk.setName( QFileInfo(s).baseName()); |
799 | // if(s.right(4) == '.') {//if regular file | 768 | // if(s.right(4) == '.') {//if regular file |
800 | if(s.left(1) != "/") { | 769 | if(s.left(1) != "/") { |
801 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | 770 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); |
802 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 771 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
803 | // lnk.setIcon(MimeType(s).pixmap() ); | 772 | // lnk.setIcon(MimeType(s).pixmap() ); |
804 | // lnk.setIcon("SoundPlayer"); | 773 | // lnk.setIcon("SoundPlayer"); |
805 | } else { | 774 | } else { |
806 | // qDebug("set link2 "+s); | 775 | // qDebug("set link2 "+s); |
807 | lnk.setFile( s); | 776 | lnk.setFile( s); |
808 | // lnk.setIcon(MimeType(s).pixmap() ); | 777 | // lnk.setIcon(MimeType(s).pixmap() ); |
809 | // lnk.setIcon("SoundPlayer"); | 778 | // lnk.setIcon("SoundPlayer"); |
810 | } | 779 | } |
811 | } | 780 | } |
812 | d->selectedFiles->addToSelection( lnk ); | 781 | d->selectedFiles->addToSelection( lnk ); |
813 | } | 782 | } |
814 | Config config( "OpiePlayer" ); | 783 | Config config( "OpiePlayer" ); |
815 | config.setGroup( "PlayList" ); | 784 | config.setGroup( "PlayList" ); |
816 | 785 | ||
817 | config.writeEntry("CurrentPlaylist",filename); | 786 | config.writeEntry("CurrentPlaylist",filename); |
818 | config.write(); | 787 | config.write(); |
819 | currentPlayList=filename; | 788 | currentPlayList=filename; |
820 | 789 | ||
821 | // m3uList->write(); | 790 | // m3uList->write(); |
822 | m3uList->close(); | 791 | m3uList->close(); |
823 | if(m3uList) delete m3uList; | 792 | if(m3uList) delete m3uList; |
824 | 793 | ||
825 | d->selectedFiles->setSelectedItem( s); | 794 | d->selectedFiles->setSelectedItem( s); |
826 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 795 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
827 | 796 | ||
828 | } | 797 | } |
829 | 798 | ||
830 | /* | 799 | /* |
831 | reads pls and adds files/urls to playlist */ | 800 | reads pls and adds files/urls to playlist */ |
832 | void PlayListWidget::readPls( const QString &filename ) { | 801 | void PlayListWidget::readPls( const QString &filename ) { |
833 | 802 | ||
834 | qDebug( "pls filename is " + filename ); | 803 | qDebug( "pls filename is " + filename ); |
835 | Om3u *m3uList; | 804 | Om3u *m3uList; |
836 | QString s, name; | 805 | QString s, name; |
837 | m3uList = new Om3u( filename, IO_ReadOnly ); | 806 | m3uList = new Om3u( filename, IO_ReadOnly ); |
838 | m3uList->readPls(); | 807 | m3uList->readPls(); |
839 | 808 | ||
840 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 809 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
841 | s = *it; | 810 | s = *it; |
842 | // s.replace( QRegExp( "%20" )," " ); | 811 | // s.replace( QRegExp( "%20" )," " ); |
843 | DocLnk lnk( s ); | 812 | DocLnk lnk( s ); |
844 | QFileInfo f( s ); | 813 | QFileInfo f( s ); |
845 | QString name = f.baseName(); | 814 | QString name = f.baseName(); |
846 | 815 | ||
847 | if( name.left( 4 ) == "http" ) { | 816 | if( name.left( 4 ) == "http" ) { |
848 | name = s.right( s.length() - 7); | 817 | name = s.right( s.length() - 7); |
849 | } else { | 818 | } else { |
850 | name = s; | 819 | name = s; |
851 | } | 820 | } |
852 | 821 | ||
853 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 822 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
854 | 823 | ||
855 | lnk.setName( name ); | 824 | lnk.setName( name ); |
856 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | 825 | if( s.at( s.length() - 4) == '.') {// if this is probably a file |
857 | lnk.setFile( s ); | 826 | lnk.setFile( s ); |
858 | } else { //if its a url | 827 | } else { //if its a url |
859 | // if( name.right( 1 ).find( '/' ) == -1) { | 828 | // if( name.right( 1 ).find( '/' ) == -1) { |
860 | // s += "/"; | 829 | // s += "/"; |
861 | // } | 830 | // } |
862 | lnk.setFile( s ); | 831 | lnk.setFile( s ); |
863 | } | 832 | } |
864 | lnk.setType( "audio/x-mpegurl" ); | 833 | lnk.setType( "audio/x-mpegurl" ); |
865 | 834 | ||
866 | lnk.writeLink(); | 835 | lnk.writeLink(); |
867 | d->selectedFiles->addToSelection( lnk ); | 836 | d->selectedFiles->addToSelection( lnk ); |
868 | } | 837 | } |
869 | 838 | ||
870 | m3uList->close(); | 839 | m3uList->close(); |
871 | if(m3uList) delete m3uList; | 840 | if(m3uList) delete m3uList; |
872 | } | 841 | } |
873 | 842 | ||
874 | /* | 843 | /* |
875 | writes current playlist to current m3u file */ | 844 | writes current playlist to current m3u file */ |
876 | void PlayListWidget::writeCurrentM3u() { | 845 | void PlayListWidget::writeCurrentM3u() { |
877 | qDebug("writing to current m3u"); | 846 | qDebug("writing to current m3u"); |
878 | Config cfg( "OpiePlayer" ); | 847 | Config cfg( "OpiePlayer" ); |
879 | cfg.setGroup("PlayList"); | 848 | cfg.setGroup("PlayList"); |
880 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 849 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
881 | 850 | ||
882 | Om3u *m3uList; | 851 | Om3u *m3uList; |
883 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 852 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
884 | if( d->selectedFiles->first()) { | 853 | if( d->selectedFiles->first()) { |
885 | 854 | ||
886 | do { | 855 | do { |
887 | qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); | 856 | qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); |
888 | m3uList->add( d->selectedFiles->current()->file() ); | 857 | m3uList->add( d->selectedFiles->current()->file() ); |
889 | } | 858 | } |
890 | while ( d->selectedFiles->next() ); | 859 | while ( d->selectedFiles->next() ); |
891 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 860 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
892 | m3uList->write(); | 861 | m3uList->write(); |
893 | m3uList->close(); | 862 | m3uList->close(); |
894 | 863 | ||
895 | if(m3uList) delete m3uList; | 864 | if(m3uList) delete m3uList; |
896 | } | 865 | } |
897 | 866 | ||
898 | } | 867 | } |
899 | 868 | ||
900 | /* | 869 | /* |
901 | writes current playlist to m3u file */ | 870 | writes current playlist to m3u file */ |
902 | void PlayListWidget::writem3u() { | 871 | void PlayListWidget::writem3u() { |
903 | InputDialog *fileDlg; | 872 | InputDialog *fileDlg; |
904 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 873 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
905 | fileDlg->exec(); | 874 | fileDlg->exec(); |
906 | QString name, filename, list; | 875 | QString name, filename, list; |
907 | Om3u *m3uList; | 876 | Om3u *m3uList; |
908 | 877 | ||
909 | if( fileDlg->result() == 1 ) { | 878 | if( fileDlg->result() == 1 ) { |
910 | name = fileDlg->text(); | 879 | name = fileDlg->text(); |
911 | // qDebug( filename ); | 880 | // qDebug( filename ); |
912 | 881 | ||
913 | if( name.left( 1) != "/" ) { | 882 | if( name.left( 1) != "/" ) { |
914 | filename = QPEApplication::documentDir() + "/" + name; | 883 | filename = QPEApplication::documentDir() + "/" + name; |
915 | } | 884 | } |
916 | 885 | ||
917 | if( name.right( 3 ) != "m3u" ) { | 886 | if( name.right( 3 ) != "m3u" ) { |
918 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; | 887 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; |
919 | } | 888 | } |
920 | 889 | ||
921 | if( d->selectedFiles->first()) { | 890 | if( d->selectedFiles->first()) { |
922 | m3uList = new Om3u(filename, IO_ReadWrite); | 891 | m3uList = new Om3u(filename, IO_ReadWrite); |
923 | 892 | ||
924 | do { | 893 | do { |
925 | m3uList->add( d->selectedFiles->current()->file()); | 894 | m3uList->add( d->selectedFiles->current()->file()); |
926 | } | 895 | } |
927 | while ( d->selectedFiles->next() ); | 896 | while ( d->selectedFiles->next() ); |
928 | // qDebug( list ); | 897 | // qDebug( list ); |
929 | m3uList->write(); | 898 | m3uList->write(); |
930 | m3uList->close(); | 899 | m3uList->close(); |
931 | if(m3uList) delete m3uList; | 900 | if(m3uList) delete m3uList; |
932 | 901 | ||
933 | if(fileDlg) delete fileDlg; | 902 | if(fileDlg) delete fileDlg; |
934 | 903 | ||
935 | DocLnk lnk; | 904 | DocLnk lnk; |
936 | lnk.setFile( filename); | 905 | lnk.setFile( filename); |
937 | // lnk.setIcon("opieplayer2/playlist2"); | 906 | // lnk.setIcon("opieplayer2/playlist2"); |
938 | lnk.setName( name); //sets file name | 907 | lnk.setName( name); //sets file name |
939 | 908 | ||
940 | // qDebug(filename); | 909 | // qDebug(filename); |
941 | Config config( "OpiePlayer" ); | 910 | Config config( "OpiePlayer" ); |
942 | config.setGroup( "PlayList" ); | 911 | config.setGroup( "PlayList" ); |
943 | 912 | ||
944 | config.writeEntry("CurrentPlaylist",filename); | 913 | config.writeEntry("CurrentPlaylist",filename); |
945 | currentPlayList=filename; | 914 | currentPlayList=filename; |
946 | 915 | ||
947 | if(!lnk.writeLink()) { | 916 | if(!lnk.writeLink()) { |
948 | qDebug("Writing doclink did not work"); | 917 | qDebug("Writing doclink did not work"); |
949 | } | 918 | } |
950 | 919 | ||
951 | setCaption(tr("OpiePlayer: ") + name); | 920 | setCaption(tr("OpiePlayer: ") + name); |
952 | } | 921 | } |
953 | } | 922 | } |
954 | } | 923 | } |
955 | 924 | ||
956 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 925 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
957 | switch ( e->key() ) { | 926 | switch ( e->key() ) { |
958 | ////////////////////////////// Zaurus keys | 927 | ////////////////////////////// Zaurus keys |
959 | case Key_F9: //activity | 928 | case Key_F9: //activity |
960 | // if(audioUI->isHidden()) | 929 | // if(audioUI->isHidden()) |
961 | // audioUI->showMaximized(); | 930 | // audioUI->showMaximized(); |
962 | break; | 931 | break; |
963 | case Key_F10: //contacts | 932 | case Key_F10: //contacts |
964 | // if( videoUI->isHidden()) | 933 | // if( videoUI->isHidden()) |
965 | // videoUI->showMaximized(); | 934 | // videoUI->showMaximized(); |
966 | break; | 935 | break; |
967 | case Key_F11: //menu | 936 | case Key_F11: //menu |
968 | break; | 937 | break; |
969 | case Key_F12: //home | 938 | case Key_F12: //home |
970 | // doBlank(); | 939 | // doBlank(); |
971 | break; | 940 | break; |
972 | case Key_F13: //mail | 941 | case Key_F13: //mail |
973 | // doUnblank(); | 942 | // doUnblank(); |
974 | break; | 943 | break; |
975 | case Key_Q: //add to playlist | 944 | case Key_Q: //add to playlist |
976 | addSelected(); | 945 | addSelected(); |
977 | break; | 946 | break; |
978 | case Key_R: //remove from playlist | 947 | case Key_R: //remove from playlist |
979 | removeSelected(); | 948 | removeSelected(); |
980 | break; | 949 | break; |
981 | // case Key_P: //play | 950 | // case Key_P: //play |
982 | // qDebug("Play"); | 951 | // qDebug("Play"); |
983 | // playSelected(); | 952 | // playSelected(); |
984 | // break; | 953 | // break; |
985 | case Key_Space: | 954 | case Key_Space: |
986 | // playSelected(); puh | 955 | // playSelected(); puh |
987 | break; | 956 | break; |
988 | case Key_1: | 957 | case Key_1: |
989 | tabWidget->setCurrentPage( 0 ); | 958 | tabWidget->setCurrentPage( 0 ); |
990 | break; | 959 | break; |
991 | case Key_2: | 960 | case Key_2: |
992 | tabWidget->setCurrentPage( 1 ); | 961 | tabWidget->setCurrentPage( 1 ); |
993 | break; | 962 | break; |
994 | case Key_3: | 963 | case Key_3: |
995 | tabWidget->setCurrentPage( 2 ); | 964 | tabWidget->setCurrentPage( 2 ); |
996 | break; | 965 | break; |
997 | case Key_4: | 966 | case Key_4: |
998 | tabWidget->setCurrentPage( 3 ); | 967 | tabWidget->setCurrentPage( 3 ); |
999 | break; | 968 | break; |
1000 | case Key_Down: | 969 | case Key_Down: |
1001 | if ( !d->selectedFiles->next() ) | 970 | if ( !d->selectedFiles->next() ) |
1002 | d->selectedFiles->first(); | 971 | d->selectedFiles->first(); |
1003 | break; | 972 | break; |
1004 | case Key_Up: | 973 | case Key_Up: |
1005 | if ( !d->selectedFiles->prev() ) | 974 | if ( !d->selectedFiles->prev() ) |
1006 | // d->selectedFiles->last(); | 975 | // d->selectedFiles->last(); |
1007 | break; | 976 | break; |
1008 | } | 977 | } |
1009 | } | 978 | } |
1010 | 979 | ||
1011 | void PlayListWidget::pmViewActivated(int index) { | 980 | void PlayListWidget::pmViewActivated(int index) { |
1012 | // qDebug("%d", index); | 981 | // qDebug("%d", index); |
1013 | switch(index) { | 982 | switch(index) { |
1014 | case -16: | 983 | case -16: |
1015 | { | 984 | { |
1016 | mediaPlayerState->toggleFullscreen(); | 985 | mediaPlayerState->toggleFullscreen(); |
1017 | bool b=mediaPlayerState->fullscreen(); | 986 | bool b=mediaPlayerState->fullscreen(); |
1018 | pmView->setItemChecked( index, b); | 987 | pmView->setItemChecked( index, b); |
1019 | Config cfg( "OpiePlayer" ); | 988 | Config cfg( "OpiePlayer" ); |
1020 | cfg.writeEntry( "FullScreen", b ); | 989 | cfg.writeEntry( "FullScreen", b ); |
1021 | } | 990 | } |
1022 | break; | 991 | break; |
1023 | }; | 992 | }; |
1024 | } | 993 | } |
1025 | 994 | ||
1026 | void PlayListWidget::populateSkinsMenu() { | 995 | void PlayListWidget::populateSkinsMenu() { |
1027 | int item = 0; | 996 | int item = 0; |
1028 | defaultSkinIndex = 0; | 997 | defaultSkinIndex = 0; |
1029 | QString skinName; | 998 | QString skinName; |
1030 | Config cfg( "OpiePlayer" ); | 999 | Config cfg( "OpiePlayer" ); |
1031 | cfg.setGroup("Options" ); | 1000 | cfg.setGroup("Options" ); |
1032 | QString skin = cfg.readEntry( "Skin", "default" ); | 1001 | QString skin = cfg.readEntry( "Skin", "default" ); |
1033 | 1002 | ||
1034 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 1003 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
1035 | skinsDir.setFilter( QDir::Dirs ); | 1004 | skinsDir.setFilter( QDir::Dirs ); |
1036 | skinsDir.setSorting(QDir::Name ); | 1005 | skinsDir.setSorting(QDir::Name ); |
1037 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 1006 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
1038 | QFileInfoListIterator it( *skinslist ); | 1007 | QFileInfoListIterator it( *skinslist ); |
1039 | QFileInfo *fi; | 1008 | QFileInfo *fi; |
1040 | while ( ( fi = it.current() ) ) { | 1009 | while ( ( fi = it.current() ) ) { |
1041 | skinName = fi->fileName(); | 1010 | skinName = fi->fileName(); |
1042 | // qDebug( fi->fileName() ); | 1011 | // qDebug( fi->fileName() ); |
1043 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 1012 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
1044 | item = skinsMenu->insertItem( fi->fileName() ) ; | 1013 | item = skinsMenu->insertItem( fi->fileName() ) ; |
1045 | } | 1014 | } |
1046 | if( skinName == "default" ) { | 1015 | if( skinName == "default" ) { |
1047 | defaultSkinIndex = item; | 1016 | defaultSkinIndex = item; |
1048 | } | 1017 | } |
1049 | if( skinName == skin ) { | 1018 | if( skinName == skin ) { |
1050 | skinsMenu->setItemChecked( item, TRUE ); | 1019 | skinsMenu->setItemChecked( item, TRUE ); |
1051 | } | 1020 | } |
1052 | ++it; | 1021 | ++it; |
1053 | } | 1022 | } |
1054 | } | 1023 | } |
1055 | 1024 | ||
1056 | void PlayListWidget::skinsMenuActivated( int item ) { | 1025 | void PlayListWidget::skinsMenuActivated( int item ) { |
1057 | for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 1026 | for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
1058 | skinsMenu->setItemChecked( i, FALSE ); | 1027 | skinsMenu->setItemChecked( i, FALSE ); |
1059 | } | 1028 | } |
1060 | skinsMenu->setItemChecked( item, TRUE ); | 1029 | skinsMenu->setItemChecked( item, TRUE ); |
1061 | 1030 | ||
1062 | Config cfg( "OpiePlayer" ); | 1031 | Config cfg( "OpiePlayer" ); |
1063 | cfg.setGroup("Options"); | 1032 | cfg.setGroup("Options"); |
1064 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 1033 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
1065 | QMessageBox::warning( this, tr( "OpiePlayer" ), | 1034 | QMessageBox::warning( this, tr( "OpiePlayer" ), |
1066 | tr( "You must <b>restart</b> Opieplayer<br>to see your changes." ) ); | 1035 | tr( "You must <b>restart</b> Opieplayer<br>to see your changes." ) ); |
1067 | } | 1036 | } |
1068 | 1037 | ||
1069 | int PlayListWidget::whichList() { | 1038 | int PlayListWidget::whichList() { |
1070 | return tabWidget->currentPageIndex(); | 1039 | return tabWidget->currentPageIndex(); |
1071 | } | 1040 | } |
1072 | 1041 | ||
1073 | QString PlayListWidget::currentFileListPathName() { | 1042 | QString PlayListWidget::currentFileListPathName() { |
1074 | switch (whichList()) { | 1043 | switch (whichList()) { |
1075 | case 1: | 1044 | case 1: |
1076 | return audioView->currentItem()->text(3); | 1045 | return audioView->currentItem()->text(3); |
1077 | break; | 1046 | break; |
1078 | case 2: | 1047 | case 2: |
1079 | return videoView->currentItem()->text(3); | 1048 | return videoView->currentItem()->text(3); |
1080 | break; | 1049 | break; |
1081 | }; | 1050 | }; |
1082 | return ""; | 1051 | return ""; |
1083 | } | 1052 | } |