summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp46
-rw-r--r--core/multimedia/opieplayer/playlistwidget.h4
2 files changed, 50 insertions, 0 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index a0bf4db..5e1be2f 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -1,528 +1,531 @@
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;audio/x-mod"; 93QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg;audio/x-mod";
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 channel = new QCopChannel( "QPE/Application/opieplayer", this );
146 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
147 this, SLOT( qcopReceive(const QCString&, const QByteArray&)) );
145 148
146 setBackgroundMode( PaletteButton ); 149 setBackgroundMode( PaletteButton );
147 150
148 setCaption( tr("OpiePlayer") ); 151 setCaption( tr("OpiePlayer") );
149 setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); 152 setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) );
150 153
151 setToolBarsMovable( FALSE ); 154 setToolBarsMovable( FALSE );
152 155
153 // Create Toolbar 156 // Create Toolbar
154 QPEToolBar *toolbar = new QPEToolBar( this ); 157 QPEToolBar *toolbar = new QPEToolBar( this );
155 toolbar->setHorizontalStretchable( TRUE ); 158 toolbar->setHorizontalStretchable( TRUE );
156 159
157 // Create Menubar 160 // Create Menubar
158 QPEMenuBar *menu = new QPEMenuBar( toolbar ); 161 QPEMenuBar *menu = new QPEMenuBar( toolbar );
159 menu->setMargin( 0 ); 162 menu->setMargin( 0 );
160 163
161 QPEToolBar *bar = new QPEToolBar( this ); 164 QPEToolBar *bar = new QPEToolBar( this );
162 bar->setLabel( tr( "Play Operations" ) ); 165 bar->setLabel( tr( "Play Operations" ) );
163// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", 166// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list",
164// this , SLOT( addSelected()) ); 167// this , SLOT( addSelected()) );
165 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); 168 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close");
166 tbDeletePlaylist->setFlat(TRUE); 169 tbDeletePlaylist->setFlat(TRUE);
167 tbDeletePlaylist->setFixedSize(20,20); 170 tbDeletePlaylist->setFixedSize(20,20);
168 171
169 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", 172 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist",
170 this , SLOT(addSelected()) ); 173 this , SLOT(addSelected()) );
171 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", 174 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist",
172 this , SLOT(removeSelected()) ); 175 this , SLOT(removeSelected()) );
173// d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); 176// 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", 177 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play",
175 this , SLOT( btnPlay(bool) ), TRUE ); 178 this , SLOT( btnPlay(bool) ), TRUE );
176 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", 179 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle",
177 mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 180 mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
178 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", 181 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop",
179 mediaPlayerState, SLOT(setLooping(bool)), TRUE ); 182 mediaPlayerState, SLOT(setLooping(bool)), TRUE );
180 tbDeletePlaylist->hide(); 183 tbDeletePlaylist->hide();
181 184
182 QPopupMenu *pmPlayList = new QPopupMenu( this ); 185 QPopupMenu *pmPlayList = new QPopupMenu( this );
183 menu->insertItem( tr( "File" ), pmPlayList ); 186 menu->insertItem( tr( "File" ), pmPlayList );
184 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 187 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
185 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 188 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
186 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 189 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
187 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 190 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
188 pmPlayList->insertSeparator(-1); 191 pmPlayList->insertSeparator(-1);
189 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 192 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
190 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); 193 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
191 pmPlayList->insertSeparator(-1); 194 pmPlayList->insertSeparator(-1);
192 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); 195 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) );
193 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); 196 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) );
194 197
195 QPopupMenu *pmView = new QPopupMenu( this ); 198 QPopupMenu *pmView = new QPopupMenu( this );
196 menu->insertItem( tr( "View" ), pmView ); 199 menu->insertItem( tr( "View" ), pmView );
197 200
198 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); 201 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0);
199 fullScreenButton->addTo(pmView); 202 fullScreenButton->addTo(pmView);
200 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); 203 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0);
201 scaleButton->addTo(pmView); 204 scaleButton->addTo(pmView);
202 205
203 206
204 skinsMenu = new QPopupMenu( this ); 207 skinsMenu = new QPopupMenu( this );
205 menu->insertItem( tr( "Skins" ), skinsMenu ); 208 menu->insertItem( tr( "Skins" ), skinsMenu );
206 skinsMenu->isCheckable(); 209 skinsMenu->isCheckable();
207 connect( skinsMenu, SIGNAL( activated( int ) ) , 210 connect( skinsMenu, SIGNAL( activated( int ) ) ,
208 this, SLOT( skinsMenuActivated( int ) ) ); 211 this, SLOT( skinsMenuActivated( int ) ) );
209 populateSkinsMenu(); 212 populateSkinsMenu();
210 213
211 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 214 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
212 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); 215 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
213 216
214 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); 217 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
215 218
216 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 219 tabWidget = new QTabWidget( hbox6, "tabWidget" );
217// tabWidget->setTabShape(QTabWidget::Triangular); 220// tabWidget->setTabShape(QTabWidget::Triangular);
218 221
219 QWidget *pTab; 222 QWidget *pTab;
220 pTab = new QWidget( tabWidget, "pTab" ); 223 pTab = new QWidget( tabWidget, "pTab" );
221// playlistView = new QListView( pTab, "playlistview" ); 224// playlistView = new QListView( pTab, "playlistview" );
222// playlistView->setMinimumSize(236,260); 225// playlistView->setMinimumSize(236,260);
223 tabWidget->insertTab( pTab,"Playlist"); 226 tabWidget->insertTab( pTab,"Playlist");
224 227
225 228
226 // Add the playlist area 229 // Add the playlist area
227 230
228 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); 231 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
229 d->playListFrame = vbox3; 232 d->playListFrame = vbox3;
230 d->playListFrame ->setMinimumSize(235,260); 233 d->playListFrame ->setMinimumSize(235,260);
231 234
232 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); 235 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
233 236
234 d->selectedFiles = new PlayListSelection( hbox2); 237 d->selectedFiles = new PlayListSelection( hbox2);
235 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); 238 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
236 239
237 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); 240 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold);
238 241
239 242
240 243
241 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch 244 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
242 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); 245 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) );
243 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); 246 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) );
244 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); 247 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) );
245 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch 248 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
246 249
247 QWidget *aTab; 250 QWidget *aTab;
248 aTab = new QWidget( tabWidget, "aTab" ); 251 aTab = new QWidget( tabWidget, "aTab" );
249 audioView = new QListView( aTab, "Audioview" ); 252 audioView = new QListView( aTab, "Audioview" );
250 audioView->setMinimumSize(233,260); 253 audioView->setMinimumSize(233,260);
251 audioView->addColumn( tr("Title"),140); 254 audioView->addColumn( tr("Title"),140);
252 audioView->addColumn(tr("Size"), -1); 255 audioView->addColumn(tr("Size"), -1);
253 audioView->addColumn(tr("Media"),-1); 256 audioView->addColumn(tr("Media"),-1);
254 audioView->addColumn( tr( "Path" ), 0 ); 257 audioView->addColumn( tr( "Path" ), 0 );
255 258
256 audioView->setColumnAlignment(1, Qt::AlignRight); 259 audioView->setColumnAlignment(1, Qt::AlignRight);
257 audioView->setColumnAlignment(2, Qt::AlignRight); 260 audioView->setColumnAlignment(2, Qt::AlignRight);
258 audioView->setAllColumnsShowFocus(TRUE); 261 audioView->setAllColumnsShowFocus(TRUE);
259 262
260 audioView->setMultiSelection( TRUE ); 263 audioView->setMultiSelection( TRUE );
261 audioView->setSelectionMode( QListView::Extended); 264 audioView->setSelectionMode( QListView::Extended);
262 audioView->setSorting( 3, TRUE ); 265 audioView->setSorting( 3, TRUE );
263 266
264 tabWidget->insertTab(aTab,tr("Audio")); 267 tabWidget->insertTab(aTab,tr("Audio"));
265 268
266 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); 269 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold);
267 270
268// audioView 271// audioView
269// populateAudioView(); 272// populateAudioView();
270// videowidget 273// videowidget
271 274
272 QWidget *vTab; 275 QWidget *vTab;
273 vTab = new QWidget( tabWidget, "vTab" ); 276 vTab = new QWidget( tabWidget, "vTab" );
274 videoView = new QListView( vTab, "Videoview" ); 277 videoView = new QListView( vTab, "Videoview" );
275 videoView->setMinimumSize(233,260); 278 videoView->setMinimumSize(233,260);
276 279
277 videoView->addColumn(tr("Title"),140); 280 videoView->addColumn(tr("Title"),140);
278 videoView->addColumn(tr("Size"),-1); 281 videoView->addColumn(tr("Size"),-1);
279 videoView->addColumn(tr("Media"),-1); 282 videoView->addColumn(tr("Media"),-1);
280 videoView->addColumn(tr( "Path" ), 0 ); 283 videoView->addColumn(tr( "Path" ), 0 );
281 videoView->setColumnAlignment(1, Qt::AlignRight); 284 videoView->setColumnAlignment(1, Qt::AlignRight);
282 videoView->setColumnAlignment(2, Qt::AlignRight); 285 videoView->setColumnAlignment(2, Qt::AlignRight);
283 videoView->setAllColumnsShowFocus(TRUE); 286 videoView->setAllColumnsShowFocus(TRUE);
284 videoView->setMultiSelection( TRUE ); 287 videoView->setMultiSelection( TRUE );
285 videoView->setSelectionMode( QListView::Extended); 288 videoView->setSelectionMode( QListView::Extended);
286 289
287 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); 290 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold);
288 291
289 tabWidget->insertTab( vTab,tr("Video")); 292 tabWidget->insertTab( vTab,tr("Video"));
290 293
291 QWidget *LTab; 294 QWidget *LTab;
292 LTab = new QWidget( tabWidget, "LTab" ); 295 LTab = new QWidget( tabWidget, "LTab" );
293 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy 296 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy
294 playLists->setMinimumSize(233,260); 297 playLists->setMinimumSize(233,260);
295 tabWidget->insertTab(LTab,tr("Lists")); 298 tabWidget->insertTab(LTab,tr("Lists"));
296 299
297 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); 300 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
298 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); 301 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) );
299 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); 302 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) );
300 303
301 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 304 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
302 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); 305 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) );
303 306
304 307
305///audioView 308///audioView
306 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 309 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
307 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 310 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
308 311
309 connect( audioView, SIGNAL( returnPressed( QListViewItem *)), 312 connect( audioView, SIGNAL( returnPressed( QListViewItem *)),
310 this,SLOT( playIt( QListViewItem *)) ); 313 this,SLOT( playIt( QListViewItem *)) );
311 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 314 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
312 315
313 316
314//videoView 317//videoView
315 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 318 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
316 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 319 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
317 connect( videoView, SIGNAL( returnPressed( QListViewItem *)), 320 connect( videoView, SIGNAL( returnPressed( QListViewItem *)),
318 this,SLOT( playIt( QListViewItem *)) ); 321 this,SLOT( playIt( QListViewItem *)) );
319 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 322 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
320 323
321 324
322//playlists 325//playlists
323 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); 326 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
324 327
325 328
326 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); 329 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
327 330
328 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 331 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
329 332
330 333
331 334
332 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); 335 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
333 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 336 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
334 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 337 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
335 338
336 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 339 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
337 340
338 setCentralWidget( vbox5 ); 341 setCentralWidget( vbox5 );
339 342
340 Config cfg( "OpiePlayer" ); 343 Config cfg( "OpiePlayer" );
341 readConfig( cfg ); 344 readConfig( cfg );
342 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default"); 345 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","default");
343 loadList(DocLnk( currentPlaylist)); 346 loadList(DocLnk( currentPlaylist));
344 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlaylist))); 347 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(currentPlaylist)));
345 348
346 initializeStates(); 349 initializeStates();
347} 350}
348 351
349 352
350PlayListWidget::~PlayListWidget() { 353PlayListWidget::~PlayListWidget() {
351 Config cfg( "OpiePlayer" ); 354 Config cfg( "OpiePlayer" );
352 writeConfig( cfg ); 355 writeConfig( cfg );
353 356
354 if ( d->current ) 357 if ( d->current )
355 delete d->current; 358 delete d->current;
356 delete d; 359 delete d;
357} 360}
358 361
359 362
360void PlayListWidget::initializeStates() { 363void PlayListWidget::initializeStates() {
361 364
362 d->tbPlay->setOn( mediaPlayerState->playing() ); 365 d->tbPlay->setOn( mediaPlayerState->playing() );
363 d->tbLoop->setOn( mediaPlayerState->looping() ); 366 d->tbLoop->setOn( mediaPlayerState->looping() );
364 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 367 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
365 setPlaylist( true); 368 setPlaylist( true);
366} 369}
367 370
368 371
369void PlayListWidget::readConfig( Config& cfg ) { 372void PlayListWidget::readConfig( Config& cfg ) {
370 cfg.setGroup("PlayList"); 373 cfg.setGroup("PlayList");
371 QString currentString = cfg.readEntry("current", "" ); 374 QString currentString = cfg.readEntry("current", "" );
372 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 375 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
373 for ( int i = 0; i < noOfFiles; i++ ) { 376 for ( int i = 0; i < noOfFiles; i++ ) {
374 QString entryName; 377 QString entryName;
375 entryName.sprintf( "File%i", i + 1 ); 378 entryName.sprintf( "File%i", i + 1 );
376 QString linkFile = cfg.readEntry( entryName ); 379 QString linkFile = cfg.readEntry( entryName );
377 DocLnk lnk( linkFile ); 380 DocLnk lnk( linkFile );
378 if ( lnk.isValid() ) { 381 if ( lnk.isValid() ) {
379 d->selectedFiles->addToSelection( lnk ); 382 d->selectedFiles->addToSelection( lnk );
380 } 383 }
381 } 384 }
382 d->selectedFiles->setSelectedItem( currentString); 385 d->selectedFiles->setSelectedItem( currentString);
383} 386}
384 387
385 388
386void PlayListWidget::writeConfig( Config& cfg ) const { 389void PlayListWidget::writeConfig( Config& cfg ) const {
387 390
388 d->selectedFiles->writeCurrent( cfg); 391 d->selectedFiles->writeCurrent( cfg);
389 cfg.setGroup("PlayList"); 392 cfg.setGroup("PlayList");
390 int noOfFiles = 0; 393 int noOfFiles = 0;
391 d->selectedFiles->first(); 394 d->selectedFiles->first();
392 do { 395 do {
393 const DocLnk *lnk = d->selectedFiles->current(); 396 const DocLnk *lnk = d->selectedFiles->current();
394 if ( lnk ) { 397 if ( lnk ) {
395 QString entryName; 398 QString entryName;
396 entryName.sprintf( "File%i", noOfFiles + 1 ); 399 entryName.sprintf( "File%i", noOfFiles + 1 );
397// qDebug(entryName); 400// qDebug(entryName);
398 cfg.writeEntry( entryName, lnk->linkFile() ); 401 cfg.writeEntry( entryName, lnk->linkFile() );
399 // if this link does exist, add it so we have the file 402 // if this link does exist, add it so we have the file
400 // next time... 403 // next time...
401 if ( !QFile::exists( lnk->linkFile() ) ) { 404 if ( !QFile::exists( lnk->linkFile() ) ) {
402 // the way writing lnks doesn't really check for out 405 // the way writing lnks doesn't really check for out
403 // of disk space, but check it anyway. 406 // of disk space, but check it anyway.
404 if ( !lnk->writeLink() ) { 407 if ( !lnk->writeLink() ) {
405 QMessageBox::critical( 0, tr("Out of space"), 408 QMessageBox::critical( 0, tr("Out of space"),
406 tr( "There was a problem saving " 409 tr( "There was a problem saving "
407 "the playlist.\n" 410 "the playlist.\n"
408 "Your playlist " 411 "Your playlist "
409 "may be missing some entries\n" 412 "may be missing some entries\n"
410 "the next time you start it." ) 413 "the next time you start it." )
411 ); 414 );
412 } 415 }
413 } 416 }
414 noOfFiles++; 417 noOfFiles++;
415 } 418 }
416 } 419 }
417 while ( d->selectedFiles->next() ); 420 while ( d->selectedFiles->next() );
418 cfg.writeEntry("NumberOfFiles", noOfFiles ); 421 cfg.writeEntry("NumberOfFiles", noOfFiles );
419} 422}
420 423
421 424
422void PlayListWidget::addToSelection( const DocLnk& lnk ) { 425void PlayListWidget::addToSelection( const DocLnk& lnk ) {
423 d->setDocumentUsed = false; 426 d->setDocumentUsed = false;
424 if ( mediaPlayerState->playlist() ) { 427 if ( mediaPlayerState->playlist() ) {
425 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) 428 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" )
426 d->selectedFiles->addToSelection( lnk ); 429 d->selectedFiles->addToSelection( lnk );
427 } 430 }
428 else 431 else
429 mediaPlayerState->setPlaying( true); 432 mediaPlayerState->setPlaying( true);
430} 433}
431 434
432 435
433void PlayListWidget::clearList() { 436void PlayListWidget::clearList() {
434 while ( first() ) 437 while ( first() )
435 d->selectedFiles->removeSelected(); 438 d->selectedFiles->removeSelected();
436} 439}
437 440
438 441
439void PlayListWidget::addAllToList() { 442void PlayListWidget::addAllToList() {
440 DocLnkSet filesAll; 443 DocLnkSet filesAll;
441 Global::findDocuments(&filesAll, "video/*;audio/*"); 444 Global::findDocuments(&filesAll, "video/*;audio/*");
442 QListIterator<DocLnk> Adit( filesAll.children() ); 445 QListIterator<DocLnk> Adit( filesAll.children() );
443 for ( ; Adit.current(); ++Adit ) 446 for ( ; Adit.current(); ++Adit )
444 if(QFileInfo(Adit.current()->file()).exists()) 447 if(QFileInfo(Adit.current()->file()).exists())
445 d->selectedFiles->addToSelection( **Adit ); 448 d->selectedFiles->addToSelection( **Adit );
446 tabWidget->setCurrentPage(0); 449 tabWidget->setCurrentPage(0);
447 450
448 writeCurrentM3u(); 451 writeCurrentM3u();
449 d->selectedFiles->first(); 452 d->selectedFiles->first();
450} 453}
451 454
452 455
453void PlayListWidget::addAllMusicToList() { 456void PlayListWidget::addAllMusicToList() {
454 QListIterator<DocLnk> dit( files.children() ); 457 QListIterator<DocLnk> dit( files.children() );
455 for ( ; dit.current(); ++dit ) 458 for ( ; dit.current(); ++dit )
456 if(QFileInfo(dit.current()->file()).exists()) 459 if(QFileInfo(dit.current()->file()).exists())
457 d->selectedFiles->addToSelection( **dit ); 460 d->selectedFiles->addToSelection( **dit );
458 tabWidget->setCurrentPage(0); 461 tabWidget->setCurrentPage(0);
459 462
460 writeCurrentM3u(); 463 writeCurrentM3u();
461 d->selectedFiles->first(); 464 d->selectedFiles->first();
462} 465}
463 466
464 467
465void PlayListWidget::addAllVideoToList() { 468void PlayListWidget::addAllVideoToList() {
466 QListIterator<DocLnk> dit( vFiles.children() ); 469 QListIterator<DocLnk> dit( vFiles.children() );
467 for ( ; dit.current(); ++dit ) 470 for ( ; dit.current(); ++dit )
468 if(QFileInfo( dit.current()->file()).exists()) 471 if(QFileInfo( dit.current()->file()).exists())
469 d->selectedFiles->addToSelection( **dit ); 472 d->selectedFiles->addToSelection( **dit );
470 tabWidget->setCurrentPage(0); 473 tabWidget->setCurrentPage(0);
471 474
472 writeCurrentM3u(); 475 writeCurrentM3u();
473 d->selectedFiles->first(); 476 d->selectedFiles->first();
474} 477}
475 478
476 479
477void PlayListWidget::setDocument(const QString& fileref) { 480void PlayListWidget::setDocument(const QString& fileref) {
478 qDebug(fileref); 481 qDebug(fileref);
479 fromSetDocument = TRUE; 482 fromSetDocument = TRUE;
480 QFileInfo fileInfo(fileref); 483 QFileInfo fileInfo(fileref);
481 if ( !fileInfo.exists() ) { 484 if ( !fileInfo.exists() ) {
482 QMessageBox::critical( 0, tr( "Invalid File" ), 485 QMessageBox::critical( 0, tr( "Invalid File" ),
483 tr( "There was a problem in getting the file." ) ); 486 tr( "There was a problem in getting the file." ) );
484 return; 487 return;
485 } 488 }
486// qDebug("setDocument "+fileref); 489// qDebug("setDocument "+fileref);
487 QString extension = fileInfo.extension(false); 490 QString extension = fileInfo.extension(false);
488 if( extension.find( "m3u", 0, false) != -1) { //is m3u 491 if( extension.find( "m3u", 0, false) != -1) { //is m3u
489 readm3u( fileref); 492 readm3u( fileref);
490 } 493 }
491 else if( extension.find( "pls", 0, false) != -1 ) { //is pls 494 else if( extension.find( "pls", 0, false) != -1 ) { //is pls
492 readPls( fileref); 495 readPls( fileref);
493 } 496 }
494 else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist 497 else if( fileref.find("playlist",0,TRUE) != -1) {//is playlist
495 clearList(); 498 clearList();
496 DocLnk lnk; 499 DocLnk lnk;
497 lnk.setName( fileInfo.baseName() ); //sets name 500 lnk.setName( fileInfo.baseName() ); //sets name
498 lnk.setFile( fileref ); //sets file name 501 lnk.setFile( fileref ); //sets file name
499 //addToSelection( lnk ); 502 //addToSelection( lnk );
500 503
501 loadList( lnk); 504 loadList( lnk);
502 d->selectedFiles->first(); 505 d->selectedFiles->first();
503 } else { 506 } else {
504 clearList(); 507 clearList();
505 DocLnk lnk; 508 DocLnk lnk;
506 lnk.setName( fileInfo.baseName() ); //sets name 509 lnk.setName( fileInfo.baseName() ); //sets name
507 lnk.setFile( fileref ); //sets file name 510 lnk.setFile( fileref ); //sets file name
508 addToSelection( lnk ); 511 addToSelection( lnk );
509// addToSelection( DocLnk( fileref ) ); 512// addToSelection( DocLnk( fileref ) );
510 d->setDocumentUsed = TRUE; 513 d->setDocumentUsed = TRUE;
511 mediaPlayerState->setPlaying( FALSE ); 514 mediaPlayerState->setPlaying( FALSE );
512 qApp->processEvents(); 515 qApp->processEvents();
513 mediaPlayerState->setPlaying( TRUE ); 516 mediaPlayerState->setPlaying( TRUE );
514 qApp->processEvents(); 517 qApp->processEvents();
515 setCaption(tr("OpiePlayer")); 518 setCaption(tr("OpiePlayer"));
516 } 519 }
517} 520}
518 521
519 522
520void PlayListWidget::setActiveWindow() { 523void PlayListWidget::setActiveWindow() {
521 qDebug("SETTING active window"); 524 qDebug("SETTING active window");
522 525
523 // When we get raised we need to ensure that it switches views 526 // When we get raised we need to ensure that it switches views
524 char origView = mediaPlayerState->view(); 527 char origView = mediaPlayerState->view();
525 mediaPlayerState->setView( 'l' ); // invalidate 528 mediaPlayerState->setView( 'l' ); // invalidate
526 mediaPlayerState->setView( origView ); // now switch back 529 mediaPlayerState->setView( origView ); // now switch back
527} 530}
528 531
@@ -1039,384 +1042,427 @@ void PlayListWidget::populateVideoView() {
1039 QString::number( QFile( Vdit.current()->file() ).size() ), 1042 QString::number( QFile( Vdit.current()->file() ).size() ),
1040 storage, Vdit.current()->file()); 1043 storage, Vdit.current()->file());
1041 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); 1044 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" ));
1042 } 1045 }
1043 } 1046 }
1044} 1047}
1045 1048
1046void PlayListWidget::openFile() { 1049void PlayListWidget::openFile() {
1047 qDebug("<<<<<<<<<OPEN File"); 1050 qDebug("<<<<<<<<<OPEN File");
1048 QString filename, name; 1051 QString filename, name;
1049 InputDialog *fileDlg; 1052 InputDialog *fileDlg;
1050 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 1053 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
1051 fileDlg->exec(); 1054 fileDlg->exec();
1052 if( fileDlg->result() == 1 ) { 1055 if( fileDlg->result() == 1 ) {
1053 filename = fileDlg->text(); 1056 filename = fileDlg->text();
1054 qDebug( "Selected filename is " + filename ); 1057 qDebug( "Selected filename is " + filename );
1055// Om3u *m3uList; 1058// Om3u *m3uList;
1056 DocLnk lnk; 1059 DocLnk lnk;
1057 Config cfg( "OpiePlayer" ); 1060 Config cfg( "OpiePlayer" );
1058 cfg.setGroup("PlayList"); 1061 cfg.setGroup("PlayList");
1059 1062
1060 if(filename.left(4) == "http") { 1063 if(filename.left(4) == "http") {
1061 QString m3uFile, m3uFilePath; 1064 QString m3uFile, m3uFilePath;
1062 if(filename.find(":",8,TRUE) != -1) { //found a port 1065 if(filename.find(":",8,TRUE) != -1) { //found a port
1063 m3uFile = filename.left( filename.find( ":",8,TRUE)); 1066 m3uFile = filename.left( filename.find( ":",8,TRUE));
1064 m3uFile = m3uFile.right( 7); 1067 m3uFile = m3uFile.right( 7);
1065 } else if(filename.left(4) == "http"){ 1068 } else if(filename.left(4) == "http"){
1066 m3uFile=filename; 1069 m3uFile=filename;
1067 m3uFile = m3uFile.right( m3uFile.length() - 7); 1070 m3uFile = m3uFile.right( m3uFile.length() - 7);
1068 } else{ 1071 } else{
1069 m3uFile=filename; 1072 m3uFile=filename;
1070 } 1073 }
1071 1074
1072// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); 1075// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile);
1073 lnk.setName( filename ); //sets name 1076 lnk.setName( filename ); //sets name
1074 lnk.setFile( filename ); //sets file name 1077 lnk.setFile( filename ); //sets file name
1075 lnk.setIcon("opieplayer2/musicfile"); 1078 lnk.setIcon("opieplayer2/musicfile");
1076 d->selectedFiles->addToSelection( lnk ); 1079 d->selectedFiles->addToSelection( lnk );
1077 writeCurrentM3u(); 1080 writeCurrentM3u();
1078 } 1081 }
1079 else if( filename.right( 3) == "m3u" ) { 1082 else if( filename.right( 3) == "m3u" ) {
1080 readm3u( filename ); 1083 readm3u( filename );
1081 1084
1082 } else if( filename.right(3) == "pls" ) { 1085 } else if( filename.right(3) == "pls" ) {
1083 readPls( filename ); 1086 readPls( filename );
1084 } else { 1087 } else {
1085 lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name 1088 lnk.setName( fullBaseName ( QFileInfo(filename)) ); //sets name
1086 lnk.setFile( filename ); //sets file name 1089 lnk.setFile( filename ); //sets file name
1087 d->selectedFiles->addToSelection( lnk); 1090 d->selectedFiles->addToSelection( lnk);
1088 writeCurrentM3u(); 1091 writeCurrentM3u();
1089 } 1092 }
1090 } 1093 }
1091 1094
1092 if( fileDlg ) { 1095 if( fileDlg ) {
1093 delete fileDlg; 1096 delete fileDlg;
1094 } 1097 }
1095} 1098}
1096 1099
1097 1100
1098/* 1101/*
1099reads m3u and shows files/urls to playlist widget */ 1102reads m3u and shows files/urls to playlist widget */
1100void PlayListWidget::readm3u( const QString &filename ) { 1103void PlayListWidget::readm3u( const QString &filename ) {
1101 qDebug( "read m3u filename " + filename ); 1104 qDebug( "read m3u filename " + filename );
1102 1105
1103 Om3u *m3uList; 1106 Om3u *m3uList;
1104 QString s, name; 1107 QString s, name;
1105 m3uList = new Om3u( filename, IO_ReadOnly ); 1108 m3uList = new Om3u( filename, IO_ReadOnly );
1106 m3uList->readM3u(); 1109 m3uList->readM3u();
1107 DocLnk lnk; 1110 DocLnk lnk;
1108 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 1111 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
1109 s = *it; 1112 s = *it;
1110// qDebug("reading "+ s); 1113// qDebug("reading "+ s);
1111 if(s.left(4)=="http") { 1114 if(s.left(4)=="http") {
1112 lnk.setName( s ); //sets file name 1115 lnk.setName( s ); //sets file name
1113 lnk.setIcon("opieplayer2/musicfile"); 1116 lnk.setIcon("opieplayer2/musicfile");
1114 if(s.right(4) != '.' || s.right(5) != '.') 1117 if(s.right(4) != '.' || s.right(5) != '.')
1115 lnk.setFile( s+"/"); //if url with no extension 1118 lnk.setFile( s+"/"); //if url with no extension
1116 else 1119 else
1117 lnk.setFile( s ); //sets file name 1120 lnk.setFile( s ); //sets file name
1118 1121
1119 } else { 1122 } else {
1120 // if( QFileInfo( s ).exists() ) { 1123 // if( QFileInfo( s ).exists() ) {
1121 lnk.setName( fullBaseName ( QFileInfo(s))); 1124 lnk.setName( fullBaseName ( QFileInfo(s)));
1122 // if(s.right(4) == '.') {//if regular file 1125 // if(s.right(4) == '.') {//if regular file
1123 if(s.left(1) != "/") { 1126 if(s.left(1) != "/") {
1124 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); 1127 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s);
1125 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); 1128 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
1126 lnk.setIcon("SoundPlayer"); 1129 lnk.setIcon("SoundPlayer");
1127 } else { 1130 } else {
1128 // qDebug("set link2 "+s); 1131 // qDebug("set link2 "+s);
1129 lnk.setFile( s); 1132 lnk.setFile( s);
1130 lnk.setIcon("SoundPlayer"); 1133 lnk.setIcon("SoundPlayer");
1131 } 1134 }
1132 } 1135 }
1133 d->selectedFiles->addToSelection( lnk ); 1136 d->selectedFiles->addToSelection( lnk );
1134 } 1137 }
1135 Config config( "OpiePlayer" ); 1138 Config config( "OpiePlayer" );
1136 config.setGroup( "PlayList" ); 1139 config.setGroup( "PlayList" );
1137 1140
1138 config.writeEntry("CurrentPlaylist",filename); 1141 config.writeEntry("CurrentPlaylist",filename);
1139 config.write(); 1142 config.write();
1140 currentPlayList=filename; 1143 currentPlayList=filename;
1141 1144
1142// m3uList->write(); 1145// m3uList->write();
1143 m3uList->close(); 1146 m3uList->close();
1144 if(m3uList) delete m3uList; 1147 if(m3uList) delete m3uList;
1145 1148
1146 d->selectedFiles->setSelectedItem( s); 1149 d->selectedFiles->setSelectedItem( s);
1147 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename))); 1150 setCaption(tr("OpiePlayer: ")+ fullBaseName ( QFileInfo(filename)));
1148 1151
1149} 1152}
1150 1153
1151/* 1154/*
1152reads pls and adds files/urls to playlist */ 1155reads pls and adds files/urls to playlist */
1153void PlayListWidget::readPls( const QString &filename ) { 1156void PlayListWidget::readPls( const QString &filename ) {
1154 1157
1155 qDebug( "pls filename is " + filename ); 1158 qDebug( "pls filename is " + filename );
1156 Om3u *m3uList; 1159 Om3u *m3uList;
1157 QString s, name; 1160 QString s, name;
1158 m3uList = new Om3u( filename, IO_ReadOnly ); 1161 m3uList = new Om3u( filename, IO_ReadOnly );
1159 m3uList->readPls(); 1162 m3uList->readPls();
1160 1163
1161 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 1164 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
1162 s = *it; 1165 s = *it;
1163 // s.replace( QRegExp( "%20" )," " ); 1166 // s.replace( QRegExp( "%20" )," " );
1164 DocLnk lnk( s ); 1167 DocLnk lnk( s );
1165 QFileInfo f( s ); 1168 QFileInfo f( s );
1166 QString name = fullBaseName ( f); 1169 QString name = fullBaseName ( f);
1167 1170
1168 if( name.left( 4 ) == "http" ) { 1171 if( name.left( 4 ) == "http" ) {
1169 name = s.right( s.length() - 7); 1172 name = s.right( s.length() - 7);
1170 } else { 1173 } else {
1171 name = s; 1174 name = s;
1172 } 1175 }
1173 1176
1174 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 1177 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
1175 1178
1176 lnk.setName( name ); 1179 lnk.setName( name );
1177 if( s.at( s.length() - 4) == '.') {// if this is probably a file 1180 if( s.at( s.length() - 4) == '.') {// if this is probably a file
1178 lnk.setFile( s ); 1181 lnk.setFile( s );
1179 } else { //if its a url 1182 } else { //if its a url
1180 if( name.right( 1 ).find( '/' ) == -1) { 1183 if( name.right( 1 ).find( '/' ) == -1) {
1181 s += "/"; 1184 s += "/";
1182 } 1185 }
1183 lnk.setFile( s ); 1186 lnk.setFile( s );
1184 } 1187 }
1185 lnk.setType( "audio/x-mpegurl" ); 1188 lnk.setType( "audio/x-mpegurl" );
1186 1189
1187 lnk.writeLink(); 1190 lnk.writeLink();
1188 d->selectedFiles->addToSelection( lnk ); 1191 d->selectedFiles->addToSelection( lnk );
1189 } 1192 }
1190 1193
1191 m3uList->close(); 1194 m3uList->close();
1192 if(m3uList) delete m3uList; 1195 if(m3uList) delete m3uList;
1193} 1196}
1194 1197
1195/* 1198/*
1196 writes current playlist to current m3u file */ 1199 writes current playlist to current m3u file */
1197void PlayListWidget::writeCurrentM3u() { 1200void PlayListWidget::writeCurrentM3u() {
1198 qDebug("writing to current m3u"); 1201 qDebug("writing to current m3u");
1199 Config cfg( "OpiePlayer" ); 1202 Config cfg( "OpiePlayer" );
1200 cfg.setGroup("PlayList"); 1203 cfg.setGroup("PlayList");
1201 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 1204 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
1202 Om3u *m3uList; 1205 Om3u *m3uList;
1203 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); 1206 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
1204 1207
1205 if( d->selectedFiles->first()) { 1208 if( d->selectedFiles->first()) {
1206 do { 1209 do {
1207 qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); 1210 qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file());
1208 m3uList->add( d->selectedFiles->current()->file() ); 1211 m3uList->add( d->selectedFiles->current()->file() );
1209 } 1212 }
1210 while ( d->selectedFiles->next() ); 1213 while ( d->selectedFiles->next() );
1211 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); 1214 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
1212 m3uList->write(); 1215 m3uList->write();
1213 m3uList->close(); 1216 m3uList->close();
1214 1217
1215 if(m3uList) delete m3uList; 1218 if(m3uList) delete m3uList;
1216 } 1219 }
1217} 1220}
1218 1221
1219 /* 1222 /*
1220 writes current playlist to m3u file */ 1223 writes current playlist to m3u file */
1221void PlayListWidget::writem3u() { 1224void PlayListWidget::writem3u() {
1222 InputDialog *fileDlg; 1225 InputDialog *fileDlg;
1223 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 1226 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
1224 fileDlg->exec(); 1227 fileDlg->exec();
1225 QString name, filename, list; 1228 QString name, filename, list;
1226 Om3u *m3uList; 1229 Om3u *m3uList;
1227 1230
1228 if( fileDlg->result() == 1 ) { 1231 if( fileDlg->result() == 1 ) {
1229 name = fileDlg->text(); 1232 name = fileDlg->text();
1230// qDebug( filename ); 1233// qDebug( filename );
1231 if( name.find("/",0,true) != -1) {// assume they specify a file path 1234 if( name.find("/",0,true) != -1) {// assume they specify a file path
1232 filename = name; 1235 filename = name;
1233 name = name.right(name.length()- name.findRev("/",-1,true) - 1 ); 1236 name = name.right(name.length()- name.findRev("/",-1,true) - 1 );
1234 } 1237 }
1235 else //otherwise dump it somewhere noticable 1238 else //otherwise dump it somewhere noticable
1236 filename = QPEApplication::documentDir() + "/" + name; 1239 filename = QPEApplication::documentDir() + "/" + name;
1237 1240
1238 if( filename.right( 3 ) != "m3u" ) //needs filename extension 1241 if( filename.right( 3 ) != "m3u" ) //needs filename extension
1239 filename += ".m3u"; 1242 filename += ".m3u";
1240 1243
1241 if( d->selectedFiles->first()) { 1244 if( d->selectedFiles->first()) {
1242 m3uList = new Om3u(filename, IO_ReadWrite); 1245 m3uList = new Om3u(filename, IO_ReadWrite);
1243 1246
1244 do { 1247 do {
1245 m3uList->add( d->selectedFiles->current()->file()); 1248 m3uList->add( d->selectedFiles->current()->file());
1246 } 1249 }
1247 while ( d->selectedFiles->next() ); 1250 while ( d->selectedFiles->next() );
1248 // qDebug( list ); 1251 // qDebug( list );
1249 m3uList->write(); 1252 m3uList->write();
1250 m3uList->close(); 1253 m3uList->close();
1251 if(m3uList) delete m3uList; 1254 if(m3uList) delete m3uList;
1252 1255
1253 if(fileDlg) delete fileDlg; 1256 if(fileDlg) delete fileDlg;
1254 1257
1255 DocLnk lnk; 1258 DocLnk lnk;
1256 lnk.setFile( filename); 1259 lnk.setFile( filename);
1257 lnk.setIcon("opieplayer2/playlist2"); 1260 lnk.setIcon("opieplayer2/playlist2");
1258 lnk.setName( name); //sets file name 1261 lnk.setName( name); //sets file name
1259 1262
1260 // qDebug(filename); 1263 // qDebug(filename);
1261 Config config( "OpiePlayer" ); 1264 Config config( "OpiePlayer" );
1262 config.setGroup( "PlayList" ); 1265 config.setGroup( "PlayList" );
1263 1266
1264 config.writeEntry("CurrentPlaylist",filename); 1267 config.writeEntry("CurrentPlaylist",filename);
1265 currentPlayList=filename; 1268 currentPlayList=filename;
1266 1269
1267 if(!lnk.writeLink()) { 1270 if(!lnk.writeLink()) {
1268 qDebug("Writing doclink did not work"); 1271 qDebug("Writing doclink did not work");
1269 } 1272 }
1270 1273
1271 setCaption(tr("OpiePlayer: ") + name); 1274 setCaption(tr("OpiePlayer: ") + name);
1272 } 1275 }
1273 } 1276 }
1274} 1277}
1275 1278
1276 1279
1277void PlayListWidget::keyReleaseEvent( QKeyEvent *e) 1280void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
1278{ 1281{
1279 switch ( e->key() ) { 1282 switch ( e->key() ) {
1280////////////////////////////// Zaurus keys 1283////////////////////////////// Zaurus keys
1281 case Key_F9: //activity 1284 case Key_F9: //activity
1282// if(audioUI->isHidden()) 1285// if(audioUI->isHidden())
1283// audioUI->showMaximized(); 1286// audioUI->showMaximized();
1284 break; 1287 break;
1285 case Key_F10: //contacts 1288 case Key_F10: //contacts
1286// if( videoUI->isHidden()) 1289// if( videoUI->isHidden())
1287// videoUI->showMaximized(); 1290// videoUI->showMaximized();
1288 break; 1291 break;
1289 case Key_F11: //menu 1292 case Key_F11: //menu
1290 break; 1293 break;
1291 case Key_F12: //home 1294 case Key_F12: //home
1292// doBlank(); 1295// doBlank();
1293 break; 1296 break;
1294 case Key_F13: //mail 1297 case Key_F13: //mail
1295// doUnblank(); 1298// doUnblank();
1296 break; 1299 break;
1297 case Key_Q: //add to playlist 1300 case Key_Q: //add to playlist
1298 qDebug("Add"); 1301 qDebug("Add");
1299 addSelected(); 1302 addSelected();
1300 break; 1303 break;
1301 case Key_R: //remove from playlist 1304 case Key_R: //remove from playlist
1302 removeSelected(); 1305 removeSelected();
1303 break; 1306 break;
1304// case Key_P: //play 1307// case Key_P: //play
1305// qDebug("Play"); 1308// qDebug("Play");
1306// playSelected(); 1309// playSelected();
1307// break; 1310// break;
1308 case Key_Space: 1311 case Key_Space:
1309 qDebug("Play"); 1312 qDebug("Play");
1310// playSelected(); puh 1313// playSelected(); puh
1311 break; 1314 break;
1312 case Key_1: 1315 case Key_1:
1313 tabWidget->setCurrentPage(0); 1316 tabWidget->setCurrentPage(0);
1314 break; 1317 break;
1315 case Key_2: 1318 case Key_2:
1316 tabWidget->setCurrentPage(1); 1319 tabWidget->setCurrentPage(1);
1317 break; 1320 break;
1318 case Key_3: 1321 case Key_3:
1319 tabWidget->setCurrentPage(2); 1322 tabWidget->setCurrentPage(2);
1320 break; 1323 break;
1321 case Key_4: 1324 case Key_4:
1322 tabWidget->setCurrentPage(3); 1325 tabWidget->setCurrentPage(3);
1323 break; 1326 break;
1324 case Key_Down: 1327 case Key_Down:
1325 if ( !d->selectedFiles->next() ) 1328 if ( !d->selectedFiles->next() )
1326 d->selectedFiles->first(); 1329 d->selectedFiles->first();
1327 1330
1328 break; 1331 break;
1329 case Key_Up: 1332 case Key_Up:
1330 if ( !d->selectedFiles->prev() ) 1333 if ( !d->selectedFiles->prev() )
1331 // d->selectedFiles->last(); 1334 // d->selectedFiles->last();
1332 1335
1333 break; 1336 break;
1334 1337
1335 } 1338 }
1336} 1339}
1337 1340
1338void PlayListWidget::keyPressEvent( QKeyEvent *) 1341void PlayListWidget::keyPressEvent( QKeyEvent *)
1339{ 1342{
1340// qDebug("Key press"); 1343// qDebug("Key press");
1341// switch ( e->key() ) { 1344// switch ( e->key() ) {
1342// ////////////////////////////// Zaurus keys 1345// ////////////////////////////// Zaurus keys
1343// case Key_A: //add to playlist 1346// case Key_A: //add to playlist
1344// qDebug("Add"); 1347// qDebug("Add");
1345// addSelected(); 1348// addSelected();
1346// break; 1349// break;
1347// case Key_R: //remove from playlist 1350// case Key_R: //remove from playlist
1348// removeSelected(); 1351// removeSelected();
1349// break; 1352// break;
1350// case Key_P: //play 1353// case Key_P: //play
1351// qDebug("Play"); 1354// qDebug("Play");
1352// playSelected(); 1355// playSelected();
1353// break; 1356// break;
1354// case Key_Space: 1357// case Key_Space:
1355// qDebug("Play"); 1358// qDebug("Play");
1356// playSelected(); 1359// playSelected();
1357// break; 1360// break;
1358// } 1361// }
1359} 1362}
1360 1363
1361void PlayListWidget::doBlank() { 1364void PlayListWidget::doBlank() {
1362 qDebug("do blanking"); 1365 qDebug("do blanking");
1363 fd=open("/dev/fb0",O_RDWR); 1366 fd=open("/dev/fb0",O_RDWR);
1364 if (fd != -1) { 1367 if (fd != -1) {
1365 ioctl(fd,FBIOBLANK,1); 1368 ioctl(fd,FBIOBLANK,1);
1366// close(fd); 1369// close(fd);
1367 } 1370 }
1368} 1371}
1369 1372
1370void PlayListWidget::doUnblank() { 1373void PlayListWidget::doUnblank() {
1371 // this crashes opieplayer with a segfault 1374 // this crashes opieplayer with a segfault
1372// int fd; 1375// int fd;
1373// fd=open("/dev/fb0",O_RDWR); 1376// fd=open("/dev/fb0",O_RDWR);
1374 qDebug("do unblanking"); 1377 qDebug("do unblanking");
1375 if (fd != -1) { 1378 if (fd != -1) {
1376 ioctl(fd,FBIOBLANK,0); 1379 ioctl(fd,FBIOBLANK,0);
1377 close(fd); 1380 close(fd);
1378 } 1381 }
1379 QCopEnvelope h("QPE/System", "setBacklight(int)"); 1382 QCopEnvelope h("QPE/System", "setBacklight(int)");
1380 h <<-3;// v[1]; // -3 Force on 1383 h <<-3;// v[1]; // -3 Force on
1381} 1384}
1382 1385
1383void PlayListWidget::populateSkinsMenu() { 1386void PlayListWidget::populateSkinsMenu() {
1384 int item = 0; 1387 int item = 0;
1385 defaultSkinIndex = 0; 1388 defaultSkinIndex = 0;
1386 QString skinName; 1389 QString skinName;
1387 Config cfg( "OpiePlayer" ); 1390 Config cfg( "OpiePlayer" );
1388 cfg.setGroup("Options" ); 1391 cfg.setGroup("Options" );
1389 QString skin = cfg.readEntry( "Skin", "default" ); 1392 QString skin = cfg.readEntry( "Skin", "default" );
1390 1393
1391 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); 1394 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" );
1392 skinsDir.setFilter( QDir::Dirs ); 1395 skinsDir.setFilter( QDir::Dirs );
1393 skinsDir.setSorting(QDir::Name ); 1396 skinsDir.setSorting(QDir::Name );
1394 const QFileInfoList *skinslist = skinsDir.entryInfoList(); 1397 const QFileInfoList *skinslist = skinsDir.entryInfoList();
1395 QFileInfoListIterator it( *skinslist ); 1398 QFileInfoListIterator it( *skinslist );
1396 QFileInfo *fi; 1399 QFileInfo *fi;
1397 while ( ( fi = it.current() ) ) { 1400 while ( ( fi = it.current() ) ) {
1398 skinName = fi->fileName(); 1401 skinName = fi->fileName();
1399// qDebug( fi->fileName() ); 1402// qDebug( fi->fileName() );
1400 if( skinName != "." && skinName != ".." && skinName !="CVS" ) { 1403 if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
1401 item = skinsMenu->insertItem( fi->fileName() ) ; 1404 item = skinsMenu->insertItem( fi->fileName() ) ;
1402 } 1405 }
1403 if( skinName == "default" ) { 1406 if( skinName == "default" ) {
1404 defaultSkinIndex = item; 1407 defaultSkinIndex = item;
1405 } 1408 }
1406 if( skinName == skin ) { 1409 if( skinName == skin ) {
1407 skinsMenu->setItemChecked( item, TRUE ); 1410 skinsMenu->setItemChecked( item, TRUE );
1408 } 1411 }
1409 ++it; 1412 ++it;
1410 } 1413 }
1411} 1414}
1412 1415
1413void PlayListWidget::skinsMenuActivated( int item ) { 1416void PlayListWidget::skinsMenuActivated( int item ) {
1414 for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { 1417 for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) {
1415 skinsMenu->setItemChecked( i, FALSE ); 1418 skinsMenu->setItemChecked( i, FALSE );
1416 } 1419 }
1417 skinsMenu->setItemChecked( item, TRUE ); 1420 skinsMenu->setItemChecked( item, TRUE );
1418 1421
1419 Config cfg( "OpiePlayer" ); 1422 Config cfg( "OpiePlayer" );
1420 cfg.setGroup("Options"); 1423 cfg.setGroup("Options");
1421 cfg.writeEntry("Skin", skinsMenu->text( item ) ); 1424 cfg.writeEntry("Skin", skinsMenu->text( item ) );
1422} 1425}
1426
1427void PlayListWidget::qcopReceive(const QCString &msg, const QByteArray &data) {
1428 qDebug("qcop message "+msg );
1429 QDataStream stream ( data, IO_ReadOnly );
1430 if ( msg == "play()" ) { //plays current selection
1431 btnPlay( true);
1432 } else if ( msg == "stop()" ) {
1433 mediaPlayerState->setPlaying( false);
1434 } else if ( msg == "togglePause()" ) {
1435 mediaPlayerState->togglePaused();
1436 } else if ( msg == "next()" ) { //select next in list
1437 mediaPlayerState->setNext();
1438 } else if ( msg == "prev()" ) { //select previous in list
1439 mediaPlayerState->setPrev();
1440 } else if ( msg == "toggleLooping()" ) { //loop or not loop
1441 mediaPlayerState->toggleLooping();
1442 } else if ( msg == "toggleShuffled()" ) { //shuffled or not shuffled
1443 mediaPlayerState->toggleShuffled();
1444 } else if ( msg == "volUp()" ) { //volume more
1445// emit moreClicked();
1446// emit moreReleased();
1447 } else if ( msg == "volDown()" ) { //volume less
1448// emit lessClicked();
1449// emit lessReleased();
1450 } else if ( msg == "play(QString)" ) { //play this now
1451 QString file;
1452 stream >> file;
1453 setDocument( (const QString &) file);
1454 } else if ( msg == "add(QString)" ) { //add to playlist
1455 QString file;
1456 stream >> file;
1457 QFileInfo fileInfo(file);
1458 DocLnk lnk;
1459 lnk.setName( fileInfo.baseName() ); //sets name
1460 lnk.setFile( file ); //sets file name
1461 addToSelection( lnk );
1462 } else if ( msg == "rem(QString)" ) { //remove from playlist
1463 QString file;
1464 stream >> file;
1465
1466 }
1467
1468}
diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h
index 1118b76..e66bcb9 100644
--- a/core/multimedia/opieplayer/playlistwidget.h
+++ b/core/multimedia/opieplayer/playlistwidget.h
@@ -1,133 +1,137 @@
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 <qpe/qcopenvelope_qws.h>
30
29#include "om3u.h" 31#include "om3u.h"
30/* #include <qtimer.h> */ 32/* #include <qtimer.h> */
31 33
32 34
33class PlayListWidgetPrivate; 35class PlayListWidgetPrivate;
34class Config; 36class Config;
35class QListViewItem; 37class QListViewItem;
36class QListView; 38class QListView;
37class QPoint; 39class QPoint;
38class QAction; 40class QAction;
39class QLabel; 41class QLabel;
40class QPopupMenu; 42class QPopupMenu;
41 43
42class PlayListWidget : public QMainWindow { 44class PlayListWidget : public QMainWindow {
43 Q_OBJECT 45 Q_OBJECT
44public: 46public:
45 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); 47 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 );
46 ~PlayListWidget(); 48 ~PlayListWidget();
47 QTabWidget * tabWidget; 49 QTabWidget * tabWidget;
48 QAction *fullScreenButton, *scaleButton; 50 QAction *fullScreenButton, *scaleButton;
49 DocLnkSet files; 51 DocLnkSet files;
50 DocLnkSet vFiles; 52 DocLnkSet vFiles;
51 QListView *audioView, *videoView, *playlistView; 53 QListView *audioView, *videoView, *playlistView;
52 QLabel *libString; 54 QLabel *libString;
53 bool fromSetDocument; 55 bool fromSetDocument;
54 bool insanityBool; 56 bool insanityBool;
55 QString setDocFileRef, currentPlayList; 57 QString setDocFileRef, currentPlayList;
56 // retrieve the current playlist entry (media file link) 58 // retrieve the current playlist entry (media file link)
57 const DocLnk *current(); 59 const DocLnk *current();
58 void useSelectedDocument(); 60 void useSelectedDocument();
59/* QTimer * menuTimer; */ 61/* QTimer * menuTimer; */
60 FileSelector* playLists; 62 FileSelector* playLists;
61 QPushButton *tbDeletePlaylist; 63 QPushButton *tbDeletePlaylist;
62 int fd, selected; 64 int fd, selected;
63public slots: 65public slots:
64 bool first(); 66 bool first();
65 bool last(); 67 bool last();
66 bool next(); 68 bool next();
67 bool prev(); 69 bool prev();
68/* void setFullScreen(); */ 70/* void setFullScreen(); */
69/* void setScaled(); */ 71/* void setScaled(); */
70protected: 72protected:
73 QCopChannel * channel;
71 QPopupMenu *skinsMenu; 74 QPopupMenu *skinsMenu;
72/* void contentsMousePressEvent( QMouseEvent * e ); */ 75/* void contentsMousePressEvent( QMouseEvent * e ); */
73/* void contentsMouseReleaseEvent( QMouseEvent * e ); */ 76/* void contentsMouseReleaseEvent( QMouseEvent * e ); */
74void keyReleaseEvent( QKeyEvent *e); 77void keyReleaseEvent( QKeyEvent *e);
75void keyPressEvent( QKeyEvent *e); 78void keyPressEvent( QKeyEvent *e);
76private: 79private:
77 int defaultSkinIndex; 80 int defaultSkinIndex;
78 bool audioScan, videoScan; 81 bool audioScan, videoScan;
79 void doBlank(); 82 void doBlank();
80 void doUnblank(); 83 void doUnblank();
81 void readm3u(const QString &); 84 void readm3u(const QString &);
82 void readPls(const QString &); 85 void readPls(const QString &);
83 86
84 87
85 void initializeStates(); 88 void initializeStates();
86 void readConfig( Config& cfg ); 89 void readConfig( Config& cfg );
87 void writeConfig( Config& cfg ) const; 90 void writeConfig( Config& cfg ) const;
88 PlayListWidgetPrivate *d; // Private implementation data 91 PlayListWidgetPrivate *d; // Private implementation data
89 void populateAudioView(); 92 void populateAudioView();
90 void populateVideoView(); 93 void populateVideoView();
91private slots: 94private slots:
92 95
96 void qcopReceive(const QCString&, const QByteArray&);
93 void populateSkinsMenu(); 97 void populateSkinsMenu();
94 void skinsMenuActivated(int); 98 void skinsMenuActivated(int);
95 void writem3u(); 99 void writem3u();
96 void writeCurrentM3u(); 100 void writeCurrentM3u();
97 void scanForAudio(); 101 void scanForAudio();
98 void scanForVideo(); 102 void scanForVideo();
99 void openFile(); 103 void openFile();
100 void setDocument( const QString& fileref ); 104 void setDocument( const QString& fileref );
101 void addToSelection( const DocLnk& ); // Add a media file to the playlist 105 void addToSelection( const DocLnk& ); // Add a media file to the playlist
102 void addToSelection( QListViewItem* ); // Add a media file to the playlist 106 void addToSelection( QListViewItem* ); // Add a media file to the playlist
103 void setActiveWindow(); // need to handle this to show the right view 107 void setActiveWindow(); // need to handle this to show the right view
104 void setPlaylist( bool ); // Show/Hide the playlist 108 void setPlaylist( bool ); // Show/Hide the playlist
105 void setView( char ); 109 void setView( char );
106 void clearList(); 110 void clearList();
107 void addAllToList(); 111 void addAllToList();
108 void addAllMusicToList(); 112 void addAllMusicToList();
109 void addAllVideoToList(); 113 void addAllVideoToList();
110 void saveList(); // Save the playlist 114 void saveList(); // Save the playlist
111 void loadList( const DocLnk &); // Load a playlist 115 void loadList( const DocLnk &); // Load a playlist
112 void playIt( QListViewItem *); 116 void playIt( QListViewItem *);
113 117
114 void btnPlay(bool); 118 void btnPlay(bool);
115 void deletePlaylist(); 119 void deletePlaylist();
116 void addSelected(); 120 void addSelected();
117 void removeSelected(); 121 void removeSelected();
118 void tabChanged(QWidget*); 122 void tabChanged(QWidget*);
119 void viewPressed( int, QListViewItem *, const QPoint&, int); 123 void viewPressed( int, QListViewItem *, const QPoint&, int);
120 void playlistViewPressed( int, QListViewItem *, const QPoint&, int); 124 void playlistViewPressed( int, QListViewItem *, const QPoint&, int);
121 void playSelected(); 125 void playSelected();
122 void listDelete(); 126 void listDelete();
123 127
124protected slots: 128protected slots:
125/* void cancelMenuTimer(); */ 129/* void cancelMenuTimer(); */
126/* void showFileMenu(); */ 130/* void showFileMenu(); */
127 131
128 132
129}; 133};
130 134
131 135
132#endif // PLAY_LIST_WIDGET_H 136#endif // PLAY_LIST_WIDGET_H
133 137