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