author | llornkcor <llornkcor> | 2002-11-10 18:46:52 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-11-10 18:46:52 (UTC) |
commit | 6078687cb1e389751503ae171ed1bea72846a4de (patch) (unidiff) | |
tree | 5d725ae35ece948a9184f89c6aa7fb3a89a5c469 | |
parent | 49e5bbbd35bef879faca0d680f1c4d64a61b7b32 (diff) | |
download | opie-6078687cb1e389751503ae171ed1bea72846a4de.zip opie-6078687cb1e389751503ae171ed1bea72846a4de.tar.gz opie-6078687cb1e389751503ae171ed1bea72846a4de.tar.bz2 |
added must restart messagebox when changing skins
-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,1082 +1,1086 @@ | |||
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; |
155 | audioScan=FALSE; | 157 | audioScan=FALSE; |
156 | populateSkinsMenu(); | 158 | populateSkinsMenu(); |
157 | initializeStates(); | 159 | initializeStates(); |
158 | 160 | ||
159 | cfg.setGroup("PlayList"); | 161 | cfg.setGroup("PlayList"); |
160 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); | 162 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); |
161 | loadList(DocLnk( currentPlaylist ) ); | 163 | loadList(DocLnk( currentPlaylist ) ); |
162 | 164 | ||
163 | } | 165 | } |
164 | 166 | ||
165 | 167 | ||
166 | PlayListWidget::~PlayListWidget() { | 168 | PlayListWidget::~PlayListWidget() { |
167 | if ( d->current ) { | 169 | if ( d->current ) { |
168 | delete d->current; | 170 | delete d->current; |
169 | } | 171 | } |
170 | delete d; | 172 | delete d; |
171 | } | 173 | } |
172 | 174 | ||
173 | 175 | ||
174 | void PlayListWidget::initializeStates() { | 176 | void PlayListWidget::initializeStates() { |
175 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 177 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
176 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 178 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
177 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 179 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
178 | setPlaylist( true ); | 180 | setPlaylist( true ); |
179 | } | 181 | } |
180 | 182 | ||
181 | void PlayListWidget::writeDefaultPlaylist() { | 183 | void PlayListWidget::writeDefaultPlaylist() { |
182 | 184 | ||
183 | Config config( "OpiePlayer" ); | 185 | Config config( "OpiePlayer" ); |
184 | config.setGroup( "PlayList" ); | 186 | config.setGroup( "PlayList" ); |
185 | QString filename=QPEApplication::documentDir() + "/default.m3u"; | 187 | QString filename=QPEApplication::documentDir() + "/default.m3u"; |
186 | QString currentString = config.readEntry( "CurrentPlaylist", filename); | 188 | QString currentString = config.readEntry( "CurrentPlaylist", filename); |
187 | if( currentString == filename) { | 189 | if( currentString == filename) { |
188 | Om3u *m3uList; | 190 | Om3u *m3uList; |
189 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); | 191 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); |
190 | if( d->selectedFiles->first() ) { | 192 | if( d->selectedFiles->first() ) { |
191 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 193 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
192 | do { | 194 | do { |
193 | // qDebug(d->selectedFiles->current()->file()); | 195 | // qDebug(d->selectedFiles->current()->file()); |
194 | m3uList->add( d->selectedFiles->current()->file() ); | 196 | m3uList->add( d->selectedFiles->current()->file() ); |
195 | } | 197 | } |
196 | while ( d->selectedFiles->next() ); | 198 | while ( d->selectedFiles->next() ); |
197 | 199 | ||
198 | m3uList->write(); | 200 | m3uList->write(); |
199 | m3uList->close(); | 201 | m3uList->close(); |
200 | if(m3uList) delete m3uList; | 202 | if(m3uList) delete m3uList; |
201 | 203 | ||
202 | } | 204 | } |
203 | } | 205 | } |
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(); |
397 | } | 399 | } |
398 | } | 400 | } |
399 | 401 | ||
400 | 402 | ||
401 | bool PlayListWidget::first() { | 403 | bool PlayListWidget::first() { |
402 | if ( mediaPlayerState->playlist() ) | 404 | if ( mediaPlayerState->playlist() ) |
403 | return d->selectedFiles->first(); | 405 | return d->selectedFiles->first(); |
404 | else | 406 | else |
405 | return mediaPlayerState->looping(); | 407 | return mediaPlayerState->looping(); |
406 | } | 408 | } |
407 | 409 | ||
408 | 410 | ||
409 | bool PlayListWidget::last() { | 411 | bool PlayListWidget::last() { |
410 | if ( mediaPlayerState->playlist() ) | 412 | if ( mediaPlayerState->playlist() ) |
411 | return d->selectedFiles->last(); | 413 | return d->selectedFiles->last(); |
412 | else | 414 | else |
413 | return mediaPlayerState->looping(); | 415 | return mediaPlayerState->looping(); |
414 | } | 416 | } |
415 | 417 | ||
416 | 418 | ||
417 | void PlayListWidget::saveList() { | 419 | void PlayListWidget::saveList() { |
418 | writem3u(); | 420 | writem3u(); |
419 | } | 421 | } |
420 | 422 | ||
421 | 423 | ||
422 | void PlayListWidget::loadList( const DocLnk & lnk) { | 424 | void PlayListWidget::loadList( const DocLnk & lnk) { |
423 | QString name = lnk.name(); | 425 | QString name = lnk.name(); |
424 | qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); | 426 | qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); |
425 | 427 | ||
426 | if( name.length()>0) { | 428 | if( name.length()>0) { |
427 | setCaption("OpiePlayer: "+name); | 429 | setCaption("OpiePlayer: "+name); |
428 | qDebug("<<<<<<<<<<<<load list "+ lnk.file()); | 430 | qDebug("<<<<<<<<<<<<load list "+ lnk.file()); |
429 | clearList(); | 431 | clearList(); |
430 | readm3u(lnk.file()); | 432 | readm3u(lnk.file()); |
431 | tabWidget->setCurrentPage(0); | 433 | tabWidget->setCurrentPage(0); |
432 | } | 434 | } |
433 | } | 435 | } |
434 | 436 | ||
435 | 437 | ||
436 | void PlayListWidget::setPlaylist( bool shown ) { | 438 | void PlayListWidget::setPlaylist( bool shown ) { |
437 | if ( shown ) { | 439 | if ( shown ) { |
438 | d->playListFrame->show(); | 440 | d->playListFrame->show(); |
439 | } else { | 441 | } else { |
440 | d->playListFrame->hide(); | 442 | d->playListFrame->hide(); |
441 | } | 443 | } |
442 | } | 444 | } |
443 | 445 | ||
444 | 446 | ||
445 | void PlayListWidget::addSelected() { | 447 | void PlayListWidget::addSelected() { |
446 | qDebug("addSelected"); | 448 | qDebug("addSelected"); |
447 | switch (whichList()) { | 449 | switch (whichList()) { |
448 | case 0: //playlist | 450 | case 0: //playlist |
449 | break; | 451 | break; |
450 | case 1: { //audio | 452 | case 1: { //audio |
451 | QListViewItemIterator it( audioView ); | 453 | QListViewItemIterator it( audioView ); |
452 | // iterate through all items of the listview | 454 | // iterate through all items of the listview |
453 | for ( ; it.current(); ++it ) { | 455 | for ( ; it.current(); ++it ) { |
454 | if ( it.current()->isSelected() ) { | 456 | if ( it.current()->isSelected() ) { |
455 | QListIterator<DocLnk> dit( files.children() ); | 457 | QListIterator<DocLnk> dit( files.children() ); |
456 | for ( ; dit.current(); ++dit ) { | 458 | for ( ; dit.current(); ++dit ) { |
457 | if( dit.current()->name() == it.current()->text(0) ) { | 459 | if( dit.current()->name() == it.current()->text(0) ) { |
458 | if( QFileInfo( dit.current()->file()).exists()) { | 460 | if( QFileInfo( dit.current()->file()).exists()) { |
459 | d->selectedFiles->addToSelection( **dit ); | 461 | d->selectedFiles->addToSelection( **dit ); |
460 | audioView->setSelected( it.current(),FALSE); | 462 | audioView->setSelected( it.current(),FALSE); |
461 | } | 463 | } |
462 | } | 464 | } |
463 | } | 465 | } |
464 | } | 466 | } |
465 | } | 467 | } |
466 | // tabWidget->setCurrentPage(0); | 468 | // tabWidget->setCurrentPage(0); |
467 | writeCurrentM3u(); | 469 | writeCurrentM3u(); |
468 | d->selectedFiles->next(); | 470 | d->selectedFiles->next(); |
469 | } | 471 | } |
470 | break; | 472 | break; |
471 | case 2: { // video | 473 | case 2: { // video |
472 | QListViewItemIterator it( videoView ); | 474 | QListViewItemIterator it( videoView ); |
473 | // iterate through all items of the listview | 475 | // iterate through all items of the listview |
474 | for ( ; it.current(); ++it ) { | 476 | for ( ; it.current(); ++it ) { |
475 | if ( it.current()->isSelected() ) { | 477 | if ( it.current()->isSelected() ) { |
476 | QListIterator<DocLnk> dit( vFiles.children() ); | 478 | QListIterator<DocLnk> dit( vFiles.children() ); |
477 | for ( ; dit.current(); ++dit ) { | 479 | for ( ; dit.current(); ++dit ) { |
478 | if( dit.current()->name() == it.current()->text(0) ) { | 480 | if( dit.current()->name() == it.current()->text(0) ) { |
479 | if(QFileInfo( dit.current()->file()).exists()) { | 481 | if(QFileInfo( dit.current()->file()).exists()) { |
480 | d->selectedFiles->addToSelection( **dit ); | 482 | d->selectedFiles->addToSelection( **dit ); |
481 | videoView->setSelected( it.current(),FALSE); | 483 | videoView->setSelected( it.current(),FALSE); |
482 | } | 484 | } |
483 | } | 485 | } |
484 | } | 486 | } |
485 | } | 487 | } |
486 | } | 488 | } |
487 | // tabWidget->setCurrentPage(0); | 489 | // tabWidget->setCurrentPage(0); |
488 | writeCurrentM3u(); | 490 | writeCurrentM3u(); |
489 | 491 | ||
490 | } | 492 | } |
491 | break; | 493 | break; |
492 | }; | 494 | }; |
493 | } | 495 | } |
494 | 496 | ||
495 | 497 | ||
496 | void PlayListWidget::removeSelected() { | 498 | void PlayListWidget::removeSelected() { |
497 | d->selectedFiles->removeSelected( ); | 499 | d->selectedFiles->removeSelected( ); |
498 | writeCurrentM3u(); | 500 | writeCurrentM3u(); |
499 | } | 501 | } |
500 | 502 | ||
501 | 503 | ||
502 | void PlayListWidget::playIt( QListViewItem *it) { | 504 | void PlayListWidget::playIt( QListViewItem *it) { |
503 | if(!it) return; | 505 | if(!it) return; |
504 | mediaPlayerState->setPlaying(FALSE); | 506 | mediaPlayerState->setPlaying(FALSE); |
505 | mediaPlayerState->setPlaying(TRUE); | 507 | mediaPlayerState->setPlaying(TRUE); |
506 | d->selectedFiles->unSelect(); | 508 | d->selectedFiles->unSelect(); |
507 | } | 509 | } |
508 | 510 | ||
509 | 511 | ||
510 | void PlayListWidget::addToSelection( QListViewItem *it) { | 512 | void PlayListWidget::addToSelection( QListViewItem *it) { |
511 | d->setDocumentUsed = FALSE; | 513 | d->setDocumentUsed = FALSE; |
512 | 514 | ||
513 | if(it) { | 515 | if(it) { |
514 | switch ( whichList()) { | 516 | switch ( whichList()) { |
515 | case 1: { | 517 | case 1: { |
516 | QListIterator<DocLnk> dit( files.children() ); | 518 | QListIterator<DocLnk> dit( files.children() ); |
517 | for ( ; dit.current(); ++dit ) { | 519 | for ( ; dit.current(); ++dit ) { |
518 | if( dit.current()->name() == it->text(0)) { | 520 | if( dit.current()->name() == it->text(0)) { |
519 | if(QFileInfo( dit.current()->file()).exists()) { | 521 | if(QFileInfo( dit.current()->file()).exists()) { |
520 | d->selectedFiles->addToSelection( **dit ); | 522 | d->selectedFiles->addToSelection( **dit ); |
521 | // qDebug("blah "+ dit.current()->name()); | 523 | // qDebug("blah "+ dit.current()->name()); |
522 | // d->selectedFiles->setSelectedItem( dit.current()->name()); | 524 | // d->selectedFiles->setSelectedItem( dit.current()->name()); |
523 | } | 525 | } |
524 | } | 526 | } |
525 | } | 527 | } |
526 | writeCurrentM3u(); | 528 | writeCurrentM3u(); |
527 | } | 529 | } |
528 | break; | 530 | break; |
529 | case 2: { | 531 | case 2: { |
530 | QListIterator<DocLnk> dit( vFiles.children() ); | 532 | QListIterator<DocLnk> dit( vFiles.children() ); |
531 | for ( ; dit.current(); ++dit ) { | 533 | for ( ; dit.current(); ++dit ) { |
532 | if( dit.current()->name() == it->text(0)) { | 534 | if( dit.current()->name() == it->text(0)) { |
533 | if( QFileInfo( dit.current()->file()).exists() ) { | 535 | if( QFileInfo( dit.current()->file()).exists() ) { |
534 | d->selectedFiles->addToSelection( **dit ); | 536 | d->selectedFiles->addToSelection( **dit ); |
535 | // qDebug("blah "+ dit.current()->name()); | 537 | // qDebug("blah "+ dit.current()->name()); |
536 | // d->selectedFiles->setSelectedItem( dit.current()->name()); | 538 | // d->selectedFiles->setSelectedItem( dit.current()->name()); |
537 | } | 539 | } |
538 | } | 540 | } |
539 | } | 541 | } |
540 | writeCurrentM3u(); | 542 | writeCurrentM3u(); |
541 | 543 | ||
542 | } | 544 | } |
543 | break; | 545 | break; |
544 | case 0: | 546 | case 0: |
545 | break; | 547 | break; |
546 | }; | 548 | }; |
547 | tabWidget->setCurrentPage(0); | 549 | tabWidget->setCurrentPage(0); |
548 | 550 | ||
549 | } | 551 | } |
550 | } | 552 | } |
551 | 553 | ||
552 | 554 | ||
553 | void PlayListWidget::tabChanged(QWidget *) { | 555 | void PlayListWidget::tabChanged(QWidget *) { |
554 | 556 | ||
555 | switch ( whichList()) { | 557 | switch ( whichList()) { |
556 | case 0: | 558 | case 0: |
557 | { | 559 | { |
558 | if( !tbDeletePlaylist->isHidden() ) { | 560 | if( !tbDeletePlaylist->isHidden() ) { |
559 | tbDeletePlaylist->hide(); | 561 | tbDeletePlaylist->hide(); |
560 | } | 562 | } |
561 | d->tbRemoveFromList->setEnabled(TRUE); | 563 | d->tbRemoveFromList->setEnabled(TRUE); |
562 | d->tbAddToList->setEnabled(FALSE); | 564 | d->tbAddToList->setEnabled(FALSE); |
563 | } | 565 | } |
564 | break; | 566 | break; |
565 | case 1: | 567 | case 1: |
566 | { | 568 | { |
567 | audioView->clear(); | 569 | audioView->clear(); |
568 | populateAudioView(); | 570 | populateAudioView(); |
569 | 571 | ||
570 | if( !tbDeletePlaylist->isHidden() ) { | 572 | if( !tbDeletePlaylist->isHidden() ) { |
571 | tbDeletePlaylist->hide(); | 573 | tbDeletePlaylist->hide(); |
572 | } | 574 | } |
573 | d->tbRemoveFromList->setEnabled(FALSE); | 575 | d->tbRemoveFromList->setEnabled(FALSE); |
574 | d->tbAddToList->setEnabled(TRUE); | 576 | d->tbAddToList->setEnabled(TRUE); |
575 | } | 577 | } |
576 | break; | 578 | break; |
577 | case 2: | 579 | case 2: |
578 | { | 580 | { |
579 | videoView->clear(); | 581 | videoView->clear(); |
580 | populateVideoView(); | 582 | populateVideoView(); |
581 | if( !tbDeletePlaylist->isHidden() ) { | 583 | if( !tbDeletePlaylist->isHidden() ) { |
582 | tbDeletePlaylist->hide(); | 584 | tbDeletePlaylist->hide(); |
583 | } | 585 | } |
584 | d->tbRemoveFromList->setEnabled(FALSE); | 586 | d->tbRemoveFromList->setEnabled(FALSE); |
585 | d->tbAddToList->setEnabled(TRUE); | 587 | d->tbAddToList->setEnabled(TRUE); |
586 | } | 588 | } |
587 | break; | 589 | break; |
588 | case 3: | 590 | case 3: |
589 | { | 591 | { |
590 | if( tbDeletePlaylist->isHidden() ) { | 592 | if( tbDeletePlaylist->isHidden() ) { |
591 | tbDeletePlaylist->show(); | 593 | tbDeletePlaylist->show(); |
592 | } | 594 | } |
593 | playLists->reread(); | 595 | playLists->reread(); |
594 | } | 596 | } |
595 | break; | 597 | break; |
596 | }; | 598 | }; |
597 | } | 599 | } |
598 | 600 | ||
599 | 601 | ||
600 | void PlayListWidget::btnPlay(bool b) { | 602 | void PlayListWidget::btnPlay(bool b) { |
601 | // mediaPlayerState->setPlaying(false); | 603 | // mediaPlayerState->setPlaying(false); |
602 | mediaPlayerState->setPlaying(b); | 604 | mediaPlayerState->setPlaying(b); |
603 | insanityBool=FALSE; | 605 | insanityBool=FALSE; |
604 | } | 606 | } |
605 | 607 | ||
606 | void PlayListWidget::deletePlaylist() { | 608 | void PlayListWidget::deletePlaylist() { |
607 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 609 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
608 | (tr("You really want to delete\nthis playlist?")), | 610 | (tr("You really want to delete\nthis playlist?")), |
609 | (tr("Yes")), (tr("No")), 0 )){ | 611 | (tr("Yes")), (tr("No")), 0 )){ |
610 | case 0: // Yes clicked, | 612 | case 0: // Yes clicked, |
611 | QFile().remove(playLists->selectedDocument().file()); | 613 | QFile().remove(playLists->selectedDocument().file()); |
612 | QFile().remove(playLists->selectedDocument().linkFile()); | 614 | QFile().remove(playLists->selectedDocument().linkFile()); |
613 | playLists->reread(); | 615 | playLists->reread(); |
614 | break; | 616 | break; |
615 | case 1: // Cancel | 617 | case 1: // Cancel |
616 | break; | 618 | break; |
617 | }; | 619 | }; |
618 | } | 620 | } |
619 | 621 | ||
620 | 622 | ||
621 | void PlayListWidget::playSelected() { | 623 | void PlayListWidget::playSelected() { |
622 | btnPlay( TRUE); | 624 | btnPlay( TRUE); |
623 | } | 625 | } |
624 | 626 | ||
625 | 627 | ||
626 | void PlayListWidget::scanForAudio() { | 628 | void PlayListWidget::scanForAudio() { |
627 | // qDebug("scan for audio"); | 629 | // qDebug("scan for audio"); |
628 | files.detachChildren(); | 630 | files.detachChildren(); |
629 | QListIterator<DocLnk> sdit( files.children() ); | 631 | QListIterator<DocLnk> sdit( files.children() ); |
630 | for ( ; sdit.current(); ++sdit ) { | 632 | for ( ; sdit.current(); ++sdit ) { |
631 | delete sdit.current(); | 633 | delete sdit.current(); |
632 | } | 634 | } |
633 | // Global::findDocuments( &files, "audio/*"); | 635 | // Global::findDocuments( &files, "audio/*"); |
634 | Global::findDocuments( &files, audioMimes); | 636 | Global::findDocuments( &files, audioMimes); |
635 | audioScan = TRUE; | 637 | audioScan = TRUE; |
636 | } | 638 | } |
637 | 639 | ||
638 | void PlayListWidget::scanForVideo() { | 640 | void PlayListWidget::scanForVideo() { |
639 | // qDebug("scan for video"); | 641 | // qDebug("scan for video"); |
640 | vFiles.detachChildren(); | 642 | vFiles.detachChildren(); |
641 | QListIterator<DocLnk> sdit( vFiles.children() ); | 643 | QListIterator<DocLnk> sdit( vFiles.children() ); |
642 | for ( ; sdit.current(); ++sdit ) { | 644 | for ( ; sdit.current(); ++sdit ) { |
643 | delete sdit.current(); | 645 | delete sdit.current(); |
644 | } | 646 | } |
645 | Global::findDocuments(&vFiles, "video/*"); | 647 | Global::findDocuments(&vFiles, "video/*"); |
646 | videoScan = TRUE; | 648 | videoScan = TRUE; |
647 | } | 649 | } |
648 | 650 | ||
649 | void PlayListWidget::populateAudioView() { | 651 | void PlayListWidget::populateAudioView() { |
650 | audioView->clear(); | 652 | audioView->clear(); |
651 | StorageInfo storageInfo; | 653 | StorageInfo storageInfo; |
652 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 654 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
653 | if(!audioScan) { | 655 | if(!audioScan) { |
654 | scanForAudio(); | 656 | scanForAudio(); |
655 | } | 657 | } |
656 | 658 | ||
657 | QListIterator<DocLnk> dit( files.children() ); | 659 | QListIterator<DocLnk> dit( files.children() ); |
658 | QListIterator<FileSystem> it ( fs ); | 660 | QListIterator<FileSystem> it ( fs ); |
659 | 661 | ||
660 | QString storage; | 662 | QString storage; |
661 | for ( ; dit.current(); ++dit ) { | 663 | for ( ; dit.current(); ++dit ) { |
662 | for( ; it.current(); ++it ){ | 664 | for( ; it.current(); ++it ){ |
663 | const QString name = (*it)->name(); | 665 | const QString name = (*it)->name(); |
664 | const QString path = (*it)->path(); | 666 | const QString path = (*it)->path(); |
665 | if(dit.current()->file().find(path) != -1 ) { | 667 | if(dit.current()->file().find(path) != -1 ) { |
666 | storage = name; | 668 | storage = name; |
667 | } | 669 | } |
668 | } | 670 | } |
669 | 671 | ||
670 | QListViewItem * newItem; | 672 | QListViewItem * newItem; |
671 | if ( QFile( dit.current()->file()).exists() || | 673 | if ( QFile( dit.current()->file()).exists() || |
672 | dit.current()->file().left(4) == "http" ) { | 674 | dit.current()->file().left(4) == "http" ) { |
673 | long size; | 675 | long size; |
674 | if( dit.current()->file().left(4) == "http" ) | 676 | if( dit.current()->file().left(4) == "http" ) |
675 | size=0; | 677 | size=0; |
676 | else | 678 | else |
677 | size = QFile( dit.current()->file() ).size(); | 679 | size = QFile( dit.current()->file() ).size(); |
678 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 680 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
679 | QString::number(size ), storage, dit.current()->file()); | 681 | QString::number(size ), storage, dit.current()->file()); |
680 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); | 682 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); |
681 | } | 683 | } |
682 | } | 684 | } |
683 | } | 685 | } |
684 | 686 | ||
685 | 687 | ||
686 | void PlayListWidget::populateVideoView() { | 688 | void PlayListWidget::populateVideoView() { |
687 | videoView->clear(); | 689 | videoView->clear(); |
688 | StorageInfo storageInfo; | 690 | StorageInfo storageInfo; |
689 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 691 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
690 | 692 | ||
691 | if(!videoScan ) { | 693 | if(!videoScan ) { |
692 | scanForVideo(); | 694 | scanForVideo(); |
693 | } | 695 | } |
694 | 696 | ||
695 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 697 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
696 | QListIterator<FileSystem> it ( fs ); | 698 | QListIterator<FileSystem> it ( fs ); |
697 | videoView->clear(); | 699 | videoView->clear(); |
698 | QString storage, pathName; | 700 | QString storage, pathName; |
699 | for ( ; Vdit.current(); ++Vdit ) { | 701 | for ( ; Vdit.current(); ++Vdit ) { |
700 | for( ; it.current(); ++it ) { | 702 | for( ; it.current(); ++it ) { |
701 | const QString name = (*it)->name(); | 703 | const QString name = (*it)->name(); |
702 | const QString path = (*it)->path(); | 704 | const QString path = (*it)->path(); |
703 | if( Vdit.current()->file().find(path) != -1 ) { | 705 | if( Vdit.current()->file().find(path) != -1 ) { |
704 | storage=name; | 706 | storage=name; |
705 | pathName=path; | 707 | pathName=path; |
706 | } | 708 | } |
707 | } | 709 | } |
708 | 710 | ||
709 | QListViewItem * newItem; | 711 | QListViewItem * newItem; |
710 | if ( QFile( Vdit.current()->file() ).exists() ) { | 712 | if ( QFile( Vdit.current()->file() ).exists() ) { |
711 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 713 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
712 | QString::number( QFile( Vdit.current()->file() ).size() ), | 714 | QString::number( QFile( Vdit.current()->file() ).size() ), |
713 | storage, Vdit.current()->file()); | 715 | storage, Vdit.current()->file()); |
714 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); | 716 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); |
715 | } | 717 | } |
716 | } | 718 | } |
717 | } | 719 | } |
718 | 720 | ||
719 | 721 | ||
720 | void PlayListWidget::openFile() { | 722 | void PlayListWidget::openFile() { |
721 | // http://66.28.164.33:2080 | 723 | // http://66.28.164.33:2080 |
722 | // http://somafm.com/star0242.m3u | 724 | // http://somafm.com/star0242.m3u |
723 | QString filename, name; | 725 | QString filename, name; |
724 | InputDialog *fileDlg; | 726 | InputDialog *fileDlg; |
725 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 727 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
726 | fileDlg->exec(); | 728 | fileDlg->exec(); |
727 | if( fileDlg->result() == 1 ) { | 729 | if( fileDlg->result() == 1 ) { |
728 | filename = fileDlg->text(); | 730 | filename = fileDlg->text(); |
729 | qDebug( "Selected filename is " + filename ); | 731 | qDebug( "Selected filename is " + filename ); |
730 | Om3u *m3uList; | 732 | Om3u *m3uList; |
731 | DocLnk lnk; | 733 | DocLnk lnk; |
732 | Config cfg( "OpiePlayer" ); | 734 | Config cfg( "OpiePlayer" ); |
733 | cfg.setGroup("PlayList"); | 735 | cfg.setGroup("PlayList"); |
734 | 736 | ||
735 | if(filename.left(4) == "http") { | 737 | if(filename.left(4) == "http") { |
736 | QString m3uFile, m3uFilePath; | 738 | QString m3uFile, m3uFilePath; |
737 | if(filename.find(":",8,TRUE) != -1) { //found a port | 739 | if(filename.find(":",8,TRUE) != -1) { //found a port |
738 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 740 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
739 | m3uFile = m3uFile.right( 7); | 741 | m3uFile = m3uFile.right( 7); |
740 | } else if(filename.left(4) == "http"){ | 742 | } else if(filename.left(4) == "http"){ |
741 | m3uFile=filename; | 743 | m3uFile=filename; |
742 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 744 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
743 | } else{ | 745 | } else{ |
744 | m3uFile=filename; | 746 | m3uFile=filename; |
745 | } | 747 | } |
746 | 748 | ||
747 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); | 749 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); |
748 | lnk.setName( filename ); //sets name | 750 | lnk.setName( filename ); //sets name |
749 | lnk.setFile( filename ); //sets file name | 751 | lnk.setFile( filename ); //sets file name |
750 | 752 | ||
751 | // lnk.setIcon("opieplayer2/musicfile"); | 753 | // lnk.setIcon("opieplayer2/musicfile"); |
752 | 754 | ||
753 | d->selectedFiles->addToSelection( lnk ); | 755 | d->selectedFiles->addToSelection( lnk ); |
754 | writeCurrentM3u(); | 756 | writeCurrentM3u(); |
755 | d->selectedFiles->setSelectedItem( lnk.name()); | 757 | d->selectedFiles->setSelectedItem( lnk.name()); |
756 | } | 758 | } |
757 | else if( filename.right( 3) == "m3u" ) { | 759 | else if( filename.right( 3) == "m3u" ) { |
758 | readm3u( filename ); | 760 | readm3u( filename ); |
759 | 761 | ||
760 | } else if( filename.right(3) == "pls" ) { | 762 | } else if( filename.right(3) == "pls" ) { |
761 | readPls( filename ); | 763 | readPls( filename ); |
762 | } else { | 764 | } else { |
763 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 765 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
764 | lnk.setFile( filename ); //sets file name | 766 | lnk.setFile( filename ); //sets file name |
765 | d->selectedFiles->addToSelection( lnk); | 767 | d->selectedFiles->addToSelection( lnk); |
766 | writeCurrentM3u(); | 768 | writeCurrentM3u(); |
767 | d->selectedFiles->setSelectedItem( lnk.name()); | 769 | d->selectedFiles->setSelectedItem( lnk.name()); |
768 | } | 770 | } |
769 | } | 771 | } |
770 | 772 | ||
771 | if( fileDlg ) { | 773 | if( fileDlg ) { |
772 | delete fileDlg; | 774 | delete fileDlg; |
773 | } | 775 | } |
774 | } | 776 | } |
775 | 777 | ||
776 | /* | 778 | /* |
777 | reads m3u and shows files/urls to playlist widget */ | 779 | reads m3u and shows files/urls to playlist widget */ |
778 | void PlayListWidget::readm3u( const QString &filename ) { | 780 | void PlayListWidget::readm3u( const QString &filename ) { |
779 | qDebug( "read m3u filename " + filename ); | 781 | qDebug( "read m3u filename " + filename ); |
780 | 782 | ||
781 | Om3u *m3uList; | 783 | Om3u *m3uList; |
782 | QString s, name; | 784 | QString s, name; |
783 | m3uList = new Om3u( filename, IO_ReadOnly ); | 785 | m3uList = new Om3u( filename, IO_ReadOnly ); |
784 | m3uList->readM3u(); | 786 | m3uList->readM3u(); |
785 | DocLnk lnk; | 787 | DocLnk lnk; |
786 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 788 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
787 | s = *it; | 789 | s = *it; |
788 | // qDebug("reading "+ s); | 790 | // qDebug("reading "+ s); |
789 | if(s.left(4)=="http") { | 791 | if(s.left(4)=="http") { |
790 | lnk.setName( s ); //sets file name | 792 | lnk.setName( s ); //sets file name |
791 | lnk.setIcon("opieplayer2/musicfile"); | 793 | lnk.setIcon("opieplayer2/musicfile"); |
792 | // if(s.right(4) != '.' || s.right(5) != '.') | 794 | // if(s.right(4) != '.' || s.right(5) != '.') |
793 | // lnk.setFile( s+"/"); //if url with no extension | 795 | // lnk.setFile( s+"/"); //if url with no extension |
794 | // else | 796 | // else |
795 | lnk.setFile( s ); //sets file name | 797 | lnk.setFile( s ); //sets file name |
796 | 798 | ||
797 | } else { | 799 | } else { |
798 | // if( QFileInfo( s ).exists() ) { | 800 | // if( QFileInfo( s ).exists() ) { |
799 | lnk.setName( QFileInfo(s).baseName()); | 801 | lnk.setName( QFileInfo(s).baseName()); |
800 | // if(s.right(4) == '.') {//if regular file | 802 | // if(s.right(4) == '.') {//if regular file |
801 | if(s.left(1) != "/") { | 803 | if(s.left(1) != "/") { |
802 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | 804 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); |
803 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 805 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
804 | // lnk.setIcon(MimeType(s).pixmap() ); | 806 | // lnk.setIcon(MimeType(s).pixmap() ); |
805 | // lnk.setIcon("SoundPlayer"); | 807 | // lnk.setIcon("SoundPlayer"); |
806 | } else { | 808 | } else { |
807 | // qDebug("set link2 "+s); | 809 | // qDebug("set link2 "+s); |
808 | lnk.setFile( s); | 810 | lnk.setFile( s); |
809 | // lnk.setIcon(MimeType(s).pixmap() ); | 811 | // lnk.setIcon(MimeType(s).pixmap() ); |
810 | // lnk.setIcon("SoundPlayer"); | 812 | // lnk.setIcon("SoundPlayer"); |
811 | } | 813 | } |
812 | } | 814 | } |
813 | d->selectedFiles->addToSelection( lnk ); | 815 | d->selectedFiles->addToSelection( lnk ); |
814 | } | 816 | } |
815 | Config config( "OpiePlayer" ); | 817 | Config config( "OpiePlayer" ); |
816 | config.setGroup( "PlayList" ); | 818 | config.setGroup( "PlayList" ); |
817 | 819 | ||
818 | config.writeEntry("CurrentPlaylist",filename); | 820 | config.writeEntry("CurrentPlaylist",filename); |
819 | config.write(); | 821 | config.write(); |
820 | currentPlayList=filename; | 822 | currentPlayList=filename; |
821 | 823 | ||
822 | // m3uList->write(); | 824 | // m3uList->write(); |
823 | m3uList->close(); | 825 | m3uList->close(); |
824 | if(m3uList) delete m3uList; | 826 | if(m3uList) delete m3uList; |
825 | 827 | ||
826 | d->selectedFiles->setSelectedItem( s); | 828 | d->selectedFiles->setSelectedItem( s); |
827 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 829 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
828 | 830 | ||
829 | } | 831 | } |
830 | 832 | ||
831 | /* | 833 | /* |
832 | reads pls and adds files/urls to playlist */ | 834 | reads pls and adds files/urls to playlist */ |
833 | void PlayListWidget::readPls( const QString &filename ) { | 835 | void PlayListWidget::readPls( const QString &filename ) { |
834 | 836 | ||
835 | qDebug( "pls filename is " + filename ); | 837 | qDebug( "pls filename is " + filename ); |
836 | Om3u *m3uList; | 838 | Om3u *m3uList; |
837 | QString s, name; | 839 | QString s, name; |
838 | m3uList = new Om3u( filename, IO_ReadOnly ); | 840 | m3uList = new Om3u( filename, IO_ReadOnly ); |
839 | m3uList->readPls(); | 841 | m3uList->readPls(); |
840 | 842 | ||
841 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 843 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
842 | s = *it; | 844 | s = *it; |
843 | // s.replace( QRegExp( "%20" )," " ); | 845 | // s.replace( QRegExp( "%20" )," " ); |
844 | DocLnk lnk( s ); | 846 | DocLnk lnk( s ); |
845 | QFileInfo f( s ); | 847 | QFileInfo f( s ); |
846 | QString name = f.baseName(); | 848 | QString name = f.baseName(); |
847 | 849 | ||
848 | if( name.left( 4 ) == "http" ) { | 850 | if( name.left( 4 ) == "http" ) { |
849 | name = s.right( s.length() - 7); | 851 | name = s.right( s.length() - 7); |
850 | } else { | 852 | } else { |
851 | name = s; | 853 | name = s; |
852 | } | 854 | } |
853 | 855 | ||
854 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 856 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
855 | 857 | ||
856 | lnk.setName( name ); | 858 | lnk.setName( name ); |
857 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | 859 | if( s.at( s.length() - 4) == '.') {// if this is probably a file |
858 | lnk.setFile( s ); | 860 | lnk.setFile( s ); |
859 | } else { //if its a url | 861 | } else { //if its a url |
860 | // if( name.right( 1 ).find( '/' ) == -1) { | 862 | // if( name.right( 1 ).find( '/' ) == -1) { |
861 | // s += "/"; | 863 | // s += "/"; |
862 | // } | 864 | // } |
863 | lnk.setFile( s ); | 865 | lnk.setFile( s ); |
864 | } | 866 | } |
865 | lnk.setType( "audio/x-mpegurl" ); | 867 | lnk.setType( "audio/x-mpegurl" ); |
866 | 868 | ||
867 | lnk.writeLink(); | 869 | lnk.writeLink(); |
868 | d->selectedFiles->addToSelection( lnk ); | 870 | d->selectedFiles->addToSelection( lnk ); |
869 | } | 871 | } |
870 | 872 | ||
871 | m3uList->close(); | 873 | m3uList->close(); |
872 | if(m3uList) delete m3uList; | 874 | if(m3uList) delete m3uList; |
873 | } | 875 | } |
874 | 876 | ||
875 | /* | 877 | /* |
876 | writes current playlist to current m3u file */ | 878 | writes current playlist to current m3u file */ |
877 | void PlayListWidget::writeCurrentM3u() { | 879 | void PlayListWidget::writeCurrentM3u() { |
878 | qDebug("writing to current m3u"); | 880 | qDebug("writing to current m3u"); |
879 | Config cfg( "OpiePlayer" ); | 881 | Config cfg( "OpiePlayer" ); |
880 | cfg.setGroup("PlayList"); | 882 | cfg.setGroup("PlayList"); |
881 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 883 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
882 | 884 | ||
883 | Om3u *m3uList; | 885 | Om3u *m3uList; |
884 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 886 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
885 | if( d->selectedFiles->first()) { | 887 | if( d->selectedFiles->first()) { |
886 | 888 | ||
887 | do { | 889 | do { |
888 | qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); | 890 | qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); |
889 | m3uList->add( d->selectedFiles->current()->file() ); | 891 | m3uList->add( d->selectedFiles->current()->file() ); |
890 | } | 892 | } |
891 | while ( d->selectedFiles->next() ); | 893 | while ( d->selectedFiles->next() ); |
892 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 894 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
893 | m3uList->write(); | 895 | m3uList->write(); |
894 | m3uList->close(); | 896 | m3uList->close(); |
895 | 897 | ||
896 | if(m3uList) delete m3uList; | 898 | if(m3uList) delete m3uList; |
897 | } | 899 | } |
898 | 900 | ||
899 | } | 901 | } |
900 | 902 | ||
901 | /* | 903 | /* |
902 | writes current playlist to m3u file */ | 904 | writes current playlist to m3u file */ |
903 | void PlayListWidget::writem3u() { | 905 | void PlayListWidget::writem3u() { |
904 | InputDialog *fileDlg; | 906 | InputDialog *fileDlg; |
905 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 907 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
906 | fileDlg->exec(); | 908 | fileDlg->exec(); |
907 | QString name, filename, list; | 909 | QString name, filename, list; |
908 | Om3u *m3uList; | 910 | Om3u *m3uList; |
909 | 911 | ||
910 | if( fileDlg->result() == 1 ) { | 912 | if( fileDlg->result() == 1 ) { |
911 | name = fileDlg->text(); | 913 | name = fileDlg->text(); |
912 | // qDebug( filename ); | 914 | // qDebug( filename ); |
913 | 915 | ||
914 | if( name.left( 1) != "/" ) { | 916 | if( name.left( 1) != "/" ) { |
915 | filename = QPEApplication::documentDir() + "/" + name; | 917 | filename = QPEApplication::documentDir() + "/" + name; |
916 | } | 918 | } |
917 | 919 | ||
918 | if( name.right( 3 ) != "m3u" ) { | 920 | if( name.right( 3 ) != "m3u" ) { |
919 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; | 921 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; |
920 | } | 922 | } |
921 | 923 | ||
922 | if( d->selectedFiles->first()) { | 924 | if( d->selectedFiles->first()) { |
923 | m3uList = new Om3u(filename, IO_ReadWrite); | 925 | m3uList = new Om3u(filename, IO_ReadWrite); |
924 | 926 | ||
925 | do { | 927 | do { |
926 | m3uList->add( d->selectedFiles->current()->file()); | 928 | m3uList->add( d->selectedFiles->current()->file()); |
927 | } | 929 | } |
928 | while ( d->selectedFiles->next() ); | 930 | while ( d->selectedFiles->next() ); |
929 | // qDebug( list ); | 931 | // qDebug( list ); |
930 | m3uList->write(); | 932 | m3uList->write(); |
931 | m3uList->close(); | 933 | m3uList->close(); |
932 | if(m3uList) delete m3uList; | 934 | if(m3uList) delete m3uList; |
933 | 935 | ||
934 | if(fileDlg) delete fileDlg; | 936 | if(fileDlg) delete fileDlg; |
935 | 937 | ||
936 | DocLnk lnk; | 938 | DocLnk lnk; |
937 | lnk.setFile( filename); | 939 | lnk.setFile( filename); |
938 | // lnk.setIcon("opieplayer2/playlist2"); | 940 | // lnk.setIcon("opieplayer2/playlist2"); |
939 | lnk.setName( name); //sets file name | 941 | lnk.setName( name); //sets file name |
940 | 942 | ||
941 | // qDebug(filename); | 943 | // qDebug(filename); |
942 | Config config( "OpiePlayer" ); | 944 | Config config( "OpiePlayer" ); |
943 | config.setGroup( "PlayList" ); | 945 | config.setGroup( "PlayList" ); |
944 | 946 | ||
945 | config.writeEntry("CurrentPlaylist",filename); | 947 | config.writeEntry("CurrentPlaylist",filename); |
946 | currentPlayList=filename; | 948 | currentPlayList=filename; |
947 | 949 | ||
948 | if(!lnk.writeLink()) { | 950 | if(!lnk.writeLink()) { |
949 | qDebug("Writing doclink did not work"); | 951 | qDebug("Writing doclink did not work"); |
950 | } | 952 | } |
951 | 953 | ||
952 | setCaption(tr("OpiePlayer: ") + name); | 954 | setCaption(tr("OpiePlayer: ") + name); |
953 | } | 955 | } |
954 | } | 956 | } |
955 | } | 957 | } |
956 | 958 | ||
957 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 959 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
958 | switch ( e->key() ) { | 960 | switch ( e->key() ) { |
959 | ////////////////////////////// Zaurus keys | 961 | ////////////////////////////// Zaurus keys |
960 | case Key_F9: //activity | 962 | case Key_F9: //activity |
961 | // if(audioUI->isHidden()) | 963 | // if(audioUI->isHidden()) |
962 | // audioUI->showMaximized(); | 964 | // audioUI->showMaximized(); |
963 | break; | 965 | break; |
964 | case Key_F10: //contacts | 966 | case Key_F10: //contacts |
965 | // if( videoUI->isHidden()) | 967 | // if( videoUI->isHidden()) |
966 | // videoUI->showMaximized(); | 968 | // videoUI->showMaximized(); |
967 | break; | 969 | break; |
968 | case Key_F11: //menu | 970 | case Key_F11: //menu |
969 | break; | 971 | break; |
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 | } |