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