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