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