-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 86130d5..040ef71 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -1,154 +1,156 @@ | |||
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; | ||
60 | // extern VideoWidget *videoUI; | ||
59 | 61 | ||
60 | QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg"; | 62 | QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg"; |
61 | // no m3u's here please | 63 | // no m3u's here please |
62 | 64 | ||
63 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 65 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
64 | : PlayListWidgetGui( parent, name, fl ) { | 66 | : PlayListWidgetGui( parent, name, fl ) { |
65 | 67 | ||
66 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), | 68 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), |
67 | "opieplayer2/add_to_playlist", | 69 | "opieplayer2/add_to_playlist", |
68 | this , SLOT(addSelected() ) ); | 70 | this , SLOT(addSelected() ) ); |
69 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), | 71 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), |
70 | "opieplayer2/remove_from_playlist", | 72 | "opieplayer2/remove_from_playlist", |
71 | this , SLOT(removeSelected() ) ); | 73 | this , SLOT(removeSelected() ) ); |
72 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", | 74 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", |
73 | this , SLOT( btnPlay( bool) ), TRUE ); | 75 | this , SLOT( btnPlay( bool) ), TRUE ); |
74 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", | 76 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", |
75 | mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); | 77 | mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); |
76 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", | 78 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", |
77 | mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); | 79 | mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); |
78 | 80 | ||
79 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 81 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
80 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), | 82 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), |
81 | this, SLOT( addAllMusicToList() ) ); | 83 | this, SLOT( addAllMusicToList() ) ); |
82 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), | 84 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), |
83 | this, SLOT( addAllVideoToList() ) ); | 85 | this, SLOT( addAllVideoToList() ) ); |
84 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), | 86 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), |
85 | this, SLOT( addAllToList() ) ); | 87 | this, SLOT( addAllToList() ) ); |
86 | pmPlayList->insertSeparator(-1); | 88 | pmPlayList->insertSeparator(-1); |
87 | // (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), | 89 | // (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), |
88 | // this, SLOT( saveList() ) ); | 90 | // this, SLOT( saveList() ) ); |
89 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), | 91 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), |
90 | this, SLOT(writem3u() ) ); | 92 | this, SLOT(writem3u() ) ); |
91 | pmPlayList->insertSeparator(-1); | 93 | pmPlayList->insertSeparator(-1); |
92 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), | 94 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), |
93 | this,SLOT( openFile() ) ); | 95 | this,SLOT( openFile() ) ); |
94 | pmPlayList->insertSeparator(-1); | 96 | pmPlayList->insertSeparator(-1); |
95 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), | 97 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), |
96 | this,SLOT( scanForAudio() ) ); | 98 | this,SLOT( scanForAudio() ) ); |
97 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), | 99 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), |
98 | this,SLOT( scanForVideo() ) ); | 100 | this,SLOT( scanForVideo() ) ); |
99 | 101 | ||
100 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), | 102 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), |
101 | mediaPlayerState, SLOT( toggleFullscreen() ) ); | 103 | mediaPlayerState, SLOT( toggleFullscreen() ) ); |
102 | 104 | ||
103 | Config cfg( "OpiePlayer" ); | 105 | Config cfg( "OpiePlayer" ); |
104 | bool b= cfg.readBoolEntry("FullScreen", 0); | 106 | bool b= cfg.readBoolEntry("FullScreen", 0); |
105 | mediaPlayerState->setFullscreen( b ); | 107 | mediaPlayerState->setFullscreen( b ); |
106 | pmView->setItemChecked( -16, b ); | 108 | pmView->setItemChecked( -16, b ); |
107 | 109 | ||
108 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", | 110 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", |
109 | d->selectedFiles, SLOT(moveSelectedUp() ) ); | 111 | d->selectedFiles, SLOT(moveSelectedUp() ) ); |
110 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", | 112 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", |
111 | d->selectedFiles, SLOT(removeSelected() ) ); | 113 | d->selectedFiles, SLOT(removeSelected() ) ); |
112 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", | 114 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", |
113 | d->selectedFiles, SLOT(moveSelectedDown() ) ); | 115 | d->selectedFiles, SLOT(moveSelectedDown() ) ); |
114 | QVBox *stretch2 = new QVBox( vbox1 ); | 116 | QVBox *stretch2 = new QVBox( vbox1 ); |
115 | 117 | ||
116 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), | 118 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), |
117 | SLOT( deletePlaylist() ) ); | 119 | SLOT( deletePlaylist() ) ); |
118 | connect( pmView, SIGNAL( activated( int ) ), | 120 | connect( pmView, SIGNAL( activated( int ) ), |
119 | this, SLOT( pmViewActivated( int ) ) ); | 121 | this, SLOT( pmViewActivated( int ) ) ); |
120 | connect( skinsMenu, SIGNAL( activated( int ) ) , | 122 | connect( skinsMenu, SIGNAL( activated( int ) ) , |
121 | this, SLOT( skinsMenuActivated( int ) ) ); | 123 | this, SLOT( skinsMenuActivated( int ) ) ); |
122 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 124 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
123 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 125 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
124 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), | 126 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), |
125 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 127 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
126 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), | 128 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), |
127 | this,SLOT( playIt( QListViewItem *) ) ); | 129 | this,SLOT( playIt( QListViewItem *) ) ); |
128 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), | 130 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), |
129 | this, SLOT( addToSelection( QListViewItem *) ) ); | 131 | this, SLOT( addToSelection( QListViewItem *) ) ); |
130 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 132 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
131 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); | 133 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); |
132 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), | 134 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), |
133 | this,SLOT( playIt( QListViewItem *) ) ); | 135 | this,SLOT( playIt( QListViewItem *) ) ); |
134 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), | 136 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), |
135 | this, SLOT( addToSelection( QListViewItem *) ) ); | 137 | this, SLOT( addToSelection( QListViewItem *) ) ); |
136 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), | 138 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), |
137 | this, SLOT( loadList( const DocLnk & ) ) ); | 139 | this, SLOT( loadList( const DocLnk & ) ) ); |
138 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), | 140 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), |
139 | this, SLOT( tabChanged( QWidget* ) ) ); | 141 | this, SLOT( tabChanged( QWidget* ) ) ); |
140 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), | 142 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), |
141 | d->tbPlay, SLOT( setOn( bool ) ) ); | 143 | d->tbPlay, SLOT( setOn( bool ) ) ); |
142 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), | 144 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), |
143 | d->tbLoop, SLOT( setOn( bool ) ) ); | 145 | d->tbLoop, SLOT( setOn( bool ) ) ); |
144 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), | 146 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), |
145 | d->tbShuffle, SLOT( setOn( bool ) ) ); | 147 | d->tbShuffle, SLOT( setOn( bool ) ) ); |
146 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), | 148 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), |
147 | this, SLOT( setPlaylist( bool ) ) ); | 149 | this, SLOT( setPlaylist( bool ) ) ); |
148 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), | 150 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), |
149 | this, SLOT( playIt( QListViewItem *) ) ); | 151 | this, SLOT( playIt( QListViewItem *) ) ); |
150 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), | 152 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), |
151 | mediaPlayerState, SLOT( setVideoGamma( int ) ) ); | 153 | mediaPlayerState, SLOT( setVideoGamma( int ) ) ); |
152 | 154 | ||
153 | // see which skins are installed | 155 | // see which skins are installed |
154 | videoScan=FALSE; | 156 | videoScan=FALSE; |
@@ -204,193 +206,193 @@ void PlayListWidget::writeDefaultPlaylist() { | |||
204 | } | 206 | } |
205 | 207 | ||
206 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 208 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
207 | d->setDocumentUsed = FALSE; | 209 | d->setDocumentUsed = FALSE; |
208 | if ( mediaPlayerState->playlist() ) { | 210 | if ( mediaPlayerState->playlist() ) { |
209 | if( QFileInfo( lnk.file() ).exists() || | 211 | if( QFileInfo( lnk.file() ).exists() || |
210 | lnk.file().left(4) == "http" ) | 212 | lnk.file().left(4) == "http" ) |
211 | d->selectedFiles->addToSelection( lnk ); | 213 | d->selectedFiles->addToSelection( lnk ); |
212 | // writeCurrentM3u(); | 214 | // writeCurrentM3u(); |
213 | } | 215 | } |
214 | else | 216 | else |
215 | mediaPlayerState->setPlaying( TRUE ); | 217 | mediaPlayerState->setPlaying( TRUE ); |
216 | } | 218 | } |
217 | 219 | ||
218 | 220 | ||
219 | void PlayListWidget::clearList() { | 221 | void PlayListWidget::clearList() { |
220 | while ( first() ) { | 222 | while ( first() ) { |
221 | d->selectedFiles->removeSelected(); | 223 | d->selectedFiles->removeSelected(); |
222 | } | 224 | } |
223 | } | 225 | } |
224 | 226 | ||
225 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 227 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
226 | switch (mouse) { | 228 | switch (mouse) { |
227 | case 1: | 229 | case 1: |
228 | break; | 230 | break; |
229 | case 2: | 231 | case 2: |
230 | { | 232 | { |
231 | QPopupMenu m; | 233 | QPopupMenu m; |
232 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 234 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
233 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 235 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
234 | m.exec( QCursor::pos() ); | 236 | m.exec( QCursor::pos() ); |
235 | } | 237 | } |
236 | break; | 238 | break; |
237 | } | 239 | } |
238 | } | 240 | } |
239 | 241 | ||
240 | 242 | ||
241 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 243 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
242 | switch (mouse) { | 244 | switch (mouse) { |
243 | case 1: | 245 | case 1: |
244 | break; | 246 | break; |
245 | case 2: | 247 | case 2: |
246 | { | 248 | { |
247 | QPopupMenu m; | 249 | QPopupMenu m; |
248 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 250 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
249 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 251 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
250 | m.exec( QCursor::pos() ); | 252 | m.exec( QCursor::pos() ); |
251 | } | 253 | } |
252 | break; | 254 | break; |
253 | } | 255 | } |
254 | } | 256 | } |
255 | 257 | ||
256 | 258 | ||
257 | void PlayListWidget::addAllToList() { | 259 | void PlayListWidget::addAllToList() { |
258 | DocLnkSet filesAll; | 260 | DocLnkSet filesAll; |
259 | Global::findDocuments(&filesAll, "video/*;"+audioMimes); | 261 | Global::findDocuments(&filesAll, "video/*;"+audioMimes); |
260 | QListIterator<DocLnk> Adit( filesAll.children() ); | 262 | QListIterator<DocLnk> Adit( filesAll.children() ); |
261 | for ( ; Adit.current(); ++Adit ) { | 263 | for ( ; Adit.current(); ++Adit ) { |
262 | if( QFileInfo( Adit.current()->file() ).exists() ) { | 264 | if( QFileInfo( Adit.current()->file() ).exists() ) { |
263 | d->selectedFiles->addToSelection( **Adit ); | 265 | d->selectedFiles->addToSelection( **Adit ); |
264 | } | 266 | } |
265 | } | 267 | } |
266 | writeCurrentM3u(); | 268 | writeCurrentM3u(); |
267 | } | 269 | } |
268 | 270 | ||
269 | 271 | ||
270 | void PlayListWidget::addAllMusicToList() { | 272 | void PlayListWidget::addAllMusicToList() { |
271 | if(!audioScan) | 273 | if(!audioScan) |
272 | scanForAudio(); | 274 | scanForAudio(); |
273 | QListIterator<DocLnk> dit( files.children() ); | 275 | QListIterator<DocLnk> dit( files.children() ); |
274 | for ( ; dit.current(); ++dit ) { | 276 | for ( ; dit.current(); ++dit ) { |
275 | if( QFileInfo(dit.current()->file() ).exists() ) { | 277 | if( QFileInfo(dit.current()->file() ).exists() ) { |
276 | d->selectedFiles->addToSelection( **dit ); | 278 | d->selectedFiles->addToSelection( **dit ); |
277 | } | 279 | } |
278 | } | 280 | } |
279 | writeCurrentM3u(); | 281 | writeCurrentM3u(); |
280 | } | 282 | } |
281 | 283 | ||
282 | 284 | ||
283 | void PlayListWidget::addAllVideoToList() { | 285 | void PlayListWidget::addAllVideoToList() { |
284 | if(!videoScan) | 286 | if(!videoScan) |
285 | scanForVideo(); | 287 | scanForVideo(); |
286 | QListIterator<DocLnk> dit( vFiles.children() ); | 288 | QListIterator<DocLnk> dit( vFiles.children() ); |
287 | for ( ; dit.current(); ++dit ) { | 289 | for ( ; dit.current(); ++dit ) { |
288 | if( QFileInfo( dit.current()->file() ).exists() ) { | 290 | if( QFileInfo( dit.current()->file() ).exists() ) { |
289 | d->selectedFiles->addToSelection( **dit ); | 291 | d->selectedFiles->addToSelection( **dit ); |
290 | } | 292 | } |
291 | } | 293 | } |
292 | writeCurrentM3u(); | 294 | writeCurrentM3u(); |
293 | } | 295 | } |
294 | 296 | ||
295 | 297 | ||
296 | void PlayListWidget::setDocument( const QString& fileref ) { | 298 | void PlayListWidget::setDocument( const QString& fileref ) { |
297 | qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); | 299 | qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); |
298 | fromSetDocument = TRUE; | 300 | fromSetDocument = TRUE; |
299 | if ( fileref.isNull() ) { | 301 | if ( fileref.isNull() ) { |
300 | QMessageBox::critical( 0, tr( "Invalid File" ), | 302 | QMessageBox::warning( this, tr( "Invalid File" ), |
301 | tr( "There was a problem in getting the file." ) ); | 303 | tr( "There was a problem in getting the file." ) ); |
302 | return; | 304 | return; |
303 | } | 305 | } |
304 | 306 | ||
305 | clearList(); | 307 | clearList(); |
306 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u | 308 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u |
307 | readm3u( fileref ); | 309 | readm3u( fileref ); |
308 | } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { | 310 | } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { |
309 | readm3u( DocLnk( fileref).file() ); | 311 | readm3u( DocLnk( fileref).file() ); |
310 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls | 312 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls |
311 | readPls( fileref ); | 313 | readPls( fileref ); |
312 | } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { | 314 | } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { |
313 | readPls( DocLnk( fileref).file() ); | 315 | readPls( DocLnk( fileref).file() ); |
314 | } else { | 316 | } else { |
315 | clearList(); | 317 | clearList(); |
316 | addToSelection( DocLnk( fileref ) ); | 318 | addToSelection( DocLnk( fileref ) ); |
317 | writeCurrentM3u(); | 319 | writeCurrentM3u(); |
318 | 320 | ||
319 | d->setDocumentUsed = TRUE; | 321 | d->setDocumentUsed = TRUE; |
320 | mediaPlayerState->setPlaying( FALSE ); | 322 | mediaPlayerState->setPlaying( FALSE ); |
321 | mediaPlayerState->setPlaying( TRUE ); | 323 | mediaPlayerState->setPlaying( TRUE ); |
322 | } | 324 | } |
323 | } | 325 | } |
324 | 326 | ||
325 | 327 | ||
326 | void PlayListWidget::useSelectedDocument() { | 328 | void PlayListWidget::useSelectedDocument() { |
327 | d->setDocumentUsed = FALSE; | 329 | d->setDocumentUsed = FALSE; |
328 | } | 330 | } |
329 | 331 | ||
330 | 332 | ||
331 | const DocLnk *PlayListWidget::current() { // this is fugly | 333 | const DocLnk *PlayListWidget::current() { // this is fugly |
332 | switch ( whichList() ) { | 334 | switch ( whichList() ) { |
333 | case 0: //playlist | 335 | case 0: //playlist |
334 | { | 336 | { |
335 | // qDebug("playlist"); | 337 | // qDebug("playlist"); |
336 | if ( mediaPlayerState->playlist() ) { | 338 | if ( mediaPlayerState->playlist() ) { |
337 | return d->selectedFiles->current(); | 339 | return d->selectedFiles->current(); |
338 | } else if ( d->setDocumentUsed && d->current ) { | 340 | } else if ( d->setDocumentUsed && d->current ) { |
339 | return d->current; | 341 | return d->current; |
340 | } else { | 342 | } else { |
341 | return &(d->files->selectedDocument()); | 343 | return &(d->files->selectedDocument()); |
342 | } | 344 | } |
343 | } | 345 | } |
344 | break; | 346 | break; |
345 | }; | 347 | }; |
346 | return 0; | 348 | return 0; |
347 | } | 349 | } |
348 | 350 | ||
349 | 351 | ||
350 | bool PlayListWidget::prev() { | 352 | bool PlayListWidget::prev() { |
351 | if ( mediaPlayerState->playlist() ) { | 353 | if ( mediaPlayerState->playlist() ) { |
352 | if ( mediaPlayerState->shuffled() ) { | 354 | if ( mediaPlayerState->shuffled() ) { |
353 | const DocLnk *cur = current(); | 355 | const DocLnk *cur = current(); |
354 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 356 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
355 | for ( int i = 0; i < j; i++ ) { | 357 | for ( int i = 0; i < j; i++ ) { |
356 | if ( !d->selectedFiles->next() ) | 358 | if ( !d->selectedFiles->next() ) |
357 | d->selectedFiles->first(); | 359 | d->selectedFiles->first(); |
358 | } | 360 | } |
359 | if ( cur == current() ) | 361 | if ( cur == current() ) |
360 | if ( !d->selectedFiles->next() ) { | 362 | if ( !d->selectedFiles->next() ) { |
361 | d->selectedFiles->first(); | 363 | d->selectedFiles->first(); |
362 | } | 364 | } |
363 | return TRUE; | 365 | return TRUE; |
364 | } else { | 366 | } else { |
365 | if ( !d->selectedFiles->prev() ) { | 367 | if ( !d->selectedFiles->prev() ) { |
366 | if ( mediaPlayerState->looping() ) { | 368 | if ( mediaPlayerState->looping() ) { |
367 | return d->selectedFiles->last(); | 369 | return d->selectedFiles->last(); |
368 | } else { | 370 | } else { |
369 | return FALSE; | 371 | return FALSE; |
370 | } | 372 | } |
371 | } | 373 | } |
372 | return TRUE; | 374 | return TRUE; |
373 | } | 375 | } |
374 | } else { | 376 | } else { |
375 | return mediaPlayerState->looping(); | 377 | return mediaPlayerState->looping(); |
376 | } | 378 | } |
377 | } | 379 | } |
378 | 380 | ||
379 | 381 | ||
380 | bool PlayListWidget::next() { | 382 | bool PlayListWidget::next() { |
381 | //qDebug("<<<<<<<<<<<<next()"); | 383 | //qDebug("<<<<<<<<<<<<next()"); |
382 | if ( mediaPlayerState->playlist() ) { | 384 | if ( mediaPlayerState->playlist() ) { |
383 | if ( mediaPlayerState->shuffled() ) { | 385 | if ( mediaPlayerState->shuffled() ) { |
384 | return prev(); | 386 | return prev(); |
385 | } else { | 387 | } else { |
386 | if ( !d->selectedFiles->next() ) { | 388 | if ( !d->selectedFiles->next() ) { |
387 | if ( mediaPlayerState->looping() ) { | 389 | if ( mediaPlayerState->looping() ) { |
388 | return d->selectedFiles->first(); | 390 | return d->selectedFiles->first(); |
389 | } else { | 391 | } else { |
390 | return FALSE; | 392 | return FALSE; |
391 | } | 393 | } |
392 | } | 394 | } |
393 | return TRUE; | 395 | return TRUE; |
394 | } | 396 | } |
395 | } else { | 397 | } else { |
396 | return mediaPlayerState->looping(); | 398 | return mediaPlayerState->looping(); |
@@ -970,113 +972,115 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | |||
970 | case Key_F12: //home | 972 | case Key_F12: //home |
971 | // doBlank(); | 973 | // doBlank(); |
972 | break; | 974 | break; |
973 | case Key_F13: //mail | 975 | case Key_F13: //mail |
974 | // doUnblank(); | 976 | // doUnblank(); |
975 | break; | 977 | break; |
976 | case Key_Q: //add to playlist | 978 | case Key_Q: //add to playlist |
977 | addSelected(); | 979 | addSelected(); |
978 | break; | 980 | break; |
979 | case Key_R: //remove from playlist | 981 | case Key_R: //remove from playlist |
980 | removeSelected(); | 982 | removeSelected(); |
981 | break; | 983 | break; |
982 | // case Key_P: //play | 984 | // case Key_P: //play |
983 | // qDebug("Play"); | 985 | // qDebug("Play"); |
984 | // playSelected(); | 986 | // playSelected(); |
985 | // break; | 987 | // break; |
986 | case Key_Space: | 988 | case Key_Space: |
987 | // playSelected(); puh | 989 | // playSelected(); puh |
988 | break; | 990 | break; |
989 | case Key_1: | 991 | case Key_1: |
990 | tabWidget->setCurrentPage( 0 ); | 992 | tabWidget->setCurrentPage( 0 ); |
991 | break; | 993 | break; |
992 | case Key_2: | 994 | case Key_2: |
993 | tabWidget->setCurrentPage( 1 ); | 995 | tabWidget->setCurrentPage( 1 ); |
994 | break; | 996 | break; |
995 | case Key_3: | 997 | case Key_3: |
996 | tabWidget->setCurrentPage( 2 ); | 998 | tabWidget->setCurrentPage( 2 ); |
997 | break; | 999 | break; |
998 | case Key_4: | 1000 | case Key_4: |
999 | tabWidget->setCurrentPage( 3 ); | 1001 | tabWidget->setCurrentPage( 3 ); |
1000 | break; | 1002 | break; |
1001 | case Key_Down: | 1003 | case Key_Down: |
1002 | if ( !d->selectedFiles->next() ) | 1004 | if ( !d->selectedFiles->next() ) |
1003 | d->selectedFiles->first(); | 1005 | d->selectedFiles->first(); |
1004 | break; | 1006 | break; |
1005 | case Key_Up: | 1007 | case Key_Up: |
1006 | if ( !d->selectedFiles->prev() ) | 1008 | if ( !d->selectedFiles->prev() ) |
1007 | // d->selectedFiles->last(); | 1009 | // d->selectedFiles->last(); |
1008 | break; | 1010 | break; |
1009 | } | 1011 | } |
1010 | } | 1012 | } |
1011 | 1013 | ||
1012 | void PlayListWidget::pmViewActivated(int index) { | 1014 | void PlayListWidget::pmViewActivated(int index) { |
1013 | // qDebug("%d", index); | 1015 | // qDebug("%d", index); |
1014 | switch(index) { | 1016 | switch(index) { |
1015 | case -16: | 1017 | case -16: |
1016 | { | 1018 | { |
1017 | mediaPlayerState->toggleFullscreen(); | 1019 | mediaPlayerState->toggleFullscreen(); |
1018 | bool b=mediaPlayerState->fullscreen(); | 1020 | bool b=mediaPlayerState->fullscreen(); |
1019 | pmView->setItemChecked( index, b); | 1021 | pmView->setItemChecked( index, b); |
1020 | Config cfg( "OpiePlayer" ); | 1022 | Config cfg( "OpiePlayer" ); |
1021 | cfg.writeEntry( "FullScreen", b ); | 1023 | cfg.writeEntry( "FullScreen", b ); |
1022 | } | 1024 | } |
1023 | break; | 1025 | break; |
1024 | }; | 1026 | }; |
1025 | } | 1027 | } |
1026 | 1028 | ||
1027 | void PlayListWidget::populateSkinsMenu() { | 1029 | void PlayListWidget::populateSkinsMenu() { |
1028 | int item = 0; | 1030 | int item = 0; |
1029 | defaultSkinIndex = 0; | 1031 | defaultSkinIndex = 0; |
1030 | QString skinName; | 1032 | QString skinName; |
1031 | Config cfg( "OpiePlayer" ); | 1033 | Config cfg( "OpiePlayer" ); |
1032 | cfg.setGroup("Options" ); | 1034 | cfg.setGroup("Options" ); |
1033 | QString skin = cfg.readEntry( "Skin", "default" ); | 1035 | QString skin = cfg.readEntry( "Skin", "default" ); |
1034 | 1036 | ||
1035 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 1037 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
1036 | skinsDir.setFilter( QDir::Dirs ); | 1038 | skinsDir.setFilter( QDir::Dirs ); |
1037 | skinsDir.setSorting(QDir::Name ); | 1039 | skinsDir.setSorting(QDir::Name ); |
1038 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 1040 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
1039 | QFileInfoListIterator it( *skinslist ); | 1041 | QFileInfoListIterator it( *skinslist ); |
1040 | QFileInfo *fi; | 1042 | QFileInfo *fi; |
1041 | while ( ( fi = it.current() ) ) { | 1043 | while ( ( fi = it.current() ) ) { |
1042 | skinName = fi->fileName(); | 1044 | skinName = fi->fileName(); |
1043 | // qDebug( fi->fileName() ); | 1045 | // qDebug( fi->fileName() ); |
1044 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 1046 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
1045 | item = skinsMenu->insertItem( fi->fileName() ) ; | 1047 | item = skinsMenu->insertItem( fi->fileName() ) ; |
1046 | } | 1048 | } |
1047 | if( skinName == "default" ) { | 1049 | if( skinName == "default" ) { |
1048 | defaultSkinIndex = item; | 1050 | defaultSkinIndex = item; |
1049 | } | 1051 | } |
1050 | if( skinName == skin ) { | 1052 | if( skinName == skin ) { |
1051 | skinsMenu->setItemChecked( item, TRUE ); | 1053 | skinsMenu->setItemChecked( item, TRUE ); |
1052 | } | 1054 | } |
1053 | ++it; | 1055 | ++it; |
1054 | } | 1056 | } |
1055 | } | 1057 | } |
1056 | 1058 | ||
1057 | void PlayListWidget::skinsMenuActivated( int item ) { | 1059 | void PlayListWidget::skinsMenuActivated( int item ) { |
1058 | for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 1060 | for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
1059 | skinsMenu->setItemChecked( i, FALSE ); | 1061 | skinsMenu->setItemChecked( i, FALSE ); |
1060 | } | 1062 | } |
1061 | skinsMenu->setItemChecked( item, TRUE ); | 1063 | skinsMenu->setItemChecked( item, TRUE ); |
1062 | 1064 | ||
1063 | Config cfg( "OpiePlayer" ); | 1065 | Config cfg( "OpiePlayer" ); |
1064 | cfg.setGroup("Options"); | 1066 | cfg.setGroup("Options"); |
1065 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 1067 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
1066 | } | 1068 | QMessageBox::warning( this, tr( "OpiePlayer" ), |
1069 | tr( "You must <b>restart</b> Opieplayer<br>to see your changes." ) ); | ||
1070 | } | ||
1067 | 1071 | ||
1068 | int PlayListWidget::whichList() { | 1072 | int PlayListWidget::whichList() { |
1069 | return tabWidget->currentPageIndex(); | 1073 | return tabWidget->currentPageIndex(); |
1070 | } | 1074 | } |
1071 | 1075 | ||
1072 | QString PlayListWidget::currentFileListPathName() { | 1076 | QString PlayListWidget::currentFileListPathName() { |
1073 | switch (whichList()) { | 1077 | switch (whichList()) { |
1074 | case 1: | 1078 | case 1: |
1075 | return audioView->currentItem()->text(3); | 1079 | return audioView->currentItem()->text(3); |
1076 | break; | 1080 | break; |
1077 | case 2: | 1081 | case 2: |
1078 | return videoView->currentItem()->text(3); | 1082 | return videoView->currentItem()->text(3); |
1079 | break; | 1083 | break; |
1080 | }; | 1084 | }; |
1081 | return ""; | 1085 | return ""; |
1082 | } | 1086 | } |