-rw-r--r-- | noncore/multimedia/opieplayer2/playlistwidget.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp index 27db464..2521906 100644 --- a/noncore/multimedia/opieplayer2/playlistwidget.cpp +++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp | |||
@@ -1,1236 +1,1237 @@ | |||
1 | 1 | ||
2 | #define QTOPIA_INTERNAL_FSLP | 2 | #define QTOPIA_INTERNAL_FSLP |
3 | #include <qpe/qcopenvelope_qws.h> | 3 | #include <qpe/qcopenvelope_qws.h> |
4 | 4 | ||
5 | #include <qpe/qpemenubar.h> | 5 | #include <qpe/qpemenubar.h> |
6 | #include <qpe/qpetoolbar.h> | 6 | #include <qpe/qpetoolbar.h> |
7 | #include <qpe/fileselector.h> | 7 | #include <qpe/fileselector.h> |
8 | #include <qpe/qpeapplication.h> | 8 | #include <qpe/qpeapplication.h> |
9 | #include <qpe/lnkproperties.h> | 9 | #include <qpe/lnkproperties.h> |
10 | #include <qpe/storage.h> | 10 | #include <qpe/storage.h> |
11 | 11 | ||
12 | #include <qpe/applnk.h> | 12 | #include <qpe/applnk.h> |
13 | #include <qpopupmenu.h> | 13 | #include <qpopupmenu.h> |
14 | #include <qpe/config.h> | 14 | #include <qpe/config.h> |
15 | #include <qpe/global.h> | 15 | #include <qpe/global.h> |
16 | #include <qpe/resource.h> | 16 | #include <qpe/resource.h> |
17 | #include <qaction.h> | 17 | #include <qaction.h> |
18 | #include <qcursor.h> | 18 | #include <qcursor.h> |
19 | #include <qimage.h> | 19 | #include <qimage.h> |
20 | #include <qfile.h> | 20 | #include <qfile.h> |
21 | #include <qdir.h> | 21 | #include <qdir.h> |
22 | #include <qlayout.h> | 22 | #include <qlayout.h> |
23 | #include <qlabel.h> | 23 | #include <qlabel.h> |
24 | #include <qlist.h> | 24 | #include <qlist.h> |
25 | #include <qlistbox.h> | 25 | #include <qlistbox.h> |
26 | #include <qmainwindow.h> | 26 | #include <qmainwindow.h> |
27 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
28 | #include <qtoolbutton.h> | 28 | #include <qtoolbutton.h> |
29 | #include <qtabwidget.h> | 29 | #include <qtabwidget.h> |
30 | #include <qlistview.h> | 30 | #include <qlistview.h> |
31 | #include <qpoint.h> | 31 | #include <qpoint.h> |
32 | #include <qlineedit.h> | 32 | #include <qlineedit.h> |
33 | #include <qpushbutton.h> | 33 | #include <qpushbutton.h> |
34 | #include <qregexp.h> | 34 | #include <qregexp.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | 36 | ||
37 | 37 | ||
38 | #include "playlistselection.h" | 38 | #include "playlistselection.h" |
39 | #include "playlistwidget.h" | 39 | #include "playlistwidget.h" |
40 | #include "mediaplayerstate.h" | 40 | #include "mediaplayerstate.h" |
41 | 41 | ||
42 | #include "inputDialog.h" | 42 | #include "inputDialog.h" |
43 | 43 | ||
44 | #include <stdlib.h> | 44 | #include <stdlib.h> |
45 | #include "audiowidget.h" | 45 | #include "audiowidget.h" |
46 | #include "videowidget.h" | 46 | #include "videowidget.h" |
47 | 47 | ||
48 | #include <unistd.h> | 48 | #include <unistd.h> |
49 | #include <sys/file.h> | 49 | #include <sys/file.h> |
50 | #include <sys/ioctl.h> | 50 | #include <sys/ioctl.h> |
51 | #include <sys/soundcard.h> | 51 | #include <sys/soundcard.h> |
52 | 52 | ||
53 | // for setBacklight() | 53 | // for setBacklight() |
54 | #include <linux/fb.h> | 54 | #include <linux/fb.h> |
55 | #include <sys/types.h> | 55 | #include <sys/types.h> |
56 | #include <sys/stat.h> | 56 | #include <sys/stat.h> |
57 | #include <stdlib.h> | 57 | #include <stdlib.h> |
58 | 58 | ||
59 | #define BUTTONS_ON_TOOLBAR | 59 | #define BUTTONS_ON_TOOLBAR |
60 | #define SIDE_BUTTONS | 60 | #define SIDE_BUTTONS |
61 | #define CAN_SAVE_LOAD_PLAYLISTS | 61 | #define CAN_SAVE_LOAD_PLAYLISTS |
62 | 62 | ||
63 | extern MediaPlayerState *mediaPlayerState; | 63 | extern MediaPlayerState *mediaPlayerState; |
64 | 64 | ||
65 | 65 | ||
66 | class PlayListWidgetPrivate { | 66 | class PlayListWidgetPrivate { |
67 | public: | 67 | public: |
68 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | 68 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
69 | QFrame *playListFrame; | 69 | QFrame *playListFrame; |
70 | FileSelector *files; | 70 | FileSelector *files; |
71 | PlayListSelection *selectedFiles; | 71 | PlayListSelection *selectedFiles; |
72 | bool setDocumentUsed; | 72 | bool setDocumentUsed; |
73 | DocLnk *current; | 73 | DocLnk *current; |
74 | }; | 74 | }; |
75 | 75 | ||
76 | 76 | ||
77 | class ToolButton : public QToolButton { | 77 | class ToolButton : public QToolButton { |
78 | public: | 78 | public: |
79 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 79 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
80 | : QToolButton( parent, name ) { | 80 | : QToolButton( parent, name ) { |
81 | setTextLabel( name ); | 81 | setTextLabel( name ); |
82 | setPixmap( Resource::loadPixmap( icon ) ); | 82 | setPixmap( Resource::loadPixmap( icon ) ); |
83 | setAutoRaise( TRUE ); | 83 | setAutoRaise( TRUE ); |
84 | setFocusPolicy( QWidget::NoFocus ); | 84 | setFocusPolicy( QWidget::NoFocus ); |
85 | setToggleButton( t ); | 85 | setToggleButton( t ); |
86 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 86 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
87 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 87 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
88 | } | 88 | } |
89 | }; | 89 | }; |
90 | 90 | ||
91 | 91 | ||
92 | class MenuItem : public QAction { | 92 | class MenuItem : public QAction { |
93 | public: | 93 | public: |
94 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 94 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
95 | : QAction( text, QString::null, 0, 0 ) { | 95 | : QAction( text, QString::null, 0, 0 ) { |
96 | connect( this, SIGNAL( activated() ), handler, slot ); | 96 | connect( this, SIGNAL( activated() ), handler, slot ); |
97 | addTo( parent ); | 97 | addTo( parent ); |
98 | } | 98 | } |
99 | }; | 99 | }; |
100 | 100 | ||
101 | 101 | ||
102 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 102 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
103 | : QMainWindow( parent, name, fl ) { | 103 | : QMainWindow( parent, name, fl ) { |
104 | 104 | ||
105 | d = new PlayListWidgetPrivate; | 105 | d = new PlayListWidgetPrivate; |
106 | d->setDocumentUsed = FALSE; | 106 | d->setDocumentUsed = FALSE; |
107 | d->current = NULL; | 107 | d->current = NULL; |
108 | fromSetDocument = FALSE; | 108 | fromSetDocument = FALSE; |
109 | insanityBool=FALSE; | 109 | insanityBool=FALSE; |
110 | audioScan = FALSE; | 110 | audioScan = FALSE; |
111 | videoScan = FALSE; | 111 | videoScan = FALSE; |
112 | 112 | ||
113 | setBackgroundMode( PaletteButton ); | 113 | setBackgroundMode( PaletteButton ); |
114 | 114 | ||
115 | setCaption( tr("OpiePlayer") ); | 115 | setCaption( tr("OpiePlayer") ); |
116 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); | 116 | setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); |
117 | 117 | ||
118 | setToolBarsMovable( FALSE ); | 118 | setToolBarsMovable( FALSE ); |
119 | 119 | ||
120 | // Create Toolbar | 120 | // Create Toolbar |
121 | QPEToolBar *toolbar = new QPEToolBar( this ); | 121 | QPEToolBar *toolbar = new QPEToolBar( this ); |
122 | toolbar->setHorizontalStretchable( TRUE ); | 122 | toolbar->setHorizontalStretchable( TRUE ); |
123 | 123 | ||
124 | // Create Menubar | 124 | // Create Menubar |
125 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | 125 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); |
126 | menu->setMargin( 0 ); | 126 | menu->setMargin( 0 ); |
127 | 127 | ||
128 | QPEToolBar *bar = new QPEToolBar( this ); | 128 | QPEToolBar *bar = new QPEToolBar( this ); |
129 | bar->setLabel( tr( "Play Operations" ) ); | 129 | bar->setLabel( tr( "Play Operations" ) ); |
130 | 130 | ||
131 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); | 131 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); |
132 | tbDeletePlaylist->setFlat(TRUE); | 132 | tbDeletePlaylist->setFlat(TRUE); |
133 | tbDeletePlaylist->setFixedSize(20,20); | 133 | tbDeletePlaylist->setFixedSize(20,20); |
134 | 134 | ||
135 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", | 135 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", |
136 | this , SLOT(addSelected()) ); | 136 | this , SLOT(addSelected()) ); |
137 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", | 137 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", |
138 | this , SLOT(removeSelected()) ); | 138 | this , SLOT(removeSelected()) ); |
139 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", | 139 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", |
140 | this , SLOT( btnPlay(bool) ), TRUE ); | 140 | this , SLOT( btnPlay(bool) ), TRUE ); |
141 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", | 141 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", |
142 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 142 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); |
143 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", | 143 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", |
144 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 144 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); |
145 | tbDeletePlaylist->hide(); | 145 | tbDeletePlaylist->hide(); |
146 | 146 | ||
147 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 147 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
148 | menu->insertItem( tr( "File" ), pmPlayList ); | 148 | menu->insertItem( tr( "File" ), pmPlayList ); |
149 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 149 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
150 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 150 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
151 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 151 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
152 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 152 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
153 | pmPlayList->insertSeparator(-1); | 153 | pmPlayList->insertSeparator(-1); |
154 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 154 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
155 | new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); | 155 | new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); |
156 | pmPlayList->insertSeparator(-1); | 156 | pmPlayList->insertSeparator(-1); |
157 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); | 157 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); |
158 | pmPlayList->insertSeparator(-1); | 158 | pmPlayList->insertSeparator(-1); |
159 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); | 159 | new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); |
160 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); | 160 | new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); |
161 | 161 | ||
162 | 162 | ||
163 | pmView = new QPopupMenu( this ); | 163 | pmView = new QPopupMenu( this ); |
164 | menu->insertItem( tr( "View" ), pmView ); | 164 | menu->insertItem( tr( "View" ), pmView ); |
165 | pmView->isCheckable(); | 165 | pmView->isCheckable(); |
166 | 166 | ||
167 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), mediaPlayerState, SLOT( toggleFullscreen() ) ); | 167 | pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), mediaPlayerState, SLOT( toggleFullscreen() ) ); |
168 | 168 | ||
169 | Config cfg( "OpiePlayer" ); | 169 | Config cfg( "OpiePlayer" ); |
170 | bool b= cfg.readBoolEntry("FullScreen", 0); | 170 | bool b= cfg.readBoolEntry("FullScreen", 0); |
171 | mediaPlayerState->setFullscreen( b ); | 171 | mediaPlayerState->setFullscreen( b ); |
172 | pmView->setItemChecked( -16, b ); | 172 | pmView->setItemChecked( -16, b ); |
173 | 173 | ||
174 | pmView->insertItem( Resource::loadPixmap("opieplayer/scale") , tr( "Scale"), mediaPlayerState, SLOT(toggleScaled() ) ); | 174 | pmView->insertItem( Resource::loadPixmap("opieplayer/scale") , tr( "Scale"), mediaPlayerState, SLOT(toggleScaled() ) ); |
175 | 175 | ||
176 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 176 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
177 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | 177 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); |
178 | 178 | ||
179 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | 179 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); |
180 | 180 | ||
181 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 181 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
182 | // tabWidget->setTabShape(QTabWidget::Triangular); | 182 | // tabWidget->setTabShape(QTabWidget::Triangular); |
183 | 183 | ||
184 | QWidget *pTab; | 184 | QWidget *pTab; |
185 | pTab = new QWidget( tabWidget, "pTab" ); | 185 | pTab = new QWidget( tabWidget, "pTab" ); |
186 | tabWidget->insertTab( pTab,"Playlist"); | 186 | tabWidget->insertTab( pTab,"Playlist"); |
187 | 187 | ||
188 | 188 | ||
189 | // Add the playlist area | 189 | // Add the playlist area |
190 | 190 | ||
191 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); | 191 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); |
192 | d->playListFrame = vbox3; | 192 | d->playListFrame = vbox3; |
193 | d->playListFrame ->setMinimumSize(235,260); | 193 | d->playListFrame ->setMinimumSize(235,260); |
194 | 194 | ||
195 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); | 195 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); |
196 | 196 | ||
197 | d->selectedFiles = new PlayListSelection( hbox2); | 197 | d->selectedFiles = new PlayListSelection( hbox2); |
198 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | 198 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); |
199 | 199 | ||
200 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); | 200 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); |
201 | 201 | ||
202 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | 202 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch |
203 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 203 | new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
204 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | 204 | new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); |
205 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 205 | new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
206 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 206 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
207 | 207 | ||
208 | QWidget *aTab; | 208 | QWidget *aTab; |
209 | aTab = new QWidget( tabWidget, "aTab" ); | 209 | aTab = new QWidget( tabWidget, "aTab" ); |
210 | audioView = new QListView( aTab, "Audioview" ); | 210 | audioView = new QListView( aTab, "Audioview" ); |
211 | audioView->setMinimumSize(233,260); | 211 | audioView->setMinimumSize(233,260); |
212 | audioView->addColumn( tr("Title"),140); | 212 | audioView->addColumn( tr("Title"),140); |
213 | audioView->addColumn(tr("Size"), -1); | 213 | audioView->addColumn(tr("Size"), -1); |
214 | audioView->addColumn(tr("Media"),-1); | 214 | audioView->addColumn(tr("Media"),-1); |
215 | audioView->setColumnAlignment(1, Qt::AlignRight); | 215 | audioView->setColumnAlignment(1, Qt::AlignRight); |
216 | audioView->setColumnAlignment(2, Qt::AlignRight); | 216 | audioView->setColumnAlignment(2, Qt::AlignRight); |
217 | audioView->setAllColumnsShowFocus(TRUE); | 217 | audioView->setAllColumnsShowFocus(TRUE); |
218 | 218 | ||
219 | audioView->setMultiSelection( TRUE ); | 219 | audioView->setMultiSelection( TRUE ); |
220 | audioView->setSelectionMode( QListView::Extended); | 220 | audioView->setSelectionMode( QListView::Extended); |
221 | 221 | ||
222 | tabWidget->insertTab(aTab,tr("Audio")); | 222 | tabWidget->insertTab(aTab,tr("Audio")); |
223 | 223 | ||
224 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | 224 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); |
225 | 225 | ||
226 | QWidget *vTab; | 226 | QWidget *vTab; |
227 | vTab = new QWidget( tabWidget, "vTab" ); | 227 | vTab = new QWidget( tabWidget, "vTab" ); |
228 | videoView = new QListView( vTab, "Videoview" ); | 228 | videoView = new QListView( vTab, "Videoview" ); |
229 | videoView->setMinimumSize(233,260); | 229 | videoView->setMinimumSize(233,260); |
230 | 230 | ||
231 | videoView->addColumn(tr("Title"),140); | 231 | videoView->addColumn(tr("Title"),140); |
232 | videoView->addColumn(tr("Size"),-1); | 232 | videoView->addColumn(tr("Size"),-1); |
233 | videoView->addColumn(tr("Media"),-1); | 233 | videoView->addColumn(tr("Media"),-1); |
234 | videoView->setColumnAlignment(1, Qt::AlignRight); | 234 | videoView->setColumnAlignment(1, Qt::AlignRight); |
235 | videoView->setColumnAlignment(2, Qt::AlignRight); | 235 | videoView->setColumnAlignment(2, Qt::AlignRight); |
236 | videoView->setAllColumnsShowFocus(TRUE); | 236 | videoView->setAllColumnsShowFocus(TRUE); |
237 | videoView->setMultiSelection( TRUE ); | 237 | videoView->setMultiSelection( TRUE ); |
238 | videoView->setSelectionMode( QListView::Extended); | 238 | videoView->setSelectionMode( QListView::Extended); |
239 | 239 | ||
240 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 240 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
241 | 241 | ||
242 | tabWidget->insertTab( vTab,tr("Video")); | 242 | tabWidget->insertTab( vTab,tr("Video")); |
243 | 243 | ||
244 | //playlists list | 244 | //playlists list |
245 | QWidget *LTab; | 245 | QWidget *LTab; |
246 | LTab = new QWidget( tabWidget, "LTab" ); | 246 | LTab = new QWidget( tabWidget, "LTab" ); |
247 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy | 247 | playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy |
248 | playLists->setMinimumSize(233,260); | 248 | playLists->setMinimumSize(233,260); |
249 | tabWidget->insertTab(LTab,tr("Lists")); | 249 | tabWidget->insertTab(LTab,tr("Lists")); |
250 | 250 | ||
251 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); | 251 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); |
252 | 252 | ||
253 | connect( pmView, SIGNAL( activated(int)), this, SLOT( pmViewActivated(int) ) ); | 253 | connect( pmView, SIGNAL( activated(int)), this, SLOT( pmViewActivated(int) ) ); |
254 | 254 | ||
255 | // connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled() ) ); | 255 | // connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled() ) ); |
256 | 256 | ||
257 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 257 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
258 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); | 258 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); |
259 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 259 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
260 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 260 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
261 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), | 261 | connect( audioView, SIGNAL( returnPressed( QListViewItem *)), |
262 | this,SLOT( playIt( QListViewItem *)) ); | 262 | this,SLOT( playIt( QListViewItem *)) ); |
263 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 263 | connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
264 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 264 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
265 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 265 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
266 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), | 266 | connect( videoView, SIGNAL( returnPressed( QListViewItem *)), |
267 | this,SLOT( playIt( QListViewItem *)) ); | 267 | this,SLOT( playIt( QListViewItem *)) ); |
268 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); | 268 | connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); |
269 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); | 269 | connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); |
270 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); | 270 | connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); |
271 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); | 271 | connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); |
272 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); | 272 | connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); |
273 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); | 273 | connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); |
274 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); | 274 | connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); |
275 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); | 275 | connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); |
276 | 276 | ||
277 | setCentralWidget( vbox5 ); | 277 | setCentralWidget( vbox5 ); |
278 | 278 | ||
279 | readConfig( cfg ); | 279 | readConfig( cfg ); |
280 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 280 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
281 | loadList(DocLnk( currentPlaylist)); | 281 | loadList(DocLnk( currentPlaylist)); |
282 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); | 282 | setCaption(tr("OpiePlayer: ")+ currentPlaylist ); |
283 | 283 | ||
284 | initializeStates(); | 284 | initializeStates(); |
285 | } | 285 | } |
286 | 286 | ||
287 | 287 | ||
288 | PlayListWidget::~PlayListWidget() { | 288 | PlayListWidget::~PlayListWidget() { |
289 | Config cfg( "OpiePlayer" ); | 289 | Config cfg( "OpiePlayer" ); |
290 | writeConfig( cfg ); | 290 | writeConfig( cfg ); |
291 | 291 | ||
292 | if ( d->current ) { | 292 | if ( d->current ) { |
293 | delete d->current; | 293 | delete d->current; |
294 | } | 294 | } |
295 | delete d; | 295 | delete d; |
296 | } | 296 | } |
297 | 297 | ||
298 | 298 | ||
299 | void PlayListWidget::initializeStates() { | 299 | void PlayListWidget::initializeStates() { |
300 | 300 | ||
301 | d->tbPlay->setOn( mediaPlayerState->playing() ); | 301 | d->tbPlay->setOn( mediaPlayerState->playing() ); |
302 | d->tbLoop->setOn( mediaPlayerState->looping() ); | 302 | d->tbLoop->setOn( mediaPlayerState->looping() ); |
303 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); | 303 | d->tbShuffle->setOn( mediaPlayerState->shuffled() ); |
304 | setPlaylist( true); | 304 | setPlaylist( true); |
305 | } | 305 | } |
306 | 306 | ||
307 | 307 | ||
308 | void PlayListWidget::readConfig( Config& cfg ) { | 308 | void PlayListWidget::readConfig( Config& cfg ) { |
309 | cfg.setGroup("PlayList"); | 309 | cfg.setGroup("PlayList"); |
310 | QString currentString = cfg.readEntry("current", "" ); | 310 | QString currentString = cfg.readEntry("current", "" ); |
311 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 311 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
312 | for ( int i = 0; i < noOfFiles; i++ ) { | 312 | for ( int i = 0; i < noOfFiles; i++ ) { |
313 | QString entryName; | 313 | QString entryName; |
314 | entryName.sprintf( "File%i", i + 1 ); | 314 | entryName.sprintf( "File%i", i + 1 ); |
315 | QString linkFile = cfg.readEntry( entryName ); | 315 | QString linkFile = cfg.readEntry( entryName ); |
316 | DocLnk lnk( linkFile ); | 316 | DocLnk lnk( linkFile ); |
317 | if ( lnk.isValid() ) { | 317 | if ( lnk.isValid() ) { |
318 | d->selectedFiles->addToSelection( lnk ); | 318 | d->selectedFiles->addToSelection( lnk ); |
319 | } | 319 | } |
320 | } | 320 | } |
321 | d->selectedFiles->setSelectedItem( currentString); | 321 | d->selectedFiles->setSelectedItem( currentString); |
322 | } | 322 | } |
323 | 323 | ||
324 | 324 | ||
325 | void PlayListWidget::writeConfig( Config& cfg ) const { | 325 | void PlayListWidget::writeConfig( Config& cfg ) const { |
326 | 326 | ||
327 | d->selectedFiles->writeCurrent( cfg); | 327 | d->selectedFiles->writeCurrent( cfg); |
328 | cfg.setGroup("PlayList"); | 328 | cfg.setGroup("PlayList"); |
329 | int noOfFiles = 0; | 329 | int noOfFiles = 0; |
330 | d->selectedFiles->first(); | 330 | d->selectedFiles->first(); |
331 | do { | 331 | do { |
332 | const DocLnk *lnk = d->selectedFiles->current(); | 332 | const DocLnk *lnk = d->selectedFiles->current(); |
333 | if ( lnk ) { | 333 | if ( lnk ) { |
334 | QString entryName; | 334 | QString entryName; |
335 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 335 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
336 | cfg.writeEntry( entryName, lnk->linkFile() ); | 336 | cfg.writeEntry( entryName, lnk->linkFile() ); |
337 | // if this link does exist, add it so we have the file | 337 | // if this link does exist, add it so we have the file |
338 | // next time... | 338 | // next time... |
339 | if ( !QFile::exists( lnk->linkFile() ) ) { | 339 | if ( !QFile::exists( lnk->linkFile() ) ) { |
340 | // the way writing lnks doesn't really check for out | 340 | // the way writing lnks doesn't really check for out |
341 | // of disk space, but check it anyway. | 341 | // of disk space, but check it anyway. |
342 | if ( !lnk->writeLink() ) { | 342 | if ( !lnk->writeLink() ) { |
343 | QMessageBox::critical( 0, tr("Out of space"), | 343 | QMessageBox::critical( 0, tr("Out of space"), |
344 | tr( "There was a problem saving " | 344 | tr( "There was a problem saving " |
345 | "the playlist.\n" | 345 | "the playlist.\n" |
346 | "Your playlist " | 346 | "Your playlist " |
347 | "may be missing some entries\n" | 347 | "may be missing some entries\n" |
348 | "the next time you start it." ) | 348 | "the next time you start it." ) |
349 | ); | 349 | ); |
350 | } | 350 | } |
351 | } | 351 | } |
352 | noOfFiles++; | 352 | noOfFiles++; |
353 | } | 353 | } |
354 | } | 354 | } |
355 | while ( d->selectedFiles->next() ); | 355 | while ( d->selectedFiles->next() ); |
356 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 356 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
357 | } | 357 | } |
358 | 358 | ||
359 | 359 | ||
360 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 360 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
361 | d->setDocumentUsed = FALSE; | 361 | d->setDocumentUsed = FALSE; |
362 | if ( mediaPlayerState->playlist() ) { | 362 | if ( mediaPlayerState->playlist() ) { |
363 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) | 363 | if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) |
364 | d->selectedFiles->addToSelection( lnk ); | 364 | d->selectedFiles->addToSelection( lnk ); |
365 | } | 365 | } |
366 | else | 366 | else |
367 | mediaPlayerState->setPlaying( TRUE ); | 367 | mediaPlayerState->setPlaying( TRUE ); |
368 | } | 368 | } |
369 | 369 | ||
370 | 370 | ||
371 | void PlayListWidget::clearList() { | 371 | void PlayListWidget::clearList() { |
372 | while ( first() ) { | 372 | while ( first() ) { |
373 | d->selectedFiles->removeSelected(); | 373 | d->selectedFiles->removeSelected(); |
374 | } | 374 | } |
375 | } | 375 | } |
376 | 376 | ||
377 | 377 | ||
378 | void PlayListWidget::addAllToList() { | 378 | void PlayListWidget::addAllToList() { |
379 | DocLnkSet filesAll; | 379 | DocLnkSet filesAll; |
380 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 380 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
381 | QListIterator<DocLnk> Adit( filesAll.children() ); | 381 | QListIterator<DocLnk> Adit( filesAll.children() ); |
382 | for ( ; Adit.current(); ++Adit ) { | 382 | for ( ; Adit.current(); ++Adit ) { |
383 | if(QFileInfo(Adit.current()->file()).exists()) { | 383 | if(QFileInfo(Adit.current()->file()).exists()) { |
384 | d->selectedFiles->addToSelection( **Adit ); | 384 | d->selectedFiles->addToSelection( **Adit ); |
385 | } | 385 | } |
386 | } | 386 | } |
387 | } | 387 | } |
388 | 388 | ||
389 | 389 | ||
390 | void PlayListWidget::addAllMusicToList() { | 390 | void PlayListWidget::addAllMusicToList() { |
391 | QListIterator<DocLnk> dit( files.children() ); | 391 | QListIterator<DocLnk> dit( files.children() ); |
392 | for ( ; dit.current(); ++dit ) { | 392 | for ( ; dit.current(); ++dit ) { |
393 | if(QFileInfo(dit.current()->file()).exists()) { | 393 | if(QFileInfo(dit.current()->file()).exists()) { |
394 | d->selectedFiles->addToSelection( **dit ); | 394 | d->selectedFiles->addToSelection( **dit ); |
395 | } | 395 | } |
396 | } | 396 | } |
397 | } | 397 | } |
398 | 398 | ||
399 | 399 | ||
400 | void PlayListWidget::addAllVideoToList() { | 400 | void PlayListWidget::addAllVideoToList() { |
401 | QListIterator<DocLnk> dit( vFiles.children() ); | 401 | QListIterator<DocLnk> dit( vFiles.children() ); |
402 | for ( ; dit.current(); ++dit ) | 402 | for ( ; dit.current(); ++dit ) |
403 | if(QFileInfo( dit.current()->file()).exists()) | 403 | if(QFileInfo( dit.current()->file()).exists()) |
404 | d->selectedFiles->addToSelection( **dit ); | 404 | d->selectedFiles->addToSelection( **dit ); |
405 | } | 405 | } |
406 | 406 | ||
407 | 407 | ||
408 | void PlayListWidget::setDocument(const QString& fileref) { | 408 | void PlayListWidget::setDocument(const QString& fileref) { |
409 | qDebug(fileref); | 409 | qDebug(fileref); |
410 | fromSetDocument = TRUE; | 410 | fromSetDocument = TRUE; |
411 | if ( fileref.isNull() ) { | 411 | if ( fileref.isNull() ) { |
412 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 412 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
413 | return; | 413 | return; |
414 | } | 414 | } |
415 | 415 | ||
416 | if(fileref.find("m3u",0,TRUE) != -1) { //is m3u | 416 | if(fileref.find("m3u",0,TRUE) != -1) { //is m3u |
417 | readm3u( fileref); | 417 | readm3u( fileref); |
418 | } else if(fileref.find("pls",0,TRUE) != -1) { //is pls | 418 | } else if(fileref.find("pls",0,TRUE) != -1) { //is pls |
419 | readPls( fileref); | 419 | readPls( fileref); |
420 | } else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist | 420 | } else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist |
421 | clearList(); | 421 | clearList(); |
422 | loadList(DocLnk(fileref)); | 422 | loadList(DocLnk(fileref)); |
423 | d->selectedFiles->first(); | 423 | d->selectedFiles->first(); |
424 | } else { | 424 | } else { |
425 | clearList(); | 425 | clearList(); |
426 | addToSelection( DocLnk( fileref ) ); | 426 | addToSelection( DocLnk( fileref ) ); |
427 | d->setDocumentUsed = TRUE; | 427 | d->setDocumentUsed = TRUE; |
428 | mediaPlayerState->setPlaying( FALSE ); | 428 | mediaPlayerState->setPlaying( FALSE ); |
429 | qApp->processEvents(); | 429 | qApp->processEvents(); |
430 | mediaPlayerState->setPlaying( TRUE ); | 430 | mediaPlayerState->setPlaying( TRUE ); |
431 | qApp->processEvents(); | 431 | qApp->processEvents(); |
432 | setCaption(tr("OpiePlayer")); | 432 | setCaption(tr("OpiePlayer")); |
433 | } | 433 | } |
434 | } | 434 | } |
435 | 435 | ||
436 | 436 | ||
437 | void PlayListWidget::setActiveWindow() { | 437 | void PlayListWidget::setActiveWindow() { |
438 | qDebug("SETTING active window"); | 438 | qDebug("SETTING active window"); |
439 | // When we get raised we need to ensure that it switches views | 439 | // When we get raised we need to ensure that it switches views |
440 | char origView = mediaPlayerState->view(); | 440 | char origView = mediaPlayerState->view(); |
441 | mediaPlayerState->setView( 'l' ); // invalidate | 441 | mediaPlayerState->setView( 'l' ); // invalidate |
442 | mediaPlayerState->setView( origView ); // now switch back | 442 | mediaPlayerState->setView( origView ); // now switch back |
443 | } | 443 | } |
444 | 444 | ||
445 | 445 | ||
446 | void PlayListWidget::useSelectedDocument() { | 446 | void PlayListWidget::useSelectedDocument() { |
447 | d->setDocumentUsed = FALSE; | 447 | d->setDocumentUsed = FALSE; |
448 | } | 448 | } |
449 | 449 | ||
450 | 450 | ||
451 | const DocLnk *PlayListWidget::current() { // this is fugly | 451 | const DocLnk *PlayListWidget::current() { // this is fugly |
452 | 452 | ||
453 | switch (tabWidget->currentPageIndex()) { | 453 | switch (tabWidget->currentPageIndex()) { |
454 | case 0: //playlist | 454 | case 0: //playlist |
455 | { | 455 | { |
456 | qDebug("playlist"); | 456 | qDebug("playlist"); |
457 | if ( mediaPlayerState->playlist() ) { | 457 | if ( mediaPlayerState->playlist() ) { |
458 | return d->selectedFiles->current(); | 458 | return d->selectedFiles->current(); |
459 | } else if ( d->setDocumentUsed && d->current ) { | 459 | } else if ( d->setDocumentUsed && d->current ) { |
460 | return d->current; | 460 | return d->current; |
461 | } else { | 461 | } else { |
462 | return d->files->selected(); | 462 | return d->files->selected(); |
463 | } | 463 | } |
464 | } | 464 | } |
465 | break; | 465 | break; |
466 | case 1://audio | 466 | case 1://audio |
467 | { | 467 | { |
468 | qDebug("audioView"); | 468 | qDebug("audioView"); |
469 | QListIterator<DocLnk> dit( files.children() ); | 469 | QListIterator<DocLnk> dit( files.children() ); |
470 | for ( ; dit.current(); ++dit ) { | 470 | for ( ; dit.current(); ++dit ) { |
471 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { | 471 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { |
472 | qDebug("here"); | 472 | qDebug("here"); |
473 | insanityBool=TRUE; | 473 | insanityBool=TRUE; |
474 | return dit; | 474 | return dit; |
475 | } | 475 | } |
476 | } | 476 | } |
477 | } | 477 | } |
478 | break; | 478 | break; |
479 | case 2: // video | 479 | case 2: // video |
480 | { | 480 | { |
481 | qDebug("videoView"); | 481 | qDebug("videoView"); |
482 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 482 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
483 | for ( ; Vdit.current(); ++Vdit ) { | 483 | for ( ; Vdit.current(); ++Vdit ) { |
484 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { | 484 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { |
485 | insanityBool=TRUE; | 485 | insanityBool=TRUE; |
486 | return Vdit; | 486 | return Vdit; |
487 | } | 487 | } |
488 | } | 488 | } |
489 | } | 489 | } |
490 | break; | 490 | break; |
491 | }; | 491 | }; |
492 | return 0; | 492 | return 0; |
493 | } | 493 | } |
494 | 494 | ||
495 | bool PlayListWidget::prev() { | 495 | bool PlayListWidget::prev() { |
496 | if ( mediaPlayerState->playlist() ) { | 496 | if ( mediaPlayerState->playlist() ) { |
497 | if ( mediaPlayerState->shuffled() ) { | 497 | if ( mediaPlayerState->shuffled() ) { |
498 | const DocLnk *cur = current(); | 498 | const DocLnk *cur = current(); |
499 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 499 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
500 | for ( int i = 0; i < j; i++ ) { | 500 | for ( int i = 0; i < j; i++ ) { |
501 | if ( !d->selectedFiles->next() ) | 501 | if ( !d->selectedFiles->next() ) |
502 | d->selectedFiles->first(); | 502 | d->selectedFiles->first(); |
503 | } | 503 | } |
504 | if ( cur == current() ) | 504 | if ( cur == current() ) |
505 | if ( !d->selectedFiles->next() ) | 505 | if ( !d->selectedFiles->next() ) |
506 | d->selectedFiles->first(); | 506 | d->selectedFiles->first(); |
507 | return TRUE; | 507 | return TRUE; |
508 | } else { | 508 | } else { |
509 | if ( !d->selectedFiles->prev() ) { | 509 | if ( !d->selectedFiles->prev() ) { |
510 | if ( mediaPlayerState->looping() ) { | 510 | if ( mediaPlayerState->looping() ) { |
511 | return d->selectedFiles->last(); | 511 | return d->selectedFiles->last(); |
512 | } else { | 512 | } else { |
513 | return FALSE; | 513 | return FALSE; |
514 | } | 514 | } |
515 | } | 515 | } |
516 | return TRUE; | 516 | return TRUE; |
517 | } | 517 | } |
518 | } else { | 518 | } else { |
519 | return mediaPlayerState->looping(); | 519 | return mediaPlayerState->looping(); |
520 | } | 520 | } |
521 | } | 521 | } |
522 | 522 | ||
523 | 523 | ||
524 | bool PlayListWidget::next() { | 524 | bool PlayListWidget::next() { |
525 | if ( mediaPlayerState->playlist() ) { | 525 | if ( mediaPlayerState->playlist() ) { |
526 | if ( mediaPlayerState->shuffled() ) { | 526 | if ( mediaPlayerState->shuffled() ) { |
527 | return prev(); | 527 | return prev(); |
528 | } else { | 528 | } else { |
529 | if ( !d->selectedFiles->next() ) { | 529 | if ( !d->selectedFiles->next() ) { |
530 | if ( mediaPlayerState->looping() ) { | 530 | if ( mediaPlayerState->looping() ) { |
531 | return d->selectedFiles->first(); | 531 | return d->selectedFiles->first(); |
532 | } else { | 532 | } else { |
533 | return FALSE; | 533 | return FALSE; |
534 | } | 534 | } |
535 | } | 535 | } |
536 | return TRUE; | 536 | return TRUE; |
537 | } | 537 | } |
538 | } else { | 538 | } else { |
539 | return mediaPlayerState->looping(); | 539 | return mediaPlayerState->looping(); |
540 | } | 540 | } |
541 | } | 541 | } |
542 | 542 | ||
543 | 543 | ||
544 | bool PlayListWidget::first() { | 544 | bool PlayListWidget::first() { |
545 | if ( mediaPlayerState->playlist() ) | 545 | if ( mediaPlayerState->playlist() ) |
546 | return d->selectedFiles->first(); | 546 | return d->selectedFiles->first(); |
547 | else | 547 | else |
548 | return mediaPlayerState->looping(); | 548 | return mediaPlayerState->looping(); |
549 | } | 549 | } |
550 | 550 | ||
551 | 551 | ||
552 | bool PlayListWidget::last() { | 552 | bool PlayListWidget::last() { |
553 | if ( mediaPlayerState->playlist() ) | 553 | if ( mediaPlayerState->playlist() ) |
554 | return d->selectedFiles->last(); | 554 | return d->selectedFiles->last(); |
555 | else | 555 | else |
556 | return mediaPlayerState->looping(); | 556 | return mediaPlayerState->looping(); |
557 | } | 557 | } |
558 | 558 | ||
559 | 559 | ||
560 | void PlayListWidget::saveList() { | 560 | void PlayListWidget::saveList() { |
561 | 561 | ||
562 | QString filename; | 562 | QString filename; |
563 | InputDialog *fileDlg; | 563 | InputDialog *fileDlg; |
564 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); | 564 | fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); |
565 | fileDlg->exec(); | 565 | fileDlg->exec(); |
566 | if( fileDlg->result() == 1 ) { | 566 | if( fileDlg->result() == 1 ) { |
567 | if ( d->current ) | 567 | if ( d->current ) |
568 | delete d->current; | 568 | delete d->current; |
569 | filename = fileDlg->LineEdit1->text();//+".playlist"; | 569 | filename = fileDlg->LineEdit1->text();//+".playlist"; |
570 | // qDebug("saving playlist "+filename+".playlist"); | 570 | // qDebug("saving playlist "+filename+".playlist"); |
571 | Config cfg( filename +".playlist"); | 571 | Config cfg( filename +".playlist"); |
572 | writeConfig( cfg ); | 572 | writeConfig( cfg ); |
573 | 573 | ||
574 | DocLnk lnk; | 574 | DocLnk lnk; |
575 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property | 575 | lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property |
576 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D | 576 | lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D |
577 | lnk.setIcon("opieplayer/playlist2"); | 577 | lnk.setIcon("opieplayer/playlist2"); |
578 | lnk.setName( filename); //sets file name | 578 | lnk.setName( filename); //sets file name |
579 | // qDebug(filename); | 579 | // qDebug(filename); |
580 | if(!lnk.writeLink()) { | 580 | if(!lnk.writeLink()) { |
581 | qDebug("Writing doclink did not work"); | 581 | qDebug("Writing doclink did not work"); |
582 | } | 582 | } |
583 | } | 583 | } |
584 | Config config( "OpiePlayer" ); | 584 | Config config( "OpiePlayer" ); |
585 | config.writeEntry("CurrentPlaylist",filename); | 585 | config.writeEntry("CurrentPlaylist",filename); |
586 | setCaption(tr("OpiePlayer: ")+filename); | 586 | setCaption(tr("OpiePlayer: ")+filename); |
587 | d->selectedFiles->first(); | 587 | d->selectedFiles->first(); |
588 | if(fileDlg) { | 588 | if(fileDlg) { |
589 | delete fileDlg; | 589 | delete fileDlg; |
590 | } | 590 | } |
591 | } | 591 | } |
592 | 592 | ||
593 | void PlayListWidget::loadList( const DocLnk & lnk) { | 593 | void PlayListWidget::loadList( const DocLnk & lnk) { |
594 | QString name= lnk.name(); | 594 | QString name= lnk.name(); |
595 | // qDebug("currentList is "+name); | 595 | // qDebug("currentList is "+name); |
596 | if( name.length()>1) { | 596 | if( name.length()>1) { |
597 | setCaption("OpiePlayer: "+name); | 597 | setCaption("OpiePlayer: "+name); |
598 | // qDebug("load list "+ name+".playlist"); | 598 | // qDebug("load list "+ name+".playlist"); |
599 | clearList(); | 599 | clearList(); |
600 | Config cfg( name+".playlist"); | 600 | Config cfg( name+".playlist"); |
601 | readConfig(cfg); | 601 | readConfig(cfg); |
602 | 602 | ||
603 | tabWidget->setCurrentPage(0); | 603 | tabWidget->setCurrentPage(0); |
604 | 604 | ||
605 | Config config( "OpiePlayer" ); | 605 | Config config( "OpiePlayer" ); |
606 | config.writeEntry("CurrentPlaylist", name); | 606 | config.writeEntry("CurrentPlaylist", name); |
607 | // d->selectedFiles->first(); | 607 | // d->selectedFiles->first(); |
608 | } | 608 | } |
609 | 609 | ||
610 | } | 610 | } |
611 | 611 | ||
612 | void PlayListWidget::setPlaylist( bool shown ) { | 612 | void PlayListWidget::setPlaylist( bool shown ) { |
613 | if ( shown ) { | 613 | if ( shown ) { |
614 | d->playListFrame->show(); | 614 | d->playListFrame->show(); |
615 | } else { | 615 | } else { |
616 | d->playListFrame->hide(); | 616 | d->playListFrame->hide(); |
617 | } | 617 | } |
618 | } | 618 | } |
619 | 619 | ||
620 | void PlayListWidget::setView( char view ) { | 620 | void PlayListWidget::setView( char view ) { |
621 | if ( view == 'l' ) | 621 | if ( view == 'l' ) |
622 | showMaximized(); | 622 | showMaximized(); |
623 | else | 623 | else |
624 | hide(); | 624 | hide(); |
625 | } | 625 | } |
626 | 626 | ||
627 | void PlayListWidget::addSelected() { | 627 | void PlayListWidget::addSelected() { |
628 | 628 | ||
629 | Config cfg( "OpiePlayer" ); | 629 | Config cfg( "OpiePlayer" ); |
630 | cfg.setGroup("PlayList"); | 630 | cfg.setGroup("PlayList"); |
631 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 631 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
632 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 632 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
633 | 633 | ||
634 | switch (tabWidget->currentPageIndex()) { | 634 | switch (tabWidget->currentPageIndex()) { |
635 | case 0: //playlist | 635 | case 0: //playlist |
636 | break; | 636 | break; |
637 | case 1: { //audio | 637 | case 1: { //audio |
638 | QListViewItemIterator it( audioView ); | 638 | QListViewItemIterator it( audioView ); |
639 | // iterate through all items of the listview | 639 | // iterate through all items of the listview |
640 | for ( ; it.current(); ++it ) { | 640 | for ( ; it.current(); ++it ) { |
641 | if ( it.current()->isSelected() ) { | 641 | if ( it.current()->isSelected() ) { |
642 | QListIterator<DocLnk> dit( files.children() ); | 642 | QListIterator<DocLnk> dit( files.children() ); |
643 | for ( ; dit.current(); ++dit ) { | 643 | for ( ; dit.current(); ++dit ) { |
644 | if( dit.current()->name() == it.current()->text(0) ) { | 644 | if( dit.current()->name() == it.current()->text(0) ) { |
645 | d->selectedFiles->addToSelection( **dit ); | 645 | d->selectedFiles->addToSelection( **dit ); |
646 | } | 646 | } |
647 | } | 647 | } |
648 | audioView->setSelected( it.current(),FALSE); | 648 | audioView->setSelected( it.current(),FALSE); |
649 | } | 649 | } |
650 | } | 650 | } |
651 | tabWidget->setCurrentPage(0); | 651 | tabWidget->setCurrentPage(0); |
652 | } | 652 | } |
653 | break; | 653 | break; |
654 | case 2: { // video | 654 | case 2: { // video |
655 | QListViewItemIterator it( videoView ); | 655 | QListViewItemIterator it( videoView ); |
656 | // iterate through all items of the listview | 656 | // iterate through all items of the listview |
657 | for ( ; it.current(); ++it ) { | 657 | for ( ; it.current(); ++it ) { |
658 | if ( it.current()->isSelected() ) { | 658 | if ( it.current()->isSelected() ) { |
659 | QListIterator<DocLnk> dit( vFiles.children() ); | 659 | QListIterator<DocLnk> dit( vFiles.children() ); |
660 | for ( ; dit.current(); ++dit ) { | 660 | for ( ; dit.current(); ++dit ) { |
661 | if( dit.current()->name() == it.current()->text(0) ) { | 661 | if( dit.current()->name() == it.current()->text(0) ) { |
662 | d->selectedFiles->addToSelection( **dit ); | 662 | d->selectedFiles->addToSelection( **dit ); |
663 | } | 663 | } |
664 | } | 664 | } |
665 | videoView->setSelected( it.current(),FALSE); | 665 | videoView->setSelected( it.current(),FALSE); |
666 | } | 666 | } |
667 | } | 667 | } |
668 | tabWidget->setCurrentPage(0); | 668 | tabWidget->setCurrentPage(0); |
669 | } | 669 | } |
670 | break; | 670 | break; |
671 | }; | 671 | }; |
672 | } | 672 | } |
673 | 673 | ||
674 | void PlayListWidget::removeSelected() { | 674 | void PlayListWidget::removeSelected() { |
675 | d->selectedFiles->removeSelected( ); | 675 | d->selectedFiles->removeSelected( ); |
676 | } | 676 | } |
677 | 677 | ||
678 | void PlayListWidget::playIt( QListViewItem *it) { | 678 | void PlayListWidget::playIt( QListViewItem *it) { |
679 | if(it==NULL) return; | ||
679 | qDebug("playIt"); | 680 | qDebug("playIt"); |
680 | mediaPlayerState->setPlaying(FALSE); | 681 | mediaPlayerState->setPlaying(FALSE); |
681 | mediaPlayerState->setPlaying(TRUE); | 682 | mediaPlayerState->setPlaying(TRUE); |
682 | d->selectedFiles->unSelect(); | 683 | d->selectedFiles->unSelect(); |
683 | } | 684 | } |
684 | 685 | ||
685 | void PlayListWidget::addToSelection( QListViewItem *it) { | 686 | void PlayListWidget::addToSelection( QListViewItem *it) { |
686 | d->setDocumentUsed = FALSE; | 687 | d->setDocumentUsed = FALSE; |
687 | 688 | ||
688 | if(it) { | 689 | if(it) { |
689 | switch (tabWidget->currentPageIndex()) { | 690 | switch (tabWidget->currentPageIndex()) { |
690 | case 1: { | 691 | case 1: { |
691 | QListIterator<DocLnk> dit( files.children() ); | 692 | QListIterator<DocLnk> dit( files.children() ); |
692 | for ( ; dit.current(); ++dit ) { | 693 | for ( ; dit.current(); ++dit ) { |
693 | if( dit.current()->name() == it->text(0)) { | 694 | if( dit.current()->name() == it->text(0)) { |
694 | d->selectedFiles->addToSelection( **dit ); | 695 | d->selectedFiles->addToSelection( **dit ); |
695 | } | 696 | } |
696 | } | 697 | } |
697 | } | 698 | } |
698 | break; | 699 | break; |
699 | case 2: { | 700 | case 2: { |
700 | QListIterator<DocLnk> dit( vFiles.children() ); | 701 | QListIterator<DocLnk> dit( vFiles.children() ); |
701 | for ( ; dit.current(); ++dit ) { | 702 | for ( ; dit.current(); ++dit ) { |
702 | if( dit.current()->name() == it->text(0)) { | 703 | if( dit.current()->name() == it->text(0)) { |
703 | d->selectedFiles->addToSelection( **dit ); | 704 | d->selectedFiles->addToSelection( **dit ); |
704 | } | 705 | } |
705 | } | 706 | } |
706 | } | 707 | } |
707 | break; | 708 | break; |
708 | case 0: | 709 | case 0: |
709 | break; | 710 | break; |
710 | }; | 711 | }; |
711 | tabWidget->setCurrentPage(0); | 712 | tabWidget->setCurrentPage(0); |
712 | } | 713 | } |
713 | } | 714 | } |
714 | 715 | ||
715 | void PlayListWidget::tabChanged(QWidget *widg) { | 716 | void PlayListWidget::tabChanged(QWidget *) { |
716 | 717 | ||
717 | switch ( tabWidget->currentPageIndex()) { | 718 | switch ( tabWidget->currentPageIndex()) { |
718 | case 0: | 719 | case 0: |
719 | { | 720 | { |
720 | if( !tbDeletePlaylist->isHidden()) | 721 | if( !tbDeletePlaylist->isHidden()) |
721 | tbDeletePlaylist->hide(); | 722 | tbDeletePlaylist->hide(); |
722 | d->tbRemoveFromList->setEnabled(TRUE); | 723 | d->tbRemoveFromList->setEnabled(TRUE); |
723 | d->tbAddToList->setEnabled(FALSE); | 724 | d->tbAddToList->setEnabled(FALSE); |
724 | } | 725 | } |
725 | break; | 726 | break; |
726 | case 1: | 727 | case 1: |
727 | { | 728 | { |
728 | audioView->clear(); | 729 | audioView->clear(); |
729 | populateAudioView(); | 730 | populateAudioView(); |
730 | 731 | ||
731 | if( !tbDeletePlaylist->isHidden()) | 732 | if( !tbDeletePlaylist->isHidden()) |
732 | tbDeletePlaylist->hide(); | 733 | tbDeletePlaylist->hide(); |
733 | d->tbRemoveFromList->setEnabled(FALSE); | 734 | d->tbRemoveFromList->setEnabled(FALSE); |
734 | d->tbAddToList->setEnabled(TRUE); | 735 | d->tbAddToList->setEnabled(TRUE); |
735 | } | 736 | } |
736 | break; | 737 | break; |
737 | case 2: | 738 | case 2: |
738 | { | 739 | { |
739 | videoView->clear(); | 740 | videoView->clear(); |
740 | populateVideoView(); | 741 | populateVideoView(); |
741 | if( !tbDeletePlaylist->isHidden()) | 742 | if( !tbDeletePlaylist->isHidden()) |
742 | tbDeletePlaylist->hide(); | 743 | tbDeletePlaylist->hide(); |
743 | d->tbRemoveFromList->setEnabled(FALSE); | 744 | d->tbRemoveFromList->setEnabled(FALSE); |
744 | d->tbAddToList->setEnabled(TRUE); | 745 | d->tbAddToList->setEnabled(TRUE); |
745 | } | 746 | } |
746 | break; | 747 | break; |
747 | case 3: | 748 | case 3: |
748 | { | 749 | { |
749 | if( tbDeletePlaylist->isHidden()) | 750 | if( tbDeletePlaylist->isHidden()) |
750 | tbDeletePlaylist->show(); | 751 | tbDeletePlaylist->show(); |
751 | playLists->reread(); | 752 | playLists->reread(); |
752 | } | 753 | } |
753 | break; | 754 | break; |
754 | }; | 755 | }; |
755 | } | 756 | } |
756 | 757 | ||
757 | void PlayListWidget::btnPlay(bool b) { | 758 | void PlayListWidget::btnPlay(bool b) { |
758 | 759 | ||
759 | // mediaPlayerState->setPlaying(b); | 760 | // mediaPlayerState->setPlaying(b); |
760 | switch ( tabWidget->currentPageIndex()) { | 761 | switch ( tabWidget->currentPageIndex()) { |
761 | case 0: | 762 | case 0: |
762 | { | 763 | { |
763 | mediaPlayerState->setPlaying(b); | 764 | mediaPlayerState->setPlaying(b); |
764 | } | 765 | } |
765 | break; | 766 | break; |
766 | case 1: | 767 | case 1: |
767 | { | 768 | { |
768 | addToSelection( audioView->currentItem() ); | 769 | addToSelection( audioView->currentItem() ); |
769 | mediaPlayerState->setPlaying(b); | 770 | mediaPlayerState->setPlaying(b); |
770 | d->selectedFiles->removeSelected( ); | 771 | d->selectedFiles->removeSelected( ); |
771 | tabWidget->setCurrentPage(1); | 772 | tabWidget->setCurrentPage(1); |
772 | d->selectedFiles->unSelect(); | 773 | d->selectedFiles->unSelect(); |
773 | insanityBool=FALSE; | 774 | insanityBool=FALSE; |
774 | }// audioView->clearSelection(); | 775 | }// audioView->clearSelection(); |
775 | break; | 776 | break; |
776 | case 2: | 777 | case 2: |
777 | { | 778 | { |
778 | addToSelection( videoView->currentItem() ); | 779 | addToSelection( videoView->currentItem() ); |
779 | mediaPlayerState->setPlaying(b); | 780 | mediaPlayerState->setPlaying(b); |
780 | qApp->processEvents(); | 781 | qApp->processEvents(); |
781 | d->selectedFiles->removeSelected( ); | 782 | d->selectedFiles->removeSelected( ); |
782 | tabWidget->setCurrentPage(2); | 783 | tabWidget->setCurrentPage(2); |
783 | d->selectedFiles->unSelect(); | 784 | d->selectedFiles->unSelect(); |
784 | insanityBool=FALSE; | 785 | insanityBool=FALSE; |
785 | }// videoView->clearSelection(); | 786 | }// videoView->clearSelection(); |
786 | break; | 787 | break; |
787 | }; | 788 | }; |
788 | 789 | ||
789 | } | 790 | } |
790 | 791 | ||
791 | void PlayListWidget::deletePlaylist() { | 792 | void PlayListWidget::deletePlaylist() { |
792 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), | 793 | switch( QMessageBox::information( this, (tr("Remove Playlist?")), |
793 | (tr("You really want to delete\nthis playlist?")), | 794 | (tr("You really want to delete\nthis playlist?")), |
794 | (tr("Yes")), (tr("No")), 0 )){ | 795 | (tr("Yes")), (tr("No")), 0 )){ |
795 | case 0: // Yes clicked, | 796 | case 0: // Yes clicked, |
796 | QFile().remove(playLists->selected()->file()); | 797 | QFile().remove(playLists->selected()->file()); |
797 | QFile().remove(playLists->selected()->linkFile()); | 798 | QFile().remove(playLists->selected()->linkFile()); |
798 | playLists->reread(); | 799 | playLists->reread(); |
799 | break; | 800 | break; |
800 | case 1: // Cancel | 801 | case 1: // Cancel |
801 | break; | 802 | break; |
802 | }; | 803 | }; |
803 | } | 804 | } |
804 | 805 | ||
805 | void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) { | 806 | void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { |
806 | switch (mouse) { | 807 | switch (mouse) { |
807 | case 1: | 808 | case 1: |
808 | break; | 809 | break; |
809 | case 2:{ | 810 | case 2:{ |
810 | QPopupMenu m; | 811 | QPopupMenu m; |
811 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); | 812 | m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); |
812 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); | 813 | m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); |
813 | m.insertSeparator(); | 814 | m.insertSeparator(); |
814 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); | 815 | m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); |
815 | m.exec( QCursor::pos() ); | 816 | m.exec( QCursor::pos() ); |
816 | } | 817 | } |
817 | break; | 818 | break; |
818 | }; | 819 | }; |
819 | } | 820 | } |
820 | 821 | ||
821 | void PlayListWidget::playSelected() { | 822 | void PlayListWidget::playSelected() { |
822 | btnPlay( TRUE); | 823 | btnPlay( TRUE); |
823 | } | 824 | } |
824 | 825 | ||
825 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) { | 826 | void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
826 | switch (mouse) { | 827 | switch (mouse) { |
827 | case 1: | 828 | case 1: |
828 | 829 | ||
829 | break; | 830 | break; |
830 | case 2: | 831 | case 2: |
831 | { | 832 | { |
832 | QPopupMenu m; | 833 | QPopupMenu m; |
833 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); | 834 | m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); |
834 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); | 835 | m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); |
835 | m.exec( QCursor::pos() ); | 836 | m.exec( QCursor::pos() ); |
836 | } | 837 | } |
837 | break; | 838 | break; |
838 | }; | 839 | }; |
839 | } | 840 | } |
840 | 841 | ||
841 | void PlayListWidget::listDelete() { | 842 | void PlayListWidget::listDelete() { |
842 | Config cfg( "OpiePlayer" ); | 843 | Config cfg( "OpiePlayer" ); |
843 | cfg.setGroup("PlayList"); | 844 | cfg.setGroup("PlayList"); |
844 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 845 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
845 | QString file; | 846 | QString file; |
846 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 847 | // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
847 | switch ( tabWidget->currentPageIndex()) { | 848 | switch ( tabWidget->currentPageIndex()) { |
848 | case 0: | 849 | case 0: |
849 | break; | 850 | break; |
850 | case 1: | 851 | case 1: |
851 | { | 852 | { |
852 | file = audioView->currentItem()->text(0); | 853 | file = audioView->currentItem()->text(0); |
853 | QListIterator<DocLnk> Pdit( files.children() ); | 854 | QListIterator<DocLnk> Pdit( files.children() ); |
854 | for ( ; Pdit.current(); ++Pdit ) { | 855 | for ( ; Pdit.current(); ++Pdit ) { |
855 | if( Pdit.current()->name() == file) { | 856 | if( Pdit.current()->name() == file) { |
856 | LnkProperties prop( Pdit.current() ); | 857 | LnkProperties prop( Pdit.current() ); |
857 | prop.showMaximized(); | 858 | prop.showMaximized(); |
858 | prop.exec(); | 859 | prop.exec(); |
859 | } | 860 | } |
860 | } | 861 | } |
861 | populateAudioView(); | 862 | populateAudioView(); |
862 | } | 863 | } |
863 | break; | 864 | break; |
864 | case 2: | 865 | case 2: |
865 | { | 866 | { |
866 | 867 | ||
867 | } | 868 | } |
868 | break; | 869 | break; |
869 | }; | 870 | }; |
870 | } | 871 | } |
871 | 872 | ||
872 | void PlayListWidget::scanForAudio() { | 873 | void PlayListWidget::scanForAudio() { |
873 | qDebug("scan for audio"); | 874 | qDebug("scan for audio"); |
874 | files.detachChildren(); | 875 | files.detachChildren(); |
875 | QListIterator<DocLnk> sdit( files.children() ); | 876 | QListIterator<DocLnk> sdit( files.children() ); |
876 | for ( ; sdit.current(); ++sdit ) { | 877 | for ( ; sdit.current(); ++sdit ) { |
877 | delete sdit.current(); | 878 | delete sdit.current(); |
878 | } | 879 | } |
879 | Global::findDocuments(&files, "audio/*"); | 880 | Global::findDocuments(&files, "audio/*"); |
880 | audioScan = TRUE; | 881 | audioScan = TRUE; |
881 | } | 882 | } |
882 | void PlayListWidget::scanForVideo() { | 883 | void PlayListWidget::scanForVideo() { |
883 | qDebug("scan for video"); | 884 | qDebug("scan for video"); |
884 | vFiles.detachChildren(); | 885 | vFiles.detachChildren(); |
885 | QListIterator<DocLnk> sdit( vFiles.children() ); | 886 | QListIterator<DocLnk> sdit( vFiles.children() ); |
886 | for ( ; sdit.current(); ++sdit ) { | 887 | for ( ; sdit.current(); ++sdit ) { |
887 | delete sdit.current(); | 888 | delete sdit.current(); |
888 | } | 889 | } |
889 | Global::findDocuments(&vFiles, "video/*"); | 890 | Global::findDocuments(&vFiles, "video/*"); |
890 | videoScan = TRUE; | 891 | videoScan = TRUE; |
891 | } | 892 | } |
892 | 893 | ||
893 | void PlayListWidget::populateAudioView() { | 894 | void PlayListWidget::populateAudioView() { |
894 | 895 | ||
895 | audioView->clear(); | 896 | audioView->clear(); |
896 | StorageInfo storageInfo; | 897 | StorageInfo storageInfo; |
897 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 898 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
898 | if(!audioScan) scanForAudio(); | 899 | if(!audioScan) scanForAudio(); |
899 | 900 | ||
900 | QListIterator<DocLnk> dit( files.children() ); | 901 | QListIterator<DocLnk> dit( files.children() ); |
901 | QListIterator<FileSystem> it ( fs ); | 902 | QListIterator<FileSystem> it ( fs ); |
902 | 903 | ||
903 | QString storage; | 904 | QString storage; |
904 | for ( ; dit.current(); ++dit ) { | 905 | for ( ; dit.current(); ++dit ) { |
905 | for( ; it.current(); ++it ){ | 906 | for( ; it.current(); ++it ){ |
906 | const QString name = (*it)->name(); | 907 | const QString name = (*it)->name(); |
907 | const QString path = (*it)->path(); | 908 | const QString path = (*it)->path(); |
908 | if(dit.current()->file().find(path) != -1 ) storage=name; | 909 | if(dit.current()->file().find(path) != -1 ) storage=name; |
909 | } | 910 | } |
910 | 911 | ||
911 | QListViewItem * newItem; | 912 | QListViewItem * newItem; |
912 | if ( QFile( dit.current()->file()).exists() ) { | 913 | if ( QFile( dit.current()->file()).exists() ) { |
913 | // qDebug(dit.current()->name()); | 914 | // qDebug(dit.current()->name()); |
914 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), | 915 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), |
915 | QString::number( QFile( dit.current()->file()).size() ), storage); | 916 | QString::number( QFile( dit.current()->file()).size() ), storage); |
916 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); | 917 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); |
917 | } | 918 | } |
918 | } | 919 | } |
919 | 920 | ||
920 | } | 921 | } |
921 | 922 | ||
922 | void PlayListWidget::populateVideoView() { | 923 | void PlayListWidget::populateVideoView() { |
923 | videoView->clear(); | 924 | videoView->clear(); |
924 | StorageInfo storageInfo; | 925 | StorageInfo storageInfo; |
925 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 926 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
926 | 927 | ||
927 | if(!videoScan ) scanForVideo(); | 928 | if(!videoScan ) scanForVideo(); |
928 | 929 | ||
929 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 930 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
930 | QListIterator<FileSystem> it ( fs ); | 931 | QListIterator<FileSystem> it ( fs ); |
931 | videoView->clear(); | 932 | videoView->clear(); |
932 | QString storage; | 933 | QString storage; |
933 | for ( ; Vdit.current(); ++Vdit ) { | 934 | for ( ; Vdit.current(); ++Vdit ) { |
934 | for( ; it.current(); ++it ){ | 935 | for( ; it.current(); ++it ){ |
935 | const QString name = (*it)->name(); | 936 | const QString name = (*it)->name(); |
936 | const QString path = (*it)->path(); | 937 | const QString path = (*it)->path(); |
937 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 938 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
938 | } | 939 | } |
939 | 940 | ||
940 | QListViewItem * newItem; | 941 | QListViewItem * newItem; |
941 | if ( QFile( Vdit.current()->file()).exists() ) { | 942 | if ( QFile( Vdit.current()->file()).exists() ) { |
942 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), | 943 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), |
943 | QString::number( QFile( Vdit.current()->file()).size() ), storage); | 944 | QString::number( QFile( Vdit.current()->file()).size() ), storage); |
944 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); | 945 | newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); |
945 | } | 946 | } |
946 | } | 947 | } |
947 | } | 948 | } |
948 | 949 | ||
949 | void PlayListWidget::openFile() { | 950 | void PlayListWidget::openFile() { |
950 | QString filename, name; | 951 | QString filename, name; |
951 | InputDialog *fileDlg; | 952 | InputDialog *fileDlg; |
952 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | 953 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); |
953 | fileDlg->exec(); | 954 | fileDlg->exec(); |
954 | if( fileDlg->result() == 1 ) { | 955 | if( fileDlg->result() == 1 ) { |
955 | filename = fileDlg->LineEdit1->text(); | 956 | filename = fileDlg->LineEdit1->text(); |
956 | 957 | ||
957 | qDebug("Selected filename is "+filename); | 958 | qDebug("Selected filename is "+filename); |
958 | if(filename.right(3) == "m3u") { | 959 | if(filename.right(3) == "m3u") { |
959 | readm3u( filename ); | 960 | readm3u( filename ); |
960 | } else if(filename.right(3) == "pls") { | 961 | } else if(filename.right(3) == "pls") { |
961 | readPls( filename ); | 962 | readPls( filename ); |
962 | } else { | 963 | } else { |
963 | DocLnk lnk; | 964 | DocLnk lnk; |
964 | 965 | ||
965 | lnk.setName(filename); //sets file name | 966 | lnk.setName(filename); //sets file name |
966 | lnk.setFile(filename); //sets File property | 967 | lnk.setFile(filename); //sets File property |
967 | lnk.setType("audio/x-mpegurl"); | 968 | lnk.setType("audio/x-mpegurl"); |
968 | lnk.setExec("opieplayer"); | 969 | lnk.setExec("opieplayer"); |
969 | lnk.setIcon("opieplayer/MPEGPlayer"); | 970 | lnk.setIcon("opieplayer/MPEGPlayer"); |
970 | 971 | ||
971 | if(!lnk.writeLink()) { | 972 | if(!lnk.writeLink()) { |
972 | qDebug("Writing doclink did not work"); | 973 | qDebug("Writing doclink did not work"); |
973 | } | 974 | } |
974 | d->selectedFiles->addToSelection( lnk); | 975 | d->selectedFiles->addToSelection( lnk); |
975 | } | 976 | } |
976 | } | 977 | } |
977 | if(fileDlg) { | 978 | if(fileDlg) { |
978 | delete fileDlg; | 979 | delete fileDlg; |
979 | } | 980 | } |
980 | } | 981 | } |
981 | 982 | ||
982 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) | 983 | void PlayListWidget::keyReleaseEvent( QKeyEvent *e) |
983 | { | 984 | { |
984 | switch ( e->key() ) { | 985 | switch ( e->key() ) { |
985 | ////////////////////////////// Zaurus keys | 986 | ////////////////////////////// Zaurus keys |
986 | case Key_F9: //activity | 987 | case Key_F9: //activity |
987 | // if(audioUI->isHidden()) | 988 | // if(audioUI->isHidden()) |
988 | // audioUI->showMaximized(); | 989 | // audioUI->showMaximized(); |
989 | break; | 990 | break; |
990 | case Key_F10: //contacts | 991 | case Key_F10: //contacts |
991 | // if( videoUI->isHidden()) | 992 | // if( videoUI->isHidden()) |
992 | // videoUI->showMaximized(); | 993 | // videoUI->showMaximized(); |
993 | break; | 994 | break; |
994 | case Key_F11: //menu | 995 | case Key_F11: //menu |
995 | break; | 996 | break; |
996 | case Key_F12: //home | 997 | case Key_F12: //home |
997 | // doBlank(); | 998 | // doBlank(); |
998 | break; | 999 | break; |
999 | case Key_F13: //mail | 1000 | case Key_F13: //mail |
1000 | // doUnblank(); | 1001 | // doUnblank(); |
1001 | break; | 1002 | break; |
1002 | case Key_Q: //add to playlist | 1003 | case Key_Q: //add to playlist |
1003 | qDebug("Add"); | 1004 | qDebug("Add"); |
1004 | addSelected(); | 1005 | addSelected(); |
1005 | break; | 1006 | break; |
1006 | case Key_R: //remove from playlist | 1007 | case Key_R: //remove from playlist |
1007 | removeSelected(); | 1008 | removeSelected(); |
1008 | break; | 1009 | break; |
1009 | // case Key_P: //play | 1010 | // case Key_P: //play |
1010 | // qDebug("Play"); | 1011 | // qDebug("Play"); |
1011 | // playSelected(); | 1012 | // playSelected(); |
1012 | // break; | 1013 | // break; |
1013 | case Key_Space: | 1014 | case Key_Space: |
1014 | qDebug("Play"); | 1015 | qDebug("Play"); |
1015 | // playSelected(); puh | 1016 | // playSelected(); puh |
1016 | break; | 1017 | break; |
1017 | case Key_1: | 1018 | case Key_1: |
1018 | tabWidget->setCurrentPage(0); | 1019 | tabWidget->setCurrentPage(0); |
1019 | break; | 1020 | break; |
1020 | case Key_2: | 1021 | case Key_2: |
1021 | tabWidget->setCurrentPage(1); | 1022 | tabWidget->setCurrentPage(1); |
1022 | break; | 1023 | break; |
1023 | case Key_3: | 1024 | case Key_3: |
1024 | tabWidget->setCurrentPage(2); | 1025 | tabWidget->setCurrentPage(2); |
1025 | break; | 1026 | break; |
1026 | case Key_4: | 1027 | case Key_4: |
1027 | tabWidget->setCurrentPage(3); | 1028 | tabWidget->setCurrentPage(3); |
1028 | break; | 1029 | break; |
1029 | case Key_Down: | 1030 | case Key_Down: |
1030 | if ( !d->selectedFiles->next() ) | 1031 | if ( !d->selectedFiles->next() ) |
1031 | d->selectedFiles->first(); | 1032 | d->selectedFiles->first(); |
1032 | 1033 | ||
1033 | break; | 1034 | break; |
1034 | case Key_Up: | 1035 | case Key_Up: |
1035 | if ( !d->selectedFiles->prev() ) | 1036 | if ( !d->selectedFiles->prev() ) |
1036 | // d->selectedFiles->last(); | 1037 | // d->selectedFiles->last(); |
1037 | 1038 | ||
1038 | break; | 1039 | break; |
1039 | 1040 | ||
1040 | } | 1041 | } |
1041 | } | 1042 | } |
1042 | 1043 | ||
1043 | void PlayListWidget::keyPressEvent( QKeyEvent *e) | 1044 | void PlayListWidget::keyPressEvent( QKeyEvent *) |
1044 | { | 1045 | { |
1045 | // qDebug("Key press"); | 1046 | // qDebug("Key press"); |
1046 | // switch ( e->key() ) { | 1047 | // switch ( e->key() ) { |
1047 | // ////////////////////////////// Zaurus keys | 1048 | // ////////////////////////////// Zaurus keys |
1048 | // case Key_A: //add to playlist | 1049 | // case Key_A: //add to playlist |
1049 | // qDebug("Add"); | 1050 | // qDebug("Add"); |
1050 | // addSelected(); | 1051 | // addSelected(); |
1051 | // break; | 1052 | // break; |
1052 | // case Key_R: //remove from playlist | 1053 | // case Key_R: //remove from playlist |
1053 | // removeSelected(); | 1054 | // removeSelected(); |
1054 | // break; | 1055 | // break; |
1055 | // case Key_P: //play | 1056 | // case Key_P: //play |
1056 | // qDebug("Play"); | 1057 | // qDebug("Play"); |
1057 | // playSelected(); | 1058 | // playSelected(); |
1058 | // break; | 1059 | // break; |
1059 | // case Key_Space: | 1060 | // case Key_Space: |
1060 | // qDebug("Play"); | 1061 | // qDebug("Play"); |
1061 | // playSelected(); | 1062 | // playSelected(); |
1062 | // break; | 1063 | // break; |
1063 | // } | 1064 | // } |
1064 | } | 1065 | } |
1065 | 1066 | ||
1066 | void PlayListWidget::doBlank() { | 1067 | void PlayListWidget::doBlank() { |
1067 | qDebug("do blanking"); | 1068 | qDebug("do blanking"); |
1068 | fd=open("/dev/fb0",O_RDWR); | 1069 | fd=open("/dev/fb0",O_RDWR); |
1069 | if (fd != -1) { | 1070 | if (fd != -1) { |
1070 | ioctl(fd,FBIOBLANK,1); | 1071 | ioctl(fd,FBIOBLANK,1); |
1071 | // close(fd); | 1072 | // close(fd); |
1072 | } | 1073 | } |
1073 | } | 1074 | } |
1074 | 1075 | ||
1075 | void PlayListWidget::doUnblank() { | 1076 | void PlayListWidget::doUnblank() { |
1076 | // this crashes opieplayer with a segfault | 1077 | // this crashes opieplayer with a segfault |
1077 | // int fd; | 1078 | // int fd; |
1078 | // fd=open("/dev/fb0",O_RDWR); | 1079 | // fd=open("/dev/fb0",O_RDWR); |
1079 | qDebug("do unblanking"); | 1080 | qDebug("do unblanking"); |
1080 | if (fd != -1) { | 1081 | if (fd != -1) { |
1081 | ioctl(fd,FBIOBLANK,0); | 1082 | ioctl(fd,FBIOBLANK,0); |
1082 | close(fd); | 1083 | close(fd); |
1083 | } | 1084 | } |
1084 | QCopEnvelope h("QPE/System", "setBacklight(int)"); | 1085 | QCopEnvelope h("QPE/System", "setBacklight(int)"); |
1085 | h <<-3;// v[1]; // -3 Force on | 1086 | h <<-3;// v[1]; // -3 Force on |
1086 | } | 1087 | } |
1087 | 1088 | ||
1088 | void PlayListWidget::readm3u(const QString &filename) { | 1089 | void PlayListWidget::readm3u(const QString &filename) { |
1089 | 1090 | ||
1090 | qDebug("m3u filename is "+filename); | 1091 | qDebug("m3u filename is "+filename); |
1091 | QFile f(filename); | 1092 | QFile f(filename); |
1092 | 1093 | ||
1093 | if(f.open(IO_ReadOnly)) { | 1094 | if(f.open(IO_ReadOnly)) { |
1094 | QTextStream t(&f); | 1095 | QTextStream t(&f); |
1095 | QString s;//, first, second; | 1096 | QString s;//, first, second; |
1096 | int i=0; | 1097 | int i=0; |
1097 | while ( !t.atEnd()) { | 1098 | while ( !t.atEnd()) { |
1098 | s=t.readLine(); | 1099 | s=t.readLine(); |
1099 | 1100 | ||
1100 | if(s.find("#",0,TRUE) == -1) { | 1101 | if(s.find("#",0,TRUE) == -1) { |
1101 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat | 1102 | if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat |
1102 | if(s.left(2) == "E:" || s.left(2) == "P:") { | 1103 | if(s.left(2) == "E:" || s.left(2) == "P:") { |
1103 | s=s.right(s.length()-2); | 1104 | s=s.right(s.length()-2); |
1104 | DocLnk lnk( s ); | 1105 | DocLnk lnk( s ); |
1105 | QFileInfo f(s); | 1106 | QFileInfo f(s); |
1106 | QString name = f.baseName(); | 1107 | QString name = f.baseName(); |
1107 | name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 ); | 1108 | name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 ); |
1108 | lnk.setName( name ); | 1109 | lnk.setName( name ); |
1109 | s=s.replace( QRegExp("\\"),"/"); | 1110 | s=s.replace( QRegExp("\\"),"/"); |
1110 | lnk.setFile( s ); | 1111 | lnk.setFile( s ); |
1111 | lnk.writeLink(); | 1112 | lnk.writeLink(); |
1112 | qDebug("add "+name); | 1113 | qDebug("add "+name); |
1113 | d->selectedFiles->addToSelection( lnk); | 1114 | d->selectedFiles->addToSelection( lnk); |
1114 | } else { // is url | 1115 | } else { // is url |
1115 | s.replace(QRegExp("%20")," "); | 1116 | s.replace(QRegExp("%20")," "); |
1116 | DocLnk lnk( s ); | 1117 | DocLnk lnk( s ); |
1117 | QString name; | 1118 | QString name; |
1118 | if(name.left(4)=="http") { | 1119 | if(name.left(4)=="http") { |
1119 | name = s.right( s.length() - 7); | 1120 | name = s.right( s.length() - 7); |
1120 | } else { | 1121 | } else { |
1121 | name = s; | 1122 | name = s; |
1122 | } | 1123 | } |
1123 | lnk.setName(name); | 1124 | lnk.setName(name); |
1124 | if(s.at(s.length()-4) == '.') { | 1125 | if(s.at(s.length()-4) == '.') { |
1125 | lnk.setFile( s); | 1126 | lnk.setFile( s); |
1126 | } else { | 1127 | } else { |
1127 | lnk.setFile( s+"/"); | 1128 | lnk.setFile( s+"/"); |
1128 | } | 1129 | } |
1129 | lnk.setType("audio/x-mpegurl"); | 1130 | lnk.setType("audio/x-mpegurl"); |
1130 | lnk.writeLink(); | 1131 | lnk.writeLink(); |
1131 | d->selectedFiles->addToSelection( lnk); | 1132 | d->selectedFiles->addToSelection( lnk); |
1132 | } | 1133 | } |
1133 | i++; | 1134 | i++; |
1134 | } | 1135 | } |
1135 | } | 1136 | } |
1136 | } | 1137 | } |
1137 | } | 1138 | } |
1138 | f.close(); | 1139 | f.close(); |
1139 | } | 1140 | } |
1140 | 1141 | ||
1141 | void PlayListWidget::writem3u() { | 1142 | void PlayListWidget::writem3u() { |
1142 | 1143 | ||
1143 | InputDialog *fileDlg; | 1144 | InputDialog *fileDlg; |
1144 | fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); | 1145 | fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); |
1145 | fileDlg->exec(); | 1146 | fileDlg->exec(); |
1146 | QString filename,list; | 1147 | QString filename,list; |
1147 | if( fileDlg->result() == 1 ) { | 1148 | if( fileDlg->result() == 1 ) { |
1148 | filename = fileDlg->LineEdit1->text(); | 1149 | filename = fileDlg->LineEdit1->text(); |
1149 | qDebug(filename); | 1150 | qDebug(filename); |
1150 | int noOfFiles = 0; | 1151 | int noOfFiles = 0; |
1151 | d->selectedFiles->first(); | 1152 | d->selectedFiles->first(); |
1152 | do { | 1153 | do { |
1153 | // we dont check for existance because of url's | 1154 | // we dont check for existance because of url's |
1154 | // qDebug(d->selectedFiles->current()->file()); | 1155 | // qDebug(d->selectedFiles->current()->file()); |
1155 | list += d->selectedFiles->current()->file()+"\n"; | 1156 | list += d->selectedFiles->current()->file()+"\n"; |
1156 | noOfFiles++; | 1157 | noOfFiles++; |
1157 | } | 1158 | } |
1158 | while ( d->selectedFiles->next() ); | 1159 | while ( d->selectedFiles->next() ); |
1159 | qDebug(list); | 1160 | qDebug(list); |
1160 | if(filename.left(1) != "/") | 1161 | if(filename.left(1) != "/") |
1161 | filename=QPEApplication::documentDir()+"/"+filename; | 1162 | filename=QPEApplication::documentDir()+"/"+filename; |
1162 | if(filename.right(3) != "m3u") | 1163 | if(filename.right(3) != "m3u") |
1163 | filename=filename+".m3u"; | 1164 | filename=filename+".m3u"; |
1164 | 1165 | ||
1165 | QFile f(filename); | 1166 | QFile f(filename); |
1166 | f.open(IO_WriteOnly); | 1167 | f.open(IO_WriteOnly); |
1167 | f.writeBlock(list, list.length()); | 1168 | f.writeBlock(list, list.length()); |
1168 | f.close(); | 1169 | f.close(); |
1169 | } | 1170 | } |
1170 | if(fileDlg) delete fileDlg; | 1171 | if(fileDlg) delete fileDlg; |
1171 | } | 1172 | } |
1172 | 1173 | ||
1173 | void PlayListWidget::readPls(const QString &filename) { | 1174 | void PlayListWidget::readPls(const QString &filename) { |
1174 | 1175 | ||
1175 | qDebug("pls filename is "+filename); | 1176 | qDebug("pls filename is "+filename); |
1176 | QFile f(filename); | 1177 | QFile f(filename); |
1177 | 1178 | ||
1178 | if(f.open(IO_ReadOnly)) { | 1179 | if(f.open(IO_ReadOnly)) { |
1179 | QTextStream t(&f); | 1180 | QTextStream t(&f); |
1180 | QString s;//, first, second; | 1181 | QString s;//, first, second; |
1181 | int i=0; | 1182 | int i=0; |
1182 | while ( !t.atEnd()) { | 1183 | while ( !t.atEnd()) { |
1183 | s=t.readLine(); | 1184 | s=t.readLine(); |
1184 | if(s.left(4) == "File") { | 1185 | if(s.left(4) == "File") { |
1185 | s=s.right(s.length() - 6); | 1186 | s=s.right(s.length() - 6); |
1186 | s.replace(QRegExp("%20")," "); | 1187 | s.replace(QRegExp("%20")," "); |
1187 | qDebug("adding "+s+" to playlist"); | 1188 | qDebug("adding "+s+" to playlist"); |
1188 | // numberofentries=2 | 1189 | // numberofentries=2 |
1189 | // File1=http | 1190 | // File1=http |
1190 | // Title | 1191 | // Title |
1191 | // Length | 1192 | // Length |
1192 | // Version | 1193 | // Version |
1193 | // File2=http | 1194 | // File2=http |
1194 | s=s.replace( QRegExp("\\"),"/"); | 1195 | s=s.replace( QRegExp("\\"),"/"); |
1195 | DocLnk lnk( s ); | 1196 | DocLnk lnk( s ); |
1196 | QFileInfo f(s); | 1197 | QFileInfo f(s); |
1197 | QString name = f.baseName(); | 1198 | QString name = f.baseName(); |
1198 | if(name.left(4)=="http") | 1199 | if(name.left(4)=="http") |
1199 | name = s.right( s.length() - 7); | 1200 | name = s.right( s.length() - 7); |
1200 | else | 1201 | else |
1201 | name=s; | 1202 | name=s; |
1202 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); | 1203 | name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); |
1203 | lnk.setName( name); | 1204 | lnk.setName( name); |
1204 | if(s.at(s.length()-4) == '.') // if this is probably a file | 1205 | if(s.at(s.length()-4) == '.') // if this is probably a file |
1205 | lnk.setFile( s); | 1206 | lnk.setFile( s); |
1206 | else { //if its a url | 1207 | else { //if its a url |
1207 | if( name.right(1).find('/') == -1) | 1208 | if( name.right(1).find('/') == -1) |
1208 | s+="/"; | 1209 | s+="/"; |
1209 | lnk.setFile( s); | 1210 | lnk.setFile( s); |
1210 | } | 1211 | } |
1211 | lnk.setType("audio/x-mpegurl"); | 1212 | lnk.setType("audio/x-mpegurl"); |
1212 | 1213 | ||
1213 | qDebug("DocLnk add "+name); | 1214 | qDebug("DocLnk add "+name); |
1214 | d->selectedFiles->addToSelection( lnk); | 1215 | d->selectedFiles->addToSelection( lnk); |
1215 | } | 1216 | } |
1216 | } | 1217 | } |
1217 | i++; | 1218 | i++; |
1218 | } | 1219 | } |
1219 | } | 1220 | } |
1220 | 1221 | ||
1221 | void PlayListWidget::pmViewActivated(int index) { | 1222 | void PlayListWidget::pmViewActivated(int index) { |
1222 | qDebug("%d", index); | 1223 | qDebug("%d", index); |
1223 | switch(index) { | 1224 | switch(index) { |
1224 | case -16: | 1225 | case -16: |
1225 | { | 1226 | { |
1226 | 1227 | ||
1227 | mediaPlayerState->toggleFullscreen(); | 1228 | mediaPlayerState->toggleFullscreen(); |
1228 | bool b=mediaPlayerState->fullscreen(); | 1229 | bool b=mediaPlayerState->fullscreen(); |
1229 | pmView->setItemChecked( index,b); | 1230 | pmView->setItemChecked( index,b); |
1230 | Config cfg( "OpiePlayer" ); | 1231 | Config cfg( "OpiePlayer" ); |
1231 | cfg.writeEntry("FullScreen", b); | 1232 | cfg.writeEntry("FullScreen", b); |
1232 | 1233 | ||
1233 | } | 1234 | } |
1234 | break; | 1235 | break; |
1235 | }; | 1236 | }; |
1236 | } | 1237 | } |