summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp45
1 files changed, 29 insertions, 16 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 8b25a4c..30e4daa 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -1,217 +1,217 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20// code added by L. J. Potter Sat 03-02-2002 06:17:54 20// code added by L. J. Potter Sat 03-02-2002 06:17:54
21#define QTOPIA_INTERNAL_FSLP 21#define QTOPIA_INTERNAL_FSLP
22#include <qpe/qcopenvelope_qws.h> 22#include <qpe/qcopenvelope_qws.h>
23 23
24#include <qpe/qpemenubar.h> 24#include <qpe/qpemenubar.h>
25#include <qpe/qpetoolbar.h> 25#include <qpe/qpetoolbar.h>
26#include <qpe/fileselector.h> 26#include <qpe/fileselector.h>
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qpe/lnkproperties.h> 28#include <qpe/lnkproperties.h>
29#include <qpe/storage.h> 29#include <qpe/storage.h>
30 30
31#include <qpe/applnk.h> 31#include <qpe/applnk.h>
32#include <qpe/config.h> 32#include <qpe/config.h>
33#include <qpe/global.h> 33#include <qpe/global.h>
34#include <qpe/resource.h> 34#include <qpe/resource.h>
35#include <qaction.h> 35#include <qaction.h>
36#include <qcursor.h> 36#include <qcursor.h>
37#include <qimage.h> 37#include <qimage.h>
38#include <qfile.h> 38#include <qfile.h>
39#include <qdir.h> 39#include <qdir.h>
40#include <qlayout.h> 40#include <qlayout.h>
41#include <qlabel.h> 41#include <qlabel.h>
42#include <qlist.h> 42#include <qlist.h>
43#include <qlistbox.h> 43#include <qlistbox.h>
44#include <qmainwindow.h> 44#include <qmainwindow.h>
45#include <qmessagebox.h> 45#include <qmessagebox.h>
46#include <qtoolbutton.h> 46#include <qtoolbutton.h>
47#include <qtabwidget.h> 47#include <qtabwidget.h>
48#include <qlistview.h> 48#include <qlistview.h>
49#include <qpoint.h> 49#include <qpoint.h>
50#include <qlineedit.h> 50#include <qlineedit.h>
51#include <qpushbutton.h> 51#include <qpushbutton.h>
52#include <qregexp.h> 52#include <qregexp.h>
53#include <qtextstream.h> 53#include <qtextstream.h>
54 54
55//#include <qtimer.h> 55//#include <qtimer.h>
56 56
57#include "playlistselection.h" 57#include "playlistselection.h"
58#include "playlistwidget.h" 58#include "playlistwidget.h"
59#include "mediaplayerstate.h" 59#include "mediaplayerstate.h"
60 60
61#include "inputDialog.h" 61#include "inputDialog.h"
62 62
63#include <stdlib.h> 63#include <stdlib.h>
64#include "audiowidget.h" 64#include "audiowidget.h"
65#include "videowidget.h" 65#include "videowidget.h"
66 66
67#include <unistd.h> 67#include <unistd.h>
68#include <sys/file.h> 68#include <sys/file.h>
69#include <sys/ioctl.h> 69#include <sys/ioctl.h>
70#include <sys/soundcard.h> 70#include <sys/soundcard.h>
71 71
72// for setBacklight() 72// for setBacklight()
73#include <linux/fb.h> 73#include <linux/fb.h>
74#include <sys/types.h> 74#include <sys/types.h>
75#include <sys/stat.h> 75#include <sys/stat.h>
76#include <stdlib.h> 76#include <stdlib.h>
77 77
78#define BUTTONS_ON_TOOLBAR 78#define BUTTONS_ON_TOOLBAR
79#define SIDE_BUTTONS 79#define SIDE_BUTTONS
80#define CAN_SAVE_LOAD_PLAYLISTS 80#define CAN_SAVE_LOAD_PLAYLISTS
81 81
82extern AudioWidget *audioUI; 82extern AudioWidget *audioUI;
83extern VideoWidget *videoUI; 83extern VideoWidget *videoUI;
84extern MediaPlayerState *mediaPlayerState; 84extern MediaPlayerState *mediaPlayerState;
85 85
86static inline QString fullBaseName ( const QFileInfo &fi ) 86static inline QString fullBaseName ( const QFileInfo &fi )
87{ 87{
88 QString str = fi. fileName ( ); 88 QString str = fi. fileName ( );
89 return str. left ( str. findRev ( '.' )); 89 return str. left ( str. findRev ( '.' ));
90} 90}
91 91
92 92
93QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg"; 93QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg";
94// class myFileSelector { 94// class myFileSelector {
95 95
96// }; 96// };
97class PlayListWidgetPrivate { 97class PlayListWidgetPrivate {
98public: 98public:
99 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; 99 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
100 QFrame *playListFrame; 100 QFrame *playListFrame;
101 FileSelector *files; 101 FileSelector *files;
102 PlayListSelection *selectedFiles; 102 PlayListSelection *selectedFiles;
103 bool setDocumentUsed; 103 bool setDocumentUsed;
104 DocLnk *current; 104 DocLnk *current;
105}; 105};
106 106
107 107
108class ToolButton : public QToolButton { 108class ToolButton : public QToolButton {
109public: 109public:
110 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 110 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
111 : QToolButton( parent, name ) { 111 : QToolButton( parent, name ) {
112 setTextLabel( name ); 112 setTextLabel( name );
113 setPixmap( Resource::loadPixmap( icon ) ); 113 setPixmap( Resource::loadPixmap( icon ) );
114 setAutoRaise( TRUE ); 114 setAutoRaise( TRUE );
115 setFocusPolicy( QWidget::NoFocus ); 115 setFocusPolicy( QWidget::NoFocus );
116 setToggleButton( t ); 116 setToggleButton( t );
117 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 117 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
118 QPEMenuToolFocusManager::manager()->addWidget( this ); 118 QPEMenuToolFocusManager::manager()->addWidget( this );
119 } 119 }
120}; 120};
121 121
122 122
123class MenuItem : public QAction { 123class MenuItem : public QAction {
124public: 124public:
125 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) 125 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
126 : QAction( text, QString::null, 0, 0 ) { 126 : QAction( text, QString::null, 0, 0 ) {
127 connect( this, SIGNAL( activated() ), handler, slot ); 127 connect( this, SIGNAL( activated() ), handler, slot );
128 addTo( parent ); 128 addTo( parent );
129 } 129 }
130}; 130};
131 131
132 132
133PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 133PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
134 : QMainWindow( parent, name, fl ) { 134 : QMainWindow( parent, name, fl ) {
135 135
136 d = new PlayListWidgetPrivate; 136 d = new PlayListWidgetPrivate;
137 d->setDocumentUsed = FALSE; 137 d->setDocumentUsed = FALSE;
138 d->current = NULL; 138 d->current = NULL;
139 fromSetDocument = FALSE; 139 fromSetDocument = FALSE;
140 insanityBool=FALSE; 140 insanityBool=FALSE;
141 audioScan = FALSE; 141 audioScan = FALSE;
142 videoScan = FALSE; 142 videoScan = FALSE;
143// menuTimer = new QTimer( this ,"menu timer"), 143// menuTimer = new QTimer( this ,"menu timer"),
144// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); 144// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) );
145 145
146 setBackgroundMode( PaletteButton ); 146 setBackgroundMode( PaletteButton );
147 147
148 setCaption( tr("OpiePlayer") ); 148 setCaption( tr("OpiePlayer") );
149 setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); 149 setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) );
150 150
151 setToolBarsMovable( FALSE ); 151 setToolBarsMovable( FALSE );
152 152
153 // Create Toolbar 153 // Create Toolbar
154 QPEToolBar *toolbar = new QPEToolBar( this ); 154 QPEToolBar *toolbar = new QPEToolBar( this );
155 toolbar->setHorizontalStretchable( TRUE ); 155 toolbar->setHorizontalStretchable( TRUE );
156 156
157 // Create Menubar 157 // Create Menubar
158 QPEMenuBar *menu = new QPEMenuBar( toolbar ); 158 QPEMenuBar *menu = new QPEMenuBar( toolbar );
159 menu->setMargin( 0 ); 159 menu->setMargin( 0 );
160 160
161 QPEToolBar *bar = new QPEToolBar( this ); 161 QPEToolBar *bar = new QPEToolBar( this );
162 bar->setLabel( tr( "Play Operations" ) ); 162 bar->setLabel( tr( "Play Operations" ) );
163// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", 163// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list",
164// this , SLOT( addSelected()) ); 164// this , SLOT( addSelected()) );
165 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); 165 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close");
166 tbDeletePlaylist->setFlat(TRUE); 166 tbDeletePlaylist->setFlat(TRUE);
167 tbDeletePlaylist->setFixedSize(20,20); 167 tbDeletePlaylist->setFixedSize(20,20);
168 168
169 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", 169 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist",
170 this , SLOT(addSelected()) ); 170 this , SLOT(addSelected()) );
171 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", 171 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist",
172 this , SLOT(removeSelected()) ); 172 this , SLOT(removeSelected()) );
173// d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); 173// d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE );
174 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", 174 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play",
175 this , SLOT( btnPlay(bool) ), TRUE ); 175 this , SLOT( btnPlay(bool) ), TRUE );
176 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", 176 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle",
177 mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 177 mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
178 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", 178 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop",
179 mediaPlayerState, SLOT(setLooping(bool)), TRUE ); 179 mediaPlayerState, SLOT(setLooping(bool)), TRUE );
180 tbDeletePlaylist->hide(); 180 tbDeletePlaylist->hide();
181 181
182 QPopupMenu *pmPlayList = new QPopupMenu( this ); 182 QPopupMenu *pmPlayList = new QPopupMenu( this );
183 menu->insertItem( tr( "File" ), pmPlayList ); 183 menu->insertItem( tr( "File" ), pmPlayList );
184 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 184 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
185 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 185 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
186 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 186 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
187 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 187 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
188 pmPlayList->insertSeparator(-1); 188 pmPlayList->insertSeparator(-1);
189 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 189 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
190 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); 190 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
191 pmPlayList->insertSeparator(-1); 191 pmPlayList->insertSeparator(-1);
192 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); 192 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) );
193 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); 193 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) );
194 194
195 QPopupMenu *pmView = new QPopupMenu( this ); 195 QPopupMenu *pmView = new QPopupMenu( this );
196 menu->insertItem( tr( "View" ), pmView ); 196 menu->insertItem( tr( "View" ), pmView );
197 197
198 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); 198 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0);
199 fullScreenButton->addTo(pmView); 199 fullScreenButton->addTo(pmView);
200 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); 200 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0);
201 scaleButton->addTo(pmView); 201 scaleButton->addTo(pmView);
202 202
203 203
204 skinsMenu = new QPopupMenu( this ); 204 skinsMenu = new QPopupMenu( this );
205 menu->insertItem( tr( "Skins" ), skinsMenu ); 205 menu->insertItem( tr( "Skins" ), skinsMenu );
206 skinsMenu->isCheckable(); 206 skinsMenu->isCheckable();
207 connect( skinsMenu, SIGNAL( activated( int ) ) , 207 connect( skinsMenu, SIGNAL( activated( int ) ) ,
208 this, SLOT( skinsMenuActivated( int ) ) ); 208 this, SLOT( skinsMenuActivated( int ) ) );
209 populateSkinsMenu(); 209 populateSkinsMenu();
210 210
211 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 211 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
212 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); 212 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
213 213
214 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); 214 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
215 215
216 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 216 tabWidget = new QTabWidget( hbox6, "tabWidget" );
217 tabWidget->setTabShape(QTabWidget::Triangular); 217 tabWidget->setTabShape(QTabWidget::Triangular);
@@ -342,274 +342,286 @@ PlayListWidget::~PlayListWidget() {
342 writeConfig( cfg ); 342 writeConfig( cfg );
343 343
344 if ( d->current ) 344 if ( d->current )
345 delete d->current; 345 delete d->current;
346 delete d; 346 delete d;
347} 347}
348 348
349 349
350void PlayListWidget::initializeStates() { 350void PlayListWidget::initializeStates() {
351 351
352 d->tbPlay->setOn( mediaPlayerState->playing() ); 352 d->tbPlay->setOn( mediaPlayerState->playing() );
353 d->tbLoop->setOn( mediaPlayerState->looping() ); 353 d->tbLoop->setOn( mediaPlayerState->looping() );
354 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 354 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
355 setPlaylist( true); 355 setPlaylist( true);
356} 356}
357 357
358 358
359void PlayListWidget::readConfig( Config& cfg ) { 359void PlayListWidget::readConfig( Config& cfg ) {
360 cfg.setGroup("PlayList"); 360 cfg.setGroup("PlayList");
361 QString currentString = cfg.readEntry("current", "" ); 361 QString currentString = cfg.readEntry("current", "" );
362 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 362 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
363 for ( int i = 0; i < noOfFiles; i++ ) { 363 for ( int i = 0; i < noOfFiles; i++ ) {
364 QString entryName; 364 QString entryName;
365 entryName.sprintf( "File%i", i + 1 ); 365 entryName.sprintf( "File%i", i + 1 );
366 QString linkFile = cfg.readEntry( entryName ); 366 QString linkFile = cfg.readEntry( entryName );
367 DocLnk lnk( linkFile ); 367 DocLnk lnk( linkFile );
368 if ( lnk.isValid() ) { 368 if ( lnk.isValid() ) {
369 d->selectedFiles->addToSelection( lnk ); 369 d->selectedFiles->addToSelection( lnk );
370 } 370 }
371 } 371 }
372 d->selectedFiles->setSelectedItem( currentString); 372 d->selectedFiles->setSelectedItem( currentString);
373} 373}
374 374
375 375
376void PlayListWidget::writeConfig( Config& cfg ) const { 376void PlayListWidget::writeConfig( Config& cfg ) const {
377 377
378 d->selectedFiles->writeCurrent( cfg); 378 d->selectedFiles->writeCurrent( cfg);
379 cfg.setGroup("PlayList"); 379 cfg.setGroup("PlayList");
380 int noOfFiles = 0; 380 int noOfFiles = 0;
381 d->selectedFiles->first(); 381 d->selectedFiles->first();
382 do { 382 do {
383 const DocLnk *lnk = d->selectedFiles->current(); 383 const DocLnk *lnk = d->selectedFiles->current();
384 if ( lnk ) { 384 if ( lnk ) {
385 QString entryName; 385 QString entryName;
386 entryName.sprintf( "File%i", noOfFiles + 1 ); 386 entryName.sprintf( "File%i", noOfFiles + 1 );
387// qDebug(entryName); 387// qDebug(entryName);
388 cfg.writeEntry( entryName, lnk->linkFile() ); 388 cfg.writeEntry( entryName, lnk->linkFile() );
389 // if this link does exist, add it so we have the file 389 // if this link does exist, add it so we have the file
390 // next time... 390 // next time...
391 if ( !QFile::exists( lnk->linkFile() ) ) { 391 if ( !QFile::exists( lnk->linkFile() ) ) {
392 // the way writing lnks doesn't really check for out 392 // the way writing lnks doesn't really check for out
393 // of disk space, but check it anyway. 393 // of disk space, but check it anyway.
394 if ( !lnk->writeLink() ) { 394 if ( !lnk->writeLink() ) {
395 QMessageBox::critical( 0, tr("Out of space"), 395 QMessageBox::critical( 0, tr("Out of space"),
396 tr( "There was a problem saving " 396 tr( "There was a problem saving "
397 "the playlist.\n" 397 "the playlist.\n"
398 "Your playlist " 398 "Your playlist "
399 "may be missing some entries\n" 399 "may be missing some entries\n"
400 "the next time you start it." ) 400 "the next time you start it." )
401 ); 401 );
402 } 402 }
403 } 403 }
404 noOfFiles++; 404 noOfFiles++;
405 } 405 }
406 } 406 }
407 while ( d->selectedFiles->next() ); 407 while ( d->selectedFiles->next() );
408 cfg.writeEntry("NumberOfFiles", noOfFiles ); 408 cfg.writeEntry("NumberOfFiles", noOfFiles );
409} 409}
410 410
411 411
412void PlayListWidget::addToSelection( const DocLnk& lnk ) { 412void PlayListWidget::addToSelection( const DocLnk& lnk ) {
413 d->setDocumentUsed = false; 413 d->setDocumentUsed = false;
414 if ( mediaPlayerState->playlist() ) { 414 if ( mediaPlayerState->playlist() ) {
415 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) 415 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" )
416 d->selectedFiles->addToSelection( lnk ); 416 d->selectedFiles->addToSelection( lnk );
417 } 417 }
418 else 418 else
419 mediaPlayerState->setPlaying( true); 419 mediaPlayerState->setPlaying( true);
420} 420}
421 421
422 422
423void PlayListWidget::clearList() { 423void PlayListWidget::clearList() {
424 while ( first() ) 424 while ( first() )
425 d->selectedFiles->removeSelected(); 425 d->selectedFiles->removeSelected();
426} 426}
427 427
428 428
429void PlayListWidget::addAllToList() { 429void PlayListWidget::addAllToList() {
430 DocLnkSet filesAll; 430 DocLnkSet filesAll;
431 Global::findDocuments(&filesAll, "video/*;audio/*"); 431 Global::findDocuments(&filesAll, "video/*;audio/*");
432 QListIterator<DocLnk> Adit( filesAll.children() ); 432 QListIterator<DocLnk> Adit( filesAll.children() );
433 for ( ; Adit.current(); ++Adit ) 433 for ( ; Adit.current(); ++Adit )
434 if(QFileInfo(Adit.current()->file()).exists()) 434 if(QFileInfo(Adit.current()->file()).exists())
435 d->selectedFiles->addToSelection( **Adit ); 435 d->selectedFiles->addToSelection( **Adit );
436 tabWidget->setCurrentPage(0); 436 tabWidget->setCurrentPage(0);
437 437
438 writeCurrentM3u(); 438 writeCurrentM3u();
439 d->selectedFiles->first(); 439 d->selectedFiles->first();
440} 440}
441 441
442 442
443void PlayListWidget::addAllMusicToList() { 443void PlayListWidget::addAllMusicToList() {
444 QListIterator<DocLnk> dit( files.children() ); 444 QListIterator<DocLnk> dit( files.children() );
445 for ( ; dit.current(); ++dit ) 445 for ( ; dit.current(); ++dit )
446 if(QFileInfo(dit.current()->file()).exists()) 446 if(QFileInfo(dit.current()->file()).exists())
447 d->selectedFiles->addToSelection( **dit ); 447 d->selectedFiles->addToSelection( **dit );
448 tabWidget->setCurrentPage(0); 448 tabWidget->setCurrentPage(0);
449 449
450 writeCurrentM3u(); 450 writeCurrentM3u();
451 d->selectedFiles->first(); 451 d->selectedFiles->first();
452} 452}
453 453
454 454
455void PlayListWidget::addAllVideoToList() { 455void PlayListWidget::addAllVideoToList() {
456 QListIterator<DocLnk> dit( vFiles.children() ); 456 QListIterator<DocLnk> dit( vFiles.children() );
457 for ( ; dit.current(); ++dit ) 457 for ( ; dit.current(); ++dit )
458 if(QFileInfo( dit.current()->file()).exists()) 458 if(QFileInfo( dit.current()->file()).exists())
459 d->selectedFiles->addToSelection( **dit ); 459 d->selectedFiles->addToSelection( **dit );
460 tabWidget->setCurrentPage(0); 460 tabWidget->setCurrentPage(0);
461 461
462 writeCurrentM3u(); 462 writeCurrentM3u();
463 d->selectedFiles->first(); 463 d->selectedFiles->first();
464} 464}
465 465
466 466
467void PlayListWidget::setDocument(const QString& fileref) { 467void PlayListWidget::setDocument(const QString& fileref) {
468 qDebug(fileref); 468 qDebug(fileref);
469 fromSetDocument = TRUE; 469 fromSetDocument = TRUE;
470 if ( fileref.isNull() ) { 470 QFileInfo fileInfo(fileref);
471 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); 471 if ( !fileInfo.exists() ) {
472 QMessageBox::critical( 0, tr( "Invalid File" ),
473 tr( "There was a problem in getting the file." ) );
472 return; 474 return;
473 } 475 }
474// qDebug("setDocument "+fileref); 476// qDebug("setDocument "+fileref);
475 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u 477 QString extension = fileInfo.extension(false);
478 if( extension.find( "m3u", 0, false) != -1) { //is m3u
476 readm3u( fileref); 479 readm3u( fileref);
477 } 480 }
478 else if(fileref.find("pls",0,TRUE) != -1) { //is pls 481 else if( extension.find( "pls", 0, false) != -1 ) { //is pls
479 readPls( fileref); 482 readPls( fileref);
480 } 483 }
481 else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist 484 else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist
482 clearList(); 485 clearList();
483 loadList(DocLnk(fileref)); 486 DocLnk lnk;
487 lnk.setName( fileInfo.baseName() ); //sets name
488 lnk.setFile( fileref ); //sets file name
489 //addToSelection( lnk );
490
491 loadList( lnk);
484 d->selectedFiles->first(); 492 d->selectedFiles->first();
485 } else { 493 } else {
486 clearList(); 494 clearList();
487 addToSelection( DocLnk( fileref ) ); 495 DocLnk lnk;
496 lnk.setName( fileInfo.baseName() ); //sets name
497 lnk.setFile( fileref ); //sets file name
498 addToSelection( lnk );
499// addToSelection( DocLnk( fileref ) );
488 d->setDocumentUsed = TRUE; 500 d->setDocumentUsed = TRUE;
489 mediaPlayerState->setPlaying( FALSE ); 501 mediaPlayerState->setPlaying( FALSE );
490 qApp->processEvents(); 502 qApp->processEvents();
491 mediaPlayerState->setPlaying( TRUE ); 503 mediaPlayerState->setPlaying( TRUE );
492 qApp->processEvents(); 504 qApp->processEvents();
493 setCaption(tr("OpiePlayer")); 505 setCaption(tr("OpiePlayer"));
494 } 506 }
495} 507}
496 508
497 509
498void PlayListWidget::setActiveWindow() { 510void PlayListWidget::setActiveWindow() {
499 qDebug("SETTING active window"); 511 qDebug("SETTING active window");
500 512
501 // When we get raised we need to ensure that it switches views 513 // When we get raised we need to ensure that it switches views
502 char origView = mediaPlayerState->view(); 514 char origView = mediaPlayerState->view();
503 mediaPlayerState->setView( 'l' ); // invalidate 515 mediaPlayerState->setView( 'l' ); // invalidate
504 mediaPlayerState->setView( origView ); // now switch back 516 mediaPlayerState->setView( origView ); // now switch back
505} 517}
506 518
507 519
508void PlayListWidget::useSelectedDocument() { 520void PlayListWidget::useSelectedDocument() {
509 d->setDocumentUsed = FALSE; 521 d->setDocumentUsed = FALSE;
510} 522}
511 523
512 524
513const DocLnk *PlayListWidget::current() { // this is fugly 525const DocLnk *PlayListWidget::current() { // this is fugly
514 526
515// if( fromSetDocument) { 527// if( fromSetDocument) {
516// qDebug("from setDoc"); 528// qDebug("from setDoc");
517// DocLnkSet files; 529// DocLnkSet files;
518// Global::findDocuments(&files, "video/*;audio/*"); 530// Global::findDocuments(&files, "video/*;audio/*");
519// QListIterator<DocLnk> dit( files.children() ); 531// QListIterator<DocLnk> dit( files.children() );
520// for ( ; dit.current(); ++dit ) { 532// for ( ; dit.current(); ++dit ) {
521// if(dit.current()->linkFile() == setDocFileRef) { 533// if(dit.current()->linkFile() == setDocFileRef) {
522// qDebug(setDocFileRef); 534// qDebug(setDocFileRef);
523// return dit; 535// return dit;
524// } 536// }
525// } 537// }
526// } else 538// } else
527 539
528 qDebug("current"); 540 qDebug("current");
529 541
530 switch (tabWidget->currentPageIndex()) { 542 switch (tabWidget->currentPageIndex()) {
531 case 0: //playlist 543 case 0: //playlist
532 { 544 {
533 qDebug("playlist"); 545 qDebug("playlist");
534 if ( mediaPlayerState->playlist() ) { 546 if ( mediaPlayerState->playlist() ) {
535 return d->selectedFiles->current(); 547 return d->selectedFiles->current();
536 } 548 }
537 else if ( d->setDocumentUsed && d->current ) { 549 else if ( d->setDocumentUsed && d->current ) {
538 return d->current; 550 return d->current;
539 } else { 551 } else {
540 return &(d->files->selectedDocument()); 552 return &(d->files->selectedDocument());
541 } 553 }
542 } 554 }
543 break; 555 break;
544 case 1://audio 556 case 1://audio
545 { 557 {
546 qDebug("audioView"); 558 qDebug("audioView");
547 QListIterator<DocLnk> dit( files.children() ); 559 QListIterator<DocLnk> dit( files.children() );
548 for ( ; dit.current(); ++dit ) { 560 for ( ; dit.current(); ++dit ) {
549 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { 561 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) {
550 qDebug("here"); 562 qDebug("here");
551 insanityBool=TRUE; 563 insanityBool=TRUE;
552 return dit; 564 return dit;
553 } 565 }
554 } 566 }
555 } 567 }
556 break; 568 break;
557 case 2: // video 569 case 2: // video
558 { 570 {
559 qDebug("videoView"); 571 qDebug("videoView");
560 QListIterator<DocLnk> Vdit( vFiles.children() ); 572 QListIterator<DocLnk> Vdit( vFiles.children() );
561 for ( ; Vdit.current(); ++Vdit ) { 573 for ( ; Vdit.current(); ++Vdit ) {
562 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { 574 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) {
563 insanityBool=TRUE; 575 insanityBool=TRUE;
564 return Vdit; 576 return Vdit;
565 } 577 }
566 } 578 }
567 } 579 }
568 break; 580 break;
569 }; 581 };
570 return 0; 582 return 0;
571} 583}
572 584
573bool PlayListWidget::prev() { 585bool PlayListWidget::prev() {
574 if ( mediaPlayerState->playlist() ) { 586 if ( mediaPlayerState->playlist() ) {
575 if ( mediaPlayerState->shuffled() ) { 587 if ( mediaPlayerState->shuffled() ) {
576 const DocLnk *cur = current(); 588 const DocLnk *cur = current();
577 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 589 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
578 for ( int i = 0; i < j; i++ ) { 590 for ( int i = 0; i < j; i++ ) {
579 if ( !d->selectedFiles->next() ) 591 if ( !d->selectedFiles->next() )
580 d->selectedFiles->first(); 592 d->selectedFiles->first();
581 } 593 }
582 if ( cur == current() ) 594 if ( cur == current() )
583 if ( !d->selectedFiles->next() ) 595 if ( !d->selectedFiles->next() )
584 d->selectedFiles->first(); 596 d->selectedFiles->first();
585 return TRUE; 597 return TRUE;
586 } else { 598 } else {
587 if ( !d->selectedFiles->prev() ) { 599 if ( !d->selectedFiles->prev() ) {
588 if ( mediaPlayerState->looping() ) { 600 if ( mediaPlayerState->looping() ) {
589 return d->selectedFiles->last(); 601 return d->selectedFiles->last();
590 } else { 602 } else {
591 return FALSE; 603 return FALSE;
592 } 604 }
593 } 605 }
594 return TRUE; 606 return TRUE;
595 } 607 }
596 } else { 608 } else {
597 return mediaPlayerState->looping(); 609 return mediaPlayerState->looping();
598 } 610 }
599} 611}
600 612
601 613
602bool PlayListWidget::next() { 614bool PlayListWidget::next() {
603 if ( mediaPlayerState->playlist() ) { 615 if ( mediaPlayerState->playlist() ) {
604 if ( mediaPlayerState->shuffled() ) { 616 if ( mediaPlayerState->shuffled() ) {
605 return prev(); 617 return prev();
606 } else { 618 } else {
607 if ( !d->selectedFiles->next() ) { 619 if ( !d->selectedFiles->next() ) {
608 if ( mediaPlayerState->looping() ) { 620 if ( mediaPlayerState->looping() ) {
609 return d->selectedFiles->first(); 621 return d->selectedFiles->first();
610 } else { 622 } else {
611 return FALSE; 623 return FALSE;
612 } 624 }
613 } 625 }
614 return TRUE; 626 return TRUE;
615 } 627 }
@@ -1066,265 +1078,266 @@ void PlayListWidget::readm3u( const QString &filename ) {
1066 Om3u *m3uList; 1078 Om3u *m3uList;
1067 QString s, name; 1079 QString s, name;
1068 m3uList = new Om3u( filename, IO_ReadOnly ); 1080 m3uList = new Om3u( filename, IO_ReadOnly );
1069 m3uList->readM3u(); 1081 m3uList->readM3u();
1070 DocLnk lnk; 1082 DocLnk lnk;
1071 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 1083 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
1072 s = *it; 1084 s = *it;
1073// qDebug("reading "+ s); 1085// qDebug("reading "+ s);
1074 if(s.left(4)=="http") { 1086 if(s.left(4)=="http") {
1075 lnk.setName( s ); //sets file name 1087 lnk.setName( s ); //sets file name
1076 lnk.setIcon("opieplayer2/musicfile"); 1088 lnk.setIcon("opieplayer2/musicfile");
1077 if(s.right(4) != '.' || s.right(5) != '.') 1089 if(s.right(4) != '.' || s.right(5) != '.')
1078 lnk.setFile( s+"/"); //if url with no extension 1090 lnk.setFile( s+"/"); //if url with no extension
1079 else 1091 else
1080 lnk.setFile( s ); //sets file name 1092 lnk.setFile( s ); //sets file name
1081 1093
1082 } else { 1094 } else {
1083 // if( QFileInfo( s ).exists() ) { 1095 // if( QFileInfo( s ).exists() ) {
1084 lnk.setName( fullBaseName ( QFileInfo(s))); 1096 lnk.setName( fullBaseName ( QFileInfo(s)));
1085 // if(s.right(4) == '.') {//if regular file 1097 // if(s.right(4) == '.') {//if regular file
1086 if(s.left(1) != "/") { 1098 if(s.left(1) != "/") {
1087 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); 1099 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s);
1088 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); 1100 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
1089 lnk.setIcon("SoundPlayer"); 1101 lnk.setIcon("SoundPlayer");
1090 } else { 1102 } else {
1091 // qDebug("set link2 "+s); 1103 // qDebug("set link2 "+s);
1092 lnk.setFile( s); 1104 lnk.setFile( s);
1093 lnk.setIcon("SoundPlayer"); 1105 lnk.setIcon("SoundPlayer");
1094 } 1106 }
1095 } 1107 }
1096 d->selectedFiles->addToSelection( lnk ); 1108 d->selectedFiles->addToSelection( lnk );
1097 } 1109 }
1098 Config config( "OpiePlayer" ); 1110 Config config( "OpiePlayer" );
1099 config.setGroup( "PlayList" ); 1111 config.setGroup( "PlayList" );
1100 1112
1101 config.writeEntry("CurrentPlaylist",filename); 1113 config.writeEntry("CurrentPlaylist",filename);
1102 config.write(); 1114 config.write();
1103 currentPlayList=filename; 1115 currentPlayList=filename;
1104 1116
1105// m3uList->write(); 1117// m3uList->write();
1106 m3uList->close(); 1118 m3uList->close();
1107 if(m3uList) delete m3uList; 1119 if(m3uList) delete m3uList;
1108 1120
1109 d->selectedFiles->setSelectedItem( s); 1121 d->selectedFiles->setSelectedItem( s);
1110 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename))); 1122 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename)));
1111 1123
1112} 1124}
1113 1125
1114/* 1126/*
1115reads pls and adds files/urls to playlist */ 1127reads pls and adds files/urls to playlist */
1116void PlayListWidget::readPls( const QString &filename ) { 1128void PlayListWidget::readPls( const QString &filename ) {
1117 1129
1118 qDebug( "pls filename is " + filename ); 1130 qDebug( "pls filename is " + filename );
1119 Om3u *m3uList; 1131 Om3u *m3uList;
1120 QString s, name; 1132 QString s, name;
1121 m3uList = new Om3u( filename, IO_ReadOnly ); 1133 m3uList = new Om3u( filename, IO_ReadOnly );
1122 m3uList->readPls(); 1134 m3uList->readPls();
1123 1135
1124 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 1136 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
1125 s = *it; 1137 s = *it;
1126 // s.replace( QRegExp( "%20" )," " ); 1138 // s.replace( QRegExp( "%20" )," " );
1127 DocLnk lnk( s ); 1139 DocLnk lnk( s );
1128 QFileInfo f( s ); 1140 QFileInfo f( s );
1129 QString name = fullBaseName ( f); 1141 QString name = fullBaseName ( f);
1130 1142
1131 if( name.left( 4 ) == "http" ) { 1143 if( name.left( 4 ) == "http" ) {
1132 name = s.right( s.length() - 7); 1144 name = s.right( s.length() - 7);
1133 } else { 1145 } else {
1134 name = s; 1146 name = s;
1135 } 1147 }
1136 1148
1137 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 1149 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
1138 1150
1139 lnk.setName( name ); 1151 lnk.setName( name );
1140 if( s.at( s.length() - 4) == '.') {// if this is probably a file 1152 if( s.at( s.length() - 4) == '.') {// if this is probably a file
1141 lnk.setFile( s ); 1153 lnk.setFile( s );
1142 } else { //if its a url 1154 } else { //if its a url
1143 if( name.right( 1 ).find( '/' ) == -1) { 1155 if( name.right( 1 ).find( '/' ) == -1) {
1144 s += "/"; 1156 s += "/";
1145 } 1157 }
1146 lnk.setFile( s ); 1158 lnk.setFile( s );
1147 } 1159 }
1148 lnk.setType( "audio/x-mpegurl" ); 1160 lnk.setType( "audio/x-mpegurl" );
1149 1161
1150 lnk.writeLink(); 1162 lnk.writeLink();
1151 d->selectedFiles->addToSelection( lnk ); 1163 d->selectedFiles->addToSelection( lnk );
1152 } 1164 }
1153 1165
1154 m3uList->close(); 1166 m3uList->close();
1155 if(m3uList) delete m3uList; 1167 if(m3uList) delete m3uList;
1156} 1168}
1157 1169
1158/* 1170/*
1159 writes current playlist to current m3u file */ 1171 writes current playlist to current m3u file */
1160void PlayListWidget::writeCurrentM3u() { 1172void PlayListWidget::writeCurrentM3u() {
1161 qDebug("writing to current m3u"); 1173 qDebug("writing to current m3u");
1162 Config cfg( "OpiePlayer" ); 1174 Config cfg( "OpiePlayer" );
1163 cfg.setGroup("PlayList"); 1175 cfg.setGroup("PlayList");
1164 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 1176 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
1165 Om3u *m3uList; 1177 Om3u *m3uList;
1166 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); 1178 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
1167 1179
1168 if( d->selectedFiles->first()) { 1180 if( d->selectedFiles->first()) {
1169 do { 1181 do {
1170 qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); 1182 qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file());
1171 m3uList->add( d->selectedFiles->current()->file() ); 1183 m3uList->add( d->selectedFiles->current()->file() );
1172 } 1184 }
1173 while ( d->selectedFiles->next() ); 1185 while ( d->selectedFiles->next() );
1174 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); 1186 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
1175 m3uList->write(); 1187 m3uList->write();
1176 m3uList->close(); 1188 m3uList->close();
1177 1189
1178 if(m3uList) delete m3uList; 1190 if(m3uList) delete m3uList;
1179 } 1191 }
1180} 1192}
1181 1193
1182 /* 1194 /*
1183 writes current playlist to m3u file */ 1195 writes current playlist to m3u file */
1184void PlayListWidget::writem3u() { 1196void PlayListWidget::writem3u() {
1185 InputDialog *fileDlg; 1197 InputDialog *fileDlg;
1186 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 1198 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
1187 fileDlg->exec(); 1199 fileDlg->exec();
1188 QString name, filename, list; 1200 QString name, filename, list;
1189 Om3u *m3uList; 1201 Om3u *m3uList;
1190 1202
1191 if( fileDlg->result() == 1 ) { 1203 if( fileDlg->result() == 1 ) {
1192 name = fileDlg->text(); 1204 name = fileDlg->text();
1193// qDebug( filename ); 1205// qDebug( filename );
1194 1206 if( name.find("/",0,true) != -1) {// assume they specify a file path
1195 if( name.left( 1) != "/" ) { 1207 filename = name;
1196 filename = QPEApplication::documentDir() + "/" + name; 1208 name = name.right(name.length()- name.findRev("/",-1,true) - 1 );
1197 }
1198
1199 if( name.right( 3 ) != "m3u" ) {
1200 filename = QPEApplication::documentDir() + "/" +name+".m3u";
1201 } 1209 }
1210 else //otherwise dump it somewhere noticable
1211 filename = QPEApplication::documentDir() + "/" + name;
1202 1212
1213 if( filename.right( 3 ) != "m3u" ) //needs filename extension
1214 filename += ".m3u";
1215
1203 if( d->selectedFiles->first()) { 1216 if( d->selectedFiles->first()) {
1204 m3uList = new Om3u(filename, IO_ReadWrite); 1217 m3uList = new Om3u(filename, IO_ReadWrite);
1205 1218
1206 do { 1219 do {
1207 m3uList->add( d->selectedFiles->current()->file()); 1220 m3uList->add( d->selectedFiles->current()->file());
1208 } 1221 }
1209 while ( d->selectedFiles->next() ); 1222 while ( d->selectedFiles->next() );
1210 // qDebug( list ); 1223 // qDebug( list );
1211 m3uList->write(); 1224 m3uList->write();
1212 m3uList->close(); 1225 m3uList->close();
1213 if(m3uList) delete m3uList; 1226 if(m3uList) delete m3uList;
1214 1227
1215 if(fileDlg) delete fileDlg; 1228 if(fileDlg) delete fileDlg;
1216 1229
1217 DocLnk lnk; 1230 DocLnk lnk;
1218 lnk.setFile( filename); 1231 lnk.setFile( filename);
1219 lnk.setIcon("opieplayer2/playlist2"); 1232 lnk.setIcon("opieplayer2/playlist2");
1220 lnk.setName( name); //sets file name 1233 lnk.setName( name); //sets file name
1221 1234
1222 // qDebug(filename); 1235 // qDebug(filename);
1223 Config config( "OpiePlayer" ); 1236 Config config( "OpiePlayer" );
1224 config.setGroup( "PlayList" ); 1237 config.setGroup( "PlayList" );
1225 1238
1226 config.writeEntry("CurrentPlaylist",filename); 1239 config.writeEntry("CurrentPlaylist",filename);
1227 currentPlayList=filename; 1240 currentPlayList=filename;
1228 1241
1229 if(!lnk.writeLink()) { 1242 if(!lnk.writeLink()) {
1230 qDebug("Writing doclink did not work"); 1243 qDebug("Writing doclink did not work");
1231 } 1244 }
1232 1245
1233 setCaption(tr("OpiePlayer: ") + name); 1246 setCaption(tr("OpiePlayer: ") + name);
1234 } 1247 }
1235 } 1248 }
1236} 1249}
1237 1250
1238 1251
1239void PlayListWidget::keyReleaseEvent( QKeyEvent *e) 1252void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
1240{ 1253{
1241 switch ( e->key() ) { 1254 switch ( e->key() ) {
1242////////////////////////////// Zaurus keys 1255////////////////////////////// Zaurus keys
1243 case Key_F9: //activity 1256 case Key_F9: //activity
1244// if(audioUI->isHidden()) 1257// if(audioUI->isHidden())
1245// audioUI->showMaximized(); 1258// audioUI->showMaximized();
1246 break; 1259 break;
1247 case Key_F10: //contacts 1260 case Key_F10: //contacts
1248// if( videoUI->isHidden()) 1261// if( videoUI->isHidden())
1249// videoUI->showMaximized(); 1262// videoUI->showMaximized();
1250 break; 1263 break;
1251 case Key_F11: //menu 1264 case Key_F11: //menu
1252 break; 1265 break;
1253 case Key_F12: //home 1266 case Key_F12: //home
1254// doBlank(); 1267// doBlank();
1255 break; 1268 break;
1256 case Key_F13: //mail 1269 case Key_F13: //mail
1257// doUnblank(); 1270// doUnblank();
1258 break; 1271 break;
1259 case Key_Q: //add to playlist 1272 case Key_Q: //add to playlist
1260 qDebug("Add"); 1273 qDebug("Add");
1261 addSelected(); 1274 addSelected();
1262 break; 1275 break;
1263 case Key_R: //remove from playlist 1276 case Key_R: //remove from playlist
1264 removeSelected(); 1277 removeSelected();
1265 break; 1278 break;
1266// case Key_P: //play 1279// case Key_P: //play
1267// qDebug("Play"); 1280// qDebug("Play");
1268// playSelected(); 1281// playSelected();
1269// break; 1282// break;
1270 case Key_Space: 1283 case Key_Space:
1271 qDebug("Play"); 1284 qDebug("Play");
1272// playSelected(); puh 1285// playSelected(); puh
1273 break; 1286 break;
1274 case Key_1: 1287 case Key_1:
1275 tabWidget->setCurrentPage(0); 1288 tabWidget->setCurrentPage(0);
1276 break; 1289 break;
1277 case Key_2: 1290 case Key_2:
1278 tabWidget->setCurrentPage(1); 1291 tabWidget->setCurrentPage(1);
1279 break; 1292 break;
1280 case Key_3: 1293 case Key_3:
1281 tabWidget->setCurrentPage(2); 1294 tabWidget->setCurrentPage(2);
1282 break; 1295 break;
1283 case Key_4: 1296 case Key_4:
1284 tabWidget->setCurrentPage(3); 1297 tabWidget->setCurrentPage(3);
1285 break; 1298 break;
1286 case Key_Down: 1299 case Key_Down:
1287 if ( !d->selectedFiles->next() ) 1300 if ( !d->selectedFiles->next() )
1288 d->selectedFiles->first(); 1301 d->selectedFiles->first();
1289 1302
1290 break; 1303 break;
1291 case Key_Up: 1304 case Key_Up:
1292 if ( !d->selectedFiles->prev() ) 1305 if ( !d->selectedFiles->prev() )
1293 // d->selectedFiles->last(); 1306 // d->selectedFiles->last();
1294 1307
1295 break; 1308 break;
1296 1309
1297 } 1310 }
1298} 1311}
1299 1312
1300void PlayListWidget::keyPressEvent( QKeyEvent *) 1313void PlayListWidget::keyPressEvent( QKeyEvent *)
1301{ 1314{
1302// qDebug("Key press"); 1315// qDebug("Key press");
1303// switch ( e->key() ) { 1316// switch ( e->key() ) {
1304// ////////////////////////////// Zaurus keys 1317// ////////////////////////////// Zaurus keys
1305// case Key_A: //add to playlist 1318// case Key_A: //add to playlist
1306// qDebug("Add"); 1319// qDebug("Add");
1307// addSelected(); 1320// addSelected();
1308// break; 1321// break;
1309// case Key_R: //remove from playlist 1322// case Key_R: //remove from playlist
1310// removeSelected(); 1323// removeSelected();
1311// break; 1324// break;
1312// case Key_P: //play 1325// case Key_P: //play
1313// qDebug("Play"); 1326// qDebug("Play");
1314// playSelected(); 1327// playSelected();
1315// break; 1328// break;
1316// case Key_Space: 1329// case Key_Space:
1317// qDebug("Play"); 1330// qDebug("Play");
1318// playSelected(); 1331// playSelected();
1319// break; 1332// break;
1320// } 1333// }
1321} 1334}
1322 1335
1323void PlayListWidget::doBlank() { 1336void PlayListWidget::doBlank() {
1324 qDebug("do blanking"); 1337 qDebug("do blanking");
1325 fd=open("/dev/fb0",O_RDWR); 1338 fd=open("/dev/fb0",O_RDWR);
1326 if (fd != -1) { 1339 if (fd != -1) {
1327 ioctl(fd,FBIOBLANK,1); 1340 ioctl(fd,FBIOBLANK,1);
1328// close(fd); 1341// close(fd);
1329 } 1342 }
1330} 1343}