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