-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index 3171a84..cb58888 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -1,97 +1,98 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 | 20 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 |
21 | 21 | ||
22 | #include <qpe/qpemenubar.h> | 22 | #include <qpe/qpemenubar.h> |
23 | #include <qpe/qpetoolbar.h> | 23 | #include <qpe/qpetoolbar.h> |
24 | #include <qpe/fileselector.h> | 24 | #include <qpe/fileselector.h> |
25 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | 26 | ||
27 | #include <qpe/applnk.h> | 27 | #include <qpe/applnk.h> |
28 | #include <qpe/config.h> | 28 | #include <qpe/config.h> |
29 | #include <qpe/global.h> | 29 | #include <qpe/global.h> |
30 | #include <qpe/resource.h> | 30 | #include <qpe/resource.h> |
31 | #include <qaction.h> | 31 | #include <qaction.h> |
32 | #include <qimage.h> | 32 | #include <qimage.h> |
33 | #include <qfile.h> | 33 | #include <qfile.h> |
34 | #include <qdir.h> | ||
34 | #include <qlayout.h> | 35 | #include <qlayout.h> |
35 | #include <qlabel.h> | 36 | #include <qlabel.h> |
36 | #include <qlist.h> | 37 | #include <qlist.h> |
37 | #include <qlistbox.h> | 38 | #include <qlistbox.h> |
38 | #include <qmainwindow.h> | 39 | #include <qmainwindow.h> |
39 | #include <qmessagebox.h> | 40 | #include <qmessagebox.h> |
40 | #include <qtoolbutton.h> | 41 | #include <qtoolbutton.h> |
41 | #include <qtabwidget.h> | 42 | #include <qtabwidget.h> |
42 | #include <qlistview.h> | 43 | #include <qlistview.h> |
43 | #include <qpoint.h> | 44 | #include <qpoint.h> |
44 | #include <qlineedit.h> | 45 | #include <qlineedit.h> |
45 | #include <qpushbutton.h> | 46 | #include <qpushbutton.h> |
46 | 47 | ||
47 | //#include <qtimer.h> | 48 | //#include <qtimer.h> |
48 | 49 | ||
49 | #include "playlistselection.h" | 50 | #include "playlistselection.h" |
50 | #include "playlistwidget.h" | 51 | #include "playlistwidget.h" |
51 | #include "mediaplayerstate.h" | 52 | #include "mediaplayerstate.h" |
52 | 53 | ||
53 | #include "inputDialog.h" | 54 | #include "inputDialog.h" |
54 | 55 | ||
55 | #include <stdlib.h> | 56 | #include <stdlib.h> |
56 | 57 | ||
57 | #define BUTTONS_ON_TOOLBAR | 58 | #define BUTTONS_ON_TOOLBAR |
58 | #define SIDE_BUTTONS | 59 | #define SIDE_BUTTONS |
59 | #define CAN_SAVE_LOAD_PLAYLISTS | 60 | #define CAN_SAVE_LOAD_PLAYLISTS |
60 | 61 | ||
61 | extern MediaPlayerState *mediaPlayerState; | 62 | extern MediaPlayerState *mediaPlayerState; |
62 | 63 | ||
63 | // class myFileSelector { | 64 | // class myFileSelector { |
64 | 65 | ||
65 | // }; | 66 | // }; |
66 | class PlayListWidgetPrivate { | 67 | class PlayListWidgetPrivate { |
67 | public: | 68 | public: |
68 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | 69 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
69 | QFrame *playListFrame; | 70 | QFrame *playListFrame; |
70 | FileSelector *files; | 71 | FileSelector *files; |
71 | PlayListSelection *selectedFiles; | 72 | PlayListSelection *selectedFiles; |
72 | bool setDocumentUsed; | 73 | bool setDocumentUsed; |
73 | DocLnk *current; | 74 | DocLnk *current; |
74 | }; | 75 | }; |
75 | 76 | ||
76 | 77 | ||
77 | class ToolButton : public QToolButton { | 78 | class ToolButton : public QToolButton { |
78 | public: | 79 | public: |
79 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 80 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
80 | : QToolButton( parent, name ) { | 81 | : QToolButton( parent, name ) { |
81 | setTextLabel( name ); | 82 | setTextLabel( name ); |
82 | setPixmap( Resource::loadPixmap( icon ) ); | 83 | setPixmap( Resource::loadPixmap( icon ) ); |
83 | setAutoRaise( TRUE ); | 84 | setAutoRaise( TRUE ); |
84 | setFocusPolicy( QWidget::NoFocus ); | 85 | setFocusPolicy( QWidget::NoFocus ); |
85 | setToggleButton( t ); | 86 | setToggleButton( t ); |
86 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 87 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
87 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 88 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
88 | } | 89 | } |
89 | }; | 90 | }; |
90 | 91 | ||
91 | 92 | ||
92 | class MenuItem : public QAction { | 93 | class MenuItem : public QAction { |
93 | public: | 94 | public: |
94 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 95 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
95 | : QAction( text, QString::null, 0, 0 ) { | 96 | : QAction( text, QString::null, 0, 0 ) { |
96 | connect( this, SIGNAL( activated() ), handler, slot ); | 97 | connect( this, SIGNAL( activated() ), handler, slot ); |
97 | addTo( parent ); | 98 | addTo( parent ); |
@@ -479,133 +480,133 @@ bool PlayListWidget::prev() { | |||
479 | } else { | 480 | } else { |
480 | if ( !d->selectedFiles->prev() ) { | 481 | if ( !d->selectedFiles->prev() ) { |
481 | if ( mediaPlayerState->looping() ) { | 482 | if ( mediaPlayerState->looping() ) { |
482 | return d->selectedFiles->last(); | 483 | return d->selectedFiles->last(); |
483 | } else { | 484 | } else { |
484 | return FALSE; | 485 | return FALSE; |
485 | } | 486 | } |
486 | } | 487 | } |
487 | return TRUE; | 488 | return TRUE; |
488 | } | 489 | } |
489 | } else { | 490 | } else { |
490 | return mediaPlayerState->looping(); | 491 | return mediaPlayerState->looping(); |
491 | } | 492 | } |
492 | } | 493 | } |
493 | 494 | ||
494 | 495 | ||
495 | bool PlayListWidget::next() { | 496 | bool PlayListWidget::next() { |
496 | if ( mediaPlayerState->playlist() ) { | 497 | if ( mediaPlayerState->playlist() ) { |
497 | if ( mediaPlayerState->shuffled() ) { | 498 | if ( mediaPlayerState->shuffled() ) { |
498 | return prev(); | 499 | return prev(); |
499 | } else { | 500 | } else { |
500 | if ( !d->selectedFiles->next() ) { | 501 | if ( !d->selectedFiles->next() ) { |
501 | if ( mediaPlayerState->looping() ) { | 502 | if ( mediaPlayerState->looping() ) { |
502 | return d->selectedFiles->first(); | 503 | return d->selectedFiles->first(); |
503 | } else { | 504 | } else { |
504 | return FALSE; | 505 | return FALSE; |
505 | } | 506 | } |
506 | } | 507 | } |
507 | return TRUE; | 508 | return TRUE; |
508 | } | 509 | } |
509 | } else { | 510 | } else { |
510 | return mediaPlayerState->looping(); | 511 | return mediaPlayerState->looping(); |
511 | } | 512 | } |
512 | } | 513 | } |
513 | 514 | ||
514 | 515 | ||
515 | bool PlayListWidget::first() { | 516 | bool PlayListWidget::first() { |
516 | if ( mediaPlayerState->playlist() ) | 517 | if ( mediaPlayerState->playlist() ) |
517 | return d->selectedFiles->first(); | 518 | return d->selectedFiles->first(); |
518 | else | 519 | else |
519 | return mediaPlayerState->looping(); | 520 | return mediaPlayerState->looping(); |
520 | } | 521 | } |
521 | 522 | ||
522 | 523 | ||
523 | bool PlayListWidget::last() { | 524 | bool PlayListWidget::last() { |
524 | if ( mediaPlayerState->playlist() ) | 525 | if ( mediaPlayerState->playlist() ) |
525 | return d->selectedFiles->last(); | 526 | return d->selectedFiles->last(); |
526 | else | 527 | else |
527 | return mediaPlayerState->looping(); | 528 | return mediaPlayerState->looping(); |
528 | } | 529 | } |
529 | 530 | ||
530 | 531 | ||
531 | void PlayListWidget::saveList() { | 532 | void PlayListWidget::saveList() { |
532 | 533 | ||
533 | QString filename; | 534 | QString filename; |
534 | InputDialog *fileDlg; | 535 | InputDialog *fileDlg; |
535 | fileDlg=new InputDialog(this,"Save Playlist",TRUE, 0); | 536 | fileDlg=new InputDialog(this,"Save Playlist",TRUE, 0); |
536 | fileDlg->exec(); | 537 | fileDlg->exec(); |
537 | if( fileDlg->result() == 1 ) { | 538 | if( fileDlg->result() == 1 ) { |
538 | filename = fileDlg->LineEdit1->text();//+".playlist"; | 539 | filename = fileDlg->LineEdit1->text();//+".playlist"; |
539 | qDebug("saving playlist "+filename+".playlist"); | 540 | qDebug("saving playlist "+filename+".playlist"); |
540 | Config cfg( filename +".playlist"); | 541 | Config cfg( filename +".playlist"); |
541 | writeConfig( cfg ); | 542 | writeConfig( cfg ); |
542 | DocLnk lnk; | 543 | DocLnk lnk; |
543 | lnk.setName( filename); //sets file name | ||
544 | // lnk.setComment( ""); | 544 | // lnk.setComment( ""); |
545 | lnk.setFile(QPEApplication::qpeDir()+"Settings/"+filename+".playlist.conf"); //sets File property | 545 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property |
546 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | 546 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D |
547 | lnk.setIcon("mpegplayer/playlist2"); | 547 | lnk.setIcon("mpegplayer/playlist2"); |
548 | lnk.setName( filename); //sets file name | ||
548 | if(!lnk.writeLink()) | 549 | if(!lnk.writeLink()) |
549 | qDebug("Writing doclink did not work"); | 550 | qDebug("Writing doclink did not work"); |
550 | } | 551 | } |
551 | 552 | ||
552 | if(fileDlg) | 553 | if(fileDlg) |
553 | delete fileDlg; | 554 | delete fileDlg; |
554 | 555 | ||
555 | } | 556 | } |
556 | 557 | ||
557 | 558 | ||
558 | void PlayListWidget::loadList( const DocLnk & lnk) { | 559 | void PlayListWidget::loadList( const DocLnk & lnk) { |
559 | qDebug("load list "+ lnk.name()+".playlist"); | 560 | qDebug("load list "+ lnk.name()+".playlist"); |
560 | clearList(); | 561 | clearList(); |
561 | Config cfg( lnk.name()+".playlist"); | 562 | Config cfg( lnk.name()+".playlist"); |
562 | readConfig(cfg); | 563 | readConfig(cfg); |
563 | tabWidget->setCurrentPage(0); | 564 | tabWidget->setCurrentPage(0); |
564 | setCaption("OpiePlayer: "+lnk.name()); | 565 | setCaption("OpiePlayer: "+lnk.name()); |
565 | } | 566 | } |
566 | 567 | ||
567 | 568 | ||
568 | void PlayListWidget::setPlaylist( bool shown ) { | 569 | void PlayListWidget::setPlaylist( bool shown ) { |
569 | if ( shown ) | 570 | if ( shown ) |
570 | d->playListFrame->show(); | 571 | d->playListFrame->show(); |
571 | else | 572 | else |
572 | d->playListFrame->hide(); | 573 | d->playListFrame->hide(); |
573 | } | 574 | } |
574 | 575 | ||
575 | 576 | ||
576 | void PlayListWidget::setView( char view ) { | 577 | void PlayListWidget::setView( char view ) { |
577 | if ( view == 'l' ) | 578 | if ( view == 'l' ) |
578 | showMaximized(); | 579 | showMaximized(); |
579 | else | 580 | else |
580 | hide(); | 581 | hide(); |
581 | } | 582 | } |
582 | 583 | ||
583 | void PlayListWidget::addSelected() { | 584 | void PlayListWidget::addSelected() { |
584 | 585 | ||
585 | switch (tabWidget->currentPageIndex()) { | 586 | switch (tabWidget->currentPageIndex()) { |
586 | case 0: //playlist | 587 | case 0: //playlist |
587 | break; | 588 | break; |
588 | case 1: { //audio | 589 | case 1: { //audio |
589 | addToSelection( audioView->selectedItem() ); | 590 | addToSelection( audioView->selectedItem() ); |
590 | } | 591 | } |
591 | break; | 592 | break; |
592 | case 2: { // video | 593 | case 2: { // video |
593 | addToSelection( videoView->selectedItem() ); | 594 | addToSelection( videoView->selectedItem() ); |
594 | } | 595 | } |
595 | break; | 596 | break; |
596 | }; | 597 | }; |
597 | } | 598 | } |
598 | 599 | ||
599 | void PlayListWidget::removeSelected() { | 600 | void PlayListWidget::removeSelected() { |
600 | d->selectedFiles->removeSelected( ); | 601 | d->selectedFiles->removeSelected( ); |
601 | } | 602 | } |
602 | 603 | ||
603 | 604 | ||
604 | void PlayListWidget::playIt( QListViewItem *it) { | 605 | void PlayListWidget::playIt( QListViewItem *it) { |
605 | // d->setDocumentUsed = FALSE; | 606 | // d->setDocumentUsed = FALSE; |
606 | mediaPlayerState->setPlaying(TRUE); | 607 | mediaPlayerState->setPlaying(TRUE); |
607 | } | 608 | } |
608 | 609 | ||
609 | void PlayListWidget::addToSelection( QListViewItem *it) { | 610 | void PlayListWidget::addToSelection( QListViewItem *it) { |
610 | d->setDocumentUsed = FALSE; | 611 | d->setDocumentUsed = FALSE; |
611 | 612 | ||