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