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