summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayerstate.h1
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp14
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.h1
3 files changed, 1 insertions, 15 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.h b/noncore/multimedia/opieplayer2/mediaplayerstate.h
index d15894f..7a80ad8 100644
--- a/noncore/multimedia/opieplayer2/mediaplayerstate.h
+++ b/noncore/multimedia/opieplayer2/mediaplayerstate.h
@@ -9,133 +9,132 @@
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// this file is based on work by trolltech 34// this file is based on work by trolltech
35 35
36#ifndef MEDIA_PLAYER_STATE_H 36#ifndef MEDIA_PLAYER_STATE_H
37#define MEDIA_PLAYER_STATE_H 37#define MEDIA_PLAYER_STATE_H
38 38
39 39
40#include <qobject.h> 40#include <qobject.h>
41 41
42 42
43class MediaPlayerDecoder; 43class MediaPlayerDecoder;
44class Config; 44class Config;
45 45
46 46
47class MediaPlayerState : public QObject { 47class MediaPlayerState : public QObject {
48Q_OBJECT 48Q_OBJECT
49public: 49public:
50 MediaPlayerState( QObject *parent, const char *name ); 50 MediaPlayerState( QObject *parent, const char *name );
51 ~MediaPlayerState(); 51 ~MediaPlayerState();
52 52
53 bool isStreaming() const { return streaming; } 53 bool isStreaming() const { return streaming; }
54 bool isSeekable() const { return seekable; } 54 bool isSeekable() const { return seekable; }
55 bool isFullscreen() const { return fullscreen; } 55 bool isFullscreen() const { return fullscreen; }
56 bool isScaled() const { return scaled; } 56 bool isScaled() const { return scaled; }
57 bool isLooping() const { return looping; } 57 bool isLooping() const { return looping; }
58 bool isShuffled() const { return shuffled; } 58 bool isShuffled() const { return shuffled; }
59 bool isUsingPlaylist() const { return usePlaylist; } 59 bool isUsingPlaylist() const { return usePlaylist; }
60 bool isPaused() const { return paused; } 60 bool isPaused() const { return paused; }
61 bool isPlaying() const { return playing; } 61 bool isPlaying() const { return playing; }
62 bool isStopped() const { return stopped; } 62 bool isStopped() const { return stopped; }
63 long position() const { return curPosition; } 63 long position() const { return curPosition; }
64 long length() const { return curLength; } 64 long length() const { return curLength; }
65 char view() const { return curView; } 65 char view() const { return curView; }
66 66
67public slots: 67public slots:
68 void setIsStreaming( bool b ); 68 void setIsStreaming( bool b );
69 void setIsSeekable( bool b ); 69 void setIsSeekable( bool b );
70 void setFullscreen( bool b ); 70 void setFullscreen( bool b );
71 void setScaled( bool b ); 71 void setScaled( bool b );
72 void setLooping( bool b ); 72 void setLooping( bool b );
73 void setShuffled( bool b ); 73 void setShuffled( bool b );
74 void setPaused( bool b ); 74 void setPaused( bool b );
75 void setPlaying( bool b ); 75 void setPlaying( bool b );
76 void setStopped( bool b ); 76 void setStopped( bool b );
77 void setPosition( long p ); 77 void setPosition( long p );
78 void updatePosition( long p ); 78 void updatePosition( long p );
79 void setLength( long l ); 79 void setLength( long l );
80 void setView( char v ); 80 void setView( char v );
81 void setBlanked( bool b ); 81 void setBlanked( bool b );
82 void setVideoGamma( int v ); 82 void setVideoGamma( int v );
83 83
84 void setPrev(); 84 void setPrev();
85 void setNext(); 85 void setNext();
86 void setList(); 86 void setList();
87 void setVideo(); 87 void setVideo();
88 void setAudio(); 88 void setAudio();
89 89
90 void toggleFullscreen(); 90 void toggleFullscreen();
91 void toggleScaled(); 91 void toggleScaled();
92 void toggleLooping(); 92 void toggleLooping();
93 void toggleShuffled(); 93 void toggleShuffled();
94 void togglePaused(); 94 void togglePaused();
95 void togglePlaying(); 95 void togglePlaying();
96 void toggleBlank(); 96 void toggleBlank();
97 void writeConfig( Config& cfg ) const; 97 void writeConfig( Config& cfg ) const;
98 98
99 99
100signals: 100signals:
101 void fullscreenToggled( bool ); 101 void fullscreenToggled( bool );
102 void scaledToggled( bool ); 102 void scaledToggled( bool );
103 void loopingToggled( bool ); 103 void loopingToggled( bool );
104 void shuffledToggled( bool ); 104 void shuffledToggled( bool );
105 void playlistToggled( bool );
106 void pausedToggled( bool ); 105 void pausedToggled( bool );
107 void playingToggled( bool ); 106 void playingToggled( bool );
108 void stopToggled( bool ); 107 void stopToggled( bool );
109 void positionChanged( long ); // When the slider is moved 108 void positionChanged( long ); // When the slider is moved
110 void positionUpdated( long ); // When the media file progresses 109 void positionUpdated( long ); // When the media file progresses
111 void lengthChanged( long ); 110 void lengthChanged( long );
112 void viewChanged( char ); 111 void viewChanged( char );
113 void isSeekableToggled( bool ); 112 void isSeekableToggled( bool );
114 void blankToggled( bool ); 113 void blankToggled( bool );
115 void videoGammaChanged( int ); 114 void videoGammaChanged( int );
116 void prev(); 115 void prev();
117 void next(); 116 void next();
118 117
119private: 118private:
120 bool streaming : 1; 119 bool streaming : 1;
121 bool seekable : 1; 120 bool seekable : 1;
122 bool fullscreen: 1; 121 bool fullscreen: 1;
123 bool scaled : 1; 122 bool scaled : 1;
124 bool blanked : 1; 123 bool blanked : 1;
125 bool looping : 1; 124 bool looping : 1;
126 bool shuffled : 1; 125 bool shuffled : 1;
127 bool usePlaylist : 1; 126 bool usePlaylist : 1;
128 bool paused : 1; 127 bool paused : 1;
129 bool playing : 1; 128 bool playing : 1;
130 bool stopped : 1; 129 bool stopped : 1;
131 long curPosition; 130 long curPosition;
132 long curLength; 131 long curLength;
133 char curView; 132 char curView;
134 int videoGamma; 133 int videoGamma;
135 void readConfig( Config& cfg ); 134 void readConfig( Config& cfg );
136 135
137}; 136};
138 137
139 138
140#endif // MEDIA_PLAYER_STATE_H 139#endif // MEDIA_PLAYER_STATE_H
141 140
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 6355bec..5b277cc 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -54,223 +54,221 @@
54#include <stdlib.h> 54#include <stdlib.h>
55#include <assert.h> 55#include <assert.h>
56 56
57#include "audiowidget.h" 57#include "audiowidget.h"
58#include "videowidget.h" 58#include "videowidget.h"
59 59
60extern MediaPlayerState *mediaPlayerState; 60extern MediaPlayerState *mediaPlayerState;
61// extern AudioWidget *audioUI; 61// extern AudioWidget *audioUI;
62// extern VideoWidget *videoUI; 62// extern VideoWidget *videoUI;
63 63
64QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg"; 64QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg";
65// no m3u's here please 65// no m3u's here please
66 66
67PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 67PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
68 : PlayListWidgetGui( parent, name, fl ) { 68 : PlayListWidgetGui( parent, name, fl ) {
69 69
70 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), 70 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ),
71 "opieplayer2/add_to_playlist", 71 "opieplayer2/add_to_playlist",
72 this , SLOT(addSelected() ) ); 72 this , SLOT(addSelected() ) );
73 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), 73 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ),
74 "opieplayer2/remove_from_playlist", 74 "opieplayer2/remove_from_playlist",
75 this , SLOT(removeSelected() ) ); 75 this , SLOT(removeSelected() ) );
76 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", 76 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play",
77 this , SLOT( btnPlay( bool) ), TRUE ); 77 this , SLOT( btnPlay( bool) ), TRUE );
78 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", 78 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle",
79 mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); 79 mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE );
80 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", 80 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop",
81 mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); 81 mediaPlayerState, SLOT( setLooping( bool ) ), TRUE );
82 82
83 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 83 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
84 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), 84 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ),
85 this, SLOT( addAllMusicToList() ) ); 85 this, SLOT( addAllMusicToList() ) );
86 (void)new MenuItem( pmPlayList, tr( "Add all video files" ), 86 (void)new MenuItem( pmPlayList, tr( "Add all video files" ),
87 this, SLOT( addAllVideoToList() ) ); 87 this, SLOT( addAllVideoToList() ) );
88 (void)new MenuItem( pmPlayList, tr( "Add all files" ), 88 (void)new MenuItem( pmPlayList, tr( "Add all files" ),
89 this, SLOT( addAllToList() ) ); 89 this, SLOT( addAllToList() ) );
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( saveList() ) ); 92// this, SLOT( saveList() ) );
93 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), 93 (void)new MenuItem( pmPlayList, tr( "Save Playlist" ),
94 this, SLOT(writem3u() ) ); 94 this, SLOT(writem3u() ) );
95 pmPlayList->insertSeparator(-1); 95 pmPlayList->insertSeparator(-1);
96 (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), 96 (void)new MenuItem( pmPlayList, tr( "Open File or URL" ),
97 this,SLOT( openFile() ) ); 97 this,SLOT( openFile() ) );
98 pmPlayList->insertSeparator(-1); 98 pmPlayList->insertSeparator(-1);
99 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), 99 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ),
100 this,SLOT( scanForAudio() ) ); 100 this,SLOT( scanForAudio() ) );
101 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), 101 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ),
102 this,SLOT( scanForVideo() ) ); 102 this,SLOT( scanForVideo() ) );
103 103
104 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), 104 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"),
105 mediaPlayerState, SLOT( toggleFullscreen() ) ); 105 mediaPlayerState, SLOT( toggleFullscreen() ) );
106 106
107 Config cfg( "OpiePlayer" ); 107 Config cfg( "OpiePlayer" );
108 bool b= cfg.readBoolEntry("FullScreen", 0); 108 bool b= cfg.readBoolEntry("FullScreen", 0);
109 mediaPlayerState->setFullscreen( b ); 109 mediaPlayerState->setFullscreen( b );
110 pmView->setItemChecked( -16, b ); 110 pmView->setItemChecked( -16, b );
111 111
112 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", 112 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up",
113 d->selectedFiles, SLOT(moveSelectedUp() ) ); 113 d->selectedFiles, SLOT(moveSelectedUp() ) );
114 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", 114 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut",
115 d->selectedFiles, SLOT(removeSelected() ) ); 115 d->selectedFiles, SLOT(removeSelected() ) );
116 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", 116 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down",
117 d->selectedFiles, SLOT(moveSelectedDown() ) ); 117 d->selectedFiles, SLOT(moveSelectedDown() ) );
118 // QVBox *stretch2 = new QVBox( vbox1 ); 118 // QVBox *stretch2 = new QVBox( vbox1 );
119 119
120 connect( tbDeletePlaylist, ( SIGNAL( released() ) ), 120 connect( tbDeletePlaylist, ( SIGNAL( released() ) ),
121 SLOT( deletePlaylist() ) ); 121 SLOT( deletePlaylist() ) );
122 connect( pmView, SIGNAL( activated( int ) ), 122 connect( pmView, SIGNAL( activated( int ) ),
123 this, SLOT( pmViewActivated( int ) ) ); 123 this, SLOT( pmViewActivated( int ) ) );
124 connect( skinsMenu, SIGNAL( activated( int ) ) , 124 connect( skinsMenu, SIGNAL( activated( int ) ) ,
125 this, SLOT( skinsMenuActivated( int ) ) ); 125 this, SLOT( skinsMenuActivated( int ) ) );
126 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), 126 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
127 this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); 127 this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) );
128 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), 128 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ),
129 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); 129 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) );
130 connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), 130 connect( audioView, SIGNAL( returnPressed( QListViewItem *) ),
131 this,SLOT( playIt( QListViewItem *) ) ); 131 this,SLOT( playIt( QListViewItem *) ) );
132 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), 132 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ),
133 this, SLOT( addToSelection( QListViewItem *) ) ); 133 this, SLOT( addToSelection( QListViewItem *) ) );
134 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), 134 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
135 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); 135 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) );
136 connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), 136 connect( videoView, SIGNAL( returnPressed( QListViewItem *) ),
137 this,SLOT( playIt( QListViewItem *) ) ); 137 this,SLOT( playIt( QListViewItem *) ) );
138 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), 138 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ),
139 this, SLOT( addToSelection( QListViewItem *) ) ); 139 this, SLOT( addToSelection( QListViewItem *) ) );
140 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), 140 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ),
141 this, SLOT( loadList( const DocLnk & ) ) ); 141 this, SLOT( loadList( const DocLnk & ) ) );
142 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), 142 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ),
143 this, SLOT( tabChanged( QWidget* ) ) ); 143 this, SLOT( tabChanged( QWidget* ) ) );
144 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), 144 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ),
145 d->tbPlay, SLOT( setOn( bool ) ) ); 145 d->tbPlay, SLOT( setOn( bool ) ) );
146 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), 146 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ),
147 d->tbLoop, SLOT( setOn( bool ) ) ); 147 d->tbLoop, SLOT( setOn( bool ) ) );
148 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), 148 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ),
149 d->tbShuffle, SLOT( setOn( bool ) ) ); 149 d->tbShuffle, SLOT( setOn( bool ) ) );
150 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ),
151 this, SLOT( setPlaylist( bool ) ) );
152 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), 150 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ),
153 this, SLOT( playIt( QListViewItem *) ) ); 151 this, SLOT( playIt( QListViewItem *) ) );
154 connect ( gammaSlider, SIGNAL( valueChanged( int ) ), 152 connect ( gammaSlider, SIGNAL( valueChanged( int ) ),
155 mediaPlayerState, SLOT( setVideoGamma( int ) ) ); 153 mediaPlayerState, SLOT( setVideoGamma( int ) ) );
156 154
157 // see which skins are installed 155 // see which skins are installed
158 videoScan=false; 156 videoScan=false;
159 audioScan=false; 157 audioScan=false;
160 audioPopulated=false; 158 audioPopulated=false;
161 videoPopulated=false; 159 videoPopulated=false;
162 populateSkinsMenu(); 160 populateSkinsMenu();
163 initializeStates(); 161 initializeStates();
164 162
165 cfg.setGroup("PlayList"); 163 cfg.setGroup("PlayList");
166 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); 164 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default");
167 loadList(DocLnk( currentPlaylist ) ); 165 loadList(DocLnk( currentPlaylist ) );
168} 166}
169 167
170 168
171PlayListWidget::~PlayListWidget() { 169PlayListWidget::~PlayListWidget() {
172 delete d; 170 delete d;
173} 171}
174 172
175 173
176void PlayListWidget::initializeStates() { 174void PlayListWidget::initializeStates() {
177 d->tbPlay->setOn( mediaPlayerState->isPlaying() ); 175 d->tbPlay->setOn( mediaPlayerState->isPlaying() );
178 d->tbLoop->setOn( mediaPlayerState->isLooping() ); 176 d->tbLoop->setOn( mediaPlayerState->isLooping() );
179 d->tbShuffle->setOn( mediaPlayerState->isShuffled() ); 177 d->tbShuffle->setOn( mediaPlayerState->isShuffled() );
180 setPlaylist( true ); 178 d->playListFrame->show();
181} 179}
182 180
183void PlayListWidget::writeDefaultPlaylist() { 181void PlayListWidget::writeDefaultPlaylist() {
184 182
185 Config config( "OpiePlayer" ); 183 Config config( "OpiePlayer" );
186 config.setGroup( "PlayList" ); 184 config.setGroup( "PlayList" );
187 QString filename=QPEApplication::documentDir() + "/default.m3u"; 185 QString filename=QPEApplication::documentDir() + "/default.m3u";
188 QString currentString = config.readEntry( "CurrentPlaylist", filename); 186 QString currentString = config.readEntry( "CurrentPlaylist", filename);
189 if( currentString == filename) { 187 if( currentString == filename) {
190 Om3u *m3uList; 188 Om3u *m3uList;
191 // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); 189 // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>");
192 if( d->selectedFiles->first() ) { 190 if( d->selectedFiles->first() ) {
193 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); 191 m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate);
194 do { 192 do {
195 // qDebug(d->selectedFiles->current()->file()); 193 // qDebug(d->selectedFiles->current()->file());
196 m3uList->add( d->selectedFiles->current()->file() ); 194 m3uList->add( d->selectedFiles->current()->file() );
197 } 195 }
198 while ( d->selectedFiles->next() ); 196 while ( d->selectedFiles->next() );
199 197
200 m3uList->write(); 198 m3uList->write();
201 m3uList->close(); 199 m3uList->close();
202 if(m3uList) delete m3uList; 200 if(m3uList) delete m3uList;
203 201
204 } 202 }
205 } 203 }
206} 204}
207 205
208void PlayListWidget::addToSelection( const DocLnk& lnk ) { 206void PlayListWidget::addToSelection( const DocLnk& lnk ) {
209 d->setDocumentUsed = FALSE; 207 d->setDocumentUsed = FALSE;
210 if ( mediaPlayerState->isUsingPlaylist() ) { 208 if ( mediaPlayerState->isUsingPlaylist() ) {
211 if( QFileInfo( lnk.file() ).exists() || 209 if( QFileInfo( lnk.file() ).exists() ||
212 lnk.file().left(4) == "http" ) { 210 lnk.file().left(4) == "http" ) {
213 d->selectedFiles->addToSelection( lnk ); 211 d->selectedFiles->addToSelection( lnk );
214 } 212 }
215// writeCurrentM3u(); 213// writeCurrentM3u();
216 } 214 }
217 else 215 else
218 mediaPlayerState->setPlaying( TRUE ); 216 mediaPlayerState->setPlaying( TRUE );
219} 217}
220 218
221 219
222void PlayListWidget::clearList() { 220void PlayListWidget::clearList() {
223 while ( first() ) { 221 while ( first() ) {
224 d->selectedFiles->removeSelected(); 222 d->selectedFiles->removeSelected();
225 } 223 }
226} 224}
227 225
228void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { 226void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
229 switch (mouse) { 227 switch (mouse) {
230 case 1: 228 case 1:
231 break; 229 break;
232 case 2: 230 case 2:
233 { 231 {
234 QPopupMenu m; 232 QPopupMenu m;
235 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 233 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
236 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 234 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
237 m.exec( QCursor::pos() ); 235 m.exec( QCursor::pos() );
238 } 236 }
239 break; 237 break;
240 } 238 }
241} 239}
242 240
243 241
244void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { 242void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) {
245 switch (mouse) { 243 switch (mouse) {
246 case 1: 244 case 1:
247 break; 245 break;
248 case 2: 246 case 2:
249 { 247 {
250 QPopupMenu m; 248 QPopupMenu m;
251 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 249 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
252 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 250 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
253 m.exec( QCursor::pos() ); 251 m.exec( QCursor::pos() );
254 } 252 }
255 break; 253 break;
256 } 254 }
257} 255}
258 256
259 257
260void PlayListWidget::addAllToList() { 258void PlayListWidget::addAllToList() {
261 259
262// QTime t; 260// QTime t;
263// t.start(); 261// t.start();
264 262
265 if(!audioScan) { 263 if(!audioScan) {
266 if(audioView->childCount() < 1) 264 if(audioView->childCount() < 1)
267 populateAudioView(); 265 populateAudioView();
268 } 266 }
269 267
270 QListViewItemIterator audioIt( audioView ); 268 QListViewItemIterator audioIt( audioView );
271 DocLnk lnk; 269 DocLnk lnk;
272 QString filename; 270 QString filename;
273 // iterate through all items of the listview 271 // iterate through all items of the listview
274 for ( ; audioIt.current(); ++audioIt ) { 272 for ( ; audioIt.current(); ++audioIt ) {
275 filename = audioIt.current()->text(3); 273 filename = audioIt.current()->text(3);
276 lnk.setName( QFileInfo(filename).baseName() ); //sets name 274 lnk.setName( QFileInfo(filename).baseName() ); //sets name
@@ -424,202 +422,192 @@ void PlayListWidget::useSelectedDocument() {
424const DocLnk *PlayListWidget::current() const { // this is fugly 422const DocLnk *PlayListWidget::current() const { // this is fugly
425 assert( currentTab() == CurrentPlayList ); 423 assert( currentTab() == CurrentPlayList );
426 424
427// qDebug("playlist"); 425// qDebug("playlist");
428 if ( mediaPlayerState->isUsingPlaylist() ) 426 if ( mediaPlayerState->isUsingPlaylist() )
429 return d->selectedFiles->current(); 427 return d->selectedFiles->current();
430 428
431 assert( false ); 429 assert( false );
432} 430}
433 431
434 432
435bool PlayListWidget::prev() { 433bool PlayListWidget::prev() {
436 if ( mediaPlayerState->isUsingPlaylist() ) { 434 if ( mediaPlayerState->isUsingPlaylist() ) {
437 if ( mediaPlayerState->isShuffled() ) { 435 if ( mediaPlayerState->isShuffled() ) {
438 const DocLnk *cur = current(); 436 const DocLnk *cur = current();
439 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 437 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
440 for ( int i = 0; i < j; i++ ) { 438 for ( int i = 0; i < j; i++ ) {
441 if ( !d->selectedFiles->next() ) 439 if ( !d->selectedFiles->next() )
442 d->selectedFiles->first(); 440 d->selectedFiles->first();
443 } 441 }
444 if ( cur == current() ) 442 if ( cur == current() )
445 if ( !d->selectedFiles->next() ) { 443 if ( !d->selectedFiles->next() ) {
446 d->selectedFiles->first(); 444 d->selectedFiles->first();
447 } 445 }
448 return TRUE; 446 return TRUE;
449 } else { 447 } else {
450 if ( !d->selectedFiles->prev() ) { 448 if ( !d->selectedFiles->prev() ) {
451 if ( mediaPlayerState->isLooping() ) { 449 if ( mediaPlayerState->isLooping() ) {
452 return d->selectedFiles->last(); 450 return d->selectedFiles->last();
453 } else { 451 } else {
454 return FALSE; 452 return FALSE;
455 } 453 }
456 } 454 }
457 return TRUE; 455 return TRUE;
458 } 456 }
459 } else { 457 } else {
460 return mediaPlayerState->isLooping(); 458 return mediaPlayerState->isLooping();
461 } 459 }
462} 460}
463 461
464 462
465bool PlayListWidget::next() { 463bool PlayListWidget::next() {
466//qDebug("<<<<<<<<<<<<next()"); 464//qDebug("<<<<<<<<<<<<next()");
467 if ( mediaPlayerState->isUsingPlaylist() ) { 465 if ( mediaPlayerState->isUsingPlaylist() ) {
468 if ( mediaPlayerState->isShuffled() ) { 466 if ( mediaPlayerState->isShuffled() ) {
469 return prev(); 467 return prev();
470 } else { 468 } else {
471 if ( !d->selectedFiles->next() ) { 469 if ( !d->selectedFiles->next() ) {
472 if ( mediaPlayerState->isLooping() ) { 470 if ( mediaPlayerState->isLooping() ) {
473 return d->selectedFiles->first(); 471 return d->selectedFiles->first();
474 } else { 472 } else {
475 return FALSE; 473 return FALSE;
476 } 474 }
477 } 475 }
478 return TRUE; 476 return TRUE;
479 } 477 }
480 } else { 478 } else {
481 return mediaPlayerState->isLooping(); 479 return mediaPlayerState->isLooping();
482 } 480 }
483} 481}
484 482
485 483
486bool PlayListWidget::first() { 484bool PlayListWidget::first() {
487 if ( mediaPlayerState->isUsingPlaylist() ) 485 if ( mediaPlayerState->isUsingPlaylist() )
488 return d->selectedFiles->first(); 486 return d->selectedFiles->first();
489 else 487 else
490 return mediaPlayerState->isLooping(); 488 return mediaPlayerState->isLooping();
491} 489}
492 490
493 491
494bool PlayListWidget::last() { 492bool PlayListWidget::last() {
495 if ( mediaPlayerState->isUsingPlaylist() ) 493 if ( mediaPlayerState->isUsingPlaylist() )
496 return d->selectedFiles->last(); 494 return d->selectedFiles->last();
497 else 495 else
498 return mediaPlayerState->isLooping(); 496 return mediaPlayerState->isLooping();
499} 497}
500 498
501 499
502 void PlayListWidget::saveList() { 500 void PlayListWidget::saveList() {
503 writem3u(); 501 writem3u();
504 } 502 }
505 503
506 504
507void PlayListWidget::loadList( const DocLnk & lnk) { 505void PlayListWidget::loadList( const DocLnk & lnk) {
508 QString name = lnk.name(); 506 QString name = lnk.name();
509 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); 507 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
510 508
511 if( name.length()>0) { 509 if( name.length()>0) {
512 setCaption("OpiePlayer: "+name); 510 setCaption("OpiePlayer: "+name);
513// qDebug("<<<<<<<<<<<<load list "+ lnk.file()); 511// qDebug("<<<<<<<<<<<<load list "+ lnk.file());
514 clearList(); 512 clearList();
515 readm3u(lnk.file()); 513 readm3u(lnk.file());
516 tabWidget->setCurrentPage(0); 514 tabWidget->setCurrentPage(0);
517 } 515 }
518} 516}
519 517
520
521void PlayListWidget::setPlaylist( bool shown ) {
522 if ( shown ) {
523 d->playListFrame->show();
524 } else {
525 d->playListFrame->hide();
526 }
527}
528
529
530void PlayListWidget::addSelected() { 518void PlayListWidget::addSelected() {
531 assert( inFileListMode() ); 519 assert( inFileListMode() );
532 520
533 QListView *fileListView = currentFileListView(); 521 QListView *fileListView = currentFileListView();
534 QListViewItemIterator it( fileListView ); 522 QListViewItemIterator it( fileListView );
535 for ( ; it.current(); ++it ) 523 for ( ; it.current(); ++it )
536 if ( it.current()->isSelected() ) { 524 if ( it.current()->isSelected() ) {
537 QString filename = it.current()->text(3); 525 QString filename = it.current()->text(3);
538 526
539 DocLnk lnk; 527 DocLnk lnk;
540 lnk.setName( QFileInfo( filename ).baseName() ); //sets name 528 lnk.setName( QFileInfo( filename ).baseName() ); //sets name
541 lnk.setFile( filename ); //sets file name 529 lnk.setFile( filename ); //sets file name
542 530
543 d->selectedFiles->addToSelection( lnk ); 531 d->selectedFiles->addToSelection( lnk );
544 } 532 }
545 533
546 fileListView->clearSelection(); 534 fileListView->clearSelection();
547 535
548 tabWidget->setCurrentPage( 0 ); 536 tabWidget->setCurrentPage( 0 );
549 writeCurrentM3u(); 537 writeCurrentM3u();
550} 538}
551 539
552 540
553void PlayListWidget::removeSelected() { 541void PlayListWidget::removeSelected() {
554 d->selectedFiles->removeSelected( ); 542 d->selectedFiles->removeSelected( );
555 writeCurrentM3u(); 543 writeCurrentM3u();
556} 544}
557 545
558 546
559void PlayListWidget::playIt( QListViewItem *it) { 547void PlayListWidget::playIt( QListViewItem *it) {
560 if(!it) return; 548 if(!it) return;
561 mediaPlayerState->setPlaying(FALSE); 549 mediaPlayerState->setPlaying(FALSE);
562 mediaPlayerState->setPlaying(TRUE); 550 mediaPlayerState->setPlaying(TRUE);
563 d->selectedFiles->unSelect(); 551 d->selectedFiles->unSelect();
564} 552}
565 553
566 554
567void PlayListWidget::addToSelection( QListViewItem *it) { 555void PlayListWidget::addToSelection( QListViewItem *it) {
568 d->setDocumentUsed = FALSE; 556 d->setDocumentUsed = FALSE;
569 557
570 if(it) { 558 if(it) {
571 if ( currentTab() == CurrentPlayList ) 559 if ( currentTab() == CurrentPlayList )
572 return; 560 return;
573 // case 1: { 561 // case 1: {
574 DocLnk lnk; 562 DocLnk lnk;
575 QString filename; 563 QString filename;
576 564
577 filename=it->text(3); 565 filename=it->text(3);
578 lnk.setName( QFileInfo(filename).baseName() ); //sets name 566 lnk.setName( QFileInfo(filename).baseName() ); //sets name
579 lnk.setFile( filename ); //sets file name 567 lnk.setFile( filename ); //sets file name
580 d->selectedFiles->addToSelection( lnk); 568 d->selectedFiles->addToSelection( lnk);
581 569
582 writeCurrentM3u(); 570 writeCurrentM3u();
583 tabWidget->setCurrentPage(0); 571 tabWidget->setCurrentPage(0);
584 572
585 } 573 }
586} 574}
587 575
588 576
589void PlayListWidget::tabChanged(QWidget *) { 577void PlayListWidget::tabChanged(QWidget *) {
590 578
591 d->tbPlay->setEnabled( true ); 579 d->tbPlay->setEnabled( true );
592 580
593 switch ( currentTab() ) { 581 switch ( currentTab() ) {
594 case CurrentPlayList: 582 case CurrentPlayList:
595 { 583 {
596 if( !tbDeletePlaylist->isHidden() ) { 584 if( !tbDeletePlaylist->isHidden() ) {
597 tbDeletePlaylist->hide(); 585 tbDeletePlaylist->hide();
598 } 586 }
599 d->tbRemoveFromList->setEnabled(TRUE); 587 d->tbRemoveFromList->setEnabled(TRUE);
600 d->tbAddToList->setEnabled(FALSE); 588 d->tbAddToList->setEnabled(FALSE);
601 } 589 }
602 break; 590 break;
603 case AudioFiles: 591 case AudioFiles:
604 { 592 {
605 // audioView->clear(); 593 // audioView->clear();
606 if(!audioPopulated) populateAudioView(); 594 if(!audioPopulated) populateAudioView();
607 595
608 if( !tbDeletePlaylist->isHidden() ) { 596 if( !tbDeletePlaylist->isHidden() ) {
609 tbDeletePlaylist->hide(); 597 tbDeletePlaylist->hide();
610 } 598 }
611 d->tbRemoveFromList->setEnabled(FALSE); 599 d->tbRemoveFromList->setEnabled(FALSE);
612 d->tbAddToList->setEnabled(TRUE); 600 d->tbAddToList->setEnabled(TRUE);
613 } 601 }
614 break; 602 break;
615 case VideoFiles: 603 case VideoFiles:
616 { 604 {
617 // videoView->clear(); 605 // videoView->clear();
618 if(!videoPopulated) populateVideoView(); 606 if(!videoPopulated) populateVideoView();
619 if( !tbDeletePlaylist->isHidden() ) { 607 if( !tbDeletePlaylist->isHidden() ) {
620 tbDeletePlaylist->hide(); 608 tbDeletePlaylist->hide();
621 } 609 }
622 d->tbRemoveFromList->setEnabled(FALSE); 610 d->tbRemoveFromList->setEnabled(FALSE);
623 d->tbAddToList->setEnabled(TRUE); 611 d->tbAddToList->setEnabled(TRUE);
624 } 612 }
625 break; 613 break;
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h
index 511a192..fa2837a 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.h
+++ b/noncore/multimedia/opieplayer2/playlistwidget.h
@@ -26,116 +26,115 @@
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 43
44#include "playlistwidgetgui.h" 44#include "playlistwidgetgui.h"
45 45
46 46
47//class PlayListWidgetPrivate; 47//class PlayListWidgetPrivate;
48class Config; 48class Config;
49class QListViewItem; 49class QListViewItem;
50class QListView; 50class QListView;
51class QPoint; 51class QPoint;
52class QAction; 52class QAction;
53class QLabel; 53class QLabel;
54 54
55class PlayListWidget : public PlayListWidgetGui { 55class PlayListWidget : public PlayListWidgetGui {
56 Q_OBJECT 56 Q_OBJECT
57public: 57public:
58 enum TabType { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; 58 enum TabType { CurrentPlayList, AudioFiles, VideoFiles, PlayLists };
59 enum { TabTypeCount = 4 }; 59 enum { TabTypeCount = 4 };
60 60
61 struct Entry 61 struct Entry
62 { 62 {
63 Entry( const QString &_name, const QString &_fileName ) 63 Entry( const QString &_name, const QString &_fileName )
64 : name( _name ), file( _fileName ) {} 64 : name( _name ), file( _fileName ) {}
65 Entry( const QString &_fileName ) 65 Entry( const QString &_fileName )
66 : name( _fileName ), file( _fileName ) {} 66 : name( _fileName ), file( _fileName ) {}
67 67
68 QString name; 68 QString name;
69 QString file; 69 QString file;
70 }; 70 };
71 71
72 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); 72 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 );
73 ~PlayListWidget(); 73 ~PlayListWidget();
74 DocLnkSet files; 74 DocLnkSet files;
75 DocLnkSet vFiles; 75 DocLnkSet vFiles;
76 bool fromSetDocument; 76 bool fromSetDocument;
77 bool insanityBool; 77 bool insanityBool;
78 QString setDocFileRef, currentPlayList; 78 QString setDocFileRef, currentPlayList;
79 // retrieve the current playlist entry (media file link) 79 // retrieve the current playlist entry (media file link)
80 const DocLnk *current() const; 80 const DocLnk *current() const;
81 void useSelectedDocument(); 81 void useSelectedDocument();
82 int selected; 82 int selected;
83 TabType currentTab() const; 83 TabType currentTab() const;
84 84
85 Entry currentEntry() const; 85 Entry currentEntry() const;
86 86
87public slots: 87public slots:
88 bool first(); 88 bool first();
89 bool last(); 89 bool last();
90 bool next(); 90 bool next();
91 bool prev(); 91 bool prev();
92 void writeDefaultPlaylist( ); 92 void writeDefaultPlaylist( );
93 QString currentFileListPathName() const; 93 QString currentFileListPathName() const;
94protected: 94protected:
95 void keyReleaseEvent( QKeyEvent *e); 95 void keyReleaseEvent( QKeyEvent *e);
96 96
97private: 97private:
98 int defaultSkinIndex; 98 int defaultSkinIndex;
99 bool audioScan, videoScan, audioPopulated, videoPopulated; 99 bool audioScan, videoScan, audioPopulated, videoPopulated;
100 void readm3u(const QString &); 100 void readm3u(const QString &);
101 void readPls(const QString &); 101 void readPls(const QString &);
102 void initializeStates(); 102 void initializeStates();
103 void populateAudioView(); 103 void populateAudioView();
104 void populateVideoView(); 104 void populateVideoView();
105 105
106 QListView *currentFileListView() const; 106 QListView *currentFileListView() const;
107 107
108 bool inFileListMode() const; 108 bool inFileListMode() const;
109 109
110private slots: 110private slots:
111 void populateSkinsMenu(); 111 void populateSkinsMenu();
112 void skinsMenuActivated(int); 112 void skinsMenuActivated(int);
113 void pmViewActivated(int); 113 void pmViewActivated(int);
114 void writem3u(); 114 void writem3u();
115 void writeCurrentM3u(); 115 void writeCurrentM3u();
116 void scanForAudio(); 116 void scanForAudio();
117 void scanForVideo(); 117 void scanForVideo();
118 void openFile(); 118 void openFile();
119 void setDocument( const QString& fileref ); 119 void setDocument( const QString& fileref );
120 void addToSelection( const DocLnk& ); // Add a media file to the playlist 120 void addToSelection( const DocLnk& ); // Add a media file to the playlist
121 void addToSelection( QListViewItem* ); // Add a media file to the playlist 121 void addToSelection( QListViewItem* ); // Add a media file to the playlist
122 void setPlaylist( bool ); // Show/Hide the playlist
123 void clearList(); 122 void clearList();
124 void addAllToList(); 123 void addAllToList();
125 void addAllMusicToList(); 124 void addAllMusicToList();
126 void addAllVideoToList(); 125 void addAllVideoToList();
127 void saveList(); // Save the playlist 126 void saveList(); // Save the playlist
128 void loadList( const DocLnk &); // Load a playlist 127 void loadList( const DocLnk &); // Load a playlist
129 void playIt( QListViewItem *); 128 void playIt( QListViewItem *);
130 void btnPlay(bool); 129 void btnPlay(bool);
131 void deletePlaylist(); 130 void deletePlaylist();
132 void addSelected(); 131 void addSelected();
133 void removeSelected(); 132 void removeSelected();
134 void tabChanged(QWidget*); 133 void tabChanged(QWidget*);
135 void viewPressed( int, QListViewItem *, const QPoint&, int); 134 void viewPressed( int, QListViewItem *, const QPoint&, int);
136 void playlistViewPressed( int, QListViewItem *, const QPoint&, int); 135 void playlistViewPressed( int, QListViewItem *, const QPoint&, int);
137 void playSelected(); 136 void playSelected();
138}; 137};
139 138
140#endif // PLAY_LIST_WIDGET_H 139#endif // PLAY_LIST_WIDGET_H
141 140