-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index c35e03d..a65495e 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -1,960 +1,960 @@ | |||
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 | tabWidget->showPage( playListTab ); | 155 | tabWidget->showPage( playListTab ); |
156 | } | 156 | } |
157 | 157 | ||
158 | 158 | ||
159 | PlayListWidget::~PlayListWidget() { | 159 | PlayListWidget::~PlayListWidget() { |
160 | delete d; | 160 | delete d; |
161 | } | 161 | } |
162 | 162 | ||
163 | 163 | ||
164 | void PlayListWidget::initializeStates() { | 164 | void PlayListWidget::initializeStates() { |
165 | d->tbPlay->setOn( mediaPlayerState.isPlaying() ); | 165 | d->tbPlay->setOn( mediaPlayerState.isPlaying() ); |
166 | d->tbLoop->setOn( mediaPlayerState.isLooping() ); | 166 | d->tbLoop->setOn( mediaPlayerState.isLooping() ); |
167 | d->tbShuffle->setOn( mediaPlayerState.isShuffled() ); | 167 | d->tbShuffle->setOn( mediaPlayerState.isShuffled() ); |
168 | d->playListFrame->show(); | 168 | d->playListFrame->show(); |
169 | } | 169 | } |
170 | 170 | ||
171 | void PlayListWidget::writeDefaultPlaylist() { | 171 | void PlayListWidget::writeDefaultPlaylist() { |
172 | 172 | ||
173 | Config config( "OpiePlayer" ); | 173 | Config config( "OpiePlayer" ); |
174 | config.setGroup( "PlayList" ); | 174 | config.setGroup( "PlayList" ); |
175 | QString filename=QPEApplication::documentDir() + "/default.m3u"; | 175 | QString filename=QPEApplication::documentDir() + "/default.m3u"; |
176 | QString currentString = config.readEntry( "CurrentPlaylist", filename); | 176 | QString currentString = config.readEntry( "CurrentPlaylist", filename); |
177 | if( currentString == filename) { | 177 | if( currentString == filename) { |
178 | Om3u *m3uList; | 178 | Om3u *m3uList; |
179 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); | 179 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); |
180 | if( d->selectedFiles->first() ) { | 180 | if( d->selectedFiles->first() ) { |
181 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 181 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
182 | do { | 182 | do { |
183 | // qDebug(d->selectedFiles->current()->file()); | 183 | // qDebug(d->selectedFiles->current()->file()); |
184 | m3uList->add( d->selectedFiles->current()->file() ); | 184 | m3uList->add( d->selectedFiles->current()->file() ); |
185 | } | 185 | } |
186 | while ( d->selectedFiles->next() ); | 186 | while ( d->selectedFiles->next() ); |
187 | 187 | ||
188 | m3uList->write(); | 188 | m3uList->write(); |
189 | m3uList->close(); | 189 | m3uList->close(); |
190 | delete m3uList; | 190 | delete m3uList; |
191 | 191 | ||
192 | } | 192 | } |
193 | } | 193 | } |
194 | } | 194 | } |
195 | 195 | ||
196 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 196 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
197 | d->setDocumentUsed = FALSE; | 197 | d->setDocumentUsed = FALSE; |
198 | if( QFileInfo( lnk.file() ).exists() || | 198 | if( QFileInfo( lnk.file() ).exists() || |
199 | lnk.file().left(4) == "http" ) { | 199 | lnk.file().left(4) == "http" ) { |
200 | d->selectedFiles->addToSelection( lnk ); | 200 | d->selectedFiles->addToSelection( lnk ); |
201 | } | 201 | } |
202 | // writeCurrentM3u(); | 202 | // writeCurrentM3u(); |
203 | } | 203 | } |
204 | 204 | ||
205 | 205 | ||
206 | void PlayListWidget::clearList() { | 206 | void PlayListWidget::clearList() { |
207 | while ( first() ) { | 207 | while ( first() ) { |
208 | d->selectedFiles->removeSelected(); | 208 | d->selectedFiles->removeSelected(); |
209 | } | 209 | } |
210 | Config cfg( "OpiePlayer" ); | 210 | Config cfg( "OpiePlayer" ); |
211 | cfg.setGroup("PlayList"); | 211 | cfg.setGroup("PlayList"); |
212 | cfg.writeEntry("CurrentPlaylist","default"); | 212 | cfg.writeEntry("CurrentPlaylist","default"); |
213 | setCaption("OpiePlayer"); | 213 | setCaption("OpiePlayer"); |
214 | } | 214 | } |
215 | 215 | ||
216 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 216 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
217 | switch (mouse) { | 217 | switch (mouse) { |
218 | case LeftButton: | 218 | case LeftButton: |
219 | break; | 219 | break; |
220 | case RightButton: | 220 | case RightButton: |
221 | { | 221 | { |
222 | QPopupMenu m; | 222 | QPopupMenu m; |
223 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 223 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
224 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 224 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
225 | m.exec( QCursor::pos() ); | 225 | m.exec( QCursor::pos() ); |
226 | } | 226 | } |
227 | break; | 227 | break; |
228 | } | 228 | } |
229 | } | 229 | } |
230 | 230 | ||
231 | 231 | ||
232 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 232 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
233 | switch (mouse) { | 233 | switch (mouse) { |
234 | case LeftButton: | 234 | case LeftButton: |
235 | break; | 235 | break; |
236 | case RightButton: | 236 | case RightButton: |
237 | { | 237 | { |
238 | QPopupMenu m; | 238 | QPopupMenu m; |
239 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 239 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
240 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 240 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
241 | m.exec( QCursor::pos() ); | 241 | m.exec( QCursor::pos() ); |
242 | } | 242 | } |
243 | break; | 243 | break; |
244 | } | 244 | } |
245 | } | 245 | } |
246 | 246 | ||
247 | 247 | ||
248 | void PlayListWidget::addAllToList() { | 248 | void PlayListWidget::addAllToList() { |
249 | 249 | ||
250 | // QTime t; | 250 | // QTime t; |
251 | // t.start(); | 251 | // t.start(); |
252 | 252 | ||
253 | audioView->populateView(); | 253 | audioView->populateView(); |
254 | 254 | ||
255 | QListViewItemIterator audioIt( audioView ); | 255 | QListViewItemIterator audioIt( audioView ); |
256 | DocLnk lnk; | 256 | DocLnk lnk; |
257 | QString filename; | 257 | QString filename; |
258 | // iterate through all items of the listview | 258 | // iterate through all items of the listview |
259 | for ( ; audioIt.current(); ++audioIt ) { | 259 | for ( ; audioIt.current(); ++audioIt ) { |
260 | filename = audioIt.current()->text(3); | 260 | filename = audioIt.current()->text(3); |
261 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 261 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
262 | lnk.setFile( filename ); //sets file name | 262 | lnk.setFile( filename ); //sets file name |
263 | d->selectedFiles->addToSelection( lnk); | 263 | d->selectedFiles->addToSelection( lnk); |
264 | } | 264 | } |
265 | 265 | ||
266 | videoView->populateView(); | 266 | videoView->populateView(); |
267 | 267 | ||
268 | QListViewItemIterator videoIt( videoView ); | 268 | QListViewItemIterator videoIt( videoView ); |
269 | for ( ; videoIt.current(); ++videoIt ) { | 269 | for ( ; videoIt.current(); ++videoIt ) { |
270 | filename = videoIt.current()->text(3); | 270 | filename = videoIt.current()->text(3); |
271 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 271 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
272 | lnk.setFile( filename ); //sets file name | 272 | lnk.setFile( filename ); //sets file name |
273 | d->selectedFiles->addToSelection( lnk); | 273 | d->selectedFiles->addToSelection( lnk); |
274 | } | 274 | } |
275 | 275 | ||
276 | // d->selectedFiles->addToSelection( ); | 276 | // d->selectedFiles->addToSelection( ); |
277 | // if ( it.current()->isSelected() ) | 277 | // if ( it.current()->isSelected() ) |
278 | // lst->append( audioIt.current() ); | 278 | // lst->append( audioIt.current() ); |
279 | // } | 279 | // } |
280 | 280 | ||
281 | 281 | ||
282 | // if(!audioScan) | 282 | // if(!audioScan) |
283 | // scanForAudio(); | 283 | // scanForAudio(); |
284 | // if(!videoScan) | 284 | // if(!videoScan) |
285 | // scanForVideo(); | 285 | // scanForVideo(); |
286 | 286 | ||
287 | // DocLnkSet filesAll; | 287 | // DocLnkSet filesAll; |
288 | // Global::findDocuments(&filesAll, "video/*;"+audioMimes); | 288 | // Global::findDocuments(&filesAll, "video/*;"+audioMimes); |
289 | // QListIterator<DocLnk> Adit( filesAll.children() ); | 289 | // QListIterator<DocLnk> Adit( filesAll.children() ); |
290 | // for ( ; Adit.current(); ++Adit ) { | 290 | // for ( ; Adit.current(); ++Adit ) { |
291 | // if( QFileInfo( Adit.current()->file() ).exists() ) { | 291 | // if( QFileInfo( Adit.current()->file() ).exists() ) { |
292 | // d->selectedFiles->addToSelection( **Adit ); | 292 | // d->selectedFiles->addToSelection( **Adit ); |
293 | // } | 293 | // } |
294 | // } | 294 | // } |
295 | 295 | ||
296 | // qDebug("elapsed time %d", t.elapsed() ); | 296 | // qDebug("elapsed time %d", t.elapsed() ); |
297 | 297 | ||
298 | tabWidget->setCurrentPage(0); | 298 | tabWidget->setCurrentPage(0); |
299 | 299 | ||
300 | writeCurrentM3u(); | 300 | writeCurrentM3u(); |
301 | d->selectedFiles->first(); | 301 | d->selectedFiles->first(); |
302 | } | 302 | } |
303 | 303 | ||
304 | 304 | ||
305 | void PlayListWidget::addAllMusicToList() { | 305 | void PlayListWidget::addAllMusicToList() { |
306 | 306 | ||
307 | audioView->populateView(); | 307 | audioView->populateView(); |
308 | 308 | ||
309 | QListViewItemIterator audioIt( audioView ); | 309 | QListViewItemIterator audioIt( audioView ); |
310 | DocLnk lnk; | 310 | DocLnk lnk; |
311 | QString filename; | 311 | QString filename; |
312 | // iterate through all items of the listview | 312 | // iterate through all items of the listview |
313 | for ( ; audioIt.current(); ++audioIt ) { | 313 | for ( ; audioIt.current(); ++audioIt ) { |
314 | filename = audioIt.current()->text(3); | 314 | filename = audioIt.current()->text(3); |
315 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 315 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
316 | lnk.setFile( filename ); //sets file name | 316 | lnk.setFile( filename ); //sets file name |
317 | d->selectedFiles->addToSelection( lnk); | 317 | d->selectedFiles->addToSelection( lnk); |
318 | } | 318 | } |
319 | 319 | ||
320 | /* if(!audioScan) | 320 | /* if(!audioScan) |
321 | scanForAudio(); | 321 | scanForAudio(); |
322 | QListIterator<DocLnk> dit( files.children() ); | 322 | QListIterator<DocLnk> dit( files.children() ); |
323 | for ( ; dit.current(); ++dit ) { | 323 | for ( ; dit.current(); ++dit ) { |
324 | if( QFileInfo(dit.current()->file() ).exists() ) { | 324 | if( QFileInfo(dit.current()->file() ).exists() ) { |
325 | d->selectedFiles->addToSelection( **dit ); | 325 | d->selectedFiles->addToSelection( **dit ); |
326 | } | 326 | } |
327 | } | 327 | } |
328 | */ | 328 | */ |
329 | tabWidget->setCurrentPage(0); | 329 | tabWidget->setCurrentPage(0); |
330 | writeCurrentM3u(); | 330 | writeCurrentM3u(); |
331 | d->selectedFiles->first(); | 331 | d->selectedFiles->first(); |
332 | } | 332 | } |
333 | 333 | ||
334 | 334 | ||
335 | void PlayListWidget::addAllVideoToList() { | 335 | void PlayListWidget::addAllVideoToList() { |
336 | 336 | ||
337 | videoView->populateView(); | 337 | videoView->populateView(); |
338 | 338 | ||
339 | QListViewItemIterator videoIt( videoView ); | 339 | QListViewItemIterator videoIt( videoView ); |
340 | DocLnk lnk; | 340 | DocLnk lnk; |
341 | QString filename; | 341 | QString filename; |
342 | for ( ; videoIt.current(); ++videoIt ) { | 342 | for ( ; videoIt.current(); ++videoIt ) { |
343 | filename = videoIt.current()->text(3); | 343 | filename = videoIt.current()->text(3); |
344 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 344 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
345 | lnk.setFile( filename ); //sets file name | 345 | lnk.setFile( filename ); //sets file name |
346 | d->selectedFiles->addToSelection( lnk); | 346 | d->selectedFiles->addToSelection( lnk); |
347 | } | 347 | } |
348 | 348 | ||
349 | 349 | ||
350 | /* if(!videoScan) | 350 | /* if(!videoScan) |
351 | scanForVideo(); | 351 | scanForVideo(); |
352 | QListIterator<DocLnk> dit( vFiles.children() ); | 352 | QListIterator<DocLnk> dit( vFiles.children() ); |
353 | for ( ; dit.current(); ++dit ) { | 353 | for ( ; dit.current(); ++dit ) { |
354 | if( QFileInfo( dit.current()->file() ).exists() ) { | 354 | if( QFileInfo( dit.current()->file() ).exists() ) { |
355 | d->selectedFiles->addToSelection( **dit ); | 355 | d->selectedFiles->addToSelection( **dit ); |
356 | } | 356 | } |
357 | } | 357 | } |
358 | */ | 358 | */ |
359 | tabWidget->setCurrentPage(0); | 359 | tabWidget->setCurrentPage(0); |
360 | writeCurrentM3u(); | 360 | writeCurrentM3u(); |
361 | d->selectedFiles->first(); | 361 | d->selectedFiles->first(); |
362 | } | 362 | } |
363 | 363 | ||
364 | 364 | ||
365 | void PlayListWidget::setDocument( const QString& fileref ) { | 365 | void PlayListWidget::setDocument( const QString& fileref ) { |
366 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); | 366 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); |
367 | fromSetDocument = TRUE; | 367 | fromSetDocument = TRUE; |
368 | if ( fileref.isNull() ) { | 368 | if ( fileref.isNull() ) { |
369 | QMessageBox::warning( this, tr( "Invalid File" ), | 369 | QMessageBox::warning( this, tr( "Invalid File" ), |
370 | tr( "There was a problem in getting the file." ) ); | 370 | tr( "There was a problem in getting the file." ) ); |
371 | return; | 371 | return; |
372 | } | 372 | } |
373 | 373 | ||
374 | clearList(); | 374 | clearList(); |
375 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u | 375 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u |
376 | readm3u( fileref ); | 376 | readm3u( fileref ); |
377 | } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { | 377 | } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { |
378 | readm3u( DocLnk( fileref).file() ); | 378 | readm3u( DocLnk( fileref).file() ); |
379 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls | 379 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls |
380 | readPls( fileref ); | 380 | readPls( fileref ); |
381 | } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { | 381 | } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { |
382 | readPls( DocLnk( fileref).file() ); | 382 | readPls( DocLnk( fileref).file() ); |
383 | } else { | 383 | } else { |
384 | clearList(); | 384 | clearList(); |
385 | addToSelection( DocLnk( fileref ) ); | 385 | addToSelection( DocLnk( fileref ) ); |
386 | writeCurrentM3u(); | 386 | writeCurrentM3u(); |
387 | 387 | ||
388 | d->setDocumentUsed = TRUE; | 388 | d->setDocumentUsed = TRUE; |
389 | mediaPlayerState.setPlaying( FALSE ); | 389 | mediaPlayerState.setPlaying( FALSE ); |
390 | mediaPlayerState.setPlaying( TRUE ); | 390 | mediaPlayerState.setPlaying( TRUE ); |
391 | } | 391 | } |
392 | } | 392 | } |
393 | 393 | ||
394 | 394 | ||
395 | void PlayListWidget::useSelectedDocument() { | 395 | void PlayListWidget::useSelectedDocument() { |
396 | d->setDocumentUsed = FALSE; | 396 | d->setDocumentUsed = FALSE; |
397 | } | 397 | } |
398 | 398 | ||
399 | 399 | ||
400 | const DocLnk *PlayListWidget::current() const { // this is fugly | 400 | const DocLnk *PlayListWidget::current() const { // this is fugly |
401 | assert( currentTab() == CurrentPlayList ); | 401 | assert( currentTab() == CurrentPlayList ); |
402 | 402 | ||
403 | const DocLnk *lnk = d->selectedFiles->current(); | 403 | const DocLnk *lnk = d->selectedFiles->current(); |
404 | if ( !lnk ) { | 404 | if ( !lnk ) { |
405 | d->selectedFiles->first(); | 405 | d->selectedFiles->first(); |
406 | lnk = d->selectedFiles->current(); | 406 | lnk = d->selectedFiles->current(); |
407 | } | 407 | } |
408 | assert( lnk ); | 408 | assert( lnk ); |
409 | return lnk; | 409 | return lnk; |
410 | } | 410 | } |
411 | 411 | ||
412 | 412 | ||
413 | bool PlayListWidget::prev() { | 413 | bool PlayListWidget::prev() { |
414 | if ( mediaPlayerState.isShuffled() ) { | 414 | if ( mediaPlayerState.isShuffled() ) { |
415 | const DocLnk *cur = current(); | 415 | const DocLnk *cur = current(); |
416 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 416 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
417 | for ( int i = 0; i < j; i++ ) { | 417 | for ( int i = 0; i < j; i++ ) { |
418 | if ( !d->selectedFiles->next() ) | 418 | if ( !d->selectedFiles->next() ) |
419 | d->selectedFiles->first(); | 419 | d->selectedFiles->first(); |
420 | } | 420 | } |
421 | if ( cur == current() ) | 421 | if ( cur == current() ) |
422 | if ( !d->selectedFiles->next() ) { | 422 | if ( !d->selectedFiles->next() ) { |
423 | d->selectedFiles->first(); | 423 | d->selectedFiles->first(); |
424 | } | 424 | } |
425 | return TRUE; | 425 | return TRUE; |
426 | } else { | 426 | } else { |
427 | if ( !d->selectedFiles->prev() ) { | 427 | if ( !d->selectedFiles->prev() ) { |
428 | if ( mediaPlayerState.isLooping() ) { | 428 | if ( mediaPlayerState.isLooping() ) { |
429 | return d->selectedFiles->last(); | 429 | return d->selectedFiles->last(); |
430 | } else { | 430 | } else { |
431 | return FALSE; | 431 | return FALSE; |
432 | } | 432 | } |
433 | } | 433 | } |
434 | return TRUE; | 434 | return TRUE; |
435 | } | 435 | } |
436 | } | 436 | } |
437 | 437 | ||
438 | 438 | ||
439 | bool PlayListWidget::next() { | 439 | bool PlayListWidget::next() { |
440 | //qDebug("<<<<<<<<<<<<next()"); | 440 | //qDebug("<<<<<<<<<<<<next()"); |
441 | if ( mediaPlayerState.isShuffled() ) { | 441 | if ( mediaPlayerState.isShuffled() ) { |
442 | return prev(); | 442 | return prev(); |
443 | } else { | 443 | } else { |
444 | if ( !d->selectedFiles->next() ) { | 444 | if ( !d->selectedFiles->next() ) { |
445 | if ( mediaPlayerState.isLooping() ) { | 445 | if ( mediaPlayerState.isLooping() ) { |
446 | return d->selectedFiles->first(); | 446 | return d->selectedFiles->first(); |
447 | } else { | 447 | } else { |
448 | return FALSE; | 448 | return FALSE; |
449 | } | 449 | } |
450 | } | 450 | } |
451 | return TRUE; | 451 | return TRUE; |
452 | } | 452 | } |
453 | } | 453 | } |
454 | 454 | ||
455 | 455 | ||
456 | bool PlayListWidget::first() { | 456 | bool PlayListWidget::first() { |
457 | return d->selectedFiles->first(); | 457 | return d->selectedFiles->first(); |
458 | } | 458 | } |
459 | 459 | ||
460 | 460 | ||
461 | bool PlayListWidget::last() { | 461 | bool PlayListWidget::last() { |
462 | return d->selectedFiles->last(); | 462 | return d->selectedFiles->last(); |
463 | } | 463 | } |
464 | 464 | ||
465 | 465 | ||
466 | void PlayListWidget::saveList() { | 466 | void PlayListWidget::saveList() { |
467 | writem3u(); | 467 | writem3u(); |
468 | } | 468 | } |
469 | 469 | ||
470 | 470 | ||
471 | void PlayListWidget::loadList( const DocLnk & lnk) { | 471 | void PlayListWidget::loadList( const DocLnk & lnk) { |
472 | QString name = lnk.name(); | 472 | QString name = lnk.name(); |
473 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); | 473 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); |
474 | 474 | ||
475 | if( name.length()>0) { | 475 | if( name.length()>0) { |
476 | setCaption("OpiePlayer: "+name); | 476 | setCaption("OpiePlayer: "+name); |
477 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); | 477 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); |
478 | clearList(); | 478 | clearList(); |
479 | readm3u(lnk.file()); | 479 | readm3u(lnk.file()); |
480 | tabWidget->setCurrentPage(0); | 480 | tabWidget->setCurrentPage(0); |
481 | } | 481 | } |
482 | } | 482 | } |
483 | 483 | ||
484 | void PlayListWidget::addSelected() { | 484 | void PlayListWidget::addSelected() { |
485 | assert( inFileListMode() ); | 485 | assert( inFileListMode() ); |
486 | 486 | ||
487 | QListViewItemIterator it( currentFileListView ); | 487 | QListViewItemIterator it( currentFileListView ); |
488 | for ( ; it.current(); ++it ) | 488 | for ( ; it.current(); ++it ) |
489 | if ( it.current()->isSelected() ) { | 489 | if ( it.current()->isSelected() ) { |
490 | QString filename = it.current()->text(3); | 490 | QString filename = it.current()->text(3); |
491 | 491 | ||
492 | DocLnk lnk; | 492 | DocLnk lnk; |
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 | 495 | ||
496 | d->selectedFiles->addToSelection( lnk ); | 496 | d->selectedFiles->addToSelection( lnk ); |
497 | } | 497 | } |
498 | 498 | ||
499 | currentFileListView->clearSelection(); | 499 | currentFileListView->clearSelection(); |
500 | 500 | ||
501 | // tabWidget->setCurrentPage( 0 ); | 501 | // tabWidget->setCurrentPage( 0 ); |
502 | writeCurrentM3u(); | 502 | writeCurrentM3u(); |
503 | } | 503 | } |
504 | 504 | ||
505 | 505 | ||
506 | void PlayListWidget::removeSelected() { | 506 | void PlayListWidget::removeSelected() { |
507 | d->selectedFiles->removeSelected( ); | 507 | d->selectedFiles->removeSelected( ); |
508 | writeCurrentM3u(); | 508 | writeCurrentM3u(); |
509 | } | 509 | } |
510 | 510 | ||
511 | 511 | ||
512 | void PlayListWidget::playIt( QListViewItem *it) { | 512 | void PlayListWidget::playIt( QListViewItem *it) { |
513 | if(!it) return; | 513 | if(!it) return; |
514 | mediaPlayerState.setPlaying(FALSE); | 514 | mediaPlayerState.setPlaying(FALSE); |
515 | mediaPlayerState.setPlaying(TRUE); | 515 | mediaPlayerState.setPlaying(TRUE); |
516 | d->selectedFiles->unSelect(); | 516 | d->selectedFiles->unSelect(); |
517 | } | 517 | } |
518 | 518 | ||
519 | 519 | ||
520 | void PlayListWidget::addToSelection( QListViewItem *it) { | 520 | void PlayListWidget::addToSelection( QListViewItem *it) { |
521 | d->setDocumentUsed = FALSE; | 521 | d->setDocumentUsed = FALSE; |
522 | 522 | ||
523 | if(it) { | 523 | if(it) { |
524 | if ( currentTab() == CurrentPlayList ) | 524 | if ( currentTab() == CurrentPlayList ) |
525 | return; | 525 | return; |
526 | // case 1: { | 526 | // case 1: { |
527 | DocLnk lnk; | 527 | DocLnk lnk; |
528 | QString filename; | 528 | QString filename; |
529 | 529 | ||
530 | filename=it->text(3); | 530 | filename=it->text(3); |
531 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 531 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
532 | lnk.setFile( filename ); //sets file name | 532 | lnk.setFile( filename ); //sets file name |
533 | d->selectedFiles->addToSelection( lnk); | 533 | d->selectedFiles->addToSelection( lnk); |
534 | 534 | ||
535 | writeCurrentM3u(); | 535 | writeCurrentM3u(); |
536 | // tabWidget->setCurrentPage(0); | 536 | // tabWidget->setCurrentPage(0); |
537 | 537 | ||
538 | } | 538 | } |
539 | } | 539 | } |
540 | 540 | ||
541 | 541 | ||
542 | void PlayListWidget::tabChanged(QWidget *) { | 542 | void PlayListWidget::tabChanged(QWidget *) { |
543 | 543 | ||
544 | d->tbPlay->setEnabled( true ); | 544 | d->tbPlay->setEnabled( true ); |
545 | 545 | ||
546 | disconnect( audioView, SIGNAL( itemsSelected( bool ) ), | 546 | disconnect( audioView, SIGNAL( itemsSelected( bool ) ), |
547 | d->tbPlay, SLOT( setEnabled( bool ) ) ); | 547 | d->tbPlay, SLOT( setEnabled( bool ) ) ); |
548 | disconnect( videoView, SIGNAL( itemsSelected( bool ) ), | 548 | disconnect( videoView, SIGNAL( itemsSelected( bool ) ), |
549 | d->tbPlay, SLOT( setEnabled( bool ) ) ); | 549 | d->tbPlay, SLOT( setEnabled( bool ) ) ); |
550 | 550 | ||
551 | currentFileListView = 0; | 551 | currentFileListView = 0; |
552 | 552 | ||
553 | switch ( currentTab() ) { | 553 | switch ( currentTab() ) { |
554 | case CurrentPlayList: | 554 | case CurrentPlayList: |
555 | { | 555 | { |
556 | if( !tbDeletePlaylist->isHidden() ) { | 556 | if( !tbDeletePlaylist->isHidden() ) { |
557 | tbDeletePlaylist->hide(); | 557 | tbDeletePlaylist->hide(); |
558 | } | 558 | } |
559 | d->tbRemoveFromList->setEnabled(TRUE); | 559 | d->tbRemoveFromList->setEnabled(TRUE); |
560 | d->tbAddToList->setEnabled(FALSE); | 560 | d->tbAddToList->setEnabled(FALSE); |
561 | 561 | ||
562 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); | 562 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); |
563 | } | 563 | } |
564 | break; | 564 | break; |
565 | case AudioFiles: | 565 | case AudioFiles: |
566 | { | 566 | { |
567 | audioView->populateView(); | 567 | audioView->populateView(); |
568 | 568 | ||
569 | if( !tbDeletePlaylist->isHidden() ) { | 569 | if( !tbDeletePlaylist->isHidden() ) { |
570 | tbDeletePlaylist->hide(); | 570 | tbDeletePlaylist->hide(); |
571 | } | 571 | } |
572 | d->tbRemoveFromList->setEnabled(FALSE); | 572 | d->tbRemoveFromList->setEnabled(FALSE); |
573 | d->tbAddToList->setEnabled(TRUE); | 573 | d->tbAddToList->setEnabled(TRUE); |
574 | 574 | ||
575 | connect( audioView, SIGNAL( itemsSelected( bool ) ), | 575 | connect( audioView, SIGNAL( itemsSelected( bool ) ), |
576 | d->tbPlay, SLOT( setEnabled( bool ) ) ); | 576 | d->tbPlay, SLOT( setEnabled( bool ) ) ); |
577 | 577 | ||
578 | d->tbPlay->setEnabled( audioView->hasSelection() ); | 578 | d->tbPlay->setEnabled( audioView->hasSelection() ); |
579 | 579 | ||
580 | currentFileListView = audioView; | 580 | currentFileListView = audioView; |
581 | } | 581 | } |
582 | break; | 582 | break; |
583 | case VideoFiles: | 583 | case VideoFiles: |
584 | { | 584 | { |
585 | videoView->populateView(); | 585 | videoView->populateView(); |
586 | if( !tbDeletePlaylist->isHidden() ) { | 586 | if( !tbDeletePlaylist->isHidden() ) { |
587 | tbDeletePlaylist->hide(); | 587 | tbDeletePlaylist->hide(); |
588 | } | 588 | } |
589 | d->tbRemoveFromList->setEnabled(FALSE); | 589 | d->tbRemoveFromList->setEnabled(FALSE); |
590 | d->tbAddToList->setEnabled(TRUE); | 590 | d->tbAddToList->setEnabled(TRUE); |
591 | 591 | ||
592 | connect( videoView, SIGNAL( itemsSelected( bool ) ), | 592 | connect( videoView, SIGNAL( itemsSelected( bool ) ), |
593 | d->tbPlay, SLOT( setEnabled( bool ) ) ); | 593 | d->tbPlay, SLOT( setEnabled( bool ) ) ); |
594 | 594 | ||
595 | d->tbPlay->setEnabled( videoView->hasSelection() ); | 595 | d->tbPlay->setEnabled( videoView->hasSelection() ); |
596 | 596 | ||
597 | currentFileListView = videoView; | 597 | currentFileListView = videoView; |
598 | } | 598 | } |
599 | break; | 599 | break; |
600 | case PlayLists: | 600 | case PlayLists: |
601 | { | 601 | { |
602 | if( tbDeletePlaylist->isHidden() ) { | 602 | if( tbDeletePlaylist->isHidden() ) { |
603 | tbDeletePlaylist->show(); | 603 | tbDeletePlaylist->show(); |
604 | } | 604 | } |
605 | playLists->reread(); | 605 | playLists->reread(); |
606 | d->tbAddToList->setEnabled(FALSE); | 606 | d->tbAddToList->setEnabled(FALSE); |
607 | 607 | ||
608 | d->tbPlay->setEnabled( false ); | 608 | d->tbPlay->setEnabled( false ); |
609 | } | 609 | } |
610 | break; | 610 | break; |
611 | }; | 611 | }; |
612 | } | 612 | } |
613 | 613 | ||
614 | 614 | ||
615 | void PlayListWidget::btnPlay(bool b) { | 615 | void PlayListWidget::btnPlay(bool b) { |
616 | // mediaPlayerState->setPlaying(false); | 616 | // mediaPlayerState->setPlaying(false); |
617 | mediaPlayerState.setPlaying(b); | 617 | mediaPlayerState.setPlaying(b); |
618 | insanityBool=FALSE; | 618 | insanityBool=FALSE; |
619 | } | 619 | } |
620 | 620 | ||
621 | void PlayListWidget::deletePlaylist() { | 621 | void PlayListWidget::deletePlaylist() { |
622 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 622 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
623 | (tr("You really want to delete\nthis playlist?")), | 623 | (tr("You really want to delete\nthis playlist?")), |
624 | (tr("Yes")), (tr("No")), 0 )){ | 624 | (tr("Yes")), (tr("No")), 0 )){ |
625 | case 0: // Yes clicked, | 625 | case 0: // Yes clicked, |
626 | QFile().remove(playLists->selectedDocument().file()); | 626 | QFile().remove(playLists->selectedDocument().file()); |
627 | QFile().remove(playLists->selectedDocument().linkFile()); | 627 | QFile().remove(playLists->selectedDocument().linkFile()); |
628 | playLists->reread(); | 628 | playLists->reread(); |
629 | break; | 629 | break; |
630 | case 1: // Cancel | 630 | case 1: // Cancel |
631 | break; | 631 | break; |
632 | }; | 632 | }; |
633 | } | 633 | } |
634 | 634 | ||
635 | 635 | ||
636 | void PlayListWidget::playSelected() { | 636 | void PlayListWidget::playSelected() { |
637 | btnPlay( TRUE); | 637 | btnPlay( TRUE); |
638 | } | 638 | } |
639 | 639 | ||
640 | bool PlayListWidget::inFileListMode() const | 640 | bool PlayListWidget::inFileListMode() const |
641 | { | 641 | { |
642 | TabType tab = currentTab(); | 642 | TabType tab = currentTab(); |
643 | return tab == AudioFiles || tab == VideoFiles; | 643 | return tab == AudioFiles || tab == VideoFiles; |
644 | } | 644 | } |
645 | 645 | ||
646 | void PlayListWidget::openFile() { | 646 | void PlayListWidget::openFile() { |
647 | // http://66.28.164.33:2080 | 647 | // http://66.28.164.33:2080 |
648 | // http://somafm.com/star0242.m3u | 648 | // http://somafm.com/star0242.m3u |
649 | QString filename, name; | 649 | QString filename, name; |
650 | InputDialog *fileDlg; | 650 | InputDialog *fileDlg; |
651 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 651 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
652 | fileDlg->exec(); | 652 | fileDlg->exec(); |
653 | if( fileDlg->result() == 1 ) { | 653 | if( fileDlg->result() == 1 ) { |
654 | filename = fileDlg->text(); | 654 | filename = fileDlg->text(); |
655 | qDebug( "Selected filename is " + filename ); | 655 | qDebug( "Selected filename is " + filename ); |
656 | // Om3u *m3uList; | 656 | // Om3u *m3uList; |
657 | DocLnk lnk; | 657 | DocLnk lnk; |
658 | Config cfg( "OpiePlayer" ); | 658 | Config cfg( "OpiePlayer" ); |
659 | cfg.setGroup("PlayList"); | 659 | cfg.setGroup("PlayList"); |
660 | 660 | ||
661 | if(filename.left(4) == "http") { | 661 | if(filename.left(4) == "http") { |
662 | QString m3uFile, m3uFilePath; | 662 | QString m3uFile, m3uFilePath; |
663 | if(filename.find(":",8,TRUE) != -1) { //found a port | 663 | if(filename.find(":",8,TRUE) != -1) { //found a port |
664 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 664 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
665 | m3uFile = m3uFile.right( 7); | 665 | m3uFile = m3uFile.right( 7); |
666 | } else if(filename.left(4) == "http"){ | 666 | } else if(filename.left(4) == "http"){ |
667 | m3uFile=filename; | 667 | m3uFile=filename; |
668 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 668 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
669 | } else{ | 669 | } else{ |
670 | m3uFile=filename; | 670 | m3uFile=filename; |
671 | } | 671 | } |
672 | 672 | ||
673 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); | 673 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); |
674 | lnk.setName( filename ); //sets name | 674 | lnk.setName( filename ); //sets name |
675 | lnk.setFile( filename ); //sets file name | 675 | lnk.setFile( filename ); //sets file name |
676 | 676 | ||
677 | // lnk.setIcon("opieplayer2/musicfile"); | 677 | // lnk.setIcon("opieplayer2/musicfile"); |
678 | 678 | ||
679 | d->selectedFiles->addToSelection( lnk ); | 679 | d->selectedFiles->addToSelection( lnk ); |
680 | writeCurrentM3u(); | 680 | writeCurrentM3u(); |
681 | d->selectedFiles->setSelectedItem( lnk.name()); | 681 | d->selectedFiles->setSelectedItem( lnk.name()); |
682 | } | 682 | } |
683 | else if( filename.right( 3) == "m3u" ) { | 683 | else if( filename.right( 3) == "m3u" ) { |
684 | readm3u( filename ); | 684 | readm3u( filename ); |
685 | 685 | ||
686 | } else if( filename.right(3) == "pls" ) { | 686 | } else if( filename.right(3) == "pls" ) { |
687 | readPls( filename ); | 687 | readPls( filename ); |
688 | } else { | 688 | } else { |
689 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 689 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
690 | lnk.setFile( filename ); //sets file name | 690 | lnk.setFile( filename ); //sets file name |
691 | d->selectedFiles->addToSelection( lnk); | 691 | d->selectedFiles->addToSelection( lnk); |
692 | writeCurrentM3u(); | 692 | writeCurrentM3u(); |
693 | d->selectedFiles->setSelectedItem( lnk.name()); | 693 | d->selectedFiles->setSelectedItem( lnk.name()); |
694 | } | 694 | } |
695 | } | 695 | } |
696 | 696 | ||
697 | delete fileDlg; | 697 | delete fileDlg; |
698 | } | 698 | } |
699 | 699 | ||
700 | /* | 700 | /* |
701 | reads m3u and shows files/urls to playlist widget */ | 701 | reads m3u and shows files/urls to playlist widget */ |
702 | void PlayListWidget::readm3u( const QString &filename ) { | 702 | void PlayListWidget::readm3u( const QString &filename ) { |
703 | qDebug( "read m3u filename " + filename ); | 703 | qDebug( "read m3u filename " + filename ); |
704 | 704 | ||
705 | Om3u *m3uList; | 705 | Om3u *m3uList; |
706 | QString s, name; | 706 | QString s, name; |
707 | m3uList = new Om3u( filename, IO_ReadOnly ); | 707 | m3uList = new Om3u( filename, IO_ReadOnly ); |
708 | m3uList->readM3u(); | 708 | m3uList->readM3u(); |
709 | DocLnk lnk; | 709 | DocLnk lnk; |
710 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 710 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
711 | s = *it; | 711 | s = *it; |
712 | // qDebug("reading "+ s); | 712 | // qDebug("reading "+ s); |
713 | if(s.left(4)=="http") { | 713 | if(s.left(4)=="http") { |
714 | lnk.setName( s ); //sets file name | 714 | lnk.setName( s ); //sets file name |
715 | lnk.setIcon("opieplayer2/musicfile"); | 715 | lnk.setIcon("opieplayer2/musicfile"); |
716 | lnk.setFile( s ); //sets file name | 716 | lnk.setFile( s ); //sets file name |
717 | 717 | ||
718 | } else { | 718 | } else { |
719 | // if( QFileInfo( s ).exists() ) { | 719 | // if( QFileInfo( s ).exists() ) { |
720 | lnk.setName( QFileInfo(s).baseName()); | 720 | lnk.setName( QFileInfo(s).baseName()); |
721 | // if(s.right(4) == '.') {//if regular file | 721 | // if(s.right(4) == '.') {//if regular file |
722 | if(s.left(1) != "/") { | 722 | if(s.left(1) != "/") { |
723 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | 723 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); |
724 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 724 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
725 | // lnk.setIcon(MimeType(s).pixmap() ); | 725 | // lnk.setIcon(MimeType(s).pixmap() ); |
726 | // lnk.setIcon("SoundPlayer"); | 726 | // lnk.setIcon("SoundPlayer"); |
727 | } else { | 727 | } else { |
728 | // qDebug("set link2 "+s); | 728 | // qDebug("set link2 "+s); |
729 | lnk.setFile( s); | 729 | lnk.setFile( s); |
730 | // lnk.setIcon(MimeType(s).pixmap() ); | 730 | // lnk.setIcon(MimeType(s).pixmap() ); |
731 | // lnk.setIcon("SoundPlayer"); | 731 | // lnk.setIcon("SoundPlayer"); |
732 | } | 732 | } |
733 | } | 733 | } |
734 | d->selectedFiles->addToSelection( lnk ); | 734 | d->selectedFiles->addToSelection( lnk ); |
735 | } | 735 | } |
736 | Config config( "OpiePlayer" ); | 736 | Config config( "OpiePlayer" ); |
737 | config.setGroup( "PlayList" ); | 737 | config.setGroup( "PlayList" ); |
738 | 738 | ||
739 | config.writeEntry("CurrentPlaylist",filename); | 739 | config.writeEntry("CurrentPlaylist",filename); |
740 | config.write(); | 740 | config.write(); |
741 | currentPlayList=filename; | 741 | currentPlayList=filename; |
742 | 742 | ||
743 | // m3uList->write(); | 743 | // m3uList->write(); |
744 | m3uList->close(); | 744 | m3uList->close(); |
745 | delete m3uList; | 745 | delete m3uList; |
746 | 746 | ||
747 | d->selectedFiles->setSelectedItem( s); | 747 | d->selectedFiles->setSelectedItem( s); |
748 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 748 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
749 | 749 | ||
750 | } | 750 | } |
751 | 751 | ||
752 | /* | 752 | /* |
753 | reads pls and adds files/urls to playlist */ | 753 | reads pls and adds files/urls to playlist */ |
754 | void PlayListWidget::readPls( const QString &filename ) { | 754 | void PlayListWidget::readPls( const QString &filename ) { |
755 | 755 | ||
756 | qDebug( "pls filename is " + filename ); | 756 | qDebug( "pls filename is " + filename ); |
757 | Om3u *m3uList; | 757 | Om3u *m3uList; |
758 | QString s, name; | 758 | QString s, name; |
759 | m3uList = new Om3u( filename, IO_ReadOnly ); | 759 | m3uList = new Om3u( filename, IO_ReadOnly ); |
760 | m3uList->readPls(); | 760 | m3uList->readPls(); |
761 | 761 | ||
762 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 762 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
763 | s = *it; | 763 | s = *it; |
764 | // s.replace( QRegExp( "%20" )," " ); | 764 | // s.replace( QRegExp( "%20" )," " ); |
765 | DocLnk lnk( s ); | 765 | DocLnk lnk( s ); |
766 | QFileInfo f( s ); | 766 | QFileInfo f( s ); |
767 | QString name = f.baseName(); | 767 | QString name = f.baseName(); |
768 | 768 | ||
769 | if( name.left( 4 ) == "http" ) { | 769 | if( name.left( 4 ) == "http" ) { |
770 | name = s.right( s.length() - 7); | 770 | name = s.right( s.length() - 7); |
771 | } else { | 771 | } else { |
772 | name = s; | 772 | name = s; |
773 | } | 773 | } |
774 | 774 | ||
775 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 775 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
776 | 776 | ||
777 | lnk.setName( name ); | 777 | lnk.setName( name ); |
778 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | 778 | if( s.at( s.length() - 4) == '.') {// if this is probably a file |
779 | lnk.setFile( s ); | 779 | lnk.setFile( s ); |
780 | } else { //if its a url | 780 | } else { //if its a url |
781 | // if( name.right( 1 ).find( '/' ) == -1) { | 781 | // if( name.right( 1 ).find( '/' ) == -1) { |
782 | // s += "/"; | 782 | // s += "/"; |
783 | // } | 783 | // } |
784 | lnk.setFile( s ); | 784 | lnk.setFile( s ); |
785 | } | 785 | } |
786 | lnk.setType( "audio/x-mpegurl" ); | 786 | lnk.setType( "audio/x-mpegurl" ); |
787 | 787 | ||
788 | lnk.writeLink(); | 788 | lnk.writeLink(); |
789 | d->selectedFiles->addToSelection( lnk ); | 789 | d->selectedFiles->addToSelection( lnk ); |
790 | } | 790 | } |
791 | 791 | ||
792 | m3uList->close(); | 792 | m3uList->close(); |
793 | delete m3uList; | 793 | delete m3uList; |
794 | } | 794 | } |
795 | 795 | ||
796 | /* | 796 | /* |
797 | writes current playlist to current m3u file */ | 797 | writes current playlist to current m3u file */ |
798 | void PlayListWidget::writeCurrentM3u() { | 798 | void PlayListWidget::writeCurrentM3u() { |
799 | qDebug("writing to current m3u"); | 799 | qDebug("writing to current m3u"); |
800 | Config cfg( "OpiePlayer" ); | 800 | Config cfg( "OpiePlayer" ); |
801 | cfg.setGroup("PlayList"); | 801 | cfg.setGroup("PlayList"); |
802 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 802 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
803 | 803 | ||
804 | Om3u *m3uList; | 804 | Om3u *m3uList; |
805 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 805 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
806 | if( d->selectedFiles->first()) { | 806 | if( d->selectedFiles->first()) { |
807 | 807 | ||
808 | do { | 808 | do { |
809 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); | 809 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); |
810 | m3uList->add( d->selectedFiles->current()->file() ); | 810 | m3uList->add( d->selectedFiles->current()->file() ); |
811 | } | 811 | } |
812 | while ( d->selectedFiles->next() ); | 812 | while ( d->selectedFiles->next() ); |
813 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 813 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
814 | m3uList->write(); | 814 | m3uList->write(); |
815 | m3uList->close(); | 815 | m3uList->close(); |
816 | } | 816 | } |
817 | delete m3uList; | 817 | delete m3uList; |
818 | 818 | ||
819 | } | 819 | } |
820 | 820 | ||
821 | /* | 821 | /* |
822 | writes current playlist to m3u file */ | 822 | writes current playlist to m3u file */ |
823 | void PlayListWidget::writem3u() { | 823 | void PlayListWidget::writem3u() { |
824 | InputDialog *fileDlg; | 824 | InputDialog *fileDlg; |
825 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 825 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
826 | fileDlg->exec(); | 826 | fileDlg->exec(); |
827 | QString name, filename, list; | 827 | QString name, filename, list; |
828 | Om3u *m3uList; | 828 | Om3u *m3uList; |
829 | 829 | ||
830 | if( fileDlg->result() == 1 ) { | 830 | if( fileDlg->result() == 1 ) { |
831 | name = fileDlg->text(); | 831 | name = fileDlg->text(); |
832 | // qDebug( filename ); | 832 | // qDebug( filename ); |
833 | 833 | ||
834 | if( name.left( 1) != "/" ) { | 834 | if( name.left( 1) != "/" ) { |
835 | filename = QPEApplication::documentDir() + "/" + name; | 835 | filename = QPEApplication::documentDir() + "/" + name; |
836 | } | 836 | } |
837 | 837 | ||
838 | if( name.right( 3 ) != "m3u" ) { | 838 | if( name.right( 3 ) != "m3u" ) { |
839 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; | 839 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; |
840 | } | 840 | } |
841 | 841 | ||
842 | if( d->selectedFiles->first()) { | 842 | if( d->selectedFiles->first()) { |
843 | m3uList = new Om3u(filename, IO_ReadWrite); | 843 | m3uList = new Om3u(filename, IO_ReadWrite); |
844 | 844 | ||
845 | do { | 845 | do { |
846 | m3uList->add( d->selectedFiles->current()->file()); | 846 | m3uList->add( d->selectedFiles->current()->file()); |
847 | } | 847 | } |
848 | while ( d->selectedFiles->next() ); | 848 | while ( d->selectedFiles->next() ); |
849 | // qDebug( list ); | 849 | // qDebug( list ); |
850 | m3uList->write(); | 850 | m3uList->write(); |
851 | m3uList->close(); | 851 | m3uList->close(); |
852 | delete m3uList; | 852 | delete m3uList; |
853 | 853 | ||
854 | delete fileDlg; | 854 | delete fileDlg; |
855 | 855 | ||
856 | DocLnk lnk; | 856 | DocLnk lnk; |
857 | lnk.setFile( filename); | 857 | lnk.setFile( filename); |
858 | lnk.setIcon("opieplayer2/playlist2"); | 858 | lnk.setIcon("opieplayer2/playlist2"); |
859 | lnk.setName( name); //sets file name | 859 | lnk.setName( name); //sets file name |
860 | 860 | ||
861 | // qDebug(filename); | 861 | // qDebug(filename); |
862 | Config config( "OpiePlayer" ); | 862 | Config config( "OpiePlayer" ); |
863 | config.setGroup( "PlayList" ); | 863 | config.setGroup( "PlayList" ); |
864 | 864 | ||
865 | config.writeEntry("CurrentPlaylist",filename); | 865 | config.writeEntry("CurrentPlaylist",filename); |
866 | currentPlayList=filename; | 866 | currentPlayList=filename; |
867 | 867 | ||
868 | if(!lnk.writeLink()) { | 868 | if(!lnk.writeLink()) { |
869 | qDebug("Writing doclink did not work"); | 869 | qDebug("Writing doclink did not work"); |
870 | } | 870 | } |
871 | 871 | ||
872 | setCaption(tr("OpiePlayer: ") + name); | 872 | setCaption(tr("OpiePlayer: ") + name); |
873 | } | 873 | } |
874 | } | 874 | } |
875 | } | 875 | } |
876 | 876 | ||
877 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 877 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
878 | switch ( e->key() ) { | 878 | switch ( e->key() ) { |
879 | ////////////////////////////// Zaurus keys | 879 | ////////////////////////////// Zaurus keys |
880 | case Key_F9: //activity | 880 | case Key_F9: //activity |
881 | // if(audioUI->isHidden()) | 881 | // if(audioUI->isHidden()) |
882 | // audioUI->showMaximized(); | 882 | // audioUI->showMaximized(); |
883 | break; | 883 | break; |
884 | case Key_F10: //contacts | 884 | case Key_F10: //contacts |
885 | // if( videoUI->isHidden()) | 885 | // if( videoUI->isHidden()) |
886 | // videoUI->showMaximized(); | 886 | // videoUI->showMaximized(); |
887 | break; | 887 | break; |
888 | case Key_F11: //menu | 888 | case Key_F11: //menu |
889 | break; | 889 | break; |
890 | case Key_F12: //home | 890 | case Key_F12: //home |
891 | // doBlank(); | 891 | // doBlank(); |
892 | break; | 892 | break; |
893 | case Key_F13: //mail | 893 | case Key_F13: //mail |
894 | // doUnblank(); | 894 | // doUnblank(); |
895 | break; | 895 | break; |
896 | case Key_Q: //add to playlist | 896 | case Key_Q: //add to playlist |
897 | addSelected(); | 897 | addSelected(); |
898 | break; | 898 | break; |
899 | case Key_R: //remove from playlist | 899 | case Key_R: //remove from playlist |
900 | removeSelected(); | 900 | removeSelected(); |
901 | break; | 901 | break; |
902 | // case Key_P: //play | 902 | // case Key_P: //play |
903 | // qDebug("Play"); | 903 | // qDebug("Play"); |
904 | // playSelected(); | 904 | // playSelected(); |
905 | // break; | 905 | // break; |
906 | case Key_Space: | 906 | case Key_Space: |
907 | // playSelected(); puh | 907 | // playSelected(); puh |
908 | break; | 908 | break; |
909 | case Key_1: | 909 | case Key_1: |
910 | tabWidget->setCurrentPage( 0 ); | 910 | tabWidget->setCurrentPage( 0 ); |
911 | break; | 911 | break; |
912 | case Key_2: | 912 | case Key_2: |
913 | tabWidget->setCurrentPage( 1 ); | 913 | tabWidget->setCurrentPage( 1 ); |
914 | break; | 914 | break; |
915 | case Key_3: | 915 | case Key_3: |
916 | tabWidget->setCurrentPage( 2 ); | 916 | tabWidget->setCurrentPage( 2 ); |
917 | break; | 917 | break; |
918 | case Key_4: | 918 | case Key_4: |
919 | tabWidget->setCurrentPage( 3 ); | 919 | tabWidget->setCurrentPage( 3 ); |
920 | break; | 920 | break; |
921 | case Key_Down: | 921 | case Key_Down: |
922 | if ( !d->selectedFiles->next() ) | 922 | if ( !d->selectedFiles->next() ) |
923 | d->selectedFiles->first(); | 923 | d->selectedFiles->first(); |
924 | break; | 924 | break; |
925 | case Key_Up: | 925 | case Key_Up: |
926 | if ( !d->selectedFiles->prev() ) | 926 | if ( !d->selectedFiles->prev() ) |
927 | // d->selectedFiles->last(); | 927 | // d->selectedFiles->last(); |
928 | break; | 928 | break; |
929 | } | 929 | } |
930 | } | 930 | } |
931 | 931 | ||
932 | void PlayListWidget::pmViewActivated(int index) { | 932 | void PlayListWidget::pmViewActivated(int index) { |
933 | // qDebug("%d", index); | 933 | // qDebug("%d", index); |
934 | switch(index) { | 934 | switch(index) { |
935 | case -16: | 935 | case -16: |
936 | { | 936 | { |
937 | mediaPlayerState.toggleFullscreen(); | 937 | mediaPlayerState.toggleFullscreen(); |
938 | bool b=mediaPlayerState.isFullscreen(); | 938 | bool b=mediaPlayerState.isFullscreen(); |
939 | pmView->setItemChecked( index, b); | 939 | pmView->setItemChecked( index, b); |
940 | Config cfg( "OpiePlayer" ); | 940 | Config cfg( "OpiePlayer" ); |
941 | cfg.writeEntry( "FullScreen", b ); | 941 | cfg.writeEntry( "FullScreen", b ); |
942 | } | 942 | } |
943 | break; | 943 | break; |
944 | }; | 944 | }; |
945 | } | 945 | } |
946 | 946 | ||
947 | void PlayListWidget::populateSkinsMenu() { | 947 | void PlayListWidget::populateSkinsMenu() { |
948 | int item = 0; | 948 | int item = 0; |
949 | defaultSkinIndex = 0; | 949 | defaultSkinIndex = 0; |
950 | QString skinName; | 950 | QString skinName; |
951 | Config cfg( "OpiePlayer" ); | 951 | Config cfg( "OpiePlayer" ); |
952 | cfg.setGroup("Options" ); | 952 | cfg.setGroup("Options" ); |
953 | QString skin = cfg.readEntry( "Skin", "default" ); | 953 | QString skin = cfg.readEntry( "Skin", "default" ); |
954 | 954 | ||
955 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 955 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
956 | skinsDir.setFilter( QDir::Dirs ); | 956 | skinsDir.setFilter( QDir::Dirs ); |
957 | skinsDir.setSorting(QDir::Name ); | 957 | skinsDir.setSorting(QDir::Name ); |
958 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 958 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
959 | QFileInfoListIterator it( *skinslist ); | 959 | QFileInfoListIterator it( *skinslist ); |
960 | QFileInfo *fi; | 960 | QFileInfo *fi; |