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