summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-08-16 03:02:33 (UTC)
committer llornkcor <llornkcor>2002-08-16 03:02:33 (UTC)
commit52eb803145b0a246e9d0e39c57bd327365f86459 (patch) (unidiff)
treeb511ebffe1fa69938fb94e320127fee61b3f371e
parent0b8d488ab4691dc32ecd49b2b2fb7c497cb4c03a (diff)
downloadopie-52eb803145b0a246e9d0e39c57bd327365f86459.zip
opie-52eb803145b0a246e9d0e39c57bd327365f86459.tar.gz
opie-52eb803145b0a246e9d0e39c57bd327365f86459.tar.bz2
make other lists fit when full
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index f5906b3..6dcc842 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -1,1293 +1,1293 @@
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( "opieplayer2/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" ), "opieplayer2/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" ), "opieplayer2/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" ), "opieplayer2/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" ),"opieplayer2/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" ),"opieplayer2/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,250); 200 d->playListFrame ->setMinimumSize(235,250);
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" ), "opieplayer2/up", d->selectedFiles, SLOT(moveSelectedUp()) ); 210 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", d->selectedFiles, SLOT(moveSelectedUp()) );
211 new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", d->selectedFiles, SLOT(removeSelected()) ); 211 new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", d->selectedFiles, SLOT(removeSelected()) );
212 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/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,250);
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,250);
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 if(QFileInfo( linkFile).exists() ) { 325 if(QFileInfo( linkFile).exists() ) {
326 DocLnk lnk( linkFile ); 326 DocLnk lnk( linkFile );
327 if ( QFileInfo( lnk.file()).exists() || linkFile.find("http",0,TRUE) != -1) { 327 if ( QFileInfo( lnk.file()).exists() || linkFile.find("http",0,TRUE) != -1) {
328 d->selectedFiles->addToSelection( lnk ); 328 d->selectedFiles->addToSelection( lnk );
329 } 329 }
330 } 330 }
331 } 331 }
332d->selectedFiles->setSelectedItem( currentString); 332d->selectedFiles->setSelectedItem( currentString);
333} 333}
334 334
335 335
336void PlayListWidget::writeConfig( Config& cfg ) const { 336void PlayListWidget::writeConfig( Config& cfg ) const {
337 337
338 d->selectedFiles->writeCurrent( cfg); 338 d->selectedFiles->writeCurrent( cfg);
339 cfg.setGroup("PlayList"); 339 cfg.setGroup("PlayList");
340 int noOfFiles = 0; 340 int noOfFiles = 0;
341 d->selectedFiles->first(); 341 d->selectedFiles->first();
342 do { 342 do {
343 const DocLnk *lnk = d->selectedFiles->current(); 343 const DocLnk *lnk = d->selectedFiles->current();
344 if ( lnk ) { 344 if ( lnk ) {
345 QString entryName; 345 QString entryName;
346 entryName.sprintf( "File%i", noOfFiles + 1 ); 346 entryName.sprintf( "File%i", noOfFiles + 1 );
347 cfg.writeEntry( entryName, lnk->linkFile() ); 347 cfg.writeEntry( entryName, lnk->linkFile() );
348 // if this link does exist, add it so we have the file 348 // if this link does exist, add it so we have the file
349 // next time... 349 // next time...
350 if ( !QFile::exists( lnk->linkFile() ) ) { 350 if ( !QFile::exists( lnk->linkFile() ) ) {
351 // the way writing lnks doesn't really check for out 351 // the way writing lnks doesn't really check for out
352 // of disk space, but check it anyway. 352 // of disk space, but check it anyway.
353 if ( !lnk->writeLink() ) { 353 if ( !lnk->writeLink() ) {
354 QMessageBox::critical( 0, tr("Out of space"), 354 QMessageBox::critical( 0, tr("Out of space"),
355 tr( "There was a problem saving " 355 tr( "There was a problem saving "
356 "the playlist.\n" 356 "the playlist.\n"
357 "Your playlist " 357 "Your playlist "
358 "may be missing some entries\n" 358 "may be missing some entries\n"
359 "the next time you start it." ) 359 "the next time you start it." )
360 ); 360 );
361 } 361 }
362 } 362 }
363 noOfFiles++; 363 noOfFiles++;
364 } 364 }
365 } 365 }
366 while ( d->selectedFiles->next() ); 366 while ( d->selectedFiles->next() );
367 cfg.writeEntry("NumberOfFiles", noOfFiles ); 367 cfg.writeEntry("NumberOfFiles", noOfFiles );
368} 368}
369 369
370 370
371void PlayListWidget::addToSelection( const DocLnk& lnk ) { 371void PlayListWidget::addToSelection( const DocLnk& lnk ) {
372 d->setDocumentUsed = FALSE; 372 d->setDocumentUsed = FALSE;
373 if ( mediaPlayerState->playlist() ) { 373 if ( mediaPlayerState->playlist() ) {
374 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) 374 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" )
375 d->selectedFiles->addToSelection( lnk ); 375 d->selectedFiles->addToSelection( lnk );
376 } 376 }
377 else 377 else
378 mediaPlayerState->setPlaying( TRUE ); 378 mediaPlayerState->setPlaying( TRUE );
379} 379}
380 380
381 381
382void PlayListWidget::clearList() { 382void PlayListWidget::clearList() {
383 while ( first() ) { 383 while ( first() ) {
384 d->selectedFiles->removeSelected(); 384 d->selectedFiles->removeSelected();
385 } 385 }
386} 386}
387 387
388 388
389void PlayListWidget::addAllToList() { 389void PlayListWidget::addAllToList() {
390 DocLnkSet filesAll; 390 DocLnkSet filesAll;
391 Global::findDocuments(&filesAll, "video/*;audio/*"); 391 Global::findDocuments(&filesAll, "video/*;audio/*");
392 QListIterator<DocLnk> Adit( filesAll.children() ); 392 QListIterator<DocLnk> Adit( filesAll.children() );
393 for ( ; Adit.current(); ++Adit ) { 393 for ( ; Adit.current(); ++Adit ) {
394 if(QFileInfo(Adit.current()->file()).exists()) { 394 if(QFileInfo(Adit.current()->file()).exists()) {
395 d->selectedFiles->addToSelection( **Adit ); 395 d->selectedFiles->addToSelection( **Adit );
396 } 396 }
397 } 397 }
398} 398}
399 399
400 400
401void PlayListWidget::addAllMusicToList() { 401void PlayListWidget::addAllMusicToList() {
402 QListIterator<DocLnk> dit( files.children() ); 402 QListIterator<DocLnk> dit( files.children() );
403 for ( ; dit.current(); ++dit ) { 403 for ( ; dit.current(); ++dit ) {
404 if(QFileInfo(dit.current()->file()).exists()) { 404 if(QFileInfo(dit.current()->file()).exists()) {
405 d->selectedFiles->addToSelection( **dit ); 405 d->selectedFiles->addToSelection( **dit );
406 } 406 }
407 } 407 }
408} 408}
409 409
410 410
411void PlayListWidget::addAllVideoToList() { 411void PlayListWidget::addAllVideoToList() {
412 QListIterator<DocLnk> dit( vFiles.children() ); 412 QListIterator<DocLnk> dit( vFiles.children() );
413 for ( ; dit.current(); ++dit ) 413 for ( ; dit.current(); ++dit )
414 if(QFileInfo( dit.current()->file()).exists()) 414 if(QFileInfo( dit.current()->file()).exists())
415 d->selectedFiles->addToSelection( **dit ); 415 d->selectedFiles->addToSelection( **dit );
416} 416}
417 417
418 418
419void PlayListWidget::setDocument(const QString& fileref) { 419void PlayListWidget::setDocument(const QString& fileref) {
420 qDebug(fileref); 420 qDebug(fileref);
421 fromSetDocument = TRUE; 421 fromSetDocument = TRUE;
422 if ( fileref.isNull() ) { 422 if ( fileref.isNull() ) {
423 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); 423 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) );
424 return; 424 return;
425 } 425 }
426 426
427 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u 427 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u
428 readm3u( fileref); 428 readm3u( fileref);
429 } else if(fileref.find("pls",0,TRUE) != -1) { //is pls 429 } else if(fileref.find("pls",0,TRUE) != -1) { //is pls
430 readPls( fileref); 430 readPls( fileref);
431 } else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist 431 } else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist
432 clearList(); 432 clearList();
433 loadList(DocLnk(fileref)); 433 loadList(DocLnk(fileref));
434 d->selectedFiles->first(); 434 d->selectedFiles->first();
435 } else { 435 } else {
436 clearList(); 436 clearList();
437 addToSelection( DocLnk( fileref ) ); 437 addToSelection( DocLnk( fileref ) );
438 d->setDocumentUsed = TRUE; 438 d->setDocumentUsed = TRUE;
439 mediaPlayerState->setPlaying( FALSE ); 439 mediaPlayerState->setPlaying( FALSE );
440 qApp->processEvents(); 440 qApp->processEvents();
441 mediaPlayerState->setPlaying( TRUE ); 441 mediaPlayerState->setPlaying( TRUE );
442 qApp->processEvents(); 442 qApp->processEvents();
443 setCaption(tr("OpiePlayer")); 443 setCaption(tr("OpiePlayer"));
444 } 444 }
445} 445}
446 446
447 447
448void PlayListWidget::setActiveWindow() { 448void PlayListWidget::setActiveWindow() {
449 qDebug("SETTING active window"); 449 qDebug("SETTING active window");
450 // When we get raised we need to ensure that it switches views 450 // When we get raised we need to ensure that it switches views
451 char origView = mediaPlayerState->view(); 451 char origView = mediaPlayerState->view();
452 mediaPlayerState->setView( 'l' ); // invalidate 452 mediaPlayerState->setView( 'l' ); // invalidate
453 mediaPlayerState->setView( origView ); // now switch back 453 mediaPlayerState->setView( origView ); // now switch back
454} 454}
455 455
456 456
457void PlayListWidget::useSelectedDocument() { 457void PlayListWidget::useSelectedDocument() {
458 d->setDocumentUsed = FALSE; 458 d->setDocumentUsed = FALSE;
459} 459}
460 460
461 461
462const DocLnk *PlayListWidget::current() { // this is fugly 462const DocLnk *PlayListWidget::current() { // this is fugly
463 463
464 switch (tabWidget->currentPageIndex()) { 464 switch (tabWidget->currentPageIndex()) {
465 case 0: //playlist 465 case 0: //playlist
466 { 466 {
467 qDebug("playlist"); 467 qDebug("playlist");
468 if ( mediaPlayerState->playlist() ) { 468 if ( mediaPlayerState->playlist() ) {
469 return d->selectedFiles->current(); 469 return d->selectedFiles->current();
470 } else if ( d->setDocumentUsed && d->current ) { 470 } else if ( d->setDocumentUsed && d->current ) {
471 return d->current; 471 return d->current;
472 } else { 472 } else {
473 return d->files->selected(); 473 return d->files->selected();
474 } 474 }
475 } 475 }
476 break; 476 break;
477 case 1://audio 477 case 1://audio
478 { 478 {
479 qDebug("audioView"); 479 qDebug("audioView");
480 QListIterator<DocLnk> dit( files.children() ); 480 QListIterator<DocLnk> dit( files.children() );
481 for ( ; dit.current(); ++dit ) { 481 for ( ; dit.current(); ++dit ) {
482 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { 482 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) {
483 qDebug("here"); 483 qDebug("here");
484 insanityBool=TRUE; 484 insanityBool=TRUE;
485 return dit; 485 return dit;
486 } 486 }
487 } 487 }
488 } 488 }
489 break; 489 break;
490 case 2: // video 490 case 2: // video
491 { 491 {
492 qDebug("videoView"); 492 qDebug("videoView");
493 QListIterator<DocLnk> Vdit( vFiles.children() ); 493 QListIterator<DocLnk> Vdit( vFiles.children() );
494 for ( ; Vdit.current(); ++Vdit ) { 494 for ( ; Vdit.current(); ++Vdit ) {
495 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { 495 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) {
496 insanityBool=TRUE; 496 insanityBool=TRUE;
497 return Vdit; 497 return Vdit;
498 } 498 }
499 } 499 }
500 } 500 }
501 break; 501 break;
502 }; 502 };
503 return 0; 503 return 0;
504} 504}
505 505
506bool PlayListWidget::prev() { 506bool PlayListWidget::prev() {
507 if ( mediaPlayerState->playlist() ) { 507 if ( mediaPlayerState->playlist() ) {
508 if ( mediaPlayerState->shuffled() ) { 508 if ( mediaPlayerState->shuffled() ) {
509 const DocLnk *cur = current(); 509 const DocLnk *cur = current();
510 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 510 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
511 for ( int i = 0; i < j; i++ ) { 511 for ( int i = 0; i < j; i++ ) {
512 if ( !d->selectedFiles->next() ) 512 if ( !d->selectedFiles->next() )
513 d->selectedFiles->first(); 513 d->selectedFiles->first();
514 } 514 }
515 if ( cur == current() ) 515 if ( cur == current() )
516 if ( !d->selectedFiles->next() ) 516 if ( !d->selectedFiles->next() )
517 d->selectedFiles->first(); 517 d->selectedFiles->first();
518 return TRUE; 518 return TRUE;
519 } else { 519 } else {
520 if ( !d->selectedFiles->prev() ) { 520 if ( !d->selectedFiles->prev() ) {
521 if ( mediaPlayerState->looping() ) { 521 if ( mediaPlayerState->looping() ) {
522 return d->selectedFiles->last(); 522 return d->selectedFiles->last();
523 } else { 523 } else {
524 return FALSE; 524 return FALSE;
525 } 525 }
526 } 526 }
527 return TRUE; 527 return TRUE;
528 } 528 }
529 } else { 529 } else {
530 return mediaPlayerState->looping(); 530 return mediaPlayerState->looping();
531 } 531 }
532} 532}
533 533
534 534
535bool PlayListWidget::next() { 535bool PlayListWidget::next() {
536 if ( mediaPlayerState->playlist() ) { 536 if ( mediaPlayerState->playlist() ) {
537 if ( mediaPlayerState->shuffled() ) { 537 if ( mediaPlayerState->shuffled() ) {
538 return prev(); 538 return prev();
539 } else { 539 } else {
540 if ( !d->selectedFiles->next() ) { 540 if ( !d->selectedFiles->next() ) {
541 if ( mediaPlayerState->looping() ) { 541 if ( mediaPlayerState->looping() ) {
542 return d->selectedFiles->first(); 542 return d->selectedFiles->first();
543 } else { 543 } else {
544 return FALSE; 544 return FALSE;
545 } 545 }
546 } 546 }
547 return TRUE; 547 return TRUE;
548 } 548 }
549 } else { 549 } else {
550 return mediaPlayerState->looping(); 550 return mediaPlayerState->looping();
551 } 551 }
552} 552}
553 553
554 554
555bool PlayListWidget::first() { 555bool PlayListWidget::first() {
556 if ( mediaPlayerState->playlist() ) 556 if ( mediaPlayerState->playlist() )
557 return d->selectedFiles->first(); 557 return d->selectedFiles->first();
558 else 558 else
559 return mediaPlayerState->looping(); 559 return mediaPlayerState->looping();
560} 560}
561 561
562 562
563bool PlayListWidget::last() { 563bool PlayListWidget::last() {
564 if ( mediaPlayerState->playlist() ) 564 if ( mediaPlayerState->playlist() )
565 return d->selectedFiles->last(); 565 return d->selectedFiles->last();
566 else 566 else
567 return mediaPlayerState->looping(); 567 return mediaPlayerState->looping();
568} 568}
569 569
570 570
571void PlayListWidget::saveList() { 571void PlayListWidget::saveList() {
572 572
573 QString filename; 573 QString filename;
574 InputDialog *fileDlg; 574 InputDialog *fileDlg;
575 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); 575 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0);
576 fileDlg->exec(); 576 fileDlg->exec();
577 if( fileDlg->result() == 1 ) { 577 if( fileDlg->result() == 1 ) {
578 if ( d->current ) 578 if ( d->current )
579 delete d->current; 579 delete d->current;
580 filename = fileDlg->LineEdit1->text();//+".playlist"; 580 filename = fileDlg->LineEdit1->text();//+".playlist";
581 // qDebug("saving playlist "+filename+".playlist"); 581 // qDebug("saving playlist "+filename+".playlist");
582 Config cfg( filename +".playlist"); 582 Config cfg( filename +".playlist");
583 writeConfig( cfg ); 583 writeConfig( cfg );
584 584
585 DocLnk lnk; 585 DocLnk lnk;
586 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property 586 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property
587 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D 587 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D
588 lnk.setIcon("opieplayer2/playlist2"); 588 lnk.setIcon("opieplayer2/playlist2");
589 lnk.setName( filename); //sets file name 589 lnk.setName( filename); //sets file name
590 // qDebug(filename); 590 // qDebug(filename);
591 if(!lnk.writeLink()) { 591 if(!lnk.writeLink()) {
592 qDebug("Writing doclink did not work"); 592 qDebug("Writing doclink did not work");
593 } 593 }
594 } 594 }
595 Config config( "OpiePlayer" ); 595 Config config( "OpiePlayer" );
596 config.writeEntry("CurrentPlaylist",filename); 596 config.writeEntry("CurrentPlaylist",filename);
597 setCaption(tr("OpiePlayer: ")+filename); 597 setCaption(tr("OpiePlayer: ")+filename);
598 d->selectedFiles->first(); 598 d->selectedFiles->first();
599 if(fileDlg) { 599 if(fileDlg) {
600 delete fileDlg; 600 delete fileDlg;
601 } 601 }
602} 602}
603 603
604void PlayListWidget::loadList( const DocLnk & lnk) { 604void PlayListWidget::loadList( const DocLnk & lnk) {
605 QString name= lnk.name(); 605 QString name= lnk.name();
606 // qDebug("currentList is "+name); 606 // qDebug("currentList is "+name);
607 if( name.length()>1) { 607 if( name.length()>1) {
608 setCaption("OpiePlayer: "+name); 608 setCaption("OpiePlayer: "+name);
609 // qDebug("load list "+ name+".playlist"); 609 // qDebug("load list "+ name+".playlist");
610 clearList(); 610 clearList();
611 Config cfg( name+".playlist"); 611 Config cfg( name+".playlist");
612 readConfig(cfg); 612 readConfig(cfg);
613 613
614 tabWidget->setCurrentPage(0); 614 tabWidget->setCurrentPage(0);
615 615
616 Config config( "OpiePlayer" ); 616 Config config( "OpiePlayer" );
617 config.writeEntry("CurrentPlaylist", name); 617 config.writeEntry("CurrentPlaylist", name);
618 // d->selectedFiles->first(); 618 // d->selectedFiles->first();
619 } 619 }
620 620
621} 621}
622 622
623void PlayListWidget::setPlaylist( bool shown ) { 623void PlayListWidget::setPlaylist( bool shown ) {
624 if ( shown ) { 624 if ( shown ) {
625 d->playListFrame->show(); 625 d->playListFrame->show();
626 } else { 626 } else {
627 d->playListFrame->hide(); 627 d->playListFrame->hide();
628 } 628 }
629} 629}
630 630
631void PlayListWidget::setView( char view ) { 631void PlayListWidget::setView( char view ) {
632 if ( view == 'l' ) 632 if ( view == 'l' )
633 showMaximized(); 633 showMaximized();
634 else 634 else
635 hide(); 635 hide();
636} 636}
637 637
638void PlayListWidget::addSelected() { 638void PlayListWidget::addSelected() {
639 639
640 Config cfg( "OpiePlayer" ); 640 Config cfg( "OpiePlayer" );
641 cfg.setGroup("PlayList"); 641 cfg.setGroup("PlayList");
642 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 642 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
643// int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 643// int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
644 644
645 switch (tabWidget->currentPageIndex()) { 645 switch (tabWidget->currentPageIndex()) {
646 case 0: //playlist 646 case 0: //playlist
647 break; 647 break;
648 case 1: { //audio 648 case 1: { //audio
649 QListViewItemIterator it( audioView ); 649 QListViewItemIterator it( audioView );
650 // iterate through all items of the listview 650 // iterate through all items of the listview
651 for ( ; it.current(); ++it ) { 651 for ( ; it.current(); ++it ) {
652 if ( it.current()->isSelected() ) { 652 if ( it.current()->isSelected() ) {
653 QListIterator<DocLnk> dit( files.children() ); 653 QListIterator<DocLnk> dit( files.children() );
654 for ( ; dit.current(); ++dit ) { 654 for ( ; dit.current(); ++dit ) {
655 if( dit.current()->name() == it.current()->text(0) ) { 655 if( dit.current()->name() == it.current()->text(0) ) {
656 if(QFileInfo( dit.current()->file()).exists()) 656 if(QFileInfo( dit.current()->file()).exists())
657 d->selectedFiles->addToSelection( **dit ); 657 d->selectedFiles->addToSelection( **dit );
658 } 658 }
659 } 659 }
660 audioView->setSelected( it.current(),FALSE); 660 audioView->setSelected( it.current(),FALSE);
661 } 661 }
662 } 662 }
663 tabWidget->setCurrentPage(0); 663 tabWidget->setCurrentPage(0);
664 } 664 }
665 break; 665 break;
666 case 2: { // video 666 case 2: { // video
667 QListViewItemIterator it( videoView ); 667 QListViewItemIterator it( videoView );
668 // iterate through all items of the listview 668 // iterate through all items of the listview
669 for ( ; it.current(); ++it ) { 669 for ( ; it.current(); ++it ) {
670 if ( it.current()->isSelected() ) { 670 if ( it.current()->isSelected() ) {
671 QListIterator<DocLnk> dit( vFiles.children() ); 671 QListIterator<DocLnk> dit( vFiles.children() );
672 for ( ; dit.current(); ++dit ) { 672 for ( ; dit.current(); ++dit ) {
673 if( dit.current()->name() == it.current()->text(0) ) { 673 if( dit.current()->name() == it.current()->text(0) ) {
674 if(QFileInfo( dit.current()->file()).exists()) 674 if(QFileInfo( dit.current()->file()).exists())
675 d->selectedFiles->addToSelection( **dit ); 675 d->selectedFiles->addToSelection( **dit );
676 } 676 }
677 } 677 }
678 videoView->setSelected( it.current(),FALSE); 678 videoView->setSelected( it.current(),FALSE);
679 } 679 }
680 } 680 }
681 tabWidget->setCurrentPage(0); 681 tabWidget->setCurrentPage(0);
682 } 682 }
683 break; 683 break;
684 }; 684 };
685} 685}
686 686
687void PlayListWidget::removeSelected() { 687void PlayListWidget::removeSelected() {
688 d->selectedFiles->removeSelected( ); 688 d->selectedFiles->removeSelected( );
689} 689}
690 690
691void PlayListWidget::playIt( QListViewItem *it) { 691void PlayListWidget::playIt( QListViewItem *it) {
692 // if(it==NULL) return; 692 // if(it==NULL) return;
693 qDebug("playIt"); 693 qDebug("playIt");
694 mediaPlayerState->setPlaying(FALSE); 694 mediaPlayerState->setPlaying(FALSE);
695 mediaPlayerState->setPlaying(TRUE); 695 mediaPlayerState->setPlaying(TRUE);
696 d->selectedFiles->unSelect(); 696 d->selectedFiles->unSelect();
697} 697}
698 698
699void PlayListWidget::addToSelection( QListViewItem *it) { 699void PlayListWidget::addToSelection( QListViewItem *it) {
700 d->setDocumentUsed = FALSE; 700 d->setDocumentUsed = FALSE;
701 701
702 if(it) { 702 if(it) {
703 switch (tabWidget->currentPageIndex()) { 703 switch (tabWidget->currentPageIndex()) {
704 case 1: { 704 case 1: {
705 QListIterator<DocLnk> dit( files.children() ); 705 QListIterator<DocLnk> dit( files.children() );
706 for ( ; dit.current(); ++dit ) { 706 for ( ; dit.current(); ++dit ) {
707 if( dit.current()->name() == it->text(0)) { 707 if( dit.current()->name() == it->text(0)) {
708 if(QFileInfo( dit.current()->file()).exists()) 708 if(QFileInfo( dit.current()->file()).exists())
709 d->selectedFiles->addToSelection( **dit ); 709 d->selectedFiles->addToSelection( **dit );
710 } 710 }
711 } 711 }
712 } 712 }
713 break; 713 break;
714 case 2: { 714 case 2: {
715 QListIterator<DocLnk> dit( vFiles.children() ); 715 QListIterator<DocLnk> dit( vFiles.children() );
716 for ( ; dit.current(); ++dit ) { 716 for ( ; dit.current(); ++dit ) {
717 if( dit.current()->name() == it->text(0)) { 717 if( dit.current()->name() == it->text(0)) {
718 if(QFileInfo( dit.current()->file()).exists()) 718 if(QFileInfo( dit.current()->file()).exists())
719 d->selectedFiles->addToSelection( **dit ); 719 d->selectedFiles->addToSelection( **dit );
720 } 720 }
721 } 721 }
722 } 722 }
723 break; 723 break;
724 case 0: 724 case 0:
725 break; 725 break;
726 }; 726 };
727 tabWidget->setCurrentPage(0); 727 tabWidget->setCurrentPage(0);
728 } 728 }
729} 729}
730 730
731void PlayListWidget::tabChanged(QWidget *) { 731void PlayListWidget::tabChanged(QWidget *) {
732 732
733 switch ( tabWidget->currentPageIndex()) { 733 switch ( tabWidget->currentPageIndex()) {
734 case 0: 734 case 0:
735 { 735 {
736 if( !tbDeletePlaylist->isHidden()) 736 if( !tbDeletePlaylist->isHidden())
737 tbDeletePlaylist->hide(); 737 tbDeletePlaylist->hide();
738 d->tbRemoveFromList->setEnabled(TRUE); 738 d->tbRemoveFromList->setEnabled(TRUE);
739 d->tbAddToList->setEnabled(FALSE); 739 d->tbAddToList->setEnabled(FALSE);
740 } 740 }
741 break; 741 break;
742 case 1: 742 case 1:
743 { 743 {
744 audioView->clear(); 744 audioView->clear();
745 populateAudioView(); 745 populateAudioView();
746 746
747 if( !tbDeletePlaylist->isHidden()) 747 if( !tbDeletePlaylist->isHidden())
748 tbDeletePlaylist->hide(); 748 tbDeletePlaylist->hide();
749 d->tbRemoveFromList->setEnabled(FALSE); 749 d->tbRemoveFromList->setEnabled(FALSE);
750 d->tbAddToList->setEnabled(TRUE); 750 d->tbAddToList->setEnabled(TRUE);
751 } 751 }
752 break; 752 break;
753 case 2: 753 case 2:
754 { 754 {
755 videoView->clear(); 755 videoView->clear();
756 populateVideoView(); 756 populateVideoView();
757 if( !tbDeletePlaylist->isHidden()) 757 if( !tbDeletePlaylist->isHidden())
758 tbDeletePlaylist->hide(); 758 tbDeletePlaylist->hide();
759 d->tbRemoveFromList->setEnabled(FALSE); 759 d->tbRemoveFromList->setEnabled(FALSE);
760 d->tbAddToList->setEnabled(TRUE); 760 d->tbAddToList->setEnabled(TRUE);
761 } 761 }
762 break; 762 break;
763 case 3: 763 case 3:
764 { 764 {
765 if( tbDeletePlaylist->isHidden()) 765 if( tbDeletePlaylist->isHidden())
766 tbDeletePlaylist->show(); 766 tbDeletePlaylist->show();
767 playLists->reread(); 767 playLists->reread();
768 } 768 }
769 break; 769 break;
770 }; 770 };
771} 771}
772 772
773void PlayListWidget::btnPlay(bool b) { 773void PlayListWidget::btnPlay(bool b) {
774 774
775// mediaPlayerState->setPlaying(b); 775// mediaPlayerState->setPlaying(b);
776 switch ( tabWidget->currentPageIndex()) { 776 switch ( tabWidget->currentPageIndex()) {
777 case 0: 777 case 0:
778 { 778 {
779 mediaPlayerState->setPlaying(b); 779 mediaPlayerState->setPlaying(b);
780 } 780 }
781 break; 781 break;
782 case 1: 782 case 1:
783 { 783 {
784 addToSelection( audioView->currentItem() ); 784 addToSelection( audioView->currentItem() );
785 mediaPlayerState->setPlaying(b); 785 mediaPlayerState->setPlaying(b);
786 d->selectedFiles->removeSelected( ); 786 d->selectedFiles->removeSelected( );
787 tabWidget->setCurrentPage(1); 787 tabWidget->setCurrentPage(1);
788 d->selectedFiles->unSelect(); 788 d->selectedFiles->unSelect();
789 insanityBool=FALSE; 789 insanityBool=FALSE;
790 }// audioView->clearSelection(); 790 }// audioView->clearSelection();
791 break; 791 break;
792 case 2: 792 case 2:
793 { 793 {
794 addToSelection( videoView->currentItem() ); 794 addToSelection( videoView->currentItem() );
795 mediaPlayerState->setPlaying(b); 795 mediaPlayerState->setPlaying(b);
796 qApp->processEvents(); 796 qApp->processEvents();
797 d->selectedFiles->removeSelected( ); 797 d->selectedFiles->removeSelected( );
798 tabWidget->setCurrentPage(2); 798 tabWidget->setCurrentPage(2);
799 d->selectedFiles->unSelect(); 799 d->selectedFiles->unSelect();
800 insanityBool=FALSE; 800 insanityBool=FALSE;
801 }// videoView->clearSelection(); 801 }// videoView->clearSelection();
802 break; 802 break;
803 }; 803 };
804 804
805} 805}
806 806
807void PlayListWidget::deletePlaylist() { 807void PlayListWidget::deletePlaylist() {
808 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 808 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
809 (tr("You really want to delete\nthis playlist?")), 809 (tr("You really want to delete\nthis playlist?")),
810 (tr("Yes")), (tr("No")), 0 )){ 810 (tr("Yes")), (tr("No")), 0 )){
811 case 0: // Yes clicked, 811 case 0: // Yes clicked,
812 QFile().remove(playLists->selected()->file()); 812 QFile().remove(playLists->selected()->file());
813 QFile().remove(playLists->selected()->linkFile()); 813 QFile().remove(playLists->selected()->linkFile());
814 playLists->reread(); 814 playLists->reread();
815 break; 815 break;
816 case 1: // Cancel 816 case 1: // Cancel
817 break; 817 break;
818 }; 818 };
819} 819}
820 820
821void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { 821void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
822 switch (mouse) { 822 switch (mouse) {
823 case 1: 823 case 1:
824 break; 824 break;
825 case 2:{ 825 case 2:{
826 QPopupMenu m; 826 QPopupMenu m;
827 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 827 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
828 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 828 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
829 m.insertSeparator(); 829 m.insertSeparator();
830 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 830 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
831 m.exec( QCursor::pos() ); 831 m.exec( QCursor::pos() );
832 } 832 }
833 break; 833 break;
834 }; 834 };
835} 835}
836 836
837void PlayListWidget::playSelected() { 837void PlayListWidget::playSelected() {
838 btnPlay( TRUE); 838 btnPlay( TRUE);
839} 839}
840 840
841void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { 841void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) {
842 switch (mouse) { 842 switch (mouse) {
843 case 1: 843 case 1:
844 844
845 break; 845 break;
846 case 2: 846 case 2:
847 { 847 {
848 QPopupMenu m; 848 QPopupMenu m;
849 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 849 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
850 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 850 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
851 m.exec( QCursor::pos() ); 851 m.exec( QCursor::pos() );
852 } 852 }
853 break; 853 break;
854 }; 854 };
855} 855}
856 856
857void PlayListWidget::listDelete() { 857void PlayListWidget::listDelete() {
858 Config cfg( "OpiePlayer" ); 858 Config cfg( "OpiePlayer" );
859 cfg.setGroup("PlayList"); 859 cfg.setGroup("PlayList");
860 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 860 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
861 QString file; 861 QString file;
862// int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 862// int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
863 switch ( tabWidget->currentPageIndex()) { 863 switch ( tabWidget->currentPageIndex()) {
864 case 0: 864 case 0:
865 break; 865 break;
866 case 1: 866 case 1:
867 { 867 {
868 file = audioView->currentItem()->text(0); 868 file = audioView->currentItem()->text(0);
869 QListIterator<DocLnk> Pdit( files.children() ); 869 QListIterator<DocLnk> Pdit( files.children() );
870 for ( ; Pdit.current(); ++Pdit ) { 870 for ( ; Pdit.current(); ++Pdit ) {
871 if( Pdit.current()->name() == file) { 871 if( Pdit.current()->name() == file) {
872 LnkProperties prop( Pdit.current() ); 872 LnkProperties prop( Pdit.current() );
873 prop.showMaximized(); 873 prop.showMaximized();
874 prop.exec(); 874 prop.exec();
875 } 875 }
876 } 876 }
877 populateAudioView(); 877 populateAudioView();
878 } 878 }
879 break; 879 break;
880 case 2: 880 case 2:
881 { 881 {
882 882
883 } 883 }
884 break; 884 break;
885 }; 885 };
886} 886}
887 887
888void PlayListWidget::scanForAudio() { 888void PlayListWidget::scanForAudio() {
889 qDebug("scan for audio"); 889 qDebug("scan for audio");
890 files.detachChildren(); 890 files.detachChildren();
891 QListIterator<DocLnk> sdit( files.children() ); 891 QListIterator<DocLnk> sdit( files.children() );
892 for ( ; sdit.current(); ++sdit ) { 892 for ( ; sdit.current(); ++sdit ) {
893 delete sdit.current(); 893 delete sdit.current();
894 } 894 }
895 Global::findDocuments(&files, "audio/*"); 895 Global::findDocuments(&files, "audio/*");
896 audioScan = TRUE; 896 audioScan = TRUE;
897} 897}
898void PlayListWidget::scanForVideo() { 898void PlayListWidget::scanForVideo() {
899 qDebug("scan for video"); 899 qDebug("scan for video");
900 vFiles.detachChildren(); 900 vFiles.detachChildren();
901 QListIterator<DocLnk> sdit( vFiles.children() ); 901 QListIterator<DocLnk> sdit( vFiles.children() );
902 for ( ; sdit.current(); ++sdit ) { 902 for ( ; sdit.current(); ++sdit ) {
903 delete sdit.current(); 903 delete sdit.current();
904 } 904 }
905 Global::findDocuments(&vFiles, "video/*"); 905 Global::findDocuments(&vFiles, "video/*");
906 videoScan = TRUE; 906 videoScan = TRUE;
907} 907}
908 908
909void PlayListWidget::populateAudioView() { 909void PlayListWidget::populateAudioView() {
910 910
911 audioView->clear(); 911 audioView->clear();
912 StorageInfo storageInfo; 912 StorageInfo storageInfo;
913 const QList<FileSystem> &fs = storageInfo.fileSystems(); 913 const QList<FileSystem> &fs = storageInfo.fileSystems();
914 if(!audioScan) scanForAudio(); 914 if(!audioScan) scanForAudio();
915 915
916 QListIterator<DocLnk> dit( files.children() ); 916 QListIterator<DocLnk> dit( files.children() );
917 QListIterator<FileSystem> it ( fs ); 917 QListIterator<FileSystem> it ( fs );
918 918
919 QString storage; 919 QString storage;
920 for ( ; dit.current(); ++dit ) { 920 for ( ; dit.current(); ++dit ) {
921 for( ; it.current(); ++it ){ 921 for( ; it.current(); ++it ){
922 const QString name = (*it)->name(); 922 const QString name = (*it)->name();
923 const QString path = (*it)->path(); 923 const QString path = (*it)->path();
924 if(dit.current()->file().find(path) != -1 ) storage=name; 924 if(dit.current()->file().find(path) != -1 ) storage=name;
925 } 925 }
926 926
927 QListViewItem * newItem; 927 QListViewItem * newItem;
928 if ( QFile( dit.current()->file()).exists() ) { 928 if ( QFile( dit.current()->file()).exists() ) {
929 // qDebug(dit.current()->name()); 929 // qDebug(dit.current()->name());
930 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 930 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
931 QString::number( QFile( dit.current()->file()).size() ), storage); 931 QString::number( QFile( dit.current()->file()).size() ), storage);
932 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/musicfile" )); 932 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/musicfile" ));
933 } 933 }
934 } 934 }
935 935
936} 936}
937 937
938void PlayListWidget::populateVideoView() { 938void PlayListWidget::populateVideoView() {
939 videoView->clear(); 939 videoView->clear();
940 StorageInfo storageInfo; 940 StorageInfo storageInfo;
941 const QList<FileSystem> &fs = storageInfo.fileSystems(); 941 const QList<FileSystem> &fs = storageInfo.fileSystems();
942 942
943 if(!videoScan ) scanForVideo(); 943 if(!videoScan ) scanForVideo();
944 944
945 QListIterator<DocLnk> Vdit( vFiles.children() ); 945 QListIterator<DocLnk> Vdit( vFiles.children() );
946 QListIterator<FileSystem> it ( fs ); 946 QListIterator<FileSystem> it ( fs );
947 videoView->clear(); 947 videoView->clear();
948 QString storage; 948 QString storage;
949 for ( ; Vdit.current(); ++Vdit ) { 949 for ( ; Vdit.current(); ++Vdit ) {
950 for( ; it.current(); ++it ){ 950 for( ; it.current(); ++it ){
951 const QString name = (*it)->name(); 951 const QString name = (*it)->name();
952 const QString path = (*it)->path(); 952 const QString path = (*it)->path();
953 if( Vdit.current()->file().find(path) != -1 ) storage=name; 953 if( Vdit.current()->file().find(path) != -1 ) storage=name;
954 } 954 }
955 955
956 QListViewItem * newItem; 956 QListViewItem * newItem;
957 if ( QFile( Vdit.current()->file()).exists() ) { 957 if ( QFile( Vdit.current()->file()).exists() ) {
958 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 958 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
959 QString::number( QFile( Vdit.current()->file()).size() ), storage); 959 QString::number( QFile( Vdit.current()->file()).size() ), storage);
960 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" )); 960 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ));
961 } 961 }
962 } 962 }
963} 963}
964 964
965void PlayListWidget::openFile() { 965void PlayListWidget::openFile() {
966 QString filename, name; 966 QString filename, name;
967 InputDialog *fileDlg; 967 InputDialog *fileDlg;
968 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 968 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
969 fileDlg->exec(); 969 fileDlg->exec();
970 if( fileDlg->result() == 1 ) { 970 if( fileDlg->result() == 1 ) {
971 filename = fileDlg->LineEdit1->text(); 971 filename = fileDlg->LineEdit1->text();
972 972
973 qDebug("Selected filename is "+filename); 973 qDebug("Selected filename is "+filename);
974 if(filename.right(3) == "m3u") { 974 if(filename.right(3) == "m3u") {
975 readm3u( filename ); 975 readm3u( filename );
976 } else if(filename.right(3) == "pls") { 976 } else if(filename.right(3) == "pls") {
977 readPls( filename ); 977 readPls( filename );
978 } else { 978 } else {
979 DocLnk lnk; 979 DocLnk lnk;
980 980
981 lnk.setName(filename); //sets file name 981 lnk.setName(filename); //sets file name
982 lnk.setFile(filename); //sets File property 982 lnk.setFile(filename); //sets File property
983 lnk.setType("audio/x-mpegurl"); 983 lnk.setType("audio/x-mpegurl");
984 lnk.setExec("opieplayer"); 984 lnk.setExec("opieplayer");
985 lnk.setIcon("opieplayer2/MPEGPlayer"); 985 lnk.setIcon("opieplayer2/MPEGPlayer");
986 986
987 if(!lnk.writeLink()) { 987 if(!lnk.writeLink()) {
988 qDebug("Writing doclink did not work"); 988 qDebug("Writing doclink did not work");
989 } 989 }
990 d->selectedFiles->addToSelection( lnk); 990 d->selectedFiles->addToSelection( lnk);
991 } 991 }
992 } 992 }
993 if(fileDlg) { 993 if(fileDlg) {
994 delete fileDlg; 994 delete fileDlg;
995 } 995 }
996} 996}
997 997
998void PlayListWidget::keyReleaseEvent( QKeyEvent *e) 998void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
999{ 999{
1000 switch ( e->key() ) { 1000 switch ( e->key() ) {
1001////////////////////////////// Zaurus keys 1001////////////////////////////// Zaurus keys
1002 case Key_F9: //activity 1002 case Key_F9: //activity
1003// if(audioUI->isHidden()) 1003// if(audioUI->isHidden())
1004// audioUI->showMaximized(); 1004// audioUI->showMaximized();
1005 break; 1005 break;
1006 case Key_F10: //contacts 1006 case Key_F10: //contacts
1007// if( videoUI->isHidden()) 1007// if( videoUI->isHidden())
1008// videoUI->showMaximized(); 1008// videoUI->showMaximized();
1009 break; 1009 break;
1010 case Key_F11: //menu 1010 case Key_F11: //menu
1011 break; 1011 break;
1012 case Key_F12: //home 1012 case Key_F12: //home
1013// doBlank(); 1013// doBlank();
1014 break; 1014 break;
1015 case Key_F13: //mail 1015 case Key_F13: //mail
1016// doUnblank(); 1016// doUnblank();
1017 break; 1017 break;
1018 case Key_Q: //add to playlist 1018 case Key_Q: //add to playlist
1019 qDebug("Add"); 1019 qDebug("Add");
1020 addSelected(); 1020 addSelected();
1021 break; 1021 break;
1022 case Key_R: //remove from playlist 1022 case Key_R: //remove from playlist
1023 removeSelected(); 1023 removeSelected();
1024 break; 1024 break;
1025// case Key_P: //play 1025// case Key_P: //play
1026// qDebug("Play"); 1026// qDebug("Play");
1027// playSelected(); 1027// playSelected();
1028// break; 1028// break;
1029 case Key_Space: 1029 case Key_Space:
1030 qDebug("Play"); 1030 qDebug("Play");
1031// playSelected(); puh 1031// playSelected(); puh
1032 break; 1032 break;
1033 case Key_1: 1033 case Key_1:
1034 tabWidget->setCurrentPage(0); 1034 tabWidget->setCurrentPage(0);
1035 break; 1035 break;
1036 case Key_2: 1036 case Key_2:
1037 tabWidget->setCurrentPage(1); 1037 tabWidget->setCurrentPage(1);
1038 break; 1038 break;
1039 case Key_3: 1039 case Key_3:
1040 tabWidget->setCurrentPage(2); 1040 tabWidget->setCurrentPage(2);
1041 break; 1041 break;
1042 case Key_4: 1042 case Key_4:
1043 tabWidget->setCurrentPage(3); 1043 tabWidget->setCurrentPage(3);
1044 break; 1044 break;
1045 case Key_Down: 1045 case Key_Down:
1046 if ( !d->selectedFiles->next() ) 1046 if ( !d->selectedFiles->next() )
1047 d->selectedFiles->first(); 1047 d->selectedFiles->first();
1048 1048
1049 break; 1049 break;
1050 case Key_Up: 1050 case Key_Up:
1051 if ( !d->selectedFiles->prev() ) 1051 if ( !d->selectedFiles->prev() )
1052 // d->selectedFiles->last(); 1052 // d->selectedFiles->last();
1053 1053
1054 break; 1054 break;
1055 1055
1056 } 1056 }
1057} 1057}
1058 1058
1059void PlayListWidget::keyPressEvent( QKeyEvent *) 1059void PlayListWidget::keyPressEvent( QKeyEvent *)
1060{ 1060{
1061// qDebug("Key press"); 1061// qDebug("Key press");
1062// switch ( e->key() ) { 1062// switch ( e->key() ) {
1063// ////////////////////////////// Zaurus keys 1063// ////////////////////////////// Zaurus keys
1064// case Key_A: //add to playlist 1064// case Key_A: //add to playlist
1065// qDebug("Add"); 1065// qDebug("Add");
1066// addSelected(); 1066// addSelected();
1067// break; 1067// break;
1068// case Key_R: //remove from playlist 1068// case Key_R: //remove from playlist
1069// removeSelected(); 1069// removeSelected();
1070// break; 1070// break;
1071// case Key_P: //play 1071// case Key_P: //play
1072// qDebug("Play"); 1072// qDebug("Play");
1073// playSelected(); 1073// playSelected();
1074// break; 1074// break;
1075// case Key_Space: 1075// case Key_Space:
1076// qDebug("Play"); 1076// qDebug("Play");
1077// playSelected(); 1077// playSelected();
1078// break; 1078// break;
1079// } 1079// }
1080} 1080}
1081 1081
1082void PlayListWidget::doBlank() { 1082void PlayListWidget::doBlank() {
1083 qDebug("do blanking"); 1083 qDebug("do blanking");
1084 fd=open("/dev/fb0",O_RDWR); 1084 fd=open("/dev/fb0",O_RDWR);
1085 if (fd != -1) { 1085 if (fd != -1) {
1086 ioctl(fd,FBIOBLANK,1); 1086 ioctl(fd,FBIOBLANK,1);
1087// close(fd); 1087// close(fd);
1088 } 1088 }
1089} 1089}
1090 1090
1091void PlayListWidget::doUnblank() { 1091void PlayListWidget::doUnblank() {
1092 // this crashes opieplayer with a segfault 1092 // this crashes opieplayer with a segfault
1093 // int fd; 1093 // int fd;
1094 // fd=open("/dev/fb0",O_RDWR); 1094 // fd=open("/dev/fb0",O_RDWR);
1095 qDebug("do unblanking"); 1095 qDebug("do unblanking");
1096 if (fd != -1) { 1096 if (fd != -1) {
1097 ioctl(fd,FBIOBLANK,0); 1097 ioctl(fd,FBIOBLANK,0);
1098 close(fd); 1098 close(fd);
1099 } 1099 }
1100 QCopEnvelope h("QPE/System", "setBacklight(int)"); 1100 QCopEnvelope h("QPE/System", "setBacklight(int)");
1101 h <<-3;// v[1]; // -3 Force on 1101 h <<-3;// v[1]; // -3 Force on
1102} 1102}
1103 1103
1104void PlayListWidget::readm3u(const QString &filename) { 1104void PlayListWidget::readm3u(const QString &filename) {
1105 1105
1106 qDebug("m3u filename is "+filename); 1106 qDebug("m3u filename is "+filename);
1107 QFile f(filename); 1107 QFile f(filename);
1108 1108
1109 if(f.open(IO_ReadOnly)) { 1109 if(f.open(IO_ReadOnly)) {
1110 QTextStream t(&f); 1110 QTextStream t(&f);
1111 QString s;//, first, second; 1111 QString s;//, first, second;
1112 int i=0; 1112 int i=0;
1113 while ( !t.atEnd()) { 1113 while ( !t.atEnd()) {
1114 s=t.readLine(); 1114 s=t.readLine();
1115 1115
1116 if(s.find("#",0,TRUE) == -1) { 1116 if(s.find("#",0,TRUE) == -1) {
1117 if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat 1117 if(s.find(" ",0,TRUE) == -1) { // not sure if this is neede since cf uses vfat
1118 if(s.left(2) == "E:" || s.left(2) == "P:") { 1118 if(s.left(2) == "E:" || s.left(2) == "P:") {
1119 s=s.right(s.length()-2); 1119 s=s.right(s.length()-2);
1120 if(QFile(s).exists()) { 1120 if(QFile(s).exists()) {
1121 DocLnk lnk( s ); 1121 DocLnk lnk( s );
1122 QFileInfo f(s); 1122 QFileInfo f(s);
1123 QString name = f.baseName(); 1123 QString name = f.baseName();
1124 name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 ); 1124 name = name.right( name.length()-name.findRev( "\\",-1,TRUE ) -1 );
1125 lnk.setName( name ); 1125 lnk.setName( name );
1126 s=s.replace( QRegExp("\\"),"/"); 1126 s=s.replace( QRegExp("\\"),"/");
1127 lnk.setFile( s ); 1127 lnk.setFile( s );
1128 lnk.writeLink(); 1128 lnk.writeLink();
1129 qDebug("add "+name); 1129 qDebug("add "+name);
1130 d->selectedFiles->addToSelection( lnk); 1130 d->selectedFiles->addToSelection( lnk);
1131 } 1131 }
1132 } else { // is url 1132 } else { // is url
1133 s.replace(QRegExp("%20")," "); 1133 s.replace(QRegExp("%20")," ");
1134 DocLnk lnk( s ); 1134 DocLnk lnk( s );
1135 QString name; 1135 QString name;
1136 if(name.left(4)=="http") { 1136 if(name.left(4)=="http") {
1137 name = s.right( s.length() - 7); 1137 name = s.right( s.length() - 7);
1138 } else { 1138 } else {
1139 name = s; 1139 name = s;
1140 } 1140 }
1141 lnk.setName(name); 1141 lnk.setName(name);
1142 if(s.at(s.length()-4) == '.') { 1142 if(s.at(s.length()-4) == '.') {
1143 lnk.setFile( s); 1143 lnk.setFile( s);
1144 } else { 1144 } else {
1145 lnk.setFile( s+"/"); 1145 lnk.setFile( s+"/");
1146 } 1146 }
1147 lnk.setType("audio/x-mpegurl"); 1147 lnk.setType("audio/x-mpegurl");
1148 lnk.writeLink(); 1148 lnk.writeLink();
1149 d->selectedFiles->addToSelection( lnk); 1149 d->selectedFiles->addToSelection( lnk);
1150 } 1150 }
1151 i++; 1151 i++;
1152 } 1152 }
1153 } 1153 }
1154 } 1154 }
1155 } 1155 }
1156 f.close(); 1156 f.close();
1157} 1157}
1158 1158
1159void PlayListWidget::writem3u() { 1159void PlayListWidget::writem3u() {
1160 1160
1161 InputDialog *fileDlg; 1161 InputDialog *fileDlg;
1162 fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0); 1162 fileDlg = new InputDialog(this,tr("Save m3u Playlist "),TRUE, 0);
1163 fileDlg->exec(); 1163 fileDlg->exec();
1164 QString filename,list; 1164 QString filename,list;
1165 if( fileDlg->result() == 1 ) { 1165 if( fileDlg->result() == 1 ) {
1166 filename = fileDlg->LineEdit1->text(); 1166 filename = fileDlg->LineEdit1->text();
1167 qDebug(filename); 1167 qDebug(filename);
1168 int noOfFiles = 0; 1168 int noOfFiles = 0;
1169 d->selectedFiles->first(); 1169 d->selectedFiles->first();
1170 do { 1170 do {
1171 // we dont check for existance because of url's 1171 // we dont check for existance because of url's
1172 // qDebug(d->selectedFiles->current()->file()); 1172 // qDebug(d->selectedFiles->current()->file());
1173 list += d->selectedFiles->current()->file()+"\n"; 1173 list += d->selectedFiles->current()->file()+"\n";
1174 noOfFiles++; 1174 noOfFiles++;
1175 } 1175 }
1176 while ( d->selectedFiles->next() ); 1176 while ( d->selectedFiles->next() );
1177 qDebug(list); 1177 qDebug(list);
1178 if(filename.left(1) != "/") 1178 if(filename.left(1) != "/")
1179 filename=QPEApplication::documentDir()+"/"+filename; 1179 filename=QPEApplication::documentDir()+"/"+filename;
1180 if(filename.right(3) != "m3u") 1180 if(filename.right(3) != "m3u")
1181 filename=filename+".m3u"; 1181 filename=filename+".m3u";
1182 1182
1183 QFile f(filename); 1183 QFile f(filename);
1184 f.open(IO_WriteOnly); 1184 f.open(IO_WriteOnly);
1185 f.writeBlock(list, list.length()); 1185 f.writeBlock(list, list.length());
1186 f.close(); 1186 f.close();
1187 } 1187 }
1188 if(fileDlg) delete fileDlg; 1188 if(fileDlg) delete fileDlg;
1189} 1189}
1190 1190
1191void PlayListWidget::readPls(const QString &filename) { 1191void PlayListWidget::readPls(const QString &filename) {
1192 1192
1193 qDebug("pls filename is "+filename); 1193 qDebug("pls filename is "+filename);
1194 QFile f(filename); 1194 QFile f(filename);
1195 1195
1196 if(f.open(IO_ReadOnly)) { 1196 if(f.open(IO_ReadOnly)) {
1197 QTextStream t(&f); 1197 QTextStream t(&f);
1198 QString s;//, first, second; 1198 QString s;//, first, second;
1199 int i=0; 1199 int i=0;
1200 while ( !t.atEnd()) { 1200 while ( !t.atEnd()) {
1201 s=t.readLine(); 1201 s=t.readLine();
1202 if(s.left(4) == "File") { 1202 if(s.left(4) == "File") {
1203 s=s.right(s.length() - 6); 1203 s=s.right(s.length() - 6);
1204 s.replace(QRegExp("%20")," "); 1204 s.replace(QRegExp("%20")," ");
1205 qDebug("adding "+s+" to playlist"); 1205 qDebug("adding "+s+" to playlist");
1206 // numberofentries=2 1206 // numberofentries=2
1207 // File1=http 1207 // File1=http
1208 // Title 1208 // Title
1209 // Length 1209 // Length
1210 // Version 1210 // Version
1211 // File2=http 1211 // File2=http
1212 s=s.replace( QRegExp("\\"),"/"); 1212 s=s.replace( QRegExp("\\"),"/");
1213 DocLnk lnk( s ); 1213 DocLnk lnk( s );
1214 QFileInfo f(s); 1214 QFileInfo f(s);
1215 QString name = f.baseName(); 1215 QString name = f.baseName();
1216 if(name.left(4)=="http") 1216 if(name.left(4)=="http")
1217 name = s.right( s.length() - 7); 1217 name = s.right( s.length() - 7);
1218 else 1218 else
1219 name=s; 1219 name=s;
1220 name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1); 1220 name = name.right(name.length()-name.findRev("\\",-1,TRUE)-1);
1221 lnk.setName( name); 1221 lnk.setName( name);
1222 if(s.at(s.length()-4) == '.') // if this is probably a file 1222 if(s.at(s.length()-4) == '.') // if this is probably a file
1223 lnk.setFile( s); 1223 lnk.setFile( s);
1224 else { //if its a url 1224 else { //if its a url
1225 if( name.right(1).find('/') == -1) 1225 if( name.right(1).find('/') == -1)
1226 s+="/"; 1226 s+="/";
1227 lnk.setFile( s); 1227 lnk.setFile( s);
1228 } 1228 }
1229 lnk.setType("audio/x-mpegurl"); 1229 lnk.setType("audio/x-mpegurl");
1230 1230
1231 qDebug("DocLnk add "+name); 1231 qDebug("DocLnk add "+name);
1232 d->selectedFiles->addToSelection( lnk); 1232 d->selectedFiles->addToSelection( lnk);
1233 } 1233 }
1234 } 1234 }
1235 i++; 1235 i++;
1236 } 1236 }
1237} 1237}
1238 1238
1239void PlayListWidget::pmViewActivated(int index) { 1239void PlayListWidget::pmViewActivated(int index) {
1240qDebug("%d", index); 1240qDebug("%d", index);
1241switch(index) { 1241switch(index) {
1242 case -16: 1242 case -16:
1243 { 1243 {
1244 1244
1245 mediaPlayerState->toggleFullscreen(); 1245 mediaPlayerState->toggleFullscreen();
1246 bool b=mediaPlayerState->fullscreen(); 1246 bool b=mediaPlayerState->fullscreen();
1247 pmView->setItemChecked( index,b); 1247 pmView->setItemChecked( index,b);
1248 Config cfg( "OpiePlayer" ); 1248 Config cfg( "OpiePlayer" );
1249 cfg.writeEntry("FullScreen", b); 1249 cfg.writeEntry("FullScreen", b);
1250 1250
1251 } 1251 }
1252 break; 1252 break;
1253}; 1253};
1254} 1254}
1255 1255
1256void PlayListWidget::populateSkinsMenu() { 1256void PlayListWidget::populateSkinsMenu() {
1257 int item=0; 1257 int item=0;
1258 defaultSkinIndex=0; 1258 defaultSkinIndex=0;
1259 QString skinName; 1259 QString skinName;
1260 Config cfg( "OpiePlayer" ); 1260 Config cfg( "OpiePlayer" );
1261 cfg.setGroup("Options"); 1261 cfg.setGroup("Options");
1262 QString skin = cfg.readEntry("Skin","default"); 1262 QString skin = cfg.readEntry("Skin","default");
1263 1263
1264 QDir skinsDir(QPEApplication::qpeDir()+"/pics/opieplayer2/skins"); 1264 QDir skinsDir(QPEApplication::qpeDir()+"/pics/opieplayer2/skins");
1265 skinsDir.setFilter( QDir::Dirs); 1265 skinsDir.setFilter( QDir::Dirs);
1266 skinsDir.setSorting(QDir::Name); 1266 skinsDir.setSorting(QDir::Name);
1267 const QFileInfoList *skinslist = skinsDir.entryInfoList(); 1267 const QFileInfoList *skinslist = skinsDir.entryInfoList();
1268 QFileInfoListIterator it( *skinslist ); 1268 QFileInfoListIterator it( *skinslist );
1269 QFileInfo *fi; 1269 QFileInfo *fi;
1270 while ( (fi=it.current()) ) { 1270 while ( (fi=it.current()) ) {
1271 skinName = fi->fileName(); 1271 skinName = fi->fileName();
1272 qDebug( fi->fileName()); 1272 qDebug( fi->fileName());
1273 if( skinName != "." && skinName != ".." && skinName !="CVS") 1273 if( skinName != "." && skinName != ".." && skinName !="CVS")
1274 item = skinsMenu->insertItem( fi->fileName()); 1274 item = skinsMenu->insertItem( fi->fileName());
1275 if( skinName == "default") 1275 if( skinName == "default")
1276 defaultSkinIndex = item; 1276 defaultSkinIndex = item;
1277 if( skinName == skin) 1277 if( skinName == skin)
1278 skinsMenu->setItemChecked( item, TRUE); 1278 skinsMenu->setItemChecked( item, TRUE);
1279 1279
1280 ++it; 1280 ++it;
1281 } 1281 }
1282} 1282}
1283 1283
1284void PlayListWidget::skinsMenuActivated(int item) { 1284void PlayListWidget::skinsMenuActivated(int item) {
1285 for(int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i--) { 1285 for(int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i--) {
1286 skinsMenu->setItemChecked( i, FALSE); 1286 skinsMenu->setItemChecked( i, FALSE);
1287 } 1287 }
1288 skinsMenu->setItemChecked( item, TRUE); 1288 skinsMenu->setItemChecked( item, TRUE);
1289 1289
1290 Config cfg( "OpiePlayer" ); 1290 Config cfg( "OpiePlayer" );
1291 cfg.setGroup("Options"); 1291 cfg.setGroup("Options");
1292 cfg.writeEntry("Skin", skinsMenu->text( item)); 1292 cfg.writeEntry("Skin", skinsMenu->text( item));
1293} 1293}