-rw-r--r-- | noncore/multimedia/opieplayer2/main.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 48 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.h | 3 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidgetgui.cpp | 12 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidgetgui.h | 4 |
5 files changed, 35 insertions, 34 deletions
diff --git a/noncore/multimedia/opieplayer2/main.cpp b/noncore/multimedia/opieplayer2/main.cpp index 24aba6c..02fdbf3 100644 --- a/noncore/multimedia/opieplayer2/main.cpp +++ b/noncore/multimedia/opieplayer2/main.cpp | |||
@@ -1,34 +1,34 @@ | |||
1 | 1 | ||
2 | #include <qpe/qpeapplication.h> | 2 | #include <qpe/qpeapplication.h> |
3 | #include "mediaplayerstate.h" | 3 | #include "mediaplayerstate.h" |
4 | #include "playlistwidget.h" | 4 | #include "playlistwidget.h" |
5 | #include "audiowidget.h" | 5 | #include "audiowidget.h" |
6 | #include "videowidget.h" | 6 | #include "videowidget.h" |
7 | #include "mediaplayer.h" | 7 | #include "mediaplayer.h" |
8 | 8 | ||
9 | MediaPlayerState *mediaPlayerState; | 9 | MediaPlayerState *mediaPlayerState; |
10 | PlayListWidget *playList; | 10 | PlayListWidget *playList; |
11 | AudioWidget *audioUI; | 11 | AudioWidget *audioUI; |
12 | VideoWidget *videoUI; | 12 | VideoWidget *videoUI; |
13 | 13 | ||
14 | int main(int argc, char **argv) { | 14 | int main(int argc, char **argv) { |
15 | QPEApplication a(argc,argv); | 15 | QPEApplication a(argc,argv); |
16 | 16 | ||
17 | MediaPlayerState st( 0, "mediaPlayerState" ); | 17 | MediaPlayerState st( 0, "mediaPlayerState" ); |
18 | mediaPlayerState = &st; | 18 | mediaPlayerState = &st; |
19 | PlayListWidget pl( 0, "playList" ); | 19 | PlayListWidget pl( st, 0, "playList" ); |
20 | playList = &pl; | 20 | playList = &pl; |
21 | pl.showMaximized(); | 21 | pl.showMaximized(); |
22 | AudioWidget aw( 0, "audioUI" ); | 22 | AudioWidget aw( 0, "audioUI" ); |
23 | audioUI = &aw; | 23 | audioUI = &aw; |
24 | VideoWidget vw( 0, "videoUI" ); | 24 | VideoWidget vw( 0, "videoUI" ); |
25 | videoUI = &vw; | 25 | videoUI = &vw; |
26 | a.processEvents(); | 26 | a.processEvents(); |
27 | MediaPlayer mp( st, 0, "mediaPlayer" ); | 27 | MediaPlayer mp( st, 0, "mediaPlayer" ); |
28 | 28 | ||
29 | a.showMainDocumentWidget(&pl); | 29 | a.showMainDocumentWidget(&pl); |
30 | 30 | ||
31 | return a.exec(); | 31 | return a.exec(); |
32 | } | 32 | } |
33 | 33 | ||
34 | 34 | ||
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index b08204e..7ba342b 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -1,809 +1,809 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; General Public License for more | 22 | ..}^=.= = ; General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = General Public License along with | 26 | -_. . . )=. = General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <qpe/qpetoolbar.h> | 34 | #include <qpe/qpetoolbar.h> |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | #include <qpe/storage.h> | 36 | #include <qpe/storage.h> |
37 | #include <qpe/mimetype.h> | 37 | #include <qpe/mimetype.h> |
38 | #include <qpe/global.h> | 38 | #include <qpe/global.h> |
39 | #include <qpe/resource.h> | 39 | #include <qpe/resource.h> |
40 | 40 | ||
41 | #include <qdatetime.h> | 41 | #include <qdatetime.h> |
42 | #include <qdir.h> | 42 | #include <qdir.h> |
43 | #include <qmessagebox.h> | 43 | #include <qmessagebox.h> |
44 | #include <qregexp.h> | 44 | #include <qregexp.h> |
45 | #include <qtextstream.h> | 45 | #include <qtextstream.h> |
46 | 46 | ||
47 | #include "playlistselection.h" | 47 | #include "playlistselection.h" |
48 | #include "playlistwidget.h" | 48 | #include "playlistwidget.h" |
49 | #include "mediaplayerstate.h" | 49 | #include "mediaplayerstate.h" |
50 | #include "inputDialog.h" | 50 | #include "inputDialog.h" |
51 | #include "om3u.h" | 51 | #include "om3u.h" |
52 | 52 | ||
53 | //only needed for the random play | 53 | //only needed for the random play |
54 | #include <stdlib.h> | 54 | #include <stdlib.h> |
55 | #include <assert.h> | 55 | #include <assert.h> |
56 | 56 | ||
57 | #include "audiowidget.h" | 57 | #include "audiowidget.h" |
58 | #include "videowidget.h" | 58 | #include "videowidget.h" |
59 | 59 | ||
60 | extern MediaPlayerState *mediaPlayerState; | 60 | extern MediaPlayerState *mediaPlayerState; |
61 | // extern AudioWidget *audioUI; | 61 | // extern AudioWidget *audioUI; |
62 | // extern VideoWidget *videoUI; | 62 | // extern VideoWidget *videoUI; |
63 | 63 | ||
64 | QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg"; | 64 | QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg"; |
65 | // no m3u's here please | 65 | // no m3u's here please |
66 | 66 | ||
67 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 67 | PlayListWidget::PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) |
68 | : PlayListWidgetGui( parent, name, fl ) { | 68 | : PlayListWidgetGui( mediaPlayerState, parent, name ) { |
69 | 69 | ||
70 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), | 70 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), |
71 | "opieplayer2/add_to_playlist", | 71 | "opieplayer2/add_to_playlist", |
72 | this , SLOT(addSelected() ) ); | 72 | this , SLOT(addSelected() ) ); |
73 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), | 73 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), |
74 | "opieplayer2/remove_from_playlist", | 74 | "opieplayer2/remove_from_playlist", |
75 | this , SLOT(removeSelected() ) ); | 75 | this , SLOT(removeSelected() ) ); |
76 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", | 76 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", |
77 | this , SLOT( btnPlay( bool) ), TRUE ); | 77 | this , SLOT( btnPlay( bool) ), TRUE ); |
78 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", | 78 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", |
79 | mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); | 79 | &mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); |
80 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", | 80 | d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", |
81 | mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); | 81 | &mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); |
82 | 82 | ||
83 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 83 | (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
84 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), | 84 | (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), |
85 | this, SLOT( addAllMusicToList() ) ); | 85 | this, SLOT( addAllMusicToList() ) ); |
86 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), | 86 | (void)new MenuItem( pmPlayList, tr( "Add all video files" ), |
87 | this, SLOT( addAllVideoToList() ) ); | 87 | this, SLOT( addAllVideoToList() ) ); |
88 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), | 88 | (void)new MenuItem( pmPlayList, tr( "Add all files" ), |
89 | this, SLOT( addAllToList() ) ); | 89 | this, SLOT( addAllToList() ) ); |
90 | pmPlayList->insertSeparator(-1); | 90 | pmPlayList->insertSeparator(-1); |
91 | // (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), | 91 | // (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), |
92 | // this, SLOT( saveList() ) ); | 92 | // this, SLOT( saveList() ) ); |
93 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), | 93 | (void)new MenuItem( pmPlayList, tr( "Save Playlist" ), |
94 | this, SLOT(writem3u() ) ); | 94 | this, SLOT(writem3u() ) ); |
95 | pmPlayList->insertSeparator(-1); | 95 | pmPlayList->insertSeparator(-1); |
96 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), | 96 | (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), |
97 | this,SLOT( openFile() ) ); | 97 | this,SLOT( openFile() ) ); |
98 | pmPlayList->insertSeparator(-1); | 98 | pmPlayList->insertSeparator(-1); |
99 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), | 99 | (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), |
100 | this,SLOT( scanForAudio() ) ); | 100 | this,SLOT( scanForAudio() ) ); |
101 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), | 101 | (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), |
102 | this,SLOT( scanForVideo() ) ); | 102 | this,SLOT( scanForVideo() ) ); |
103 | 103 | ||
104 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), | 104 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), |
105 | mediaPlayerState, SLOT( toggleFullscreen() ) ); | 105 | &mediaPlayerState, SLOT( toggleFullscreen() ) ); |
106 | 106 | ||
107 | Config cfg( "OpiePlayer" ); | 107 | Config cfg( "OpiePlayer" ); |
108 | bool b= cfg.readBoolEntry("FullScreen", 0); | 108 | bool b= cfg.readBoolEntry("FullScreen", 0); |
109 | mediaPlayerState->setFullscreen( b ); | 109 | mediaPlayerState.setFullscreen( b ); |
110 | pmView->setItemChecked( -16, b ); | 110 | pmView->setItemChecked( -16, b ); |
111 | 111 | ||
112 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", | 112 | (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", |
113 | d->selectedFiles, SLOT(moveSelectedUp() ) ); | 113 | d->selectedFiles, SLOT(moveSelectedUp() ) ); |
114 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", | 114 | (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", |
115 | d->selectedFiles, SLOT(removeSelected() ) ); | 115 | d->selectedFiles, SLOT(removeSelected() ) ); |
116 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", | 116 | (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", |
117 | d->selectedFiles, SLOT(moveSelectedDown() ) ); | 117 | d->selectedFiles, SLOT(moveSelectedDown() ) ); |
118 | // QVBox *stretch2 = new QVBox( vbox1 ); | 118 | // QVBox *stretch2 = new QVBox( vbox1 ); |
119 | 119 | ||
120 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), | 120 | connect( tbDeletePlaylist, ( SIGNAL( released() ) ), |
121 | SLOT( deletePlaylist() ) ); | 121 | SLOT( deletePlaylist() ) ); |
122 | connect( pmView, SIGNAL( activated( int ) ), | 122 | connect( pmView, SIGNAL( activated( int ) ), |
123 | this, SLOT( pmViewActivated( int ) ) ); | 123 | this, SLOT( pmViewActivated( int ) ) ); |
124 | connect( skinsMenu, SIGNAL( activated( int ) ) , | 124 | connect( skinsMenu, SIGNAL( activated( int ) ) , |
125 | this, SLOT( skinsMenuActivated( int ) ) ); | 125 | this, SLOT( skinsMenuActivated( int ) ) ); |
126 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 126 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
127 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 127 | this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
128 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), | 128 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), |
129 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); | 129 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); |
130 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), | 130 | connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), |
131 | this,SLOT( playIt( QListViewItem *) ) ); | 131 | this,SLOT( playIt( QListViewItem *) ) ); |
132 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), | 132 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), |
133 | this, SLOT( addToSelection( QListViewItem *) ) ); | 133 | this, SLOT( addToSelection( QListViewItem *) ) ); |
134 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), | 134 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), |
135 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); | 135 | this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); |
136 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), | 136 | connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), |
137 | this,SLOT( playIt( QListViewItem *) ) ); | 137 | this,SLOT( playIt( QListViewItem *) ) ); |
138 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), | 138 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), |
139 | this, SLOT( addToSelection( QListViewItem *) ) ); | 139 | this, SLOT( addToSelection( QListViewItem *) ) ); |
140 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), | 140 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), |
141 | this, SLOT( loadList( const DocLnk & ) ) ); | 141 | this, SLOT( loadList( const DocLnk & ) ) ); |
142 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), | 142 | connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), |
143 | this, SLOT( tabChanged( QWidget* ) ) ); | 143 | this, SLOT( tabChanged( QWidget* ) ) ); |
144 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), | 144 | connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), |
145 | d->tbPlay, SLOT( setOn( bool ) ) ); | 145 | d->tbPlay, SLOT( setOn( bool ) ) ); |
146 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), | 146 | connect( &mediaPlayerState, SIGNAL( loopingToggled( bool ) ), |
147 | d->tbLoop, SLOT( setOn( bool ) ) ); | 147 | d->tbLoop, SLOT( setOn( bool ) ) ); |
148 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), | 148 | connect( &mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), |
149 | d->tbShuffle, SLOT( setOn( bool ) ) ); | 149 | d->tbShuffle, SLOT( setOn( bool ) ) ); |
150 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), | 150 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), |
151 | this, SLOT( playIt( QListViewItem *) ) ); | 151 | this, SLOT( playIt( QListViewItem *) ) ); |
152 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), | 152 | connect ( gammaSlider, SIGNAL( valueChanged( int ) ), |
153 | mediaPlayerState, SLOT( setVideoGamma( int ) ) ); | 153 | &mediaPlayerState, SLOT( setVideoGamma( int ) ) ); |
154 | 154 | ||
155 | // see which skins are installed | 155 | // see which skins are installed |
156 | videoScan=false; | 156 | videoScan=false; |
157 | audioScan=false; | 157 | audioScan=false; |
158 | audioPopulated=false; | 158 | audioPopulated=false; |
159 | videoPopulated=false; | 159 | videoPopulated=false; |
160 | populateSkinsMenu(); | 160 | populateSkinsMenu(); |
161 | initializeStates(); | 161 | initializeStates(); |
162 | 162 | ||
163 | cfg.setGroup("PlayList"); | 163 | cfg.setGroup("PlayList"); |
164 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); | 164 | QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "default"); |
165 | loadList(DocLnk( currentPlaylist ) ); | 165 | loadList(DocLnk( currentPlaylist ) ); |
166 | } | 166 | } |
167 | 167 | ||
168 | 168 | ||
169 | PlayListWidget::~PlayListWidget() { | 169 | PlayListWidget::~PlayListWidget() { |
170 | delete d; | 170 | delete d; |
171 | } | 171 | } |
172 | 172 | ||
173 | 173 | ||
174 | void PlayListWidget::initializeStates() { | 174 | void PlayListWidget::initializeStates() { |
175 | d->tbPlay->setOn( mediaPlayerState->isPlaying() ); | 175 | d->tbPlay->setOn( mediaPlayerState.isPlaying() ); |
176 | d->tbLoop->setOn( mediaPlayerState->isLooping() ); | 176 | d->tbLoop->setOn( mediaPlayerState.isLooping() ); |
177 | d->tbShuffle->setOn( mediaPlayerState->isShuffled() ); | 177 | d->tbShuffle->setOn( mediaPlayerState.isShuffled() ); |
178 | d->playListFrame->show(); | 178 | d->playListFrame->show(); |
179 | } | 179 | } |
180 | 180 | ||
181 | void PlayListWidget::writeDefaultPlaylist() { | 181 | void PlayListWidget::writeDefaultPlaylist() { |
182 | 182 | ||
183 | Config config( "OpiePlayer" ); | 183 | Config config( "OpiePlayer" ); |
184 | config.setGroup( "PlayList" ); | 184 | config.setGroup( "PlayList" ); |
185 | QString filename=QPEApplication::documentDir() + "/default.m3u"; | 185 | QString filename=QPEApplication::documentDir() + "/default.m3u"; |
186 | QString currentString = config.readEntry( "CurrentPlaylist", filename); | 186 | QString currentString = config.readEntry( "CurrentPlaylist", filename); |
187 | if( currentString == filename) { | 187 | if( currentString == filename) { |
188 | Om3u *m3uList; | 188 | Om3u *m3uList; |
189 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); | 189 | // qDebug("<<<<<<<<<<<<<default>>>>>>>>>>>>>>>>>>>"); |
190 | if( d->selectedFiles->first() ) { | 190 | if( d->selectedFiles->first() ) { |
191 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); | 191 | m3uList = new Om3u(filename, IO_ReadWrite | IO_Truncate); |
192 | do { | 192 | do { |
193 | // qDebug(d->selectedFiles->current()->file()); | 193 | // qDebug(d->selectedFiles->current()->file()); |
194 | m3uList->add( d->selectedFiles->current()->file() ); | 194 | m3uList->add( d->selectedFiles->current()->file() ); |
195 | } | 195 | } |
196 | while ( d->selectedFiles->next() ); | 196 | while ( d->selectedFiles->next() ); |
197 | 197 | ||
198 | m3uList->write(); | 198 | m3uList->write(); |
199 | m3uList->close(); | 199 | m3uList->close(); |
200 | if(m3uList) delete m3uList; | 200 | if(m3uList) delete m3uList; |
201 | 201 | ||
202 | } | 202 | } |
203 | } | 203 | } |
204 | } | 204 | } |
205 | 205 | ||
206 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 206 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
207 | d->setDocumentUsed = FALSE; | 207 | d->setDocumentUsed = FALSE; |
208 | if( QFileInfo( lnk.file() ).exists() || | 208 | if( QFileInfo( lnk.file() ).exists() || |
209 | lnk.file().left(4) == "http" ) { | 209 | lnk.file().left(4) == "http" ) { |
210 | d->selectedFiles->addToSelection( lnk ); | 210 | d->selectedFiles->addToSelection( lnk ); |
211 | } | 211 | } |
212 | // writeCurrentM3u(); | 212 | // writeCurrentM3u(); |
213 | } | 213 | } |
214 | 214 | ||
215 | 215 | ||
216 | void PlayListWidget::clearList() { | 216 | void PlayListWidget::clearList() { |
217 | while ( first() ) { | 217 | while ( first() ) { |
218 | d->selectedFiles->removeSelected(); | 218 | d->selectedFiles->removeSelected(); |
219 | } | 219 | } |
220 | } | 220 | } |
221 | 221 | ||
222 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { | 222 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
223 | switch (mouse) { | 223 | switch (mouse) { |
224 | case 1: | 224 | case 1: |
225 | break; | 225 | break; |
226 | case 2: | 226 | case 2: |
227 | { | 227 | { |
228 | QPopupMenu m; | 228 | QPopupMenu m; |
229 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 229 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
230 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 230 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
231 | m.exec( QCursor::pos() ); | 231 | m.exec( QCursor::pos() ); |
232 | } | 232 | } |
233 | break; | 233 | break; |
234 | } | 234 | } |
235 | } | 235 | } |
236 | 236 | ||
237 | 237 | ||
238 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 238 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
239 | switch (mouse) { | 239 | switch (mouse) { |
240 | case 1: | 240 | case 1: |
241 | break; | 241 | break; |
242 | case 2: | 242 | case 2: |
243 | { | 243 | { |
244 | QPopupMenu m; | 244 | QPopupMenu m; |
245 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 245 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
246 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 246 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
247 | m.exec( QCursor::pos() ); | 247 | m.exec( QCursor::pos() ); |
248 | } | 248 | } |
249 | break; | 249 | break; |
250 | } | 250 | } |
251 | } | 251 | } |
252 | 252 | ||
253 | 253 | ||
254 | void PlayListWidget::addAllToList() { | 254 | void PlayListWidget::addAllToList() { |
255 | 255 | ||
256 | // QTime t; | 256 | // QTime t; |
257 | // t.start(); | 257 | // t.start(); |
258 | 258 | ||
259 | if(!audioScan) { | 259 | if(!audioScan) { |
260 | if(audioView->childCount() < 1) | 260 | if(audioView->childCount() < 1) |
261 | populateAudioView(); | 261 | populateAudioView(); |
262 | } | 262 | } |
263 | 263 | ||
264 | QListViewItemIterator audioIt( audioView ); | 264 | QListViewItemIterator audioIt( audioView ); |
265 | DocLnk lnk; | 265 | DocLnk lnk; |
266 | QString filename; | 266 | QString filename; |
267 | // iterate through all items of the listview | 267 | // iterate through all items of the listview |
268 | for ( ; audioIt.current(); ++audioIt ) { | 268 | for ( ; audioIt.current(); ++audioIt ) { |
269 | filename = audioIt.current()->text(3); | 269 | filename = audioIt.current()->text(3); |
270 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 270 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
271 | lnk.setFile( filename ); //sets file name | 271 | lnk.setFile( filename ); //sets file name |
272 | d->selectedFiles->addToSelection( lnk); | 272 | d->selectedFiles->addToSelection( lnk); |
273 | } | 273 | } |
274 | 274 | ||
275 | if(!videoScan) { | 275 | if(!videoScan) { |
276 | if(videoView->childCount() < 1) | 276 | if(videoView->childCount() < 1) |
277 | populateVideoView(); | 277 | populateVideoView(); |
278 | } | 278 | } |
279 | 279 | ||
280 | QListViewItemIterator videoIt( videoView ); | 280 | QListViewItemIterator videoIt( videoView ); |
281 | for ( ; videoIt.current(); ++videoIt ) { | 281 | for ( ; videoIt.current(); ++videoIt ) { |
282 | filename = videoIt.current()->text(3); | 282 | filename = videoIt.current()->text(3); |
283 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 283 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
284 | lnk.setFile( filename ); //sets file name | 284 | lnk.setFile( filename ); //sets file name |
285 | d->selectedFiles->addToSelection( lnk); | 285 | d->selectedFiles->addToSelection( lnk); |
286 | } | 286 | } |
287 | 287 | ||
288 | // d->selectedFiles->addToSelection( ); | 288 | // d->selectedFiles->addToSelection( ); |
289 | // if ( it.current()->isSelected() ) | 289 | // if ( it.current()->isSelected() ) |
290 | // lst->append( audioIt.current() ); | 290 | // lst->append( audioIt.current() ); |
291 | // } | 291 | // } |
292 | 292 | ||
293 | 293 | ||
294 | // if(!audioScan) | 294 | // if(!audioScan) |
295 | // scanForAudio(); | 295 | // scanForAudio(); |
296 | // if(!videoScan) | 296 | // if(!videoScan) |
297 | // scanForVideo(); | 297 | // scanForVideo(); |
298 | 298 | ||
299 | // DocLnkSet filesAll; | 299 | // DocLnkSet filesAll; |
300 | // Global::findDocuments(&filesAll, "video/*;"+audioMimes); | 300 | // Global::findDocuments(&filesAll, "video/*;"+audioMimes); |
301 | // QListIterator<DocLnk> Adit( filesAll.children() ); | 301 | // QListIterator<DocLnk> Adit( filesAll.children() ); |
302 | // for ( ; Adit.current(); ++Adit ) { | 302 | // for ( ; Adit.current(); ++Adit ) { |
303 | // if( QFileInfo( Adit.current()->file() ).exists() ) { | 303 | // if( QFileInfo( Adit.current()->file() ).exists() ) { |
304 | // d->selectedFiles->addToSelection( **Adit ); | 304 | // d->selectedFiles->addToSelection( **Adit ); |
305 | // } | 305 | // } |
306 | // } | 306 | // } |
307 | 307 | ||
308 | // qDebug("elapsed time %d", t.elapsed() ); | 308 | // qDebug("elapsed time %d", t.elapsed() ); |
309 | 309 | ||
310 | tabWidget->setCurrentPage(0); | 310 | tabWidget->setCurrentPage(0); |
311 | 311 | ||
312 | writeCurrentM3u(); | 312 | writeCurrentM3u(); |
313 | d->selectedFiles->first(); | 313 | d->selectedFiles->first(); |
314 | } | 314 | } |
315 | 315 | ||
316 | 316 | ||
317 | void PlayListWidget::addAllMusicToList() { | 317 | void PlayListWidget::addAllMusicToList() { |
318 | 318 | ||
319 | if(!audioScan) { | 319 | if(!audioScan) { |
320 | if(audioView->childCount() < 1) | 320 | if(audioView->childCount() < 1) |
321 | populateAudioView(); | 321 | populateAudioView(); |
322 | } | 322 | } |
323 | 323 | ||
324 | QListViewItemIterator audioIt( audioView ); | 324 | QListViewItemIterator audioIt( audioView ); |
325 | DocLnk lnk; | 325 | DocLnk lnk; |
326 | QString filename; | 326 | QString filename; |
327 | // iterate through all items of the listview | 327 | // iterate through all items of the listview |
328 | for ( ; audioIt.current(); ++audioIt ) { | 328 | for ( ; audioIt.current(); ++audioIt ) { |
329 | filename = audioIt.current()->text(3); | 329 | filename = audioIt.current()->text(3); |
330 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 330 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
331 | lnk.setFile( filename ); //sets file name | 331 | lnk.setFile( filename ); //sets file name |
332 | d->selectedFiles->addToSelection( lnk); | 332 | d->selectedFiles->addToSelection( lnk); |
333 | } | 333 | } |
334 | 334 | ||
335 | /* if(!audioScan) | 335 | /* if(!audioScan) |
336 | scanForAudio(); | 336 | scanForAudio(); |
337 | QListIterator<DocLnk> dit( files.children() ); | 337 | QListIterator<DocLnk> dit( files.children() ); |
338 | for ( ; dit.current(); ++dit ) { | 338 | for ( ; dit.current(); ++dit ) { |
339 | if( QFileInfo(dit.current()->file() ).exists() ) { | 339 | if( QFileInfo(dit.current()->file() ).exists() ) { |
340 | d->selectedFiles->addToSelection( **dit ); | 340 | d->selectedFiles->addToSelection( **dit ); |
341 | } | 341 | } |
342 | } | 342 | } |
343 | */ | 343 | */ |
344 | tabWidget->setCurrentPage(0); | 344 | tabWidget->setCurrentPage(0); |
345 | writeCurrentM3u(); | 345 | writeCurrentM3u(); |
346 | d->selectedFiles->first(); | 346 | d->selectedFiles->first(); |
347 | } | 347 | } |
348 | 348 | ||
349 | 349 | ||
350 | void PlayListWidget::addAllVideoToList() { | 350 | void PlayListWidget::addAllVideoToList() { |
351 | 351 | ||
352 | if(!videoScan) { | 352 | if(!videoScan) { |
353 | if(videoView->childCount() < 1) | 353 | if(videoView->childCount() < 1) |
354 | populateVideoView(); | 354 | populateVideoView(); |
355 | } | 355 | } |
356 | 356 | ||
357 | QListViewItemIterator videoIt( videoView ); | 357 | QListViewItemIterator videoIt( videoView ); |
358 | DocLnk lnk; | 358 | DocLnk lnk; |
359 | QString filename; | 359 | QString filename; |
360 | for ( ; videoIt.current(); ++videoIt ) { | 360 | for ( ; videoIt.current(); ++videoIt ) { |
361 | filename = videoIt.current()->text(3); | 361 | filename = videoIt.current()->text(3); |
362 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 362 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
363 | lnk.setFile( filename ); //sets file name | 363 | lnk.setFile( filename ); //sets file name |
364 | d->selectedFiles->addToSelection( lnk); | 364 | d->selectedFiles->addToSelection( lnk); |
365 | } | 365 | } |
366 | 366 | ||
367 | 367 | ||
368 | /* if(!videoScan) | 368 | /* if(!videoScan) |
369 | scanForVideo(); | 369 | scanForVideo(); |
370 | QListIterator<DocLnk> dit( vFiles.children() ); | 370 | QListIterator<DocLnk> dit( vFiles.children() ); |
371 | for ( ; dit.current(); ++dit ) { | 371 | for ( ; dit.current(); ++dit ) { |
372 | if( QFileInfo( dit.current()->file() ).exists() ) { | 372 | if( QFileInfo( dit.current()->file() ).exists() ) { |
373 | d->selectedFiles->addToSelection( **dit ); | 373 | d->selectedFiles->addToSelection( **dit ); |
374 | } | 374 | } |
375 | } | 375 | } |
376 | */ | 376 | */ |
377 | tabWidget->setCurrentPage(0); | 377 | tabWidget->setCurrentPage(0); |
378 | writeCurrentM3u(); | 378 | writeCurrentM3u(); |
379 | d->selectedFiles->first(); | 379 | d->selectedFiles->first(); |
380 | } | 380 | } |
381 | 381 | ||
382 | 382 | ||
383 | void PlayListWidget::setDocument( const QString& fileref ) { | 383 | void PlayListWidget::setDocument( const QString& fileref ) { |
384 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); | 384 | // qDebug( "<<<<<<<<set document>>>>>>>>>> "+fileref ); |
385 | fromSetDocument = TRUE; | 385 | fromSetDocument = TRUE; |
386 | if ( fileref.isNull() ) { | 386 | if ( fileref.isNull() ) { |
387 | QMessageBox::warning( this, tr( "Invalid File" ), | 387 | QMessageBox::warning( this, tr( "Invalid File" ), |
388 | tr( "There was a problem in getting the file." ) ); | 388 | tr( "There was a problem in getting the file." ) ); |
389 | return; | 389 | return; |
390 | } | 390 | } |
391 | 391 | ||
392 | clearList(); | 392 | clearList(); |
393 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u | 393 | if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u |
394 | readm3u( fileref ); | 394 | readm3u( fileref ); |
395 | } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { | 395 | } else if( DocLnk( fileref).file().find( "m3u", 0, TRUE) != -1 ) { |
396 | readm3u( DocLnk( fileref).file() ); | 396 | readm3u( DocLnk( fileref).file() ); |
397 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls | 397 | } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls |
398 | readPls( fileref ); | 398 | readPls( fileref ); |
399 | } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { | 399 | } else if( DocLnk( fileref).file().find( "pls", 0, TRUE) != -1 ) { |
400 | readPls( DocLnk( fileref).file() ); | 400 | readPls( DocLnk( fileref).file() ); |
401 | } else { | 401 | } else { |
402 | clearList(); | 402 | clearList(); |
403 | addToSelection( DocLnk( fileref ) ); | 403 | addToSelection( DocLnk( fileref ) ); |
404 | writeCurrentM3u(); | 404 | writeCurrentM3u(); |
405 | 405 | ||
406 | d->setDocumentUsed = TRUE; | 406 | d->setDocumentUsed = TRUE; |
407 | mediaPlayerState->setPlaying( FALSE ); | 407 | mediaPlayerState.setPlaying( FALSE ); |
408 | mediaPlayerState->setPlaying( TRUE ); | 408 | mediaPlayerState.setPlaying( TRUE ); |
409 | } | 409 | } |
410 | } | 410 | } |
411 | 411 | ||
412 | 412 | ||
413 | void PlayListWidget::useSelectedDocument() { | 413 | void PlayListWidget::useSelectedDocument() { |
414 | d->setDocumentUsed = FALSE; | 414 | d->setDocumentUsed = FALSE; |
415 | } | 415 | } |
416 | 416 | ||
417 | 417 | ||
418 | const DocLnk *PlayListWidget::current() const { // this is fugly | 418 | const DocLnk *PlayListWidget::current() const { // this is fugly |
419 | assert( currentTab() == CurrentPlayList ); | 419 | assert( currentTab() == CurrentPlayList ); |
420 | 420 | ||
421 | const DocLnk *lnk = d->selectedFiles->current(); | 421 | const DocLnk *lnk = d->selectedFiles->current(); |
422 | if ( !lnk ) { | 422 | if ( !lnk ) { |
423 | d->selectedFiles->first(); | 423 | d->selectedFiles->first(); |
424 | lnk = d->selectedFiles->current(); | 424 | lnk = d->selectedFiles->current(); |
425 | } | 425 | } |
426 | assert( lnk ); | 426 | assert( lnk ); |
427 | return lnk; | 427 | return lnk; |
428 | } | 428 | } |
429 | 429 | ||
430 | 430 | ||
431 | bool PlayListWidget::prev() { | 431 | bool PlayListWidget::prev() { |
432 | if ( mediaPlayerState->isShuffled() ) { | 432 | if ( mediaPlayerState.isShuffled() ) { |
433 | const DocLnk *cur = current(); | 433 | const DocLnk *cur = current(); |
434 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 434 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
435 | for ( int i = 0; i < j; i++ ) { | 435 | for ( int i = 0; i < j; i++ ) { |
436 | if ( !d->selectedFiles->next() ) | 436 | if ( !d->selectedFiles->next() ) |
437 | d->selectedFiles->first(); | 437 | d->selectedFiles->first(); |
438 | } | 438 | } |
439 | if ( cur == current() ) | 439 | if ( cur == current() ) |
440 | if ( !d->selectedFiles->next() ) { | 440 | if ( !d->selectedFiles->next() ) { |
441 | d->selectedFiles->first(); | 441 | d->selectedFiles->first(); |
442 | } | 442 | } |
443 | return TRUE; | 443 | return TRUE; |
444 | } else { | 444 | } else { |
445 | if ( !d->selectedFiles->prev() ) { | 445 | if ( !d->selectedFiles->prev() ) { |
446 | if ( mediaPlayerState->isLooping() ) { | 446 | if ( mediaPlayerState.isLooping() ) { |
447 | return d->selectedFiles->last(); | 447 | return d->selectedFiles->last(); |
448 | } else { | 448 | } else { |
449 | return FALSE; | 449 | return FALSE; |
450 | } | 450 | } |
451 | } | 451 | } |
452 | return TRUE; | 452 | return TRUE; |
453 | } | 453 | } |
454 | } | 454 | } |
455 | 455 | ||
456 | 456 | ||
457 | bool PlayListWidget::next() { | 457 | bool PlayListWidget::next() { |
458 | //qDebug("<<<<<<<<<<<<next()"); | 458 | //qDebug("<<<<<<<<<<<<next()"); |
459 | if ( mediaPlayerState->isShuffled() ) { | 459 | if ( mediaPlayerState.isShuffled() ) { |
460 | return prev(); | 460 | return prev(); |
461 | } else { | 461 | } else { |
462 | if ( !d->selectedFiles->next() ) { | 462 | if ( !d->selectedFiles->next() ) { |
463 | if ( mediaPlayerState->isLooping() ) { | 463 | if ( mediaPlayerState.isLooping() ) { |
464 | return d->selectedFiles->first(); | 464 | return d->selectedFiles->first(); |
465 | } else { | 465 | } else { |
466 | return FALSE; | 466 | return FALSE; |
467 | } | 467 | } |
468 | } | 468 | } |
469 | return TRUE; | 469 | return TRUE; |
470 | } | 470 | } |
471 | } | 471 | } |
472 | 472 | ||
473 | 473 | ||
474 | bool PlayListWidget::first() { | 474 | bool PlayListWidget::first() { |
475 | return d->selectedFiles->first(); | 475 | return d->selectedFiles->first(); |
476 | } | 476 | } |
477 | 477 | ||
478 | 478 | ||
479 | bool PlayListWidget::last() { | 479 | bool PlayListWidget::last() { |
480 | return d->selectedFiles->last(); | 480 | return d->selectedFiles->last(); |
481 | } | 481 | } |
482 | 482 | ||
483 | 483 | ||
484 | void PlayListWidget::saveList() { | 484 | void PlayListWidget::saveList() { |
485 | writem3u(); | 485 | writem3u(); |
486 | } | 486 | } |
487 | 487 | ||
488 | 488 | ||
489 | void PlayListWidget::loadList( const DocLnk & lnk) { | 489 | void PlayListWidget::loadList( const DocLnk & lnk) { |
490 | QString name = lnk.name(); | 490 | QString name = lnk.name(); |
491 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); | 491 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); |
492 | 492 | ||
493 | if( name.length()>0) { | 493 | if( name.length()>0) { |
494 | setCaption("OpiePlayer: "+name); | 494 | setCaption("OpiePlayer: "+name); |
495 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); | 495 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); |
496 | clearList(); | 496 | clearList(); |
497 | readm3u(lnk.file()); | 497 | readm3u(lnk.file()); |
498 | tabWidget->setCurrentPage(0); | 498 | tabWidget->setCurrentPage(0); |
499 | } | 499 | } |
500 | } | 500 | } |
501 | 501 | ||
502 | void PlayListWidget::addSelected() { | 502 | void PlayListWidget::addSelected() { |
503 | assert( inFileListMode() ); | 503 | assert( inFileListMode() ); |
504 | 504 | ||
505 | QListView *fileListView = currentFileListView(); | 505 | QListView *fileListView = currentFileListView(); |
506 | QListViewItemIterator it( fileListView ); | 506 | QListViewItemIterator it( fileListView ); |
507 | for ( ; it.current(); ++it ) | 507 | for ( ; it.current(); ++it ) |
508 | if ( it.current()->isSelected() ) { | 508 | if ( it.current()->isSelected() ) { |
509 | QString filename = it.current()->text(3); | 509 | QString filename = it.current()->text(3); |
510 | 510 | ||
511 | DocLnk lnk; | 511 | DocLnk lnk; |
512 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name | 512 | lnk.setName( QFileInfo( filename ).baseName() ); //sets name |
513 | lnk.setFile( filename ); //sets file name | 513 | lnk.setFile( filename ); //sets file name |
514 | 514 | ||
515 | d->selectedFiles->addToSelection( lnk ); | 515 | d->selectedFiles->addToSelection( lnk ); |
516 | } | 516 | } |
517 | 517 | ||
518 | fileListView->clearSelection(); | 518 | fileListView->clearSelection(); |
519 | 519 | ||
520 | tabWidget->setCurrentPage( 0 ); | 520 | tabWidget->setCurrentPage( 0 ); |
521 | writeCurrentM3u(); | 521 | writeCurrentM3u(); |
522 | } | 522 | } |
523 | 523 | ||
524 | 524 | ||
525 | void PlayListWidget::removeSelected() { | 525 | void PlayListWidget::removeSelected() { |
526 | d->selectedFiles->removeSelected( ); | 526 | d->selectedFiles->removeSelected( ); |
527 | writeCurrentM3u(); | 527 | writeCurrentM3u(); |
528 | } | 528 | } |
529 | 529 | ||
530 | 530 | ||
531 | void PlayListWidget::playIt( QListViewItem *it) { | 531 | void PlayListWidget::playIt( QListViewItem *it) { |
532 | if(!it) return; | 532 | if(!it) return; |
533 | mediaPlayerState->setPlaying(FALSE); | 533 | mediaPlayerState.setPlaying(FALSE); |
534 | mediaPlayerState->setPlaying(TRUE); | 534 | mediaPlayerState.setPlaying(TRUE); |
535 | d->selectedFiles->unSelect(); | 535 | d->selectedFiles->unSelect(); |
536 | } | 536 | } |
537 | 537 | ||
538 | 538 | ||
539 | void PlayListWidget::addToSelection( QListViewItem *it) { | 539 | void PlayListWidget::addToSelection( QListViewItem *it) { |
540 | d->setDocumentUsed = FALSE; | 540 | d->setDocumentUsed = FALSE; |
541 | 541 | ||
542 | if(it) { | 542 | if(it) { |
543 | if ( currentTab() == CurrentPlayList ) | 543 | if ( currentTab() == CurrentPlayList ) |
544 | return; | 544 | return; |
545 | // case 1: { | 545 | // case 1: { |
546 | DocLnk lnk; | 546 | DocLnk lnk; |
547 | QString filename; | 547 | QString filename; |
548 | 548 | ||
549 | filename=it->text(3); | 549 | filename=it->text(3); |
550 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 550 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
551 | lnk.setFile( filename ); //sets file name | 551 | lnk.setFile( filename ); //sets file name |
552 | d->selectedFiles->addToSelection( lnk); | 552 | d->selectedFiles->addToSelection( lnk); |
553 | 553 | ||
554 | writeCurrentM3u(); | 554 | writeCurrentM3u(); |
555 | tabWidget->setCurrentPage(0); | 555 | tabWidget->setCurrentPage(0); |
556 | 556 | ||
557 | } | 557 | } |
558 | } | 558 | } |
559 | 559 | ||
560 | 560 | ||
561 | void PlayListWidget::tabChanged(QWidget *) { | 561 | void PlayListWidget::tabChanged(QWidget *) { |
562 | 562 | ||
563 | d->tbPlay->setEnabled( true ); | 563 | d->tbPlay->setEnabled( true ); |
564 | 564 | ||
565 | switch ( currentTab() ) { | 565 | switch ( currentTab() ) { |
566 | case CurrentPlayList: | 566 | case CurrentPlayList: |
567 | { | 567 | { |
568 | if( !tbDeletePlaylist->isHidden() ) { | 568 | if( !tbDeletePlaylist->isHidden() ) { |
569 | tbDeletePlaylist->hide(); | 569 | tbDeletePlaylist->hide(); |
570 | } | 570 | } |
571 | d->tbRemoveFromList->setEnabled(TRUE); | 571 | d->tbRemoveFromList->setEnabled(TRUE); |
572 | d->tbAddToList->setEnabled(FALSE); | 572 | d->tbAddToList->setEnabled(FALSE); |
573 | 573 | ||
574 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); | 574 | d->tbPlay->setEnabled( !d->selectedFiles->isEmpty() ); |
575 | } | 575 | } |
576 | break; | 576 | break; |
577 | case AudioFiles: | 577 | case AudioFiles: |
578 | { | 578 | { |
579 | // audioView->clear(); | 579 | // audioView->clear(); |
580 | if(!audioPopulated) populateAudioView(); | 580 | if(!audioPopulated) populateAudioView(); |
581 | 581 | ||
582 | if( !tbDeletePlaylist->isHidden() ) { | 582 | if( !tbDeletePlaylist->isHidden() ) { |
583 | tbDeletePlaylist->hide(); | 583 | tbDeletePlaylist->hide(); |
584 | } | 584 | } |
585 | d->tbRemoveFromList->setEnabled(FALSE); | 585 | d->tbRemoveFromList->setEnabled(FALSE); |
586 | d->tbAddToList->setEnabled(TRUE); | 586 | d->tbAddToList->setEnabled(TRUE); |
587 | } | 587 | } |
588 | break; | 588 | break; |
589 | case VideoFiles: | 589 | case VideoFiles: |
590 | { | 590 | { |
591 | // videoView->clear(); | 591 | // videoView->clear(); |
592 | if(!videoPopulated) populateVideoView(); | 592 | if(!videoPopulated) populateVideoView(); |
593 | if( !tbDeletePlaylist->isHidden() ) { | 593 | if( !tbDeletePlaylist->isHidden() ) { |
594 | tbDeletePlaylist->hide(); | 594 | tbDeletePlaylist->hide(); |
595 | } | 595 | } |
596 | d->tbRemoveFromList->setEnabled(FALSE); | 596 | d->tbRemoveFromList->setEnabled(FALSE); |
597 | d->tbAddToList->setEnabled(TRUE); | 597 | d->tbAddToList->setEnabled(TRUE); |
598 | } | 598 | } |
599 | break; | 599 | break; |
600 | case PlayLists: | 600 | case PlayLists: |
601 | { | 601 | { |
602 | if( tbDeletePlaylist->isHidden() ) { | 602 | if( tbDeletePlaylist->isHidden() ) { |
603 | tbDeletePlaylist->show(); | 603 | tbDeletePlaylist->show(); |
604 | } | 604 | } |
605 | playLists->reread(); | 605 | playLists->reread(); |
606 | d->tbAddToList->setEnabled(FALSE); | 606 | d->tbAddToList->setEnabled(FALSE); |
607 | 607 | ||
608 | d->tbPlay->setEnabled( false ); | 608 | d->tbPlay->setEnabled( false ); |
609 | } | 609 | } |
610 | break; | 610 | break; |
611 | }; | 611 | }; |
612 | } | 612 | } |
613 | 613 | ||
614 | 614 | ||
615 | void PlayListWidget::btnPlay(bool b) { | 615 | void PlayListWidget::btnPlay(bool b) { |
616 | // mediaPlayerState->setPlaying(false); | 616 | // mediaPlayerState->setPlaying(false); |
617 | mediaPlayerState->setPlaying(b); | 617 | mediaPlayerState.setPlaying(b); |
618 | insanityBool=FALSE; | 618 | insanityBool=FALSE; |
619 | } | 619 | } |
620 | 620 | ||
621 | void PlayListWidget::deletePlaylist() { | 621 | void PlayListWidget::deletePlaylist() { |
622 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 622 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
623 | (tr("You really want to delete\nthis playlist?")), | 623 | (tr("You really want to delete\nthis playlist?")), |
624 | (tr("Yes")), (tr("No")), 0 )){ | 624 | (tr("Yes")), (tr("No")), 0 )){ |
625 | case 0: // Yes clicked, | 625 | case 0: // Yes clicked, |
626 | QFile().remove(playLists->selectedDocument().file()); | 626 | QFile().remove(playLists->selectedDocument().file()); |
627 | QFile().remove(playLists->selectedDocument().linkFile()); | 627 | QFile().remove(playLists->selectedDocument().linkFile()); |
628 | playLists->reread(); | 628 | playLists->reread(); |
629 | break; | 629 | break; |
630 | case 1: // Cancel | 630 | case 1: // Cancel |
631 | break; | 631 | break; |
632 | }; | 632 | }; |
633 | } | 633 | } |
634 | 634 | ||
635 | 635 | ||
636 | void PlayListWidget::playSelected() { | 636 | void PlayListWidget::playSelected() { |
637 | btnPlay( TRUE); | 637 | btnPlay( TRUE); |
638 | } | 638 | } |
639 | 639 | ||
640 | 640 | ||
641 | void PlayListWidget::scanForAudio() { | 641 | void PlayListWidget::scanForAudio() { |
642 | // qDebug("scan for audio"); | 642 | // qDebug("scan for audio"); |
643 | files.detachChildren(); | 643 | files.detachChildren(); |
644 | QListIterator<DocLnk> sdit( files.children() ); | 644 | QListIterator<DocLnk> sdit( files.children() ); |
645 | for ( ; sdit.current(); ++sdit ) { | 645 | for ( ; sdit.current(); ++sdit ) { |
646 | delete sdit.current(); | 646 | delete sdit.current(); |
647 | } | 647 | } |
648 | // Global::findDocuments( &files, "audio/*"); | 648 | // Global::findDocuments( &files, "audio/*"); |
649 | Global::findDocuments( &files, audioMimes); | 649 | Global::findDocuments( &files, audioMimes); |
650 | audioScan = true; | 650 | audioScan = true; |
651 | populateAudioView(); | 651 | populateAudioView(); |
652 | } | 652 | } |
653 | 653 | ||
654 | void PlayListWidget::scanForVideo() { | 654 | void PlayListWidget::scanForVideo() { |
655 | // qDebug("scan for video"); | 655 | // qDebug("scan for video"); |
656 | vFiles.detachChildren(); | 656 | vFiles.detachChildren(); |
657 | QListIterator<DocLnk> sdit( vFiles.children() ); | 657 | QListIterator<DocLnk> sdit( vFiles.children() ); |
658 | for ( ; sdit.current(); ++sdit ) { | 658 | for ( ; sdit.current(); ++sdit ) { |
659 | delete sdit.current(); | 659 | delete sdit.current(); |
660 | } | 660 | } |
661 | Global::findDocuments(&vFiles, "video/*"); | 661 | Global::findDocuments(&vFiles, "video/*"); |
662 | videoScan = true; | 662 | videoScan = true; |
663 | populateVideoView(); | 663 | populateVideoView(); |
664 | } | 664 | } |
665 | 665 | ||
666 | void PlayListWidget::populateAudioView() { | 666 | void PlayListWidget::populateAudioView() { |
667 | audioView->clear(); | 667 | audioView->clear(); |
668 | StorageInfo storageInfo; | 668 | StorageInfo storageInfo; |
669 | // const QList<FileSystem> &fs = storageInfo.fileSystems(); | 669 | // const QList<FileSystem> &fs = storageInfo.fileSystems(); |
670 | if(!audioScan) { | 670 | if(!audioScan) { |
671 | scanForAudio(); | 671 | scanForAudio(); |
672 | } | 672 | } |
673 | 673 | ||
674 | QListIterator<DocLnk> dit( files.children() ); | 674 | QListIterator<DocLnk> dit( files.children() ); |
675 | // QListIterator<FileSystem> it ( fs ); | 675 | // QListIterator<FileSystem> it ( fs ); |
676 | audioView->clear(); | 676 | audioView->clear(); |
677 | 677 | ||
678 | QString storage; | 678 | QString storage; |
679 | for ( ; dit.current(); ++dit ) { | 679 | for ( ; dit.current(); ++dit ) { |
680 | // // for( ; it.current(); ++it ){ | 680 | // // for( ; it.current(); ++it ){ |
681 | // const QString name = (*dit)->name(); | 681 | // const QString name = (*dit)->name(); |
682 | // const QString path = (*dit)->path(); | 682 | // const QString path = (*dit)->path(); |
683 | // if(dit.current()->file().find(path) != -1 ) { | 683 | // if(dit.current()->file().find(path) != -1 ) { |
684 | // storage = name; | 684 | // storage = name; |
685 | // // } | 685 | // // } |
686 | // } | 686 | // } |
687 | 687 | ||
688 | QListViewItem * newItem; | 688 | QListViewItem * newItem; |
689 | if ( QFile( dit.current()->file()).exists() || | 689 | if ( QFile( dit.current()->file()).exists() || |
690 | dit.current()->file().left(4) == "http" ) { | 690 | dit.current()->file().left(4) == "http" ) { |
691 | long size; | 691 | long size; |
692 | if( dit.current()->file().left(4) == "http" ) | 692 | if( dit.current()->file().left(4) == "http" ) |
693 | size=0; | 693 | size=0; |
694 | else | 694 | else |
695 | size = QFile( dit.current()->file() ).size(); | 695 | size = QFile( dit.current()->file() ).size(); |
696 | 696 | ||
697 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 697 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
698 | QString::number(size ), "" /*storage*/, | 698 | QString::number(size ), "" /*storage*/, |
699 | dit.current()->file() ); | 699 | dit.current()->file() ); |
700 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); | 700 | newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); |
701 | // qDebug("<<<< "+dit.current()->file()); | 701 | // qDebug("<<<< "+dit.current()->file()); |
702 | } | 702 | } |
703 | } | 703 | } |
704 | audioPopulated=true; | 704 | audioPopulated=true; |
705 | } | 705 | } |
706 | 706 | ||
707 | 707 | ||
708 | void PlayListWidget::populateVideoView() { | 708 | void PlayListWidget::populateVideoView() { |
709 | videoView->clear(); | 709 | videoView->clear(); |
710 | StorageInfo storageInfo; | 710 | StorageInfo storageInfo; |
711 | // const QList<FileSystem> &fs = storageInfo.fileSystems(); | 711 | // const QList<FileSystem> &fs = storageInfo.fileSystems(); |
712 | 712 | ||
713 | if(!videoScan ) { | 713 | if(!videoScan ) { |
714 | scanForVideo(); | 714 | scanForVideo(); |
715 | } | 715 | } |
716 | 716 | ||
717 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 717 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
718 | // QListIterator<FileSystem> it ( fs ); | 718 | // QListIterator<FileSystem> it ( fs ); |
719 | videoView->clear(); | 719 | videoView->clear(); |
720 | QString storage, pathName; | 720 | QString storage, pathName; |
721 | for ( ; Vdit.current(); ++Vdit ) { | 721 | for ( ; Vdit.current(); ++Vdit ) { |
722 | // // for( ; it.current(); ++it ) { | 722 | // // for( ; it.current(); ++it ) { |
723 | // const QString name = (*Vdit)->name(); | 723 | // const QString name = (*Vdit)->name(); |
724 | // const QString path = (*Vdit)->path(); | 724 | // const QString path = (*Vdit)->path(); |
725 | // if( Vdit.current()->file().find(path) != -1 ) { | 725 | // if( Vdit.current()->file().find(path) != -1 ) { |
726 | // storage=name; | 726 | // storage=name; |
727 | // pathName=path; | 727 | // pathName=path; |
728 | // // } | 728 | // // } |
729 | // } | 729 | // } |
730 | 730 | ||
731 | QListViewItem * newItem; | 731 | QListViewItem * newItem; |
732 | if ( QFile( Vdit.current()->file() ).exists() ) { | 732 | if ( QFile( Vdit.current()->file() ).exists() ) { |
733 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 733 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
734 | QString::number( QFile( Vdit.current()->file() ).size() ), | 734 | QString::number( QFile( Vdit.current()->file() ).size() ), |
735 | ""/*storage*/, Vdit.current()->file()); | 735 | ""/*storage*/, Vdit.current()->file()); |
736 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); | 736 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); |
737 | } | 737 | } |
738 | } | 738 | } |
739 | videoPopulated=true; | 739 | videoPopulated=true; |
740 | } | 740 | } |
741 | 741 | ||
742 | QListView *PlayListWidget::currentFileListView() const | 742 | QListView *PlayListWidget::currentFileListView() const |
743 | { | 743 | { |
744 | switch ( currentTab() ) { | 744 | switch ( currentTab() ) { |
745 | case AudioFiles: return audioView; | 745 | case AudioFiles: return audioView; |
746 | case VideoFiles: return videoView; | 746 | case VideoFiles: return videoView; |
747 | default: assert( false ); | 747 | default: assert( false ); |
748 | } | 748 | } |
749 | return 0; | 749 | return 0; |
750 | } | 750 | } |
751 | 751 | ||
752 | bool PlayListWidget::inFileListMode() const | 752 | bool PlayListWidget::inFileListMode() const |
753 | { | 753 | { |
754 | TabType tab = currentTab(); | 754 | TabType tab = currentTab(); |
755 | return tab == AudioFiles || tab == VideoFiles; | 755 | return tab == AudioFiles || tab == VideoFiles; |
756 | } | 756 | } |
757 | 757 | ||
758 | void PlayListWidget::openFile() { | 758 | void PlayListWidget::openFile() { |
759 | // http://66.28.164.33:2080 | 759 | // http://66.28.164.33:2080 |
760 | // http://somafm.com/star0242.m3u | 760 | // http://somafm.com/star0242.m3u |
761 | QString filename, name; | 761 | QString filename, name; |
762 | InputDialog *fileDlg; | 762 | InputDialog *fileDlg; |
763 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 763 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
764 | fileDlg->exec(); | 764 | fileDlg->exec(); |
765 | if( fileDlg->result() == 1 ) { | 765 | if( fileDlg->result() == 1 ) { |
766 | filename = fileDlg->text(); | 766 | filename = fileDlg->text(); |
767 | qDebug( "Selected filename is " + filename ); | 767 | qDebug( "Selected filename is " + filename ); |
768 | // Om3u *m3uList; | 768 | // Om3u *m3uList; |
769 | DocLnk lnk; | 769 | DocLnk lnk; |
770 | Config cfg( "OpiePlayer" ); | 770 | Config cfg( "OpiePlayer" ); |
771 | cfg.setGroup("PlayList"); | 771 | cfg.setGroup("PlayList"); |
772 | 772 | ||
773 | if(filename.left(4) == "http") { | 773 | if(filename.left(4) == "http") { |
774 | QString m3uFile, m3uFilePath; | 774 | QString m3uFile, m3uFilePath; |
775 | if(filename.find(":",8,TRUE) != -1) { //found a port | 775 | if(filename.find(":",8,TRUE) != -1) { //found a port |
776 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 776 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
777 | m3uFile = m3uFile.right( 7); | 777 | m3uFile = m3uFile.right( 7); |
778 | } else if(filename.left(4) == "http"){ | 778 | } else if(filename.left(4) == "http"){ |
779 | m3uFile=filename; | 779 | m3uFile=filename; |
780 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 780 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
781 | } else{ | 781 | } else{ |
782 | m3uFile=filename; | 782 | m3uFile=filename; |
783 | } | 783 | } |
784 | 784 | ||
785 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); | 785 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); |
786 | lnk.setName( filename ); //sets name | 786 | lnk.setName( filename ); //sets name |
787 | lnk.setFile( filename ); //sets file name | 787 | lnk.setFile( filename ); //sets file name |
788 | 788 | ||
789 | // lnk.setIcon("opieplayer2/musicfile"); | 789 | // lnk.setIcon("opieplayer2/musicfile"); |
790 | 790 | ||
791 | d->selectedFiles->addToSelection( lnk ); | 791 | d->selectedFiles->addToSelection( lnk ); |
792 | writeCurrentM3u(); | 792 | writeCurrentM3u(); |
793 | d->selectedFiles->setSelectedItem( lnk.name()); | 793 | d->selectedFiles->setSelectedItem( lnk.name()); |
794 | } | 794 | } |
795 | else if( filename.right( 3) == "m3u" ) { | 795 | else if( filename.right( 3) == "m3u" ) { |
796 | readm3u( filename ); | 796 | readm3u( filename ); |
797 | 797 | ||
798 | } else if( filename.right(3) == "pls" ) { | 798 | } else if( filename.right(3) == "pls" ) { |
799 | readPls( filename ); | 799 | readPls( filename ); |
800 | } else { | 800 | } else { |
801 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 801 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
802 | lnk.setFile( filename ); //sets file name | 802 | lnk.setFile( filename ); //sets file name |
803 | d->selectedFiles->addToSelection( lnk); | 803 | d->selectedFiles->addToSelection( lnk); |
804 | writeCurrentM3u(); | 804 | writeCurrentM3u(); |
805 | d->selectedFiles->setSelectedItem( lnk.name()); | 805 | d->selectedFiles->setSelectedItem( lnk.name()); |
806 | } | 806 | } |
807 | } | 807 | } |
808 | 808 | ||
809 | if( fileDlg ) { | 809 | if( fileDlg ) { |
@@ -860,269 +860,269 @@ void PlayListWidget::readm3u( const QString &filename ) { | |||
860 | 860 | ||
861 | d->selectedFiles->setSelectedItem( s); | 861 | d->selectedFiles->setSelectedItem( s); |
862 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); | 862 | setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); |
863 | 863 | ||
864 | } | 864 | } |
865 | 865 | ||
866 | /* | 866 | /* |
867 | reads pls and adds files/urls to playlist */ | 867 | reads pls and adds files/urls to playlist */ |
868 | void PlayListWidget::readPls( const QString &filename ) { | 868 | void PlayListWidget::readPls( const QString &filename ) { |
869 | 869 | ||
870 | qDebug( "pls filename is " + filename ); | 870 | qDebug( "pls filename is " + filename ); |
871 | Om3u *m3uList; | 871 | Om3u *m3uList; |
872 | QString s, name; | 872 | QString s, name; |
873 | m3uList = new Om3u( filename, IO_ReadOnly ); | 873 | m3uList = new Om3u( filename, IO_ReadOnly ); |
874 | m3uList->readPls(); | 874 | m3uList->readPls(); |
875 | 875 | ||
876 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 876 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
877 | s = *it; | 877 | s = *it; |
878 | // s.replace( QRegExp( "%20" )," " ); | 878 | // s.replace( QRegExp( "%20" )," " ); |
879 | DocLnk lnk( s ); | 879 | DocLnk lnk( s ); |
880 | QFileInfo f( s ); | 880 | QFileInfo f( s ); |
881 | QString name = f.baseName(); | 881 | QString name = f.baseName(); |
882 | 882 | ||
883 | if( name.left( 4 ) == "http" ) { | 883 | if( name.left( 4 ) == "http" ) { |
884 | name = s.right( s.length() - 7); | 884 | name = s.right( s.length() - 7); |
885 | } else { | 885 | } else { |
886 | name = s; | 886 | name = s; |
887 | } | 887 | } |
888 | 888 | ||
889 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 889 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
890 | 890 | ||
891 | lnk.setName( name ); | 891 | lnk.setName( name ); |
892 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | 892 | if( s.at( s.length() - 4) == '.') {// if this is probably a file |
893 | lnk.setFile( s ); | 893 | lnk.setFile( s ); |
894 | } else { //if its a url | 894 | } else { //if its a url |
895 | // if( name.right( 1 ).find( '/' ) == -1) { | 895 | // if( name.right( 1 ).find( '/' ) == -1) { |
896 | // s += "/"; | 896 | // s += "/"; |
897 | // } | 897 | // } |
898 | lnk.setFile( s ); | 898 | lnk.setFile( s ); |
899 | } | 899 | } |
900 | lnk.setType( "audio/x-mpegurl" ); | 900 | lnk.setType( "audio/x-mpegurl" ); |
901 | 901 | ||
902 | lnk.writeLink(); | 902 | lnk.writeLink(); |
903 | d->selectedFiles->addToSelection( lnk ); | 903 | d->selectedFiles->addToSelection( lnk ); |
904 | } | 904 | } |
905 | 905 | ||
906 | m3uList->close(); | 906 | m3uList->close(); |
907 | if(m3uList) delete m3uList; | 907 | if(m3uList) delete m3uList; |
908 | } | 908 | } |
909 | 909 | ||
910 | /* | 910 | /* |
911 | writes current playlist to current m3u file */ | 911 | writes current playlist to current m3u file */ |
912 | void PlayListWidget::writeCurrentM3u() { | 912 | void PlayListWidget::writeCurrentM3u() { |
913 | qDebug("writing to current m3u"); | 913 | qDebug("writing to current m3u"); |
914 | Config cfg( "OpiePlayer" ); | 914 | Config cfg( "OpiePlayer" ); |
915 | cfg.setGroup("PlayList"); | 915 | cfg.setGroup("PlayList"); |
916 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 916 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
917 | 917 | ||
918 | Om3u *m3uList; | 918 | Om3u *m3uList; |
919 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 919 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
920 | if( d->selectedFiles->first()) { | 920 | if( d->selectedFiles->first()) { |
921 | 921 | ||
922 | do { | 922 | do { |
923 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); | 923 | // qDebug( "add writeCurrentM3u " +d->selectedFiles->current()->file()); |
924 | m3uList->add( d->selectedFiles->current()->file() ); | 924 | m3uList->add( d->selectedFiles->current()->file() ); |
925 | } | 925 | } |
926 | while ( d->selectedFiles->next() ); | 926 | while ( d->selectedFiles->next() ); |
927 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 927 | // qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
928 | m3uList->write(); | 928 | m3uList->write(); |
929 | m3uList->close(); | 929 | m3uList->close(); |
930 | 930 | ||
931 | if(m3uList) delete m3uList; | 931 | if(m3uList) delete m3uList; |
932 | } | 932 | } |
933 | 933 | ||
934 | } | 934 | } |
935 | 935 | ||
936 | /* | 936 | /* |
937 | writes current playlist to m3u file */ | 937 | writes current playlist to m3u file */ |
938 | void PlayListWidget::writem3u() { | 938 | void PlayListWidget::writem3u() { |
939 | InputDialog *fileDlg; | 939 | InputDialog *fileDlg; |
940 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 940 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
941 | fileDlg->exec(); | 941 | fileDlg->exec(); |
942 | QString name, filename, list; | 942 | QString name, filename, list; |
943 | Om3u *m3uList; | 943 | Om3u *m3uList; |
944 | 944 | ||
945 | if( fileDlg->result() == 1 ) { | 945 | if( fileDlg->result() == 1 ) { |
946 | name = fileDlg->text(); | 946 | name = fileDlg->text(); |
947 | // qDebug( filename ); | 947 | // qDebug( filename ); |
948 | 948 | ||
949 | if( name.left( 1) != "/" ) { | 949 | if( name.left( 1) != "/" ) { |
950 | filename = QPEApplication::documentDir() + "/" + name; | 950 | filename = QPEApplication::documentDir() + "/" + name; |
951 | } | 951 | } |
952 | 952 | ||
953 | if( name.right( 3 ) != "m3u" ) { | 953 | if( name.right( 3 ) != "m3u" ) { |
954 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; | 954 | filename = QPEApplication::documentDir() + "/" +name+".m3u"; |
955 | } | 955 | } |
956 | 956 | ||
957 | if( d->selectedFiles->first()) { | 957 | if( d->selectedFiles->first()) { |
958 | m3uList = new Om3u(filename, IO_ReadWrite); | 958 | m3uList = new Om3u(filename, IO_ReadWrite); |
959 | 959 | ||
960 | do { | 960 | do { |
961 | m3uList->add( d->selectedFiles->current()->file()); | 961 | m3uList->add( d->selectedFiles->current()->file()); |
962 | } | 962 | } |
963 | while ( d->selectedFiles->next() ); | 963 | while ( d->selectedFiles->next() ); |
964 | // qDebug( list ); | 964 | // qDebug( list ); |
965 | m3uList->write(); | 965 | m3uList->write(); |
966 | m3uList->close(); | 966 | m3uList->close(); |
967 | if(m3uList) delete m3uList; | 967 | if(m3uList) delete m3uList; |
968 | 968 | ||
969 | if(fileDlg) delete fileDlg; | 969 | if(fileDlg) delete fileDlg; |
970 | 970 | ||
971 | DocLnk lnk; | 971 | DocLnk lnk; |
972 | lnk.setFile( filename); | 972 | lnk.setFile( filename); |
973 | lnk.setIcon("opieplayer2/playlist2"); | 973 | lnk.setIcon("opieplayer2/playlist2"); |
974 | lnk.setName( name); //sets file name | 974 | lnk.setName( name); //sets file name |
975 | 975 | ||
976 | // qDebug(filename); | 976 | // qDebug(filename); |
977 | Config config( "OpiePlayer" ); | 977 | Config config( "OpiePlayer" ); |
978 | config.setGroup( "PlayList" ); | 978 | config.setGroup( "PlayList" ); |
979 | 979 | ||
980 | config.writeEntry("CurrentPlaylist",filename); | 980 | config.writeEntry("CurrentPlaylist",filename); |
981 | currentPlayList=filename; | 981 | currentPlayList=filename; |
982 | 982 | ||
983 | if(!lnk.writeLink()) { | 983 | if(!lnk.writeLink()) { |
984 | qDebug("Writing doclink did not work"); | 984 | qDebug("Writing doclink did not work"); |
985 | } | 985 | } |
986 | 986 | ||
987 | setCaption(tr("OpiePlayer: ") + name); | 987 | setCaption(tr("OpiePlayer: ") + name); |
988 | } | 988 | } |
989 | } | 989 | } |
990 | } | 990 | } |
991 | 991 | ||
992 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { | 992 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { |
993 | switch ( e->key() ) { | 993 | switch ( e->key() ) { |
994 | ////////////////////////////// Zaurus keys | 994 | ////////////////////////////// Zaurus keys |
995 | case Key_F9: //activity | 995 | case Key_F9: //activity |
996 | // if(audioUI->isHidden()) | 996 | // if(audioUI->isHidden()) |
997 | // audioUI->showMaximized(); | 997 | // audioUI->showMaximized(); |
998 | break; | 998 | break; |
999 | case Key_F10: //contacts | 999 | case Key_F10: //contacts |
1000 | // if( videoUI->isHidden()) | 1000 | // if( videoUI->isHidden()) |
1001 | // videoUI->showMaximized(); | 1001 | // videoUI->showMaximized(); |
1002 | break; | 1002 | break; |
1003 | case Key_F11: //menu | 1003 | case Key_F11: //menu |
1004 | break; | 1004 | break; |
1005 | case Key_F12: //home | 1005 | case Key_F12: //home |
1006 | // doBlank(); | 1006 | // doBlank(); |
1007 | break; | 1007 | break; |
1008 | case Key_F13: //mail | 1008 | case Key_F13: //mail |
1009 | // doUnblank(); | 1009 | // doUnblank(); |
1010 | break; | 1010 | break; |
1011 | case Key_Q: //add to playlist | 1011 | case Key_Q: //add to playlist |
1012 | addSelected(); | 1012 | addSelected(); |
1013 | break; | 1013 | break; |
1014 | case Key_R: //remove from playlist | 1014 | case Key_R: //remove from playlist |
1015 | removeSelected(); | 1015 | removeSelected(); |
1016 | break; | 1016 | break; |
1017 | // case Key_P: //play | 1017 | // case Key_P: //play |
1018 | // qDebug("Play"); | 1018 | // qDebug("Play"); |
1019 | // playSelected(); | 1019 | // playSelected(); |
1020 | // break; | 1020 | // break; |
1021 | case Key_Space: | 1021 | case Key_Space: |
1022 | // playSelected(); puh | 1022 | // playSelected(); puh |
1023 | break; | 1023 | break; |
1024 | case Key_1: | 1024 | case Key_1: |
1025 | tabWidget->setCurrentPage( 0 ); | 1025 | tabWidget->setCurrentPage( 0 ); |
1026 | break; | 1026 | break; |
1027 | case Key_2: | 1027 | case Key_2: |
1028 | tabWidget->setCurrentPage( 1 ); | 1028 | tabWidget->setCurrentPage( 1 ); |
1029 | break; | 1029 | break; |
1030 | case Key_3: | 1030 | case Key_3: |
1031 | tabWidget->setCurrentPage( 2 ); | 1031 | tabWidget->setCurrentPage( 2 ); |
1032 | break; | 1032 | break; |
1033 | case Key_4: | 1033 | case Key_4: |
1034 | tabWidget->setCurrentPage( 3 ); | 1034 | tabWidget->setCurrentPage( 3 ); |
1035 | break; | 1035 | break; |
1036 | case Key_Down: | 1036 | case Key_Down: |
1037 | if ( !d->selectedFiles->next() ) | 1037 | if ( !d->selectedFiles->next() ) |
1038 | d->selectedFiles->first(); | 1038 | d->selectedFiles->first(); |
1039 | break; | 1039 | break; |
1040 | case Key_Up: | 1040 | case Key_Up: |
1041 | if ( !d->selectedFiles->prev() ) | 1041 | if ( !d->selectedFiles->prev() ) |
1042 | // d->selectedFiles->last(); | 1042 | // d->selectedFiles->last(); |
1043 | break; | 1043 | break; |
1044 | } | 1044 | } |
1045 | } | 1045 | } |
1046 | 1046 | ||
1047 | void PlayListWidget::pmViewActivated(int index) { | 1047 | void PlayListWidget::pmViewActivated(int index) { |
1048 | // qDebug("%d", index); | 1048 | // qDebug("%d", index); |
1049 | switch(index) { | 1049 | switch(index) { |
1050 | case -16: | 1050 | case -16: |
1051 | { | 1051 | { |
1052 | mediaPlayerState->toggleFullscreen(); | 1052 | mediaPlayerState.toggleFullscreen(); |
1053 | bool b=mediaPlayerState->isFullscreen(); | 1053 | bool b=mediaPlayerState.isFullscreen(); |
1054 | pmView->setItemChecked( index, b); | 1054 | pmView->setItemChecked( index, b); |
1055 | Config cfg( "OpiePlayer" ); | 1055 | Config cfg( "OpiePlayer" ); |
1056 | cfg.writeEntry( "FullScreen", b ); | 1056 | cfg.writeEntry( "FullScreen", b ); |
1057 | } | 1057 | } |
1058 | break; | 1058 | break; |
1059 | }; | 1059 | }; |
1060 | } | 1060 | } |
1061 | 1061 | ||
1062 | void PlayListWidget::populateSkinsMenu() { | 1062 | void PlayListWidget::populateSkinsMenu() { |
1063 | int item = 0; | 1063 | int item = 0; |
1064 | defaultSkinIndex = 0; | 1064 | defaultSkinIndex = 0; |
1065 | QString skinName; | 1065 | QString skinName; |
1066 | Config cfg( "OpiePlayer" ); | 1066 | Config cfg( "OpiePlayer" ); |
1067 | cfg.setGroup("Options" ); | 1067 | cfg.setGroup("Options" ); |
1068 | QString skin = cfg.readEntry( "Skin", "default" ); | 1068 | QString skin = cfg.readEntry( "Skin", "default" ); |
1069 | 1069 | ||
1070 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 1070 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
1071 | skinsDir.setFilter( QDir::Dirs ); | 1071 | skinsDir.setFilter( QDir::Dirs ); |
1072 | skinsDir.setSorting(QDir::Name ); | 1072 | skinsDir.setSorting(QDir::Name ); |
1073 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 1073 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
1074 | QFileInfoListIterator it( *skinslist ); | 1074 | QFileInfoListIterator it( *skinslist ); |
1075 | QFileInfo *fi; | 1075 | QFileInfo *fi; |
1076 | while ( ( fi = it.current() ) ) { | 1076 | while ( ( fi = it.current() ) ) { |
1077 | skinName = fi->fileName(); | 1077 | skinName = fi->fileName(); |
1078 | // qDebug( fi->fileName() ); | 1078 | // qDebug( fi->fileName() ); |
1079 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 1079 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
1080 | item = skinsMenu->insertItem( fi->fileName() ) ; | 1080 | item = skinsMenu->insertItem( fi->fileName() ) ; |
1081 | } | 1081 | } |
1082 | if( skinName == "default" ) { | 1082 | if( skinName == "default" ) { |
1083 | defaultSkinIndex = item; | 1083 | defaultSkinIndex = item; |
1084 | } | 1084 | } |
1085 | if( skinName == skin ) { | 1085 | if( skinName == skin ) { |
1086 | skinsMenu->setItemChecked( item, TRUE ); | 1086 | skinsMenu->setItemChecked( item, TRUE ); |
1087 | } | 1087 | } |
1088 | ++it; | 1088 | ++it; |
1089 | } | 1089 | } |
1090 | } | 1090 | } |
1091 | 1091 | ||
1092 | void PlayListWidget::skinsMenuActivated( int item ) { | 1092 | void PlayListWidget::skinsMenuActivated( int item ) { |
1093 | for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 1093 | for(unsigned int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
1094 | skinsMenu->setItemChecked( i, FALSE ); | 1094 | skinsMenu->setItemChecked( i, FALSE ); |
1095 | } | 1095 | } |
1096 | skinsMenu->setItemChecked( item, TRUE ); | 1096 | skinsMenu->setItemChecked( item, TRUE ); |
1097 | 1097 | ||
1098 | Config cfg( "OpiePlayer" ); | 1098 | Config cfg( "OpiePlayer" ); |
1099 | cfg.setGroup("Options"); | 1099 | cfg.setGroup("Options"); |
1100 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 1100 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
1101 | QMessageBox::warning( this, tr( "OpiePlayer" ), | 1101 | QMessageBox::warning( this, tr( "OpiePlayer" ), |
1102 | tr( "You must <b>restart</b> Opieplayer<br>to see your changes." ) ); | 1102 | tr( "You must <b>restart</b> Opieplayer<br>to see your changes." ) ); |
1103 | } | 1103 | } |
1104 | 1104 | ||
1105 | PlayListWidget::TabType PlayListWidget::currentTab() const | 1105 | PlayListWidget::TabType PlayListWidget::currentTab() const |
1106 | { | 1106 | { |
1107 | static const TabType indexToTabType[ TabTypeCount ] = | 1107 | static const TabType indexToTabType[ TabTypeCount ] = |
1108 | { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; | 1108 | { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; |
1109 | 1109 | ||
1110 | int index = tabWidget->currentPageIndex(); | 1110 | int index = tabWidget->currentPageIndex(); |
1111 | assert( index < TabTypeCount && index >= 0 ); | 1111 | assert( index < TabTypeCount && index >= 0 ); |
1112 | 1112 | ||
1113 | return indexToTabType[ index ]; | 1113 | return indexToTabType[ index ]; |
1114 | } | 1114 | } |
1115 | 1115 | ||
1116 | PlayListWidget::Entry PlayListWidget::currentEntry() const | 1116 | PlayListWidget::Entry PlayListWidget::currentEntry() const |
1117 | { | 1117 | { |
1118 | if ( currentTab() == CurrentPlayList ) { | 1118 | if ( currentTab() == CurrentPlayList ) { |
1119 | const DocLnk *lnk = current(); | 1119 | const DocLnk *lnk = current(); |
1120 | return Entry( lnk->name(), lnk->file() ); | 1120 | return Entry( lnk->name(), lnk->file() ); |
1121 | } | 1121 | } |
1122 | 1122 | ||
1123 | return Entry( currentFileListPathName() ); | 1123 | return Entry( currentFileListPathName() ); |
1124 | } | 1124 | } |
1125 | 1125 | ||
1126 | QString PlayListWidget::currentFileListPathName() const { | 1126 | QString PlayListWidget::currentFileListPathName() const { |
1127 | return currentFileListView()->currentItem()->text( 3 ); | 1127 | return currentFileListView()->currentItem()->text( 3 ); |
1128 | } | 1128 | } |
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h index fa2837a..3f52e63 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.h +++ b/noncore/multimedia/opieplayer2/playlistwidget.h | |||
@@ -1,140 +1,141 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; General Public License for more | 22 | ..}^=.= = ; General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = General Public License along with | 26 | -_. . . )=. = General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifndef PLAY_LIST_WIDGET_H | 34 | #ifndef PLAY_LIST_WIDGET_H |
35 | #define PLAY_LIST_WIDGET_H | 35 | #define PLAY_LIST_WIDGET_H |
36 | 36 | ||
37 | #include <qmainwindow.h> | 37 | #include <qmainwindow.h> |
38 | #include <qpe/applnk.h> | 38 | #include <qpe/applnk.h> |
39 | #include <qtabwidget.h> | 39 | #include <qtabwidget.h> |
40 | #include <qpe/fileselector.h> | 40 | #include <qpe/fileselector.h> |
41 | #include <qpushbutton.h> | 41 | #include <qpushbutton.h> |
42 | #include <qpopupmenu.h> | 42 | #include <qpopupmenu.h> |
43 | 43 | ||
44 | #include "playlistwidgetgui.h" | 44 | #include "playlistwidgetgui.h" |
45 | 45 | ||
46 | 46 | ||
47 | //class PlayListWidgetPrivate; | 47 | //class PlayListWidgetPrivate; |
48 | class Config; | 48 | class Config; |
49 | class QListViewItem; | 49 | class QListViewItem; |
50 | class QListView; | 50 | class QListView; |
51 | class QPoint; | 51 | class QPoint; |
52 | class QAction; | 52 | class QAction; |
53 | class QLabel; | 53 | class QLabel; |
54 | 54 | ||
55 | class PlayListWidget : public PlayListWidgetGui { | 55 | class PlayListWidget : public PlayListWidgetGui { |
56 | Q_OBJECT | 56 | Q_OBJECT |
57 | public: | 57 | public: |
58 | enum TabType { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; | 58 | enum TabType { CurrentPlayList, AudioFiles, VideoFiles, PlayLists }; |
59 | enum { TabTypeCount = 4 }; | 59 | enum { TabTypeCount = 4 }; |
60 | 60 | ||
61 | struct Entry | 61 | struct Entry |
62 | { | 62 | { |
63 | Entry( const QString &_name, const QString &_fileName ) | 63 | Entry( const QString &_name, const QString &_fileName ) |
64 | : name( _name ), file( _fileName ) {} | 64 | : name( _name ), file( _fileName ) {} |
65 | Entry( const QString &_fileName ) | 65 | Entry( const QString &_fileName ) |
66 | : name( _fileName ), file( _fileName ) {} | 66 | : name( _fileName ), file( _fileName ) {} |
67 | 67 | ||
68 | QString name; | 68 | QString name; |
69 | QString file; | 69 | QString file; |
70 | }; | 70 | }; |
71 | 71 | ||
72 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); | 72 | PlayListWidget( MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); |
73 | ~PlayListWidget(); | 73 | ~PlayListWidget(); |
74 | DocLnkSet files; | 74 | DocLnkSet files; |
75 | DocLnkSet vFiles; | 75 | DocLnkSet vFiles; |
76 | bool fromSetDocument; | 76 | bool fromSetDocument; |
77 | bool insanityBool; | 77 | bool insanityBool; |
78 | QString setDocFileRef, currentPlayList; | 78 | QString setDocFileRef, currentPlayList; |
79 | // retrieve the current playlist entry (media file link) | 79 | // retrieve the current playlist entry (media file link) |
80 | const DocLnk *current() const; | 80 | const DocLnk *current() const; |
81 | void useSelectedDocument(); | 81 | void useSelectedDocument(); |
82 | int selected; | 82 | int selected; |
83 | TabType currentTab() const; | 83 | TabType currentTab() const; |
84 | 84 | ||
85 | Entry currentEntry() const; | 85 | Entry currentEntry() const; |
86 | 86 | ||
87 | public slots: | 87 | public slots: |
88 | bool first(); | 88 | bool first(); |
89 | bool last(); | 89 | bool last(); |
90 | bool next(); | 90 | bool next(); |
91 | bool prev(); | 91 | bool prev(); |
92 | void writeDefaultPlaylist( ); | 92 | void writeDefaultPlaylist( ); |
93 | QString currentFileListPathName() const; | 93 | QString currentFileListPathName() const; |
94 | protected: | 94 | protected: |
95 | void keyReleaseEvent( QKeyEvent *e); | 95 | void keyReleaseEvent( QKeyEvent *e); |
96 | 96 | ||
97 | private: | 97 | private: |
98 | int defaultSkinIndex; | 98 | int defaultSkinIndex; |
99 | bool audioScan, videoScan, audioPopulated, videoPopulated; | 99 | bool audioScan, videoScan, audioPopulated, videoPopulated; |
100 | void readm3u(const QString &); | 100 | void readm3u(const QString &); |
101 | void readPls(const QString &); | 101 | void readPls(const QString &); |
102 | void initializeStates(); | 102 | void initializeStates(); |
103 | void populateAudioView(); | 103 | void populateAudioView(); |
104 | void populateVideoView(); | 104 | void populateVideoView(); |
105 | 105 | ||
106 | QListView *currentFileListView() const; | 106 | QListView *currentFileListView() const; |
107 | 107 | ||
108 | bool inFileListMode() const; | 108 | bool inFileListMode() const; |
109 | 109 | ||
110 | private slots: | 110 | private slots: |
111 | void populateSkinsMenu(); | 111 | void populateSkinsMenu(); |
112 | void skinsMenuActivated(int); | 112 | void skinsMenuActivated(int); |
113 | void pmViewActivated(int); | 113 | void pmViewActivated(int); |
114 | void writem3u(); | 114 | void writem3u(); |
115 | void writeCurrentM3u(); | 115 | void writeCurrentM3u(); |
116 | void scanForAudio(); | 116 | void scanForAudio(); |
117 | void scanForVideo(); | 117 | void scanForVideo(); |
118 | void openFile(); | 118 | void openFile(); |
119 | void setDocument( const QString& fileref ); | 119 | void setDocument( const QString& fileref ); |
120 | void addToSelection( const DocLnk& ); // Add a media file to the playlist | 120 | void addToSelection( const DocLnk& ); // Add a media file to the playlist |
121 | void addToSelection( QListViewItem* ); // Add a media file to the playlist | 121 | void addToSelection( QListViewItem* ); // Add a media file to the playlist |
122 | void clearList(); | 122 | void clearList(); |
123 | void addAllToList(); | 123 | void addAllToList(); |
124 | void addAllMusicToList(); | 124 | void addAllMusicToList(); |
125 | void addAllVideoToList(); | 125 | void addAllVideoToList(); |
126 | void saveList(); // Save the playlist | 126 | void saveList(); // Save the playlist |
127 | void loadList( const DocLnk &); // Load a playlist | 127 | void loadList( const DocLnk &); // Load a playlist |
128 | void playIt( QListViewItem *); | 128 | void playIt( QListViewItem *); |
129 | void btnPlay(bool); | 129 | void btnPlay(bool); |
130 | void deletePlaylist(); | 130 | void deletePlaylist(); |
131 | void addSelected(); | 131 | void addSelected(); |
132 | void removeSelected(); | 132 | void removeSelected(); |
133 | void tabChanged(QWidget*); | 133 | void tabChanged(QWidget*); |
134 | void viewPressed( int, QListViewItem *, const QPoint&, int); | 134 | void viewPressed( int, QListViewItem *, const QPoint&, int); |
135 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); | 135 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); |
136 | void playSelected(); | 136 | void playSelected(); |
137 | |||
137 | }; | 138 | }; |
138 | 139 | ||
139 | #endif // PLAY_LIST_WIDGET_H | 140 | #endif // PLAY_LIST_WIDGET_H |
140 | 141 | ||
diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp index 8be7a2f..f47ddcc 100644 --- a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp | |||
@@ -1,228 +1,226 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; General Public License for more | 22 | ..}^=.= = ; General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = General Public License along with | 26 | -_. . . )=. = General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <qpe/qpemenubar.h> | 34 | #include <qpe/qpemenubar.h> |
35 | #include <qpe/qpetoolbar.h> | 35 | #include <qpe/qpetoolbar.h> |
36 | #include <qpe/fileselector.h> | 36 | #include <qpe/fileselector.h> |
37 | #include <qpe/qpeapplication.h> | 37 | #include <qpe/qpeapplication.h> |
38 | #include <qpe/storage.h> | 38 | #include <qpe/storage.h> |
39 | #include <qpe/mimetype.h> | 39 | #include <qpe/mimetype.h> |
40 | #include <qpe/config.h> | 40 | #include <qpe/config.h> |
41 | #include <qpe/global.h> | 41 | #include <qpe/global.h> |
42 | #include <qpe/resource.h> | 42 | #include <qpe/resource.h> |
43 | 43 | ||
44 | #include <qpopupmenu.h> | 44 | #include <qpopupmenu.h> |
45 | #include <qaction.h> | 45 | #include <qaction.h> |
46 | #include <qcursor.h> | 46 | #include <qcursor.h> |
47 | #include <qdir.h> | 47 | #include <qdir.h> |
48 | #include <qlayout.h> | 48 | #include <qlayout.h> |
49 | 49 | ||
50 | #include "playlistselection.h" | 50 | #include "playlistselection.h" |
51 | #include "playlistwidget.h" | 51 | #include "playlistwidget.h" |
52 | #include "mediaplayerstate.h" | 52 | #include "mediaplayerstate.h" |
53 | #include "inputDialog.h" | 53 | #include "inputDialog.h" |
54 | 54 | ||
55 | //only needed for the random play | 55 | //only needed for the random play |
56 | #include <stdlib.h> | 56 | #include <stdlib.h> |
57 | 57 | ||
58 | #include "audiowidget.h" | 58 | #include "audiowidget.h" |
59 | #include "videowidget.h" | 59 | #include "videowidget.h" |
60 | #include "mediaplayerstate.h" | 60 | #include "mediaplayerstate.h" |
61 | 61 | ||
62 | extern MediaPlayerState *mediaPlayerState; | 62 | PlayListWidgetGui::PlayListWidgetGui( MediaPlayerState &_mediaPlayerState, QWidget* parent, const char* name ) |
63 | 63 | : QMainWindow( parent, name ), mediaPlayerState( _mediaPlayerState ) { | |
64 | PlayListWidgetGui::PlayListWidgetGui( QWidget* parent, const char* name, WFlags fl ) | ||
65 | : QMainWindow( parent, name, fl ) { | ||
66 | 64 | ||
67 | d = new PlayListWidgetPrivate; | 65 | d = new PlayListWidgetPrivate; |
68 | d->setDocumentUsed = FALSE; | 66 | d->setDocumentUsed = FALSE; |
69 | 67 | ||
70 | setBackgroundMode( PaletteButton ); | 68 | setBackgroundMode( PaletteButton ); |
71 | setToolBarsMovable( FALSE ); | 69 | setToolBarsMovable( FALSE ); |
72 | 70 | ||
73 | // Create Toolbar | 71 | // Create Toolbar |
74 | QPEToolBar *toolbar = new QPEToolBar( this ); | 72 | QPEToolBar *toolbar = new QPEToolBar( this ); |
75 | toolbar->setHorizontalStretchable( TRUE ); | 73 | toolbar->setHorizontalStretchable( TRUE ); |
76 | 74 | ||
77 | // Create Menubar | 75 | // Create Menubar |
78 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | 76 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); |
79 | menu->setMargin( 0 ); | 77 | menu->setMargin( 0 ); |
80 | 78 | ||
81 | bar = new QPEToolBar( this ); | 79 | bar = new QPEToolBar( this ); |
82 | bar->setLabel( tr( "Play Operations" ) ); | 80 | bar->setLabel( tr( "Play Operations" ) ); |
83 | 81 | ||
84 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet( "trash" ), "", bar, "close" ); | 82 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet( "trash" ), "", bar, "close" ); |
85 | tbDeletePlaylist->setFlat( TRUE ); | 83 | tbDeletePlaylist->setFlat( TRUE ); |
86 | tbDeletePlaylist->setFixedSize( 20, 20 ); | 84 | tbDeletePlaylist->setFixedSize( 20, 20 ); |
87 | 85 | ||
88 | tbDeletePlaylist->hide(); | 86 | tbDeletePlaylist->hide(); |
89 | 87 | ||
90 | pmPlayList = new QPopupMenu( this ); | 88 | pmPlayList = new QPopupMenu( this ); |
91 | menu->insertItem( tr( "File" ), pmPlayList ); | 89 | menu->insertItem( tr( "File" ), pmPlayList ); |
92 | 90 | ||
93 | pmView = new QPopupMenu( this ); | 91 | pmView = new QPopupMenu( this ); |
94 | menu->insertItem( tr( "View" ), pmView ); | 92 | menu->insertItem( tr( "View" ), pmView ); |
95 | pmView->isCheckable(); | 93 | pmView->isCheckable(); |
96 | 94 | ||
97 | skinsMenu = new QPopupMenu( this ); | 95 | skinsMenu = new QPopupMenu( this ); |
98 | pmView->insertItem( tr( "Skins" ), skinsMenu ); | 96 | pmView->insertItem( tr( "Skins" ), skinsMenu ); |
99 | skinsMenu->isCheckable(); | 97 | skinsMenu->isCheckable(); |
100 | 98 | ||
101 | gammaMenu = new QPopupMenu( this ); | 99 | gammaMenu = new QPopupMenu( this ); |
102 | pmView->insertItem( tr( "Gamma (Video)" ), gammaMenu ); | 100 | pmView->insertItem( tr( "Gamma (Video)" ), gammaMenu ); |
103 | 101 | ||
104 | gammaSlider = new QSlider( QSlider::Vertical, gammaMenu ); | 102 | gammaSlider = new QSlider( QSlider::Vertical, gammaMenu ); |
105 | gammaSlider->setRange( -40, 40 ); | 103 | gammaSlider->setRange( -40, 40 ); |
106 | gammaSlider->setTickmarks( QSlider::Left ); | 104 | gammaSlider->setTickmarks( QSlider::Left ); |
107 | gammaSlider->setTickInterval( 20 ); | 105 | gammaSlider->setTickInterval( 20 ); |
108 | gammaSlider->setFocusPolicy( QWidget::StrongFocus ); | 106 | gammaSlider->setFocusPolicy( QWidget::StrongFocus ); |
109 | gammaSlider->setValue( 0 ); | 107 | gammaSlider->setValue( 0 ); |
110 | gammaSlider->setMinimumHeight( 50 ); | 108 | gammaSlider->setMinimumHeight( 50 ); |
111 | 109 | ||
112 | gammaLCD = new QLCDNumber( 3, gammaMenu ); | 110 | gammaLCD = new QLCDNumber( 3, gammaMenu ); |
113 | gammaLCD-> setFrameShape ( QFrame::NoFrame ); | 111 | gammaLCD-> setFrameShape ( QFrame::NoFrame ); |
114 | gammaLCD-> setSegmentStyle ( QLCDNumber::Flat ); | 112 | gammaLCD-> setSegmentStyle ( QLCDNumber::Flat ); |
115 | 113 | ||
116 | gammaMenu->insertItem( gammaSlider ); | 114 | gammaMenu->insertItem( gammaSlider ); |
117 | gammaMenu->insertItem( gammaLCD ); | 115 | gammaMenu->insertItem( gammaLCD ); |
118 | 116 | ||
119 | connect( gammaSlider, SIGNAL( valueChanged( int ) ), gammaLCD, SLOT( display( int ) ) ); | 117 | connect( gammaSlider, SIGNAL( valueChanged( int ) ), gammaLCD, SLOT( display( int ) ) ); |
120 | 118 | ||
121 | vbox5 = new QVBox( this ); | 119 | vbox5 = new QVBox( this ); |
122 | QVBox *vbox4 = new QVBox( vbox5 ); | 120 | QVBox *vbox4 = new QVBox( vbox5 ); |
123 | QHBox *hbox6 = new QHBox( vbox4 ); | 121 | QHBox *hbox6 = new QHBox( vbox4 ); |
124 | 122 | ||
125 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 123 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
126 | 124 | ||
127 | QWidget *pTab; | 125 | QWidget *pTab; |
128 | pTab = new QWidget( tabWidget, "pTab" ); | 126 | pTab = new QWidget( tabWidget, "pTab" ); |
129 | tabWidget->insertTab( pTab, "Playlist"); | 127 | tabWidget->insertTab( pTab, "Playlist"); |
130 | 128 | ||
131 | QGridLayout *Playout = new QGridLayout( pTab ); | 129 | QGridLayout *Playout = new QGridLayout( pTab ); |
132 | Playout->setSpacing( 2); | 130 | Playout->setSpacing( 2); |
133 | Playout->setMargin( 2); | 131 | Playout->setMargin( 2); |
134 | 132 | ||
135 | // Add the playlist area | 133 | // Add the playlist area |
136 | QVBox *vbox3 = new QVBox( pTab ); | 134 | QVBox *vbox3 = new QVBox( pTab ); |
137 | d->playListFrame = vbox3; | 135 | d->playListFrame = vbox3; |
138 | 136 | ||
139 | QHBox *hbox2 = new QHBox( vbox3 ); | 137 | QHBox *hbox2 = new QHBox( vbox3 ); |
140 | d->selectedFiles = new PlayListSelection( hbox2 ); | 138 | d->selectedFiles = new PlayListSelection( hbox2 ); |
141 | 139 | ||
142 | vbox1 = new QVBox( hbox2 ); | 140 | vbox1 = new QVBox( hbox2 ); |
143 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(), QPEApplication::RightOnHold ); | 141 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(), QPEApplication::RightOnHold ); |
144 | QVBox *stretch1 = new QVBox( vbox1 ); // add stretch | 142 | QVBox *stretch1 = new QVBox( vbox1 ); // add stretch |
145 | 143 | ||
146 | Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 ); | 144 | Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 ); |
147 | 145 | ||
148 | QWidget *aTab; | 146 | QWidget *aTab; |
149 | aTab = new QWidget( tabWidget, "aTab" ); | 147 | aTab = new QWidget( tabWidget, "aTab" ); |
150 | 148 | ||
151 | QGridLayout *Alayout = new QGridLayout( aTab ); | 149 | QGridLayout *Alayout = new QGridLayout( aTab ); |
152 | Alayout->setSpacing( 2 ); | 150 | Alayout->setSpacing( 2 ); |
153 | Alayout->setMargin( 2 ); | 151 | Alayout->setMargin( 2 ); |
154 | audioView = new QListView( aTab, "Audioview" ); | 152 | audioView = new QListView( aTab, "Audioview" ); |
155 | audioView->addColumn( tr( "Title" ), 140 ); | 153 | audioView->addColumn( tr( "Title" ), 140 ); |
156 | audioView->addColumn( tr( "Size" ), -1 ); | 154 | audioView->addColumn( tr( "Size" ), -1 ); |
157 | audioView->addColumn( tr( "Media" ), 0 ); | 155 | audioView->addColumn( tr( "Media" ), 0 ); |
158 | audioView->addColumn( tr( "Path" ), -1 ); | 156 | audioView->addColumn( tr( "Path" ), -1 ); |
159 | audioView->setColumnAlignment( 1, Qt::AlignRight ); | 157 | audioView->setColumnAlignment( 1, Qt::AlignRight ); |
160 | audioView->setColumnAlignment( 2, Qt::AlignRight ); | 158 | audioView->setColumnAlignment( 2, Qt::AlignRight ); |
161 | audioView->setAllColumnsShowFocus( TRUE ); | 159 | audioView->setAllColumnsShowFocus( TRUE ); |
162 | audioView->setSorting( 3, TRUE ); | 160 | audioView->setSorting( 3, TRUE ); |
163 | audioView->setMultiSelection( TRUE ); | 161 | audioView->setMultiSelection( TRUE ); |
164 | audioView->setSelectionMode( QListView::Extended ); | 162 | audioView->setSelectionMode( QListView::Extended ); |
165 | Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 ); | 163 | Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 ); |
166 | tabWidget->insertTab( aTab, tr( "Audio" ) ); | 164 | tabWidget->insertTab( aTab, tr( "Audio" ) ); |
167 | 165 | ||
168 | QPEApplication::setStylusOperation( audioView->viewport(), QPEApplication::RightOnHold ); | 166 | QPEApplication::setStylusOperation( audioView->viewport(), QPEApplication::RightOnHold ); |
169 | 167 | ||
170 | QWidget *vTab; | 168 | QWidget *vTab; |
171 | vTab = new QWidget( tabWidget, "vTab" ); | 169 | vTab = new QWidget( tabWidget, "vTab" ); |
172 | 170 | ||
173 | QGridLayout *Vlayout = new QGridLayout( vTab ); | 171 | QGridLayout *Vlayout = new QGridLayout( vTab ); |
174 | Vlayout->setSpacing( 2 ); | 172 | Vlayout->setSpacing( 2 ); |
175 | Vlayout->setMargin( 2 ); | 173 | Vlayout->setMargin( 2 ); |
176 | videoView = new QListView( vTab, "Videoview" ); | 174 | videoView = new QListView( vTab, "Videoview" ); |
177 | videoView->addColumn( tr( "Title" ), 140); | 175 | videoView->addColumn( tr( "Title" ), 140); |
178 | videoView->addColumn( tr( "Size" ), -1 ); | 176 | videoView->addColumn( tr( "Size" ), -1 ); |
179 | videoView->addColumn(tr( "Media" ), 0 ); | 177 | videoView->addColumn(tr( "Media" ), 0 ); |
180 | videoView->addColumn(tr( "Path" ), -1 ); | 178 | videoView->addColumn(tr( "Path" ), -1 ); |
181 | videoView->setColumnAlignment( 1, Qt::AlignRight ); | 179 | videoView->setColumnAlignment( 1, Qt::AlignRight ); |
182 | videoView->setColumnAlignment( 2, Qt::AlignRight ); | 180 | videoView->setColumnAlignment( 2, Qt::AlignRight ); |
183 | videoView->setAllColumnsShowFocus( TRUE ); | 181 | videoView->setAllColumnsShowFocus( TRUE ); |
184 | videoView->setSorting( 3, TRUE ); | 182 | videoView->setSorting( 3, TRUE ); |
185 | videoView->setMultiSelection( TRUE ); | 183 | videoView->setMultiSelection( TRUE ); |
186 | videoView->setSelectionMode( QListView::Extended ); | 184 | videoView->setSelectionMode( QListView::Extended ); |
187 | Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 ); | 185 | Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 ); |
188 | 186 | ||
189 | QPEApplication::setStylusOperation( videoView->viewport(), QPEApplication::RightOnHold ); | 187 | QPEApplication::setStylusOperation( videoView->viewport(), QPEApplication::RightOnHold ); |
190 | 188 | ||
191 | tabWidget->insertTab( vTab, tr( "Video" ) ); | 189 | tabWidget->insertTab( vTab, tr( "Video" ) ); |
192 | 190 | ||
193 | //playlists list | 191 | //playlists list |
194 | QWidget *LTab; | 192 | QWidget *LTab; |
195 | LTab = new QWidget( tabWidget, "LTab" ); | 193 | LTab = new QWidget( tabWidget, "LTab" ); |
196 | QGridLayout *Llayout = new QGridLayout( LTab ); | 194 | QGridLayout *Llayout = new QGridLayout( LTab ); |
197 | Llayout->setSpacing( 2 ); | 195 | Llayout->setSpacing( 2 ); |
198 | Llayout->setMargin( 2 ); | 196 | Llayout->setMargin( 2 ); |
199 | 197 | ||
200 | playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE ); | 198 | playLists = new FileSelector( "playlist/plain;audio/x-mpegurl", LTab, "fileselector" , FALSE, FALSE ); |
201 | Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 ); | 199 | Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 ); |
202 | 200 | ||
203 | tabWidget->insertTab( LTab, tr( "Lists" ) ); | 201 | tabWidget->insertTab( LTab, tr( "Lists" ) ); |
204 | 202 | ||
205 | setCentralWidget( vbox5 ); | 203 | setCentralWidget( vbox5 ); |
206 | } | 204 | } |
207 | 205 | ||
208 | 206 | ||
209 | 207 | ||
210 | PlayListWidgetGui::~PlayListWidgetGui() { | 208 | PlayListWidgetGui::~PlayListWidgetGui() { |
211 | } | 209 | } |
212 | 210 | ||
213 | void PlayListWidgetGui::setView( char view ) { | 211 | void PlayListWidgetGui::setView( char view ) { |
214 | if ( view == 'l' ) | 212 | if ( view == 'l' ) |
215 | showMaximized(); | 213 | showMaximized(); |
216 | else | 214 | else |
217 | hide(); | 215 | hide(); |
218 | } | 216 | } |
219 | 217 | ||
220 | 218 | ||
221 | void PlayListWidgetGui::setActiveWindow() { | 219 | void PlayListWidgetGui::setActiveWindow() { |
222 | // qDebug("SETTING active window"); | 220 | // qDebug("SETTING active window"); |
223 | // When we get raised we need to ensure that it switches views | 221 | // When we get raised we need to ensure that it switches views |
224 | MediaPlayerState::DisplayType origDisplayType = mediaPlayerState->displayType(); | 222 | MediaPlayerState::DisplayType origDisplayType = mediaPlayerState.displayType(); |
225 | mediaPlayerState->setDisplayType( MediaPlayerState::MediaSelection ); // invalidate | 223 | mediaPlayerState.setDisplayType( MediaPlayerState::MediaSelection ); // invalidate |
226 | mediaPlayerState->setDisplayType( origDisplayType ); // now switch back | 224 | mediaPlayerState.setDisplayType( origDisplayType ); // now switch back |
227 | } | 225 | } |
228 | 226 | ||
diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.h b/noncore/multimedia/opieplayer2/playlistwidgetgui.h index 4eefb93..9b5252a 100644 --- a/noncore/multimedia/opieplayer2/playlistwidgetgui.h +++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.h | |||
@@ -1,128 +1,130 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; General Public License for more | 22 | ..}^=.= = ; General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = General Public License along with | 26 | -_. . . )=. = General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifndef PLAY_LIST_WIDGET_GUI_H | 34 | #ifndef PLAY_LIST_WIDGET_GUI_H |
35 | #define PLAY_LIST_WIDGET_GUI_H | 35 | #define PLAY_LIST_WIDGET_GUI_H |
36 | 36 | ||
37 | #include <qmainwindow.h> | 37 | #include <qmainwindow.h> |
38 | #include <qpe/applnk.h> | 38 | #include <qpe/applnk.h> |
39 | #include <qpe/resource.h> | 39 | #include <qpe/resource.h> |
40 | #include <qpe/qpemenubar.h> | 40 | #include <qpe/qpemenubar.h> |
41 | 41 | ||
42 | #include <qtabwidget.h> | 42 | #include <qtabwidget.h> |
43 | #include <qpe/fileselector.h> | 43 | #include <qpe/fileselector.h> |
44 | #include <qpushbutton.h> | 44 | #include <qpushbutton.h> |
45 | #include <qpopupmenu.h> | 45 | #include <qpopupmenu.h> |
46 | #include <qaction.h> | 46 | #include <qaction.h> |
47 | #include <qslider.h> | 47 | #include <qslider.h> |
48 | #include <qlcdnumber.h> | 48 | #include <qlcdnumber.h> |
49 | 49 | ||
50 | class PlayListWidgetPrivate; | 50 | class PlayListWidgetPrivate; |
51 | class PlayListSelection; | 51 | class PlayListSelection; |
52 | class MediaPlayerState; | ||
52 | 53 | ||
53 | class Config; | 54 | class Config; |
54 | class QPEToolBar; | 55 | class QPEToolBar; |
55 | class QListViewItem; | 56 | class QListViewItem; |
56 | class QListView; | 57 | class QListView; |
57 | class QPoint; | 58 | class QPoint; |
58 | class QAction; | 59 | class QAction; |
59 | class QLabel; | 60 | class QLabel; |
60 | 61 | ||
61 | class PlayListWidgetPrivate { | 62 | class PlayListWidgetPrivate { |
62 | public: | 63 | public: |
63 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | 64 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
64 | QFrame *playListFrame; | 65 | QFrame *playListFrame; |
65 | PlayListSelection *selectedFiles; | 66 | PlayListSelection *selectedFiles; |
66 | bool setDocumentUsed; | 67 | bool setDocumentUsed; |
67 | }; | 68 | }; |
68 | 69 | ||
69 | 70 | ||
70 | class ToolButton : public QToolButton { | 71 | class ToolButton : public QToolButton { |
71 | public: | 72 | public: |
72 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 73 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
73 | : QToolButton( parent, name ) { | 74 | : QToolButton( parent, name ) { |
74 | setTextLabel( name ); | 75 | setTextLabel( name ); |
75 | setPixmap( Resource::loadPixmap( icon ) ); | 76 | setPixmap( Resource::loadPixmap( icon ) ); |
76 | setAutoRaise( TRUE ); | 77 | setAutoRaise( TRUE ); |
77 | setFocusPolicy( QWidget::NoFocus ); | 78 | setFocusPolicy( QWidget::NoFocus ); |
78 | setToggleButton( t ); | 79 | setToggleButton( t ); |
79 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 80 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
80 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 81 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
81 | } | 82 | } |
82 | }; | 83 | }; |
83 | 84 | ||
84 | 85 | ||
85 | class MenuItem : public QAction { | 86 | class MenuItem : public QAction { |
86 | 87 | ||
87 | public: | 88 | public: |
88 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 89 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
89 | : QAction( text, QString::null, 0, 0 ) { | 90 | : QAction( text, QString::null, 0, 0 ) { |
90 | connect( this, SIGNAL( activated() ), handler, slot ); | 91 | connect( this, SIGNAL( activated() ), handler, slot ); |
91 | addTo( parent ); | 92 | addTo( parent ); |
92 | } | 93 | } |
93 | }; | 94 | }; |
94 | 95 | ||
95 | class PlayListWidgetGui : public QMainWindow { | 96 | class PlayListWidgetGui : public QMainWindow { |
96 | Q_OBJECT | 97 | Q_OBJECT |
97 | public: | 98 | public: |
98 | PlayListWidgetGui( QWidget* parent=0, const char* name=0, WFlags fl=0 ); | 99 | PlayListWidgetGui( MediaPlayerState &_mediaPlayerState, QWidget* parent=0, const char* name=0 ); |
99 | ~PlayListWidgetGui(); | 100 | ~PlayListWidgetGui(); |
100 | 101 | ||
101 | protected: | 102 | protected: |
102 | QTabWidget * tabWidget; | 103 | QTabWidget * tabWidget; |
103 | QListView *audioView, *videoView, *playlistView; | 104 | QListView *audioView, *videoView, *playlistView; |
104 | QLabel *libString; | 105 | QLabel *libString; |
105 | QPopupMenu *pmView ; | 106 | QPopupMenu *pmView ; |
106 | QPopupMenu *gammaMenu; | 107 | QPopupMenu *gammaMenu; |
107 | QSlider *gammaSlider; | 108 | QSlider *gammaSlider; |
108 | QLCDNumber *gammaLCD; | 109 | QLCDNumber *gammaLCD; |
109 | bool fromSetDocument; | 110 | bool fromSetDocument; |
110 | bool insanityBool; | 111 | bool insanityBool; |
111 | QString setDocFileRef; | 112 | QString setDocFileRef; |
112 | // retrieve the current playlist entry (media file link) | 113 | // retrieve the current playlist entry (media file link) |
113 | QPushButton *tbDeletePlaylist; | 114 | QPushButton *tbDeletePlaylist; |
114 | int selected; | 115 | int selected; |
115 | QPopupMenu *pmPlayList; | 116 | QPopupMenu *pmPlayList; |
116 | FileSelector* playLists; | 117 | FileSelector* playLists; |
117 | QPopupMenu *skinsMenu; | 118 | QPopupMenu *skinsMenu; |
118 | PlayListWidgetPrivate *d; // Private implementation data | 119 | PlayListWidgetPrivate *d; // Private implementation data |
119 | QVBox *vbox1; | 120 | QVBox *vbox1; |
120 | QVBox *vbox5; | 121 | QVBox *vbox5; |
121 | QPEToolBar *bar; | 122 | QPEToolBar *bar; |
122 | void setActiveWindow(); // need to handle this to show the right view | 123 | void setActiveWindow(); // need to handle this to show the right view |
123 | void setView( char ); | 124 | void setView( char ); |
124 | 125 | ||
126 | MediaPlayerState &mediaPlayerState; | ||
125 | }; | 127 | }; |
126 | 128 | ||
127 | #endif | 129 | #endif |
128 | 130 | ||