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