author | harlekin <harlekin> | 2002-07-09 12:33:52 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-07-09 12:33:52 (UTC) |
commit | 2fa8959b269c51bb40d1f03bbd7c55fdaa9da0dd (patch) (unidiff) | |
tree | 8ce99f4cde91c9346a4cd6f7029ec1d1308cfb30 /noncore/multimedia/opieplayer2 | |
parent | c0d304c69f6c42328472cd1328d9cad7c2ed4dfb (diff) | |
download | opie-2fa8959b269c51bb40d1f03bbd7c55fdaa9da0dd.zip opie-2fa8959b269c51bb40d1f03bbd7c55fdaa9da0dd.tar.gz opie-2fa8959b269c51bb40d1f03bbd7c55fdaa9da0dd.tar.bz2 |
more gui work
Diffstat (limited to 'noncore/multimedia/opieplayer2') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/mediadetect.cpp | 38 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediadetect.h | 31 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/opieplayer2.pro | 4 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 229 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.cpp | 20 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinecontrol.h | 2 |
6 files changed, 136 insertions, 188 deletions
diff --git a/noncore/multimedia/opieplayer2/mediadetect.cpp b/noncore/multimedia/opieplayer2/mediadetect.cpp new file mode 100644 index 0000000..7deeb2f --- a/dev/null +++ b/noncore/multimedia/opieplayer2/mediadetect.cpp | |||
@@ -0,0 +1,38 @@ | |||
1 | #include <qstring.h> | ||
2 | #include "mediadetect.h" | ||
3 | |||
4 | |||
5 | MediaDetect::MediaDetect() { | ||
6 | } | ||
7 | |||
8 | MediaDetect::~MediaDetect() { | ||
9 | } | ||
10 | |||
11 | char MediaDetect::videoOrAudio( const QString& fileName ) { | ||
12 | if( fileName.right(4) == ".avi" || | ||
13 | fileName.right(4) == ".mpg" || | ||
14 | fileName.right(4) == ".asf" || | ||
15 | fileName.right(4) == ".mov" || | ||
16 | fileName.right(5) == ".mpeg" ) { | ||
17 | return 'v'; | ||
18 | } else if ( fileName.right(4) == ".avi" || | ||
19 | fileName.right(4) == ".mp3" || | ||
20 | fileName.right(4) == ".ogg" || | ||
21 | fileName.right(4) == ".wav" ) { | ||
22 | return 'a'; | ||
23 | } else { | ||
24 | return 'f'; | ||
25 | } | ||
26 | } | ||
27 | |||
28 | bool MediaDetect::isStreaming( const QString& fileName ) { | ||
29 | // ugly | ||
30 | if( fileName.left(4) == "http" ) { | ||
31 | return true; | ||
32 | } else if (fileName.left(3) == "ftp" ) { | ||
33 | return true; | ||
34 | } else { | ||
35 | return false; | ||
36 | } | ||
37 | } | ||
38 | |||
diff --git a/noncore/multimedia/opieplayer2/mediadetect.h b/noncore/multimedia/opieplayer2/mediadetect.h new file mode 100644 index 0000000..bd5ea1d --- a/dev/null +++ b/noncore/multimedia/opieplayer2/mediadetect.h | |||
@@ -0,0 +1,31 @@ | |||
1 | |||
2 | #ifndef MEDIADETECT_H | ||
3 | #define MEDIADETECT_H | ||
4 | |||
5 | |||
6 | class QString; | ||
7 | class MediaDetect { | ||
8 | |||
9 | public: | ||
10 | MediaDetect(); | ||
11 | ~MediaDetect(); | ||
12 | |||
13 | /** | ||
14 | * Look at the filename and decide which gui is to be used | ||
15 | * | ||
16 | * @param filename the filename | ||
17 | * @return the char - a for audio gui, v for video, f for error | ||
18 | */ | ||
19 | char videoOrAudio( const QString& fileName ); | ||
20 | |||
21 | /** | ||
22 | * Find out if it is a streaming media file | ||
23 | * | ||
24 | * @param filename the filename | ||
25 | * @return if it is a streaming url or not | ||
26 | */ | ||
27 | bool isStreaming( const QString& fileName ); | ||
28 | |||
29 | }; | ||
30 | |||
31 | #endif | ||
diff --git a/noncore/multimedia/opieplayer2/opieplayer2.pro b/noncore/multimedia/opieplayer2/opieplayer2.pro index bcd9b92..37208ef 100644 --- a/noncore/multimedia/opieplayer2/opieplayer2.pro +++ b/noncore/multimedia/opieplayer2/opieplayer2.pro | |||
@@ -1,15 +1,15 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | CONFIG = qt warn_on release | 2 | CONFIG = qt warn_on release |
3 | #release | 3 | #release |
4 | DESTDIR = $(OPIEDIR)/bin | 4 | DESTDIR = $(OPIEDIR)/bin |
5 | HEADERS = playlistselection.h mediaplayerstate.h xinecontrol.h\ | 5 | HEADERS = playlistselection.h mediaplayerstate.h xinecontrol.h mediadetect.h\ |
6 | videowidget.h audiowidget.h playlistwidget.h mediaplayer.h inputDialog.h \ | 6 | videowidget.h audiowidget.h playlistwidget.h mediaplayer.h inputDialog.h \ |
7 | frame.h lib.h | 7 | frame.h lib.h |
8 | SOURCES = main.cpp \ | 8 | SOURCES = main.cpp \ |
9 | playlistselection.cpp mediaplayerstate.cpp xinecontrol.cpp\ | 9 | playlistselection.cpp mediaplayerstate.cpp xinecontrol.cpp mediadetect.cpp\ |
10 | videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp inputDialog.cpp \ | 10 | videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp inputDialog.cpp \ |
11 | frame.cpp lib.cpp nullvideo.c | 11 | frame.cpp lib.cpp nullvideo.c |
12 | TARGET = opieplayer | 12 | TARGET = opieplayer |
13 | INCLUDEPATH += $(OPIEDIR)/include | 13 | INCLUDEPATH += $(OPIEDIR)/include |
14 | DEPENDPATH += $(OPIEDIR)/include | 14 | DEPENDPATH += $(OPIEDIR)/include |
15 | LIBS += -lqpe -lpthread -lopie -lxine -lxineutils | 15 | LIBS += -lqpe -lpthread -lopie -lxine -lxineutils |
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 0390c99..9373f6b 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -31,13 +31,12 @@ | |||
31 | #include <qpoint.h> | 31 | #include <qpoint.h> |
32 | #include <qlineedit.h> | 32 | #include <qlineedit.h> |
33 | #include <qpushbutton.h> | 33 | #include <qpushbutton.h> |
34 | #include <qregexp.h> | 34 | #include <qregexp.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | 36 | ||
37 | //#include <qtimer.h> | ||
38 | 37 | ||
39 | #include "playlistselection.h" | 38 | #include "playlistselection.h" |
40 | #include "playlistwidget.h" | 39 | #include "playlistwidget.h" |
41 | #include "mediaplayerstate.h" | 40 | #include "mediaplayerstate.h" |
42 | 41 | ||
43 | #include "inputDialog.h" | 42 | #include "inputDialog.h" |
@@ -58,19 +57,15 @@ | |||
58 | #include <stdlib.h> | 57 | #include <stdlib.h> |
59 | 58 | ||
60 | #define BUTTONS_ON_TOOLBAR | 59 | #define BUTTONS_ON_TOOLBAR |
61 | #define SIDE_BUTTONS | 60 | #define SIDE_BUTTONS |
62 | #define CAN_SAVE_LOAD_PLAYLISTS | 61 | #define CAN_SAVE_LOAD_PLAYLISTS |
63 | 62 | ||
64 | extern AudioWidget *audioUI; | ||
65 | extern VideoWidget *videoUI; | ||
66 | extern MediaPlayerState *mediaPlayerState; | 63 | extern MediaPlayerState *mediaPlayerState; |
67 | 64 | ||
68 | // class myFileSelector { | ||
69 | 65 | ||
70 | // }; | ||
71 | class PlayListWidgetPrivate { | 66 | class PlayListWidgetPrivate { |
72 | public: | 67 | public: |
73 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | 68 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
74 | QFrame *playListFrame; | 69 | QFrame *playListFrame; |
75 | FileSelector *files; | 70 | FileSelector *files; |
76 | PlayListSelection *selectedFiles; | 71 | PlayListSelection *selectedFiles; |
@@ -111,14 +106,12 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
111 | d->setDocumentUsed = FALSE; | 106 | d->setDocumentUsed = FALSE; |
112 | d->current = NULL; | 107 | d->current = NULL; |
113 | fromSetDocument = FALSE; | 108 | fromSetDocument = FALSE; |
114 | insanityBool=FALSE; | 109 | insanityBool=FALSE; |
115 | audioScan = FALSE; | 110 | audioScan = FALSE; |
116 | videoScan = FALSE; | 111 | videoScan = FALSE; |
117 | // menuTimer = new QTimer( this ,"menu timer"), | ||
118 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); | ||
119 | 112 | ||
120 | setBackgroundMode( PaletteButton ); | 113 | setBackgroundMode( PaletteButton ); |
121 | 114 | ||
122 | setCaption( tr("OpiePlayer") ); | 115 | setCaption( tr("OpiePlayer") ); |
123 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); | 116 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); |
124 | 117 | ||
@@ -131,23 +124,21 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
131 | // Create Menubar | 124 | // Create Menubar |
132 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | 125 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); |
133 | menu->setMargin( 0 ); | 126 | menu->setMargin( 0 ); |
134 | 127 | ||
135 | QPEToolBar *bar = new QPEToolBar( this ); | 128 | QPEToolBar *bar = new QPEToolBar( this ); |
136 | bar->setLabel( tr( "Play Operations" ) ); | 129 | bar->setLabel( tr( "Play Operations" ) ); |
137 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", | 130 | |
138 | // this , SLOT( addSelected()) ); | ||
139 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); | 131 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); |
140 | tbDeletePlaylist->setFlat(TRUE); | 132 | tbDeletePlaylist->setFlat(TRUE); |
141 | tbDeletePlaylist->setFixedSize(20,20); | 133 | tbDeletePlaylist->setFixedSize(20,20); |
142 | 134 | ||
143 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", | 135 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", |
144 | this , SLOT(addSelected()) ); | 136 | this , SLOT(addSelected()) ); |
145 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", | 137 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", |
146 | this , SLOT(removeSelected()) ); | 138 | this , SLOT(removeSelected()) ); |
147 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); | ||
148 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", | 139 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", |
149 | this , SLOT( btnPlay(bool) ), TRUE ); | 140 | this , SLOT( btnPlay(bool) ), TRUE ); |
150 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", | 141 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", |
151 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 142 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); |
152 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", | 143 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", |
153 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 144 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); |
@@ -183,14 +174,12 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
183 | 174 | ||
184 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 175 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
185 | tabWidget->setTabShape(QTabWidget::Triangular); | 176 | tabWidget->setTabShape(QTabWidget::Triangular); |
186 | 177 | ||
187 | QWidget *pTab; | 178 | QWidget *pTab; |
188 | pTab = new QWidget( tabWidget, "pTab" ); | 179 | pTab = new QWidget( tabWidget, "pTab" ); |
189 | // playlistView = new QListView( pTab, "playlistview" ); | ||
190 | // playlistView->setMinimumSize(236,260); | ||
191 | tabWidget->insertTab( pTab,"Playlist"); | 180 | tabWidget->insertTab( pTab,"Playlist"); |
192 | 181 | ||
193 | 182 | ||
194 | // Add the playlist area | 183 | // Add the playlist area |
195 | 184 | ||
196 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); | 185 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); |
@@ -201,14 +190,12 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
201 | 190 | ||
202 | d->selectedFiles = new PlayListSelection( hbox2); | 191 | d->selectedFiles = new PlayListSelection( hbox2); |
203 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | 192 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); |
204 | 193 | ||
205 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); | 194 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); |
206 | 195 | ||
207 | |||
208 | |||
209 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | 196 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch |
210 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 197 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
211 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | 198 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); |
212 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 199 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
213 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 200 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
214 | 201 | ||
@@ -227,16 +214,12 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
227 | audioView->setSelectionMode( QListView::Extended); | 214 | audioView->setSelectionMode( QListView::Extended); |
228 | 215 | ||
229 | tabWidget->insertTab(aTab,tr("Audio")); | 216 | tabWidget->insertTab(aTab,tr("Audio")); |
230 | 217 | ||
231 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | 218 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); |
232 | 219 | ||
233 | // audioView | ||
234 | // populateAudioView(); | ||
235 | // videowidget | ||
236 | |||
237 | QWidget *vTab; | 220 | QWidget *vTab; |
238 | vTab = new QWidget( tabWidget, "vTab" ); | 221 | vTab = new QWidget( tabWidget, "vTab" ); |
239 | videoView = new QListView( vTab, "Videoview" ); | 222 | videoView = new QListView( vTab, "Videoview" ); |
240 | videoView->setMinimumSize(233,260); | 223 | videoView->setMinimumSize(233,260); |
241 | 224 | ||
242 | videoView->addColumn(tr("Title"),140); | 225 | videoView->addColumn(tr("Title"),140); |
@@ -248,101 +231,72 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
248 | videoView->setMultiSelection( TRUE ); | 231 | videoView->setMultiSelection( TRUE ); |
249 | videoView->setSelectionMode( QListView::Extended); | 232 | videoView->setSelectionMode( QListView::Extended); |
250 | 233 | ||
251 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 234 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
252 | 235 | ||
253 | tabWidget->insertTab( vTab,tr("Video")); | 236 | tabWidget->insertTab( vTab,tr("Video")); |
254 | // populateVideoView(); | ||
255 | 237 | ||
256 | //playlists list | 238 | //playlists list |
257 | QWidget *LTab; | 239 | QWidget *LTab; |
258 | LTab = new QWidget( tabWidget, "LTab" ); | 240 | LTab = new QWidget( tabWidget, "LTab" ); |
259 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | 241 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy |
260 | playLists->setMinimumSize(233,260); | 242 | playLists->setMinimumSize(233,260); |
261 | tabWidget->insertTab(LTab,tr("Lists")); | 243 | tabWidget->insertTab(LTab,tr("Lists")); |
262 | 244 | ||
263 | // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | ||
264 | |||
265 | // add the library area | ||
266 | |||
267 | // connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), | ||
268 | // this, SLOT( fauxPlay( QListViewItem *) ) ); | ||
269 | // connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), | ||
270 | // this, SLOT( fauxPlay( QListViewItem *)) ); | ||
271 | |||
272 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); | ||
273 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); | ||
274 | |||
275 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); | 245 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); |
276 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); | 246 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); |
277 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); | 247 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); |
278 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 248 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
279 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); | 249 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); |
280 | |||
281 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 250 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
282 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 251 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
283 | |||
284 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), | 252 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), |
285 | this,SLOT( playIt( QListViewItem *)) ); | 253 | this,SLOT( playIt( QListViewItem *)) ); |
286 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 254 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
287 | |||
288 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 255 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
289 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 256 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
290 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), | 257 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), |
291 | this,SLOT( playIt( QListViewItem *)) ); | 258 | this,SLOT( playIt( QListViewItem *)) ); |
292 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 259 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
293 | |||
294 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 260 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
295 | |||
296 | |||
297 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 261 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
298 | |||
299 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 262 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
300 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 263 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
301 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 264 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
302 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 265 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
303 | |||
304 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 266 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
305 | // connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); | ||
306 | 267 | ||
307 | setCentralWidget( vbox5 ); | 268 | setCentralWidget( vbox5 ); |
308 | 269 | ||
309 | Config cfg( "OpiePlayer" ); | 270 | Config cfg( "OpiePlayer" ); |
310 | readConfig( cfg ); | 271 | readConfig( cfg ); |
311 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 272 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
312 | // qDebug("currentList is "+currentPlaylist); | ||
313 | loadList(DocLnk( currentPlaylist)); | 273 | loadList(DocLnk( currentPlaylist)); |
314 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); | 274 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); |
315 | 275 | ||
316 | initializeStates(); | 276 | initializeStates(); |
317 | } | 277 | } |
318 | 278 | ||
319 | 279 | ||
320 | PlayListWidget::~PlayListWidget() { | 280 | PlayListWidget::~PlayListWidget() { |
321 | Config cfg( "OpiePlayer" ); | 281 | Config cfg( "OpiePlayer" ); |
322 | writeConfig( cfg ); | 282 | writeConfig( cfg ); |
323 | 283 | ||
324 | 284 | if ( d->current ) { | |
325 | if ( d->current ) | ||
326 | delete d->current; | 285 | delete d->current; |
286 | } | ||
327 | delete d; | 287 | delete d; |
328 | } | 288 | } |
329 | 289 | ||
330 | 290 | ||
331 | void PlayListWidget::initializeStates() { | 291 | void PlayListWidget::initializeStates() { |
332 | 292 | ||
333 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 293 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
334 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 294 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
335 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 295 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
336 | // d->tbFull->setOn( mediaPlayerState->fullscreen() ); | ||
337 | // d->tbScale->setOn( mediaPlayerState->scaled() ); | ||
338 | // d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); | ||
339 | // setPlaylist( mediaPlayerState->playlist() ); | ||
340 | setPlaylist( true); | 296 | setPlaylist( true); |
341 | // d->selectedFiles->first(); | ||
342 | |||
343 | } | 297 | } |
344 | 298 | ||
345 | 299 | ||
346 | void PlayListWidget::readConfig( Config& cfg ) { | 300 | void PlayListWidget::readConfig( Config& cfg ) { |
347 | cfg.setGroup("PlayList"); | 301 | cfg.setGroup("PlayList"); |
348 | QString currentString = cfg.readEntry("current", "" ); | 302 | QString currentString = cfg.readEntry("current", "" ); |
@@ -354,13 +308,12 @@ void PlayListWidget::readConfig( Config& cfg ) { | |||
354 | DocLnk lnk( linkFile ); | 308 | DocLnk lnk( linkFile ); |
355 | if ( lnk.isValid() ) { | 309 | if ( lnk.isValid() ) { |
356 | d->selectedFiles->addToSelection( lnk ); | 310 | d->selectedFiles->addToSelection( lnk ); |
357 | } | 311 | } |
358 | } | 312 | } |
359 | d->selectedFiles->setSelectedItem( currentString); | 313 | d->selectedFiles->setSelectedItem( currentString); |
360 | // d->selectedFiles->setSelectedItem( (const QString &)currentString); | ||
361 | } | 314 | } |
362 | 315 | ||
363 | 316 | ||
364 | void PlayListWidget::writeConfig( Config& cfg ) const { | 317 | void PlayListWidget::writeConfig( Config& cfg ) const { |
365 | 318 | ||
366 | d->selectedFiles->writeCurrent( cfg); | 319 | d->selectedFiles->writeCurrent( cfg); |
@@ -369,13 +322,12 @@ void PlayListWidget::writeConfig( Config& cfg ) const { | |||
369 | d->selectedFiles->first(); | 322 | d->selectedFiles->first(); |
370 | do { | 323 | do { |
371 | const DocLnk *lnk = d->selectedFiles->current(); | 324 | const DocLnk *lnk = d->selectedFiles->current(); |
372 | if ( lnk ) { | 325 | if ( lnk ) { |
373 | QString entryName; | 326 | QString entryName; |
374 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 327 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
375 | // qDebug(entryName); | ||
376 | cfg.writeEntry( entryName, lnk->linkFile() ); | 328 | cfg.writeEntry( entryName, lnk->linkFile() ); |
377 | // if this link does exist, add it so we have the file | 329 | // if this link does exist, add it so we have the file |
378 | // next time... | 330 | // next time... |
379 | if ( !QFile::exists( lnk->linkFile() ) ) { | 331 | if ( !QFile::exists( lnk->linkFile() ) ) { |
380 | // the way writing lnks doesn't really check for out | 332 | // the way writing lnks doesn't really check for out |
381 | // of disk space, but check it anyway. | 333 | // of disk space, but check it anyway. |
@@ -395,51 +347,49 @@ void PlayListWidget::writeConfig( Config& cfg ) const { | |||
395 | while ( d->selectedFiles->next() ); | 347 | while ( d->selectedFiles->next() ); |
396 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 348 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
397 | } | 349 | } |
398 | 350 | ||
399 | 351 | ||
400 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 352 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
401 | // qDebug("add"); | ||
402 | // if( lnk.file().find(" ",0,TRUE) != -1 || lnk.file().find("%20",0,TRUE) != -1) { | ||
403 | // QMessageBox::message("Note","You are trying to play\na malformed url."); | ||
404 | |||
405 | // } else { | ||
406 | |||
407 | d->setDocumentUsed = FALSE; | 353 | d->setDocumentUsed = FALSE; |
408 | if ( mediaPlayerState->playlist() ) { | 354 | if ( mediaPlayerState->playlist() ) { |
409 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) | 355 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) |
410 | d->selectedFiles->addToSelection( lnk ); | 356 | d->selectedFiles->addToSelection( lnk ); |
411 | } | 357 | } |
412 | else | 358 | else |
413 | mediaPlayerState->setPlaying( TRUE ); | 359 | mediaPlayerState->setPlaying( TRUE ); |
414 | // } | ||
415 | } | 360 | } |
416 | 361 | ||
417 | 362 | ||
418 | void PlayListWidget::clearList() { | 363 | void PlayListWidget::clearList() { |
419 | while ( first() ) | 364 | while ( first() ) { |
420 | d->selectedFiles->removeSelected(); | 365 | d->selectedFiles->removeSelected(); |
421 | } | 366 | } |
367 | } | ||
422 | 368 | ||
423 | 369 | ||
424 | void PlayListWidget::addAllToList() { | 370 | void PlayListWidget::addAllToList() { |
425 | DocLnkSet filesAll; | 371 | DocLnkSet filesAll; |
426 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 372 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
427 | QListIterator<DocLnk> Adit( filesAll.children() ); | 373 | QListIterator<DocLnk> Adit( filesAll.children() ); |
428 | for ( ; Adit.current(); ++Adit ) | 374 | for ( ; Adit.current(); ++Adit ) { |
429 | if(QFileInfo(Adit.current()->file()).exists()) | 375 | if(QFileInfo(Adit.current()->file()).exists()) { |
430 | d->selectedFiles->addToSelection( **Adit ); | 376 | d->selectedFiles->addToSelection( **Adit ); |
431 | } | 377 | } |
378 | } | ||
379 | } | ||
432 | 380 | ||
433 | 381 | ||
434 | void PlayListWidget::addAllMusicToList() { | 382 | void PlayListWidget::addAllMusicToList() { |
435 | QListIterator<DocLnk> dit( files.children() ); | 383 | QListIterator<DocLnk> dit( files.children() ); |
436 | for ( ; dit.current(); ++dit ) | 384 | for ( ; dit.current(); ++dit ) { |
437 | if(QFileInfo(dit.current()->file()).exists()) | 385 | if(QFileInfo(dit.current()->file()).exists()) { |
438 | d->selectedFiles->addToSelection( **dit ); | 386 | d->selectedFiles->addToSelection( **dit ); |
439 | } | 387 | } |
388 | } | ||
389 | } | ||
440 | 390 | ||
441 | 391 | ||
442 | void PlayListWidget::addAllVideoToList() { | 392 | void PlayListWidget::addAllVideoToList() { |
443 | QListIterator<DocLnk> dit( vFiles.children() ); | 393 | QListIterator<DocLnk> dit( vFiles.children() ); |
444 | for ( ; dit.current(); ++dit ) | 394 | for ( ; dit.current(); ++dit ) |
445 | if(QFileInfo( dit.current()->file()).exists()) | 395 | if(QFileInfo( dit.current()->file()).exists()) |
@@ -451,20 +401,18 @@ void PlayListWidget::setDocument(const QString& fileref) { | |||
451 | qDebug(fileref); | 401 | qDebug(fileref); |
452 | fromSetDocument = TRUE; | 402 | fromSetDocument = TRUE; |
453 | if ( fileref.isNull() ) { | 403 | if ( fileref.isNull() ) { |
454 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 404 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
455 | return; | 405 | return; |
456 | } | 406 | } |
457 | // qDebug("setDocument "+fileref); | 407 | |
458 | if(fileref.find("m3u",0,TRUE) != -1) { //is m3u | 408 | if(fileref.find("m3u",0,TRUE) != -1) { //is m3u |
459 | readm3u( fileref); | 409 | readm3u( fileref); |
460 | } | 410 | } else if(fileref.find("pls",0,TRUE) != -1) { //is pls |
461 | else if(fileref.find("pls",0,TRUE) != -1) { //is pls | ||
462 | readPls( fileref); | 411 | readPls( fileref); |
463 | } | 412 | } else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist |
464 | else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist | ||
465 | clearList(); | 413 | clearList(); |
466 | loadList(DocLnk(fileref)); | 414 | loadList(DocLnk(fileref)); |
467 | d->selectedFiles->first(); | 415 | d->selectedFiles->first(); |
468 | } else { | 416 | } else { |
469 | clearList(); | 417 | clearList(); |
470 | addToSelection( DocLnk( fileref ) ); | 418 | addToSelection( DocLnk( fileref ) ); |
@@ -490,34 +438,19 @@ void PlayListWidget::useSelectedDocument() { | |||
490 | d->setDocumentUsed = FALSE; | 438 | d->setDocumentUsed = FALSE; |
491 | } | 439 | } |
492 | 440 | ||
493 | 441 | ||
494 | const DocLnk *PlayListWidget::current() { // this is fugly | 442 | const DocLnk *PlayListWidget::current() { // this is fugly |
495 | 443 | ||
496 | // if( fromSetDocument) { | ||
497 | // qDebug("from setDoc"); | ||
498 | // DocLnkSet files; | ||
499 | // Global::findDocuments(&files, "video/*;audio/*"); | ||
500 | // QListIterator<DocLnk> dit( files.children() ); | ||
501 | // for ( ; dit.current(); ++dit ) { | ||
502 | // if(dit.current()->linkFile() == setDocFileRef) { | ||
503 | // qDebug(setDocFileRef); | ||
504 | // return dit; | ||
505 | // } | ||
506 | // } | ||
507 | // } else | ||
508 | |||
509 | |||
510 | switch (tabWidget->currentPageIndex()) { | 444 | switch (tabWidget->currentPageIndex()) { |
511 | case 0: //playlist | 445 | case 0: //playlist |
512 | { | 446 | { |
513 | qDebug("playlist"); | 447 | qDebug("playlist"); |
514 | if ( mediaPlayerState->playlist() ) { | 448 | if ( mediaPlayerState->playlist() ) { |
515 | return d->selectedFiles->current(); | 449 | return d->selectedFiles->current(); |
516 | } | 450 | } else if ( d->setDocumentUsed && d->current ) { |
517 | else if ( d->setDocumentUsed && d->current ) { | ||
518 | return d->current; | 451 | return d->current; |
519 | } else { | 452 | } else { |
520 | return d->files->selected(); | 453 | return d->files->selected(); |
521 | } | 454 | } |
522 | } | 455 | } |
523 | break; | 456 | break; |
@@ -627,28 +560,29 @@ void PlayListWidget::saveList() { | |||
627 | filename = fileDlg->LineEdit1->text();//+".playlist"; | 560 | filename = fileDlg->LineEdit1->text();//+".playlist"; |
628 | // qDebug("saving playlist "+filename+".playlist"); | 561 | // qDebug("saving playlist "+filename+".playlist"); |
629 | Config cfg( filename +".playlist"); | 562 | Config cfg( filename +".playlist"); |
630 | writeConfig( cfg ); | 563 | writeConfig( cfg ); |
631 | 564 | ||
632 | DocLnk lnk; | 565 | DocLnk lnk; |
633 | // lnk.setComment( ""); | ||
634 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property | 566 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property |
635 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | 567 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D |
636 | lnk.setIcon("opieplayer/playlist2"); | 568 | lnk.setIcon("opieplayer/playlist2"); |
637 | lnk.setName( filename); //sets file name | 569 | lnk.setName( filename); //sets file name |
638 | // qDebug(filename); | 570 | // qDebug(filename); |
639 | if(!lnk.writeLink()) | 571 | if(!lnk.writeLink()) { |
640 | qDebug("Writing doclink did not work"); | 572 | qDebug("Writing doclink did not work"); |
641 | } | 573 | } |
574 | } | ||
642 | Config config( "OpiePlayer" ); | 575 | Config config( "OpiePlayer" ); |
643 | config.writeEntry("CurrentPlaylist",filename); | 576 | config.writeEntry("CurrentPlaylist",filename); |
644 | setCaption(tr("OpiePlayer: ")+filename); | 577 | setCaption(tr("OpiePlayer: ")+filename); |
645 | d->selectedFiles->first(); | 578 | d->selectedFiles->first(); |
646 | if(fileDlg) | 579 | if(fileDlg) { |
647 | delete fileDlg; | 580 | delete fileDlg; |
648 | } | 581 | } |
582 | } | ||
649 | 583 | ||
650 | void PlayListWidget::loadList( const DocLnk & lnk) { | 584 | void PlayListWidget::loadList( const DocLnk & lnk) { |
651 | QString name= lnk.name(); | 585 | QString name= lnk.name(); |
652 | // qDebug("currentList is "+name); | 586 | // qDebug("currentList is "+name); |
653 | if( name.length()>1) { | 587 | if( name.length()>1) { |
654 | setCaption("OpiePlayer: "+name); | 588 | setCaption("OpiePlayer: "+name); |
@@ -664,17 +598,18 @@ void PlayListWidget::loadList( const DocLnk & lnk) { | |||
664 | // d->selectedFiles->first(); | 598 | // d->selectedFiles->first(); |
665 | } | 599 | } |
666 | 600 | ||
667 | } | 601 | } |
668 | 602 | ||
669 | void PlayListWidget::setPlaylist( bool shown ) { | 603 | void PlayListWidget::setPlaylist( bool shown ) { |
670 | if ( shown ) | 604 | if ( shown ) { |
671 | d->playListFrame->show(); | 605 | d->playListFrame->show(); |
672 | else | 606 | } else { |
673 | d->playListFrame->hide(); | 607 | d->playListFrame->hide(); |
674 | } | 608 | } |
609 | } | ||
675 | 610 | ||
676 | void PlayListWidget::setView( char view ) { | 611 | void PlayListWidget::setView( char view ) { |
677 | if ( view == 'l' ) | 612 | if ( view == 'l' ) |
678 | showMaximized(); | 613 | showMaximized(); |
679 | else | 614 | else |
680 | hide(); | 615 | hide(); |
@@ -688,15 +623,12 @@ void PlayListWidget::addSelected() { | |||
688 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 623 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
689 | 624 | ||
690 | switch (tabWidget->currentPageIndex()) { | 625 | switch (tabWidget->currentPageIndex()) { |
691 | case 0: //playlist | 626 | case 0: //playlist |
692 | break; | 627 | break; |
693 | case 1: { //audio | 628 | case 1: { //audio |
694 | // QString entryName; | ||
695 | // entryName.sprintf( "File%i", i + 1 ); | ||
696 | // QString linkFile = cfg.readEntry( entryName ); | ||
697 | QListViewItemIterator it( audioView ); | 629 | QListViewItemIterator it( audioView ); |
698 | // iterate through all items of the listview | 630 | // iterate through all items of the listview |
699 | for ( ; it.current(); ++it ) { | 631 | for ( ; it.current(); ++it ) { |
700 | if ( it.current()->isSelected() ) { | 632 | if ( it.current()->isSelected() ) { |
701 | QListIterator<DocLnk> dit( files.children() ); | 633 | QListIterator<DocLnk> dit( files.children() ); |
702 | for ( ; dit.current(); ++dit ) { | 634 | for ( ; dit.current(); ++dit ) { |
@@ -718,42 +650,26 @@ void PlayListWidget::addSelected() { | |||
718 | QListIterator<DocLnk> dit( vFiles.children() ); | 650 | QListIterator<DocLnk> dit( vFiles.children() ); |
719 | for ( ; dit.current(); ++dit ) { | 651 | for ( ; dit.current(); ++dit ) { |
720 | if( dit.current()->name() == it.current()->text(0) ) { | 652 | if( dit.current()->name() == it.current()->text(0) ) { |
721 | d->selectedFiles->addToSelection( **dit ); | 653 | d->selectedFiles->addToSelection( **dit ); |
722 | } | 654 | } |
723 | } | 655 | } |
724 | |||
725 | videoView->setSelected( it.current(),FALSE); | 656 | videoView->setSelected( it.current(),FALSE); |
726 | } | 657 | } |
727 | } | 658 | } |
728 | // for ( int i = 0; i < noOfFiles; i++ ) { | ||
729 | // QString entryName; | ||
730 | // entryName.sprintf( "File%i", i + 1 ); | ||
731 | // QString linkFile = cfg.readEntry( entryName ); | ||
732 | // if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { | ||
733 | // int result= QMessageBox::warning(this,tr("OpiePlayer"), | ||
734 | // tr("This is all ready in your playlist.\nContinue?"), | ||
735 | // tr("Yes"),tr("No"),0,0,1); | ||
736 | // if (result !=0) | ||
737 | // return; | ||
738 | // } | ||
739 | // } | ||
740 | // addToSelection( videoView->selectedItem() ); | ||
741 | tabWidget->setCurrentPage(0); | 659 | tabWidget->setCurrentPage(0); |
742 | } | 660 | } |
743 | break; | 661 | break; |
744 | }; | 662 | }; |
745 | } | 663 | } |
746 | 664 | ||
747 | void PlayListWidget::removeSelected() { | 665 | void PlayListWidget::removeSelected() { |
748 | d->selectedFiles->removeSelected( ); | 666 | d->selectedFiles->removeSelected( ); |
749 | } | 667 | } |
750 | 668 | ||
751 | void PlayListWidget::playIt( QListViewItem *it) { | 669 | void PlayListWidget::playIt( QListViewItem *it) { |
752 | // d->setDocumentUsed = FALSE; | ||
753 | // mediaPlayerState->curPosition =0; | ||
754 | qDebug("playIt"); | 670 | qDebug("playIt"); |
755 | mediaPlayerState->setPlaying(FALSE); | 671 | mediaPlayerState->setPlaying(FALSE); |
756 | mediaPlayerState->setPlaying(TRUE); | 672 | mediaPlayerState->setPlaying(TRUE); |
757 | d->selectedFiles->unSelect(); | 673 | d->selectedFiles->unSelect(); |
758 | } | 674 | } |
759 | 675 | ||
@@ -832,18 +748,13 @@ void PlayListWidget::tabChanged(QWidget *widg) { | |||
832 | void PlayListWidget::btnPlay(bool b) { | 748 | void PlayListWidget::btnPlay(bool b) { |
833 | 749 | ||
834 | // mediaPlayerState->setPlaying(b); | 750 | // mediaPlayerState->setPlaying(b); |
835 | switch ( tabWidget->currentPageIndex()) { | 751 | switch ( tabWidget->currentPageIndex()) { |
836 | case 0: | 752 | case 0: |
837 | { | 753 | { |
838 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 | ||
839 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { | ||
840 | // QMessageBox::message("Note","You are trying to play\na malformed url."); | ||
841 | // } else { | ||
842 | mediaPlayerState->setPlaying(b); | 754 | mediaPlayerState->setPlaying(b); |
843 | // } | ||
844 | } | 755 | } |
845 | break; | 756 | break; |
846 | case 1: | 757 | case 1: |
847 | { | 758 | { |
848 | addToSelection( audioView->currentItem() ); | 759 | addToSelection( audioView->currentItem() ); |
849 | mediaPlayerState->setPlaying(b); | 760 | mediaPlayerState->setPlaying(b); |
@@ -879,55 +790,46 @@ void PlayListWidget::deletePlaylist() { | |||
879 | break; | 790 | break; |
880 | case 1: // Cancel | 791 | case 1: // Cancel |
881 | break; | 792 | break; |
882 | }; | 793 | }; |
883 | } | 794 | } |
884 | 795 | ||
885 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 796 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) { |
886 | { | ||
887 | switch (mouse) { | 797 | switch (mouse) { |
888 | case 1: | 798 | case 1: |
889 | break; | 799 | break; |
890 | case 2:{ | 800 | case 2:{ |
891 | |||
892 | QPopupMenu m; | 801 | QPopupMenu m; |
893 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 802 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
894 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 803 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
895 | m.insertSeparator(); | 804 | m.insertSeparator(); |
896 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) | ||
897 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 805 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
898 | |||
899 | m.exec( QCursor::pos() ); | 806 | m.exec( QCursor::pos() ); |
900 | } | 807 | } |
901 | break; | 808 | break; |
902 | }; | 809 | }; |
903 | } | 810 | } |
904 | 811 | ||
905 | void PlayListWidget::playSelected() | 812 | void PlayListWidget::playSelected() { |
906 | { | ||
907 | btnPlay( TRUE); | 813 | btnPlay( TRUE); |
908 | // d->selectedFiles->unSelect(); | ||
909 | } | 814 | } |
910 | 815 | ||
911 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 816 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) { |
912 | { | ||
913 | switch (mouse) { | 817 | switch (mouse) { |
914 | case 1: | 818 | case 1: |
915 | 819 | ||
916 | break; | 820 | break; |
917 | case 2:{ | 821 | case 2: |
822 | { | ||
918 | QPopupMenu m; | 823 | QPopupMenu m; |
919 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 824 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
920 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 825 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
921 | // m.insertSeparator(); | ||
922 | // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | ||
923 | m.exec( QCursor::pos() ); | 826 | m.exec( QCursor::pos() ); |
924 | } | 827 | } |
925 | break; | 828 | break; |
926 | }; | 829 | }; |
927 | |||
928 | } | 830 | } |
929 | 831 | ||
930 | void PlayListWidget::listDelete() { | 832 | void PlayListWidget::listDelete() { |
931 | Config cfg( "OpiePlayer" ); | 833 | Config cfg( "OpiePlayer" ); |
932 | cfg.setGroup("PlayList"); | 834 | cfg.setGroup("PlayList"); |
933 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 835 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
@@ -936,42 +838,27 @@ void PlayListWidget::listDelete() { | |||
936 | switch ( tabWidget->currentPageIndex()) { | 838 | switch ( tabWidget->currentPageIndex()) { |
937 | case 0: | 839 | case 0: |
938 | break; | 840 | break; |
939 | case 1: | 841 | case 1: |
940 | { | 842 | { |
941 | file = audioView->selectedItem()->text(0); | 843 | file = audioView->selectedItem()->text(0); |
942 | // Global::findDocuments(&files, "audio/*"); | ||
943 | // AppLnkSet appFiles; | ||
944 | QListIterator<DocLnk> dit( files.children() ); | 844 | QListIterator<DocLnk> dit( files.children() ); |
945 | for ( ; dit.current(); ++dit ) { | 845 | for ( ; dit.current(); ++dit ) { |
946 | if( dit.current()->name() == file) { | 846 | if( dit.current()->name() == file) { |
947 | // qDebug(file); | 847 | // qDebug(file); |
948 | LnkProperties prop( dit.current() ); | 848 | LnkProperties prop( dit.current() ); |
949 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | ||
950 | prop.showMaximized(); | 849 | prop.showMaximized(); |
951 | prop.exec(); | 850 | prop.exec(); |
952 | } | 851 | } |
953 | } | 852 | } |
954 | populateAudioView(); | 853 | populateAudioView(); |
955 | } | 854 | } |
956 | break; | 855 | break; |
957 | case 2: | 856 | case 2: |
958 | { | 857 | { |
959 | // file = videoView->selectedItem()->text(0); | 858 | |
960 | // for ( int i = 0; i < noOfFiles; i++ ) { | ||
961 | // QString entryName; | ||
962 | // entryName.sprintf( "File%i", i + 1 ); | ||
963 | // QString linkFile = cfg.readEntry( entryName ); | ||
964 | // AppLnk lnk( AppLnk(linkFile)); | ||
965 | // if( lnk.name() == file ) { | ||
966 | // LnkProperties prop( &lnk); | ||
967 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | ||
968 | // prop.showMaximized(); | ||
969 | // prop.exec(); | ||
970 | // } | ||
971 | // } | ||
972 | } | 859 | } |
973 | break; | 860 | break; |
974 | }; | 861 | }; |
975 | } | 862 | } |
976 | 863 | ||
977 | void PlayListWidget::scanForAudio() { | 864 | void PlayListWidget::scanForAudio() { |
@@ -1055,47 +942,42 @@ void PlayListWidget::openFile() { | |||
1055 | QString filename, name; | 942 | QString filename, name; |
1056 | InputDialog *fileDlg; | 943 | InputDialog *fileDlg; |
1057 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 944 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
1058 | fileDlg->exec(); | 945 | fileDlg->exec(); |
1059 | if( fileDlg->result() == 1 ) { | 946 | if( fileDlg->result() == 1 ) { |
1060 | filename = fileDlg->LineEdit1->text(); | 947 | filename = fileDlg->LineEdit1->text(); |
1061 | // http://205.188.234.129:8030 | 948 | |
1062 | // http://66.28.68.70:8000 | ||
1063 | // filename.replace(QRegExp("%20")," "); | ||
1064 | if(filename.find(" ",0,TRUE) != -1 || filename.find("%20",0,TRUE) != -1) { | ||
1065 | QMessageBox::message("Note","Spaces in urls are not allowed."); | ||
1066 | return; | ||
1067 | } else { | ||
1068 | qDebug("Selected filename is "+filename); | 949 | qDebug("Selected filename is "+filename); |
1069 | if(filename.right(3) == "m3u") | 950 | if(filename.right(3) == "m3u") { |
1070 | readm3u( filename); | 951 | readm3u( filename); |
1071 | else if(filename.right(3) == "pls") | 952 | } else if(filename.right(3) == "pls") { |
1072 | readPls( filename); | 953 | readPls( filename); |
1073 | else { | 954 | } else { |
1074 | DocLnk lnk; | 955 | DocLnk lnk; |
1075 | 956 | ||
1076 | lnk.setName(filename); //sets file name | 957 | lnk.setName(filename); //sets file name |
1077 | if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3") | 958 | // probably not needed anymore either |
959 | if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3") { | ||
1078 | filename += "/"; | 960 | filename += "/"; |
961 | } | ||
1079 | lnk.setFile(filename); //sets File property | 962 | lnk.setFile(filename); //sets File property |
1080 | 963 | ||
1081 | lnk.setType("audio/x-mpegurl"); | 964 | lnk.setType("audio/x-mpegurl"); |
1082 | lnk.setExec("opieplayer"); | 965 | lnk.setExec("opieplayer"); |
1083 | lnk.setIcon("opieplayer/MPEGPlayer"); | 966 | lnk.setIcon("opieplayer/MPEGPlayer"); |
1084 | 967 | ||
1085 | if(!lnk.writeLink()) | 968 | if(!lnk.writeLink()) { |
1086 | qDebug("Writing doclink did not work"); | 969 | qDebug("Writing doclink did not work"); |
1087 | d->selectedFiles->addToSelection( lnk); | ||
1088 | // if(fileDlg2) | ||
1089 | // delete fileDlg2; | ||
1090 | } | 970 | } |
971 | d->selectedFiles->addToSelection( lnk); | ||
1091 | } | 972 | } |
1092 | } | 973 | } |
1093 | if(fileDlg) | 974 | if(fileDlg) { |
1094 | delete fileDlg; | 975 | delete fileDlg; |
1095 | } | 976 | } |
977 | } | ||
1096 | 978 | ||
1097 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | 979 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) |
1098 | { | 980 | { |
1099 | switch ( e->key() ) { | 981 | switch ( e->key() ) { |
1100 | ////////////////////////////// Zaurus keys | 982 | ////////////////////////////// Zaurus keys |
1101 | case Key_F9: //activity | 983 | case Key_F9: //activity |
@@ -1207,53 +1089,45 @@ void PlayListWidget::readm3u(const QString &filename) { | |||
1207 | 1089 | ||
1208 | if(f.open(IO_ReadOnly)) { | 1090 | if(f.open(IO_ReadOnly)) { |
1209 | QTextStream t(&f); | 1091 | QTextStream t(&f); |
1210 | QString s;//, first, second; | 1092 | QString s;//, first, second; |
1211 | int i=0; | 1093 | int i=0; |
1212 | while ( !t.atEnd()) { | 1094 | while ( !t.atEnd()) { |
1213 | // Lview->insertLine(t.readLine(),-1); | ||
1214 | s=t.readLine(); | 1095 | s=t.readLine(); |
1215 | if(s.find(" ",0,TRUE) != -1 || s.find("%20",0,TRUE) != -1) { | 1096 | |
1216 | QMessageBox::message("Note","Spaces in urls are not allowed."); | 1097 | if(s.find("#",0,TRUE) == -1) { |
1217 | } | ||
1218 | else if(s.find("#",0,TRUE) == -1) { | ||
1219 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat | 1098 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat |
1220 | if(s.left(2) == "E:" || s.left(2) == "P:") { | 1099 | if(s.left(2) == "E:" || s.left(2) == "P:") { |
1221 | s=s.right(s.length()-2); | 1100 | s=s.right(s.length()-2); |
1222 | DocLnk lnk( s ); | 1101 | DocLnk lnk( s ); |
1223 | QFileInfo f(s); | 1102 | QFileInfo f(s); |
1224 | QString name = f.baseName(); | 1103 | QString name = f.baseName(); |
1225 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | 1104 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); |
1226 | lnk.setName( name); | 1105 | lnk.setName( name); |
1227 | s=s.replace( QRegExp("\\"),"/"); | 1106 | s=s.replace( QRegExp("\\"),"/"); |
1228 | lnk.setFile( s); | 1107 | lnk.setFile( s); |
1229 | lnk.writeLink(); | 1108 | lnk.writeLink(); |
1230 | // lnk.setIcon(opieplayer/MPEGPlayer); | ||
1231 | qDebug("add "+name); | 1109 | qDebug("add "+name); |
1232 | d->selectedFiles->addToSelection( lnk); | 1110 | d->selectedFiles->addToSelection( lnk); |
1233 | } else { // is url | 1111 | } else { // is url |
1234 | |||
1235 | s.replace(QRegExp("%20")," "); | 1112 | s.replace(QRegExp("%20")," "); |
1236 | DocLnk lnk( s); | 1113 | DocLnk lnk( s); |
1237 | QString name; | 1114 | QString name; |
1238 | if(name.left(4)=="http") | 1115 | if(name.left(4)=="http") { |
1239 | name = s.right( s.length() - 7); | 1116 | name = s.right( s.length() - 7); |
1240 | else | 1117 | } else { |
1241 | name=s; | 1118 | name=s; |
1242 | // name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | 1119 | } |
1243 | lnk.setName(name); | 1120 | lnk.setName(name); |
1244 | if(s.at(s.length()-4) == '.') | 1121 | if(s.at(s.length()-4) == '.') { |
1245 | lnk.setFile( s); | 1122 | lnk.setFile( s); |
1246 | else | 1123 | } else { |
1247 | lnk.setFile( s+"/"); | 1124 | lnk.setFile( s+"/"); |
1248 | // lnk.setFile( filename); | 1125 | } |
1249 | // lnk.setComment( s+"/"); | ||
1250 | lnk.setType("audio/x-mpegurl"); | 1126 | lnk.setType("audio/x-mpegurl"); |
1251 | lnk.writeLink(); | 1127 | lnk.writeLink(); |
1252 | // lnk.setIcon( "opieplayer/MPEGPlayer"); | ||
1253 | // qDebug("add "+s); | ||
1254 | d->selectedFiles->addToSelection( lnk); | 1128 | d->selectedFiles->addToSelection( lnk); |
1255 | } | 1129 | } |
1256 | i++; | 1130 | i++; |
1257 | } | 1131 | } |
1258 | } | 1132 | } |
1259 | } | 1133 | } |
@@ -1311,26 +1185,21 @@ void PlayListWidget::readPls(const QString &filename) { | |||
1311 | // numberofentries=2 | 1185 | // numberofentries=2 |
1312 | // File1=http | 1186 | // File1=http |
1313 | // Title | 1187 | // Title |
1314 | // Length | 1188 | // Length |
1315 | // Version | 1189 | // Version |
1316 | // File2=http | 1190 | // File2=http |
1317 | |||
1318 | s=s.replace( QRegExp("\\"),"/"); | 1191 | s=s.replace( QRegExp("\\"),"/"); |
1319 | DocLnk lnk( s ); | 1192 | DocLnk lnk( s ); |
1320 | QFileInfo f(s); | 1193 | QFileInfo f(s); |
1321 | QString name = f.baseName(); | 1194 | QString name = f.baseName(); |
1322 | if(name.left(4)=="http") | 1195 | if(name.left(4)=="http") |
1323 | name = s.right( s.length() - 7); | 1196 | name = s.right( s.length() - 7); |
1324 | else | 1197 | else |
1325 | name=s; | 1198 | name=s; |
1326 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | 1199 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); |
1327 | // QFileInfo f(s); | ||
1328 | // QString name = f.baseName(); | ||
1329 | // name = name.left(name.length()-4); | ||
1330 | // name = name.right(name.findRev("/",0,TRUE)); | ||
1331 | lnk.setName( name); | 1200 | lnk.setName( name); |
1332 | if(s.at(s.length()-4) == '.') // if this is probably a file | 1201 | if(s.at(s.length()-4) == '.') // if this is probably a file |
1333 | lnk.setFile( s); | 1202 | lnk.setFile( s); |
1334 | else { //if its a url | 1203 | else { //if its a url |
1335 | if( name.right(1).find('/') == -1) | 1204 | if( name.right(1).find('/') == -1) |
1336 | s+="/"; | 1205 | s+="/"; |
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.cpp b/noncore/multimedia/opieplayer2/xinecontrol.cpp index 5b674f8..7407e4e 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.cpp +++ b/noncore/multimedia/opieplayer2/xinecontrol.cpp | |||
@@ -1,10 +1,11 @@ | |||
1 | 1 | ||
2 | #include "xinecontrol.h" | 2 | #include "xinecontrol.h" |
3 | #include "mediaplayerstate.h" | 3 | #include "mediaplayerstate.h" |
4 | 4 | ||
5 | |||
5 | extern MediaPlayerState *mediaPlayerState; | 6 | extern MediaPlayerState *mediaPlayerState; |
6 | 7 | ||
7 | XineControl::XineControl( QObject *parent, const char *name ) | 8 | XineControl::XineControl( QObject *parent, const char *name ) |
8 | : QObject( parent, name ) { | 9 | : QObject( parent, name ) { |
9 | libXine = new XINE::Lib(); | 10 | libXine = new XINE::Lib(); |
10 | 11 | ||
@@ -19,30 +20,37 @@ XineControl::~XineControl() { | |||
19 | } | 20 | } |
20 | 21 | ||
21 | void XineControl::play( const QString& fileName ) { | 22 | void XineControl::play( const QString& fileName ) { |
22 | libXine->play( fileName ); | 23 | libXine->play( fileName ); |
23 | mediaPlayerState->setPlaying( true ); | 24 | mediaPlayerState->setPlaying( true ); |
24 | // default to audio view until we know how to handle video | 25 | // default to audio view until we know how to handle video |
25 | mediaPlayerState->setView('a'); | 26 | // MediaDetect mdetect; |
26 | // determines of slider is shown | 27 | char whichGui = mdetect.videoOrAudio( fileName ); |
27 | // mediaPlayerState->setIsStreaming( false ); | 28 | if (whichGui == 'f') { |
28 | // hier dann schaun welcher view | 29 | qDebug("Nicht erkannter Dateityp"); |
30 | return; | ||
31 | } | ||
32 | |||
33 | // which gui (video / audio) | ||
34 | mediaPlayerState->setView( whichGui ); | ||
35 | |||
36 | // determine if slider is shown | ||
37 | mediaPlayerState->setIsStreaming( mdetect.isStreaming( fileName ) ); | ||
29 | } | 38 | } |
30 | 39 | ||
31 | void XineControl::stop( bool isSet ) { | 40 | void XineControl::stop( bool isSet ) { |
32 | if ( !isSet) { | 41 | if ( !isSet) { |
33 | libXine->stop(); | 42 | libXine->stop(); |
34 | mediaPlayerState->setNext(); | 43 | mediaPlayerState->setList(); |
35 | //mediaPlayerState->setPlaying( false ); | 44 | //mediaPlayerState->setPlaying( false ); |
36 | } else { | 45 | } else { |
37 | // play again | 46 | // play again |
38 | } | 47 | } |
39 | } | 48 | } |
40 | 49 | ||
41 | void XineControl::pause( bool isSet) { | 50 | void XineControl::pause( bool isSet) { |
42 | |||
43 | libXine->pause(); | 51 | libXine->pause(); |
44 | } | 52 | } |
45 | 53 | ||
46 | int XineControl::currentTime() { | 54 | int XineControl::currentTime() { |
47 | // todo: jede sekunde überprüfen | 55 | // todo: jede sekunde überprüfen |
48 | m_currentTime = libXine->currentTime(); | 56 | m_currentTime = libXine->currentTime(); |
diff --git a/noncore/multimedia/opieplayer2/xinecontrol.h b/noncore/multimedia/opieplayer2/xinecontrol.h index e45f1df..aab00cd 100644 --- a/noncore/multimedia/opieplayer2/xinecontrol.h +++ b/noncore/multimedia/opieplayer2/xinecontrol.h | |||
@@ -1,11 +1,12 @@ | |||
1 | 1 | ||
2 | #ifndef XINECONTROL_H | 2 | #ifndef XINECONTROL_H |
3 | #define XINECONTROL_H | 3 | #define XINECONTROL_H |
4 | 4 | ||
5 | #include "lib.h" | 5 | #include "lib.h" |
6 | #include "mediadetect.h" | ||
6 | #include <qobject.h> | 7 | #include <qobject.h> |
7 | 8 | ||
8 | class XineControl : public QObject { | 9 | class XineControl : public QObject { |
9 | Q_OBJECT | 10 | Q_OBJECT |
10 | public: | 11 | public: |
11 | XineControl( QObject *parent = 0, const char *name =0 ); | 12 | XineControl( QObject *parent = 0, const char *name =0 ); |
@@ -22,12 +23,13 @@ public slots: | |||
22 | void length(); | 23 | void length(); |
23 | 24 | ||
24 | int position(); | 25 | int position(); |
25 | 26 | ||
26 | private: | 27 | private: |
27 | XINE::Lib *libXine; | 28 | XINE::Lib *libXine; |
29 | MediaDetect mdetect; | ||
28 | int m_length; | 30 | int m_length; |
29 | int m_currentTime; | 31 | int m_currentTime; |
30 | int m_position; | 32 | int m_position; |
31 | 33 | ||
32 | signals: | 34 | signals: |
33 | void positionChanged( int position ); | 35 | void positionChanged( int position ); |