summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-04-20 18:53:33 (UTC)
committer llornkcor <llornkcor>2002-04-20 18:53:33 (UTC)
commitb8bdd6ceaab890f8b35492a11e13bcdb101b1220 (patch) (unidiff)
tree1ba128f600c5b0e5f2b0dce459b77270287e59ca
parent703c9c483b5e3fa6d2090398d6ee3a5638326b02 (diff)
downloadopie-b8bdd6ceaab890f8b35492a11e13bcdb101b1220.zip
opie-b8bdd6ceaab890f8b35492a11e13bcdb101b1220.tar.gz
opie-b8bdd6ceaab890f8b35492a11e13bcdb101b1220.tar.bz2
changed MediaPlayer to OpiePlayer in config stuff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/mediaplayerstate.cpp4
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp12
2 files changed, 8 insertions, 8 deletions
diff --git a/core/multimedia/opieplayer/mediaplayerstate.cpp b/core/multimedia/opieplayer/mediaplayerstate.cpp
index a960c49..4e14436 100644
--- a/core/multimedia/opieplayer/mediaplayerstate.cpp
+++ b/core/multimedia/opieplayer/mediaplayerstate.cpp
@@ -1,116 +1,116 @@
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#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21#include <qpe/qlibrary.h> 21#include <qpe/qlibrary.h>
22#include <qpe/config.h> 22#include <qpe/config.h>
23#include <qvaluelist.h> 23#include <qvaluelist.h>
24#include <qobject.h> 24#include <qobject.h>
25#include <qdir.h> 25#include <qdir.h>
26#include <qpe/mediaplayerplugininterface.h> 26#include <qpe/mediaplayerplugininterface.h>
27#include "mediaplayerstate.h" 27#include "mediaplayerstate.h"
28 28
29 29
30 30
31#ifdef QT_NO_COMPONENT 31#ifdef QT_NO_COMPONENT
32// Plugins which are compiled in when no plugin architecture available 32// Plugins which are compiled in when no plugin architecture available
33#include "libmad/libmadpluginimpl.h" 33#include "libmad/libmadpluginimpl.h"
34#include "libmpeg3/libmpeg3pluginimpl.h" 34#include "libmpeg3/libmpeg3pluginimpl.h"
35#include "wavplugin/wavpluginimpl.h" 35#include "wavplugin/wavpluginimpl.h"
36#endif 36#endif
37 37
38 38
39//#define MediaPlayerDebug(x) qDebug x 39//#define MediaPlayerDebug(x) qDebug x
40#define MediaPlayerDebug(x) 40#define MediaPlayerDebug(x)
41 41
42 42
43MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) 43MediaPlayerState::MediaPlayerState( QObject *parent, const char *name )
44 : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) { 44 : QObject( parent, name ), decoder( NULL ), libmpeg3decoder( NULL ) {
45 Config cfg( "MediaPlayer" ); 45 Config cfg( "OpiePlayer" );
46 readConfig( cfg ); 46 readConfig( cfg );
47 loadPlugins(); 47 loadPlugins();
48} 48}
49 49
50 50
51MediaPlayerState::~MediaPlayerState() { 51MediaPlayerState::~MediaPlayerState() {
52 Config cfg( "MediaPlayer" ); 52 Config cfg( "OpiePlayer" );
53 writeConfig( cfg ); 53 writeConfig( cfg );
54} 54}
55 55
56 56
57void MediaPlayerState::readConfig( Config& cfg ) { 57void MediaPlayerState::readConfig( Config& cfg ) {
58 cfg.setGroup("Options"); 58 cfg.setGroup("Options");
59 isFullscreen = cfg.readBoolEntry( "FullScreen" ); 59 isFullscreen = cfg.readBoolEntry( "FullScreen" );
60 isScaled = cfg.readBoolEntry( "Scaling" ); 60 isScaled = cfg.readBoolEntry( "Scaling" );
61 isLooping = cfg.readBoolEntry( "Looping" ); 61 isLooping = cfg.readBoolEntry( "Looping" );
62 isShuffled = cfg.readBoolEntry( "Shuffle" ); 62 isShuffled = cfg.readBoolEntry( "Shuffle" );
63 usePlaylist = cfg.readBoolEntry( "UsePlayList" ); 63 usePlaylist = cfg.readBoolEntry( "UsePlayList" );
64 usePlaylist = TRUE; 64 usePlaylist = TRUE;
65 isPlaying = FALSE; 65 isPlaying = FALSE;
66 isPaused = FALSE; 66 isPaused = FALSE;
67 curPosition = 0; 67 curPosition = 0;
68 curLength = 0; 68 curLength = 0;
69 curView = 'l'; 69 curView = 'l';
70} 70}
71 71
72 72
73void MediaPlayerState::writeConfig( Config& cfg ) const { 73void MediaPlayerState::writeConfig( Config& cfg ) const {
74 cfg.setGroup("Options"); 74 cfg.setGroup("Options");
75 cfg.writeEntry("FullScreen", isFullscreen ); 75 cfg.writeEntry("FullScreen", isFullscreen );
76 cfg.writeEntry("Scaling", isScaled ); 76 cfg.writeEntry("Scaling", isScaled );
77 cfg.writeEntry("Looping", isLooping ); 77 cfg.writeEntry("Looping", isLooping );
78 cfg.writeEntry("Shuffle", isShuffled ); 78 cfg.writeEntry("Shuffle", isShuffled );
79 cfg.writeEntry("UsePlayList", usePlaylist ); 79 cfg.writeEntry("UsePlayList", usePlaylist );
80} 80}
81 81
82 82
83struct MediaPlayerPlugin { 83struct MediaPlayerPlugin {
84#ifndef QT_NO_COMPONENT 84#ifndef QT_NO_COMPONENT
85 QLibrary *library; 85 QLibrary *library;
86#endif 86#endif
87 MediaPlayerPluginInterface *iface; 87 MediaPlayerPluginInterface *iface;
88 MediaPlayerDecoder *decoder; 88 MediaPlayerDecoder *decoder;
89 MediaPlayerEncoder *encoder; 89 MediaPlayerEncoder *encoder;
90}; 90};
91 91
92 92
93static QValueList<MediaPlayerPlugin> pluginList; 93static QValueList<MediaPlayerPlugin> pluginList;
94 94
95 95
96// Find the first decoder which supports this type of file 96// Find the first decoder which supports this type of file
97MediaPlayerDecoder *MediaPlayerState::newDecoder( const QString& file ) { 97MediaPlayerDecoder *MediaPlayerState::newDecoder( const QString& file ) {
98 MediaPlayerDecoder *tmpDecoder = NULL; 98 MediaPlayerDecoder *tmpDecoder = NULL;
99 QValueList<MediaPlayerPlugin>::Iterator it; 99 QValueList<MediaPlayerPlugin>::Iterator it;
100 for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { 100 for ( it = pluginList.begin(); it != pluginList.end(); ++it ) {
101 if ( (*it).decoder->isFileSupported( file ) ) { 101 if ( (*it).decoder->isFileSupported( file ) ) {
102 tmpDecoder = (*it).decoder; 102 tmpDecoder = (*it).decoder;
103 break; 103 break;
104 } 104 }
105 } 105 }
106 return decoder = tmpDecoder; 106 return decoder = tmpDecoder;
107} 107}
108 108
109 109
110MediaPlayerDecoder *MediaPlayerState::curDecoder() { 110MediaPlayerDecoder *MediaPlayerState::curDecoder() {
111 return decoder; 111 return decoder;
112} 112}
113 113
114 114
115// ### hack to get true sample count 115// ### hack to get true sample count
116MediaPlayerDecoder *MediaPlayerState::libMpeg3Decoder() { 116MediaPlayerDecoder *MediaPlayerState::libMpeg3Decoder() {
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 4b1ff22..218fd49 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -228,141 +228,141 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
228 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 228 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
229 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 229 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
230 230
231 231
232// audioView 232// audioView
233 populateAudioView(); 233 populateAudioView();
234// videowidget 234// videowidget
235 235
236 QWidget *vTab; 236 QWidget *vTab;
237 vTab = new QWidget( tabWidget, "vTab" ); 237 vTab = new QWidget( tabWidget, "vTab" );
238 videoView = new QListView( vTab, "Videoview" ); 238 videoView = new QListView( vTab, "Videoview" );
239 videoView->setMinimumSize(233,260); 239 videoView->setMinimumSize(233,260);
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->setMultiSelection( TRUE ); 247// videoView->setMultiSelection( TRUE );
248// videoView->setSelectionMode( QListView::Extended); 248// videoView->setSelectionMode( QListView::Extended);
249 249
250 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); 250 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold);
251 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 251 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
252 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 252 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
253 253
254 tabWidget->insertTab( vTab,tr("Video")); 254 tabWidget->insertTab( vTab,tr("Video"));
255populateVideoView(); 255populateVideoView();
256 256
257//playlists list 257//playlists list
258 QWidget *LTab; 258 QWidget *LTab;
259 LTab = new QWidget( tabWidget, "LTab" ); 259 LTab = new QWidget( tabWidget, "LTab" );
260 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy 260 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy
261 playLists->setMinimumSize(233,260);; 261 playLists->setMinimumSize(233,260);;
262 tabWidget->insertTab(LTab,tr("Lists")); 262 tabWidget->insertTab(LTab,tr("Lists"));
263 263
264 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); 264 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
265// connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); 265// connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) );
266 266
267 267
268// add the library area 268// add the library area
269 269
270// connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), 270// connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)),
271// this, SLOT( fauxPlay( QListViewItem *) ) ); 271// this, SLOT( fauxPlay( QListViewItem *) ) );
272// connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), 272// connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)),
273// this, SLOT( fauxPlay( QListViewItem *)) ); 273// this, SLOT( fauxPlay( QListViewItem *)) );
274 274
275// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); 275// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) );
276// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); 276// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) );
277 277
278 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 278 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
279 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 279 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
280 280
281 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); 281 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
282 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 282 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
283 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); 283 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
284 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 284 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
285 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 285 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
286 286
287 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 287 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
288// connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); 288// connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) );
289 289
290 setCentralWidget( vbox5 ); 290 setCentralWidget( vbox5 );
291 291
292 Config cfg( "MediaPlayer" ); 292 Config cfg( "OpiePlayer" );
293 readConfig( cfg ); 293 readConfig( cfg );
294 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 294 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
295// qDebug("currentList is "+currentPlaylist); 295// qDebug("currentList is "+currentPlaylist);
296 loadList(DocLnk( currentPlaylist)); 296 loadList(DocLnk( currentPlaylist));
297 setCaption(tr("OpiePlayer: ")+ currentPlaylist ); 297 setCaption(tr("OpiePlayer: ")+ currentPlaylist );
298 298
299 initializeStates(); 299 initializeStates();
300} 300}
301 301
302 302
303PlayListWidget::~PlayListWidget() { 303PlayListWidget::~PlayListWidget() {
304 Config cfg( "MediaPlayer" ); 304 Config cfg( "OpiePlayer" );
305 writeConfig( cfg ); 305 writeConfig( cfg );
306 306
307 307
308 if ( d->current ) 308 if ( d->current )
309 delete d->current; 309 delete d->current;
310 delete d; 310 delete d;
311} 311}
312 312
313 313
314void PlayListWidget::initializeStates() { 314void PlayListWidget::initializeStates() {
315 315
316 d->tbPlay->setOn( mediaPlayerState->playing() ); 316 d->tbPlay->setOn( mediaPlayerState->playing() );
317 d->tbLoop->setOn( mediaPlayerState->looping() ); 317 d->tbLoop->setOn( mediaPlayerState->looping() );
318 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 318 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
319// d->tbFull->setOn( mediaPlayerState->fullscreen() ); 319// d->tbFull->setOn( mediaPlayerState->fullscreen() );
320// d->tbScale->setOn( mediaPlayerState->scaled() ); 320// d->tbScale->setOn( mediaPlayerState->scaled() );
321// d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); 321// d->tbScale->setEnabled( mediaPlayerState->fullscreen() );
322// setPlaylist( mediaPlayerState->playlist() ); 322// setPlaylist( mediaPlayerState->playlist() );
323 setPlaylist( true); 323 setPlaylist( true);
324// d->selectedFiles->first(); 324// d->selectedFiles->first();
325 325
326} 326}
327 327
328 328
329void PlayListWidget::readConfig( Config& cfg ) { 329void 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 DocLnk lnk( linkFile ); 337 DocLnk lnk( linkFile );
338 if ( lnk.isValid() ) { 338 if ( lnk.isValid() ) {
339 d->selectedFiles->addToSelection( lnk ); 339 d->selectedFiles->addToSelection( lnk );
340 } 340 }
341 } 341 }
342 d->selectedFiles->setSelectedItem( currentString); 342 d->selectedFiles->setSelectedItem( currentString);
343// d->selectedFiles->setSelectedItem( (const QString &)currentString); 343// d->selectedFiles->setSelectedItem( (const QString &)currentString);
344} 344}
345 345
346 346
347void PlayListWidget::writeConfig( Config& cfg ) const { 347void PlayListWidget::writeConfig( Config& cfg ) const {
348 348
349 d->selectedFiles->writeCurrent( cfg); 349 d->selectedFiles->writeCurrent( cfg);
350 cfg.setGroup("PlayList"); 350 cfg.setGroup("PlayList");
351 int noOfFiles = 0; 351 int noOfFiles = 0;
352 d->selectedFiles->first(); 352 d->selectedFiles->first();
353 do { 353 do {
354 const DocLnk *lnk = d->selectedFiles->current(); 354 const DocLnk *lnk = d->selectedFiles->current();
355 if ( lnk ) { 355 if ( lnk ) {
356 QString entryName; 356 QString entryName;
357 entryName.sprintf( "File%i", noOfFiles + 1 ); 357 entryName.sprintf( "File%i", noOfFiles + 1 );
358// qDebug(entryName); 358// qDebug(entryName);
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"
@@ -564,172 +564,172 @@ bool PlayListWidget::next() {
564 if ( !d->selectedFiles->next() ) { 564 if ( !d->selectedFiles->next() ) {
565 if ( mediaPlayerState->looping() ) { 565 if ( mediaPlayerState->looping() ) {
566 return d->selectedFiles->first(); 566 return d->selectedFiles->first();
567 } else { 567 } else {
568 return FALSE; 568 return FALSE;
569 } 569 }
570 } 570 }
571 return TRUE; 571 return TRUE;
572 } 572 }
573 } else { 573 } else {
574 return mediaPlayerState->looping(); 574 return mediaPlayerState->looping();
575 } 575 }
576} 576}
577 577
578 578
579bool PlayListWidget::first() { 579bool PlayListWidget::first() {
580 if ( mediaPlayerState->playlist() ) 580 if ( mediaPlayerState->playlist() )
581 return d->selectedFiles->first(); 581 return d->selectedFiles->first();
582 else 582 else
583 return mediaPlayerState->looping(); 583 return mediaPlayerState->looping();
584} 584}
585 585
586 586
587bool PlayListWidget::last() { 587bool PlayListWidget::last() {
588 if ( mediaPlayerState->playlist() ) 588 if ( mediaPlayerState->playlist() )
589 return d->selectedFiles->last(); 589 return d->selectedFiles->last();
590 else 590 else
591 return mediaPlayerState->looping(); 591 return mediaPlayerState->looping();
592} 592}
593 593
594 594
595void PlayListWidget::saveList() { 595void PlayListWidget::saveList() {
596 596
597 QString filename; 597 QString filename;
598 InputDialog *fileDlg; 598 InputDialog *fileDlg;
599 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); 599 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0);
600 fileDlg->exec(); 600 fileDlg->exec();
601 if( fileDlg->result() == 1 ) { 601 if( fileDlg->result() == 1 ) {
602 if ( d->current ) 602 if ( d->current )
603 delete d->current; 603 delete d->current;
604 filename = fileDlg->LineEdit1->text();//+".playlist"; 604 filename = fileDlg->LineEdit1->text();//+".playlist";
605// qDebug("saving playlist "+filename+".playlist"); 605// qDebug("saving playlist "+filename+".playlist");
606 Config cfg( filename +".playlist"); 606 Config cfg( filename +".playlist");
607 writeConfig( cfg ); 607 writeConfig( cfg );
608 608
609// qDebug("same name so delete lnk??"); 609// qDebug("same name so delete lnk??");
610// if( playLists->selected()->name() == filename) { 610// if( playLists->selected()->name() == filename) {
611 611
612// qDebug("same name so delete lnk"); 612// qDebug("same name so delete lnk");
613// QFile().remove(playLists->selected()->file()); 613// QFile().remove(playLists->selected()->file());
614// QFile().remove(playLists->selected()->linkFile()); 614// QFile().remove(playLists->selected()->linkFile());
615// playLists->reread(); 615// playLists->reread();
616// } 616// }
617// qDebug("new doclnk"); 617// qDebug("new doclnk");
618 DocLnk lnk; 618 DocLnk lnk;
619// lnk.setComment( ""); 619// lnk.setComment( "");
620 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property 620 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property
621 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D 621 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D
622 lnk.setIcon("mpegplayer/playlist2"); 622 lnk.setIcon("mpegplayer/playlist2");
623 lnk.setName( filename); //sets file name 623 lnk.setName( filename); //sets file name
624// qDebug(filename); 624// qDebug(filename);
625 if(!lnk.writeLink()) 625 if(!lnk.writeLink())
626 qDebug("Writing doclink did not work"); 626 qDebug("Writing doclink did not work");
627 } 627 }
628 Config config( "MediaPlayer" ); 628 Config config( "OpiePlayer" );
629 config.writeEntry("CurrentPlaylist",filename); 629 config.writeEntry("CurrentPlaylist",filename);
630 setCaption(tr("OpiePlayer: ")+filename); 630 setCaption(tr("OpiePlayer: ")+filename);
631 d->selectedFiles->first(); 631 d->selectedFiles->first();
632 if(fileDlg) 632 if(fileDlg)
633 delete fileDlg; 633 delete fileDlg;
634} 634}
635 635
636void PlayListWidget::loadList( const DocLnk & lnk) { 636void PlayListWidget::loadList( const DocLnk & lnk) {
637 QString name= lnk.name(); 637 QString name= lnk.name();
638// qDebug("currentList is "+name); 638// qDebug("currentList is "+name);
639 if( name.length()>1) { 639 if( name.length()>1) {
640 setCaption("OpiePlayer: "+name); 640 setCaption("OpiePlayer: "+name);
641// qDebug("load list "+ name+".playlist"); 641// qDebug("load list "+ name+".playlist");
642 clearList(); 642 clearList();
643 Config cfg( name+".playlist"); 643 Config cfg( name+".playlist");
644 readConfig(cfg); 644 readConfig(cfg);
645 645
646 tabWidget->setCurrentPage(0); 646 tabWidget->setCurrentPage(0);
647 647
648 Config config( "MediaPlayer" ); 648 Config config( "OpiePlayer" );
649 config.writeEntry("CurrentPlaylist", name); 649 config.writeEntry("CurrentPlaylist", name);
650// d->selectedFiles->first(); 650// d->selectedFiles->first();
651 } 651 }
652 652
653} 653}
654 654
655void PlayListWidget::setPlaylist( bool shown ) { 655void PlayListWidget::setPlaylist( bool shown ) {
656 if ( shown ) 656 if ( shown )
657 d->playListFrame->show(); 657 d->playListFrame->show();
658 else 658 else
659 d->playListFrame->hide(); 659 d->playListFrame->hide();
660} 660}
661 661
662void PlayListWidget::setView( char view ) { 662void PlayListWidget::setView( char view ) {
663 if ( view == 'l' ) 663 if ( view == 'l' )
664 showMaximized(); 664 showMaximized();
665 else 665 else
666 hide(); 666 hide();
667} 667}
668 668
669void PlayListWidget::addSelected() { 669void PlayListWidget::addSelected() {
670 670
671 Config cfg( "MediaPlayer" ); 671 Config cfg( "OpiePlayer" );
672 cfg.setGroup("PlayList"); 672 cfg.setGroup("PlayList");
673 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 673 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
674 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 674 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
675 675
676 switch (tabWidget->currentPageIndex()) { 676 switch (tabWidget->currentPageIndex()) {
677 case 0: //playlist 677 case 0: //playlist
678 break; 678 break;
679 case 1: { //audio 679 case 1: { //audio
680 for ( int i = 0; i < noOfFiles; i++ ) { 680 for ( int i = 0; i < noOfFiles; i++ ) {
681 QString entryName; 681 QString entryName;
682 entryName.sprintf( "File%i", i + 1 ); 682 entryName.sprintf( "File%i", i + 1 );
683 QString linkFile = cfg.readEntry( entryName ); 683 QString linkFile = cfg.readEntry( entryName );
684 if( DocLnk( linkFile).name() == audioView->selectedItem()->text(0) ) { 684 if( DocLnk( linkFile).name() == audioView->selectedItem()->text(0) ) {
685 int result= QMessageBox::warning(this,tr("OpiePlayer"), 685 int result= QMessageBox::warning(this,tr("OpiePlayer"),
686 tr("This is all ready in your playlist.\nContinue?"), 686 tr("This is all ready in your playlist.\nContinue?"),
687 tr("Yes"),tr("No"),0,0,1); 687 tr("Yes"),tr("No"),0,0,1);
688 if (result !=0) 688 if (result !=0)
689 return; 689 return;
690 } 690 }
691 } 691 }
692 addToSelection( audioView->selectedItem() ); 692 addToSelection( audioView->selectedItem() );
693 tabWidget->setCurrentPage(1); 693 tabWidget->setCurrentPage(1);
694 } 694 }
695 break; 695 break;
696 case 2: { // video 696 case 2: { // video
697 for ( int i = 0; i < noOfFiles; i++ ) { 697 for ( int i = 0; i < noOfFiles; i++ ) {
698 QString entryName; 698 QString entryName;
699 entryName.sprintf( "File%i", i + 1 ); 699 entryName.sprintf( "File%i", i + 1 );
700 QString linkFile = cfg.readEntry( entryName ); 700 QString linkFile = cfg.readEntry( entryName );
701 if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { 701 if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) {
702 int result= QMessageBox::warning(this,tr("OpiePlayer"), 702 int result= QMessageBox::warning(this,tr("OpiePlayer"),
703 tr("This is all ready in your playlist.\nContinue?"), 703 tr("This is all ready in your playlist.\nContinue?"),
704 tr("Yes"),tr("No"),0,0,1); 704 tr("Yes"),tr("No"),0,0,1);
705 if (result !=0) 705 if (result !=0)
706 return; 706 return;
707 } 707 }
708 } 708 }
709 addToSelection( videoView->selectedItem() ); 709 addToSelection( videoView->selectedItem() );
710 tabWidget->setCurrentPage(2); 710 tabWidget->setCurrentPage(2);
711 } 711 }
712 break; 712 break;
713 }; 713 };
714} 714}
715 715
716void PlayListWidget::removeSelected() { 716void PlayListWidget::removeSelected() {
717 d->selectedFiles->removeSelected( ); 717 d->selectedFiles->removeSelected( );
718} 718}
719 719
720void PlayListWidget::playIt( QListViewItem *it) { 720void PlayListWidget::playIt( QListViewItem *it) {
721// d->setDocumentUsed = FALSE; 721// d->setDocumentUsed = FALSE;
722 mediaPlayerState->setPlaying(TRUE); 722 mediaPlayerState->setPlaying(TRUE);
723} 723}
724 724
725void PlayListWidget::addToSelection( QListViewItem *it) { 725void PlayListWidget::addToSelection( QListViewItem *it) {
726 d->setDocumentUsed = FALSE; 726 d->setDocumentUsed = FALSE;
727 727
728 if(it) { 728 if(it) {
729 switch (tabWidget->currentPageIndex()) { 729 switch (tabWidget->currentPageIndex()) {
730 case 1: { 730 case 1: {
731 QListIterator<DocLnk> dit( files.children() ); 731 QListIterator<DocLnk> dit( files.children() );
732 for ( ; dit.current(); ++dit ) { 732 for ( ; dit.current(); ++dit ) {
733 if( dit.current()->name() == it->text(0)) { 733 if( dit.current()->name() == it->text(0)) {
734 d->selectedFiles->addToSelection( **dit ); 734 d->selectedFiles->addToSelection( **dit );
735 } 735 }
@@ -818,129 +818,129 @@ void PlayListWidget::btnPlay(bool b) {
818 d->selectedFiles->removeSelected( ); 818 d->selectedFiles->removeSelected( );
819 tabWidget->setCurrentPage(2); 819 tabWidget->setCurrentPage(2);
820 d->selectedFiles->unSelect(); 820 d->selectedFiles->unSelect();
821// videoView->clearSelection(); 821// videoView->clearSelection();
822 } 822 }
823 break; 823 break;
824 }; 824 };
825} 825}
826 826
827void PlayListWidget::deletePlaylist() { 827void PlayListWidget::deletePlaylist() {
828 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 828 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
829 (tr("You really want to delete\nthis playlist?")), 829 (tr("You really want to delete\nthis playlist?")),
830 (tr("Yes")), (tr("No")), 0 )){ 830 (tr("Yes")), (tr("No")), 0 )){
831 case 0: // Yes clicked, 831 case 0: // Yes clicked,
832 QFile().remove(playLists->selected()->file()); 832 QFile().remove(playLists->selected()->file());
833 QFile().remove(playLists->selected()->linkFile()); 833 QFile().remove(playLists->selected()->linkFile());
834 playLists->reread(); 834 playLists->reread();
835 break; 835 break;
836 case 1: // Cancel 836 case 1: // Cancel
837 break; 837 break;
838 }; 838 };
839 839
840} 840}
841 841
842void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) 842void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i)
843{ 843{
844 switch (mouse) { 844 switch (mouse) {
845 case 1: 845 case 1:
846 break; 846 break;
847 case 2:{ 847 case 2:{
848 QPopupMenu m; 848 QPopupMenu m;
849 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 849 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
850 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 850 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
851 m.insertSeparator(); 851 m.insertSeparator();
852 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 852 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
853 m.exec( QCursor::pos() ); 853 m.exec( QCursor::pos() );
854 } 854 }
855 break; 855 break;
856 }; 856 };
857} 857}
858 858
859void PlayListWidget::playSelected() 859void PlayListWidget::playSelected()
860{ 860{
861 btnPlay( TRUE); 861 btnPlay( TRUE);
862} 862}
863 863
864void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) 864void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i)
865{ 865{
866 switch (mouse) { 866 switch (mouse) {
867 case 1: 867 case 1:
868 break; 868 break;
869 case 2:{ 869 case 2:{
870 QPopupMenu m; 870 QPopupMenu m;
871 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 871 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
872 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 872 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
873// m.insertSeparator(); 873// m.insertSeparator();
874 m.exec( QCursor::pos() ); 874 m.exec( QCursor::pos() );
875 } 875 }
876 break; 876 break;
877 }; 877 };
878 878
879} 879}
880 880
881void PlayListWidget::listDelete() { 881void PlayListWidget::listDelete() {
882 Config cfg( "MediaPlayer" ); 882 Config cfg( "OpiePlayer" );
883 cfg.setGroup("PlayList"); 883 cfg.setGroup("PlayList");
884 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 884 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
885 QString file; 885 QString file;
886 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 886 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
887 switch ( tabWidget->currentPageIndex()) { 887 switch ( tabWidget->currentPageIndex()) {
888 case 0: 888 case 0:
889 break; 889 break;
890 case 1: 890 case 1:
891 { 891 {
892 file = audioView->selectedItem()->text(0); 892 file = audioView->selectedItem()->text(0);
893// Global::findDocuments(&files, "audio/*"); 893// Global::findDocuments(&files, "audio/*");
894// AppLnkSet appFiles; 894// AppLnkSet appFiles;
895 QListIterator<DocLnk> dit( files.children() ); 895 QListIterator<DocLnk> dit( files.children() );
896 for ( ; dit.current(); ++dit ) { 896 for ( ; dit.current(); ++dit ) {
897 if( dit.current()->name() == file) { 897 if( dit.current()->name() == file) {
898// qDebug(file); 898// qDebug(file);
899 LnkProperties prop( dit.current() ); 899 LnkProperties prop( dit.current() );
900// connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 900// connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
901 prop.showMaximized(); 901 prop.showMaximized();
902 prop.exec(); 902 prop.exec();
903 } 903 }
904 } 904 }
905 populateAudioView(); 905 populateAudioView();
906 } 906 }
907 break; 907 break;
908 case 2: 908 case 2:
909 { 909 {
910// file = videoView->selectedItem()->text(0); 910// file = videoView->selectedItem()->text(0);
911// for ( int i = 0; i < noOfFiles; i++ ) { 911// for ( int i = 0; i < noOfFiles; i++ ) {
912// QString entryName; 912// QString entryName;
913// entryName.sprintf( "File%i", i + 1 ); 913// entryName.sprintf( "File%i", i + 1 );
914// QString linkFile = cfg.readEntry( entryName ); 914// QString linkFile = cfg.readEntry( entryName );
915// AppLnk lnk( AppLnk(linkFile)); 915// AppLnk lnk( AppLnk(linkFile));
916// if( lnk.name() == file ) { 916// if( lnk.name() == file ) {
917// LnkProperties prop( &lnk); 917// LnkProperties prop( &lnk);
918// // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 918// // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
919// prop.showMaximized(); 919// prop.showMaximized();
920// prop.exec(); 920// prop.exec();
921// } 921// }
922// } 922// }
923 } 923 }
924 break; 924 break;
925 }; 925 };
926} 926}
927 927
928void PlayListWidget::populateAudioView() { 928void PlayListWidget::populateAudioView() {
929// if(files) 929// if(files)
930// files.~DocLnkSet(); 930// files.~DocLnkSet();
931 StorageInfo storageInfo; 931 StorageInfo storageInfo;
932 const QList<FileSystem> &fs = storageInfo.fileSystems(); 932 const QList<FileSystem> &fs = storageInfo.fileSystems();
933 933
934 Global::findDocuments(&files, "audio/*"); 934 Global::findDocuments(&files, "audio/*");
935 QListIterator<DocLnk> dit( files.children() ); 935 QListIterator<DocLnk> dit( files.children() );
936 QListIterator<FileSystem> it ( fs ); 936 QListIterator<FileSystem> it ( fs );
937 audioView->clear(); 937 audioView->clear();
938 QString storage; 938 QString storage;
939 for ( ; dit.current(); ++dit ) { 939 for ( ; dit.current(); ++dit ) {
940 for( ; it.current(); ++it ){ 940 for( ; it.current(); ++it ){
941 const QString name = (*it)->name(); 941 const QString name = (*it)->name();
942 const QString path = (*it)->path(); 942 const QString path = (*it)->path();
943 if(dit.current()->file().find(path) != -1 ) storage=name; 943 if(dit.current()->file().find(path) != -1 ) storage=name;
944 } 944 }
945 945
946 QListViewItem * newItem; 946 QListViewItem * newItem;