-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 46 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.h | 4 |
2 files changed, 50 insertions, 0 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index a0bf4db..5e1be2f 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -1,1422 +1,1468 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 | 20 | // code added by L. J. Potter Sat 03-02-2002 06:17:54 |
21 | #define QTOPIA_INTERNAL_FSLP | 21 | #define QTOPIA_INTERNAL_FSLP |
22 | #include <qpe/qcopenvelope_qws.h> | 22 | #include <qpe/qcopenvelope_qws.h> |
23 | 23 | ||
24 | #include <qpe/qpemenubar.h> | 24 | #include <qpe/qpemenubar.h> |
25 | #include <qpe/qpetoolbar.h> | 25 | #include <qpe/qpetoolbar.h> |
26 | #include <qpe/fileselector.h> | 26 | #include <qpe/fileselector.h> |
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | #include <qpe/lnkproperties.h> | 28 | #include <qpe/lnkproperties.h> |
29 | #include <qpe/storage.h> | 29 | #include <qpe/storage.h> |
30 | 30 | ||
31 | #include <qpe/applnk.h> | 31 | #include <qpe/applnk.h> |
32 | #include <qpe/config.h> | 32 | #include <qpe/config.h> |
33 | #include <qpe/global.h> | 33 | #include <qpe/global.h> |
34 | #include <qpe/resource.h> | 34 | #include <qpe/resource.h> |
35 | #include <qaction.h> | 35 | #include <qaction.h> |
36 | #include <qcursor.h> | 36 | #include <qcursor.h> |
37 | #include <qimage.h> | 37 | #include <qimage.h> |
38 | #include <qfile.h> | 38 | #include <qfile.h> |
39 | #include <qdir.h> | 39 | #include <qdir.h> |
40 | #include <qlayout.h> | 40 | #include <qlayout.h> |
41 | #include <qlabel.h> | 41 | #include <qlabel.h> |
42 | #include <qlist.h> | 42 | #include <qlist.h> |
43 | #include <qlistbox.h> | 43 | #include <qlistbox.h> |
44 | #include <qmainwindow.h> | 44 | #include <qmainwindow.h> |
45 | #include <qmessagebox.h> | 45 | #include <qmessagebox.h> |
46 | #include <qtoolbutton.h> | 46 | #include <qtoolbutton.h> |
47 | #include <qtabwidget.h> | 47 | #include <qtabwidget.h> |
48 | #include <qlistview.h> | 48 | #include <qlistview.h> |
49 | #include <qpoint.h> | 49 | #include <qpoint.h> |
50 | #include <qlineedit.h> | 50 | #include <qlineedit.h> |
51 | #include <qpushbutton.h> | 51 | #include <qpushbutton.h> |
52 | #include <qregexp.h> | 52 | #include <qregexp.h> |
53 | #include <qtextstream.h> | 53 | #include <qtextstream.h> |
54 | 54 | ||
55 | //#include <qtimer.h> | 55 | //#include <qtimer.h> |
56 | 56 | ||
57 | #include "playlistselection.h" | 57 | #include "playlistselection.h" |
58 | #include "playlistwidget.h" | 58 | #include "playlistwidget.h" |
59 | #include "mediaplayerstate.h" | 59 | #include "mediaplayerstate.h" |
60 | 60 | ||
61 | #include "inputDialog.h" | 61 | #include "inputDialog.h" |
62 | 62 | ||
63 | #include <stdlib.h> | 63 | #include <stdlib.h> |
64 | #include "audiowidget.h" | 64 | #include "audiowidget.h" |
65 | #include "videowidget.h" | 65 | #include "videowidget.h" |
66 | 66 | ||
67 | #include <unistd.h> | 67 | #include <unistd.h> |
68 | #include <sys/file.h> | 68 | #include <sys/file.h> |
69 | #include <sys/ioctl.h> | 69 | #include <sys/ioctl.h> |
70 | #include <sys/soundcard.h> | 70 | #include <sys/soundcard.h> |
71 | 71 | ||
72 | // for setBacklight() | 72 | // for setBacklight() |
73 | #include <linux/fb.h> | 73 | #include <linux/fb.h> |
74 | #include <sys/types.h> | 74 | #include <sys/types.h> |
75 | #include <sys/stat.h> | 75 | #include <sys/stat.h> |
76 | #include <stdlib.h> | 76 | #include <stdlib.h> |
77 | 77 | ||
78 | #define BUTTONS_ON_TOOLBAR | 78 | #define BUTTONS_ON_TOOLBAR |
79 | #define SIDE_BUTTONS | 79 | #define SIDE_BUTTONS |
80 | #define CAN_SAVE_LOAD_PLAYLISTS | 80 | #define CAN_SAVE_LOAD_PLAYLISTS |
81 | 81 | ||
82 | extern AudioWidget *audioUI; | 82 | extern AudioWidget *audioUI; |
83 | extern VideoWidget *videoUI; | 83 | extern VideoWidget *videoUI; |
84 | extern MediaPlayerState *mediaPlayerState; | 84 | extern MediaPlayerState *mediaPlayerState; |
85 | 85 | ||
86 | static inline QString fullBaseName ( const QFileInfo &fi ) | 86 | static inline QString fullBaseName ( const QFileInfo &fi ) |
87 | { | 87 | { |
88 | QString str = fi. fileName ( ); | 88 | QString str = fi. fileName ( ); |
89 | return str. left ( str. findRev ( '.' )); | 89 | return str. left ( str. findRev ( '.' )); |
90 | } | 90 | } |
91 | 91 | ||
92 | 92 | ||
93 | QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg;audio/x-mod"; | 93 | QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg;audio/x-mod"; |
94 | // class myFileSelector { | 94 | // class myFileSelector { |
95 | 95 | ||
96 | // }; | 96 | // }; |
97 | class PlayListWidgetPrivate { | 97 | class PlayListWidgetPrivate { |
98 | public: | 98 | public: |
99 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | 99 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
100 | QFrame *playListFrame; | 100 | QFrame *playListFrame; |
101 | FileSelector *files; | 101 | FileSelector *files; |
102 | PlayListSelection *selectedFiles; | 102 | PlayListSelection *selectedFiles; |
103 | bool setDocumentUsed; | 103 | bool setDocumentUsed; |
104 | DocLnk *current; | 104 | DocLnk *current; |
105 | }; | 105 | }; |
106 | 106 | ||
107 | 107 | ||
108 | class ToolButton : public QToolButton { | 108 | class ToolButton : public QToolButton { |
109 | public: | 109 | public: |
110 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 110 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
111 | : QToolButton( parent, name ) { | 111 | : QToolButton( parent, name ) { |
112 | setTextLabel( name ); | 112 | setTextLabel( name ); |
113 | setPixmap( Resource::loadPixmap( icon ) ); | 113 | setPixmap( Resource::loadPixmap( icon ) ); |
114 | setAutoRaise( TRUE ); | 114 | setAutoRaise( TRUE ); |
115 | setFocusPolicy( QWidget::NoFocus ); | 115 | setFocusPolicy( QWidget::NoFocus ); |
116 | setToggleButton( t ); | 116 | setToggleButton( t ); |
117 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 117 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
118 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 118 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
119 | } | 119 | } |
120 | }; | 120 | }; |
121 | 121 | ||
122 | 122 | ||
123 | class MenuItem : public QAction { | 123 | class MenuItem : public QAction { |
124 | public: | 124 | public: |
125 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 125 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
126 | : QAction( text, QString::null, 0, 0 ) { | 126 | : QAction( text, QString::null, 0, 0 ) { |
127 | connect( this, SIGNAL( activated() ), handler, slot ); | 127 | connect( this, SIGNAL( activated() ), handler, slot ); |
128 | addTo( parent ); | 128 | addTo( parent ); |
129 | } | 129 | } |
130 | }; | 130 | }; |
131 | 131 | ||
132 | 132 | ||
133 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 133 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
134 | : QMainWindow( parent, name, fl ) { | 134 | : QMainWindow( parent, name, fl ) { |
135 | 135 | ||
136 | d = new PlayListWidgetPrivate; | 136 | d = new PlayListWidgetPrivate; |
137 | d->setDocumentUsed = FALSE; | 137 | d->setDocumentUsed = FALSE; |
138 | d->current = NULL; | 138 | d->current = NULL; |
139 | fromSetDocument = FALSE; | 139 | fromSetDocument = FALSE; |
140 | insanityBool=FALSE; | 140 | insanityBool=FALSE; |
141 | audioScan = FALSE; | 141 | audioScan = FALSE; |
142 | videoScan = FALSE; | 142 | videoScan = FALSE; |
143 | // menuTimer = new QTimer( this ,"menu timer"), | 143 | // menuTimer = new QTimer( this ,"menu timer"), |
144 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); | 144 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); |
145 | channel = new QCopChannel( "QPE/Application/opieplayer", this ); | ||
146 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | ||
147 | this, SLOT( qcopReceive(const QCString&, const QByteArray&)) ); | ||
145 | 148 | ||
146 | setBackgroundMode( PaletteButton ); | 149 | setBackgroundMode( PaletteButton ); |
147 | 150 | ||
148 | setCaption( tr("OpiePlayer") ); | 151 | setCaption( tr("OpiePlayer") ); |
149 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); | 152 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); |
150 | 153 | ||
151 | setToolBarsMovable( FALSE ); | 154 | setToolBarsMovable( FALSE ); |
152 | 155 | ||
153 | // Create Toolbar | 156 | // Create Toolbar |
154 | QPEToolBar *toolbar = new QPEToolBar( this ); | 157 | QPEToolBar *toolbar = new QPEToolBar( this ); |
155 | toolbar->setHorizontalStretchable( TRUE ); | 158 | toolbar->setHorizontalStretchable( TRUE ); |
156 | 159 | ||
157 | // Create Menubar | 160 | // Create Menubar |
158 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | 161 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); |
159 | menu->setMargin( 0 ); | 162 | menu->setMargin( 0 ); |
160 | 163 | ||
161 | QPEToolBar *bar = new QPEToolBar( this ); | 164 | QPEToolBar *bar = new QPEToolBar( this ); |
162 | bar->setLabel( tr( "Play Operations" ) ); | 165 | bar->setLabel( tr( "Play Operations" ) ); |
163 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", | 166 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", |
164 | // this , SLOT( addSelected()) ); | 167 | // this , SLOT( addSelected()) ); |
165 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); | 168 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); |
166 | tbDeletePlaylist->setFlat(TRUE); | 169 | tbDeletePlaylist->setFlat(TRUE); |
167 | tbDeletePlaylist->setFixedSize(20,20); | 170 | tbDeletePlaylist->setFixedSize(20,20); |
168 | 171 | ||
169 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", | 172 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", |
170 | this , SLOT(addSelected()) ); | 173 | this , SLOT(addSelected()) ); |
171 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", | 174 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", |
172 | this , SLOT(removeSelected()) ); | 175 | this , SLOT(removeSelected()) ); |
173 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); | 176 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); |
174 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", | 177 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", |
175 | this , SLOT( btnPlay(bool) ), TRUE ); | 178 | this , SLOT( btnPlay(bool) ), TRUE ); |
176 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", | 179 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", |
177 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 180 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); |
178 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", | 181 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", |
179 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 182 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); |
180 | tbDeletePlaylist->hide(); | 183 | tbDeletePlaylist->hide(); |
181 | 184 | ||
182 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 185 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
183 | menu->insertItem( tr( "File" ), pmPlayList ); | 186 | menu->insertItem( tr( "File" ), pmPlayList ); |
184 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 187 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
185 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 188 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
186 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 189 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
187 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 190 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
188 | pmPlayList->insertSeparator(-1); | 191 | pmPlayList->insertSeparator(-1); |
189 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 192 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
190 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); | 193 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); |
191 | pmPlayList->insertSeparator(-1); | 194 | pmPlayList->insertSeparator(-1); |
192 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); | 195 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); |
193 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); | 196 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); |
194 | 197 | ||
195 | QPopupMenu *pmView = new QPopupMenu( this ); | 198 | QPopupMenu *pmView = new QPopupMenu( this ); |
196 | menu->insertItem( tr( "View" ), pmView ); | 199 | menu->insertItem( tr( "View" ), pmView ); |
197 | 200 | ||
198 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); | 201 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); |
199 | fullScreenButton->addTo(pmView); | 202 | fullScreenButton->addTo(pmView); |
200 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); | 203 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); |
201 | scaleButton->addTo(pmView); | 204 | scaleButton->addTo(pmView); |
202 | 205 | ||
203 | 206 | ||
204 | skinsMenu = new QPopupMenu( this ); | 207 | skinsMenu = new QPopupMenu( this ); |
205 | menu->insertItem( tr( "Skins" ), skinsMenu ); | 208 | menu->insertItem( tr( "Skins" ), skinsMenu ); |
206 | skinsMenu->isCheckable(); | 209 | skinsMenu->isCheckable(); |
207 | connect( skinsMenu, SIGNAL( activated( int ) ) , | 210 | connect( skinsMenu, SIGNAL( activated( int ) ) , |
208 | this, SLOT( skinsMenuActivated( int ) ) ); | 211 | this, SLOT( skinsMenuActivated( int ) ) ); |
209 | populateSkinsMenu(); | 212 | populateSkinsMenu(); |
210 | 213 | ||
211 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 214 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
212 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | 215 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); |
213 | 216 | ||
214 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | 217 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); |
215 | 218 | ||
216 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 219 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
217 | // tabWidget->setTabShape(QTabWidget::Triangular); | 220 | // tabWidget->setTabShape(QTabWidget::Triangular); |
218 | 221 | ||
219 | QWidget *pTab; | 222 | QWidget *pTab; |
220 | pTab = new QWidget( tabWidget, "pTab" ); | 223 | pTab = new QWidget( tabWidget, "pTab" ); |
221 | // playlistView = new QListView( pTab, "playlistview" ); | 224 | // playlistView = new QListView( pTab, "playlistview" ); |
222 | // playlistView->setMinimumSize(236,260); | 225 | // playlistView->setMinimumSize(236,260); |
223 | tabWidget->insertTab( pTab,"Playlist"); | 226 | tabWidget->insertTab( pTab,"Playlist"); |
224 | 227 | ||
225 | 228 | ||
226 | // Add the playlist area | 229 | // Add the playlist area |
227 | 230 | ||
228 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); | 231 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); |
229 | d->playListFrame = vbox3; | 232 | d->playListFrame = vbox3; |
230 | d->playListFrame ->setMinimumSize(235,260); | 233 | d->playListFrame ->setMinimumSize(235,260); |
231 | 234 | ||
232 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); | 235 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); |
233 | 236 | ||
234 | d->selectedFiles = new PlayListSelection( hbox2); | 237 | d->selectedFiles = new PlayListSelection( hbox2); |
235 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | 238 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); |
236 | 239 | ||
237 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); | 240 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); |
238 | 241 | ||
239 | 242 | ||
240 | 243 | ||
241 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | 244 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch |
242 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 245 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
243 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | 246 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); |
244 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 247 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
245 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 248 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
246 | 249 | ||
247 | QWidget *aTab; | 250 | QWidget *aTab; |
248 | aTab = new QWidget( tabWidget, "aTab" ); | 251 | aTab = new QWidget( tabWidget, "aTab" ); |
249 | audioView = new QListView( aTab, "Audioview" ); | 252 | audioView = new QListView( aTab, "Audioview" ); |
250 | audioView->setMinimumSize(233,260); | 253 | audioView->setMinimumSize(233,260); |
251 | audioView->addColumn( tr("Title"),140); | 254 | audioView->addColumn( tr("Title"),140); |
252 | audioView->addColumn(tr("Size"), -1); | 255 | audioView->addColumn(tr("Size"), -1); |
253 | audioView->addColumn(tr("Media"),-1); | 256 | audioView->addColumn(tr("Media"),-1); |
254 | audioView->addColumn( tr( "Path" ), 0 ); | 257 | audioView->addColumn( tr( "Path" ), 0 ); |
255 | 258 | ||
256 | audioView->setColumnAlignment(1, Qt::AlignRight); | 259 | audioView->setColumnAlignment(1, Qt::AlignRight); |
257 | audioView->setColumnAlignment(2, Qt::AlignRight); | 260 | audioView->setColumnAlignment(2, Qt::AlignRight); |
258 | audioView->setAllColumnsShowFocus(TRUE); | 261 | audioView->setAllColumnsShowFocus(TRUE); |
259 | 262 | ||
260 | audioView->setMultiSelection( TRUE ); | 263 | audioView->setMultiSelection( TRUE ); |
261 | audioView->setSelectionMode( QListView::Extended); | 264 | audioView->setSelectionMode( QListView::Extended); |
262 | audioView->setSorting( 3, TRUE ); | 265 | audioView->setSorting( 3, TRUE ); |
263 | 266 | ||
264 | tabWidget->insertTab(aTab,tr("Audio")); | 267 | tabWidget->insertTab(aTab,tr("Audio")); |
265 | 268 | ||
266 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | 269 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); |
267 | 270 | ||
268 | // audioView | 271 | // audioView |
269 | // populateAudioView(); | 272 | // populateAudioView(); |
270 | // videowidget | 273 | // videowidget |
271 | 274 | ||
272 | QWidget *vTab; | 275 | QWidget *vTab; |
273 | vTab = new QWidget( tabWidget, "vTab" ); | 276 | vTab = new QWidget( tabWidget, "vTab" ); |
274 | videoView = new QListView( vTab, "Videoview" ); | 277 | videoView = new QListView( vTab, "Videoview" ); |
275 | videoView->setMinimumSize(233,260); | 278 | videoView->setMinimumSize(233,260); |
276 | 279 | ||
277 | videoView->addColumn(tr("Title"),140); | 280 | videoView->addColumn(tr("Title"),140); |
278 | videoView->addColumn(tr("Size"),-1); | 281 | videoView->addColumn(tr("Size"),-1); |
279 | videoView->addColumn(tr("Media"),-1); | 282 | videoView->addColumn(tr("Media"),-1); |
280 | videoView->addColumn(tr( "Path" ), 0 ); | 283 | videoView->addColumn(tr( "Path" ), 0 ); |
281 | videoView->setColumnAlignment(1, Qt::AlignRight); | 284 | videoView->setColumnAlignment(1, Qt::AlignRight); |
282 | videoView->setColumnAlignment(2, Qt::AlignRight); | 285 | videoView->setColumnAlignment(2, Qt::AlignRight); |
283 | videoView->setAllColumnsShowFocus(TRUE); | 286 | videoView->setAllColumnsShowFocus(TRUE); |
284 | videoView->setMultiSelection( TRUE ); | 287 | videoView->setMultiSelection( TRUE ); |
285 | videoView->setSelectionMode( QListView::Extended); | 288 | videoView->setSelectionMode( QListView::Extended); |
286 | 289 | ||
287 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 290 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
288 | 291 | ||
289 | tabWidget->insertTab( vTab,tr("Video")); | 292 | tabWidget->insertTab( vTab,tr("Video")); |
290 | 293 | ||
291 | QWidget *LTab; | 294 | QWidget *LTab; |
292 | LTab = new QWidget( tabWidget, "LTab" ); | 295 | LTab = new QWidget( tabWidget, "LTab" ); |
293 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | 296 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy |
294 | playLists->setMinimumSize(233,260); | 297 | playLists->setMinimumSize(233,260); |
295 | tabWidget->insertTab(LTab,tr("Lists")); | 298 | tabWidget->insertTab(LTab,tr("Lists")); |
296 | 299 | ||
297 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); | 300 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); |
298 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); | 301 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); |
299 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); | 302 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); |
300 | 303 | ||
301 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 304 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
302 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); | 305 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); |
303 | 306 | ||
304 | 307 | ||
305 | ///audioView | 308 | ///audioView |
306 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 309 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
307 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 310 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
308 | 311 | ||
309 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), | 312 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), |
310 | this,SLOT( playIt( QListViewItem *)) ); | 313 | this,SLOT( playIt( QListViewItem *)) ); |
311 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 314 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
312 | 315 | ||
313 | 316 | ||
314 | //videoView | 317 | //videoView |
315 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 318 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
316 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 319 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
317 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), | 320 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), |
318 | this,SLOT( playIt( QListViewItem *)) ); | 321 | this,SLOT( playIt( QListViewItem *)) ); |
319 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 322 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
320 | 323 | ||
321 | 324 | ||
322 | //playlists | 325 | //playlists |
323 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 326 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
324 | 327 | ||
325 | 328 | ||
326 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 329 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
327 | 330 | ||
328 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 331 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
329 | 332 | ||
330 | 333 | ||
331 | 334 | ||
332 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 335 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
333 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 336 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
334 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 337 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
335 | 338 | ||
336 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 339 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
337 | 340 | ||
338 | setCentralWidget( vbox5 ); | 341 | setCentralWidget( vbox5 ); |
339 | 342 | ||
340 | Config cfg( "OpiePlayer" ); | 343 | Config cfg( "OpiePlayer" ); |
341 | readConfig( cfg ); | 344 | readConfig( cfg ); |
342 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); | 345 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); |
343 | loadList(DocLnk( currentPlaylist)); | 346 | loadList(DocLnk( currentPlaylist)); |
344 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlaylist))); | 347 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlaylist))); |
345 | 348 | ||
346 | initializeStates(); | 349 | initializeStates(); |
347 | } | 350 | } |
348 | 351 | ||
349 | 352 | ||
350 | PlayListWidget::~PlayListWidget() { | 353 | PlayListWidget::~PlayListWidget() { |
351 | Config cfg( "OpiePlayer" ); | 354 | Config cfg( "OpiePlayer" ); |
352 | writeConfig( cfg ); | 355 | writeConfig( cfg ); |
353 | 356 | ||
354 | if ( d->current ) | 357 | if ( d->current ) |
355 | delete d->current; | 358 | delete d->current; |
356 | delete d; | 359 | delete d; |
357 | } | 360 | } |
358 | 361 | ||
359 | 362 | ||
360 | void PlayListWidget::initializeStates() { | 363 | void PlayListWidget::initializeStates() { |
361 | 364 | ||
362 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 365 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
363 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 366 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
364 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 367 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
365 | setPlaylist( true); | 368 | setPlaylist( true); |
366 | } | 369 | } |
367 | 370 | ||
368 | 371 | ||
369 | void PlayListWidget::readConfig( Config& cfg ) { | 372 | void PlayListWidget::readConfig( Config& cfg ) { |
370 | cfg.setGroup("PlayList"); | 373 | cfg.setGroup("PlayList"); |
371 | QString currentString = cfg.readEntry("current", "" ); | 374 | QString currentString = cfg.readEntry("current", "" ); |
372 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 375 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
373 | for ( int i = 0; i < noOfFiles; i++ ) { | 376 | for ( int i = 0; i < noOfFiles; i++ ) { |
374 | QString entryName; | 377 | QString entryName; |
375 | entryName.sprintf( "File%i", i + 1 ); | 378 | entryName.sprintf( "File%i", i + 1 ); |
376 | QString linkFile = cfg.readEntry( entryName ); | 379 | QString linkFile = cfg.readEntry( entryName ); |
377 | DocLnk lnk( linkFile ); | 380 | DocLnk lnk( linkFile ); |
378 | if ( lnk.isValid() ) { | 381 | if ( lnk.isValid() ) { |
379 | d->selectedFiles->addToSelection( lnk ); | 382 | d->selectedFiles->addToSelection( lnk ); |
380 | } | 383 | } |
381 | } | 384 | } |
382 | d->selectedFiles->setSelectedItem( currentString); | 385 | d->selectedFiles->setSelectedItem( currentString); |
383 | } | 386 | } |
384 | 387 | ||
385 | 388 | ||
386 | void PlayListWidget::writeConfig( Config& cfg ) const { | 389 | void PlayListWidget::writeConfig( Config& cfg ) const { |
387 | 390 | ||
388 | d->selectedFiles->writeCurrent( cfg); | 391 | d->selectedFiles->writeCurrent( cfg); |
389 | cfg.setGroup("PlayList"); | 392 | cfg.setGroup("PlayList"); |
390 | int noOfFiles = 0; | 393 | int noOfFiles = 0; |
391 | d->selectedFiles->first(); | 394 | d->selectedFiles->first(); |
392 | do { | 395 | do { |
393 | const DocLnk *lnk = d->selectedFiles->current(); | 396 | const DocLnk *lnk = d->selectedFiles->current(); |
394 | if ( lnk ) { | 397 | if ( lnk ) { |
395 | QString entryName; | 398 | QString entryName; |
396 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 399 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
397 | // qDebug(entryName); | 400 | // qDebug(entryName); |
398 | cfg.writeEntry( entryName, lnk->linkFile() ); | 401 | cfg.writeEntry( entryName, lnk->linkFile() ); |
399 | // if this link does exist, add it so we have the file | 402 | // if this link does exist, add it so we have the file |
400 | // next time... | 403 | // next time... |
401 | if ( !QFile::exists( lnk->linkFile() ) ) { | 404 | if ( !QFile::exists( lnk->linkFile() ) ) { |
402 | // the way writing lnks doesn't really check for out | 405 | // the way writing lnks doesn't really check for out |
403 | // of disk space, but check it anyway. | 406 | // of disk space, but check it anyway. |
404 | if ( !lnk->writeLink() ) { | 407 | if ( !lnk->writeLink() ) { |
405 | QMessageBox::critical( 0, tr("Out of space"), | 408 | QMessageBox::critical( 0, tr("Out of space"), |
406 | tr( "There was a problem saving " | 409 | tr( "There was a problem saving " |
407 | "the playlist.\n" | 410 | "the playlist.\n" |
408 | "Your playlist " | 411 | "Your playlist " |
409 | "may be missing some entries\n" | 412 | "may be missing some entries\n" |
410 | "the next time you start it." ) | 413 | "the next time you start it." ) |
411 | ); | 414 | ); |
412 | } | 415 | } |
413 | } | 416 | } |
414 | noOfFiles++; | 417 | noOfFiles++; |
415 | } | 418 | } |
416 | } | 419 | } |
417 | while ( d->selectedFiles->next() ); | 420 | while ( d->selectedFiles->next() ); |
418 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 421 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
419 | } | 422 | } |
420 | 423 | ||
421 | 424 | ||
422 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 425 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
423 | d->setDocumentUsed = false; | 426 | d->setDocumentUsed = false; |
424 | if ( mediaPlayerState->playlist() ) { | 427 | if ( mediaPlayerState->playlist() ) { |
425 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) | 428 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) |
426 | d->selectedFiles->addToSelection( lnk ); | 429 | d->selectedFiles->addToSelection( lnk ); |
427 | } | 430 | } |
428 | else | 431 | else |
429 | mediaPlayerState->setPlaying( true); | 432 | mediaPlayerState->setPlaying( true); |
430 | } | 433 | } |
431 | 434 | ||
432 | 435 | ||
433 | void PlayListWidget::clearList() { | 436 | void PlayListWidget::clearList() { |
434 | while ( first() ) | 437 | while ( first() ) |
435 | d->selectedFiles->removeSelected(); | 438 | d->selectedFiles->removeSelected(); |
436 | } | 439 | } |
437 | 440 | ||
438 | 441 | ||
439 | void PlayListWidget::addAllToList() { | 442 | void PlayListWidget::addAllToList() { |
440 | DocLnkSet filesAll; | 443 | DocLnkSet filesAll; |
441 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 444 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
442 | QListIterator<DocLnk> Adit( filesAll.children() ); | 445 | QListIterator<DocLnk> Adit( filesAll.children() ); |
443 | for ( ; Adit.current(); ++Adit ) | 446 | for ( ; Adit.current(); ++Adit ) |
444 | if(QFileInfo(Adit.current()->file()).exists()) | 447 | if(QFileInfo(Adit.current()->file()).exists()) |
445 | d->selectedFiles->addToSelection( **Adit ); | 448 | d->selectedFiles->addToSelection( **Adit ); |
446 | tabWidget->setCurrentPage(0); | 449 | tabWidget->setCurrentPage(0); |
447 | 450 | ||
448 | writeCurrentM3u(); | 451 | writeCurrentM3u(); |
449 | d->selectedFiles->first(); | 452 | d->selectedFiles->first(); |
450 | } | 453 | } |
451 | 454 | ||
452 | 455 | ||
453 | void PlayListWidget::addAllMusicToList() { | 456 | void PlayListWidget::addAllMusicToList() { |
454 | QListIterator<DocLnk> dit( files.children() ); | 457 | QListIterator<DocLnk> dit( files.children() ); |
455 | for ( ; dit.current(); ++dit ) | 458 | for ( ; dit.current(); ++dit ) |
456 | if(QFileInfo(dit.current()->file()).exists()) | 459 | if(QFileInfo(dit.current()->file()).exists()) |
457 | d->selectedFiles->addToSelection( **dit ); | 460 | d->selectedFiles->addToSelection( **dit ); |
458 | tabWidget->setCurrentPage(0); | 461 | tabWidget->setCurrentPage(0); |
459 | 462 | ||
460 | writeCurrentM3u(); | 463 | writeCurrentM3u(); |
461 | d->selectedFiles->first(); | 464 | d->selectedFiles->first(); |
462 | } | 465 | } |
463 | 466 | ||
464 | 467 | ||
465 | void PlayListWidget::addAllVideoToList() { | 468 | void PlayListWidget::addAllVideoToList() { |
466 | QListIterator<DocLnk> dit( vFiles.children() ); | 469 | QListIterator<DocLnk> dit( vFiles.children() ); |
467 | for ( ; dit.current(); ++dit ) | 470 | for ( ; dit.current(); ++dit ) |
468 | if(QFileInfo( dit.current()->file()).exists()) | 471 | if(QFileInfo( dit.current()->file()).exists()) |
469 | d->selectedFiles->addToSelection( **dit ); | 472 | d->selectedFiles->addToSelection( **dit ); |
470 | tabWidget->setCurrentPage(0); | 473 | tabWidget->setCurrentPage(0); |
471 | 474 | ||
472 | writeCurrentM3u(); | 475 | writeCurrentM3u(); |
473 | d->selectedFiles->first(); | 476 | d->selectedFiles->first(); |
474 | } | 477 | } |
475 | 478 | ||
476 | 479 | ||
477 | void PlayListWidget::setDocument(const QString& fileref) { | 480 | void PlayListWidget::setDocument(const QString& fileref) { |
478 | qDebug(fileref); | 481 | qDebug(fileref); |
479 | fromSetDocument = TRUE; | 482 | fromSetDocument = TRUE; |
480 | QFileInfo fileInfo(fileref); | 483 | QFileInfo fileInfo(fileref); |
481 | if ( !fileInfo.exists() ) { | 484 | if ( !fileInfo.exists() ) { |
482 | QMessageBox::critical( 0, tr( "Invalid File" ), | 485 | QMessageBox::critical( 0, tr( "Invalid File" ), |
483 | tr( "There was a problem in getting the file." ) ); | 486 | tr( "There was a problem in getting the file." ) ); |
484 | return; | 487 | return; |
485 | } | 488 | } |
486 | // qDebug("setDocument "+fileref); | 489 | // qDebug("setDocument "+fileref); |
487 | QString extension = fileInfo.extension(false); | 490 | QString extension = fileInfo.extension(false); |
488 | if( extension.find( "m3u", 0, false) != -1) { //is m3u | 491 | if( extension.find( "m3u", 0, false) != -1) { //is m3u |
489 | readm3u( fileref); | 492 | readm3u( fileref); |
490 | } | 493 | } |
491 | else if( extension.find( "pls", 0, false) != -1 ) { //is pls | 494 | else if( extension.find( "pls", 0, false) != -1 ) { //is pls |
492 | readPls( fileref); | 495 | readPls( fileref); |
493 | } | 496 | } |
494 | else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist | 497 | else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist |
495 | clearList(); | 498 | clearList(); |
496 | DocLnk lnk; | 499 | DocLnk lnk; |
497 | lnk.setName( fileInfo.baseName() ); //sets name | 500 | lnk.setName( fileInfo.baseName() ); //sets name |
498 | lnk.setFile( fileref ); //sets file name | 501 | lnk.setFile( fileref ); //sets file name |
499 | //addToSelection( lnk ); | 502 | //addToSelection( lnk ); |
500 | 503 | ||
501 | loadList( lnk); | 504 | loadList( lnk); |
502 | d->selectedFiles->first(); | 505 | d->selectedFiles->first(); |
503 | } else { | 506 | } else { |
504 | clearList(); | 507 | clearList(); |
505 | DocLnk lnk; | 508 | DocLnk lnk; |
506 | lnk.setName( fileInfo.baseName() ); //sets name | 509 | lnk.setName( fileInfo.baseName() ); //sets name |
507 | lnk.setFile( fileref ); //sets file name | 510 | lnk.setFile( fileref ); //sets file name |
508 | addToSelection( lnk ); | 511 | addToSelection( lnk ); |
509 | // addToSelection( DocLnk( fileref ) ); | 512 | // addToSelection( DocLnk( fileref ) ); |
510 | d->setDocumentUsed = TRUE; | 513 | d->setDocumentUsed = TRUE; |
511 | mediaPlayerState->setPlaying( FALSE ); | 514 | mediaPlayerState->setPlaying( FALSE ); |
512 | qApp->processEvents(); | 515 | qApp->processEvents(); |
513 | mediaPlayerState->setPlaying( TRUE ); | 516 | mediaPlayerState->setPlaying( TRUE ); |
514 | qApp->processEvents(); | 517 | qApp->processEvents(); |
515 | setCaption(tr("OpiePlayer")); | 518 | setCaption(tr("OpiePlayer")); |
516 | } | 519 | } |
517 | } | 520 | } |
518 | 521 | ||
519 | 522 | ||
520 | void PlayListWidget::setActiveWindow() { | 523 | void PlayListWidget::setActiveWindow() { |
521 | qDebug("SETTING active window"); | 524 | qDebug("SETTING active window"); |
522 | 525 | ||
523 | // When we get raised we need to ensure that it switches views | 526 | // When we get raised we need to ensure that it switches views |
524 | char origView = mediaPlayerState->view(); | 527 | char origView = mediaPlayerState->view(); |
525 | mediaPlayerState->setView( 'l' ); // invalidate | 528 | mediaPlayerState->setView( 'l' ); // invalidate |
526 | mediaPlayerState->setView( origView ); // now switch back | 529 | mediaPlayerState->setView( origView ); // now switch back |
527 | } | 530 | } |
528 | 531 | ||
529 | 532 | ||
530 | void PlayListWidget::useSelectedDocument() { | 533 | void PlayListWidget::useSelectedDocument() { |
531 | d->setDocumentUsed = FALSE; | 534 | d->setDocumentUsed = FALSE; |
532 | } | 535 | } |
533 | 536 | ||
534 | 537 | ||
535 | const DocLnk *PlayListWidget::current() { // this is fugly | 538 | const DocLnk *PlayListWidget::current() { // this is fugly |
536 | 539 | ||
537 | // if( fromSetDocument) { | 540 | // if( fromSetDocument) { |
538 | // qDebug("from setDoc"); | 541 | // qDebug("from setDoc"); |
539 | // DocLnkSet files; | 542 | // DocLnkSet files; |
540 | // Global::findDocuments(&files, "video/*;audio/*"); | 543 | // Global::findDocuments(&files, "video/*;audio/*"); |
541 | // QListIterator<DocLnk> dit( files.children() ); | 544 | // QListIterator<DocLnk> dit( files.children() ); |
542 | // for ( ; dit.current(); ++dit ) { | 545 | // for ( ; dit.current(); ++dit ) { |
543 | // if(dit.current()->linkFile() == setDocFileRef) { | 546 | // if(dit.current()->linkFile() == setDocFileRef) { |
544 | // qDebug(setDocFileRef); | 547 | // qDebug(setDocFileRef); |
545 | // return dit; | 548 | // return dit; |
546 | // } | 549 | // } |
547 | // } | 550 | // } |
548 | // } else | 551 | // } else |
549 | 552 | ||
550 | qDebug("current"); | 553 | qDebug("current"); |
551 | 554 | ||
552 | switch (tabWidget->currentPageIndex()) { | 555 | switch (tabWidget->currentPageIndex()) { |
553 | case 0: //playlist | 556 | case 0: //playlist |
554 | { | 557 | { |
555 | qDebug("playlist"); | 558 | qDebug("playlist"); |
556 | if ( mediaPlayerState->playlist() ) { | 559 | if ( mediaPlayerState->playlist() ) { |
557 | return d->selectedFiles->current(); | 560 | return d->selectedFiles->current(); |
558 | } | 561 | } |
559 | else if ( d->setDocumentUsed && d->current ) { | 562 | else if ( d->setDocumentUsed && d->current ) { |
560 | return d->current; | 563 | return d->current; |
561 | } else { | 564 | } else { |
562 | return &(d->files->selectedDocument()); | 565 | return &(d->files->selectedDocument()); |
563 | } | 566 | } |
564 | } | 567 | } |
565 | break; | 568 | break; |
566 | case 1://audio | 569 | case 1://audio |
567 | { | 570 | { |
568 | qDebug("audioView"); | 571 | qDebug("audioView"); |
569 | QListIterator<DocLnk> dit( files.children() ); | 572 | QListIterator<DocLnk> dit( files.children() ); |
570 | for ( ; dit.current(); ++dit ) { | 573 | for ( ; dit.current(); ++dit ) { |
571 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { | 574 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { |
572 | qDebug("here"); | 575 | qDebug("here"); |
573 | insanityBool=TRUE; | 576 | insanityBool=TRUE; |
574 | return dit; | 577 | return dit; |
575 | } | 578 | } |
576 | } | 579 | } |
577 | } | 580 | } |
578 | break; | 581 | break; |
579 | case 2: // video | 582 | case 2: // video |
580 | { | 583 | { |
581 | qDebug("videoView"); | 584 | qDebug("videoView"); |
582 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 585 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
583 | for ( ; Vdit.current(); ++Vdit ) { | 586 | for ( ; Vdit.current(); ++Vdit ) { |
584 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { | 587 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { |
585 | insanityBool=TRUE; | 588 | insanityBool=TRUE; |
586 | return Vdit; | 589 | return Vdit; |
587 | } | 590 | } |
588 | } | 591 | } |
589 | } | 592 | } |
590 | break; | 593 | break; |
591 | }; | 594 | }; |
592 | return 0; | 595 | return 0; |
593 | } | 596 | } |
594 | 597 | ||
595 | bool PlayListWidget::prev() { | 598 | bool PlayListWidget::prev() { |
596 | if ( mediaPlayerState->playlist() ) { | 599 | if ( mediaPlayerState->playlist() ) { |
597 | if ( mediaPlayerState->shuffled() ) { | 600 | if ( mediaPlayerState->shuffled() ) { |
598 | const DocLnk *cur = current(); | 601 | const DocLnk *cur = current(); |
599 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 602 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
600 | for ( int i = 0; i < j; i++ ) { | 603 | for ( int i = 0; i < j; i++ ) { |
601 | if ( !d->selectedFiles->next() ) | 604 | if ( !d->selectedFiles->next() ) |
602 | d->selectedFiles->first(); | 605 | d->selectedFiles->first(); |
603 | } | 606 | } |
604 | if ( cur == current() ) | 607 | if ( cur == current() ) |
605 | if ( !d->selectedFiles->next() ) | 608 | if ( !d->selectedFiles->next() ) |
606 | d->selectedFiles->first(); | 609 | d->selectedFiles->first(); |
607 | return TRUE; | 610 | return TRUE; |
608 | } else { | 611 | } else { |
609 | if ( !d->selectedFiles->prev() ) { | 612 | if ( !d->selectedFiles->prev() ) { |
610 | if ( mediaPlayerState->looping() ) { | 613 | if ( mediaPlayerState->looping() ) { |
611 | return d->selectedFiles->last(); | 614 | return d->selectedFiles->last(); |
612 | } else { | 615 | } else { |
613 | return FALSE; | 616 | return FALSE; |
614 | } | 617 | } |
615 | } | 618 | } |
616 | return TRUE; | 619 | return TRUE; |
617 | } | 620 | } |
618 | } else { | 621 | } else { |
619 | return mediaPlayerState->looping(); | 622 | return mediaPlayerState->looping(); |
620 | } | 623 | } |
621 | } | 624 | } |
622 | 625 | ||
623 | 626 | ||
624 | bool PlayListWidget::next() { | 627 | bool PlayListWidget::next() { |
625 | if ( mediaPlayerState->playlist() ) { | 628 | if ( mediaPlayerState->playlist() ) { |
626 | if ( mediaPlayerState->shuffled() ) { | 629 | if ( mediaPlayerState->shuffled() ) { |
627 | return prev(); | 630 | return prev(); |
628 | } else { | 631 | } else { |
629 | if ( !d->selectedFiles->next() ) { | 632 | if ( !d->selectedFiles->next() ) { |
630 | if ( mediaPlayerState->looping() ) { | 633 | if ( mediaPlayerState->looping() ) { |
631 | return d->selectedFiles->first(); | 634 | return d->selectedFiles->first(); |
632 | } else { | 635 | } else { |
633 | return FALSE; | 636 | return FALSE; |
634 | } | 637 | } |
635 | } | 638 | } |
636 | return TRUE; | 639 | return TRUE; |
637 | } | 640 | } |
638 | } else { | 641 | } else { |
639 | return mediaPlayerState->looping(); | 642 | return mediaPlayerState->looping(); |
640 | } | 643 | } |
641 | } | 644 | } |
642 | 645 | ||
643 | 646 | ||
644 | bool PlayListWidget::first() { | 647 | bool PlayListWidget::first() { |
645 | if ( mediaPlayerState->playlist() ) | 648 | if ( mediaPlayerState->playlist() ) |
646 | return d->selectedFiles->first(); | 649 | return d->selectedFiles->first(); |
647 | else | 650 | else |
648 | return mediaPlayerState->looping(); | 651 | return mediaPlayerState->looping(); |
649 | } | 652 | } |
650 | 653 | ||
651 | 654 | ||
652 | bool PlayListWidget::last() { | 655 | bool PlayListWidget::last() { |
653 | if ( mediaPlayerState->playlist() ) | 656 | if ( mediaPlayerState->playlist() ) |
654 | return d->selectedFiles->last(); | 657 | return d->selectedFiles->last(); |
655 | else | 658 | else |
656 | return mediaPlayerState->looping(); | 659 | return mediaPlayerState->looping(); |
657 | } | 660 | } |
658 | 661 | ||
659 | 662 | ||
660 | void PlayListWidget::saveList() { | 663 | void PlayListWidget::saveList() { |
661 | writem3u(); | 664 | writem3u(); |
662 | } | 665 | } |
663 | 666 | ||
664 | void PlayListWidget::loadList( const DocLnk & lnk) { | 667 | void PlayListWidget::loadList( const DocLnk & lnk) { |
665 | QString name = lnk.name(); | 668 | QString name = lnk.name(); |
666 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); | 669 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); |
667 | 670 | ||
668 | if( name.length()>0) { | 671 | if( name.length()>0) { |
669 | setCaption("OpiePlayer: "+name); | 672 | setCaption("OpiePlayer: "+name); |
670 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); | 673 | // qDebug("<<<<<<<<<<<<load list "+ lnk.file()); |
671 | clearList(); | 674 | clearList(); |
672 | readm3u(lnk.file()); | 675 | readm3u(lnk.file()); |
673 | tabWidget->setCurrentPage(0); | 676 | tabWidget->setCurrentPage(0); |
674 | } | 677 | } |
675 | } | 678 | } |
676 | 679 | ||
677 | void PlayListWidget::setPlaylist( bool shown ) { | 680 | void PlayListWidget::setPlaylist( bool shown ) { |
678 | if ( shown ) | 681 | if ( shown ) |
679 | d->playListFrame->show(); | 682 | d->playListFrame->show(); |
680 | else | 683 | else |
681 | d->playListFrame->hide(); | 684 | d->playListFrame->hide(); |
682 | } | 685 | } |
683 | 686 | ||
684 | void PlayListWidget::setView( char view ) { | 687 | void PlayListWidget::setView( char view ) { |
685 | if ( view == 'l' ) | 688 | if ( view == 'l' ) |
686 | showMaximized(); | 689 | showMaximized(); |
687 | else | 690 | else |
688 | hide(); | 691 | hide(); |
689 | } | 692 | } |
690 | 693 | ||
691 | void PlayListWidget::addSelected() { | 694 | void PlayListWidget::addSelected() { |
692 | qDebug("addSelected"); | 695 | qDebug("addSelected"); |
693 | DocLnk lnk; | 696 | DocLnk lnk; |
694 | QString filename; | 697 | QString filename; |
695 | switch (tabWidget->currentPageIndex()) { | 698 | switch (tabWidget->currentPageIndex()) { |
696 | 699 | ||
697 | case 0: //playlist | 700 | case 0: //playlist |
698 | return; | 701 | return; |
699 | break; | 702 | break; |
700 | case 1: { //audio | 703 | case 1: { //audio |
701 | QListViewItemIterator it( audioView ); | 704 | QListViewItemIterator it( audioView ); |
702 | for ( ; it.current(); ++it ) { | 705 | for ( ; it.current(); ++it ) { |
703 | if ( it.current()->isSelected() ) { | 706 | if ( it.current()->isSelected() ) { |
704 | filename = it.current()->text(3); | 707 | filename = it.current()->text(3); |
705 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 708 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
706 | lnk.setFile( filename ); //sets file name | 709 | lnk.setFile( filename ); //sets file name |
707 | d->selectedFiles->addToSelection( lnk); | 710 | d->selectedFiles->addToSelection( lnk); |
708 | } | 711 | } |
709 | } | 712 | } |
710 | audioView->clearSelection(); | 713 | audioView->clearSelection(); |
711 | // d->selectedFiles->next(); | 714 | // d->selectedFiles->next(); |
712 | } | 715 | } |
713 | break; | 716 | break; |
714 | 717 | ||
715 | case 2: { // video | 718 | case 2: { // video |
716 | QListViewItemIterator it( videoView ); | 719 | QListViewItemIterator it( videoView ); |
717 | for ( ; it.current(); ++it ) { | 720 | for ( ; it.current(); ++it ) { |
718 | if ( it.current()->isSelected() ) { | 721 | if ( it.current()->isSelected() ) { |
719 | 722 | ||
720 | filename = it.current()->text(3); | 723 | filename = it.current()->text(3); |
721 | lnk.setName( QFileInfo(filename).baseName() ); //sets name | 724 | lnk.setName( QFileInfo(filename).baseName() ); //sets name |
722 | lnk.setFile( filename ); //sets file name | 725 | lnk.setFile( filename ); //sets file name |
723 | d->selectedFiles->addToSelection( lnk); | 726 | d->selectedFiles->addToSelection( lnk); |
724 | } | 727 | } |
725 | } | 728 | } |
726 | videoView->clearSelection(); | 729 | videoView->clearSelection(); |
727 | } | 730 | } |
728 | break; | 731 | break; |
729 | }; | 732 | }; |
730 | // tabWidget->setCurrentPage(0); | 733 | // tabWidget->setCurrentPage(0); |
731 | writeCurrentM3u(); | 734 | writeCurrentM3u(); |
732 | 735 | ||
733 | } | 736 | } |
734 | 737 | ||
735 | void PlayListWidget::removeSelected() { | 738 | void PlayListWidget::removeSelected() { |
736 | d->selectedFiles->removeSelected( ); | 739 | d->selectedFiles->removeSelected( ); |
737 | } | 740 | } |
738 | 741 | ||
739 | void PlayListWidget::playIt( QListViewItem *) { | 742 | void PlayListWidget::playIt( QListViewItem *) { |
740 | // d->setDocumentUsed = FALSE; | 743 | // d->setDocumentUsed = FALSE; |
741 | // mediaPlayerState->curPosition =0; | 744 | // mediaPlayerState->curPosition =0; |
742 | qDebug("playIt"); | 745 | qDebug("playIt"); |
743 | mediaPlayerState->setPlaying(FALSE); | 746 | mediaPlayerState->setPlaying(FALSE); |
744 | mediaPlayerState->setPlaying(TRUE); | 747 | mediaPlayerState->setPlaying(TRUE); |
745 | d->selectedFiles->unSelect(); | 748 | d->selectedFiles->unSelect(); |
746 | } | 749 | } |
747 | 750 | ||
748 | void PlayListWidget::addToSelection( QListViewItem *it) { | 751 | void PlayListWidget::addToSelection( QListViewItem *it) { |
749 | d->setDocumentUsed = FALSE; | 752 | d->setDocumentUsed = FALSE; |
750 | 753 | ||
751 | if(it) { | 754 | if(it) { |
752 | switch ( tabWidget->currentPageIndex()) { | 755 | switch ( tabWidget->currentPageIndex()) { |
753 | case 0: //playlist | 756 | case 0: //playlist |
754 | return; | 757 | return; |
755 | break; | 758 | break; |
756 | }; | 759 | }; |
757 | // case 1: { | 760 | // case 1: { |
758 | DocLnk lnk; | 761 | DocLnk lnk; |
759 | QString filename; | 762 | QString filename; |
760 | 763 | ||
761 | filename=it->text(3); | 764 | filename=it->text(3); |
762 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name | 765 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name |
763 | lnk.setFile( filename ); //sets file name | 766 | lnk.setFile( filename ); //sets file name |
764 | d->selectedFiles->addToSelection( lnk); | 767 | d->selectedFiles->addToSelection( lnk); |
765 | 768 | ||
766 | writeCurrentM3u(); | 769 | writeCurrentM3u(); |
767 | // tabWidget->setCurrentPage(0); | 770 | // tabWidget->setCurrentPage(0); |
768 | 771 | ||
769 | } | 772 | } |
770 | } | 773 | } |
771 | 774 | ||
772 | void PlayListWidget::tabChanged(QWidget *) { | 775 | void PlayListWidget::tabChanged(QWidget *) { |
773 | 776 | ||
774 | switch ( tabWidget->currentPageIndex()) { | 777 | switch ( tabWidget->currentPageIndex()) { |
775 | case 0: | 778 | case 0: |
776 | { | 779 | { |
777 | if( !tbDeletePlaylist->isHidden()) | 780 | if( !tbDeletePlaylist->isHidden()) |
778 | tbDeletePlaylist->hide(); | 781 | tbDeletePlaylist->hide(); |
779 | d->tbRemoveFromList->setEnabled(TRUE); | 782 | d->tbRemoveFromList->setEnabled(TRUE); |
780 | d->tbAddToList->setEnabled(FALSE); | 783 | d->tbAddToList->setEnabled(FALSE); |
781 | } | 784 | } |
782 | break; | 785 | break; |
783 | case 1: | 786 | case 1: |
784 | { | 787 | { |
785 | audioView->clear(); | 788 | audioView->clear(); |
786 | populateAudioView(); | 789 | populateAudioView(); |
787 | 790 | ||
788 | if( !tbDeletePlaylist->isHidden()) | 791 | if( !tbDeletePlaylist->isHidden()) |
789 | tbDeletePlaylist->hide(); | 792 | tbDeletePlaylist->hide(); |
790 | d->tbRemoveFromList->setEnabled(FALSE); | 793 | d->tbRemoveFromList->setEnabled(FALSE); |
791 | d->tbAddToList->setEnabled(TRUE); | 794 | d->tbAddToList->setEnabled(TRUE); |
792 | } | 795 | } |
793 | break; | 796 | break; |
794 | case 2: | 797 | case 2: |
795 | { | 798 | { |
796 | videoView->clear(); | 799 | videoView->clear(); |
797 | populateVideoView(); | 800 | populateVideoView(); |
798 | if( !tbDeletePlaylist->isHidden()) | 801 | if( !tbDeletePlaylist->isHidden()) |
799 | tbDeletePlaylist->hide(); | 802 | tbDeletePlaylist->hide(); |
800 | d->tbRemoveFromList->setEnabled(FALSE); | 803 | d->tbRemoveFromList->setEnabled(FALSE); |
801 | d->tbAddToList->setEnabled(TRUE); | 804 | d->tbAddToList->setEnabled(TRUE); |
802 | } | 805 | } |
803 | break; | 806 | break; |
804 | case 3: | 807 | case 3: |
805 | { | 808 | { |
806 | if( tbDeletePlaylist->isHidden()) | 809 | if( tbDeletePlaylist->isHidden()) |
807 | tbDeletePlaylist->show(); | 810 | tbDeletePlaylist->show(); |
808 | playLists->reread(); | 811 | playLists->reread(); |
809 | } | 812 | } |
810 | break; | 813 | break; |
811 | }; | 814 | }; |
812 | } | 815 | } |
813 | 816 | ||
814 | void PlayListWidget::btnPlay(bool b) { | 817 | void PlayListWidget::btnPlay(bool b) { |
815 | qDebug("<<<<<<<<<<<<<<<BtnPlay"); | 818 | qDebug("<<<<<<<<<<<<<<<BtnPlay"); |
816 | // mediaPlayerState->setPlaying(b); | 819 | // mediaPlayerState->setPlaying(b); |
817 | switch ( tabWidget->currentPageIndex()) { | 820 | switch ( tabWidget->currentPageIndex()) { |
818 | case 0: | 821 | case 0: |
819 | { | 822 | { |
820 | qDebug("1"); | 823 | qDebug("1"); |
821 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 | 824 | // if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 |
822 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { | 825 | // if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { |
823 | // QMessageBox::message("Note","You are trying to play\na malformed url."); | 826 | // QMessageBox::message("Note","You are trying to play\na malformed url."); |
824 | // } else { | 827 | // } else { |
825 | mediaPlayerState->setPlaying(b); | 828 | mediaPlayerState->setPlaying(b); |
826 | insanityBool=FALSE; | 829 | insanityBool=FALSE; |
827 | qDebug("insanity"); | 830 | qDebug("insanity"); |
828 | // } | 831 | // } |
829 | } | 832 | } |
830 | break; | 833 | break; |
831 | case 1: | 834 | case 1: |
832 | { | 835 | { |
833 | qDebug("2"); | 836 | qDebug("2"); |
834 | // d->selectedFiles->unSelect(); | 837 | // d->selectedFiles->unSelect(); |
835 | addToSelection( audioView->currentItem() ); | 838 | addToSelection( audioView->currentItem() ); |
836 | mediaPlayerState->setPlaying(true); | 839 | mediaPlayerState->setPlaying(true); |
837 | d->selectedFiles->removeSelected( ); | 840 | d->selectedFiles->removeSelected( ); |
838 | d->selectedFiles->unSelect(); | 841 | d->selectedFiles->unSelect(); |
839 | tabWidget->setCurrentPage(1); | 842 | tabWidget->setCurrentPage(1); |
840 | insanityBool=FALSE; | 843 | insanityBool=FALSE; |
841 | }// audioView->clearSelection(); | 844 | }// audioView->clearSelection(); |
842 | break; | 845 | break; |
843 | case 2: | 846 | case 2: |
844 | { | 847 | { |
845 | qDebug("3"); | 848 | qDebug("3"); |
846 | 849 | ||
847 | addToSelection( videoView->currentItem() ); | 850 | addToSelection( videoView->currentItem() ); |
848 | mediaPlayerState->setPlaying(true); | 851 | mediaPlayerState->setPlaying(true); |
849 | // qApp->processEvents(); | 852 | // qApp->processEvents(); |
850 | d->selectedFiles->removeSelected( ); | 853 | d->selectedFiles->removeSelected( ); |
851 | d->selectedFiles->unSelect(); | 854 | d->selectedFiles->unSelect(); |
852 | tabWidget->setCurrentPage(2); | 855 | tabWidget->setCurrentPage(2); |
853 | insanityBool=FALSE; | 856 | insanityBool=FALSE; |
854 | }// videoView->clearSelection(); | 857 | }// videoView->clearSelection(); |
855 | break; | 858 | break; |
856 | }; | 859 | }; |
857 | 860 | ||
858 | } | 861 | } |
859 | 862 | ||
860 | void PlayListWidget::deletePlaylist() { | 863 | void PlayListWidget::deletePlaylist() { |
861 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 864 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
862 | (tr("You really want to delete\nthis playlist?")), | 865 | (tr("You really want to delete\nthis playlist?")), |
863 | (tr("Yes")), (tr("No")), 0 )){ | 866 | (tr("Yes")), (tr("No")), 0 )){ |
864 | case 0: // Yes clicked, | 867 | case 0: // Yes clicked, |
865 | QFile().remove(playLists->selectedDocument().file()); | 868 | QFile().remove(playLists->selectedDocument().file()); |
866 | QFile().remove(playLists->selectedDocument().linkFile()); | 869 | QFile().remove(playLists->selectedDocument().linkFile()); |
867 | playLists->reread(); | 870 | playLists->reread(); |
868 | break; | 871 | break; |
869 | case 1: // Cancel | 872 | case 1: // Cancel |
870 | break; | 873 | break; |
871 | }; | 874 | }; |
872 | } | 875 | } |
873 | 876 | ||
874 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) | 877 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) |
875 | { | 878 | { |
876 | switch (mouse) { | 879 | switch (mouse) { |
877 | case 1: | 880 | case 1: |
878 | break; | 881 | break; |
879 | case 2:{ | 882 | case 2:{ |
880 | 883 | ||
881 | QPopupMenu m; | 884 | QPopupMenu m; |
882 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 885 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
883 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 886 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
884 | m.insertSeparator(); | 887 | m.insertSeparator(); |
885 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) | 888 | if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) |
886 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 889 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
887 | 890 | ||
888 | m.exec( QCursor::pos() ); | 891 | m.exec( QCursor::pos() ); |
889 | } | 892 | } |
890 | break; | 893 | break; |
891 | }; | 894 | }; |
892 | } | 895 | } |
893 | 896 | ||
894 | void PlayListWidget::playSelected() | 897 | void PlayListWidget::playSelected() |
895 | { | 898 | { |
896 | qDebug("playSelected"); | 899 | qDebug("playSelected"); |
897 | btnPlay( true); | 900 | btnPlay( true); |
898 | // d->selectedFiles->unSelect(); | 901 | // d->selectedFiles->unSelect(); |
899 | } | 902 | } |
900 | 903 | ||
901 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) | 904 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) |
902 | { | 905 | { |
903 | switch (mouse) { | 906 | switch (mouse) { |
904 | case 1: | 907 | case 1: |
905 | 908 | ||
906 | break; | 909 | break; |
907 | case 2:{ | 910 | case 2:{ |
908 | QPopupMenu m; | 911 | QPopupMenu m; |
909 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 912 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
910 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 913 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
911 | // m.insertSeparator(); | 914 | // m.insertSeparator(); |
912 | // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 915 | // m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
913 | m.exec( QCursor::pos() ); | 916 | m.exec( QCursor::pos() ); |
914 | } | 917 | } |
915 | break; | 918 | break; |
916 | }; | 919 | }; |
917 | 920 | ||
918 | } | 921 | } |
919 | 922 | ||
920 | void PlayListWidget::listDelete() { | 923 | void PlayListWidget::listDelete() { |
921 | Config cfg( "OpiePlayer" ); | 924 | Config cfg( "OpiePlayer" ); |
922 | cfg.setGroup("PlayList"); | 925 | cfg.setGroup("PlayList"); |
923 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 926 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
924 | QString file; | 927 | QString file; |
925 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 928 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
926 | switch ( tabWidget->currentPageIndex()) { | 929 | switch ( tabWidget->currentPageIndex()) { |
927 | case 0: | 930 | case 0: |
928 | break; | 931 | break; |
929 | case 1: | 932 | case 1: |
930 | { | 933 | { |
931 | file = audioView->currentItem()->text(0); | 934 | file = audioView->currentItem()->text(0); |
932 | QListIterator<DocLnk> Pdit( files.children() ); | 935 | QListIterator<DocLnk> Pdit( files.children() ); |
933 | for ( ; Pdit.current(); ++Pdit ) { | 936 | for ( ; Pdit.current(); ++Pdit ) { |
934 | if( Pdit.current()->name() == file) { | 937 | if( Pdit.current()->name() == file) { |
935 | LnkProperties prop( Pdit.current() ); | 938 | LnkProperties prop( Pdit.current() ); |
936 | prop.showMaximized(); | 939 | prop.showMaximized(); |
937 | prop.exec(); | 940 | prop.exec(); |
938 | } | 941 | } |
939 | } | 942 | } |
940 | populateAudioView(); | 943 | populateAudioView(); |
941 | } | 944 | } |
942 | break; | 945 | break; |
943 | case 2: | 946 | case 2: |
944 | { | 947 | { |
945 | // file = videoView->selectedItem()->text(0); | 948 | // file = videoView->selectedItem()->text(0); |
946 | // for ( int i = 0; i < noOfFiles; i++ ) { | 949 | // for ( int i = 0; i < noOfFiles; i++ ) { |
947 | // QString entryName; | 950 | // QString entryName; |
948 | // entryName.sprintf( "File%i", i + 1 ); | 951 | // entryName.sprintf( "File%i", i + 1 ); |
949 | // QString linkFile = cfg.readEntry( entryName ); | 952 | // QString linkFile = cfg.readEntry( entryName ); |
950 | // AppLnk lnk( AppLnk(linkFile)); | 953 | // AppLnk lnk( AppLnk(linkFile)); |
951 | // if( lnk.name() == file ) { | 954 | // if( lnk.name() == file ) { |
952 | // LnkProperties prop( &lnk); | 955 | // LnkProperties prop( &lnk); |
953 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 956 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
954 | // prop.showMaximized(); | 957 | // prop.showMaximized(); |
955 | // prop.exec(); | 958 | // prop.exec(); |
956 | // } | 959 | // } |
957 | // } | 960 | // } |
958 | } | 961 | } |
959 | break; | 962 | break; |
960 | }; | 963 | }; |
961 | } | 964 | } |
962 | 965 | ||
963 | void PlayListWidget::scanForAudio() { | 966 | void PlayListWidget::scanForAudio() { |
964 | // qDebug("scan for audio"); | 967 | // qDebug("scan for audio"); |
965 | files.detachChildren(); | 968 | files.detachChildren(); |
966 | QListIterator<DocLnk> sdit( files.children() ); | 969 | QListIterator<DocLnk> sdit( files.children() ); |
967 | for ( ; sdit.current(); ++sdit ) { | 970 | for ( ; sdit.current(); ++sdit ) { |
968 | delete sdit.current(); | 971 | delete sdit.current(); |
969 | } | 972 | } |
970 | Global::findDocuments( &files, audioMimes); | 973 | Global::findDocuments( &files, audioMimes); |
971 | audioScan = true; | 974 | audioScan = true; |
972 | } | 975 | } |
973 | void PlayListWidget::scanForVideo() { | 976 | void PlayListWidget::scanForVideo() { |
974 | // qDebug("scan for video"); | 977 | // qDebug("scan for video"); |
975 | vFiles.detachChildren(); | 978 | vFiles.detachChildren(); |
976 | QListIterator<DocLnk> sdit( vFiles.children() ); | 979 | QListIterator<DocLnk> sdit( vFiles.children() ); |
977 | for ( ; sdit.current(); ++sdit ) { | 980 | for ( ; sdit.current(); ++sdit ) { |
978 | delete sdit.current(); | 981 | delete sdit.current(); |
979 | } | 982 | } |
980 | Global::findDocuments(&vFiles, "video/*"); | 983 | Global::findDocuments(&vFiles, "video/*"); |
981 | videoScan = true; | 984 | videoScan = true; |
982 | } | 985 | } |
983 | 986 | ||
984 | void PlayListWidget::populateAudioView() { | 987 | void PlayListWidget::populateAudioView() { |
985 | 988 | ||
986 | audioView->clear(); | 989 | audioView->clear(); |
987 | StorageInfo storageInfo; | 990 | StorageInfo storageInfo; |
988 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 991 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
989 | if(!audioScan) scanForAudio(); | 992 | if(!audioScan) scanForAudio(); |
990 | 993 | ||
991 | QListIterator<DocLnk> dit( files.children() ); | 994 | QListIterator<DocLnk> dit( files.children() ); |
992 | QListIterator<FileSystem> it ( fs ); | 995 | QListIterator<FileSystem> it ( fs ); |
993 | 996 | ||
994 | QString storage; | 997 | QString storage; |
995 | for ( ; dit.current(); ++dit ) { | 998 | for ( ; dit.current(); ++dit ) { |
996 | for( ; it.current(); ++it ){ | 999 | for( ; it.current(); ++it ){ |
997 | const QString name = (*it)->name(); | 1000 | const QString name = (*it)->name(); |
998 | const QString path = (*it)->path(); | 1001 | const QString path = (*it)->path(); |
999 | if(dit.current()->file().find(path) != -1 ) storage=name; | 1002 | if(dit.current()->file().find(path) != -1 ) storage=name; |
1000 | } | 1003 | } |
1001 | 1004 | ||
1002 | QListViewItem * newItem; | 1005 | QListViewItem * newItem; |
1003 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { | 1006 | if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { |
1004 | long size; | 1007 | long size; |
1005 | if( dit.current()->file().left(4) == "http" ) | 1008 | if( dit.current()->file().left(4) == "http" ) |
1006 | size=0; | 1009 | size=0; |
1007 | else | 1010 | else |
1008 | size = QFile( dit.current()->file() ).size(); | 1011 | size = QFile( dit.current()->file() ).size(); |
1009 | // qDebug(dit.current()->name()); | 1012 | // qDebug(dit.current()->name()); |
1010 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 1013 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
1011 | QString::number(size ), storage, dit.current()->file()); | 1014 | QString::number(size ), storage, dit.current()->file()); |
1012 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); | 1015 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); |
1013 | } | 1016 | } |
1014 | } | 1017 | } |
1015 | 1018 | ||
1016 | } | 1019 | } |
1017 | 1020 | ||
1018 | void PlayListWidget::populateVideoView() { | 1021 | void PlayListWidget::populateVideoView() { |
1019 | videoView->clear(); | 1022 | videoView->clear(); |
1020 | StorageInfo storageInfo; | 1023 | StorageInfo storageInfo; |
1021 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 1024 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
1022 | 1025 | ||
1023 | if(!videoScan ) scanForVideo(); | 1026 | if(!videoScan ) scanForVideo(); |
1024 | 1027 | ||
1025 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 1028 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
1026 | QListIterator<FileSystem> it ( fs ); | 1029 | QListIterator<FileSystem> it ( fs ); |
1027 | videoView->clear(); | 1030 | videoView->clear(); |
1028 | QString storage; | 1031 | QString storage; |
1029 | for ( ; Vdit.current(); ++Vdit ) { | 1032 | for ( ; Vdit.current(); ++Vdit ) { |
1030 | for( ; it.current(); ++it ){ | 1033 | for( ; it.current(); ++it ){ |
1031 | const QString name = (*it)->name(); | 1034 | const QString name = (*it)->name(); |
1032 | const QString path = (*it)->path(); | 1035 | const QString path = (*it)->path(); |
1033 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 1036 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
1034 | } | 1037 | } |
1035 | 1038 | ||
1036 | QListViewItem * newItem; | 1039 | QListViewItem * newItem; |
1037 | if ( QFile( Vdit.current()->file()).exists() ) { | 1040 | if ( QFile( Vdit.current()->file()).exists() ) { |
1038 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 1041 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
1039 | QString::number( QFile( Vdit.current()->file() ).size() ), | 1042 | QString::number( QFile( Vdit.current()->file() ).size() ), |
1040 | storage, Vdit.current()->file()); | 1043 | storage, Vdit.current()->file()); |
1041 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); | 1044 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); |
1042 | } | 1045 | } |
1043 | } | 1046 | } |
1044 | } | 1047 | } |
1045 | 1048 | ||
1046 | void PlayListWidget::openFile() { | 1049 | void PlayListWidget::openFile() { |
1047 | qDebug("<<<<<<<<<OPEN File"); | 1050 | qDebug("<<<<<<<<<OPEN File"); |
1048 | QString filename, name; | 1051 | QString filename, name; |
1049 | InputDialog *fileDlg; | 1052 | InputDialog *fileDlg; |
1050 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 1053 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
1051 | fileDlg->exec(); | 1054 | fileDlg->exec(); |
1052 | if( fileDlg->result() == 1 ) { | 1055 | if( fileDlg->result() == 1 ) { |
1053 | filename = fileDlg->text(); | 1056 | filename = fileDlg->text(); |
1054 | qDebug( "Selected filename is " + filename ); | 1057 | qDebug( "Selected filename is " + filename ); |
1055 | // Om3u *m3uList; | 1058 | // Om3u *m3uList; |
1056 | DocLnk lnk; | 1059 | DocLnk lnk; |
1057 | Config cfg( "OpiePlayer" ); | 1060 | Config cfg( "OpiePlayer" ); |
1058 | cfg.setGroup("PlayList"); | 1061 | cfg.setGroup("PlayList"); |
1059 | 1062 | ||
1060 | if(filename.left(4) == "http") { | 1063 | if(filename.left(4) == "http") { |
1061 | QString m3uFile, m3uFilePath; | 1064 | QString m3uFile, m3uFilePath; |
1062 | if(filename.find(":",8,TRUE) != -1) { //found a port | 1065 | if(filename.find(":",8,TRUE) != -1) { //found a port |
1063 | m3uFile = filename.left( filename.find( ":",8,TRUE)); | 1066 | m3uFile = filename.left( filename.find( ":",8,TRUE)); |
1064 | m3uFile = m3uFile.right( 7); | 1067 | m3uFile = m3uFile.right( 7); |
1065 | } else if(filename.left(4) == "http"){ | 1068 | } else if(filename.left(4) == "http"){ |
1066 | m3uFile=filename; | 1069 | m3uFile=filename; |
1067 | m3uFile = m3uFile.right( m3uFile.length() - 7); | 1070 | m3uFile = m3uFile.right( m3uFile.length() - 7); |
1068 | } else{ | 1071 | } else{ |
1069 | m3uFile=filename; | 1072 | m3uFile=filename; |
1070 | } | 1073 | } |
1071 | 1074 | ||
1072 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); | 1075 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); |
1073 | lnk.setName( filename ); //sets name | 1076 | lnk.setName( filename ); //sets name |
1074 | lnk.setFile( filename ); //sets file name | 1077 | lnk.setFile( filename ); //sets file name |
1075 | lnk.setIcon("opieplayer2/musicfile"); | 1078 | lnk.setIcon("opieplayer2/musicfile"); |
1076 | d->selectedFiles->addToSelection( lnk ); | 1079 | d->selectedFiles->addToSelection( lnk ); |
1077 | writeCurrentM3u(); | 1080 | writeCurrentM3u(); |
1078 | } | 1081 | } |
1079 | else if( filename.right( 3) == "m3u" ) { | 1082 | else if( filename.right( 3) == "m3u" ) { |
1080 | readm3u( filename ); | 1083 | readm3u( filename ); |
1081 | 1084 | ||
1082 | } else if( filename.right(3) == "pls" ) { | 1085 | } else if( filename.right(3) == "pls" ) { |
1083 | readPls( filename ); | 1086 | readPls( filename ); |
1084 | } else { | 1087 | } else { |
1085 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name | 1088 | lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name |
1086 | lnk.setFile( filename ); //sets file name | 1089 | lnk.setFile( filename ); //sets file name |
1087 | d->selectedFiles->addToSelection( lnk); | 1090 | d->selectedFiles->addToSelection( lnk); |
1088 | writeCurrentM3u(); | 1091 | writeCurrentM3u(); |
1089 | } | 1092 | } |
1090 | } | 1093 | } |
1091 | 1094 | ||
1092 | if( fileDlg ) { | 1095 | if( fileDlg ) { |
1093 | delete fileDlg; | 1096 | delete fileDlg; |
1094 | } | 1097 | } |
1095 | } | 1098 | } |
1096 | 1099 | ||
1097 | 1100 | ||
1098 | /* | 1101 | /* |
1099 | reads m3u and shows files/urls to playlist widget */ | 1102 | reads m3u and shows files/urls to playlist widget */ |
1100 | void PlayListWidget::readm3u( const QString &filename ) { | 1103 | void PlayListWidget::readm3u( const QString &filename ) { |
1101 | qDebug( "read m3u filename " + filename ); | 1104 | qDebug( "read m3u filename " + filename ); |
1102 | 1105 | ||
1103 | Om3u *m3uList; | 1106 | Om3u *m3uList; |
1104 | QString s, name; | 1107 | QString s, name; |
1105 | m3uList = new Om3u( filename, IO_ReadOnly ); | 1108 | m3uList = new Om3u( filename, IO_ReadOnly ); |
1106 | m3uList->readM3u(); | 1109 | m3uList->readM3u(); |
1107 | DocLnk lnk; | 1110 | DocLnk lnk; |
1108 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 1111 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
1109 | s = *it; | 1112 | s = *it; |
1110 | // qDebug("reading "+ s); | 1113 | // qDebug("reading "+ s); |
1111 | if(s.left(4)=="http") { | 1114 | if(s.left(4)=="http") { |
1112 | lnk.setName( s ); //sets file name | 1115 | lnk.setName( s ); //sets file name |
1113 | lnk.setIcon("opieplayer2/musicfile"); | 1116 | lnk.setIcon("opieplayer2/musicfile"); |
1114 | if(s.right(4) != '.' || s.right(5) != '.') | 1117 | if(s.right(4) != '.' || s.right(5) != '.') |
1115 | lnk.setFile( s+"/"); //if url with no extension | 1118 | lnk.setFile( s+"/"); //if url with no extension |
1116 | else | 1119 | else |
1117 | lnk.setFile( s ); //sets file name | 1120 | lnk.setFile( s ); //sets file name |
1118 | 1121 | ||
1119 | } else { | 1122 | } else { |
1120 | // if( QFileInfo( s ).exists() ) { | 1123 | // if( QFileInfo( s ).exists() ) { |
1121 | lnk.setName( fullBaseName ( QFileInfo(s))); | 1124 | lnk.setName( fullBaseName ( QFileInfo(s))); |
1122 | // if(s.right(4) == '.') {//if regular file | 1125 | // if(s.right(4) == '.') {//if regular file |
1123 | if(s.left(1) != "/") { | 1126 | if(s.left(1) != "/") { |
1124 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); | 1127 | // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); |
1125 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); | 1128 | lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); |
1126 | lnk.setIcon("SoundPlayer"); | 1129 | lnk.setIcon("SoundPlayer"); |
1127 | } else { | 1130 | } else { |
1128 | // qDebug("set link2 "+s); | 1131 | // qDebug("set link2 "+s); |
1129 | lnk.setFile( s); | 1132 | lnk.setFile( s); |
1130 | lnk.setIcon("SoundPlayer"); | 1133 | lnk.setIcon("SoundPlayer"); |
1131 | } | 1134 | } |
1132 | } | 1135 | } |
1133 | d->selectedFiles->addToSelection( lnk ); | 1136 | d->selectedFiles->addToSelection( lnk ); |
1134 | } | 1137 | } |
1135 | Config config( "OpiePlayer" ); | 1138 | Config config( "OpiePlayer" ); |
1136 | config.setGroup( "PlayList" ); | 1139 | config.setGroup( "PlayList" ); |
1137 | 1140 | ||
1138 | config.writeEntry("CurrentPlaylist",filename); | 1141 | config.writeEntry("CurrentPlaylist",filename); |
1139 | config.write(); | 1142 | config.write(); |
1140 | currentPlayList=filename; | 1143 | currentPlayList=filename; |
1141 | 1144 | ||
1142 | // m3uList->write(); | 1145 | // m3uList->write(); |
1143 | m3uList->close(); | 1146 | m3uList->close(); |
1144 | if(m3uList) delete m3uList; | 1147 | if(m3uList) delete m3uList; |
1145 | 1148 | ||
1146 | d->selectedFiles->setSelectedItem( s); | 1149 | d->selectedFiles->setSelectedItem( s); |
1147 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename))); | 1150 | setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename))); |
1148 | 1151 | ||
1149 | } | 1152 | } |
1150 | 1153 | ||
1151 | /* | 1154 | /* |
1152 | reads pls and adds files/urls to playlist */ | 1155 | reads pls and adds files/urls to playlist */ |
1153 | void PlayListWidget::readPls( const QString &filename ) { | 1156 | void PlayListWidget::readPls( const QString &filename ) { |
1154 | 1157 | ||
1155 | qDebug( "pls filename is " + filename ); | 1158 | qDebug( "pls filename is " + filename ); |
1156 | Om3u *m3uList; | 1159 | Om3u *m3uList; |
1157 | QString s, name; | 1160 | QString s, name; |
1158 | m3uList = new Om3u( filename, IO_ReadOnly ); | 1161 | m3uList = new Om3u( filename, IO_ReadOnly ); |
1159 | m3uList->readPls(); | 1162 | m3uList->readPls(); |
1160 | 1163 | ||
1161 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { | 1164 | for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { |
1162 | s = *it; | 1165 | s = *it; |
1163 | // s.replace( QRegExp( "%20" )," " ); | 1166 | // s.replace( QRegExp( "%20" )," " ); |
1164 | DocLnk lnk( s ); | 1167 | DocLnk lnk( s ); |
1165 | QFileInfo f( s ); | 1168 | QFileInfo f( s ); |
1166 | QString name = fullBaseName ( f); | 1169 | QString name = fullBaseName ( f); |
1167 | 1170 | ||
1168 | if( name.left( 4 ) == "http" ) { | 1171 | if( name.left( 4 ) == "http" ) { |
1169 | name = s.right( s.length() - 7); | 1172 | name = s.right( s.length() - 7); |
1170 | } else { | 1173 | } else { |
1171 | name = s; | 1174 | name = s; |
1172 | } | 1175 | } |
1173 | 1176 | ||
1174 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 1177 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
1175 | 1178 | ||
1176 | lnk.setName( name ); | 1179 | lnk.setName( name ); |
1177 | if( s.at( s.length() - 4) == '.') {// if this is probably a file | 1180 | if( s.at( s.length() - 4) == '.') {// if this is probably a file |
1178 | lnk.setFile( s ); | 1181 | lnk.setFile( s ); |
1179 | } else { //if its a url | 1182 | } else { //if its a url |
1180 | if( name.right( 1 ).find( '/' ) == -1) { | 1183 | if( name.right( 1 ).find( '/' ) == -1) { |
1181 | s += "/"; | 1184 | s += "/"; |
1182 | } | 1185 | } |
1183 | lnk.setFile( s ); | 1186 | lnk.setFile( s ); |
1184 | } | 1187 | } |
1185 | lnk.setType( "audio/x-mpegurl" ); | 1188 | lnk.setType( "audio/x-mpegurl" ); |
1186 | 1189 | ||
1187 | lnk.writeLink(); | 1190 | lnk.writeLink(); |
1188 | d->selectedFiles->addToSelection( lnk ); | 1191 | d->selectedFiles->addToSelection( lnk ); |
1189 | } | 1192 | } |
1190 | 1193 | ||
1191 | m3uList->close(); | 1194 | m3uList->close(); |
1192 | if(m3uList) delete m3uList; | 1195 | if(m3uList) delete m3uList; |
1193 | } | 1196 | } |
1194 | 1197 | ||
1195 | /* | 1198 | /* |
1196 | writes current playlist to current m3u file */ | 1199 | writes current playlist to current m3u file */ |
1197 | void PlayListWidget::writeCurrentM3u() { | 1200 | void PlayListWidget::writeCurrentM3u() { |
1198 | qDebug("writing to current m3u"); | 1201 | qDebug("writing to current m3u"); |
1199 | Config cfg( "OpiePlayer" ); | 1202 | Config cfg( "OpiePlayer" ); |
1200 | cfg.setGroup("PlayList"); | 1203 | cfg.setGroup("PlayList"); |
1201 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 1204 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
1202 | Om3u *m3uList; | 1205 | Om3u *m3uList; |
1203 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); | 1206 | m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); |
1204 | 1207 | ||
1205 | if( d->selectedFiles->first()) { | 1208 | if( d->selectedFiles->first()) { |
1206 | do { | 1209 | do { |
1207 | qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); | 1210 | qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); |
1208 | m3uList->add( d->selectedFiles->current()->file() ); | 1211 | m3uList->add( d->selectedFiles->current()->file() ); |
1209 | } | 1212 | } |
1210 | while ( d->selectedFiles->next() ); | 1213 | while ( d->selectedFiles->next() ); |
1211 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); | 1214 | qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); |
1212 | m3uList->write(); | 1215 | m3uList->write(); |
1213 | m3uList->close(); | 1216 | m3uList->close(); |
1214 | 1217 | ||
1215 | if(m3uList) delete m3uList; | 1218 | if(m3uList) delete m3uList; |
1216 | } | 1219 | } |
1217 | } | 1220 | } |
1218 | 1221 | ||
1219 | /* | 1222 | /* |
1220 | writes current playlist to m3u file */ | 1223 | writes current playlist to m3u file */ |
1221 | void PlayListWidget::writem3u() { | 1224 | void PlayListWidget::writem3u() { |
1222 | InputDialog *fileDlg; | 1225 | InputDialog *fileDlg; |
1223 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); | 1226 | fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); |
1224 | fileDlg->exec(); | 1227 | fileDlg->exec(); |
1225 | QString name, filename, list; | 1228 | QString name, filename, list; |
1226 | Om3u *m3uList; | 1229 | Om3u *m3uList; |
1227 | 1230 | ||
1228 | if( fileDlg->result() == 1 ) { | 1231 | if( fileDlg->result() == 1 ) { |
1229 | name = fileDlg->text(); | 1232 | name = fileDlg->text(); |
1230 | // qDebug( filename ); | 1233 | // qDebug( filename ); |
1231 | if( name.find("/",0,true) != -1) {// assume they specify a file path | 1234 | if( name.find("/",0,true) != -1) {// assume they specify a file path |
1232 | filename = name; | 1235 | filename = name; |
1233 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); | 1236 | name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); |
1234 | } | 1237 | } |
1235 | else //otherwise dump it somewhere noticable | 1238 | else //otherwise dump it somewhere noticable |
1236 | filename = QPEApplication::documentDir() + "/" + name; | 1239 | filename = QPEApplication::documentDir() + "/" + name; |
1237 | 1240 | ||
1238 | if( filename.right( 3 ) != "m3u" ) //needs filename extension | 1241 | if( filename.right( 3 ) != "m3u" ) //needs filename extension |
1239 | filename += ".m3u"; | 1242 | filename += ".m3u"; |
1240 | 1243 | ||
1241 | if( d->selectedFiles->first()) { | 1244 | if( d->selectedFiles->first()) { |
1242 | m3uList = new Om3u(filename, IO_ReadWrite); | 1245 | m3uList = new Om3u(filename, IO_ReadWrite); |
1243 | 1246 | ||
1244 | do { | 1247 | do { |
1245 | m3uList->add( d->selectedFiles->current()->file()); | 1248 | m3uList->add( d->selectedFiles->current()->file()); |
1246 | } | 1249 | } |
1247 | while ( d->selectedFiles->next() ); | 1250 | while ( d->selectedFiles->next() ); |
1248 | // qDebug( list ); | 1251 | // qDebug( list ); |
1249 | m3uList->write(); | 1252 | m3uList->write(); |
1250 | m3uList->close(); | 1253 | m3uList->close(); |
1251 | if(m3uList) delete m3uList; | 1254 | if(m3uList) delete m3uList; |
1252 | 1255 | ||
1253 | if(fileDlg) delete fileDlg; | 1256 | if(fileDlg) delete fileDlg; |
1254 | 1257 | ||
1255 | DocLnk lnk; | 1258 | DocLnk lnk; |
1256 | lnk.setFile( filename); | 1259 | lnk.setFile( filename); |
1257 | lnk.setIcon("opieplayer2/playlist2"); | 1260 | lnk.setIcon("opieplayer2/playlist2"); |
1258 | lnk.setName( name); //sets file name | 1261 | lnk.setName( name); //sets file name |
1259 | 1262 | ||
1260 | // qDebug(filename); | 1263 | // qDebug(filename); |
1261 | Config config( "OpiePlayer" ); | 1264 | Config config( "OpiePlayer" ); |
1262 | config.setGroup( "PlayList" ); | 1265 | config.setGroup( "PlayList" ); |
1263 | 1266 | ||
1264 | config.writeEntry("CurrentPlaylist",filename); | 1267 | config.writeEntry("CurrentPlaylist",filename); |
1265 | currentPlayList=filename; | 1268 | currentPlayList=filename; |
1266 | 1269 | ||
1267 | if(!lnk.writeLink()) { | 1270 | if(!lnk.writeLink()) { |
1268 | qDebug("Writing doclink did not work"); | 1271 | qDebug("Writing doclink did not work"); |
1269 | } | 1272 | } |
1270 | 1273 | ||
1271 | setCaption(tr("OpiePlayer: ") + name); | 1274 | setCaption(tr("OpiePlayer: ") + name); |
1272 | } | 1275 | } |
1273 | } | 1276 | } |
1274 | } | 1277 | } |
1275 | 1278 | ||
1276 | 1279 | ||
1277 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | 1280 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) |
1278 | { | 1281 | { |
1279 | switch ( e->key() ) { | 1282 | switch ( e->key() ) { |
1280 | ////////////////////////////// Zaurus keys | 1283 | ////////////////////////////// Zaurus keys |
1281 | case Key_F9: //activity | 1284 | case Key_F9: //activity |
1282 | // if(audioUI->isHidden()) | 1285 | // if(audioUI->isHidden()) |
1283 | // audioUI->showMaximized(); | 1286 | // audioUI->showMaximized(); |
1284 | break; | 1287 | break; |
1285 | case Key_F10: //contacts | 1288 | case Key_F10: //contacts |
1286 | // if( videoUI->isHidden()) | 1289 | // if( videoUI->isHidden()) |
1287 | // videoUI->showMaximized(); | 1290 | // videoUI->showMaximized(); |
1288 | break; | 1291 | break; |
1289 | case Key_F11: //menu | 1292 | case Key_F11: //menu |
1290 | break; | 1293 | break; |
1291 | case Key_F12: //home | 1294 | case Key_F12: //home |
1292 | // doBlank(); | 1295 | // doBlank(); |
1293 | break; | 1296 | break; |
1294 | case Key_F13: //mail | 1297 | case Key_F13: //mail |
1295 | // doUnblank(); | 1298 | // doUnblank(); |
1296 | break; | 1299 | break; |
1297 | case Key_Q: //add to playlist | 1300 | case Key_Q: //add to playlist |
1298 | qDebug("Add"); | 1301 | qDebug("Add"); |
1299 | addSelected(); | 1302 | addSelected(); |
1300 | break; | 1303 | break; |
1301 | case Key_R: //remove from playlist | 1304 | case Key_R: //remove from playlist |
1302 | removeSelected(); | 1305 | removeSelected(); |
1303 | break; | 1306 | break; |
1304 | // case Key_P: //play | 1307 | // case Key_P: //play |
1305 | // qDebug("Play"); | 1308 | // qDebug("Play"); |
1306 | // playSelected(); | 1309 | // playSelected(); |
1307 | // break; | 1310 | // break; |
1308 | case Key_Space: | 1311 | case Key_Space: |
1309 | qDebug("Play"); | 1312 | qDebug("Play"); |
1310 | // playSelected(); puh | 1313 | // playSelected(); puh |
1311 | break; | 1314 | break; |
1312 | case Key_1: | 1315 | case Key_1: |
1313 | tabWidget->setCurrentPage(0); | 1316 | tabWidget->setCurrentPage(0); |
1314 | break; | 1317 | break; |
1315 | case Key_2: | 1318 | case Key_2: |
1316 | tabWidget->setCurrentPage(1); | 1319 | tabWidget->setCurrentPage(1); |
1317 | break; | 1320 | break; |
1318 | case Key_3: | 1321 | case Key_3: |
1319 | tabWidget->setCurrentPage(2); | 1322 | tabWidget->setCurrentPage(2); |
1320 | break; | 1323 | break; |
1321 | case Key_4: | 1324 | case Key_4: |
1322 | tabWidget->setCurrentPage(3); | 1325 | tabWidget->setCurrentPage(3); |
1323 | break; | 1326 | break; |
1324 | case Key_Down: | 1327 | case Key_Down: |
1325 | if ( !d->selectedFiles->next() ) | 1328 | if ( !d->selectedFiles->next() ) |
1326 | d->selectedFiles->first(); | 1329 | d->selectedFiles->first(); |
1327 | 1330 | ||
1328 | break; | 1331 | break; |
1329 | case Key_Up: | 1332 | case Key_Up: |
1330 | if ( !d->selectedFiles->prev() ) | 1333 | if ( !d->selectedFiles->prev() ) |
1331 | // d->selectedFiles->last(); | 1334 | // d->selectedFiles->last(); |
1332 | 1335 | ||
1333 | break; | 1336 | break; |
1334 | 1337 | ||
1335 | } | 1338 | } |
1336 | } | 1339 | } |
1337 | 1340 | ||
1338 | void PlayListWidget::keyPressEvent( QKeyEvent *) | 1341 | void PlayListWidget::keyPressEvent( QKeyEvent *) |
1339 | { | 1342 | { |
1340 | // qDebug("Key press"); | 1343 | // qDebug("Key press"); |
1341 | // switch ( e->key() ) { | 1344 | // switch ( e->key() ) { |
1342 | // ////////////////////////////// Zaurus keys | 1345 | // ////////////////////////////// Zaurus keys |
1343 | // case Key_A: //add to playlist | 1346 | // case Key_A: //add to playlist |
1344 | // qDebug("Add"); | 1347 | // qDebug("Add"); |
1345 | // addSelected(); | 1348 | // addSelected(); |
1346 | // break; | 1349 | // break; |
1347 | // case Key_R: //remove from playlist | 1350 | // case Key_R: //remove from playlist |
1348 | // removeSelected(); | 1351 | // removeSelected(); |
1349 | // break; | 1352 | // break; |
1350 | // case Key_P: //play | 1353 | // case Key_P: //play |
1351 | // qDebug("Play"); | 1354 | // qDebug("Play"); |
1352 | // playSelected(); | 1355 | // playSelected(); |
1353 | // break; | 1356 | // break; |
1354 | // case Key_Space: | 1357 | // case Key_Space: |
1355 | // qDebug("Play"); | 1358 | // qDebug("Play"); |
1356 | // playSelected(); | 1359 | // playSelected(); |
1357 | // break; | 1360 | // break; |
1358 | // } | 1361 | // } |
1359 | } | 1362 | } |
1360 | 1363 | ||
1361 | void PlayListWidget::doBlank() { | 1364 | void PlayListWidget::doBlank() { |
1362 | qDebug("do blanking"); | 1365 | qDebug("do blanking"); |
1363 | fd=open("/dev/fb0",O_RDWR); | 1366 | fd=open("/dev/fb0",O_RDWR); |
1364 | if (fd != -1) { | 1367 | if (fd != -1) { |
1365 | ioctl(fd,FBIOBLANK,1); | 1368 | ioctl(fd,FBIOBLANK,1); |
1366 | // close(fd); | 1369 | // close(fd); |
1367 | } | 1370 | } |
1368 | } | 1371 | } |
1369 | 1372 | ||
1370 | void PlayListWidget::doUnblank() { | 1373 | void PlayListWidget::doUnblank() { |
1371 | // this crashes opieplayer with a segfault | 1374 | // this crashes opieplayer with a segfault |
1372 | // int fd; | 1375 | // int fd; |
1373 | // fd=open("/dev/fb0",O_RDWR); | 1376 | // fd=open("/dev/fb0",O_RDWR); |
1374 | qDebug("do unblanking"); | 1377 | qDebug("do unblanking"); |
1375 | if (fd != -1) { | 1378 | if (fd != -1) { |
1376 | ioctl(fd,FBIOBLANK,0); | 1379 | ioctl(fd,FBIOBLANK,0); |
1377 | close(fd); | 1380 | close(fd); |
1378 | } | 1381 | } |
1379 | QCopEnvelope h("QPE/System", "setBacklight(int)"); | 1382 | QCopEnvelope h("QPE/System", "setBacklight(int)"); |
1380 | h <<-3;// v[1]; // -3 Force on | 1383 | h <<-3;// v[1]; // -3 Force on |
1381 | } | 1384 | } |
1382 | 1385 | ||
1383 | void PlayListWidget::populateSkinsMenu() { | 1386 | void PlayListWidget::populateSkinsMenu() { |
1384 | int item = 0; | 1387 | int item = 0; |
1385 | defaultSkinIndex = 0; | 1388 | defaultSkinIndex = 0; |
1386 | QString skinName; | 1389 | QString skinName; |
1387 | Config cfg( "OpiePlayer" ); | 1390 | Config cfg( "OpiePlayer" ); |
1388 | cfg.setGroup("Options" ); | 1391 | cfg.setGroup("Options" ); |
1389 | QString skin = cfg.readEntry( "Skin", "default" ); | 1392 | QString skin = cfg.readEntry( "Skin", "default" ); |
1390 | 1393 | ||
1391 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); | 1394 | QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); |
1392 | skinsDir.setFilter( QDir::Dirs ); | 1395 | skinsDir.setFilter( QDir::Dirs ); |
1393 | skinsDir.setSorting(QDir::Name ); | 1396 | skinsDir.setSorting(QDir::Name ); |
1394 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); | 1397 | const QFileInfoList *skinslist = skinsDir.entryInfoList(); |
1395 | QFileInfoListIterator it( *skinslist ); | 1398 | QFileInfoListIterator it( *skinslist ); |
1396 | QFileInfo *fi; | 1399 | QFileInfo *fi; |
1397 | while ( ( fi = it.current() ) ) { | 1400 | while ( ( fi = it.current() ) ) { |
1398 | skinName = fi->fileName(); | 1401 | skinName = fi->fileName(); |
1399 | // qDebug( fi->fileName() ); | 1402 | // qDebug( fi->fileName() ); |
1400 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { | 1403 | if( skinName != "." && skinName != ".." && skinName !="CVS" ) { |
1401 | item = skinsMenu->insertItem( fi->fileName() ) ; | 1404 | item = skinsMenu->insertItem( fi->fileName() ) ; |
1402 | } | 1405 | } |
1403 | if( skinName == "default" ) { | 1406 | if( skinName == "default" ) { |
1404 | defaultSkinIndex = item; | 1407 | defaultSkinIndex = item; |
1405 | } | 1408 | } |
1406 | if( skinName == skin ) { | 1409 | if( skinName == skin ) { |
1407 | skinsMenu->setItemChecked( item, TRUE ); | 1410 | skinsMenu->setItemChecked( item, TRUE ); |
1408 | } | 1411 | } |
1409 | ++it; | 1412 | ++it; |
1410 | } | 1413 | } |
1411 | } | 1414 | } |
1412 | 1415 | ||
1413 | void PlayListWidget::skinsMenuActivated( int item ) { | 1416 | void PlayListWidget::skinsMenuActivated( int item ) { |
1414 | for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { | 1417 | for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { |
1415 | skinsMenu->setItemChecked( i, FALSE ); | 1418 | skinsMenu->setItemChecked( i, FALSE ); |
1416 | } | 1419 | } |
1417 | skinsMenu->setItemChecked( item, TRUE ); | 1420 | skinsMenu->setItemChecked( item, TRUE ); |
1418 | 1421 | ||
1419 | Config cfg( "OpiePlayer" ); | 1422 | Config cfg( "OpiePlayer" ); |
1420 | cfg.setGroup("Options"); | 1423 | cfg.setGroup("Options"); |
1421 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); | 1424 | cfg.writeEntry("Skin", skinsMenu->text( item ) ); |
1422 | } | 1425 | } |
1426 | |||
1427 | void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) { | ||
1428 | qDebug("qcop message "+msg ); | ||
1429 | QDataStream stream ( data, IO_ReadOnly ); | ||
1430 | if ( msg == "play()" ) { //plays current selection | ||
1431 | btnPlay( true); | ||
1432 | } else if ( msg == "stop()" ) { | ||
1433 | mediaPlayerState->setPlaying( false); | ||
1434 | } else if ( msg == "togglePause()" ) { | ||
1435 | mediaPlayerState->togglePaused(); | ||
1436 | } else if ( msg == "next()" ) { //select next in list | ||
1437 | mediaPlayerState->setNext(); | ||
1438 | } else if ( msg == "prev()" ) { //select previous in list | ||
1439 | mediaPlayerState->setPrev(); | ||
1440 | } else if ( msg == "toggleLooping()" ) { //loop or not loop | ||
1441 | mediaPlayerState->toggleLooping(); | ||
1442 | } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled | ||
1443 | mediaPlayerState->toggleShuffled(); | ||
1444 | } else if ( msg == "volUp()" ) { //volume more | ||
1445 | // emit moreClicked(); | ||
1446 | // emit moreReleased(); | ||
1447 | } else if ( msg == "volDown()" ) { //volume less | ||
1448 | // emit lessClicked(); | ||
1449 | // emit lessReleased(); | ||
1450 | } else if ( msg == "play(QString)" ) { //play this now | ||
1451 | QString file; | ||
1452 | stream >> file; | ||
1453 | setDocument( (const QString &) file); | ||
1454 | } else if ( msg == "add(QString)" ) { //add to playlist | ||
1455 | QString file; | ||
1456 | stream >> file; | ||
1457 | QFileInfo fileInfo(file); | ||
1458 | DocLnk lnk; | ||
1459 | lnk.setName( fileInfo.baseName() ); //sets name | ||
1460 | lnk.setFile( file ); //sets file name | ||
1461 | addToSelection( lnk ); | ||
1462 | } else if ( msg == "rem(QString)" ) { //remove from playlist | ||
1463 | QString file; | ||
1464 | stream >> file; | ||
1465 | |||
1466 | } | ||
1467 | |||
1468 | } | ||
diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h index 1118b76..e66bcb9 100644 --- a/core/multimedia/opieplayer/playlistwidget.h +++ b/core/multimedia/opieplayer/playlistwidget.h | |||
@@ -1,133 +1,137 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef PLAY_LIST_WIDGET_H | 20 | #ifndef PLAY_LIST_WIDGET_H |
21 | #define PLAY_LIST_WIDGET_H | 21 | #define PLAY_LIST_WIDGET_H |
22 | 22 | ||
23 | #include <qmainwindow.h> | 23 | #include <qmainwindow.h> |
24 | #include <qpe/applnk.h> | 24 | #include <qpe/applnk.h> |
25 | #include <qtabwidget.h> | 25 | #include <qtabwidget.h> |
26 | #include <qpe/fileselector.h> | 26 | #include <qpe/fileselector.h> |
27 | #include <qpushbutton.h> | 27 | #include <qpushbutton.h> |
28 | 28 | ||
29 | #include <qpe/qcopenvelope_qws.h> | ||
30 | |||
29 | #include "om3u.h" | 31 | #include "om3u.h" |
30 | /* #include <qtimer.h> */ | 32 | /* #include <qtimer.h> */ |
31 | 33 | ||
32 | 34 | ||
33 | class PlayListWidgetPrivate; | 35 | class PlayListWidgetPrivate; |
34 | class Config; | 36 | class Config; |
35 | class QListViewItem; | 37 | class QListViewItem; |
36 | class QListView; | 38 | class QListView; |
37 | class QPoint; | 39 | class QPoint; |
38 | class QAction; | 40 | class QAction; |
39 | class QLabel; | 41 | class QLabel; |
40 | class QPopupMenu; | 42 | class QPopupMenu; |
41 | 43 | ||
42 | class PlayListWidget : public QMainWindow { | 44 | class PlayListWidget : public QMainWindow { |
43 | Q_OBJECT | 45 | Q_OBJECT |
44 | public: | 46 | public: |
45 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); | 47 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); |
46 | ~PlayListWidget(); | 48 | ~PlayListWidget(); |
47 | QTabWidget * tabWidget; | 49 | QTabWidget * tabWidget; |
48 | QAction *fullScreenButton, *scaleButton; | 50 | QAction *fullScreenButton, *scaleButton; |
49 | DocLnkSet files; | 51 | DocLnkSet files; |
50 | DocLnkSet vFiles; | 52 | DocLnkSet vFiles; |
51 | QListView *audioView, *videoView, *playlistView; | 53 | QListView *audioView, *videoView, *playlistView; |
52 | QLabel *libString; | 54 | QLabel *libString; |
53 | bool fromSetDocument; | 55 | bool fromSetDocument; |
54 | bool insanityBool; | 56 | bool insanityBool; |
55 | QString setDocFileRef, currentPlayList; | 57 | QString setDocFileRef, currentPlayList; |
56 | // retrieve the current playlist entry (media file link) | 58 | // retrieve the current playlist entry (media file link) |
57 | const DocLnk *current(); | 59 | const DocLnk *current(); |
58 | void useSelectedDocument(); | 60 | void useSelectedDocument(); |
59 | /* QTimer * menuTimer; */ | 61 | /* QTimer * menuTimer; */ |
60 | FileSelector* playLists; | 62 | FileSelector* playLists; |
61 | QPushButton *tbDeletePlaylist; | 63 | QPushButton *tbDeletePlaylist; |
62 | int fd, selected; | 64 | int fd, selected; |
63 | public slots: | 65 | public slots: |
64 | bool first(); | 66 | bool first(); |
65 | bool last(); | 67 | bool last(); |
66 | bool next(); | 68 | bool next(); |
67 | bool prev(); | 69 | bool prev(); |
68 | /* void setFullScreen(); */ | 70 | /* void setFullScreen(); */ |
69 | /* void setScaled(); */ | 71 | /* void setScaled(); */ |
70 | protected: | 72 | protected: |
73 | QCopChannel * channel; | ||
71 | QPopupMenu *skinsMenu; | 74 | QPopupMenu *skinsMenu; |
72 | /* void contentsMousePressEvent( QMouseEvent * e ); */ | 75 | /* void contentsMousePressEvent( QMouseEvent * e ); */ |
73 | /* void contentsMouseReleaseEvent( QMouseEvent * e ); */ | 76 | /* void contentsMouseReleaseEvent( QMouseEvent * e ); */ |
74 | void keyReleaseEvent( QKeyEvent *e); | 77 | void keyReleaseEvent( QKeyEvent *e); |
75 | void keyPressEvent( QKeyEvent *e); | 78 | void keyPressEvent( QKeyEvent *e); |
76 | private: | 79 | private: |
77 | int defaultSkinIndex; | 80 | int defaultSkinIndex; |
78 | bool audioScan, videoScan; | 81 | bool audioScan, videoScan; |
79 | void doBlank(); | 82 | void doBlank(); |
80 | void doUnblank(); | 83 | void doUnblank(); |
81 | void readm3u(const QString &); | 84 | void readm3u(const QString &); |
82 | void readPls(const QString &); | 85 | void readPls(const QString &); |
83 | 86 | ||
84 | 87 | ||
85 | void initializeStates(); | 88 | void initializeStates(); |
86 | void readConfig( Config& cfg ); | 89 | void readConfig( Config& cfg ); |
87 | void writeConfig( Config& cfg ) const; | 90 | void writeConfig( Config& cfg ) const; |
88 | PlayListWidgetPrivate *d; // Private implementation data | 91 | PlayListWidgetPrivate *d; // Private implementation data |
89 | void populateAudioView(); | 92 | void populateAudioView(); |
90 | void populateVideoView(); | 93 | void populateVideoView(); |
91 | private slots: | 94 | private slots: |
92 | 95 | ||
96 | void qcopReceive(const QCString&, const QByteArray&); | ||
93 | void populateSkinsMenu(); | 97 | void populateSkinsMenu(); |
94 | void skinsMenuActivated(int); | 98 | void skinsMenuActivated(int); |
95 | void writem3u(); | 99 | void writem3u(); |
96 | void writeCurrentM3u(); | 100 | void writeCurrentM3u(); |
97 | void scanForAudio(); | 101 | void scanForAudio(); |
98 | void scanForVideo(); | 102 | void scanForVideo(); |
99 | void openFile(); | 103 | void openFile(); |
100 | void setDocument( const QString& fileref ); | 104 | void setDocument( const QString& fileref ); |
101 | void addToSelection( const DocLnk& ); // Add a media file to the playlist | 105 | void addToSelection( const DocLnk& ); // Add a media file to the playlist |
102 | void addToSelection( QListViewItem* ); // Add a media file to the playlist | 106 | void addToSelection( QListViewItem* ); // Add a media file to the playlist |
103 | void setActiveWindow(); // need to handle this to show the right view | 107 | void setActiveWindow(); // need to handle this to show the right view |
104 | void setPlaylist( bool ); // Show/Hide the playlist | 108 | void setPlaylist( bool ); // Show/Hide the playlist |
105 | void setView( char ); | 109 | void setView( char ); |
106 | void clearList(); | 110 | void clearList(); |
107 | void addAllToList(); | 111 | void addAllToList(); |
108 | void addAllMusicToList(); | 112 | void addAllMusicToList(); |
109 | void addAllVideoToList(); | 113 | void addAllVideoToList(); |
110 | void saveList(); // Save the playlist | 114 | void saveList(); // Save the playlist |
111 | void loadList( const DocLnk &); // Load a playlist | 115 | void loadList( const DocLnk &); // Load a playlist |
112 | void playIt( QListViewItem *); | 116 | void playIt( QListViewItem *); |
113 | 117 | ||
114 | void btnPlay(bool); | 118 | void btnPlay(bool); |
115 | void deletePlaylist(); | 119 | void deletePlaylist(); |
116 | void addSelected(); | 120 | void addSelected(); |
117 | void removeSelected(); | 121 | void removeSelected(); |
118 | void tabChanged(QWidget*); | 122 | void tabChanged(QWidget*); |
119 | void viewPressed( int, QListViewItem *, const QPoint&, int); | 123 | void viewPressed( int, QListViewItem *, const QPoint&, int); |
120 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); | 124 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); |
121 | void playSelected(); | 125 | void playSelected(); |
122 | void listDelete(); | 126 | void listDelete(); |
123 | 127 | ||
124 | protected slots: | 128 | protected slots: |
125 | /* void cancelMenuTimer(); */ | 129 | /* void cancelMenuTimer(); */ |
126 | /* void showFileMenu(); */ | 130 | /* void showFileMenu(); */ |
127 | 131 | ||
128 | 132 | ||
129 | }; | 133 | }; |
130 | 134 | ||
131 | 135 | ||
132 | #endif // PLAY_LIST_WIDGET_H | 136 | #endif // PLAY_LIST_WIDGET_H |
133 | 137 | ||