-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.cpp | 62 | ||||
-rw-r--r-- | core/multimedia/opieplayer/playlistwidget.h | 1 |
2 files changed, 51 insertions, 12 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp index d9a70ce..11f9752 100644 --- a/core/multimedia/opieplayer/playlistwidget.cpp +++ b/core/multimedia/opieplayer/playlistwidget.cpp | |||
@@ -60,198 +60,200 @@ | |||
60 | 60 | ||
61 | #define BUTTONS_ON_TOOLBAR | 61 | #define BUTTONS_ON_TOOLBAR |
62 | #define SIDE_BUTTONS | 62 | #define SIDE_BUTTONS |
63 | #define CAN_SAVE_LOAD_PLAYLISTS | 63 | #define CAN_SAVE_LOAD_PLAYLISTS |
64 | 64 | ||
65 | extern MediaPlayerState *mediaPlayerState; | 65 | extern MediaPlayerState *mediaPlayerState; |
66 | 66 | ||
67 | // class myFileSelector { | 67 | // class myFileSelector { |
68 | 68 | ||
69 | // }; | 69 | // }; |
70 | class PlayListWidgetPrivate { | 70 | class PlayListWidgetPrivate { |
71 | public: | 71 | public: |
72 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; | 72 | QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; |
73 | QFrame *playListFrame; | 73 | QFrame *playListFrame; |
74 | FileSelector *files; | 74 | FileSelector *files; |
75 | PlayListSelection *selectedFiles; | 75 | PlayListSelection *selectedFiles; |
76 | bool setDocumentUsed; | 76 | bool setDocumentUsed; |
77 | DocLnk *current; | 77 | DocLnk *current; |
78 | }; | 78 | }; |
79 | 79 | ||
80 | 80 | ||
81 | class ToolButton : public QToolButton { | 81 | class ToolButton : public QToolButton { |
82 | public: | 82 | public: |
83 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) | 83 | ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) |
84 | : QToolButton( parent, name ) { | 84 | : QToolButton( parent, name ) { |
85 | setTextLabel( name ); | 85 | setTextLabel( name ); |
86 | setPixmap( Resource::loadPixmap( icon ) ); | 86 | setPixmap( Resource::loadPixmap( icon ) ); |
87 | setAutoRaise( TRUE ); | 87 | setAutoRaise( TRUE ); |
88 | setFocusPolicy( QWidget::NoFocus ); | 88 | setFocusPolicy( QWidget::NoFocus ); |
89 | setToggleButton( t ); | 89 | setToggleButton( t ); |
90 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); | 90 | connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); |
91 | QPEMenuToolFocusManager::manager()->addWidget( this ); | 91 | QPEMenuToolFocusManager::manager()->addWidget( this ); |
92 | } | 92 | } |
93 | }; | 93 | }; |
94 | 94 | ||
95 | 95 | ||
96 | class MenuItem : public QAction { | 96 | class MenuItem : public QAction { |
97 | public: | 97 | public: |
98 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) | 98 | MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) |
99 | : QAction( text, QString::null, 0, 0 ) { | 99 | : QAction( text, QString::null, 0, 0 ) { |
100 | connect( this, SIGNAL( activated() ), handler, slot ); | 100 | connect( this, SIGNAL( activated() ), handler, slot ); |
101 | addTo( parent ); | 101 | addTo( parent ); |
102 | } | 102 | } |
103 | }; | 103 | }; |
104 | 104 | ||
105 | 105 | ||
106 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) | 106 | PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) |
107 | : QMainWindow( parent, name, fl ) { | 107 | : QMainWindow( parent, name, fl ) { |
108 | 108 | ||
109 | d = new PlayListWidgetPrivate; | 109 | d = new PlayListWidgetPrivate; |
110 | d->setDocumentUsed = FALSE; | 110 | d->setDocumentUsed = FALSE; |
111 | d->current = NULL; | 111 | d->current = NULL; |
112 | fromSetDocument = FALSE; | 112 | fromSetDocument = FALSE; |
113 | insanityBool=FALSE; | 113 | insanityBool=FALSE; |
114 | // menuTimer = new QTimer( this ,"menu timer"), | 114 | // menuTimer = new QTimer( this ,"menu timer"), |
115 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); | 115 | // connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); |
116 | 116 | ||
117 | setBackgroundMode( PaletteButton ); | 117 | setBackgroundMode( PaletteButton ); |
118 | 118 | ||
119 | setCaption( tr("OpiePlayer") ); | 119 | setCaption( tr("OpiePlayer") ); |
120 | setIcon( Resource::loadPixmap( "MPEGPlayer" ) ); | 120 | setIcon( Resource::loadPixmap( "MPEGPlayer" ) ); |
121 | 121 | ||
122 | setToolBarsMovable( FALSE ); | 122 | setToolBarsMovable( FALSE ); |
123 | 123 | ||
124 | // Create Toolbar | 124 | // Create Toolbar |
125 | QPEToolBar *toolbar = new QPEToolBar( this ); | 125 | QPEToolBar *toolbar = new QPEToolBar( this ); |
126 | toolbar->setHorizontalStretchable( TRUE ); | 126 | toolbar->setHorizontalStretchable( TRUE ); |
127 | 127 | ||
128 | // Create Menubar | 128 | // Create Menubar |
129 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); | 129 | QPEMenuBar *menu = new QPEMenuBar( toolbar ); |
130 | menu->setMargin( 0 ); | 130 | menu->setMargin( 0 ); |
131 | 131 | ||
132 | QPEToolBar *bar = new QPEToolBar( this ); | 132 | QPEToolBar *bar = new QPEToolBar( this ); |
133 | bar->setLabel( tr( "Play Operations" ) ); | 133 | bar->setLabel( tr( "Play Operations" ) ); |
134 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "mpegplayer/play_current_list", | 134 | // d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "mpegplayer/play_current_list", |
135 | // this , SLOT( addSelected()) ); | 135 | // this , SLOT( addSelected()) ); |
136 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); | 136 | tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); |
137 | tbDeletePlaylist->setFlat(TRUE); | 137 | tbDeletePlaylist->setFlat(TRUE); |
138 | tbDeletePlaylist->setFixedSize(20,20); | 138 | tbDeletePlaylist->setFixedSize(20,20); |
139 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); | 139 | connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); |
140 | 140 | ||
141 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist", | 141 | d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "mpegplayer/add_to_playlist", |
142 | this , SLOT(addSelected()) ); | 142 | this , SLOT(addSelected()) ); |
143 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", | 143 | d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "mpegplayer/remove_from_playlist", |
144 | this , SLOT(removeSelected()) ); | 144 | this , SLOT(removeSelected()) ); |
145 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); | 145 | // d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); |
146 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", | 146 | d->tbPlay = new ToolButton( bar, tr( "Play" ), "mpegplayer/play", |
147 | this , SLOT( btnPlay(bool) ), TRUE ); | 147 | this , SLOT( btnPlay(bool) ), TRUE ); |
148 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"mpegplayer/shuffle", | 148 | d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"mpegplayer/shuffle", |
149 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); | 149 | mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); |
150 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"mpegplayer/loop", | 150 | d->tbLoop = new ToolButton( bar, tr( "Loop" ),"mpegplayer/loop", |
151 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); | 151 | mediaPlayerState, SLOT(setLooping(bool)), TRUE ); |
152 | tbDeletePlaylist->hide(); | 152 | tbDeletePlaylist->hide(); |
153 | 153 | ||
154 | QPopupMenu *pmPlayList = new QPopupMenu( this ); | 154 | QPopupMenu *pmPlayList = new QPopupMenu( this ); |
155 | menu->insertItem( tr( "File" ), pmPlayList ); | 155 | menu->insertItem( tr( "File" ), pmPlayList ); |
156 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); | 156 | new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); |
157 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); | 157 | new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); |
158 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); | 158 | new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); |
159 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); | 159 | new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); |
160 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); | 160 | // pmPlayList->insertSeparator(-1); |
161 | // new MenuItem( pmPlayList, tr( "Load PlayList" ), this, SLOT( loadList() ) ); | 161 | new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); |
162 | pmPlayList->insertSeparator(-1); | ||
163 | new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); | ||
162 | 164 | ||
163 | QPopupMenu *pmView = new QPopupMenu( this ); | 165 | QPopupMenu *pmView = new QPopupMenu( this ); |
164 | menu->insertItem( tr( "View" ), pmView ); | 166 | menu->insertItem( tr( "View" ), pmView ); |
165 | 167 | ||
166 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); | 168 | fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); |
167 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); | 169 | connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); |
168 | fullScreenButton->addTo(pmView); | 170 | fullScreenButton->addTo(pmView); |
169 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("mpegplayer/scale"), QString::null, 0, this, 0); | 171 | scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("mpegplayer/scale"), QString::null, 0, this, 0); |
170 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); | 172 | connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); |
171 | scaleButton->addTo(pmView); | 173 | scaleButton->addTo(pmView); |
172 | 174 | ||
173 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); | 175 | QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); |
174 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); | 176 | QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); |
175 | 177 | ||
176 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); | 178 | QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); |
177 | 179 | ||
178 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); | 180 | tabWidget = new QTabWidget( hbox6, "tabWidget" ); |
179 | tabWidget->setTabShape(QTabWidget::Triangular); | 181 | tabWidget->setTabShape(QTabWidget::Triangular); |
180 | 182 | ||
181 | QWidget *pTab; | 183 | QWidget *pTab; |
182 | pTab = new QWidget( tabWidget, "pTab" ); | 184 | pTab = new QWidget( tabWidget, "pTab" ); |
183 | // playlistView = new QListView( pTab, "playlistview" ); | 185 | // playlistView = new QListView( pTab, "playlistview" ); |
184 | // playlistView->setMinimumSize(236,260); | 186 | // playlistView->setMinimumSize(236,260); |
185 | tabWidget->insertTab( pTab,"Playlist"); | 187 | tabWidget->insertTab( pTab,"Playlist"); |
186 | 188 | ||
187 | 189 | ||
188 | // Add the playlist area | 190 | // Add the playlist area |
189 | 191 | ||
190 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); | 192 | QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); |
191 | d->playListFrame = vbox3; | 193 | d->playListFrame = vbox3; |
192 | d->playListFrame ->setMinimumSize(235,260); | 194 | d->playListFrame ->setMinimumSize(235,260); |
193 | 195 | ||
194 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); | 196 | QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); |
195 | 197 | ||
196 | d->selectedFiles = new PlayListSelection( hbox2); | 198 | d->selectedFiles = new PlayListSelection( hbox2); |
197 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); | 199 | QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); |
198 | 200 | ||
199 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); | 201 | QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); |
200 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 202 | connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
201 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); | 203 | this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); |
202 | 204 | ||
203 | 205 | ||
204 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch | 206 | QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch |
205 | new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); | 207 | new ToolButton( vbox1, tr( "Move Up" ), "mpegplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); |
206 | new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); | 208 | new ToolButton( vbox1, tr( "Remove" ), "mpegplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); |
207 | new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); | 209 | new ToolButton( vbox1, tr( "Move Down" ), "mpegplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); |
208 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch | 210 | QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch |
209 | 211 | ||
210 | QWidget *aTab; | 212 | QWidget *aTab; |
211 | aTab = new QWidget( tabWidget, "aTab" ); | 213 | aTab = new QWidget( tabWidget, "aTab" ); |
212 | audioView = new QListView( aTab, "Audioview" ); | 214 | audioView = new QListView( aTab, "Audioview" ); |
213 | audioView->setMinimumSize(233,260); | 215 | audioView->setMinimumSize(233,260); |
214 | audioView->addColumn( tr("Title"),140); | 216 | audioView->addColumn( tr("Title"),140); |
215 | audioView->addColumn(tr("Size"), -1); | 217 | audioView->addColumn(tr("Size"), -1); |
216 | audioView->addColumn(tr("Media"),-1); | 218 | audioView->addColumn(tr("Media"),-1); |
217 | audioView->setColumnAlignment(1, Qt::AlignRight); | 219 | audioView->setColumnAlignment(1, Qt::AlignRight); |
218 | audioView->setColumnAlignment(2, Qt::AlignRight); | 220 | audioView->setColumnAlignment(2, Qt::AlignRight); |
219 | audioView->setAllColumnsShowFocus(TRUE); | 221 | audioView->setAllColumnsShowFocus(TRUE); |
220 | // audioView->setMultiSelection( TRUE ); | 222 | // audioView->setMultiSelection( TRUE ); |
221 | // audioView->setSelectionMode( QListView::Extended); | 223 | // audioView->setSelectionMode( QListView::Extended); |
222 | 224 | ||
223 | tabWidget->insertTab(aTab,tr("Audio")); | 225 | tabWidget->insertTab(aTab,tr("Audio")); |
224 | 226 | ||
225 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); | 227 | QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); |
226 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 228 | connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
227 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 229 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
228 | 230 | ||
229 | 231 | ||
230 | // audioView | 232 | // audioView |
231 | populateAudioView(); | 233 | populateAudioView(); |
232 | // videowidget | 234 | // videowidget |
233 | 235 | ||
234 | QWidget *vTab; | 236 | QWidget *vTab; |
235 | vTab = new QWidget( tabWidget, "vTab" ); | 237 | vTab = new QWidget( tabWidget, "vTab" ); |
236 | videoView = new QListView( vTab, "Videoview" ); | 238 | videoView = new QListView( vTab, "Videoview" ); |
237 | videoView->setMinimumSize(233,260); | 239 | videoView->setMinimumSize(233,260); |
238 | 240 | ||
239 | videoView->addColumn(tr("Title"),140); | 241 | videoView->addColumn(tr("Title"),140); |
240 | videoView->addColumn(tr("Size"),-1); | 242 | videoView->addColumn(tr("Size"),-1); |
241 | videoView->addColumn(tr("Media"),-1); | 243 | videoView->addColumn(tr("Media"),-1); |
242 | videoView->setColumnAlignment(1, Qt::AlignRight); | 244 | videoView->setColumnAlignment(1, Qt::AlignRight); |
243 | videoView->setColumnAlignment(2, Qt::AlignRight); | 245 | videoView->setColumnAlignment(2, Qt::AlignRight); |
244 | videoView->setAllColumnsShowFocus(TRUE); | 246 | videoView->setAllColumnsShowFocus(TRUE); |
245 | // videoView->setMultiSelection( TRUE ); | 247 | // videoView->setMultiSelection( TRUE ); |
246 | // videoView->setSelectionMode( QListView::Extended); | 248 | // videoView->setSelectionMode( QListView::Extended); |
247 | 249 | ||
248 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); | 250 | QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); |
249 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 251 | connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
250 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); | 252 | this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); |
251 | 253 | ||
252 | tabWidget->insertTab( vTab,tr("Video")); | 254 | tabWidget->insertTab( vTab,tr("Video")); |
253 | populateVideoView(); | 255 | populateVideoView(); |
254 | 256 | ||
255 | //playlists list | 257 | //playlists list |
256 | QWidget *LTab; | 258 | QWidget *LTab; |
257 | LTab = new QWidget( tabWidget, "LTab" ); | 259 | LTab = new QWidget( tabWidget, "LTab" ); |
@@ -327,212 +329,219 @@ void PlayListWidget::initializeStates() { | |||
327 | void PlayListWidget::readConfig( Config& cfg ) { | 329 | void PlayListWidget::readConfig( Config& cfg ) { |
328 | cfg.setGroup("PlayList"); | 330 | cfg.setGroup("PlayList"); |
329 | QString currentString = cfg.readEntry("current", "" ); | 331 | QString currentString = cfg.readEntry("current", "" ); |
330 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 332 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
331 | for ( int i = 0; i < noOfFiles; i++ ) { | 333 | for ( int i = 0; i < noOfFiles; i++ ) { |
332 | QString entryName; | 334 | QString entryName; |
333 | entryName.sprintf( "File%i", i + 1 ); | 335 | entryName.sprintf( "File%i", i + 1 ); |
334 | QString linkFile = cfg.readEntry( entryName ); | 336 | QString linkFile = cfg.readEntry( entryName ); |
335 | DocLnk lnk( linkFile ); | 337 | DocLnk lnk( linkFile ); |
336 | if ( lnk.isValid() ) { | 338 | if ( lnk.isValid() ) { |
337 | d->selectedFiles->addToSelection( lnk ); | 339 | d->selectedFiles->addToSelection( lnk ); |
338 | } | 340 | } |
339 | } | 341 | } |
340 | d->selectedFiles->setSelectedItem( currentString); | 342 | d->selectedFiles->setSelectedItem( currentString); |
341 | // d->selectedFiles->setSelectedItem( (const QString &)currentString); | 343 | // d->selectedFiles->setSelectedItem( (const QString &)currentString); |
342 | } | 344 | } |
343 | 345 | ||
344 | 346 | ||
345 | void PlayListWidget::writeConfig( Config& cfg ) const { | 347 | void PlayListWidget::writeConfig( Config& cfg ) const { |
346 | 348 | ||
347 | d->selectedFiles->writeCurrent( cfg); | 349 | d->selectedFiles->writeCurrent( cfg); |
348 | cfg.setGroup("PlayList"); | 350 | cfg.setGroup("PlayList"); |
349 | int noOfFiles = 0; | 351 | int noOfFiles = 0; |
350 | d->selectedFiles->first(); | 352 | d->selectedFiles->first(); |
351 | do { | 353 | do { |
352 | const DocLnk *lnk = d->selectedFiles->current(); | 354 | const DocLnk *lnk = d->selectedFiles->current(); |
353 | if ( lnk ) { | 355 | if ( lnk ) { |
354 | QString entryName; | 356 | QString entryName; |
355 | entryName.sprintf( "File%i", noOfFiles + 1 ); | 357 | entryName.sprintf( "File%i", noOfFiles + 1 ); |
356 | // qDebug(entryName); | 358 | // qDebug(entryName); |
357 | cfg.writeEntry( entryName, lnk->linkFile() ); | 359 | cfg.writeEntry( entryName, lnk->linkFile() ); |
358 | // 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 |
359 | // next time... | 361 | // next time... |
360 | if ( !QFile::exists( lnk->linkFile() ) ) { | 362 | if ( !QFile::exists( lnk->linkFile() ) ) { |
361 | // the way writing lnks doesn't really check for out | 363 | // the way writing lnks doesn't really check for out |
362 | // of disk space, but check it anyway. | 364 | // of disk space, but check it anyway. |
363 | if ( !lnk->writeLink() ) { | 365 | if ( !lnk->writeLink() ) { |
364 | QMessageBox::critical( 0, tr("Out of space"), | 366 | QMessageBox::critical( 0, tr("Out of space"), |
365 | tr( "There was a problem saving " | 367 | tr( "There was a problem saving " |
366 | "the playlist.\n" | 368 | "the playlist.\n" |
367 | "Your playlist " | 369 | "Your playlist " |
368 | "may be missing some entries\n" | 370 | "may be missing some entries\n" |
369 | "the next time you start it." ) | 371 | "the next time you start it." ) |
370 | ); | 372 | ); |
371 | } | 373 | } |
372 | } | 374 | } |
373 | noOfFiles++; | 375 | noOfFiles++; |
374 | } | 376 | } |
375 | } | 377 | } |
376 | while ( d->selectedFiles->next() ); | 378 | while ( d->selectedFiles->next() ); |
377 | cfg.writeEntry("NumberOfFiles", noOfFiles ); | 379 | cfg.writeEntry("NumberOfFiles", noOfFiles ); |
378 | } | 380 | } |
379 | 381 | ||
380 | 382 | ||
381 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { | 383 | void PlayListWidget::addToSelection( const DocLnk& lnk ) { |
382 | // qDebug("add"); | 384 | // qDebug("add"); |
383 | d->setDocumentUsed = FALSE; | 385 | d->setDocumentUsed = FALSE; |
384 | if ( mediaPlayerState->playlist() ) | 386 | if ( mediaPlayerState->playlist() ) |
385 | d->selectedFiles->addToSelection( lnk ); | 387 | d->selectedFiles->addToSelection( lnk ); |
386 | else | 388 | else |
387 | mediaPlayerState->setPlaying( TRUE ); | 389 | mediaPlayerState->setPlaying( TRUE ); |
388 | } | 390 | } |
389 | 391 | ||
390 | 392 | ||
391 | void PlayListWidget::clearList() { | 393 | void PlayListWidget::clearList() { |
392 | while ( first() ) | 394 | while ( first() ) |
393 | d->selectedFiles->removeSelected(); | 395 | d->selectedFiles->removeSelected(); |
394 | } | 396 | } |
395 | 397 | ||
396 | 398 | ||
397 | void PlayListWidget::addAllToList() { | 399 | void PlayListWidget::addAllToList() { |
398 | DocLnkSet filesAll; | 400 | DocLnkSet filesAll; |
399 | Global::findDocuments(&filesAll, "video/*;audio/*"); | 401 | Global::findDocuments(&filesAll, "video/*;audio/*"); |
400 | QListIterator<DocLnk> Adit( filesAll.children() ); | 402 | QListIterator<DocLnk> Adit( filesAll.children() ); |
401 | for ( ; Adit.current(); ++Adit ) | 403 | for ( ; Adit.current(); ++Adit ) |
402 | d->selectedFiles->addToSelection( **Adit ); | 404 | d->selectedFiles->addToSelection( **Adit ); |
403 | } | 405 | } |
404 | 406 | ||
405 | 407 | ||
406 | void PlayListWidget::addAllMusicToList() { | 408 | void PlayListWidget::addAllMusicToList() { |
407 | // DocLnkSet files; | 409 | // DocLnkSet files; |
408 | // Global::findDocuments(&files, "audio/*"); | 410 | // Global::findDocuments(&files, "audio/*"); |
409 | QListIterator<DocLnk> dit( files.children() ); | 411 | QListIterator<DocLnk> dit( files.children() ); |
410 | for ( ; dit.current(); ++dit ) | 412 | for ( ; dit.current(); ++dit ) |
411 | d->selectedFiles->addToSelection( **dit ); | 413 | d->selectedFiles->addToSelection( **dit ); |
412 | } | 414 | } |
413 | 415 | ||
414 | 416 | ||
415 | void PlayListWidget::addAllVideoToList() { | 417 | void PlayListWidget::addAllVideoToList() { |
416 | QListIterator<DocLnk> dit( vFiles.children() ); | 418 | QListIterator<DocLnk> dit( vFiles.children() ); |
417 | for ( ; dit.current(); ++dit ) | 419 | for ( ; dit.current(); ++dit ) |
418 | d->selectedFiles->addToSelection( **dit ); | 420 | d->selectedFiles->addToSelection( **dit ); |
419 | } | 421 | } |
420 | 422 | ||
421 | 423 | ||
422 | void PlayListWidget::setDocument(const QString& fileref) { | 424 | void PlayListWidget::setDocument(const QString& fileref) { |
425 | qDebug(fileref); | ||
423 | fromSetDocument = TRUE; | 426 | fromSetDocument = TRUE; |
424 | if ( fileref.isNull() ) { | 427 | if ( fileref.isNull() ) { |
425 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); | 428 | QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); |
426 | return; | 429 | return; |
427 | } | 430 | } |
428 | // qDebug("setDocument "+fileref); | 431 | // qDebug("setDocument "+fileref); |
429 | if(fileref.find("playlist",0,TRUE) == -1) { | 432 | if(fileref.find("m3u",0,TRUE) != -1) { //is m3u |
433 | clearList(); | ||
434 | addToSelection( DocLnk( fileref ) ); | ||
435 | d->setDocumentUsed = TRUE; | ||
436 | d->selectedFiles->first(); | ||
437 | qApp->processEvents(); | ||
438 | } | ||
439 | else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist | ||
440 | clearList(); | ||
441 | loadList(DocLnk(fileref)); | ||
442 | d->selectedFiles->first(); | ||
443 | } else { | ||
430 | clearList(); | 444 | clearList(); |
431 | addToSelection( DocLnk( fileref ) ); | 445 | addToSelection( DocLnk( fileref ) ); |
432 | d->setDocumentUsed = TRUE; | 446 | d->setDocumentUsed = TRUE; |
433 | mediaPlayerState->setPlaying( FALSE ); | 447 | mediaPlayerState->setPlaying( FALSE ); |
434 | qApp->processEvents(); | 448 | qApp->processEvents(); |
435 | mediaPlayerState->setPlaying( TRUE ); | 449 | mediaPlayerState->setPlaying( TRUE ); |
436 | qApp->processEvents(); | 450 | qApp->processEvents(); |
437 | setCaption(tr("OpiePlayer")); | 451 | setCaption(tr("OpiePlayer")); |
438 | |||
439 | } else { //is playlist | ||
440 | clearList(); | ||
441 | loadList(DocLnk(fileref)); | ||
442 | d->selectedFiles->first(); | ||
443 | } | 452 | } |
444 | } | 453 | } |
445 | 454 | ||
446 | 455 | ||
447 | void PlayListWidget::setActiveWindow() { | 456 | void PlayListWidget::setActiveWindow() { |
448 | // When we get raised we need to ensure that it switches views | 457 | // When we get raised we need to ensure that it switches views |
449 | char origView = mediaPlayerState->view(); | 458 | char origView = mediaPlayerState->view(); |
450 | mediaPlayerState->setView( 'l' ); // invalidate | 459 | mediaPlayerState->setView( 'l' ); // invalidate |
451 | mediaPlayerState->setView( origView ); // now switch back | 460 | mediaPlayerState->setView( origView ); // now switch back |
452 | } | 461 | } |
453 | 462 | ||
454 | 463 | ||
455 | void PlayListWidget::useSelectedDocument() { | 464 | void PlayListWidget::useSelectedDocument() { |
456 | d->setDocumentUsed = FALSE; | 465 | d->setDocumentUsed = FALSE; |
457 | } | 466 | } |
458 | 467 | ||
459 | 468 | ||
460 | const DocLnk *PlayListWidget::current() { // this is fugly | 469 | const DocLnk *PlayListWidget::current() { // this is fugly |
461 | 470 | ||
462 | // if( fromSetDocument) { | 471 | // if( fromSetDocument) { |
463 | // qDebug("from setDoc"); | 472 | // qDebug("from setDoc"); |
464 | // DocLnkSet files; | 473 | // DocLnkSet files; |
465 | // Global::findDocuments(&files, "video/*;audio/*"); | 474 | // Global::findDocuments(&files, "video/*;audio/*"); |
466 | // QListIterator<DocLnk> dit( files.children() ); | 475 | // QListIterator<DocLnk> dit( files.children() ); |
467 | // for ( ; dit.current(); ++dit ) { | 476 | // for ( ; dit.current(); ++dit ) { |
468 | // if(dit.current()->linkFile() == setDocFileRef) { | 477 | // if(dit.current()->linkFile() == setDocFileRef) { |
469 | // qDebug(setDocFileRef); | 478 | // qDebug(setDocFileRef); |
470 | // return dit; | 479 | // return dit; |
471 | // } | 480 | // } |
472 | // } | 481 | // } |
473 | // } else | 482 | // } else |
474 | 483 | ||
475 | 484 | ||
476 | switch (tabWidget->currentPageIndex()) { | 485 | switch (tabWidget->currentPageIndex()) { |
477 | case 0: //playlist | 486 | case 0: //playlist |
478 | { | 487 | { |
479 | qDebug("playlist"); | 488 | qDebug("playlist"); |
480 | if ( mediaPlayerState->playlist() ) { | 489 | if ( mediaPlayerState->playlist() ) { |
481 | return d->selectedFiles->current(); | 490 | return d->selectedFiles->current(); |
482 | } | 491 | } |
483 | else if ( d->setDocumentUsed && d->current ) { | 492 | else if ( d->setDocumentUsed && d->current ) { |
484 | return d->current; | 493 | return d->current; |
485 | } else { | 494 | } else { |
486 | return d->files->selected(); | 495 | return d->files->selected(); |
487 | } | 496 | } |
488 | } | 497 | } |
489 | break; | 498 | break; |
490 | case 1://audio | 499 | case 1://audio |
491 | { | 500 | { |
492 | qDebug("audioView"); | 501 | qDebug("audioView"); |
493 | // Global::findDocuments(&files, "audio/*"); | 502 | // Global::findDocuments(&files, "audio/*"); |
494 | QListIterator<DocLnk> dit( files.children() ); | 503 | QListIterator<DocLnk> dit( files.children() ); |
495 | for ( ; dit.current(); ++dit ) { | 504 | for ( ; dit.current(); ++dit ) { |
496 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { | 505 | if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { |
497 | qDebug("here"); | 506 | qDebug("here"); |
498 | insanityBool=TRUE; | 507 | insanityBool=TRUE; |
499 | return dit; | 508 | return dit; |
500 | } | 509 | } |
501 | } | 510 | } |
502 | } | 511 | } |
503 | break; | 512 | break; |
504 | case 2: // video | 513 | case 2: // video |
505 | { | 514 | { |
506 | qDebug("videoView"); | 515 | qDebug("videoView"); |
507 | // Global::findDocuments(&vFiles, "video/*"); | 516 | // Global::findDocuments(&vFiles, "video/*"); |
508 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 517 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
509 | for ( ; Vdit.current(); ++Vdit ) { | 518 | for ( ; Vdit.current(); ++Vdit ) { |
510 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { | 519 | if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { |
511 | insanityBool=TRUE; | 520 | insanityBool=TRUE; |
512 | return Vdit; | 521 | return Vdit; |
513 | } | 522 | } |
514 | } | 523 | } |
515 | } | 524 | } |
516 | break; | 525 | break; |
517 | }; | 526 | }; |
518 | return 0; | 527 | return 0; |
519 | } | 528 | } |
520 | 529 | ||
521 | bool PlayListWidget::prev() { | 530 | bool PlayListWidget::prev() { |
522 | if ( mediaPlayerState->playlist() ) { | 531 | if ( mediaPlayerState->playlist() ) { |
523 | if ( mediaPlayerState->shuffled() ) { | 532 | if ( mediaPlayerState->shuffled() ) { |
524 | const DocLnk *cur = current(); | 533 | const DocLnk *cur = current(); |
525 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); | 534 | int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); |
526 | for ( int i = 0; i < j; i++ ) { | 535 | for ( int i = 0; i < j; i++ ) { |
527 | if ( !d->selectedFiles->next() ) | 536 | if ( !d->selectedFiles->next() ) |
528 | d->selectedFiles->first(); | 537 | d->selectedFiles->first(); |
529 | } | 538 | } |
530 | if ( cur == current() ) | 539 | if ( cur == current() ) |
531 | if ( !d->selectedFiles->next() ) | 540 | if ( !d->selectedFiles->next() ) |
532 | d->selectedFiles->first(); | 541 | d->selectedFiles->first(); |
533 | return TRUE; | 542 | return TRUE; |
534 | } else { | 543 | } else { |
535 | if ( !d->selectedFiles->prev() ) { | 544 | if ( !d->selectedFiles->prev() ) { |
536 | if ( mediaPlayerState->looping() ) { | 545 | if ( mediaPlayerState->looping() ) { |
537 | return d->selectedFiles->last(); | 546 | return d->selectedFiles->last(); |
538 | } else { | 547 | } else { |
@@ -872,96 +881,125 @@ void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const | |||
872 | void PlayListWidget::listDelete() { | 881 | void PlayListWidget::listDelete() { |
873 | Config cfg( "MediaPlayer" ); | 882 | Config cfg( "MediaPlayer" ); |
874 | cfg.setGroup("PlayList"); | 883 | cfg.setGroup("PlayList"); |
875 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); | 884 | QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); |
876 | QString file; | 885 | QString file; |
877 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); | 886 | int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); |
878 | switch ( tabWidget->currentPageIndex()) { | 887 | switch ( tabWidget->currentPageIndex()) { |
879 | case 0: | 888 | case 0: |
880 | break; | 889 | break; |
881 | case 1: | 890 | case 1: |
882 | { | 891 | { |
883 | file = audioView->selectedItem()->text(0); | 892 | file = audioView->selectedItem()->text(0); |
884 | // Global::findDocuments(&files, "audio/*"); | 893 | // Global::findDocuments(&files, "audio/*"); |
885 | // AppLnkSet appFiles; | 894 | // AppLnkSet appFiles; |
886 | QListIterator<DocLnk> dit( files.children() ); | 895 | QListIterator<DocLnk> dit( files.children() ); |
887 | for ( ; dit.current(); ++dit ) { | 896 | for ( ; dit.current(); ++dit ) { |
888 | if( dit.current()->name() == file) { | 897 | if( dit.current()->name() == file) { |
889 | // qDebug(file); | 898 | // qDebug(file); |
890 | LnkProperties prop( dit.current() ); | 899 | LnkProperties prop( dit.current() ); |
891 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 900 | // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
892 | prop.showMaximized(); | 901 | prop.showMaximized(); |
893 | prop.exec(); | 902 | prop.exec(); |
894 | } | 903 | } |
895 | } | 904 | } |
896 | populateAudioView(); | 905 | populateAudioView(); |
897 | } | 906 | } |
898 | break; | 907 | break; |
899 | case 2: | 908 | case 2: |
900 | { | 909 | { |
901 | // file = videoView->selectedItem()->text(0); | 910 | // file = videoView->selectedItem()->text(0); |
902 | // for ( int i = 0; i < noOfFiles; i++ ) { | 911 | // for ( int i = 0; i < noOfFiles; i++ ) { |
903 | // QString entryName; | 912 | // QString entryName; |
904 | // entryName.sprintf( "File%i", i + 1 ); | 913 | // entryName.sprintf( "File%i", i + 1 ); |
905 | // QString linkFile = cfg.readEntry( entryName ); | 914 | // QString linkFile = cfg.readEntry( entryName ); |
906 | // AppLnk lnk( AppLnk(linkFile)); | 915 | // AppLnk lnk( AppLnk(linkFile)); |
907 | // if( lnk.name() == file ) { | 916 | // if( lnk.name() == file ) { |
908 | // LnkProperties prop( &lnk); | 917 | // LnkProperties prop( &lnk); |
909 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 918 | // // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
910 | // prop.showMaximized(); | 919 | // prop.showMaximized(); |
911 | // prop.exec(); | 920 | // prop.exec(); |
912 | // } | 921 | // } |
913 | // } | 922 | // } |
914 | } | 923 | } |
915 | break; | 924 | break; |
916 | }; | 925 | }; |
917 | } | 926 | } |
918 | 927 | ||
919 | void PlayListWidget::populateAudioView() { | 928 | void PlayListWidget::populateAudioView() { |
920 | // if(files) | 929 | // if(files) |
921 | // files.~DocLnkSet(); | 930 | // files.~DocLnkSet(); |
922 | StorageInfo storageInfo; | 931 | StorageInfo storageInfo; |
923 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 932 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
924 | 933 | ||
925 | Global::findDocuments(&files, "audio/*"); | 934 | Global::findDocuments(&files, "audio/*"); |
926 | QListIterator<DocLnk> dit( files.children() ); | 935 | QListIterator<DocLnk> dit( files.children() ); |
927 | QListIterator<FileSystem> it ( fs ); | 936 | QListIterator<FileSystem> it ( fs ); |
928 | audioView->clear(); | 937 | audioView->clear(); |
929 | QString storage; | 938 | QString storage; |
930 | for ( ; dit.current(); ++dit ) { | 939 | for ( ; dit.current(); ++dit ) { |
931 | for( ; it.current(); ++it ){ | 940 | for( ; it.current(); ++it ){ |
932 | const QString name = (*it)->name(); | 941 | const QString name = (*it)->name(); |
933 | const QString path = (*it)->path(); | 942 | const QString path = (*it)->path(); |
934 | if(dit.current()->file().find(path) != -1 ) storage=name; | 943 | if(dit.current()->file().find(path) != -1 ) storage=name; |
935 | } | 944 | } |
936 | 945 | ||
937 | QListViewItem * newItem; | 946 | QListViewItem * newItem; |
938 | if ( QFile( dit.current()->file()).exists() ) { | 947 | if ( QFile( dit.current()->file()).exists() ) { |
939 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); | 948 | newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); |
940 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); | 949 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/musicfile" )); |
941 | } | 950 | } |
942 | } | 951 | } |
943 | } | 952 | } |
944 | 953 | ||
945 | void PlayListWidget::populateVideoView() { | 954 | void PlayListWidget::populateVideoView() { |
946 | StorageInfo storageInfo; | 955 | StorageInfo storageInfo; |
947 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 956 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
948 | 957 | ||
949 | Global::findDocuments(&vFiles, "video/*"); | 958 | Global::findDocuments(&vFiles, "video/*"); |
950 | QListIterator<DocLnk> Vdit( vFiles.children() ); | 959 | QListIterator<DocLnk> Vdit( vFiles.children() ); |
951 | QListIterator<FileSystem> it ( fs ); | 960 | QListIterator<FileSystem> it ( fs ); |
952 | videoView->clear(); | 961 | videoView->clear(); |
953 | QString storage; | 962 | QString storage; |
954 | for ( ; Vdit.current(); ++Vdit ) { | 963 | for ( ; Vdit.current(); ++Vdit ) { |
955 | for( ; it.current(); ++it ){ | 964 | for( ; it.current(); ++it ){ |
956 | const QString name = (*it)->name(); | 965 | const QString name = (*it)->name(); |
957 | const QString path = (*it)->path(); | 966 | const QString path = (*it)->path(); |
958 | if( Vdit.current()->file().find(path) != -1 ) storage=name; | 967 | if( Vdit.current()->file().find(path) != -1 ) storage=name; |
959 | } | 968 | } |
960 | 969 | ||
961 | QListViewItem * newItem; | 970 | QListViewItem * newItem; |
962 | if ( QFile( Vdit.current()->file()).exists() ) { | 971 | if ( QFile( Vdit.current()->file()).exists() ) { |
963 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); | 972 | newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); |
964 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); | 973 | newItem->setPixmap(0, Resource::loadPixmap( "mpegplayer/videofile" )); |
965 | } | 974 | } |
966 | } | 975 | } |
967 | } | 976 | } |
977 | |||
978 | void PlayListWidget::openFile() { | ||
979 | QString filename; | ||
980 | InputDialog *fileDlg; | ||
981 | fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); | ||
982 | fileDlg->exec(); | ||
983 | if( fileDlg->result() == 1 ) { | ||
984 | filename = fileDlg->LineEdit1->text(); | ||
985 | } | ||
986 | qDebug(filename); | ||
987 | DocLnk lnk; | ||
988 | QString name = filename.right(filename.length()-filename.find("http://")-7); | ||
989 | lnk.setName( name); //sets file name | ||
990 | // lnk.setComment(); | ||
991 | lnk.setFile(filename); //sets File property | ||
992 | // problem is, the launcher sees this as a broken link and does not display it :( | ||
993 | |||
994 | lnk.setType("audio/x-mpegurl"); | ||
995 | lnk.setExec("opieplayer"); | ||
996 | lnk.setIcon("opieplayer/MPEGPlayer"); | ||
997 | QString cmd="touch "+QPEApplication::documentDir()+"audio/x-mpegurl/"+name; | ||
998 | system( cmd.latin1()); | ||
999 | // d->selectedFiles->addToSelection( **dit ); | ||
1000 | |||
1001 | if(!lnk.writeLink()) | ||
1002 | qDebug("Writing doclink did not work"); | ||
1003 | if(fileDlg) | ||
1004 | delete fileDlg; | ||
1005 | } | ||
diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h index 186ca1b..02cdba6 100644 --- a/core/multimedia/opieplayer/playlistwidget.h +++ b/core/multimedia/opieplayer/playlistwidget.h | |||
@@ -1,112 +1,113 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef PLAY_LIST_WIDGET_H | 20 | #ifndef PLAY_LIST_WIDGET_H |
21 | #define PLAY_LIST_WIDGET_H | 21 | #define PLAY_LIST_WIDGET_H |
22 | 22 | ||
23 | #include <qmainwindow.h> | 23 | #include <qmainwindow.h> |
24 | #include <qpe/applnk.h> | 24 | #include <qpe/applnk.h> |
25 | #include <qtabwidget.h> | 25 | #include <qtabwidget.h> |
26 | #include <qpe/fileselector.h> | 26 | #include <qpe/fileselector.h> |
27 | #include <qpushbutton.h> | 27 | #include <qpushbutton.h> |
28 | 28 | ||
29 | /* #include <qtimer.h> */ | 29 | /* #include <qtimer.h> */ |
30 | 30 | ||
31 | 31 | ||
32 | class PlayListWidgetPrivate; | 32 | class PlayListWidgetPrivate; |
33 | class Config; | 33 | class Config; |
34 | class QListViewItem; | 34 | class QListViewItem; |
35 | class QListView; | 35 | class QListView; |
36 | class QPoint; | 36 | class QPoint; |
37 | class QAction; | 37 | class QAction; |
38 | class QLabel; | 38 | class QLabel; |
39 | 39 | ||
40 | class PlayListWidget : public QMainWindow { | 40 | class PlayListWidget : public QMainWindow { |
41 | Q_OBJECT | 41 | Q_OBJECT |
42 | public: | 42 | public: |
43 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); | 43 | PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); |
44 | ~PlayListWidget(); | 44 | ~PlayListWidget(); |
45 | QTabWidget * tabWidget; | 45 | QTabWidget * tabWidget; |
46 | QAction *fullScreenButton, *scaleButton; | 46 | QAction *fullScreenButton, *scaleButton; |
47 | DocLnkSet files; | 47 | DocLnkSet files; |
48 | DocLnkSet vFiles; | 48 | DocLnkSet vFiles; |
49 | QListView *audioView, *videoView, *playlistView; | 49 | QListView *audioView, *videoView, *playlistView; |
50 | QLabel *libString; | 50 | QLabel *libString; |
51 | bool fromSetDocument; | 51 | bool fromSetDocument; |
52 | bool insanityBool; | 52 | bool insanityBool; |
53 | QString setDocFileRef; | 53 | QString setDocFileRef; |
54 | // retrieve the current playlist entry (media file link) | 54 | // retrieve the current playlist entry (media file link) |
55 | const DocLnk *current(); | 55 | const DocLnk *current(); |
56 | void useSelectedDocument(); | 56 | void useSelectedDocument(); |
57 | /* QTimer * menuTimer; */ | 57 | /* QTimer * menuTimer; */ |
58 | FileSelector* playLists; | 58 | FileSelector* playLists; |
59 | QPushButton *tbDeletePlaylist; | 59 | QPushButton *tbDeletePlaylist; |
60 | public slots: | 60 | public slots: |
61 | bool first(); | 61 | bool first(); |
62 | bool last(); | 62 | bool last(); |
63 | bool next(); | 63 | bool next(); |
64 | bool prev(); | 64 | bool prev(); |
65 | /* void setFullScreen(); */ | 65 | /* void setFullScreen(); */ |
66 | /* void setScaled(); */ | 66 | /* void setScaled(); */ |
67 | protected: | 67 | protected: |
68 | /* void contentsMousePressEvent( QMouseEvent * e ); */ | 68 | /* void contentsMousePressEvent( QMouseEvent * e ); */ |
69 | /* void contentsMouseReleaseEvent( QMouseEvent * e ); */ | 69 | /* void contentsMouseReleaseEvent( QMouseEvent * e ); */ |
70 | 70 | ||
71 | private: | 71 | private: |
72 | void initializeStates(); | 72 | void initializeStates(); |
73 | void readConfig( Config& cfg ); | 73 | void readConfig( Config& cfg ); |
74 | void writeConfig( Config& cfg ) const; | 74 | void writeConfig( Config& cfg ) const; |
75 | PlayListWidgetPrivate *d; // Private implementation data | 75 | PlayListWidgetPrivate *d; // Private implementation data |
76 | void populateAudioView(); | 76 | void populateAudioView(); |
77 | void populateVideoView(); | 77 | void populateVideoView(); |
78 | private slots: | 78 | private slots: |
79 | void openFile(); | ||
79 | void setDocument( const QString& fileref ); | 80 | void setDocument( const QString& fileref ); |
80 | void addToSelection( const DocLnk& ); // Add a media file to the playlist | 81 | void addToSelection( const DocLnk& ); // Add a media file to the playlist |
81 | void addToSelection( QListViewItem* ); // Add a media file to the playlist | 82 | void addToSelection( QListViewItem* ); // Add a media file to the playlist |
82 | void setActiveWindow(); // need to handle this to show the right view | 83 | void setActiveWindow(); // need to handle this to show the right view |
83 | void setPlaylist( bool ); // Show/Hide the playlist | 84 | void setPlaylist( bool ); // Show/Hide the playlist |
84 | void setView( char ); | 85 | void setView( char ); |
85 | void clearList(); | 86 | void clearList(); |
86 | void addAllToList(); | 87 | void addAllToList(); |
87 | void addAllMusicToList(); | 88 | void addAllMusicToList(); |
88 | void addAllVideoToList(); | 89 | void addAllVideoToList(); |
89 | void saveList(); // Save the playlist | 90 | void saveList(); // Save the playlist |
90 | void loadList( const DocLnk &); // Load a playlist | 91 | void loadList( const DocLnk &); // Load a playlist |
91 | void playIt( QListViewItem *); | 92 | void playIt( QListViewItem *); |
92 | 93 | ||
93 | void btnPlay(bool); | 94 | void btnPlay(bool); |
94 | void deletePlaylist(); | 95 | void deletePlaylist(); |
95 | void addSelected(); | 96 | void addSelected(); |
96 | void removeSelected(); | 97 | void removeSelected(); |
97 | void tabChanged(QWidget*); | 98 | void tabChanged(QWidget*); |
98 | void viewPressed( int, QListViewItem *, const QPoint&, int); | 99 | void viewPressed( int, QListViewItem *, const QPoint&, int); |
99 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); | 100 | void playlistViewPressed( int, QListViewItem *, const QPoint&, int); |
100 | void playSelected(); | 101 | void playSelected(); |
101 | void listDelete(); | 102 | void listDelete(); |
102 | 103 | ||
103 | protected slots: | 104 | protected slots: |
104 | /* void cancelMenuTimer(); */ | 105 | /* void cancelMenuTimer(); */ |
105 | /* void showFileMenu(); */ | 106 | /* void showFileMenu(); */ |
106 | 107 | ||
107 | 108 | ||
108 | }; | 109 | }; |
109 | 110 | ||
110 | 111 | ||
111 | #endif // PLAY_LIST_WIDGET_H | 112 | #endif // PLAY_LIST_WIDGET_H |
112 | 113 | ||