summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp8
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp2
2 files changed, 7 insertions, 3 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index 0f8242b..6a48b82 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -1,295 +1,299 @@
1#include <qpe/qpeapplication.h> 1#include <qpe/qpeapplication.h>
2#include <qpe/qlibrary.h> 2#include <qpe/qlibrary.h>
3#include <qpe/resource.h> 3#include <qpe/resource.h>
4#include <qpe/config.h> 4#include <qpe/config.h>
5#include <qpe/qcopenvelope_qws.h> 5#include <qpe/qcopenvelope_qws.h>
6 6
7#include <qmainwindow.h> 7#include <qmainwindow.h>
8#include <qmessagebox.h> 8#include <qmessagebox.h>
9#include <qwidgetstack.h> 9#include <qwidgetstack.h>
10#include <qfile.h> 10#include <qfile.h>
11 11
12#include "mediaplayer.h" 12#include "mediaplayer.h"
13#include "playlistwidget.h" 13#include "playlistwidget.h"
14#include "audiowidget.h" 14#include "audiowidget.h"
15#include "videowidget.h" 15#include "videowidget.h"
16#include "volumecontrol.h" 16#include "volumecontrol.h"
17 17
18#include "mediaplayerstate.h" 18#include "mediaplayerstate.h"
19 19
20// for setBacklight() 20// for setBacklight()
21#include <linux/fb.h> 21#include <linux/fb.h>
22#include <sys/file.h> 22#include <sys/file.h>
23#include <sys/ioctl.h> 23#include <sys/ioctl.h>
24 24
25 25
26extern AudioWidget *audioUI; 26extern AudioWidget *audioUI;
27extern VideoWidget *videoUI; 27extern VideoWidget *videoUI;
28extern PlayListWidget *playList; 28extern PlayListWidget *playList;
29extern MediaPlayerState *mediaPlayerState; 29extern MediaPlayerState *mediaPlayerState;
30 30
31 31
32#define FBIOBLANK 0x4611 32#define FBIOBLANK 0x4611
33 33
34MediaPlayer::MediaPlayer( QObject *parent, const char *name ) 34MediaPlayer::MediaPlayer( QObject *parent, const char *name )
35 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { 35 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) {
36 36
37 playList->setCaption(tr("OpiePlayer: Initializating"));
38
37 qApp->processEvents(); 39 qApp->processEvents();
38 // QPEApplication::grabKeyboard(); // EVIL 40 // QPEApplication::grabKeyboard(); // EVIL
39 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 41 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
40 42
41 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); 43 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) );
42 44
43 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); 45 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) );
44 46
45 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); 47 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) );
46 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); 48 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) );
47 connect( mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); 49 connect( mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) );
48 50
49 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 51 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
50 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 52 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
51 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 53 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
52 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 54 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
53 55
54 connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 56 connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
55 connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 57 connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
56 connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 58 connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
57 connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 59 connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
58 60
59 volControl = new VolumeControl; 61 volControl = new VolumeControl;
60 xineControl = new XineControl(); 62 xineControl = new XineControl();
63 playList->setCaption(tr("OpiePlayer"));
61} 64}
62 65
63MediaPlayer::~MediaPlayer() { 66MediaPlayer::~MediaPlayer() {
64 delete xineControl; 67 delete xineControl;
65 delete volControl; 68 delete volControl;
66} 69}
67 70
68void MediaPlayer::pauseCheck( bool b ) { 71void MediaPlayer::pauseCheck( bool b ) {
69 if ( b && !mediaPlayerState->playing() ) { 72 if ( b && !mediaPlayerState->playing() ) {
70 mediaPlayerState->setPaused( FALSE ); 73 mediaPlayerState->setPaused( FALSE );
71 } 74 }
72} 75}
73 76
74void MediaPlayer::play() { 77void MediaPlayer::play() {
75 mediaPlayerState->setPlaying( FALSE ); 78 mediaPlayerState->setPlaying( FALSE );
76 mediaPlayerState->setPlaying( TRUE ); 79 mediaPlayerState->setPlaying( TRUE );
77} 80}
78 81
79void MediaPlayer::setPlaying( bool play ) { 82void MediaPlayer::setPlaying( bool play ) {
80 if ( !play ) { 83 if ( !play ) {
81 return; 84 return;
82 } 85 }
83 86
84 if ( mediaPlayerState->paused() ) { 87 if ( mediaPlayerState->paused() ) {
85 mediaPlayerState->setPaused( FALSE ); 88 mediaPlayerState->setPaused( FALSE );
86 return; 89 return;
87 } 90 }
88 91
89 const DocLnk *playListCurrent = playList->current(); 92 const DocLnk *playListCurrent = playList->current();
90 if ( playListCurrent != NULL ) { 93 if ( playListCurrent != NULL ) {
91 currentFile = playListCurrent; 94 currentFile = playListCurrent;
92 } 95 }
93 96
94 xineControl->play( currentFile->file() ); 97 xineControl->play( currentFile->file() );
95 98
96 long seconds = mediaPlayerState->length();// 99 long seconds = mediaPlayerState->length();//
97 QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); 100 QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
98 qDebug(time); 101 qDebug(time);
99 102
100 QString tickerText; 103 QString tickerText;
101 if( currentFile->file().left(4) == "http" ) 104 if( currentFile->file().left(4) == "http" )
102 tickerText= tr( " File: " ) + currentFile->name(); 105 tickerText= tr( " File: " ) + currentFile->name();
103 else 106 else
104 tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time; 107 tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time;
105 108
106 audioUI->setTickerText( currentFile->file( ) ); 109 audioUI->setTickerText( currentFile->file( ) );
107 110
108} 111}
109 112
110 113
111void MediaPlayer::prev() { 114void MediaPlayer::prev() {
112 if ( playList->prev() ) { 115 if ( playList->prev() ) {
113 play(); 116 play();
114 } else if ( mediaPlayerState->looping() ) { 117 } else if ( mediaPlayerState->looping() ) {
115 if ( playList->last() ) { 118 if ( playList->last() ) {
116 play(); 119 play();
117 } 120 }
118 } else { 121 } else {
119 mediaPlayerState->setList(); 122 mediaPlayerState->setList();
120 } 123 }
121} 124}
122 125
123 126
124void MediaPlayer::next() { 127void MediaPlayer::next() {
125 if ( playList->next() ) { 128 if ( playList->next() ) {
126 play(); 129 play();
127 } else if ( mediaPlayerState->looping() ) { 130 } else if ( mediaPlayerState->looping() ) {
128 if ( playList->first() ) { 131 if ( playList->first() ) {
129 play(); 132 play();
130 } 133 }
131 } else { 134 } else {
132 mediaPlayerState->setList(); 135 mediaPlayerState->setList();
133 } 136 }
134} 137}
135 138
136 139
137void MediaPlayer::startDecreasingVolume() { 140void MediaPlayer::startDecreasingVolume() {
138 volumeDirection = -1; 141 volumeDirection = -1;
139 startTimer( 100 ); 142 startTimer( 100 );
140 volControl->decVol(2); 143 volControl->decVol(2);
141} 144}
142 145
143 146
144void MediaPlayer::startIncreasingVolume() { 147void MediaPlayer::startIncreasingVolume() {
145 volumeDirection = +1; 148 volumeDirection = +1;
146 startTimer( 100 ); 149 startTimer( 100 );
147 volControl->incVol(2); 150 volControl->incVol(2);
148} 151}
149 152
150 153
151bool drawnOnScreenDisplay = FALSE; 154bool drawnOnScreenDisplay = FALSE;
152unsigned int onScreenDisplayVolume = 0; 155unsigned int onScreenDisplayVolume = 0;
153const int yoff = 110; 156const int yoff = 110;
154 157
155void MediaPlayer::stopChangingVolume() { 158void MediaPlayer::stopChangingVolume() {
156 killTimers(); 159 killTimers();
157 // Get rid of the on-screen display stuff 160 // Get rid of the on-screen display stuff
158 drawnOnScreenDisplay = FALSE; 161 drawnOnScreenDisplay = FALSE;
159 onScreenDisplayVolume = 0; 162 onScreenDisplayVolume = 0;
160 int w=0; 163 int w=0;
161 int h=0; 164 int h=0;
162 if( !xineControl->hasVideo()) { 165 if( !xineControl->hasVideo()) {
163 w = audioUI->width(); 166 w = audioUI->width();
164 h = audioUI->height(); 167 h = audioUI->height();
165 audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); 168 audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE );
166 } else { 169 } else {
167 w = videoUI->width(); 170 w = videoUI->width();
168 h = videoUI->height(); 171 h = videoUI->height();
169 videoUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); 172 videoUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE );
170 } 173 }
171} 174}
172 175
173 176
174void MediaPlayer::timerEvent( QTimerEvent * ) { 177void MediaPlayer::timerEvent( QTimerEvent * ) {
175 if ( volumeDirection == +1 ) { 178 if ( volumeDirection == +1 ) {
176 volControl->incVol(2); 179 volControl->incVol(2);
177 } else if ( volumeDirection == -1 ) { 180 } else if ( volumeDirection == -1 ) {
178 volControl->decVol(2); 181 volControl->decVol(2);
179 } 182 }
180 183
181 184
182 // TODO FIXME 185 // TODO FIXME
183 unsigned int v= 0; 186 unsigned int v= 0;
184 v = volControl->volume(); 187 v = volControl->volume();
185 v = v / 10; 188 v = v / 10;
186 189
187 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { 190 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) {
188 return; 191 return;
189 } 192 }
190 193
191 int w=0; int h=0; 194 int w=0; int h=0;
192 if( !xineControl->hasVideo()) { 195 if( !xineControl->hasVideo()) {
193 w = audioUI->width(); 196 w = audioUI->width();
194 h = audioUI->height(); 197 h = audioUI->height();
195 198
196 if ( drawnOnScreenDisplay ) { 199 if ( drawnOnScreenDisplay ) {
197 if ( onScreenDisplayVolume > v ) { 200 if ( onScreenDisplayVolume > v ) {
198 audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); 201 audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE );
199 } 202 }
200 } 203 }
201 drawnOnScreenDisplay = TRUE; 204 drawnOnScreenDisplay = TRUE;
202 onScreenDisplayVolume = v; 205 onScreenDisplayVolume = v;
203 QPainter p( audioUI ); 206 QPainter p( audioUI );
204 p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); 207 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
205 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); 208 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
206 209
207 QFont f; 210 QFont f;
208 f.setPixelSize( 20 ); 211 f.setPixelSize( 20 );
209 f.setBold( TRUE ); 212 f.setBold( TRUE );
210 p.setFont( f ); 213 p.setFont( f );
211 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); 214 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") );
212 215
213 for ( unsigned int i = 0; i < 10; i++ ) { 216 for ( unsigned int i = 0; i < 10; i++ ) {
214 if ( v > i ) { 217 if ( v > i ) {
215 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); 218 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
216 } else { 219 } else {
217 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); 220 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
218 } 221 }
219 } 222 }
220 } else { 223 } else {
221 w = videoUI->width(); 224 w = videoUI->width();
222 h = videoUI->height(); 225 h = videoUI->height();
223 226
224 if ( drawnOnScreenDisplay ) { 227 if ( drawnOnScreenDisplay ) {
225 if ( onScreenDisplayVolume > v ) { 228 if ( onScreenDisplayVolume > v ) {
226 videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); 229 videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE );
227 } 230 }
228 } 231 }
229 drawnOnScreenDisplay = TRUE; 232 drawnOnScreenDisplay = TRUE;
230 onScreenDisplayVolume = v; 233 onScreenDisplayVolume = v;
231 QPainter p( videoUI ); 234 QPainter p( videoUI );
232 p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); 235 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
233 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); 236 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
234 237
235 QFont f; 238 QFont f;
236 f.setPixelSize( 20 ); 239 f.setPixelSize( 20 );
237 f.setBold( TRUE ); 240 f.setBold( TRUE );
238 p.setFont( f ); 241 p.setFont( f );
239 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); 242 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") );
240 243
241 for ( unsigned int i = 0; i < 10; i++ ) { 244 for ( unsigned int i = 0; i < 10; i++ ) {
242 if ( v > i ) { 245 if ( v > i ) {
243 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); 246 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
244 } else { 247 } else {
245 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); 248 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
246 } 249 }
247 } 250 }
248 } 251 }
249} 252}
250 253
251 254
252void MediaPlayer::blank( bool b ) { 255void MediaPlayer::blank( bool b ) {
253 fd=open("/dev/fb0",O_RDWR); 256 fd=open("/dev/fb0",O_RDWR);
254 if (fd != -1) { 257 if (fd != -1) {
255 if ( b ) { 258 if ( b ) {
256 qDebug("do blanking"); 259 qDebug("do blanking");
257 ioctl( fd, FBIOBLANK, 3 ); 260 ioctl( fd, FBIOBLANK, 3 );
258 isBlanked = TRUE; 261 isBlanked = TRUE;
259 } else { 262 } else {
260 qDebug("do unblanking"); 263 qDebug("do unblanking");
261 ioctl( fd, FBIOBLANK, 0); 264 ioctl( fd, FBIOBLANK, 0);
262 isBlanked = FALSE; 265 isBlanked = FALSE;
263 } 266 }
264 close( fd ); 267 close( fd );
265 } else { 268 } else {
266 qDebug("<< /dev/fb0 could not be opend >>"); 269 qDebug("<< /dev/fb0 could not be opened >>");
267 } 270 }
268} 271}
269 272
270void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { 273void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {
271 switch ( e->key() ) { 274 switch ( e->key() ) {
272////////////////////////////// Zaurus keys 275////////////////////////////// Zaurus keys
273 case Key_Home: 276 case Key_Home:
274 break; 277 break;
275 case Key_F9: //activity 278 case Key_F9: //activity
276 break; 279 break;
277 case Key_F10: //contacts 280 case Key_F10: //contacts
278 break; 281 break;
279 case Key_F11: //menu 282 case Key_F11: //menu
280 break; 283 break;
281 case Key_F12: //home 284 case Key_F12: //home
282 qDebug("Blank here"); 285 qDebug("Blank here");
283// mediaPlayerState->toggleBlank(); 286// mediaPlayerState->toggleBlank();
284 break; 287 break;
285 case Key_F13: //mail 288 case Key_F13: //mail
286 qDebug("Blank here"); 289 qDebug("Blank here");
287 // mediaPlayerState->toggleBlank(); 290 // mediaPlayerState->toggleBlank();
288 break; 291 break;
289 } 292 }
290} 293}
291 294
292void MediaPlayer::cleanUp() { 295void MediaPlayer::cleanUp() {// this happens on closing
296
293// QPEApplication::grabKeyboard(); 297// QPEApplication::grabKeyboard();
294// QPEApplication::ungrabKeyboard(); 298// QPEApplication::ungrabKeyboard();
295} 299}
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 251c2e5..5c804f5 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -1,486 +1,486 @@
1 1
2#define QTOPIA_INTERNAL_FSLP 2#define QTOPIA_INTERNAL_FSLP
3#include <qpe/qpemenubar.h> 3#include <qpe/qpemenubar.h>
4#include <qpe/qpetoolbar.h> 4#include <qpe/qpetoolbar.h>
5#include <qpe/fileselector.h> 5#include <qpe/fileselector.h>
6#include <qpe/qpeapplication.h> 6#include <qpe/qpeapplication.h>
7#include <qpe/lnkproperties.h> 7#include <qpe/lnkproperties.h>
8#include <qpe/storage.h> 8#include <qpe/storage.h>
9 9
10#include <qpe/applnk.h> 10#include <qpe/applnk.h>
11#include <qpopupmenu.h> 11#include <qpopupmenu.h>
12#include <qpe/config.h> 12#include <qpe/config.h>
13#include <qpe/global.h> 13#include <qpe/global.h>
14#include <qpe/resource.h> 14#include <qpe/resource.h>
15#include <qaction.h> 15#include <qaction.h>
16#include <qcursor.h> 16#include <qcursor.h>
17#include <qimage.h> 17#include <qimage.h>
18#include <qfile.h> 18#include <qfile.h>
19#include <qdir.h> 19#include <qdir.h>
20#include <qlayout.h> 20#include <qlayout.h>
21#include <qlabel.h> 21#include <qlabel.h>
22#include <qlist.h> 22#include <qlist.h>
23#include <qlistbox.h> 23#include <qlistbox.h>
24#include <qmainwindow.h> 24#include <qmainwindow.h>
25#include <qmessagebox.h> 25#include <qmessagebox.h>
26#include <qtoolbutton.h> 26#include <qtoolbutton.h>
27#include <qtabwidget.h> 27#include <qtabwidget.h>
28#include <qlistview.h> 28#include <qlistview.h>
29#include <qpoint.h> 29#include <qpoint.h>
30#include <qlineedit.h> 30#include <qlineedit.h>
31#include <qpushbutton.h> 31#include <qpushbutton.h>
32#include <qregexp.h> 32#include <qregexp.h>
33#include <qtextstream.h> 33#include <qtextstream.h>
34 34
35 35
36#include "playlistselection.h" 36#include "playlistselection.h"
37#include "playlistwidget.h" 37#include "playlistwidget.h"
38#include "mediaplayerstate.h" 38#include "mediaplayerstate.h"
39 39
40#include "inputDialog.h" 40#include "inputDialog.h"
41 41
42#include <stdlib.h> 42#include <stdlib.h>
43#include "audiowidget.h" 43#include "audiowidget.h"
44#include "videowidget.h" 44#include "videowidget.h"
45 45
46#define BUTTONS_ON_TOOLBAR 46#define BUTTONS_ON_TOOLBAR
47#define SIDE_BUTTONS 47#define SIDE_BUTTONS
48#define CAN_SAVE_LOAD_PLAYLISTS 48#define CAN_SAVE_LOAD_PLAYLISTS
49 49
50extern MediaPlayerState *mediaPlayerState; 50extern MediaPlayerState *mediaPlayerState;
51 51
52 52
53class PlayListWidgetPrivate { 53class PlayListWidgetPrivate {
54public: 54public:
55 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; 55 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
56 QFrame *playListFrame; 56 QFrame *playListFrame;
57 FileSelector *files; 57 FileSelector *files;
58 PlayListSelection *selectedFiles; 58 PlayListSelection *selectedFiles;
59 bool setDocumentUsed; 59 bool setDocumentUsed;
60 DocLnk *current; 60 DocLnk *current;
61}; 61};
62 62
63 63
64class ToolButton : public QToolButton { 64class ToolButton : public QToolButton {
65public: 65public:
66 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 66 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
67 : QToolButton( parent, name ) { 67 : QToolButton( parent, name ) {
68 setTextLabel( name ); 68 setTextLabel( name );
69 setPixmap( Resource::loadPixmap( icon ) ); 69 setPixmap( Resource::loadPixmap( icon ) );
70 setAutoRaise( TRUE ); 70 setAutoRaise( TRUE );
71 setFocusPolicy( QWidget::NoFocus ); 71 setFocusPolicy( QWidget::NoFocus );
72 setToggleButton( t ); 72 setToggleButton( t );
73 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 73 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
74 QPEMenuToolFocusManager::manager()->addWidget( this ); 74 QPEMenuToolFocusManager::manager()->addWidget( this );
75 } 75 }
76}; 76};
77 77
78 78
79class MenuItem : public QAction { 79class MenuItem : public QAction {
80public: 80public:
81 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) 81 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
82 : QAction( text, QString::null, 0, 0 ) { 82 : QAction( text, QString::null, 0, 0 ) {
83 connect( this, SIGNAL( activated() ), handler, slot ); 83 connect( this, SIGNAL( activated() ), handler, slot );
84 addTo( parent ); 84 addTo( parent );
85 } 85 }
86}; 86};
87 87
88 88
89PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 89PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
90 : QMainWindow( parent, name, fl ) { 90 : QMainWindow( parent, name, fl ) {
91 91
92 d = new PlayListWidgetPrivate; 92 d = new PlayListWidgetPrivate;
93 d->setDocumentUsed = FALSE; 93 d->setDocumentUsed = FALSE;
94 d->current = NULL; 94 d->current = NULL;
95 fromSetDocument = FALSE; 95 fromSetDocument = FALSE;
96 insanityBool=FALSE; 96 insanityBool=FALSE;
97 audioScan = FALSE; 97 audioScan = FALSE;
98 videoScan = FALSE; 98 videoScan = FALSE;
99 99
100 setBackgroundMode( PaletteButton ); 100 setBackgroundMode( PaletteButton );
101 101
102 setCaption( tr("OpiePlayer") ); 102// setCaption( tr("OpiePlayer") );
103 setIcon( Resource::loadPixmap( "opieplayer2/MPEGPlayer" ) ); 103 setIcon( Resource::loadPixmap( "opieplayer2/MPEGPlayer" ) );
104 104
105 setToolBarsMovable( FALSE ); 105 setToolBarsMovable( FALSE );
106 106
107 // Create Toolbar 107 // Create Toolbar
108 QPEToolBar *toolbar = new QPEToolBar( this ); 108 QPEToolBar *toolbar = new QPEToolBar( this );
109 toolbar->setHorizontalStretchable( TRUE ); 109 toolbar->setHorizontalStretchable( TRUE );
110 110
111 // Create Menubar 111 // Create Menubar
112 QPEMenuBar *menu = new QPEMenuBar( toolbar ); 112 QPEMenuBar *menu = new QPEMenuBar( toolbar );
113 menu->setMargin( 0 ); 113 menu->setMargin( 0 );
114 114
115 QPEToolBar *bar = new QPEToolBar( this ); 115 QPEToolBar *bar = new QPEToolBar( this );
116 bar->setLabel( tr( "Play Operations" ) ); 116 bar->setLabel( tr( "Play Operations" ) );
117 117
118 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); 118 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close");
119 tbDeletePlaylist->setFlat(TRUE); 119 tbDeletePlaylist->setFlat(TRUE);
120 tbDeletePlaylist->setFixedSize(20,20); 120 tbDeletePlaylist->setFixedSize(20,20);
121 121
122 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer2/add_to_playlist", 122 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer2/add_to_playlist",
123 this , SLOT(addSelected()) ); 123 this , SLOT(addSelected()) );
124 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer2/remove_from_playlist", 124 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer2/remove_from_playlist",
125 this , SLOT(removeSelected()) ); 125 this , SLOT(removeSelected()) );
126 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", 126 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play",
127 this , SLOT( btnPlay(bool) ), TRUE ); 127 this , SLOT( btnPlay(bool) ), TRUE );
128 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", 128 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle",
129 mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 129 mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
130 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer2/loop", 130 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer2/loop",
131 mediaPlayerState, SLOT(setLooping(bool)), TRUE ); 131 mediaPlayerState, SLOT(setLooping(bool)), TRUE );
132 tbDeletePlaylist->hide(); 132 tbDeletePlaylist->hide();
133 133
134 QPopupMenu *pmPlayList = new QPopupMenu( this ); 134 QPopupMenu *pmPlayList = new QPopupMenu( this );
135 menu->insertItem( tr( "File" ), pmPlayList ); 135 menu->insertItem( tr( "File" ), pmPlayList );
136 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 136 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
137 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 137 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
138 (void)new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 138 (void)new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
139 (void)new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 139 (void)new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
140 pmPlayList->insertSeparator(-1); 140 pmPlayList->insertSeparator(-1);
141 (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 141 (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
142 (void)new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); 142 (void)new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) );
143 pmPlayList->insertSeparator(-1); 143 pmPlayList->insertSeparator(-1);
144 (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); 144 (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
145 pmPlayList->insertSeparator(-1); 145 pmPlayList->insertSeparator(-1);
146 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); 146 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) );
147 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); 147 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) );
148 148
149 pmView = new QPopupMenu( this ); 149 pmView = new QPopupMenu( this );
150 menu->insertItem( tr( "View" ), pmView ); 150 menu->insertItem( tr( "View" ), pmView );
151 pmView->isCheckable(); 151 pmView->isCheckable();
152 152
153 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), mediaPlayerState, SLOT( toggleFullscreen() ) ); 153 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), mediaPlayerState, SLOT( toggleFullscreen() ) );
154 154
155 Config cfg( "OpiePlayer" ); 155 Config cfg( "OpiePlayer" );
156 bool b= cfg.readBoolEntry("FullScreen", 0); 156 bool b= cfg.readBoolEntry("FullScreen", 0);
157 mediaPlayerState->setFullscreen( b ); 157 mediaPlayerState->setFullscreen( b );
158 pmView->setItemChecked( -16, b ); 158 pmView->setItemChecked( -16, b );
159 159
160 // pmView->insertItem( Resource::loadPixmap("opieplayer/scale") , tr( "Scale"), mediaPlayerState, SLOT(toggleScaled() ) ); 160 // pmView->insertItem( Resource::loadPixmap("opieplayer/scale") , tr( "Scale"), mediaPlayerState, SLOT(toggleScaled() ) );
161 161
162 pmView->insertSeparator(-1); 162 pmView->insertSeparator(-1);
163 163
164 skinsMenu = new QPopupMenu( this ); 164 skinsMenu = new QPopupMenu( this );
165 pmView->insertItem( tr( "Skins" ), skinsMenu ); 165 pmView->insertItem( tr( "Skins" ), skinsMenu );
166 skinsMenu->isCheckable(); 166 skinsMenu->isCheckable();
167 populateSkinsMenu(); 167 populateSkinsMenu();
168 168
169 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 169 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
170 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); 170 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
171 171
172 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); 172 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
173 173
174 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 174 tabWidget = new QTabWidget( hbox6, "tabWidget" );
175 // tabWidget->setTabShape(QTabWidget::Triangular); 175 // tabWidget->setTabShape(QTabWidget::Triangular);
176 176
177 QWidget *pTab; 177 QWidget *pTab;
178 pTab = new QWidget( tabWidget, "pTab" ); 178 pTab = new QWidget( tabWidget, "pTab" );
179 tabWidget->insertTab( pTab,"Playlist"); 179 tabWidget->insertTab( pTab,"Playlist");
180 180
181 181
182 QGridLayout *Playout = new QGridLayout( pTab ); 182 QGridLayout *Playout = new QGridLayout( pTab );
183 Playout->setSpacing( 2); 183 Playout->setSpacing( 2);
184 Playout->setMargin( 2); 184 Playout->setMargin( 2);
185 185
186 // Add the playlist area 186 // Add the playlist area
187 187
188 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); 188 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
189 d->playListFrame = vbox3; 189 d->playListFrame = vbox3;
190 190
191 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); 191 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
192 192
193 d->selectedFiles = new PlayListSelection( hbox2); 193 d->selectedFiles = new PlayListSelection( hbox2);
194 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); 194 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
195 195
196 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); 196 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold);
197 197
198 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch 198 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
199 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", d->selectedFiles, SLOT(moveSelectedUp()) ); 199 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", d->selectedFiles, SLOT(moveSelectedUp()) );
200 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", d->selectedFiles, SLOT(removeSelected()) ); 200 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", d->selectedFiles, SLOT(removeSelected()) );
201 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", d->selectedFiles, SLOT(moveSelectedDown()) ); 201 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", d->selectedFiles, SLOT(moveSelectedDown()) );
202 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch 202 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
203 203
204 204
205 Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 ); 205 Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 );
206 206
207 QWidget *aTab; 207 QWidget *aTab;
208 aTab = new QWidget( tabWidget, "aTab" ); 208 aTab = new QWidget( tabWidget, "aTab" );
209 209
210 QGridLayout *Alayout = new QGridLayout( aTab ); 210 QGridLayout *Alayout = new QGridLayout( aTab );
211 Alayout->setSpacing( 2); 211 Alayout->setSpacing( 2);
212 Alayout->setMargin( 2); 212 Alayout->setMargin( 2);
213 213
214 audioView = new QListView( aTab, "Audioview" ); 214 audioView = new QListView( aTab, "Audioview" );
215 audioView->addColumn( tr("Title"),140); 215 audioView->addColumn( tr("Title"),140);
216 audioView->addColumn(tr("Size"), -1); 216 audioView->addColumn(tr("Size"), -1);
217 audioView->addColumn(tr("Media"),-1); 217 audioView->addColumn(tr("Media"),-1);
218 audioView->setColumnAlignment(1, Qt::AlignRight); 218 audioView->setColumnAlignment(1, Qt::AlignRight);
219 audioView->setColumnAlignment(2, Qt::AlignRight); 219 audioView->setColumnAlignment(2, Qt::AlignRight);
220 audioView->setAllColumnsShowFocus(TRUE); 220 audioView->setAllColumnsShowFocus(TRUE);
221 audioView->setSorting(0,TRUE); 221 audioView->setSorting(0,TRUE);
222 222
223 audioView->setMultiSelection( TRUE ); 223 audioView->setMultiSelection( TRUE );
224 audioView->setSelectionMode( QListView::Extended); 224 audioView->setSelectionMode( QListView::Extended);
225 225
226 Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 ); 226 Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 );
227 227
228 tabWidget->insertTab(aTab,tr("Audio")); 228 tabWidget->insertTab(aTab,tr("Audio"));
229 229
230 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); 230 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold);
231 231
232 QWidget *vTab; 232 QWidget *vTab;
233 vTab = new QWidget( tabWidget, "vTab" ); 233 vTab = new QWidget( tabWidget, "vTab" );
234 234
235 QGridLayout *Vlayout = new QGridLayout( vTab ); 235 QGridLayout *Vlayout = new QGridLayout( vTab );
236 Vlayout->setSpacing( 2); 236 Vlayout->setSpacing( 2);
237 Vlayout->setMargin( 2); 237 Vlayout->setMargin( 2);
238 238
239 videoView = new QListView( vTab, "Videoview" ); 239 videoView = new QListView( vTab, "Videoview" );
240 240
241 videoView->addColumn(tr("Title"),140); 241 videoView->addColumn(tr("Title"),140);
242 videoView->addColumn(tr("Size"),-1); 242 videoView->addColumn(tr("Size"),-1);
243 videoView->addColumn(tr("Media"),-1); 243 videoView->addColumn(tr("Media"),-1);
244 videoView->setColumnAlignment(1, Qt::AlignRight); 244 videoView->setColumnAlignment(1, Qt::AlignRight);
245 videoView->setColumnAlignment(2, Qt::AlignRight); 245 videoView->setColumnAlignment(2, Qt::AlignRight);
246 videoView->setAllColumnsShowFocus(TRUE); 246 videoView->setAllColumnsShowFocus(TRUE);
247 videoView->setSorting(0,TRUE); 247 videoView->setSorting(0,TRUE);
248 248
249 videoView->setMultiSelection( TRUE ); 249 videoView->setMultiSelection( TRUE );
250 videoView->setSelectionMode( QListView::Extended); 250 videoView->setSelectionMode( QListView::Extended);
251 251
252 Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 ); 252 Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 );
253 253
254 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); 254 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold);
255 255
256 tabWidget->insertTab( vTab,tr("Video")); 256 tabWidget->insertTab( vTab,tr("Video"));
257 257
258 //playlists list 258 //playlists list
259 QWidget *LTab; 259 QWidget *LTab;
260 LTab = new QWidget( tabWidget, "LTab" ); 260 LTab = new QWidget( tabWidget, "LTab" );
261 QGridLayout *Llayout = new QGridLayout( LTab ); 261 QGridLayout *Llayout = new QGridLayout( LTab );
262 Llayout->setSpacing( 2); 262 Llayout->setSpacing( 2);
263 Llayout->setMargin( 2); 263 Llayout->setMargin( 2);
264 264
265 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy 265 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy
266 Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 ); 266 Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 );
267 267
268 tabWidget->insertTab(LTab,tr("Lists")); 268 tabWidget->insertTab(LTab,tr("Lists"));
269 269
270 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); 270 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
271 271
272 connect( pmView, SIGNAL( activated(int)), this, SLOT( pmViewActivated(int) ) ); 272 connect( pmView, SIGNAL( activated(int)), this, SLOT( pmViewActivated(int) ) );
273 273
274 connect( skinsMenu, SIGNAL( activated(int)), this, SLOT(skinsMenuActivated(int) ) ); 274 connect( skinsMenu, SIGNAL( activated(int)), this, SLOT(skinsMenuActivated(int) ) );
275 275
276 // connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled() ) ); 276 // connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled() ) );
277 277
278 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 278 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
279 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); 279 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) );
280 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 280 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
281 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 281 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
282 connect( audioView, SIGNAL( returnPressed( QListViewItem *)), 282 connect( audioView, SIGNAL( returnPressed( QListViewItem *)),
283 this,SLOT( playIt( QListViewItem *)) ); 283 this,SLOT( playIt( QListViewItem *)) );
284 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 284 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
285 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 285 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
286 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 286 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
287 connect( videoView, SIGNAL( returnPressed( QListViewItem *)), 287 connect( videoView, SIGNAL( returnPressed( QListViewItem *)),
288 this,SLOT( playIt( QListViewItem *)) ); 288 this,SLOT( playIt( QListViewItem *)) );
289 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 289 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
290 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); 290 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
291 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); 291 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
292 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 292 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
293 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); 293 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
294 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 294 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
295 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 295 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
296 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 296 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
297 297
298 setCentralWidget( vbox5 ); 298 setCentralWidget( vbox5 );
299 299
300 readConfig( cfg ); 300 readConfig( cfg );
301 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 301 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
302 loadList(DocLnk( currentPlaylist)); 302 loadList(DocLnk( currentPlaylist));
303 setCaption(tr("OpiePlayer: ")+ currentPlaylist ); 303 setCaption(tr("OpiePlayer: ")+ currentPlaylist );
304 304
305 initializeStates(); 305 initializeStates();
306} 306}
307 307
308 308
309PlayListWidget::~PlayListWidget() { 309PlayListWidget::~PlayListWidget() {
310 Config cfg( "OpiePlayer" ); 310 Config cfg( "OpiePlayer" );
311 writeConfig( cfg ); 311 writeConfig( cfg );
312 312
313 if ( d->current ) { 313 if ( d->current ) {
314 delete d->current; 314 delete d->current;
315 } 315 }
316 delete d; 316 delete d;
317} 317}
318 318
319 319
320void PlayListWidget::initializeStates() { 320void PlayListWidget::initializeStates() {
321 321
322 d->tbPlay->setOn( mediaPlayerState->playing() ); 322 d->tbPlay->setOn( mediaPlayerState->playing() );
323 d->tbLoop->setOn( mediaPlayerState->looping() ); 323 d->tbLoop->setOn( mediaPlayerState->looping() );
324 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 324 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
325 setPlaylist( true); 325 setPlaylist( true);
326} 326}
327 327
328 328
329void PlayListWidget::readConfig( Config& cfg ) { 329void PlayListWidget::readConfig( Config& cfg ) {
330 cfg.setGroup("PlayList"); 330 cfg.setGroup("PlayList");
331 QString currentString = cfg.readEntry("current", "" ); 331 QString currentString = cfg.readEntry("current", "" );
332 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 332 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
333 for ( int i = 0; i < noOfFiles; i++ ) { 333 for ( int i = 0; i < noOfFiles; i++ ) {
334 QString entryName; 334 QString entryName;
335 entryName.sprintf( "File%i", i + 1 ); 335 entryName.sprintf( "File%i", i + 1 );
336 QString linkFile = cfg.readEntry( entryName ); 336 QString linkFile = cfg.readEntry( entryName );
337 if(QFileInfo( linkFile).exists() ) { 337 if(QFileInfo( linkFile).exists() ) {
338 DocLnk lnk( linkFile ); 338 DocLnk lnk( linkFile );
339 if ( QFileInfo( lnk.file()).exists() || linkFile.find("http",0,TRUE) != -1) { 339 if ( QFileInfo( lnk.file()).exists() || linkFile.find("http",0,TRUE) != -1) {
340 d->selectedFiles->addToSelection( lnk ); 340 d->selectedFiles->addToSelection( lnk );
341 } 341 }
342 } 342 }
343 } 343 }
344 d->selectedFiles->setSelectedItem( currentString); 344 d->selectedFiles->setSelectedItem( currentString);
345} 345}
346 346
347 347
348void PlayListWidget::writeConfig( Config& cfg ) const { 348void PlayListWidget::writeConfig( Config& cfg ) const {
349 349
350 d->selectedFiles->writeCurrent( cfg); 350 d->selectedFiles->writeCurrent( cfg);
351 cfg.setGroup("PlayList"); 351 cfg.setGroup("PlayList");
352 int noOfFiles = 0; 352 int noOfFiles = 0;
353 d->selectedFiles->first(); 353 d->selectedFiles->first();
354 do { 354 do {
355 const DocLnk *lnk = d->selectedFiles->current(); 355 const DocLnk *lnk = d->selectedFiles->current();
356 if ( lnk ) { 356 if ( lnk ) {
357 QString entryName; 357 QString entryName;
358 entryName.sprintf( "File%i", noOfFiles + 1 ); 358 entryName.sprintf( "File%i", noOfFiles + 1 );
359 cfg.writeEntry( entryName, lnk->linkFile() ); 359 cfg.writeEntry( entryName, lnk->linkFile() );
360 // if this link does exist, add it so we have the file 360 // if this link does exist, add it so we have the file
361 // next time... 361 // next time...
362 if ( !QFile::exists( lnk->linkFile() ) ) { 362 if ( !QFile::exists( lnk->linkFile() ) ) {
363 // the way writing lnks doesn't really check for out 363 // the way writing lnks doesn't really check for out
364 // of disk space, but check it anyway. 364 // of disk space, but check it anyway.
365 if ( !lnk->writeLink() ) { 365 if ( !lnk->writeLink() ) {
366 QMessageBox::critical( 0, tr("Out of space"), 366 QMessageBox::critical( 0, tr("Out of space"),
367 tr( "There was a problem saving " 367 tr( "There was a problem saving "
368 "the playlist.\n" 368 "the playlist.\n"
369 "Your playlist " 369 "Your playlist "
370 "may be missing some entries\n" 370 "may be missing some entries\n"
371 "the next time you start it." ) 371 "the next time you start it." )
372 ); 372 );
373 } 373 }
374 } 374 }
375 noOfFiles++; 375 noOfFiles++;
376 } 376 }
377 } 377 }
378 while ( d->selectedFiles->next() ); 378 while ( d->selectedFiles->next() );
379 cfg.writeEntry("NumberOfFiles", noOfFiles ); 379 cfg.writeEntry("NumberOfFiles", noOfFiles );
380} 380}
381 381
382 382
383void PlayListWidget::addToSelection( const DocLnk& lnk ) { 383void PlayListWidget::addToSelection( const DocLnk& lnk ) {
384 d->setDocumentUsed = FALSE; 384 d->setDocumentUsed = FALSE;
385 if ( mediaPlayerState->playlist() ) { 385 if ( mediaPlayerState->playlist() ) {
386 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) 386 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" )
387 d->selectedFiles->addToSelection( lnk ); 387 d->selectedFiles->addToSelection( lnk );
388 } 388 }
389 else 389 else
390 mediaPlayerState->setPlaying( TRUE ); 390 mediaPlayerState->setPlaying( TRUE );
391} 391}
392 392
393 393
394void PlayListWidget::clearList() { 394void PlayListWidget::clearList() {
395 while ( first() ) { 395 while ( first() ) {
396 d->selectedFiles->removeSelected(); 396 d->selectedFiles->removeSelected();
397 } 397 }
398} 398}
399 399
400 400
401void PlayListWidget::addAllToList() { 401void PlayListWidget::addAllToList() {
402 DocLnkSet filesAll; 402 DocLnkSet filesAll;
403 Global::findDocuments(&filesAll, "video/*;audio/*"); 403 Global::findDocuments(&filesAll, "video/*;audio/*");
404 QListIterator<DocLnk> Adit( filesAll.children() ); 404 QListIterator<DocLnk> Adit( filesAll.children() );
405 for ( ; Adit.current(); ++Adit ) { 405 for ( ; Adit.current(); ++Adit ) {
406 if(QFileInfo(Adit.current()->file()).exists()) { 406 if(QFileInfo(Adit.current()->file()).exists()) {
407 d->selectedFiles->addToSelection( **Adit ); 407 d->selectedFiles->addToSelection( **Adit );
408 } 408 }
409 } 409 }
410} 410}
411 411
412 412
413void PlayListWidget::addAllMusicToList() { 413void PlayListWidget::addAllMusicToList() {
414 QListIterator<DocLnk> dit( files.children() ); 414 QListIterator<DocLnk> dit( files.children() );
415 for ( ; dit.current(); ++dit ) { 415 for ( ; dit.current(); ++dit ) {
416 if(QFileInfo(dit.current()->file()).exists()) { 416 if(QFileInfo(dit.current()->file()).exists()) {
417 d->selectedFiles->addToSelection( **dit ); 417 d->selectedFiles->addToSelection( **dit );
418 } 418 }
419 } 419 }
420} 420}
421 421
422 422
423void PlayListWidget::addAllVideoToList() { 423void PlayListWidget::addAllVideoToList() {
424 QListIterator<DocLnk> dit( vFiles.children() ); 424 QListIterator<DocLnk> dit( vFiles.children() );
425 for ( ; dit.current(); ++dit ) 425 for ( ; dit.current(); ++dit )
426 if(QFileInfo( dit.current()->file()).exists()) 426 if(QFileInfo( dit.current()->file()).exists())
427 d->selectedFiles->addToSelection( **dit ); 427 d->selectedFiles->addToSelection( **dit );
428} 428}
429 429
430 430
431void PlayListWidget::setDocument(const QString& fileref) { 431void PlayListWidget::setDocument(const QString& fileref) {
432 qDebug(fileref); 432 qDebug(fileref);
433 fromSetDocument = TRUE; 433 fromSetDocument = TRUE;
434 if ( fileref.isNull() ) { 434 if ( fileref.isNull() ) {
435 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); 435 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) );
436 return; 436 return;
437 } 437 }
438 438
439 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u 439 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u
440 readm3u( fileref); 440 readm3u( fileref);
441 } else if(fileref.find("pls",0,TRUE) != -1) { //is pls 441 } else if(fileref.find("pls",0,TRUE) != -1) { //is pls
442 readPls( fileref); 442 readPls( fileref);
443 } else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist 443 } else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist
444 clearList(); 444 clearList();
445 loadList(DocLnk(fileref)); 445 loadList(DocLnk(fileref));
446 d->selectedFiles->first(); 446 d->selectedFiles->first();
447 } else { 447 } else {
448 clearList(); 448 clearList();
449 addToSelection( DocLnk( fileref ) ); 449 addToSelection( DocLnk( fileref ) );
450 d->setDocumentUsed = TRUE; 450 d->setDocumentUsed = TRUE;
451 mediaPlayerState->setPlaying( FALSE ); 451 mediaPlayerState->setPlaying( FALSE );
452 qApp->processEvents(); 452 qApp->processEvents();
453 mediaPlayerState->setPlaying( TRUE ); 453 mediaPlayerState->setPlaying( TRUE );
454 qApp->processEvents(); 454 qApp->processEvents();
455 setCaption(tr("OpiePlayer")); 455 setCaption(tr("OpiePlayer"));
456 } 456 }
457} 457}
458 458
459 459
460void PlayListWidget::setActiveWindow() { 460void PlayListWidget::setActiveWindow() {
461 qDebug("SETTING active window"); 461 qDebug("SETTING active window");
462 // When we get raised we need to ensure that it switches views 462 // When we get raised we need to ensure that it switches views
463 char origView = mediaPlayerState->view(); 463 char origView = mediaPlayerState->view();
464 mediaPlayerState->setView( 'l' ); // invalidate 464 mediaPlayerState->setView( 'l' ); // invalidate
465 mediaPlayerState->setView( origView ); // now switch back 465 mediaPlayerState->setView( origView ); // now switch back
466} 466}
467 467
468 468
469void PlayListWidget::useSelectedDocument() { 469void PlayListWidget::useSelectedDocument() {
470 d->setDocumentUsed = FALSE; 470 d->setDocumentUsed = FALSE;
471} 471}
472 472
473 473
474const DocLnk *PlayListWidget::current() { // this is fugly 474const DocLnk *PlayListWidget::current() { // this is fugly
475 475
476 switch (tabWidget->currentPageIndex()) { 476 switch (tabWidget->currentPageIndex()) {
477 case 0: //playlist 477 case 0: //playlist
478 { 478 {
479 qDebug("playlist"); 479 qDebug("playlist");
480 if ( mediaPlayerState->playlist() ) { 480 if ( mediaPlayerState->playlist() ) {
481 return d->selectedFiles->current(); 481 return d->selectedFiles->current();
482 } else if ( d->setDocumentUsed && d->current ) { 482 } else if ( d->setDocumentUsed && d->current ) {
483 return d->current; 483 return d->current;
484 } else { 484 } else {
485 return d->files->selected(); 485 return d->files->selected();
486 } 486 }