-rw-r--r-- | core/multimedia/opieplayer/playlistselection.cpp | 3 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 2 |
2 files changed, 2 insertions, 3 deletions
diff --git a/core/multimedia/opieplayer/playlistselection.cpp b/core/multimedia/opieplayer/playlistselection.cpp index 58c3966..430aa6b 100644 --- a/core/multimedia/opieplayer/playlistselection.cpp +++ b/core/multimedia/opieplayer/playlistselection.cpp | |||
@@ -1,213 +1,212 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the 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 | 20 | ||
21 | #include "playlistselection.h" | 21 | #include "playlistselection.h" |
22 | 22 | ||
23 | /* OPIE */ | 23 | /* OPIE */ |
24 | #include <opie2/odebug.h> | 24 | #include <opie2/odebug.h> |
25 | 25 | ||
26 | /* QT */ | 26 | /* QT */ |
27 | #include <qheader.h> | 27 | #include <qheader.h> |
28 | 28 | ||
29 | /* STD */ | 29 | /* STD */ |
30 | #include <stdlib.h> | 30 | #include <stdlib.h> |
31 | 31 | ||
32 | class PlayListSelectionItem : public QListViewItem { | 32 | class PlayListSelectionItem : public QListViewItem { |
33 | public: | 33 | public: |
34 | PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { | 34 | PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { |
35 | setText( 0, f->name() ); | 35 | setText( 0, f->name() ); |
36 | setPixmap( 0, f->pixmap() ); | 36 | setPixmap( 0, f->pixmap() ); |
37 | } | 37 | } |
38 | 38 | ||
39 | ~PlayListSelectionItem() { | 39 | ~PlayListSelectionItem() { |
40 | }; | 40 | }; |
41 | 41 | ||
42 | const DocLnk *file() const { return fl; } | 42 | const DocLnk *file() const { return fl; } |
43 | 43 | ||
44 | private: | 44 | private: |
45 | const DocLnk *fl; | 45 | const DocLnk *fl; |
46 | }; | 46 | }; |
47 | 47 | ||
48 | 48 | ||
49 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) | 49 | PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) |
50 | : QListView( parent, name ) | 50 | : QListView( parent, name ) |
51 | { | 51 | { |
52 | // odebug << "starting playlistselector" << oendl; | 52 | // odebug << "starting playlistselector" << oendl; |
53 | // #ifdef USE_PLAYLIST_BACKGROUND | 53 | // #ifdef USE_PLAYLIST_BACKGROUND |
54 | // setStaticBackground( TRUE ); | 54 | // setStaticBackground( TRUE ); |
55 | // setBackgroundPixmap( Resource::loadPixmap( "opieplayer/background" ) ); | 55 | // setBackgroundPixmap( Resource::loadPixmap( "opieplayer/background" ) ); |
56 | 56 | ||
57 | // setBackgroundPixmap( Resource::loadPixmap( "launcher/opielogo" ) ); | 57 | // setBackgroundPixmap( Resource::loadPixmap( "launcher/opielogo" ) ); |
58 | // #endif | 58 | // #endif |
59 | // addColumn("Title",236); | 59 | // addColumn("Title",236); |
60 | // setAllColumnsShowFocus( TRUE ); | 60 | // setAllColumnsShowFocus( TRUE ); |
61 | addColumn( tr( "Playlist Selection" ) ); | 61 | addColumn( tr( "Playlist Selection" ) ); |
62 | header()->hide(); | 62 | header()->hide(); |
63 | // setSorting( -1, FALSE ); | 63 | // setSorting( -1, FALSE ); |
64 | // FIXME | 64 | // FIXME |
65 | } | 65 | } |
66 | 66 | ||
67 | 67 | ||
68 | PlayListSelection::~PlayListSelection() { | 68 | PlayListSelection::~PlayListSelection() { |
69 | } | 69 | } |
70 | 70 | ||
71 | 71 | ||
72 | // #ifdef USE_PLAYLIST_BACKGROUND | 72 | // #ifdef USE_PLAYLIST_BACKGROUND |
73 | void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { | 73 | void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { |
74 | // odebug << "drawBackground" << oendl; | 74 | // odebug << "drawBackground" << oendl; |
75 | p->fillRect( r, QBrush( white ) ); | 75 | p->fillRect( r, QBrush( white ) ); |
76 | // QImage logo = Resource::loadImage( "launcher/opielogo" ); | 76 | // QImage logo = Resource::loadImage( "launcher/opielogo" ); |
77 | // if ( !logo.isNull() ) | 77 | // if ( !logo.isNull() ) |
78 | // p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); | 78 | // p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); |
79 | } | 79 | } |
80 | // #endif | 80 | // #endif |
81 | 81 | ||
82 | 82 | ||
83 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { | 83 | void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { |
84 | if ( event->state() == QMouseEvent::LeftButton ) { | 84 | if ( event->state() == QMouseEvent::LeftButton ) { |
85 | QListViewItem *currentItem = selectedItem(); | 85 | QListViewItem *currentItem = selectedItem(); |
86 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); | 86 | QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); |
87 | if ( currentItem && currentItem->itemAbove() == itemUnder ) | 87 | if ( currentItem && currentItem->itemAbove() == itemUnder ) |
88 | moveSelectedUp(); | 88 | moveSelectedUp(); |
89 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) | 89 | else if ( currentItem && currentItem->itemBelow() == itemUnder ) |
90 | moveSelectedDown(); | 90 | moveSelectedDown(); |
91 | } | 91 | } |
92 | } | 92 | } |
93 | 93 | ||
94 | 94 | ||
95 | const DocLnk *PlayListSelection::current() { | 95 | const DocLnk *PlayListSelection::current() { |
96 | PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); | 96 | PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); |
97 | if ( item ) | 97 | if ( item ) |
98 | return item->file(); | 98 | return item->file(); |
99 | return NULL; | 99 | return NULL; |
100 | } | 100 | } |
101 | 101 | ||
102 | 102 | ||
103 | void PlayListSelection::addToSelection( const DocLnk &lnk ) { | 103 | void PlayListSelection::addToSelection( const DocLnk &lnk ) { |
104 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); | 104 | PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); |
105 | QListViewItem *current = selectedItem(); | 105 | QListViewItem *current = selectedItem(); |
106 | if ( current ) | 106 | if ( current ) |
107 | item->moveItem( current ); | 107 | item->moveItem( current ); |
108 | setSelected( item, TRUE ); | 108 | setSelected( item, TRUE ); |
109 | ensureItemVisible( item); | 109 | ensureItemVisible( item); |
110 | } | 110 | } |
111 | 111 | ||
112 | 112 | ||
113 | void PlayListSelection::removeSelected() { | 113 | void PlayListSelection::removeSelected() { |
114 | QListViewItem *item = selectedItem(); | 114 | QListViewItem *item = selectedItem(); |
115 | if ( item ) | 115 | if ( item ) |
116 | delete item; | 116 | delete item; |
117 | setSelected( currentItem(), TRUE ); | 117 | setSelected( currentItem(), TRUE ); |
118 | ensureItemVisible( selectedItem() ); | 118 | ensureItemVisible( selectedItem() ); |
119 | } | 119 | } |
120 | 120 | ||
121 | 121 | ||
122 | void PlayListSelection::moveSelectedUp() { | 122 | void PlayListSelection::moveSelectedUp() { |
123 | QListViewItem *item = selectedItem(); | 123 | QListViewItem *item = selectedItem(); |
124 | if ( item && item->itemAbove() ) | 124 | if ( item && item->itemAbove() ) |
125 | item->itemAbove()->moveItem( item ); | 125 | item->itemAbove()->moveItem( item ); |
126 | ensureItemVisible( selectedItem() ); | 126 | ensureItemVisible( selectedItem() ); |
127 | } | 127 | } |
128 | 128 | ||
129 | 129 | ||
130 | void PlayListSelection::moveSelectedDown() { | 130 | void PlayListSelection::moveSelectedDown() { |
131 | QListViewItem *item = selectedItem(); | 131 | QListViewItem *item = selectedItem(); |
132 | if ( item && item->itemBelow() ) | 132 | if ( item && item->itemBelow() ) |
133 | item->moveItem( item->itemBelow() ); | 133 | item->moveItem( item->itemBelow() ); |
134 | ensureItemVisible( selectedItem() ); | 134 | ensureItemVisible( selectedItem() ); |
135 | } | 135 | } |
136 | 136 | ||
137 | 137 | ||
138 | bool PlayListSelection::prev() { | 138 | bool PlayListSelection::prev() { |
139 | QListViewItem *item = selectedItem(); | 139 | QListViewItem *item = selectedItem(); |
140 | if ( item && item->itemAbove() ) | 140 | if ( item && item->itemAbove() ) |
141 | setSelected( item->itemAbove(), TRUE ); | 141 | setSelected( item->itemAbove(), TRUE ); |
142 | else | 142 | else |
143 | return FALSE; | 143 | return FALSE; |
144 | ensureItemVisible( selectedItem() ); | 144 | ensureItemVisible( selectedItem() ); |
145 | return TRUE; | 145 | return TRUE; |
146 | } | 146 | } |
147 | 147 | ||
148 | bool PlayListSelection::next() { | 148 | bool PlayListSelection::next() { |
149 | QListViewItem *item = selectedItem(); | 149 | QListViewItem *item = selectedItem(); |
150 | if ( item && item->itemBelow() ) | 150 | if ( item && item->itemBelow() ) |
151 | setSelected( item->itemBelow(), TRUE ); | 151 | setSelected( item->itemBelow(), TRUE ); |
152 | else | 152 | else |
153 | return FALSE; | 153 | return FALSE; |
154 | ensureItemVisible( selectedItem() ); | 154 | ensureItemVisible( selectedItem() ); |
155 | return TRUE; | 155 | return TRUE; |
156 | } | 156 | } |
157 | 157 | ||
158 | 158 | ||
159 | bool PlayListSelection::first() { | 159 | bool PlayListSelection::first() { |
160 | QListViewItem *item = firstChild(); | 160 | QListViewItem *item = firstChild(); |
161 | if ( item ) | 161 | if ( item ) |
162 | setSelected( item, TRUE ); | 162 | setSelected( item, TRUE ); |
163 | else | 163 | else |
164 | return FALSE; | 164 | return FALSE; |
165 | ensureItemVisible( selectedItem() ); | 165 | ensureItemVisible( selectedItem() ); |
166 | return TRUE; | 166 | return TRUE; |
167 | } | 167 | } |
168 | 168 | ||
169 | 169 | ||
170 | bool PlayListSelection::last() { | 170 | bool PlayListSelection::last() { |
171 | QListViewItem *prevItem = NULL; | 171 | QListViewItem *prevItem = NULL; |
172 | QListViewItem *item = firstChild(); | 172 | QListViewItem *item = firstChild(); |
173 | while ( ( item = item->nextSibling() ) ) | 173 | while ( ( item = item->nextSibling() ) ) |
174 | prevItem = item; | 174 | prevItem = item; |
175 | if ( prevItem ) | 175 | if ( prevItem ) |
176 | setSelected( prevItem, TRUE ); | 176 | setSelected( prevItem, TRUE ); |
177 | else | 177 | else |
178 | return FALSE; | 178 | return FALSE; |
179 | ensureItemVisible( selectedItem() ); | 179 | ensureItemVisible( selectedItem() ); |
180 | return TRUE; | 180 | return TRUE; |
181 | } | 181 | } |
182 | 182 | ||
183 | void PlayListSelection::unSelect() | 183 | void PlayListSelection::unSelect() |
184 | { | 184 | { |
185 | QListViewItem *item = selectedItem(); | 185 | setSelected( currentItem() , FALSE); |
186 | setSelected( currentItem(), FALSE); | ||
187 | } | 186 | } |
188 | 187 | ||
189 | void PlayListSelection::writeCurrent( Config& cfg ) { | 188 | void PlayListSelection::writeCurrent( Config& cfg ) { |
190 | cfg.setGroup("PlayList"); | 189 | cfg.setGroup("PlayList"); |
191 | QListViewItem *item = selectedItem(); | 190 | QListViewItem *item = selectedItem(); |
192 | if ( item ) | 191 | if ( item ) |
193 | cfg.writeEntry("current", item->text(0) ); | 192 | cfg.writeEntry("current", item->text(0) ); |
194 | // odebug << item->text(0) << oendl; | 193 | // odebug << item->text(0) << oendl; |
195 | 194 | ||
196 | } | 195 | } |
197 | 196 | ||
198 | void PlayListSelection::setSelectedItem(const QString &strk ) { | 197 | void PlayListSelection::setSelectedItem(const QString &strk ) { |
199 | 198 | ||
200 | unSelect(); | 199 | unSelect(); |
201 | QListViewItemIterator it( this ); | 200 | QListViewItemIterator it( this ); |
202 | for ( ; it.current(); ++it ) { | 201 | for ( ; it.current(); ++it ) { |
203 | // odebug << it.current()->text(0) << oendl; | 202 | // odebug << it.current()->text(0) << oendl; |
204 | if( strk == it.current()->text(0)) { | 203 | if( strk == it.current()->text(0)) { |
205 | // odebug << "We have a match "+strk << oendl; | 204 | // odebug << "We have a match "+strk << oendl; |
206 | setSelected( it.current(), TRUE); | 205 | setSelected( it.current(), TRUE); |
207 | ensureItemVisible( it.current() ); | 206 | ensureItemVisible( it.current() ); |
208 | return; | 207 | return; |
209 | } | 208 | } |
210 | } | 209 | } |
211 | // setSelected( item, TRUE ); | 210 | // setSelected( item, TRUE ); |
212 | // ensureItemVisible( selectedItem() ); | 211 | // ensureItemVisible( selectedItem() ); |
213 | } | 212 | } |
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index d85ce50..46aeff2 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -640,820 +640,820 @@ bool PlayListWidget::next() { | |||
640 | } | 640 | } |
641 | 641 | ||
642 | 642 | ||
643 | bool PlayListWidget::first() { | 643 | bool PlayListWidget::first() { |
644 | if ( mediaPlayerState->playlist() ) | 644 | if ( mediaPlayerState->playlist() ) |
645 | return d->selectedFiles->first(); | 645 | return d->selectedFiles->first(); |
646 | else | 646 | else |
647 | return mediaPlayerState->looping(); | 647 | return mediaPlayerState->looping(); |
648 | } | 648 | } |
649 | 649 | ||
650 | 650 | ||
651 | bool PlayListWidget::last() { | 651 | bool PlayListWidget::last() { |
652 | if ( mediaPlayerState->playlist() ) | 652 | if ( mediaPlayerState->playlist() ) |
653 | return d->selectedFiles->last(); | 653 | return d->selectedFiles->last(); |
654 | else | 654 | else |
655 | return mediaPlayerState->looping(); | 655 | return mediaPlayerState->looping(); |
656 | } | 656 | } |
657 | 657 | ||
658 | 658 | ||
659 | void PlayListWidget::saveList() { | 659 | void PlayListWidget::saveList() { |
660 | writem3u(); | 660 | writem3u(); |
661 | } | 661 | } |
662 | 662 | ||
663 | void PlayListWidget::loadList( const DocLnk & lnk) { | 663 | void PlayListWidget::loadList( const DocLnk & lnk) { |
664 | QString name = lnk.name(); | 664 | QString name = lnk.name(); |
665 | // odebug << "<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name << oendl; | 665 | // odebug << "<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name << oendl; |
666 | 666 | ||
667 | if( name.length()>0) { | 667 | if( name.length()>0) { |
668 | setCaption("OpiePlayer: "+name); | 668 | setCaption("OpiePlayer: "+name); |
669 | // odebug << "<<<<<<<<<<<<load list "+ lnk.file() << oendl; | 669 | // odebug << "<<<<<<<<<<<<load list "+ lnk.file() << oendl; |
670 | clearList(); | 670 | clearList(); |
671 | readm3u(lnk.file()); | 671 | readm3u(lnk.file()); |
672 | tabWidget->setCurrentPage(0); | 672 | tabWidget->setCurrentPage(0); |
673 | } | 673 | } |
674 | } | 674 | } |
675 | 675 | ||
676 | void PlayListWidget::setPlaylist( bool shown ) { | 676 | void PlayListWidget::setPlaylist( bool shown ) { |
677 | if ( shown ) | 677 | if ( shown ) |
678 | d->playListFrame->show(); | 678 | d->playListFrame->show(); |
679 | else | 679 | else |
680 | d->playListFrame->hide(); | 680 | d->playListFrame->hide(); |
681 | } | 681 | } |
682 | 682 | ||
683 | void PlayListWidget::setView( char view ) { | 683 | void PlayListWidget::setView( char view ) { |
684 | if ( view == 'l' ) | 684 | if ( view == 'l' ) |
685 | QPEApplication::showWidget( this ); | 685 | QPEApplication::showWidget( this ); |
686 | else | 686 | else |
687 | hide(); | 687 | hide(); |
688 | } | 688 | } |
689 | 689 | ||
690 | void PlayListWidget::addSelected() { | 690 | void PlayListWidget::addSelected() { |
691 | DocLnk lnk; | 691 | DocLnk lnk; |
692 | QString filename; | 692 | QString filename; |
693 | switch (tabWidget->currentPageIndex()) { | 693 | switch (tabWidget->currentPageIndex()) { |
694 | 694 | ||
695 | case 0: //playlist | 695 | case 0: //playlist |
696 | return; | 696 | return; |
697 | break; | 697 | break; |
698 | case 1: { //audio | 698 | case 1: { //audio |
699 | QListViewItemIterator it( audioView ); | 699 | QListViewItemIterator it( audioView ); |
700 | for ( ; it.current(); ++it ) { | 700 | for ( ; it.current(); ++it ) { |
701 | if ( it.current()->isSelected() ) { | 701 | if ( it.current()->isSelected() ) { |
702 | filename = it.current()->text(3); | 702 | filename = it.current()->text(3); |
703 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 703 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
704 | lnk.setFile( filename ); //sets file name | 704 | lnk.setFile( filename ); //sets file name |
705 | d->selectedFiles->addToSelection( lnk); | 705 | d->selectedFiles->addToSelection( lnk); |
706 | } | 706 | } |
707 | } | 707 | } |
708 | audioView->clearSelection(); | 708 | audioView->clearSelection(); |
709 | // d->selectedFiles->next(); | 709 | // d->selectedFiles->next(); |
710 | } | 710 | } |
711 | break; | 711 | break; |
712 | 712 | ||
713 | case 2: { // video | 713 | case 2: { // video |
714 | QListViewItemIterator it( videoView ); | 714 | QListViewItemIterator it( videoView ); |
715 | for ( ; it.current(); ++it ) { | 715 | for ( ; it.current(); ++it ) { |
716 | if ( it.current()->isSelected() ) { | 716 | if ( it.current()->isSelected() ) { |
717 | 717 | ||
718 | filename = it.current()->text(3); | 718 | filename = it.current()->text(3); |
719 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 719 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
720 | lnk.setFile( filename ); //sets file name | 720 | lnk.setFile( filename ); //sets file name |
721 | d->selectedFiles->addToSelection( lnk); | 721 | d->selectedFiles->addToSelection( lnk); |
722 | } | 722 | } |
723 | } | 723 | } |
724 | videoView->clearSelection(); | 724 | videoView->clearSelection(); |
725 | } | 725 | } |
726 | break; | 726 | break; |
727 | }; | 727 | }; |
728 | // tabWidget->setCurrentPage(0); | 728 | // tabWidget->setCurrentPage(0); |
729 | writeCurrentM3u(); | 729 | writeCurrentM3u(); |
730 | 730 | ||
731 | } | 731 | } |
732 | 732 | ||
733 | void PlayListWidget::removeSelected() { | 733 | void PlayListWidget::removeSelected() { |
734 | d->selectedFiles->removeSelected( ); | 734 | d->selectedFiles->removeSelected( ); |
735 | } | 735 | } |
736 | 736 | ||
737 | void PlayListWidget::playIt( QListViewItem *) { | 737 | void PlayListWidget::playIt( QListViewItem *) { |
738 | // d->setDocumentUsed = FALSE; | 738 | // d->setDocumentUsed = FALSE; |
739 | // mediaPlayerState->curPosition =0; | 739 | // mediaPlayerState->curPosition =0; |
740 | // mediaPlayerState->setPlaying(FALSE); | 740 | // mediaPlayerState->setPlaying(FALSE); |
741 | mediaPlayerState->setPlaying(TRUE); | 741 | mediaPlayerState->setPlaying(TRUE); |
742 | d->selectedFiles->unSelect(); | 742 | d->selectedFiles->unSelect(); |
743 | } | 743 | } |
744 | 744 | ||
745 | void PlayListWidget::addToSelection( QListViewItem *it) { | 745 | void PlayListWidget::addToSelection( QListViewItem *it) { |
746 | d->setDocumentUsed = FALSE; | 746 | d->setDocumentUsed = FALSE; |
747 | 747 | ||
748 | if(it) { | 748 | if(it) { |
749 | switch ( tabWidget->currentPageIndex()) { | 749 | switch ( tabWidget->currentPageIndex()) { |
750 | case 0: //playlist | 750 | case 0: //playlist |
751 | return; | 751 | return; |
752 | break; | 752 | break; |
753 | }; | 753 | }; |
754 | // case 1: { | 754 | // case 1: { |
755 | DocLnk lnk; | 755 | DocLnk lnk; |
756 | QString filename; | 756 | QString filename; |
757 | 757 | ||
758 | filename=it->text(3); | 758 | filename=it->text(3); |
759 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name | 759 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name |
760 | lnk.setFile( filename ); //sets file name | 760 | lnk.setFile( filename ); //sets file name |
761 | d->selectedFiles->addToSelection( lnk); | 761 | d->selectedFiles->addToSelection( lnk); |
762 | 762 | ||
763 | if(tabWidget->currentPageIndex() == 0) | 763 | if(tabWidget->currentPageIndex() == 0) |
764 | writeCurrentM3u(); | 764 | writeCurrentM3u(); |
765 | // tabWidget->setCurrentPage(0); | 765 | // tabWidget->setCurrentPage(0); |
766 | 766 | ||
767 | } | 767 | } |
768 | } | 768 | } |
769 | 769 | ||
770 | void PlayListWidget::tabChanged(QWidget *) { | 770 | void PlayListWidget::tabChanged(QWidget *) { |
771 | 771 | ||
772 | switch ( tabWidget->currentPageIndex()) { | 772 | switch ( tabWidget->currentPageIndex()) { |
773 | case 0: | 773 | case 0: |
774 | { | 774 | { |
775 | if( !tbDeletePlaylist->isHidden()) | 775 | if( !tbDeletePlaylist->isHidden()) |
776 | tbDeletePlaylist->hide(); | 776 | tbDeletePlaylist->hide(); |
777 | d->tbRemoveFromList->setEnabled(TRUE); | 777 | d->tbRemoveFromList->setEnabled(TRUE); |
778 | d->tbAddToList->setEnabled(FALSE); | 778 | d->tbAddToList->setEnabled(FALSE); |
779 | } | 779 | } |
780 | break; | 780 | break; |
781 | case 1: | 781 | case 1: |
782 | { | 782 | { |
783 | audioView->clear(); | 783 | audioView->clear(); |
784 | populateAudioView(); | 784 | populateAudioView(); |
785 | 785 | ||
786 | if( !tbDeletePlaylist->isHidden()) | 786 | if( !tbDeletePlaylist->isHidden()) |
787 | tbDeletePlaylist->hide(); | 787 | tbDeletePlaylist->hide(); |
788 | d->tbRemoveFromList->setEnabled(FALSE); | 788 | d->tbRemoveFromList->setEnabled(FALSE); |
789 | d->tbAddToList->setEnabled(TRUE); | 789 | d->tbAddToList->setEnabled(TRUE); |
790 | } | 790 | } |
791 | break; | 791 | break; |
792 | case 2: | 792 | case 2: |
793 | { | 793 | { |
794 | videoView->clear(); | 794 | videoView->clear(); |
795 | populateVideoView(); | 795 | populateVideoView(); |
796 | if( !tbDeletePlaylist->isHidden()) | 796 | if( !tbDeletePlaylist->isHidden()) |
797 | tbDeletePlaylist->hide(); | 797 | tbDeletePlaylist->hide(); |
798 | d->tbRemoveFromList->setEnabled(FALSE); | 798 | d->tbRemoveFromList->setEnabled(FALSE); |
799 | d->tbAddToList->setEnabled(TRUE); | 799 | d->tbAddToList->setEnabled(TRUE); |
800 | } | 800 | } |
801 | break; | 801 | break; |
802 | case 3: | 802 | case 3: |
803 | { | 803 | { |
804 | if( tbDeletePlaylist->isHidden()) | 804 | if( tbDeletePlaylist->isHidden()) |
805 | tbDeletePlaylist->show(); | 805 | tbDeletePlaylist->show(); |
806 | playLists->reread(); | 806 | playLists->reread(); |
807 | } | 807 | } |
808 | break; | 808 | break; |
809 | }; | 809 | }; |
810 | } | 810 | } |
811 | 811 | ||
812 | void PlayListWidget::btnPlay(bool b) { | 812 | void PlayListWidget::btnPlay(bool b) { |
813 | // mediaPlayerState->setPlaying(b); | 813 | // mediaPlayerState->setPlaying(b); |
814 | switch ( tabWidget->currentPageIndex()) { | 814 | switch ( tabWidget->currentPageIndex()) { |
815 | case 0: | 815 | case 0: |
816 | { | 816 | { |
817 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 | 817 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 |
818 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { | 818 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { |
819 | // QMessageBox::message("Note","You are trying to play\na malformed url."); | 819 | // QMessageBox::message("Note","You are trying to play\na malformed url."); |
820 | // } else { | 820 | // } else { |
821 | mediaPlayerState->setPlaying(b); | 821 | mediaPlayerState->setPlaying(b); |
822 | insanityBool=FALSE; | 822 | insanityBool=FALSE; |
823 | odebug << "insanity" << oendl; | 823 | odebug << "insanity" << oendl; |
824 | // } | 824 | // } |
825 | } | 825 | } |
826 | break; | 826 | break; |
827 | case 1: | 827 | case 1: |
828 | { | 828 | { |
829 | // d->selectedFiles->unSelect(); | 829 | // d->selectedFiles->unSelect(); |
830 | addToSelection( audioView->currentItem() ); | 830 | addToSelection( audioView->currentItem() ); |
831 | mediaPlayerState->setPlaying( b); | 831 | mediaPlayerState->setPlaying( b); |
832 | d->selectedFiles->removeSelected( ); | 832 | d->selectedFiles->removeSelected( ); |
833 | d->selectedFiles->unSelect(); | 833 | d->selectedFiles->unSelect(); |
834 | tabWidget->setCurrentPage(1); | 834 | tabWidget->setCurrentPage(1); |
835 | insanityBool=FALSE; | 835 | insanityBool=FALSE; |
836 | }// audioView->clearSelection(); | 836 | }// audioView->clearSelection(); |
837 | break; | 837 | break; |
838 | case 2: | 838 | case 2: |
839 | { | 839 | { |
840 | 840 | ||
841 | addToSelection( videoView->currentItem() ); | 841 | addToSelection( videoView->currentItem() ); |
842 | mediaPlayerState->setPlaying( b); | 842 | mediaPlayerState->setPlaying( b); |
843 | // qApp->processEvents(); | 843 | // qApp->processEvents(); |
844 | d->selectedFiles->removeSelected( ); | 844 | d->selectedFiles->removeSelected( ); |
845 | d->selectedFiles->unSelect(); | 845 | d->selectedFiles->unSelect(); |
846 | tabWidget->setCurrentPage(2); | 846 | tabWidget->setCurrentPage(2); |
847 | insanityBool=FALSE; | 847 | insanityBool=FALSE; |
848 | }// videoView->clearSelection(); | 848 | }// videoView->clearSelection(); |
849 | break; | 849 | break; |
850 | }; | 850 | }; |
851 | 851 | ||
852 | } | 852 | } |
853 | 853 | ||
854 | void PlayListWidget::deletePlaylist() { | 854 | void PlayListWidget::deletePlaylist() { |
855 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 855 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
856 | (tr("You really want to delete\nthis playlist?")), | 856 | (tr("You really want to delete\nthis playlist?")), |
857 | (tr("Yes")), (tr("No")), 0 )){ | 857 | (tr("Yes")), (tr("No")), 0 )){ |
858 | case 0: // Yes clicked, | 858 | case 0: // Yes clicked, |
859 | QFile().remove(playLists->selectedDocument().file()); | 859 | QFile().remove(playLists->selectedDocument().file()); |
860 | QFile().remove(playLists->selectedDocument().linkFile()); | 860 | QFile().remove(playLists->selectedDocument().linkFile()); |
861 | playLists->reread(); | 861 | playLists->reread(); |
862 | break; | 862 | break; |
863 | case 1: // Cancel | 863 | case 1: // Cancel |
864 | break; | 864 | break; |
865 | }; | 865 | }; |
866 | } | 866 | } |
867 | 867 | ||
868 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) | 868 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) |
869 | { | 869 | { |
870 | switch (mouse) { | 870 | switch (mouse) { |
871 | case 1: | 871 | case 1: |
872 | break; | 872 | break; |
873 | case 2:{ | 873 | case 2:{ |
874 | 874 | ||
875 | QPopupMenu m; | 875 | QPopupMenu m; |
876 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 876 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
877 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 877 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
878 | m.insertSeparator(); | 878 | m.insertSeparator(); |
879 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) | 879 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) |
880 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 880 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
881 | 881 | ||
882 | m.exec( QCursor::pos() ); | 882 | m.exec( QCursor::pos() ); |
883 | } | 883 | } |
884 | break; | 884 | break; |
885 | }; | 885 | }; |
886 | } | 886 | } |
887 | 887 | ||
888 | void PlayListWidget::playSelected() | 888 | void PlayListWidget::playSelected() |
889 | { | 889 | { |
890 | btnPlay( true); | 890 | btnPlay( true); |
891 | // d->selectedFiles->unSelect(); | 891 | // d->selectedFiles->unSelect(); |
892 | } | 892 | } |
893 | 893 | ||
894 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) | 894 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) |
895 | { | 895 | { |
896 | switch (mouse) { | 896 | switch (mouse) { |
897 | case 1: | 897 | case 1: |
898 | 898 | ||
899 | break; | 899 | break; |
900 | case 2:{ | 900 | case 2:{ |
901 | QPopupMenu m; | 901 | QPopupMenu m; |
902 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 902 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
903 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 903 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
904 | // m.insertSeparator(); | 904 | // m.insertSeparator(); |
905 | // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 905 | // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
906 | m.exec( QCursor::pos() ); | 906 | m.exec( QCursor::pos() ); |
907 | } | 907 | } |
908 | break; | 908 | break; |
909 | }; | 909 | }; |
910 | 910 | ||
911 | } | 911 | } |
912 | 912 | ||
913 | void PlayListWidget::listDelete() { | 913 | void PlayListWidget::listDelete() { |
914 | Config cfg( "OpiePlayer" ); | 914 | Config cfg( "OpiePlayer" ); |
915 | cfg.setGroup("PlayList"); | 915 | cfg.setGroup("PlayList"); |
916 | currentPlayList = cfg.readEntry("CurrentPlaylist",""); | 916 | currentPlayList = cfg.readEntry("CurrentPlaylist",""); |
917 | QString file; | 917 | QString file; |
918 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 918 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
919 | switch ( tabWidget->currentPageIndex()) { | 919 | switch ( tabWidget->currentPageIndex()) { |
920 | case 0: | 920 | case 0: |
921 | break; | 921 | break; |
922 | case 1: | 922 | case 1: |
923 | { | 923 | { |
924 | file = audioView->currentItem()->text(0); | 924 | file = audioView->currentItem()->text(0); |
925 | QListIterator<DocLnk> Pdit( files.children() ); | 925 | QListIterator<DocLnk> Pdit( files.children() ); |
926 | for ( ; Pdit.current(); ++Pdit ) { | 926 | for ( ; Pdit.current(); ++Pdit ) { |
927 | if( Pdit.current()->name() == file) { | 927 | if( Pdit.current()->name() == file) { |
928 | LnkProperties prop( Pdit.current() ); | 928 | LnkProperties prop( Pdit.current() ); |
929 | QPEApplication::execDialog( &prop ); | 929 | QPEApplication::execDialog( &prop ); |
930 | } | 930 | } |
931 | } | 931 | } |
932 | populateAudioView(); | 932 | populateAudioView(); |
933 | } | 933 | } |
934 | break; | 934 | break; |
935 | case 2: | 935 | case 2: |
936 | { | 936 | { |
937 | // file = videoView->selectedItem()->text(0); | 937 | // file = videoView->selectedItem()->text(0); |
938 | // for ( int i = 0; i < noOfFiles; i++ ) { | 938 | // for ( int i = 0; i < noOfFiles; i++ ) { |
939 | // QString entryName; | 939 | // QString entryName; |
940 | // entryName.sprintf( "File%i", i + 1 ); | 940 | // entryName.sprintf( "File%i", i + 1 ); |
941 | // QString linkFile = cfg.readEntry( entryName ); | 941 | // QString linkFile = cfg.readEntry( entryName ); |
942 | // AppLnk lnk( AppLnk(linkFile)); | 942 | // AppLnk lnk( AppLnk(linkFile)); |
943 | // if( lnk.name() == file ) { | 943 | // if( lnk.name() == file ) { |
944 | // LnkProperties prop( &lnk); | 944 | // LnkProperties prop( &lnk); |
945 | // // connect(&prop, SIGNAL(select(const AppLnk*)), this, SLOT(externalSelected(const AppLnk*))); | 945 | // // connect(&prop, SIGNAL(select(const AppLnk*)), this, SLOT(externalSelected(const AppLnk*))); |
946 | // prop.showMaximized(); | 946 | // prop.showMaximized(); |
947 | // prop.exec(); | 947 | // prop.exec(); |
948 | // } | 948 | // } |
949 | // } | 949 | // } |
950 | } | 950 | } |
951 | break; | 951 | break; |
952 | }; | 952 | }; |
953 | } | 953 | } |
954 | 954 | ||
955 | void PlayListWidget::scanForAudio() { | 955 | void PlayListWidget::scanForAudio() { |
956 | // odebug << "scan for audio" << oendl; | 956 | // odebug << "scan for audio" << oendl; |
957 | files.detachChildren(); | 957 | files.detachChildren(); |
958 | QListIterator<DocLnk> sdit( files.children() ); | 958 | QListIterator<DocLnk> sdit( files.children() ); |
959 | for ( ; sdit.current(); ++sdit ) { | 959 | for ( ; sdit.current(); ++sdit ) { |
960 | delete sdit.current(); | 960 | delete sdit.current(); |
961 | } | 961 | } |
962 | Global::findDocuments( &files, audioMimes); | 962 | Global::findDocuments( &files, audioMimes); |
963 | audioScan = true; | 963 | audioScan = true; |
964 | } | 964 | } |
965 | void PlayListWidget::scanForVideo() { | 965 | void PlayListWidget::scanForVideo() { |
966 | // odebug << "scan for video" << oendl; | 966 | // odebug << "scan for video" << oendl; |
967 | vFiles.detachChildren(); | 967 | vFiles.detachChildren(); |
968 | QListIterator<DocLnk> sdit( vFiles.children() ); | 968 | QListIterator<DocLnk> sdit( vFiles.children() ); |
969 | for ( ; sdit.current(); ++sdit ) { | 969 | for ( ; sdit.current(); ++sdit ) { |
970 | delete sdit.current(); | 970 | delete sdit.current(); |
971 | } | 971 | } |
972 | Global::findDocuments(&vFiles, "video/*"); | 972 | Global::findDocuments(&vFiles, "video/*"); |
973 | videoScan = true; | 973 | videoScan = true; |
974 | } | 974 | } |
975 | 975 | ||
976 | void PlayListWidget::populateAudioView() { | 976 | void PlayListWidget::populateAudioView() { |
977 | 977 | ||
978 | audioView->clear(); | 978 | audioView->clear(); |
979 | StorageInfo storageInfo; | 979 | StorageInfo storageInfo; |
980 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 980 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
981 | if(!audioScan) scanForAudio(); | 981 | if(!audioScan) scanForAudio(); |
982 | 982 | ||
983 | QListIterator<DocLnk> dit( files.children() ); | 983 | QListIterator<DocLnk> dit( files.children() ); |
984 | QListIterator<FileSystem> it ( fs ); | 984 | QListIterator<FileSystem> it ( fs ); |
985 | 985 | ||
986 | QString storage; | 986 | QString storage; |
987 | for ( ; dit.current(); ++dit ) { | 987 | for ( ; dit.current(); ++dit ) { |
988 | for( ; it.current(); ++it ){ | 988 | for( ; it.current(); ++it ){ |
989 | const QString name = (*it)->name(); | 989 | const QString name = (*it)->name(); |
990 | const QString path = (*it)->path(); | 990 | const QString path = (*it)->path(); |
991 | if(dit.current()->file().find(path) != -1 ) storage=name; | 991 | if(dit.current()->file().find(path) != -1 ) storage=name; |
992 | } | 992 | } |
993 | 993 | ||
994 | QListViewItem * newItem; | 994 | QListViewItem * newItem; |
995 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { | 995 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { |
996 | long size; | 996 | long size; |
997 | if( dit.current()->file().left(4) == "http" ) | 997 | if( dit.current()->file().left(4) == "http" ) |
998 | size=0; | 998 | size=0; |
999 | else | 999 | else |
1000 | size = QFile( dit.current()->file() ).size(); | 1000 | size = QFile( dit.current()->file() ).size(); |
1001 | // odebug << dit.current()->name() << oendl; | 1001 | // odebug << dit.current()->name() << oendl; |
1002 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 1002 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
1003 | QString::number(size ), storage, dit.current()->file()); | 1003 | QString::number(size ), storage, dit.current()->file()); |
1004 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); | 1004 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); |
1005 | } | 1005 | } |
1006 | } | 1006 | } |
1007 | 1007 | ||
1008 | } | 1008 | } |
1009 | 1009 | ||
1010 | void PlayListWidget::populateVideoView() { | 1010 | void PlayListWidget::populateVideoView() { |
1011 | videoView->clear(); | 1011 | videoView->clear(); |
1012 | StorageInfo storageInfo; | 1012 | StorageInfo storageInfo; |
1013 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 1013 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
1014 | 1014 | ||
1015 | if(!videoScan ) scanForVideo(); | 1015 | if(!videoScan ) scanForVideo(); |
1016 | 1016 | ||
1017 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 1017 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
1018 | QListIterator<FileSystem> it ( fs ); | 1018 | QListIterator<FileSystem> it ( fs ); |
1019 | videoView->clear(); | 1019 | videoView->clear(); |
1020 | QString storage; | 1020 | QString storage; |
1021 | for ( ; Vdit.current(); ++Vdit ) { | 1021 | for ( ; Vdit.current(); ++Vdit ) { |
1022 | for( ; it.current(); ++it ){ | 1022 | for( ; it.current(); ++it ){ |
1023 | const QString name = (*it)->name(); | 1023 | const QString name = (*it)->name(); |
1024 | const QString path = (*it)->path(); | 1024 | const QString path = (*it)->path(); |
1025 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 1025 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
1026 | } | 1026 | } |
1027 | 1027 | ||
1028 | QListViewItem * newItem; | 1028 | QListViewItem * newItem; |
1029 | if ( QFile( Vdit.current()->file()).exists() ) { | 1029 | if ( QFile( Vdit.current()->file()).exists() ) { |
1030 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 1030 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
1031 | QString::number( QFile( Vdit.current()->file() ).size() ), | 1031 | QString::number( QFile( Vdit.current()->file() ).size() ), |
1032 | storage, Vdit.current()->file()); | 1032 | storage, Vdit.current()->file()); |
1033 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); | 1033 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); |
1034 | } | 1034 | } |
1035 | } | 1035 | } |
1036 | } | 1036 | } |
1037 | 1037 | ||
1038 | void PlayListWidget::openFile() { | 1038 | void PlayListWidget::openFile() { |
1039 | QString filename, name; | 1039 | QString filename, name; |
1040 | InputDialog *fileDlg; | 1040 | InputDialog *fileDlg; |
1041 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 1041 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
1042 | fileDlg->exec(); | 1042 | fileDlg->exec(); |
1043 | if( fileDlg->result() == 1 ) { | 1043 | if( fileDlg->result() == 1 ) { |
1044 | filename = fileDlg->text(); | 1044 | filename = fileDlg->text(); |
1045 | // odebug << "Selected filename is " + filename << oendl; | 1045 | // odebug << "Selected filename is " + filename << oendl; |
1046 | DocLnk lnk; | 1046 | DocLnk lnk; |
1047 | Config cfg( "OpiePlayer" ); | 1047 | Config cfg( "OpiePlayer" ); |
1048 | cfg.setGroup("PlayList"); | 1048 | cfg.setGroup("PlayList"); |
1049 | 1049 | ||
1050 | QString m3uFile; | 1050 | QString m3uFile; |
1051 | m3uFile = filename; | 1051 | m3uFile = filename; |
1052 | if(filename.left(4) == "http") { | 1052 | if(filename.left(4) == "http") { |
1053 | if(filename.find(":",8,TRUE) != -1) { //found a port | 1053 | if(filename.find(":",8,TRUE) != -1) { //found a port |
1054 | 1054 | ||
1055 | m3uFile = filename; | 1055 | m3uFile = filename; |
1056 | if( m3uFile.right( 1 ).find( '/' ) == -1) { | 1056 | if( m3uFile.right( 1 ).find( '/' ) == -1) { |
1057 | m3uFile += "/"; | 1057 | m3uFile += "/"; |
1058 | } | 1058 | } |
1059 | filename = m3uFile; | 1059 | filename = m3uFile; |
1060 | } | 1060 | } |
1061 | lnk.setName( m3uFile ); //sets name | 1061 | lnk.setName( m3uFile ); //sets name |
1062 | lnk.setFile( filename ); //sets file name | 1062 | lnk.setFile( filename ); //sets file name |
1063 | lnk.setIcon("opieplayer2/musicfile"); | 1063 | lnk.setIcon("opieplayer2/musicfile"); |
1064 | d->selectedFiles->addToSelection( lnk ); | 1064 | d->selectedFiles->addToSelection( lnk ); |
1065 | writeCurrentM3u(); | 1065 | writeCurrentM3u(); |
1066 | } | 1066 | } |
1067 | else if( filename.right( 3) == "m3u" ) { | 1067 | else if( filename.right( 3) == "m3u" ) { |
1068 | readm3u( filename ); | 1068 | readm3u( filename ); |
1069 | 1069 | ||
1070 | } else if( filename.right(3) == "pls" ) { | 1070 | } else if( filename.right(3) == "pls" ) { |
1071 | readPls( filename ); | 1071 | readPls( filename ); |
1072 | } else { | 1072 | } else { |
1073 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name | 1073 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name |
1074 | lnk.setFile( filename ); //sets file name | 1074 | lnk.setFile( filename ); //sets file name |
1075 | d->selectedFiles->addToSelection( lnk); | 1075 | d->selectedFiles->addToSelection( lnk); |
1076 | lnk.removeLinkFile(); | 1076 | lnk.removeLinkFile(); |
1077 | writeCurrentM3u(); | 1077 | writeCurrentM3u(); |
1078 | } | 1078 | } |
1079 | } | 1079 | } |
1080 | 1080 | ||
1081 | if( fileDlg ) { | 1081 | if( fileDlg ) { |
1082 | delete fileDlg; | 1082 | delete fileDlg; |
1083 | } | 1083 | } |
1084 | } | 1084 | } |
1085 | 1085 | ||
1086 | 1086 | ||
1087 | /* | 1087 | /* |
1088 | reads m3u and shows files/urls to playlist widget */ | 1088 | reads m3u and shows files/urls to playlist widget */ |
1089 | void PlayListWidget::readm3u( const QString &filename ) { | 1089 | void PlayListWidget::readm3u( const QString &filename ) { |
1090 | // odebug << "read m3u filename " + filename << oendl; | 1090 | // odebug << "read m3u filename " + filename << oendl; |
1091 | 1091 | ||
1092 | Om3u *m3uList; | 1092 | Om3u *m3uList; |
1093 | QString s, name; | 1093 | QString s, name; |
1094 | m3uList = new Om3u( filename, IO_ReadOnly ); | 1094 | m3uList = new Om3u( filename, IO_ReadOnly ); |
1095 | m3uList->readM3u(); | 1095 | m3uList->readM3u(); |
1096 | DocLnk lnk; | 1096 | DocLnk lnk; |
1097 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 1097 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
1098 | s = *it; | 1098 | s = *it; |
1099 | // odebug << "reading "+ s << oendl; | 1099 | // odebug << "reading "+ s << oendl; |
1100 | if(s.left(4)=="http") { | 1100 | if(s.left(4)=="http") { |
1101 | lnk.setName( s ); //sets file name | 1101 | lnk.setName( s ); //sets file name |
1102 | lnk.setIcon("opieplayer2/musicfile"); | 1102 | lnk.setIcon("opieplayer2/musicfile"); |
1103 | 1103 | ||
1104 | // if(s.right(4) != '.' || s.right(5) != '.') | 1104 | // if(s.right(4) != '.' || s.right(5) != '.') |
1105 | if(s.right(4) != '.' || s.right(5) != '.' ) | 1105 | if(s.right(4) != '.' || s.right(5) != '.' ) |
1106 | if( s.right(1) != "/") | 1106 | if( s.right(1) != "/") |
1107 | lnk.setFile( s+"/"); //if url with no extension | 1107 | lnk.setFile( s+"/"); //if url with no extension |
1108 | else | 1108 | else |
1109 | lnk.setFile( s ); //sets file name | 1109 | lnk.setFile( s ); //sets file name |
1110 | 1110 | ||
1111 | } else { | 1111 | } else { |
1112 | // if( QFileInfo( s ).exists() ) { | 1112 | // if( QFileInfo( s ).exists() ) { |
1113 | lnk.setName( fullBaseName ( QFileInfo(s))); | 1113 | lnk.setName( fullBaseName ( QFileInfo(s))); |
1114 | // if(s.right(4) == '.') {//if regular file | 1114 | // if(s.right(4) == '.') {//if regular file |
1115 | if(s.left(1) != "/") { | 1115 | if(s.left(1) != "/") { |
1116 | // odebug << "set link "+QFileInfo(filename).dirPath()+"/"+s << oendl; | 1116 | // odebug << "set link "+QFileInfo(filename).dirPath()+"/"+s << oendl; |
1117 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 1117 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
1118 | lnk.setIcon("SoundPlayer"); | 1118 | lnk.setIcon("SoundPlayer"); |
1119 | } else { | 1119 | } else { |
1120 | // odebug << "set link2 "+s << oendl; | 1120 | // odebug << "set link2 "+s << oendl; |
1121 | lnk.setFile( s); | 1121 | lnk.setFile( s); |
1122 | lnk.setIcon("SoundPlayer"); | 1122 | lnk.setIcon("SoundPlayer"); |
1123 | } | 1123 | } |
1124 | } | 1124 | } |
1125 | d->selectedFiles->addToSelection( lnk ); | 1125 | d->selectedFiles->addToSelection( lnk ); |
1126 | } | 1126 | } |
1127 | Config config( "OpiePlayer" ); | 1127 | Config config( "OpiePlayer" ); |
1128 | config.setGroup( "PlayList" ); | 1128 | config.setGroup( "PlayList" ); |
1129 | 1129 | ||
1130 | config.writeEntry("CurrentPlaylist",filename); | 1130 | config.writeEntry("CurrentPlaylist",filename); |
1131 | config.write(); | 1131 | config.write(); |
1132 | currentPlayList=filename; | 1132 | currentPlayList=filename; |
1133 | 1133 | ||
1134 | // m3uList->write(); | 1134 | // m3uList->write(); |
1135 | m3uList->close(); | 1135 | m3uList->close(); |
1136 | if(m3uList) delete m3uList; | 1136 | if(m3uList) delete m3uList; |
1137 | 1137 | ||
1138 | d->selectedFiles->setSelectedItem( s); | 1138 | d->selectedFiles->setSelectedItem( s); |
1139 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename))); | 1139 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename))); |
1140 | 1140 | ||
1141 | } | 1141 | } |
1142 | 1142 | ||
1143 | /* | 1143 | /* |
1144 | reads pls and adds files/urls to playlist */ | 1144 | reads pls and adds files/urls to playlist */ |
1145 | void PlayListWidget::readPls( const QString &filename ) { | 1145 | void PlayListWidget::readPls( const QString &filename ) { |
1146 | 1146 | ||
1147 | // odebug << "pls filename is " + filename << oendl; | 1147 | // odebug << "pls filename is " + filename << oendl; |
1148 | Om3u *m3uList; | 1148 | Om3u *m3uList; |
1149 | QString s, name; | 1149 | QString s, name; |
1150 | m3uList = new Om3u( filename, IO_ReadOnly ); | 1150 | m3uList = new Om3u( filename, IO_ReadOnly ); |
1151 | m3uList->readPls(); | 1151 | m3uList->readPls(); |
1152 | 1152 | ||
1153 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 1153 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
1154 | s = *it; | 1154 | s = *it; |
1155 | // s.replace( QRegExp( "%20" )," " ); | 1155 | // s.replace( QRegExp( "%20" )," " ); |
1156 | DocLnk lnk( s ); | 1156 | DocLnk lnk( s ); |
1157 | QFileInfo f( s ); | 1157 | QFileInfo f( s ); |
1158 | QString name = fullBaseName ( f); | 1158 | QString name = fullBaseName ( f); |
1159 | 1159 | ||
1160 | if( name.left( 4 ) == "http" ) { | 1160 | if( name.left( 4 ) == "http" ) { |
1161 | name = s.right( s.length() - 7); | 1161 | name = s.right( s.length() - 7); |
1162 | } else { | 1162 | } else { |
1163 | name = s; | 1163 | name = s; |
1164 | } | 1164 | } |
1165 | 1165 | ||
1166 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 1166 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
1167 | 1167 | ||
1168 | lnk.setName( name ); | 1168 | lnk.setName( name ); |
1169 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | 1169 | if( s.at( s.length() - 4) == '.') {// if this is probably a file |
1170 | lnk.setFile( s ); | 1170 | lnk.setFile( s ); |
1171 | } else { //if its a url | 1171 | } else { //if its a url |
1172 | if( name.right( 1 ).find( '/' ) == -1) { | 1172 | if( name.right( 1 ).find( '/' ) == -1) { |
1173 | s += "/"; | 1173 | s += "/"; |
1174 | } | 1174 | } |
1175 | lnk.setFile( s ); | 1175 | lnk.setFile( s ); |
1176 | } | 1176 | } |
1177 | lnk.setType( "audio/x-mpegurl" ); | 1177 | lnk.setType( "audio/x-mpegurl" ); |
1178 | 1178 | ||
1179 | lnk.writeLink(); | 1179 | lnk.writeLink(); |
1180 | d->selectedFiles->addToSelection( lnk ); | 1180 | d->selectedFiles->addToSelection( lnk ); |
1181 | } | 1181 | } |
1182 | 1182 | ||
1183 | m3uList->close(); | 1183 | m3uList->close(); |
1184 | if(m3uList) delete m3uList; | 1184 | if(m3uList) delete m3uList; |
1185 | } | 1185 | } |
1186 | 1186 | ||
1187 | /* | 1187 | /* |
1188 | writes current playlist to current m3u file */ | 1188 | writes current playlist to current m3u file */ |
1189 | void PlayListWidget::writeCurrentM3u() { | 1189 | void PlayListWidget::writeCurrentM3u() { |
1190 | // odebug << "writing to current m3u" << oendl; | 1190 | // odebug << "writing to current m3u" << oendl; |
1191 | Config cfg( "OpiePlayer" ); | 1191 | Config cfg( "OpiePlayer" ); |
1192 | cfg.setGroup("PlayList"); | 1192 | cfg.setGroup("PlayList"); |
1193 | currentPlayList = cfg.readEntry("CurrentPlaylist",""); | 1193 | currentPlayList = cfg.readEntry("CurrentPlaylist",""); |
1194 | Om3u *m3uList; | 1194 | Om3u *m3uList; |
1195 | m3uList = new Om3u( currentPlayList, IO_ReadWrite | IO_Truncate ); | 1195 | m3uList = new Om3u( currentPlayList, IO_ReadWrite | IO_Truncate ); |
1196 | 1196 | ||
1197 | if( d->selectedFiles->first()) { | 1197 | if( d->selectedFiles->first()) { |
1198 | do { | 1198 | do { |
1199 | // odebug << "writeCurrentM3u " +d->selectedFiles->current()->file() << oendl; | 1199 | // odebug << "writeCurrentM3u " +d->selectedFiles->current()->file() << oendl; |
1200 | m3uList->add( d->selectedFiles->current()->file() ); | 1200 | m3uList->add( d->selectedFiles->current()->file() ); |
1201 | } | 1201 | } |
1202 | while ( d->selectedFiles->next() ); | 1202 | while ( d->selectedFiles->next() ); |
1203 | // odebug << "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" << oendl; | 1203 | // odebug << "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" << oendl; |
1204 | m3uList->write(); | 1204 | m3uList->write(); |
1205 | m3uList->close(); | 1205 | m3uList->close(); |
1206 | 1206 | ||
1207 | if(m3uList) delete m3uList; | 1207 | if(m3uList) delete m3uList; |
1208 | } | 1208 | } |
1209 | } | 1209 | } |
1210 | 1210 | ||
1211 | /* | 1211 | /* |
1212 | writes current playlist to m3u file */ | 1212 | writes current playlist to m3u file */ |
1213 | void PlayListWidget::writem3u() { | 1213 | void PlayListWidget::writem3u() { |
1214 | InputDialog *fileDlg; | 1214 | InputDialog *fileDlg; |
1215 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 1215 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
1216 | fileDlg->exec(); | 1216 | fileDlg->exec(); |
1217 | QString name, filename, list; | 1217 | QString name, filename, list; |
1218 | Om3u *m3uList; | 1218 | Om3u *m3uList; |
1219 | 1219 | ||
1220 | if( fileDlg->result() == 1 ) { | 1220 | if( fileDlg->result() == 1 ) { |
1221 | name = fileDlg->text(); | 1221 | name = fileDlg->text(); |
1222 | // odebug << filename << oendl; | 1222 | // odebug << filename << oendl; |
1223 | if( name.find("/",0,true) != -1) {// assume they specify a file path | 1223 | if( name.find("/",0,true) != -1) {// assume they specify a file path |
1224 | filename = name; | 1224 | filename = name; |
1225 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); | 1225 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); |
1226 | } | 1226 | } |
1227 | else //otherwise dump it somewhere noticable | 1227 | else //otherwise dump it somewhere noticable |
1228 | filename = QPEApplication::documentDir() + "/" + name; | 1228 | filename = QPEApplication::documentDir() + "/" + name; |
1229 | 1229 | ||
1230 | if( filename.right( 3 ) != "m3u" ) //needs filename extension | 1230 | if( filename.right( 3 ) != "m3u" ) //needs filename extension |
1231 | filename += ".m3u"; | 1231 | filename += ".m3u"; |
1232 | 1232 | ||
1233 | if( d->selectedFiles->first()) { | 1233 | if( d->selectedFiles->first()) { |
1234 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 1234 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
1235 | 1235 | ||
1236 | do { | 1236 | do { |
1237 | m3uList->add( d->selectedFiles->current()->file()); | 1237 | m3uList->add( d->selectedFiles->current()->file()); |
1238 | } | 1238 | } |
1239 | while ( d->selectedFiles->next() ); | 1239 | while ( d->selectedFiles->next() ); |
1240 | // odebug << list << oendl; | 1240 | // odebug << list << oendl; |
1241 | m3uList->write(); | 1241 | m3uList->write(); |
1242 | m3uList->close(); | 1242 | m3uList->close(); |
1243 | if(m3uList) delete m3uList; | 1243 | if(m3uList) delete m3uList; |
1244 | 1244 | ||
1245 | if(fileDlg) delete fileDlg; | 1245 | if(fileDlg) delete fileDlg; |
1246 | 1246 | ||
1247 | DocLnk lnk; | 1247 | DocLnk lnk; |
1248 | lnk.setFile( filename); | 1248 | lnk.setFile( filename); |
1249 | lnk.setIcon("opieplayer2/playlist2"); | 1249 | lnk.setIcon("opieplayer2/playlist2"); |
1250 | lnk.setName( name); //sets file name | 1250 | lnk.setName( name); //sets file name |
1251 | 1251 | ||
1252 | // odebug << filename << oendl; | 1252 | // odebug << filename << oendl; |
1253 | Config config( "OpiePlayer" ); | 1253 | Config config( "OpiePlayer" ); |
1254 | config.setGroup( "PlayList" ); | 1254 | config.setGroup( "PlayList" ); |
1255 | 1255 | ||
1256 | config.writeEntry("CurrentPlaylist",filename); | 1256 | config.writeEntry("CurrentPlaylist",filename); |
1257 | currentPlayList=filename; | 1257 | currentPlayList=filename; |
1258 | 1258 | ||
1259 | if(!lnk.writeLink()) { | 1259 | if(!lnk.writeLink()) { |
1260 | // odebug << "Writing doclink did not work" << oendl; | 1260 | // odebug << "Writing doclink did not work" << oendl; |
1261 | } | 1261 | } |
1262 | 1262 | ||
1263 | setCaption(tr("OpiePlayer: ") + name); | 1263 | setCaption(tr("OpiePlayer: ") + name); |
1264 | } | 1264 | } |
1265 | } | 1265 | } |
1266 | } | 1266 | } |
1267 | 1267 | ||
1268 | 1268 | ||
1269 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | 1269 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) |
1270 | { | 1270 | { |
1271 | switch ( e->key() ) { | 1271 | switch ( e->key() ) { |
1272 | ////////////////////////////// Zaurus keys | 1272 | ////////////////////////////// Zaurus keys |
1273 | case Key_F9: //activity | 1273 | case Key_F9: //activity |
1274 | // if(audioUI->isHidden()) | 1274 | // if(audioUI->isHidden()) |
1275 | // audioUI->showMaximized(); | 1275 | // audioUI->showMaximized(); |
1276 | break; | 1276 | break; |
1277 | case Key_F10: //contacts | 1277 | case Key_F10: //contacts |
1278 | // if( videoUI->isHidden()) | 1278 | // if( videoUI->isHidden()) |
1279 | // videoUI->showMaximized(); | 1279 | // videoUI->showMaximized(); |
1280 | break; | 1280 | break; |
1281 | case Key_F11: //menu | 1281 | case Key_F11: //menu |
1282 | break; | 1282 | break; |
1283 | case Key_F12: //home | 1283 | case Key_F12: //home |
1284 | // doBlank(); | 1284 | // doBlank(); |
1285 | break; | 1285 | break; |
1286 | case Key_F13: //mail | 1286 | case Key_F13: //mail |
1287 | // doUnblank(); | 1287 | // doUnblank(); |
1288 | break; | 1288 | break; |
1289 | case Key_Q: //add to playlist | 1289 | case Key_Q: //add to playlist |
1290 | addSelected(); | 1290 | addSelected(); |
1291 | break; | 1291 | break; |
1292 | case Key_R: //remove from playlist | 1292 | case Key_R: //remove from playlist |
1293 | removeSelected(); | 1293 | removeSelected(); |
1294 | break; | 1294 | break; |
1295 | // case Key_P: //play | 1295 | // case Key_P: //play |
1296 | // odebug << "Play" << oendl; | 1296 | // odebug << "Play" << oendl; |
1297 | // playSelected(); | 1297 | // playSelected(); |
1298 | // break; | 1298 | // break; |
1299 | case Key_Space: | 1299 | case Key_Space: |
1300 | // playSelected(); puh | 1300 | // playSelected(); puh |
1301 | break; | 1301 | break; |
1302 | case Key_1: | 1302 | case Key_1: |
1303 | tabWidget->setCurrentPage(0); | 1303 | tabWidget->setCurrentPage(0); |
1304 | break; | 1304 | break; |
1305 | case Key_2: | 1305 | case Key_2: |
1306 | tabWidget->setCurrentPage(1); | 1306 | tabWidget->setCurrentPage(1); |
1307 | break; | 1307 | break; |
1308 | case Key_3: | 1308 | case Key_3: |
1309 | tabWidget->setCurrentPage(2); | 1309 | tabWidget->setCurrentPage(2); |
1310 | break; | 1310 | break; |
1311 | case Key_4: | 1311 | case Key_4: |
1312 | tabWidget->setCurrentPage(3); | 1312 | tabWidget->setCurrentPage(3); |
1313 | break; | 1313 | break; |
1314 | case Key_Down: | 1314 | case Key_Down: |
1315 | if ( !d->selectedFiles->next() ) | 1315 | if ( !d->selectedFiles->next() ) |
1316 | d->selectedFiles->first(); | 1316 | d->selectedFiles->first(); |
1317 | 1317 | ||
1318 | break; | 1318 | break; |
1319 | case Key_Up: | 1319 | case Key_Up: |
1320 | if ( !d->selectedFiles->prev() ) | 1320 | if ( !d->selectedFiles->prev() ) |
1321 | // d->selectedFiles->last(); | 1321 | // d->selectedFiles->last(); |
1322 | 1322 | ||
1323 | break; | 1323 | break; |
1324 | 1324 | ||
1325 | } | 1325 | } |
1326 | } | 1326 | } |
1327 | 1327 | ||
1328 | void PlayListWidget::keyPressEvent( QKeyEvent *) | 1328 | void PlayListWidget::keyPressEvent( QKeyEvent *) |
1329 | { | 1329 | { |
1330 | // odebug << "Key press" << oendl; | 1330 | // odebug << "Key press" << oendl; |
1331 | // switch ( e->key() ) { | 1331 | // switch ( e->key() ) { |
1332 | // ////////////////////////////// Zaurus keys | 1332 | // ////////////////////////////// Zaurus keys |
1333 | // case Key_A: //add to playlist | 1333 | // case Key_A: //add to playlist |
1334 | // odebug << "Add" << oendl; | 1334 | // odebug << "Add" << oendl; |
1335 | // addSelected(); | 1335 | // addSelected(); |
1336 | // break; | 1336 | // break; |
1337 | // case Key_R: //remove from playlist | 1337 | // case Key_R: //remove from playlist |
1338 | // removeSelected(); | 1338 | // removeSelected(); |
1339 | // break; | 1339 | // break; |
1340 | // case Key_P: //play | 1340 | // case Key_P: //play |
1341 | // odebug << "Play" << oendl; | 1341 | // odebug << "Play" << oendl; |
1342 | // playSelected(); | 1342 | // playSelected(); |
1343 | // break; | 1343 | // break; |
1344 | // case Key_Space: | 1344 | // case Key_Space: |
1345 | // odebug << "Play" << oendl; | 1345 | // odebug << "Play" << oendl; |
1346 | // playSelected(); | 1346 | // playSelected(); |
1347 | // break; | 1347 | // break; |
1348 | // } | 1348 | // } |
1349 | } | 1349 | } |
1350 | 1350 | ||
1351 | void PlayListWidget::doBlank() { | 1351 | void PlayListWidget::doBlank() { |
1352 | // odebug << "do blanking" << oendl; | 1352 | // odebug << "do blanking" << oendl; |
1353 | #ifdef QT_QWS_DEVFS | 1353 | #ifdef QT_QWS_DEVFS |
1354 | fd=open("/dev/fb/0",O_RDWR); | 1354 | fd=open("/dev/fb/0",O_RDWR); |
1355 | #else | 1355 | #else |
1356 | fd=open("/dev/fb0",O_RDWR); | 1356 | fd=open("/dev/fb0",O_RDWR); |
1357 | #endif | 1357 | #endif |
1358 | if (fd != -1) { | 1358 | if (fd != -1) { |
1359 | ioctl(fd,FBIOBLANK,1); | 1359 | ioctl(fd,FBIOBLANK,1); |
1360 | // close(fd); | 1360 | // close(fd); |
1361 | } | 1361 | } |
1362 | } | 1362 | } |
1363 | 1363 | ||
1364 | void PlayListWidget::doUnblank() { | 1364 | void PlayListWidget::doUnblank() { |
1365 | // this crashes opieplayer with a segfault | 1365 | // this crashes opieplayer with a segfault |
1366 | // int fd; | 1366 | // int fd; |
1367 | // fd=open("/dev/fb0",O_RDWR); | 1367 | // fd=open("/dev/fb0",O_RDWR); |
1368 | // odebug << "do unblanking" << oendl; | 1368 | // odebug << "do unblanking" << oendl; |
1369 | if (fd != -1) { | 1369 | if (fd != -1) { |
1370 | ioctl(fd,FBIOBLANK,0); | 1370 | ioctl(fd,FBIOBLANK,0); |
1371 | close(fd); | 1371 | close(fd); |
1372 | } | 1372 | } |
1373 | QCopEnvelope h("QPE/System", "setBacklight(int)"); | 1373 | QCopEnvelope h("QPE/System", "setBacklight(int)"); |
1374 | h <<-3;// v[1]; // -3 Force on | 1374 | h <<-3;// v[1]; // -3 Force on |
1375 | } | 1375 | } |
1376 | 1376 | ||
1377 | void PlayListWidget::populateSkinsMenu() { | 1377 | void PlayListWidget::populateSkinsMenu() { |
1378 | int item = 0; | 1378 | int item = 0; |
1379 | defaultSkinIndex = 0; | 1379 | defaultSkinIndex = 0; |
1380 | QString skinName; | 1380 | QString skinName; |
1381 | Config cfg( "OpiePlayer" ); | 1381 | Config cfg( "OpiePlayer" ); |
1382 | cfg.setGroup("Options" ); | 1382 | cfg.setGroup("Options" ); |
1383 | QString skin = cfg.readEntry( "Skin", "default" ); | 1383 | QString skin = cfg.readEntry( "Skin", "default" ); |
1384 | 1384 | ||
1385 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 1385 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
1386 | skinsDir.setFilter( QDir::Dirs ); | 1386 | skinsDir.setFilter( QDir::Dirs ); |
1387 | skinsDir.setSorting(QDir::Name ); | 1387 | skinsDir.setSorting(QDir::Name ); |
1388 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 1388 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
1389 | QFileInfoListIterator it( *skinslist ); | 1389 | QFileInfoListIterator it( *skinslist ); |
1390 | QFileInfo *fi; | 1390 | QFileInfo *fi; |
1391 | while ( ( fi = it.current() ) ) { | 1391 | while ( ( fi = it.current() ) ) { |
1392 | skinName = fi->fileName(); | 1392 | skinName = fi->fileName(); |
1393 | // odebug << fi->fileName() << oendl; | 1393 | // odebug << fi->fileName() << oendl; |
1394 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 1394 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
1395 | item = skinsMenu->insertItem( fi->fileName() ) ; | 1395 | item = skinsMenu->insertItem( fi->fileName() ) ; |
1396 | } | 1396 | } |
1397 | if( skinName == "default" ) { | 1397 | if( skinName == "default" ) { |
1398 | defaultSkinIndex = item; | 1398 | defaultSkinIndex = item; |
1399 | } | 1399 | } |
1400 | if( skinName == skin ) { | 1400 | if( skinName == skin ) { |
1401 | skinsMenu->setItemChecked( item, TRUE ); | 1401 | skinsMenu->setItemChecked( item, TRUE ); |
1402 | } | 1402 | } |
1403 | ++it; | 1403 | ++it; |
1404 | } | 1404 | } |
1405 | } | 1405 | } |
1406 | 1406 | ||
1407 | void PlayListWidget::skinsMenuActivated( int item ) { | 1407 | void PlayListWidget::skinsMenuActivated( int item ) { |
1408 | for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 1408 | for( int i = defaultSkinIndex; i > defaultSkinIndex - static_cast<int>(skinsMenu->count()); i-- ) { |
1409 | skinsMenu->setItemChecked( i, FALSE ); | 1409 | skinsMenu->setItemChecked( i, FALSE ); |
1410 | } | 1410 | } |
1411 | skinsMenu->setItemChecked( item, TRUE ); | 1411 | skinsMenu->setItemChecked( item, TRUE ); |
1412 | 1412 | ||
1413 | Config cfg( "OpiePlayer" ); | 1413 | Config cfg( "OpiePlayer" ); |
1414 | cfg.setGroup("Options"); | 1414 | cfg.setGroup("Options"); |
1415 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 1415 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
1416 | } | 1416 | } |
1417 | 1417 | ||
1418 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { | 1418 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { |
1419 | // odebug << "qcop message "+msg << oendl; | 1419 | // odebug << "qcop message "+msg << oendl; |
1420 | QDataStream stream ( data, IO_ReadOnly ); | 1420 | QDataStream stream ( data, IO_ReadOnly ); |
1421 | if ( msg == "play()" ) { //plays current selection | 1421 | if ( msg == "play()" ) { //plays current selection |
1422 | btnPlay( true); | 1422 | btnPlay( true); |
1423 | } else if ( msg == "stop()" ) { | 1423 | } else if ( msg == "stop()" ) { |
1424 | mediaPlayerState->setPlaying( false); | 1424 | mediaPlayerState->setPlaying( false); |
1425 | } else if ( msg == "togglePause()" ) { | 1425 | } else if ( msg == "togglePause()" ) { |
1426 | mediaPlayerState->togglePaused(); | 1426 | mediaPlayerState->togglePaused(); |
1427 | } else if ( msg == "next()" ) { //select next in lis | 1427 | } else if ( msg == "next()" ) { //select next in lis |
1428 | mediaPlayerState->setNext(); | 1428 | mediaPlayerState->setNext(); |
1429 | } else if ( msg == "prev()" ) { //select previous in list | 1429 | } else if ( msg == "prev()" ) { //select previous in list |
1430 | mediaPlayerState->setPrev(); | 1430 | mediaPlayerState->setPrev(); |
1431 | } else if ( msg == "toggleLooping()" ) { //loop or not loop | 1431 | } else if ( msg == "toggleLooping()" ) { //loop or not loop |
1432 | mediaPlayerState->toggleLooping(); | 1432 | mediaPlayerState->toggleLooping(); |
1433 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled | 1433 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled |
1434 | mediaPlayerState->toggleShuffled(); | 1434 | mediaPlayerState->toggleShuffled(); |
1435 | } else if ( msg == "volUp()" ) { //volume more | 1435 | } else if ( msg == "volUp()" ) { //volume more |
1436 | // emit moreClicked(); | 1436 | // emit moreClicked(); |
1437 | // emit moreReleased(); | 1437 | // emit moreReleased(); |
1438 | } else if ( msg == "volDown()" ) { //volume less | 1438 | } else if ( msg == "volDown()" ) { //volume less |
1439 | // emit lessClicked(); | 1439 | // emit lessClicked(); |
1440 | // emit lessReleased(); | 1440 | // emit lessReleased(); |
1441 | } else if ( msg == "play(QString)" ) { //play this now | 1441 | } else if ( msg == "play(QString)" ) { //play this now |
1442 | QString file; | 1442 | QString file; |
1443 | stream >> file; | 1443 | stream >> file; |
1444 | setDocumentEx( (const QString &) file); | 1444 | setDocumentEx( (const QString &) file); |
1445 | } else if ( msg == "add(QString)" ) { //add to playlist | 1445 | } else if ( msg == "add(QString)" ) { //add to playlist |
1446 | QString file; | 1446 | QString file; |
1447 | stream >> file; | 1447 | stream >> file; |
1448 | QFileInfo fileInfo(file); | 1448 | QFileInfo fileInfo(file); |
1449 | DocLnk lnk; | 1449 | DocLnk lnk; |
1450 | lnk.setName( fileInfo.baseName() ); //sets name | 1450 | lnk.setName( fileInfo.baseName() ); //sets name |
1451 | lnk.setFile( file ); //sets file name | 1451 | lnk.setFile( file ); //sets file name |
1452 | addToSelection( lnk ); | 1452 | addToSelection( lnk ); |
1453 | } else if ( msg == "rem(QString)" ) { //remove from playlist | 1453 | } else if ( msg == "rem(QString)" ) { //remove from playlist |
1454 | QString file; | 1454 | QString file; |
1455 | stream >> file; | 1455 | stream >> file; |
1456 | } else if ( msg == "setDocument(QString)" ) { //loop or not loop | 1456 | } else if ( msg == "setDocument(QString)" ) { //loop or not loop |
1457 | QCopEnvelope h("QPE/Application/opieplayer", "raise()"); | 1457 | QCopEnvelope h("QPE/Application/opieplayer", "raise()"); |
1458 | } | 1458 | } |
1459 | } | 1459 | } |