author | llornkcor <llornkcor> | 2002-05-31 00:24:18 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-05-31 00:24:18 (UTC) |
commit | 294fecd1c15c4940bdab8566e5afaee9f305abb6 (patch) (unidiff) | |
tree | 47860d13c0aeffb0b9afad96d669d8935769fe7a /core/multimedia | |
parent | 706841997a5d466f3b873ed79102e4abe0d745ae (diff) | |
download | opie-294fecd1c15c4940bdab8566e5afaee9f305abb6.zip opie-294fecd1c15c4940bdab8566e5afaee9f305abb6.tar.gz opie-294fecd1c15c4940bdab8566e5afaee9f305abb6.tar.bz2 |
sped up startup time, and fixed segfault on exit
-rw-r--r-- | core/multimedia/opieplayer/mediaplayer.h | 2 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 68 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.h | 3 |
3 files changed, 52 insertions, 21 deletions
diff --git a/core/multimedia/opieplayer/mediaplayer.h b/core/multimedia/opieplayer/mediaplayer.h index cf9daea..8f9a0ee 100644 --- a/core/multimedia/opieplayer/mediaplayer.h +++ b/core/multimedia/opieplayer/mediaplayer.h | |||
@@ -35,27 +35,27 @@ public: | |||
35 | MediaPlayer( QObject *parent, const char *name ); | 35 | MediaPlayer( QObject *parent, const char *name ); |
36 | ~MediaPlayer(); | 36 | ~MediaPlayer(); |
37 | 37 | ||
38 | private slots: | 38 | private slots: |
39 | void setPlaying( bool ); | 39 | void setPlaying( bool ); |
40 | void pauseCheck( bool ); | 40 | void pauseCheck( bool ); |
41 | void play(); | 41 | void play(); |
42 | void next(); | 42 | void next(); |
43 | void prev(); | 43 | void prev(); |
44 | void startIncreasingVolume(); | 44 | void startIncreasingVolume(); |
45 | void startDecreasingVolume(); | 45 | void startDecreasingVolume(); |
46 | void stopChangingVolume(); | 46 | void stopChangingVolume(); |
47 | void cleanUp(); | ||
47 | 48 | ||
48 | protected: | 49 | protected: |
49 | void timerEvent( QTimerEvent *e ); | 50 | void timerEvent( QTimerEvent *e ); |
50 | void keyReleaseEvent( QKeyEvent *e); | 51 | void keyReleaseEvent( QKeyEvent *e); |
51 | void doBlank(); | 52 | void doBlank(); |
52 | void doUnblank(); | 53 | void doUnblank(); |
53 | void cleanUp(); | ||
54 | private: | 54 | private: |
55 | int volumeDirection; | 55 | int volumeDirection; |
56 | const DocLnk *currentFile; | 56 | const DocLnk *currentFile; |
57 | }; | 57 | }; |
58 | 58 | ||
59 | 59 | ||
60 | #endif // MEDIA_PLAYER_H | 60 | #endif // MEDIA_PLAYER_H |
61 | 61 | ||
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 7a79be1..78c2822 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -23,25 +23,24 @@ | |||
23 | 23 | ||
24 | #include <qpe/qpemenubar.h> | 24 | #include <qpe/qpemenubar.h> |
25 | #include <qpe/qpetoolbar.h> | 25 | #include <qpe/qpetoolbar.h> |
26 | #include <qpe/fileselector.h> | 26 | #include <qpe/fileselector.h> |
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | #include <qpe/lnkproperties.h> | 28 | #include <qpe/lnkproperties.h> |
29 | #include <qpe/storage.h> | 29 | #include <qpe/storage.h> |
30 | 30 | ||
31 | #include <qpe/applnk.h> | 31 | #include <qpe/applnk.h> |
32 | #include <qpe/config.h> | 32 | #include <qpe/config.h> |
33 | #include <qpe/global.h> | 33 | #include <qpe/global.h> |
34 | #include <qpe/resource.h> | 34 | #include <qpe/resource.h> |
35 | |||
36 | #include <qaction.h> | 35 | #include <qaction.h> |
37 | #include <qcursor.h> | 36 | #include <qcursor.h> |
38 | #include <qimage.h> | 37 | #include <qimage.h> |
39 | #include <qfile.h> | 38 | #include <qfile.h> |
40 | #include <qdir.h> | 39 | #include <qdir.h> |
41 | #include <qlayout.h> | 40 | #include <qlayout.h> |
42 | #include <qlabel.h> | 41 | #include <qlabel.h> |
43 | #include <qlist.h> | 42 | #include <qlist.h> |
44 | #include <qlistbox.h> | 43 | #include <qlistbox.h> |
45 | #include <qmainwindow.h> | 44 | #include <qmainwindow.h> |
46 | #include <qmessagebox.h> | 45 | #include <qmessagebox.h> |
47 | #include <qtoolbutton.h> | 46 | #include <qtoolbutton.h> |
@@ -122,24 +121,26 @@ public: | |||
122 | } | 121 | } |
123 | }; | 122 | }; |
124 | 123 | ||
125 | 124 | ||
126 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 125 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
127 | : QMainWindow( parent, name, fl ) { | 126 | : QMainWindow( parent, name, fl ) { |
128 | 127 | ||
129 | d = new PlayListWidgetPrivate; | 128 | d = new PlayListWidgetPrivate; |
130 | d->setDocumentUsed = FALSE; | 129 | d->setDocumentUsed = FALSE; |
131 | d->current = NULL; | 130 | d->current = NULL; |
132 | fromSetDocument = FALSE; | 131 | fromSetDocument = FALSE; |
133 | insanityBool=FALSE; | 132 | insanityBool=FALSE; |
133 | audioScan = FALSE; | ||
134 | videoScan = FALSE; | ||
134 | // menuTimer = new QTimer( this ,"menu timer"), | 135 | // menuTimer = new QTimer( this ,"menu timer"), |
135 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); | 136 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); |
136 | 137 | ||
137 | setBackgroundMode( PaletteButton ); | 138 | setBackgroundMode( PaletteButton ); |
138 | 139 | ||
139 | setCaption( tr("OpiePlayer") ); | 140 | setCaption( tr("OpiePlayer") ); |
140 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); | 141 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); |
141 | 142 | ||
142 | setToolBarsMovable( FALSE ); | 143 | setToolBarsMovable( FALSE ); |
143 | 144 | ||
144 | // Create Toolbar | 145 | // Create Toolbar |
145 | QPEToolBar *toolbar = new QPEToolBar( this ); | 146 | QPEToolBar *toolbar = new QPEToolBar( this ); |
@@ -172,24 +173,27 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
172 | tbDeletePlaylist->hide(); | 173 | tbDeletePlaylist->hide(); |
173 | 174 | ||
174 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 175 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
175 | menu->insertItem( tr( "File" ), pmPlayList ); | 176 | menu->insertItem( tr( "File" ), pmPlayList ); |
176 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 177 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
177 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 178 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
178 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 179 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
179 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 180 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
180 | // pmPlayList->insertSeparator(-1); | 181 | // pmPlayList->insertSeparator(-1); |
181 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 182 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
182 | pmPlayList->insertSeparator(-1); | 183 | pmPlayList->insertSeparator(-1); |
183 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); | 184 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); |
185 | pmPlayList->insertSeparator(-1); | ||
186 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); | ||
187 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); | ||
184 | 188 | ||
185 | QPopupMenu *pmView = new QPopupMenu( this ); | 189 | QPopupMenu *pmView = new QPopupMenu( this ); |
186 | menu->insertItem( tr( "View" ), pmView ); | 190 | menu->insertItem( tr( "View" ), pmView ); |
187 | 191 | ||
188 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); | 192 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); |
189 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); | 193 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); |
190 | fullScreenButton->addTo(pmView); | 194 | fullScreenButton->addTo(pmView); |
191 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); | 195 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); |
192 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); | 196 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); |
193 | scaleButton->addTo(pmView); | 197 | scaleButton->addTo(pmView); |
194 | 198 | ||
195 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 199 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
@@ -245,62 +249,61 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | |||
245 | audioView->setSelectionMode( QListView::Extended); | 249 | audioView->setSelectionMode( QListView::Extended); |
246 | 250 | ||
247 | tabWidget->insertTab(aTab,tr("Audio")); | 251 | tabWidget->insertTab(aTab,tr("Audio")); |
248 | 252 | ||
249 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | 253 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); |
250 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 254 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
251 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 255 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
252 | 256 | ||
253 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), | 257 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), |
254 | this,SLOT( playIt( QListViewItem *)) ); | 258 | this,SLOT( playIt( QListViewItem *)) ); |
255 | 259 | ||
256 | // audioView | 260 | // audioView |
257 | populateAudioView(); | 261 | // populateAudioView(); |
258 | // videowidget | 262 | // videowidget |
259 | 263 | ||
260 | QWidget *vTab; | 264 | QWidget *vTab; |
261 | vTab = new QWidget( tabWidget, "vTab" ); | 265 | vTab = new QWidget( tabWidget, "vTab" ); |
262 | videoView = new QListView( vTab, "Videoview" ); | 266 | videoView = new QListView( vTab, "Videoview" ); |
263 | videoView->setMinimumSize(233,260); | 267 | videoView->setMinimumSize(233,260); |
264 | 268 | ||
265 | videoView->addColumn(tr("Title"),140); | 269 | videoView->addColumn(tr("Title"),140); |
266 | videoView->addColumn(tr("Size"),-1); | 270 | videoView->addColumn(tr("Size"),-1); |
267 | videoView->addColumn(tr("Media"),-1); | 271 | videoView->addColumn(tr("Media"),-1); |
268 | videoView->setColumnAlignment(1, Qt::AlignRight); | 272 | videoView->setColumnAlignment(1, Qt::AlignRight); |
269 | videoView->setColumnAlignment(2, Qt::AlignRight); | 273 | videoView->setColumnAlignment(2, Qt::AlignRight); |
270 | videoView->setAllColumnsShowFocus(TRUE); | 274 | videoView->setAllColumnsShowFocus(TRUE); |
271 | videoView->setMultiSelection( TRUE ); | 275 | videoView->setMultiSelection( TRUE ); |
272 | videoView->setSelectionMode( QListView::Extended); | 276 | videoView->setSelectionMode( QListView::Extended); |
273 | 277 | ||
274 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 278 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
275 | 279 | ||
276 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 280 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
277 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 281 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
278 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), | 282 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), |
279 | this,SLOT( playIt( QListViewItem *)) ); | 283 | this,SLOT( playIt( QListViewItem *)) ); |
280 | 284 | ||
281 | tabWidget->insertTab( vTab,tr("Video")); | 285 | tabWidget->insertTab( vTab,tr("Video")); |
282 | populateVideoView(); | 286 | // populateVideoView(); |
283 | 287 | ||
284 | //playlists list | 288 | //playlists list |
285 | QWidget *LTab; | 289 | QWidget *LTab; |
286 | LTab = new QWidget( tabWidget, "LTab" ); | 290 | LTab = new QWidget( tabWidget, "LTab" ); |
287 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | 291 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy |
288 | playLists->setMinimumSize(233,260);; | 292 | playLists->setMinimumSize(233,260); |
289 | tabWidget->insertTab(LTab,tr("Lists")); | 293 | tabWidget->insertTab(LTab,tr("Lists")); |
290 | 294 | ||
291 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 295 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
292 | // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | 296 | // connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); |
293 | 297 | ||
294 | |||
295 | // add the library area | 298 | // add the library area |
296 | 299 | ||
297 | // connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), | 300 | // connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), |
298 | // this, SLOT( fauxPlay( QListViewItem *) ) ); | 301 | // this, SLOT( fauxPlay( QListViewItem *) ) ); |
299 | // connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), | 302 | // connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), |
300 | // this, SLOT( fauxPlay( QListViewItem *)) ); | 303 | // this, SLOT( fauxPlay( QListViewItem *)) ); |
301 | 304 | ||
302 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); | 305 | // connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); |
303 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); | 306 | // connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); |
304 | 307 | ||
305 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 308 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
306 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 309 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
@@ -424,26 +427,24 @@ void PlayListWidget::clearList() { | |||
424 | 427 | ||
425 | 428 | ||
426 | void PlayListWidget::addAllToList() { | 429 | void PlayListWidget::addAllToList() { |
427 | DocLnkSet filesAll; | 430 | DocLnkSet filesAll; |
428 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 431 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
429 | QListIterator<DocLnk> Adit( filesAll.children() ); | 432 | QListIterator<DocLnk> Adit( filesAll.children() ); |
430 | for ( ; Adit.current(); ++Adit ) | 433 | for ( ; Adit.current(); ++Adit ) |
431 | d->selectedFiles->addToSelection( **Adit ); | 434 | d->selectedFiles->addToSelection( **Adit ); |
432 | } | 435 | } |
433 | 436 | ||
434 | 437 | ||
435 | void PlayListWidget::addAllMusicToList() { | 438 | void PlayListWidget::addAllMusicToList() { |
436 | // DocLnkSet files; | ||
437 | // Global::findDocuments(&files, "audio/*"); | ||
438 | QListIterator<DocLnk> dit( files.children() ); | 439 | QListIterator<DocLnk> dit( files.children() ); |
439 | for ( ; dit.current(); ++dit ) | 440 | for ( ; dit.current(); ++dit ) |
440 | d->selectedFiles->addToSelection( **dit ); | 441 | d->selectedFiles->addToSelection( **dit ); |
441 | } | 442 | } |
442 | 443 | ||
443 | 444 | ||
444 | void PlayListWidget::addAllVideoToList() { | 445 | void PlayListWidget::addAllVideoToList() { |
445 | QListIterator<DocLnk> dit( vFiles.children() ); | 446 | QListIterator<DocLnk> dit( vFiles.children() ); |
446 | for ( ; dit.current(); ++dit ) | 447 | for ( ; dit.current(); ++dit ) |
447 | d->selectedFiles->addToSelection( **dit ); | 448 | d->selectedFiles->addToSelection( **dit ); |
448 | } | 449 | } |
449 | 450 | ||
@@ -518,39 +519,37 @@ const DocLnk *PlayListWidget::current() { // this is fugly | |||
518 | return d->selectedFiles->current(); | 519 | return d->selectedFiles->current(); |
519 | } | 520 | } |
520 | else if ( d->setDocumentUsed && d->current ) { | 521 | else if ( d->setDocumentUsed && d->current ) { |
521 | return d->current; | 522 | return d->current; |
522 | } else { | 523 | } else { |
523 | return d->files->selected(); | 524 | return d->files->selected(); |
524 | } | 525 | } |
525 | } | 526 | } |
526 | break; | 527 | break; |
527 | case 1://audio | 528 | case 1://audio |
528 | { | 529 | { |
529 | qDebug("audioView"); | 530 | qDebug("audioView"); |
530 | // Global::findDocuments(&files, "audio/*"); | ||
531 | QListIterator<DocLnk> dit( files.children() ); | 531 | QListIterator<DocLnk> dit( files.children() ); |
532 | for ( ; dit.current(); ++dit ) { | 532 | for ( ; dit.current(); ++dit ) { |
533 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { | 533 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { |
534 | qDebug("here"); | 534 | qDebug("here"); |
535 | insanityBool=TRUE; | 535 | insanityBool=TRUE; |
536 | return dit; | 536 | return dit; |
537 | } | 537 | } |
538 | } | 538 | } |
539 | } | 539 | } |
540 | break; | 540 | break; |
541 | case 2: // video | 541 | case 2: // video |
542 | { | 542 | { |
543 | qDebug("videoView"); | 543 | qDebug("videoView"); |
544 | // Global::findDocuments(&vFiles, "video/*"); | ||
545 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 544 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
546 | for ( ; Vdit.current(); ++Vdit ) { | 545 | for ( ; Vdit.current(); ++Vdit ) { |
547 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { | 546 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { |
548 | insanityBool=TRUE; | 547 | insanityBool=TRUE; |
549 | return Vdit; | 548 | return Vdit; |
550 | } | 549 | } |
551 | } | 550 | } |
552 | } | 551 | } |
553 | break; | 552 | break; |
554 | }; | 553 | }; |
555 | return 0; | 554 | return 0; |
556 | } | 555 | } |
@@ -794,50 +793,53 @@ void PlayListWidget::tabChanged(QWidget *widg) { | |||
794 | 793 | ||
795 | switch ( tabWidget->currentPageIndex()) { | 794 | switch ( tabWidget->currentPageIndex()) { |
796 | case 0: | 795 | case 0: |
797 | { | 796 | { |
798 | if( !tbDeletePlaylist->isHidden()) | 797 | if( !tbDeletePlaylist->isHidden()) |
799 | tbDeletePlaylist->hide(); | 798 | tbDeletePlaylist->hide(); |
800 | d->tbRemoveFromList->setEnabled(TRUE); | 799 | d->tbRemoveFromList->setEnabled(TRUE); |
801 | d->tbAddToList->setEnabled(FALSE); | 800 | d->tbAddToList->setEnabled(FALSE); |
802 | } | 801 | } |
803 | break; | 802 | break; |
804 | case 1: | 803 | case 1: |
805 | { | 804 | { |
805 | audioView->clear(); | ||
806 | populateAudioView(); | ||
807 | |||
806 | if( !tbDeletePlaylist->isHidden()) | 808 | if( !tbDeletePlaylist->isHidden()) |
807 | tbDeletePlaylist->hide(); | 809 | tbDeletePlaylist->hide(); |
808 | d->tbRemoveFromList->setEnabled(FALSE); | 810 | d->tbRemoveFromList->setEnabled(FALSE); |
809 | d->tbAddToList->setEnabled(TRUE); | 811 | d->tbAddToList->setEnabled(TRUE); |
810 | } | 812 | } |
811 | break; | 813 | break; |
812 | case 2: | 814 | case 2: |
813 | { | 815 | { |
816 | videoView->clear(); | ||
817 | populateVideoView(); | ||
814 | if( !tbDeletePlaylist->isHidden()) | 818 | if( !tbDeletePlaylist->isHidden()) |
815 | tbDeletePlaylist->hide(); | 819 | tbDeletePlaylist->hide(); |
816 | d->tbRemoveFromList->setEnabled(FALSE); | 820 | d->tbRemoveFromList->setEnabled(FALSE); |
817 | d->tbAddToList->setEnabled(TRUE); | 821 | d->tbAddToList->setEnabled(TRUE); |
818 | } | 822 | } |
819 | break; | 823 | break; |
820 | case 3: | 824 | case 3: |
821 | { | 825 | { |
822 | if( tbDeletePlaylist->isHidden()) | 826 | if( tbDeletePlaylist->isHidden()) |
823 | tbDeletePlaylist->show(); | 827 | tbDeletePlaylist->show(); |
824 | playLists->reread(); | 828 | playLists->reread(); |
825 | } | 829 | } |
826 | break; | 830 | break; |
827 | }; | 831 | }; |
828 | } | 832 | } |
829 | 833 | ||
830 | |||
831 | |||
832 | void PlayListWidget::btnPlay(bool b) { | 834 | void PlayListWidget::btnPlay(bool b) { |
833 | 835 | ||
834 | // mediaPlayerState->setPlaying(b); | 836 | // mediaPlayerState->setPlaying(b); |
835 | switch ( tabWidget->currentPageIndex()) { | 837 | switch ( tabWidget->currentPageIndex()) { |
836 | case 0: | 838 | case 0: |
837 | { | 839 | { |
838 | mediaPlayerState->setPlaying(b); | 840 | mediaPlayerState->setPlaying(b); |
839 | } | 841 | } |
840 | break; | 842 | break; |
841 | case 1: | 843 | case 1: |
842 | { | 844 | { |
843 | // if(audioView->selectedItem()) { | 845 | // if(audioView->selectedItem()) { |
@@ -871,25 +873,24 @@ void PlayListWidget::btnPlay(bool b) { | |||
871 | void PlayListWidget::deletePlaylist() { | 873 | void PlayListWidget::deletePlaylist() { |
872 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 874 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
873 | (tr("You really want to delete\nthis playlist?")), | 875 | (tr("You really want to delete\nthis playlist?")), |
874 | (tr("Yes")), (tr("No")), 0 )){ | 876 | (tr("Yes")), (tr("No")), 0 )){ |
875 | case 0: // Yes clicked, | 877 | case 0: // Yes clicked, |
876 | QFile().remove(playLists->selected()->file()); | 878 | QFile().remove(playLists->selected()->file()); |
877 | QFile().remove(playLists->selected()->linkFile()); | 879 | QFile().remove(playLists->selected()->linkFile()); |
878 | playLists->reread(); | 880 | playLists->reread(); |
879 | break; | 881 | break; |
880 | case 1: // Cancel | 882 | case 1: // Cancel |
881 | break; | 883 | break; |
882 | }; | 884 | }; |
883 | |||
884 | } | 885 | } |
885 | 886 | ||
886 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) | 887 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) |
887 | { | 888 | { |
888 | switch (mouse) { | 889 | switch (mouse) { |
889 | case 1: | 890 | case 1: |
890 | break; | 891 | break; |
891 | case 2:{ | 892 | case 2:{ |
892 | QPopupMenu m; | 893 | QPopupMenu m; |
893 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 894 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
894 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 895 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
895 | m.insertSeparator(); | 896 | m.insertSeparator(); |
@@ -965,70 +966,96 @@ void PlayListWidget::listDelete() { | |||
965 | // if( lnk.name() == file ) { | 966 | // if( lnk.name() == file ) { |
966 | // LnkProperties prop( &lnk); | 967 | // LnkProperties prop( &lnk); |
967 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 968 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
968 | // prop.showMaximized(); | 969 | // prop.showMaximized(); |
969 | // prop.exec(); | 970 | // prop.exec(); |
970 | // } | 971 | // } |
971 | // } | 972 | // } |
972 | } | 973 | } |
973 | break; | 974 | break; |
974 | }; | 975 | }; |
975 | } | 976 | } |
976 | 977 | ||
978 | void PlayListWidget::scanForAudio() { | ||
979 | qDebug("scan for audio"); | ||
980 | files.detachChildren(); | ||
981 | QListIterator<DocLnk> sdit( files.children() ); | ||
982 | for ( ; sdit.current(); ++sdit ) { | ||
983 | delete sdit.current(); | ||
984 | } | ||
985 | Global::findDocuments(&files, "audio/*"); | ||
986 | audioScan = TRUE; | ||
987 | } | ||
988 | void PlayListWidget::scanForVideo() { | ||
989 | qDebug("scan for video"); | ||
990 | vFiles.detachChildren(); | ||
991 | QListIterator<DocLnk> sdit( vFiles.children() ); | ||
992 | for ( ; sdit.current(); ++sdit ) { | ||
993 | delete sdit.current(); | ||
994 | } | ||
995 | Global::findDocuments(&vFiles, "video/*"); | ||
996 | videoScan = TRUE; | ||
997 | } | ||
998 | |||
977 | void PlayListWidget::populateAudioView() { | 999 | void PlayListWidget::populateAudioView() { |
978 | // if(files) | 1000 | |
979 | // files.~DocLnkSet(); | 1001 | audioView->clear(); |
980 | StorageInfo storageInfo; | 1002 | StorageInfo storageInfo; |
981 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 1003 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
1004 | if(!audioScan) scanForAudio(); | ||
982 | 1005 | ||
983 | Global::findDocuments(&files, "audio/*"); | ||
984 | QListIterator<DocLnk> dit( files.children() ); | 1006 | QListIterator<DocLnk> dit( files.children() ); |
985 | QListIterator<FileSystem> it ( fs ); | 1007 | QListIterator<FileSystem> it ( fs ); |
986 | audioView->clear(); | 1008 | |
987 | QString storage; | 1009 | QString storage; |
988 | for ( ; dit.current(); ++dit ) { | 1010 | for ( ; dit.current(); ++dit ) { |
989 | for( ; it.current(); ++it ){ | 1011 | for( ; it.current(); ++it ){ |
990 | const QString name = (*it)->name(); | 1012 | const QString name = (*it)->name(); |
991 | const QString path = (*it)->path(); | 1013 | const QString path = (*it)->path(); |
992 | if(dit.current()->file().find(path) != -1 ) storage=name; | 1014 | if(dit.current()->file().find(path) != -1 ) storage=name; |
993 | } | 1015 | } |
994 | 1016 | ||
995 | QListViewItem * newItem; | 1017 | QListViewItem * newItem; |
996 | if ( QFile( dit.current()->file()).exists() ) { | 1018 | if ( QFile( dit.current()->file()).exists() ) { |
997 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); | 1019 | // qDebug(dit.current()->name()); |
1020 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | ||
1021 | QString::number( QFile( dit.current()->file()).size() ), storage); | ||
998 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); | 1022 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); |
999 | } | 1023 | } |
1000 | } | 1024 | } |
1001 | 1025 | ||
1002 | } | 1026 | } |
1003 | 1027 | ||
1004 | void PlayListWidget::populateVideoView() { | 1028 | void PlayListWidget::populateVideoView() { |
1029 | videoView->clear(); | ||
1005 | StorageInfo storageInfo; | 1030 | StorageInfo storageInfo; |
1006 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 1031 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
1007 | 1032 | ||
1008 | Global::findDocuments(&vFiles, "video/*"); | 1033 | if(!videoScan ) scanForVideo(); |
1034 | |||
1009 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 1035 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
1010 | QListIterator<FileSystem> it ( fs ); | 1036 | QListIterator<FileSystem> it ( fs ); |
1011 | videoView->clear(); | 1037 | videoView->clear(); |
1012 | QString storage; | 1038 | QString storage; |
1013 | for ( ; Vdit.current(); ++Vdit ) { | 1039 | for ( ; Vdit.current(); ++Vdit ) { |
1014 | for( ; it.current(); ++it ){ | 1040 | for( ; it.current(); ++it ){ |
1015 | const QString name = (*it)->name(); | 1041 | const QString name = (*it)->name(); |
1016 | const QString path = (*it)->path(); | 1042 | const QString path = (*it)->path(); |
1017 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 1043 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
1018 | } | 1044 | } |
1019 | 1045 | ||
1020 | QListViewItem * newItem; | 1046 | QListViewItem * newItem; |
1021 | if ( QFile( Vdit.current()->file()).exists() ) { | 1047 | if ( QFile( Vdit.current()->file()).exists() ) { |
1022 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); | 1048 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
1049 | QString::number( QFile( Vdit.current()->file()).size() ), storage); | ||
1023 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); | 1050 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); |
1024 | } | 1051 | } |
1025 | } | 1052 | } |
1026 | } | 1053 | } |
1027 | 1054 | ||
1028 | void PlayListWidget::openFile() { | 1055 | void PlayListWidget::openFile() { |
1029 | QString filename, name; | 1056 | QString filename, name; |
1030 | InputDialog *fileDlg; | 1057 | InputDialog *fileDlg; |
1031 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 1058 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
1032 | fileDlg->exec(); | 1059 | fileDlg->exec(); |
1033 | if( fileDlg->result() == 1 ) { | 1060 | if( fileDlg->result() == 1 ) { |
1034 | filename = fileDlg->LineEdit1->text(); | 1061 | filename = fileDlg->LineEdit1->text(); |
@@ -1086,25 +1113,25 @@ void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | |||
1086 | qDebug("Add"); | 1113 | qDebug("Add"); |
1087 | addSelected(); | 1114 | addSelected(); |
1088 | break; | 1115 | break; |
1089 | case Key_R: //remove from playlist | 1116 | case Key_R: //remove from playlist |
1090 | removeSelected(); | 1117 | removeSelected(); |
1091 | break; | 1118 | break; |
1092 | // case Key_P: //play | 1119 | // case Key_P: //play |
1093 | // qDebug("Play"); | 1120 | // qDebug("Play"); |
1094 | // playSelected(); | 1121 | // playSelected(); |
1095 | // break; | 1122 | // break; |
1096 | case Key_Space: | 1123 | case Key_Space: |
1097 | qDebug("Play"); | 1124 | qDebug("Play"); |
1098 | playSelected(); | 1125 | // playSelected(); puh |
1099 | break; | 1126 | break; |
1100 | case Key_1: | 1127 | case Key_1: |
1101 | tabWidget->setCurrentPage(0); | 1128 | tabWidget->setCurrentPage(0); |
1102 | break; | 1129 | break; |
1103 | case Key_2: | 1130 | case Key_2: |
1104 | tabWidget->setCurrentPage(1); | 1131 | tabWidget->setCurrentPage(1); |
1105 | break; | 1132 | break; |
1106 | case Key_3: | 1133 | case Key_3: |
1107 | tabWidget->setCurrentPage(2); | 1134 | tabWidget->setCurrentPage(2); |
1108 | break; | 1135 | break; |
1109 | case Key_4: | 1136 | case Key_4: |
1110 | tabWidget->setCurrentPage(3); | 1137 | tabWidget->setCurrentPage(3); |
@@ -1224,12 +1251,13 @@ void PlayListWidget::readPls(const QString &filename) { | |||
1224 | // QFileInfo f(s); | 1251 | // QFileInfo f(s); |
1225 | // QString name = f.baseName(); | 1252 | // QString name = f.baseName(); |
1226 | // // name = name.left(name.length()-4); | 1253 | // // name = name.left(name.length()-4); |
1227 | // name = name.right(name.findRev("/",0,TRUE)); | 1254 | // name = name.right(name.findRev("/",0,TRUE)); |
1228 | // lnk.setName( name); | 1255 | // lnk.setName( name); |
1229 | // lnk.setFile( s); | 1256 | // lnk.setFile( s); |
1230 | // qDebug("add "+name); | 1257 | // qDebug("add "+name); |
1231 | // d->selectedFiles->addToSelection( lnk); | 1258 | // d->selectedFiles->addToSelection( lnk); |
1232 | } | 1259 | } |
1233 | i++; | 1260 | i++; |
1234 | } | 1261 | } |
1235 | } | 1262 | } |
1263 | |||
diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h index 778e3ee..6569f35 100644 --- a/core/multimedia/opieplayer/playlistwidget.h +++ b/core/multimedia/opieplayer/playlistwidget.h | |||
@@ -62,38 +62,41 @@ public slots: | |||
62 | bool first(); | 62 | bool first(); |
63 | bool last(); | 63 | bool last(); |
64 | bool next(); | 64 | bool next(); |
65 | bool prev(); | 65 | bool prev(); |
66 | /* void setFullScreen(); */ | 66 | /* void setFullScreen(); */ |
67 | /* void setScaled(); */ | 67 | /* void setScaled(); */ |
68 | protected: | 68 | protected: |
69 | /* void contentsMousePressEvent( QMouseEvent * e ); */ | 69 | /* void contentsMousePressEvent( QMouseEvent * e ); */ |
70 | /* void contentsMouseReleaseEvent( QMouseEvent * e ); */ | 70 | /* void contentsMouseReleaseEvent( QMouseEvent * e ); */ |
71 | void keyReleaseEvent( QKeyEvent *e); | 71 | void keyReleaseEvent( QKeyEvent *e); |
72 | void keyPressEvent( QKeyEvent *e); | 72 | void keyPressEvent( QKeyEvent *e); |
73 | private: | 73 | private: |
74 | bool audioScan, videoScan; | ||
74 | void doBlank(); | 75 | void doBlank(); |
75 | void doUnblank(); | 76 | void doUnblank(); |
76 | void readm3u(const QString &); | 77 | void readm3u(const QString &); |
77 | void writem3u(const QString &); | 78 | void writem3u(const QString &); |
78 | void readPls(const QString &); | 79 | void readPls(const QString &); |
79 | 80 | ||
80 | 81 | ||
81 | void initializeStates(); | 82 | void initializeStates(); |
82 | void readConfig( Config& cfg ); | 83 | void readConfig( Config& cfg ); |
83 | void writeConfig( Config& cfg ) const; | 84 | void writeConfig( Config& cfg ) const; |
84 | PlayListWidgetPrivate *d; // Private implementation data | 85 | PlayListWidgetPrivate *d; // Private implementation data |
85 | void populateAudioView(); | 86 | void populateAudioView(); |
86 | void populateVideoView(); | 87 | void populateVideoView(); |
87 | private slots: | 88 | private slots: |
89 | void scanForAudio(); | ||
90 | void scanForVideo(); | ||
88 | void openFile(); | 91 | void openFile(); |
89 | void setDocument( const QString& fileref ); | 92 | void setDocument( const QString& fileref ); |
90 | void addToSelection( const DocLnk& ); // Add a media file to the playlist | 93 | void addToSelection( const DocLnk& ); // Add a media file to the playlist |
91 | void addToSelection( QListViewItem* ); // Add a media file to the playlist | 94 | void addToSelection( QListViewItem* ); // Add a media file to the playlist |
92 | void setActiveWindow(); // need to handle this to show the right view | 95 | void setActiveWindow(); // need to handle this to show the right view |
93 | void setPlaylist( bool ); // Show/Hide the playlist | 96 | void setPlaylist( bool ); // Show/Hide the playlist |
94 | void setView( char ); | 97 | void setView( char ); |
95 | void clearList(); | 98 | void clearList(); |
96 | void addAllToList(); | 99 | void addAllToList(); |
97 | void addAllMusicToList(); | 100 | void addAllMusicToList(); |
98 | void addAllVideoToList(); | 101 | void addAllVideoToList(); |
99 | void saveList(); // Save the playlist | 102 | void saveList(); // Save the playlist |