summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-11-03 23:41:56 (UTC)
committer llornkcor <llornkcor>2002-11-03 23:41:56 (UTC)
commit829eeff0374389891aa88b12fcafffb55f480797 (patch) (unidiff)
treebdef672d653e386535647ef82e291d95b520ef78
parentbf62b8f48d08f5a5e92681e1487a5f43d5c7a231 (diff)
downloadopie-829eeff0374389891aa88b12fcafffb55f480797.zip
opie-829eeff0374389891aa88b12fcafffb55f480797.tar.gz
opie-829eeff0374389891aa88b12fcafffb55f480797.tar.bz2
finish audio skin
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/audiowidget.cpp20
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp48
-rw-r--r--core/multimedia/opieplayer/playlistwidget.h5
3 files changed, 63 insertions, 10 deletions
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp
index 896da91..d20d560 100644
--- a/core/multimedia/opieplayer/audiowidget.cpp
+++ b/core/multimedia/opieplayer/audiowidget.cpp
@@ -1,491 +1,491 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21#include <qpe/resource.h> 21#include <qpe/resource.h>
22#include <qpe/config.h> 22#include <qpe/config.h>
23 23
24#include <qwidget.h> 24#include <qwidget.h>
25#include <qpixmap.h> 25#include <qpixmap.h>
26#include <qbutton.h> 26#include <qbutton.h>
27#include <qpainter.h> 27#include <qpainter.h>
28#include <qframe.h> 28#include <qframe.h>
29#include <qlayout.h> 29#include <qlayout.h>
30 30
31#include "audiowidget.h" 31#include "audiowidget.h"
32#include "mediaplayerstate.h" 32#include "mediaplayerstate.h"
33 33
34#include <stdlib.h> 34#include <stdlib.h>
35#include <stdio.h> 35#include <stdio.h>
36 36
37extern MediaPlayerState *mediaPlayerState; 37extern MediaPlayerState *mediaPlayerState;
38 38
39 39
40static const int xo = -2; // movable x offset 40static const int xo = -2; // movable x offset
41static const int yo = 22; // movable y offset 41static const int yo = 22; // movable y offset
42 42
43struct MediaButton { 43struct MediaButton {
44 bool isToggle, isHeld, isDown; 44 bool isToggle, isHeld, isDown;
45}; 45};
46 46
47//Layout information for the audioButtons (and if it is a toggle button or not) 47//Layout information for the audioButtons (and if it is a toggle button or not)
48MediaButton audioButtons[] = { 48MediaButton audioButtons[] = {
49 { TRUE, FALSE, FALSE }, // play 49 { TRUE, FALSE, FALSE }, // play
50 { FALSE, FALSE, FALSE }, // stop 50 { FALSE, FALSE, FALSE }, // stop
51 { TRUE, FALSE, FALSE }, // pause
52 { FALSE, FALSE, FALSE }, // next 51 { FALSE, FALSE, FALSE }, // next
53 { FALSE, FALSE, FALSE }, // previous 52 { FALSE, FALSE, FALSE }, // previous
54 { FALSE, FALSE, FALSE }, // volume up 53 { FALSE, FALSE, FALSE }, // volume up
55 { FALSE, FALSE, FALSE }, // volume down 54 { FALSE, FALSE, FALSE }, // volume down
56 { TRUE, FALSE, FALSE }, // repeat/loop 55 { TRUE, FALSE, FALSE }, // repeat/loop
57 { FALSE, FALSE, FALSE }, // playlist 56 { FALSE, FALSE, FALSE }, // playlist
58 { FALSE, FALSE, FALSE }, // forward 57 { FALSE, FALSE, FALSE }, // forward
59 { FALSE, FALSE, FALSE } // back 58 { FALSE, FALSE, FALSE } // back
60}; 59};
61 60
62const char *skin_mask_file_names[11] = { 61const char *skin_mask_file_names[10] = {
63 "play", "stop", "pause", "next", "prev", "up", 62 "play", "stop", "next", "prev", "up",
64 "down", "loop", "playlist", "forward", "back" 63 "down", "loop", "playlist", "forward", "back"
65}; 64};
66 65
67
68static void changeTextColor( QWidget *w ) { 66static void changeTextColor( QWidget *w ) {
69 QPalette p = w->palette(); 67 QPalette p = w->palette();
70 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); 68 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) );
71 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); 69 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) );
72 w->setPalette( p ); 70 w->setPalette( p );
73} 71}
74 72
75static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); 73static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
76 74
77AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : 75AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
78 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) 76 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this )
79{ 77{
80 setCaption( tr("OpiePlayer") ); 78 setCaption( tr("OpiePlayer") );
81 qDebug("<<<<<audioWidget"); 79 qDebug("<<<<<audioWidget");
82 80
83 Config cfg("OpiePlayer"); 81 Config cfg("OpiePlayer");
84 cfg.setGroup("AudioWidget"); 82 cfg.setGroup("Options");
85 skin = cfg.readEntry("Skin","default"); 83 skin = cfg.readEntry("Skin","default");
86 //skin = "scaleTest"; 84 //skin = "scaleTest";
87// color of background, frame, degree of transparency 85// color of background, frame, degree of transparency
88 86
89 QString skinPath = "opieplayer2/skins/" + skin; 87 QString skinPath = "opieplayer2/skins/" + skin;
88 qDebug("skin path "+skinPath);
89
90 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 90 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
91 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); 91 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
92 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); 92 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
93 93
94 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); 94 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
95 imgButtonMask->fill( 0 ); 95 imgButtonMask->fill( 0 );
96 96
97 for ( int i = 0; i < 11; i++ ) { 97 for ( int i = 0; i < 10; i++ ) {
98 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; 98 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png";
99 masks[i] = new QBitmap( filename ); 99 masks[i] = new QBitmap( filename );
100 100
101 if ( !masks[i]->isNull() ) { 101 if ( !masks[i]->isNull() ) {
102 QImage imgMask = masks[i]->convertToImage(); 102 QImage imgMask = masks[i]->convertToImage();
103 uchar **dest = imgButtonMask->jumpTable(); 103 uchar **dest = imgButtonMask->jumpTable();
104 for ( int y = 0; y < imgUp->height(); y++ ) { 104 for ( int y = 0; y < imgUp->height(); y++ ) {
105 uchar *line = dest[y]; 105 uchar *line = dest[y];
106 for ( int x = 0; x < imgUp->width(); x++ ) 106 for ( int x = 0; x < imgUp->width(); x++ )
107 if ( !qRed( imgMask.pixel( x, y ) ) ) 107 if ( !qRed( imgMask.pixel( x, y ) ) )
108 line[x] = i + 1; 108 line[x] = i + 1;
109 } 109 }
110 } 110 }
111 111
112 } 112 }
113 113
114 for ( int i = 0; i < 11; i++ ) { 114 for ( int i = 0; i < 11; i++ ) {
115 buttonPixUp[i] = NULL; 115 buttonPixUp[i] = NULL;
116 buttonPixDown[i] = NULL; 116 buttonPixDown[i] = NULL;
117 } 117 }
118 118
119 setBackgroundPixmap( *pixBg ); 119 setBackgroundPixmap( *pixBg );
120 120
121 songInfo.setFocusPolicy( QWidget::NoFocus ); 121 songInfo.setFocusPolicy( QWidget::NoFocus );
122 122
123 changeTextColor( &songInfo ); 123 changeTextColor( &songInfo );
124 songInfo.setBackgroundColor( QColor( 167, 212, 167 )); 124 songInfo.setBackgroundColor( QColor( 167, 212, 167 ));
125 songInfo.setFrameStyle( QFrame::NoFrame); 125 songInfo.setFrameStyle( QFrame::NoFrame);
126// songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); 126// songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
127 //NoFrame 127 //NoFrame
128// songInfo.setForegroundColor(Qt::white); 128// songInfo.setForegroundColor(Qt::white);
129 129
130 slider.setFixedHeight( 20 ); 130 slider.setFixedHeight( 20 );
131 slider.setMinValue( 0 ); 131 slider.setMinValue( 0 );
132 slider.setMaxValue( 1 ); 132 slider.setMaxValue( 1 );
133 slider.setFocusPolicy( QWidget::NoFocus ); 133 slider.setFocusPolicy( QWidget::NoFocus );
134 slider.setBackgroundPixmap( *pixBg ); 134 slider.setBackgroundPixmap( *pixBg );
135 135
136 time.setFocusPolicy( QWidget::NoFocus ); 136 time.setFocusPolicy( QWidget::NoFocus );
137 time.setAlignment( Qt::AlignCenter ); 137 time.setAlignment( Qt::AlignCenter );
138 time.setFrame(FALSE); 138 time.setFrame(FALSE);
139 changeTextColor( &time ); 139 changeTextColor( &time );
140 140
141 resizeEvent( NULL ); 141 resizeEvent( NULL );
142 142
143 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 143 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
144 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 144 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
145 145
146 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 146 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
147 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 147 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
148 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 148 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
149 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 149 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
150 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 150 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
151 151
152 // Intialise state 152 // Intialise state
153 setLength( mediaPlayerState->length() ); 153 setLength( mediaPlayerState->length() );
154 setPosition( mediaPlayerState->position() ); 154 setPosition( mediaPlayerState->position() );
155 setLooping( mediaPlayerState->fullscreen() ); 155 setLooping( mediaPlayerState->fullscreen() );
156 setPaused( mediaPlayerState->paused() ); 156 setPaused( mediaPlayerState->paused() );
157 setPlaying( mediaPlayerState->playing() ); 157 setPlaying( mediaPlayerState->playing() );
158 158
159} 159}
160 160
161 161
162AudioWidget::~AudioWidget() { 162AudioWidget::~AudioWidget() {
163 163
164 for ( int i = 0; i < 11; i++ ) { 164 for ( int i = 0; i < 10; i++ ) {
165 delete buttonPixUp[i]; 165 delete buttonPixUp[i];
166 delete buttonPixDown[i]; 166 delete buttonPixDown[i];
167 } 167 }
168 delete pixBg; 168 delete pixBg;
169 delete imgUp; 169 delete imgUp;
170 delete imgDn; 170 delete imgDn;
171 delete imgButtonMask; 171 delete imgButtonMask;
172 for ( int i = 0; i < 11; i++ ) { 172 for ( int i = 0; i < 10; i++ ) {
173 delete masks[i]; 173 delete masks[i];
174 } 174 }
175} 175}
176 176
177 177
178QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 178QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
179 QPixmap pix( img.width(), img.height() ); 179 QPixmap pix( img.width(), img.height() );
180 QPainter p( &pix ); 180 QPainter p( &pix );
181 p.drawTiledPixmap( pix.rect(), bg, offset ); 181 p.drawTiledPixmap( pix.rect(), bg, offset );
182 p.drawImage( 0, 0, img ); 182 p.drawImage( 0, 0, img );
183 return new QPixmap( pix ); 183 return new QPixmap( pix );
184} 184}
185 185
186 186
187QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) 187QPixmap *maskPixToMask( QPixmap pix, QBitmap mask )
188{ 188{
189 QPixmap *pixmap = new QPixmap( pix ); 189 QPixmap *pixmap = new QPixmap( pix );
190 pixmap->setMask( mask ); 190 pixmap->setMask( mask );
191 return pixmap; 191 return pixmap;
192} 192}
193 193
194 194
195 195
196void AudioWidget::resizeEvent( QResizeEvent * ) { 196void AudioWidget::resizeEvent( QResizeEvent * ) {
197 int h = height(); 197 int h = height();
198 int w = width(); 198 int w = width();
199 199
200 songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); 200 songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) );
201 slider.setFixedWidth( w - 110 ); 201 slider.setFixedWidth( w - 110 );
202 slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); 202 slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) );
203 slider.setBackgroundOrigin( QWidget::ParentOrigin ); 203 slider.setBackgroundOrigin( QWidget::ParentOrigin );
204 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); 204 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
205 205
206 xoff = ( w - imgUp->width() ) / 2; 206 xoff = ( w - imgUp->width() ) / 2;
207 yoff = (( h - imgUp->height() ) / 2) - 10; 207 yoff = (( h - imgUp->height() ) / 2) - 10;
208 QPoint p( xoff, yoff ); 208 QPoint p( xoff, yoff );
209 209
210 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); 210 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p );
211 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); 211 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p );
212 212
213 for ( int i = 0; i < 11; i++ ) { 213 for ( int i = 0; i < 10; i++ ) {
214 if ( !masks[i]->isNull() ) { 214 if ( !masks[i]->isNull() ) {
215 delete buttonPixUp[i]; 215 delete buttonPixUp[i];
216 delete buttonPixDown[i]; 216 delete buttonPixDown[i];
217 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); 217 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] );
218 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); 218 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] );
219 } 219 }
220 } 220 }
221 221
222 delete pixUp; 222 delete pixUp;
223 delete pixDn; 223 delete pixDn;
224} 224}
225 225
226 226
227static bool audioSliderBeingMoved = FALSE; 227static bool audioSliderBeingMoved = FALSE;
228 228
229void AudioWidget::sliderPressed() { 229void AudioWidget::sliderPressed() {
230 audioSliderBeingMoved = TRUE; 230 audioSliderBeingMoved = TRUE;
231} 231}
232 232
233 233
234void AudioWidget::sliderReleased() { 234void AudioWidget::sliderReleased() {
235 audioSliderBeingMoved = FALSE; 235 audioSliderBeingMoved = FALSE;
236 if ( slider.width() == 0 ) 236 if ( slider.width() == 0 )
237 return; 237 return;
238 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); 238 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width());
239 mediaPlayerState->setPosition( val ); 239 mediaPlayerState->setPosition( val );
240} 240}
241 241
242 242
243void AudioWidget::setPosition( long i ) { 243void AudioWidget::setPosition( long i ) {
244// qDebug("set position %d",i); 244// qDebug("set position %d",i);
245 long length = mediaPlayerState->length(); 245 long length = mediaPlayerState->length();
246 updateSlider( i, length ); 246 updateSlider( i, length );
247} 247}
248 248
249 249
250void AudioWidget::setLength( long max ) { 250void AudioWidget::setLength( long max ) {
251 updateSlider( mediaPlayerState->position(), max ); 251 updateSlider( mediaPlayerState->position(), max );
252} 252}
253 253
254 254
255void AudioWidget::setView( char view ) { 255void AudioWidget::setView( char view ) {
256 256
257 if (mediaPlayerState->isStreaming) { 257 if (mediaPlayerState->isStreaming) {
258 if( !slider.isHidden()) slider.hide(); 258 if( !slider.isHidden()) slider.hide();
259 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 259 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
260 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 260 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
261 } else { 261 } else {
262// this stops the slider from being moved, thus 262// this stops the slider from being moved, thus
263 // does not stop stream when it reaches the end 263 // does not stop stream when it reaches the end
264 slider.show(); 264 slider.show();
265 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 265 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
266 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 266 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
267 } 267 }
268 268
269 if ( view == 'a' ) { 269 if ( view == 'a' ) {
270 startTimer( 150 ); 270 startTimer( 150 );
271// show(); 271// show();
272 showMaximized(); 272 showMaximized();
273 } else { 273 } else {
274 killTimers(); 274 killTimers();
275 hide(); 275 hide();
276 } 276 }
277} 277}
278 278
279 279
280static QString timeAsString( long length ) { 280static QString timeAsString( long length ) {
281 length /= 44100; 281 length /= 44100;
282 int minutes = length / 60; 282 int minutes = length / 60;
283 int seconds = length % 60; 283 int seconds = length % 60;
284 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); 284 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 );
285} 285}
286 286
287void AudioWidget::updateSlider( long i, long max ) { 287void AudioWidget::updateSlider( long i, long max ) {
288 time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); 288 time.setText( timeAsString( i ) + " / " + timeAsString( max ) );
289 289
290 if ( max == 0 ) 290 if ( max == 0 )
291 return; 291 return;
292 // Will flicker too much if we don't do this 292 // Will flicker too much if we don't do this
293 // Scale to something reasonable 293 // Scale to something reasonable
294 int width = slider.width(); 294 int width = slider.width();
295 int val = int((double)i * width / max); 295 int val = int((double)i * width / max);
296 if ( !audioSliderBeingMoved ) { 296 if ( !audioSliderBeingMoved ) {
297 if ( slider.value() != val ) 297 if ( slider.value() != val )
298 slider.setValue( val ); 298 slider.setValue( val );
299 if ( slider.maxValue() != width ) 299 if ( slider.maxValue() != width )
300 slider.setMaxValue( width ); 300 slider.setMaxValue( width );
301 } 301 }
302} 302}
303 303
304 304
305void AudioWidget::setToggleButton( int i, bool down ) { 305void AudioWidget::setToggleButton( int i, bool down ) {
306 if ( down != audioButtons[i].isDown ) 306 if ( down != audioButtons[i].isDown )
307 toggleButton( i ); 307 toggleButton( i );
308} 308}
309 309
310 310
311void AudioWidget::toggleButton( int i ) { 311void AudioWidget::toggleButton( int i ) {
312 audioButtons[i].isDown = !audioButtons[i].isDown; 312 audioButtons[i].isDown = !audioButtons[i].isDown;
313 QPainter p(this); 313 QPainter p(this);
314 paintButton ( &p, i ); 314 paintButton ( &p, i );
315} 315}
316 316
317 317
318void AudioWidget::paintButton( QPainter *p, int i ) { 318void AudioWidget::paintButton( QPainter *p, int i ) {
319 if ( audioButtons[i].isDown ) 319 if ( audioButtons[i].isDown )
320 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 320 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
321 else 321 else
322 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 322 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
323} 323}
324 324
325 325
326void AudioWidget::timerEvent( QTimerEvent * ) { 326void AudioWidget::timerEvent( QTimerEvent * ) {
327/* 327/*
328 int x = audioButtons[AudioPlay].xPos; 328 int x = audioButtons[AudioPlay].xPos;
329 int y = audioButtons[AudioPlay].yPos; 329 int y = audioButtons[AudioPlay].yPos;
330 QPainter p( this ); 330 QPainter p( this );
331 // Optimize to only draw the little bit of the changing images which is different 331 // Optimize to only draw the little bit of the changing images which is different
332 p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 ); 332 p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 );
333 p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 ); 333 p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 );
334*/ 334*/
335/* 335/*
336 static int frame = 0; 336 static int frame = 0;
337 if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { 337 if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) {
338 frame = frame >= 7 ? 0 : frame + 1; 338 frame = frame >= 7 ? 0 : frame + 1;
339 } 339 }
340 */ 340 */
341} 341}
342 342
343 343
344void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 344void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
345 for ( int i = 0; i < numButtons; i++ ) { 345 for ( int i = 0; i < numButtons; i++ ) {
346 if ( event->state() == QMouseEvent::LeftButton ) { 346 if ( event->state() == QMouseEvent::LeftButton ) {
347 347
348 // The test to see if the mouse click is inside the button or not 348 // The test to see if the mouse click is inside the button or not
349 int x = event->pos().x() - xoff; 349 int x = event->pos().x() - xoff;
350 int y = event->pos().y() - yoff; 350 int y = event->pos().y() - yoff;
351 351
352 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() 352 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
353 && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 ); 353 && y < imgButtonMask->height() && imgButtonMask->pixelIndex( x, y ) == i + 1 );
354 354
355 if ( isOnButton && i == AudioVolumeUp ) 355 if ( isOnButton && i == AudioVolumeUp )
356 qDebug("on up"); 356 qDebug("on up");
357 357
358 if ( isOnButton && !audioButtons[i].isHeld ) { 358 if ( isOnButton && !audioButtons[i].isHeld ) {
359 audioButtons[i].isHeld = TRUE; 359 audioButtons[i].isHeld = TRUE;
360 toggleButton(i); 360 toggleButton(i);
361 switch (i) { 361 switch (i) {
362 case AudioVolumeUp: 362 case AudioVolumeUp:
363 qDebug("more clicked"); 363 qDebug("more clicked");
364 emit moreClicked(); 364 emit moreClicked();
365 return; 365 return;
366 case AudioVolumeDown: emit lessClicked(); return; 366 case AudioVolumeDown: emit lessClicked(); return;
367 } 367 }
368 } else if ( !isOnButton && audioButtons[i].isHeld ) { 368 } else if ( !isOnButton && audioButtons[i].isHeld ) {
369 audioButtons[i].isHeld = FALSE; 369 audioButtons[i].isHeld = FALSE;
370 toggleButton(i); 370 toggleButton(i);
371 } 371 }
372 } else { 372 } else {
373 if ( audioButtons[i].isHeld ) { 373 if ( audioButtons[i].isHeld ) {
374 audioButtons[i].isHeld = FALSE; 374 audioButtons[i].isHeld = FALSE;
375 if ( !audioButtons[i].isToggle ) 375 if ( !audioButtons[i].isToggle )
376 setToggleButton( i, FALSE ); 376 setToggleButton( i, FALSE );
377 switch (i) { 377 switch (i) {
378 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; 378 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return;
379 case AudioStop: mediaPlayerState->setPlaying(FALSE); return; 379 case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
380 case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; 380 case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return;
381 case AudioNext: mediaPlayerState->setNext(); return; 381 case AudioNext: mediaPlayerState->setNext(); return;
382 case AudioPrevious: mediaPlayerState->setPrev(); return; 382 case AudioPrevious: mediaPlayerState->setPrev(); return;
383 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; 383 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return;
384 case AudioVolumeUp: emit moreReleased(); return; 384 case AudioVolumeUp: emit moreReleased(); return;
385 case AudioVolumeDown: emit lessReleased(); return; 385 case AudioVolumeDown: emit lessReleased(); return;
386 case AudioPlayList: mediaPlayerState->setList(); return; 386 case AudioPlayList: mediaPlayerState->setList(); return;
387 } 387 }
388 } 388 }
389 } 389 }
390 } 390 }
391} 391}
392 392
393 393
394 394
395void AudioWidget::mousePressEvent( QMouseEvent *event ) { 395void AudioWidget::mousePressEvent( QMouseEvent *event ) {
396 mouseMoveEvent( event ); 396 mouseMoveEvent( event );
397} 397}
398 398
399 399
400void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { 400void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
401 mouseMoveEvent( event ); 401 mouseMoveEvent( event );
402} 402}
403 403
404 404
405void AudioWidget::showEvent( QShowEvent* ) { 405void AudioWidget::showEvent( QShowEvent* ) {
406 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 406 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
407 mouseMoveEvent( &event ); 407 mouseMoveEvent( &event );
408} 408}
409 409
410 410
411void AudioWidget::closeEvent( QCloseEvent* ) { 411void AudioWidget::closeEvent( QCloseEvent* ) {
412 mediaPlayerState->setList(); 412 mediaPlayerState->setList();
413} 413}
414 414
415 415
416void AudioWidget::paintEvent( QPaintEvent * pe) { 416void AudioWidget::paintEvent( QPaintEvent * pe) {
417 if ( !pe->erased() ) { 417 if ( !pe->erased() ) {
418 // Combine with background and double buffer 418 // Combine with background and double buffer
419 QPixmap pix( pe->rect().size() ); 419 QPixmap pix( pe->rect().size() );
420 QPainter p( &pix ); 420 QPainter p( &pix );
421 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 421 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
422 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); 422 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
423 for ( int i = 0; i < numButtons; i++ ) 423 for ( int i = 0; i < numButtons; i++ )
424 paintButton( &p, i ); 424 paintButton( &p, i );
425 QPainter p2( this ); 425 QPainter p2( this );
426 p2.drawPixmap( pe->rect().topLeft(), pix ); 426 p2.drawPixmap( pe->rect().topLeft(), pix );
427 } else { 427 } else {
428 QPainter p( this ); 428 QPainter p( this );
429 for ( int i = 0; i < numButtons; i++ ) 429 for ( int i = 0; i < numButtons; i++ )
430 paintButton( &p, i ); 430 paintButton( &p, i );
431 } 431 }
432} 432}
433 433
434void AudioWidget::keyReleaseEvent( QKeyEvent *e) 434void AudioWidget::keyReleaseEvent( QKeyEvent *e)
435{ 435{
436 switch ( e->key() ) { 436 switch ( e->key() ) {
437////////////////////////////// Zaurus keys 437////////////////////////////// Zaurus keys
438 case Key_Home: 438 case Key_Home:
439 break; 439 break;
440 case Key_F9: //activity 440 case Key_F9: //activity
441 hide(); 441 hide();
442// qDebug("Audio F9"); 442// qDebug("Audio F9");
443 break; 443 break;
444 case Key_F10: //contacts 444 case Key_F10: //contacts
445 break; 445 break;
446 case Key_F11: //menu 446 case Key_F11: //menu
447 break; 447 break;
448 case Key_F12: //home 448 case Key_F12: //home
449 break; 449 break;
450 case Key_F13: //mail 450 case Key_F13: //mail
451 break; 451 break;
452 case Key_Space: { 452 case Key_Space: {
453 453
454 if(mediaPlayerState->playing()) { 454 if(mediaPlayerState->playing()) {
455// toggleButton(1); 455// toggleButton(1);
456 mediaPlayerState->setPlaying(FALSE); 456 mediaPlayerState->setPlaying(FALSE);
457// toggleButton(1); 457// toggleButton(1);
458 } else { 458 } else {
459// toggleButton(0); 459// toggleButton(0);
460 mediaPlayerState->setPlaying(TRUE); 460 mediaPlayerState->setPlaying(TRUE);
461// toggleButton(0); 461// toggleButton(0);
462 } 462 }
463 } 463 }
464 break; 464 break;
465 case Key_Down: //volume 465 case Key_Down: //volume
466 toggleButton(6); 466 toggleButton(6);
467 emit lessClicked(); 467 emit lessClicked();
468 emit lessReleased(); 468 emit lessReleased();
469 toggleButton(6); 469 toggleButton(6);
470 break; 470 break;
471 case Key_Up: //volume 471 case Key_Up: //volume
472 toggleButton(5); 472 toggleButton(5);
473 emit moreClicked(); 473 emit moreClicked();
474 emit moreReleased(); 474 emit moreReleased();
475 toggleButton(5); 475 toggleButton(5);
476 break; 476 break;
477 case Key_Right: //next in playlist 477 case Key_Right: //next in playlist
478// toggleButton(3); 478// toggleButton(3);
479 mediaPlayerState->setNext(); 479 mediaPlayerState->setNext();
480// toggleButton(3); 480// toggleButton(3);
481 break; 481 break;
482 case Key_Left: // previous in playlist 482 case Key_Left: // previous in playlist
483// toggleButton(4); 483// toggleButton(4);
484 mediaPlayerState->setPrev(); 484 mediaPlayerState->setPrev();
485// toggleButton(4); 485// toggleButton(4);
486 break; 486 break;
487 case Key_Escape: 487 case Key_Escape:
488 break; 488 break;
489 489
490 }; 490 };
491} 491}
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 6580a88..a937d7c 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -1,1352 +1,1400 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20// code added by L. J. Potter Sat 03-02-2002 06:17:54 20// code added by L. J. Potter Sat 03-02-2002 06:17:54
21#define QTOPIA_INTERNAL_FSLP 21#define QTOPIA_INTERNAL_FSLP
22#include <qpe/qcopenvelope_qws.h> 22#include <qpe/qcopenvelope_qws.h>
23 23
24#include <qpe/qpemenubar.h> 24#include <qpe/qpemenubar.h>
25#include <qpe/qpetoolbar.h> 25#include <qpe/qpetoolbar.h>
26#include <qpe/fileselector.h> 26#include <qpe/fileselector.h>
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qpe/lnkproperties.h> 28#include <qpe/lnkproperties.h>
29#include <qpe/storage.h> 29#include <qpe/storage.h>
30 30
31#include <qpe/applnk.h> 31#include <qpe/applnk.h>
32#include <qpe/config.h> 32#include <qpe/config.h>
33#include <qpe/global.h> 33#include <qpe/global.h>
34#include <qpe/resource.h> 34#include <qpe/resource.h>
35#include <qaction.h> 35#include <qaction.h>
36#include <qcursor.h> 36#include <qcursor.h>
37#include <qimage.h> 37#include <qimage.h>
38#include <qfile.h> 38#include <qfile.h>
39#include <qdir.h> 39#include <qdir.h>
40#include <qlayout.h> 40#include <qlayout.h>
41#include <qlabel.h> 41#include <qlabel.h>
42#include <qlist.h> 42#include <qlist.h>
43#include <qlistbox.h> 43#include <qlistbox.h>
44#include <qmainwindow.h> 44#include <qmainwindow.h>
45#include <qmessagebox.h> 45#include <qmessagebox.h>
46#include <qtoolbutton.h> 46#include <qtoolbutton.h>
47#include <qtabwidget.h> 47#include <qtabwidget.h>
48#include <qlistview.h> 48#include <qlistview.h>
49#include <qpoint.h> 49#include <qpoint.h>
50#include <qlineedit.h> 50#include <qlineedit.h>
51#include <qpushbutton.h> 51#include <qpushbutton.h>
52#include <qregexp.h> 52#include <qregexp.h>
53#include <qtextstream.h> 53#include <qtextstream.h>
54 54
55//#include <qtimer.h> 55//#include <qtimer.h>
56 56
57#include "playlistselection.h" 57#include "playlistselection.h"
58#include "playlistwidget.h" 58#include "playlistwidget.h"
59#include "mediaplayerstate.h" 59#include "mediaplayerstate.h"
60 60
61#include "inputDialog.h" 61#include "inputDialog.h"
62 62
63#include <stdlib.h> 63#include <stdlib.h>
64#include "audiowidget.h" 64#include "audiowidget.h"
65#include "videowidget.h" 65#include "videowidget.h"
66 66
67#include <unistd.h> 67#include <unistd.h>
68#include <sys/file.h> 68#include <sys/file.h>
69#include <sys/ioctl.h> 69#include <sys/ioctl.h>
70#include <sys/soundcard.h> 70#include <sys/soundcard.h>
71 71
72// for setBacklight() 72// for setBacklight()
73#include <linux/fb.h> 73#include <linux/fb.h>
74#include <sys/types.h> 74#include <sys/types.h>
75#include <sys/stat.h> 75#include <sys/stat.h>
76#include <stdlib.h> 76#include <stdlib.h>
77 77
78#define BUTTONS_ON_TOOLBAR 78#define BUTTONS_ON_TOOLBAR
79#define SIDE_BUTTONS 79#define SIDE_BUTTONS
80#define CAN_SAVE_LOAD_PLAYLISTS 80#define CAN_SAVE_LOAD_PLAYLISTS
81 81
82extern AudioWidget *audioUI; 82extern AudioWidget *audioUI;
83extern VideoWidget *videoUI; 83extern VideoWidget *videoUI;
84extern MediaPlayerState *mediaPlayerState; 84extern MediaPlayerState *mediaPlayerState;
85 85
86QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg"; 86QString audioMimes ="audio/mpeg;audio/x-wav;audio/x-ogg";
87// class myFileSelector { 87// class myFileSelector {
88 88
89// }; 89// };
90class PlayListWidgetPrivate { 90class PlayListWidgetPrivate {
91public: 91public:
92 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; 92 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
93 QFrame *playListFrame; 93 QFrame *playListFrame;
94 FileSelector *files; 94 FileSelector *files;
95 PlayListSelection *selectedFiles; 95 PlayListSelection *selectedFiles;
96 bool setDocumentUsed; 96 bool setDocumentUsed;
97 DocLnk *current; 97 DocLnk *current;
98}; 98};
99 99
100 100
101class ToolButton : public QToolButton { 101class ToolButton : public QToolButton {
102public: 102public:
103 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 103 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
104 : QToolButton( parent, name ) { 104 : QToolButton( parent, name ) {
105 setTextLabel( name ); 105 setTextLabel( name );
106 setPixmap( Resource::loadPixmap( icon ) ); 106 setPixmap( Resource::loadPixmap( icon ) );
107 setAutoRaise( TRUE ); 107 setAutoRaise( TRUE );
108 setFocusPolicy( QWidget::NoFocus ); 108 setFocusPolicy( QWidget::NoFocus );
109 setToggleButton( t ); 109 setToggleButton( t );
110 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 110 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
111 QPEMenuToolFocusManager::manager()->addWidget( this ); 111 QPEMenuToolFocusManager::manager()->addWidget( this );
112 } 112 }
113}; 113};
114 114
115 115
116class MenuItem : public QAction { 116class MenuItem : public QAction {
117public: 117public:
118 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) 118 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
119 : QAction( text, QString::null, 0, 0 ) { 119 : QAction( text, QString::null, 0, 0 ) {
120 connect( this, SIGNAL( activated() ), handler, slot ); 120 connect( this, SIGNAL( activated() ), handler, slot );
121 addTo( parent ); 121 addTo( parent );
122 } 122 }
123}; 123};
124 124
125 125
126PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 126PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
127 : QMainWindow( parent, name, fl ) { 127 : QMainWindow( parent, name, fl ) {
128 128
129 d = new PlayListWidgetPrivate; 129 d = new PlayListWidgetPrivate;
130 d->setDocumentUsed = FALSE; 130 d->setDocumentUsed = FALSE;
131 d->current = NULL; 131 d->current = NULL;
132 fromSetDocument = FALSE; 132 fromSetDocument = FALSE;
133 insanityBool=FALSE; 133 insanityBool=FALSE;
134 audioScan = FALSE; 134 audioScan = FALSE;
135 videoScan = FALSE; 135 videoScan = FALSE;
136// menuTimer = new QTimer( this ,"menu timer"), 136// menuTimer = new QTimer( this ,"menu timer"),
137// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) ); 137// connect( menuTimer, SIGNAL( timeout() ), SLOT( addSelected() ) );
138 138
139 setBackgroundMode( PaletteButton ); 139 setBackgroundMode( PaletteButton );
140 140
141 setCaption( tr("OpiePlayer") ); 141 setCaption( tr("OpiePlayer") );
142 setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) ); 142 setIcon( Resource::loadPixmap( "opieplayer/MPEGPlayer" ) );
143 143
144 setToolBarsMovable( FALSE ); 144 setToolBarsMovable( FALSE );
145 145
146 // Create Toolbar 146 // Create Toolbar
147 QPEToolBar *toolbar = new QPEToolBar( this ); 147 QPEToolBar *toolbar = new QPEToolBar( this );
148 toolbar->setHorizontalStretchable( TRUE ); 148 toolbar->setHorizontalStretchable( TRUE );
149 149
150 // Create Menubar 150 // Create Menubar
151 QPEMenuBar *menu = new QPEMenuBar( toolbar ); 151 QPEMenuBar *menu = new QPEMenuBar( toolbar );
152 menu->setMargin( 0 ); 152 menu->setMargin( 0 );
153 153
154 QPEToolBar *bar = new QPEToolBar( this ); 154 QPEToolBar *bar = new QPEToolBar( this );
155 bar->setLabel( tr( "Play Operations" ) ); 155 bar->setLabel( tr( "Play Operations" ) );
156// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list", 156// d->tbPlayCurList = new ToolButton( bar, tr( "play List" ), "opieplayer/play_current_list",
157// this , SLOT( addSelected()) ); 157// this , SLOT( addSelected()) );
158 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); 158 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close");
159 tbDeletePlaylist->setFlat(TRUE); 159 tbDeletePlaylist->setFlat(TRUE);
160 tbDeletePlaylist->setFixedSize(20,20); 160 tbDeletePlaylist->setFixedSize(20,20);
161 161
162 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist", 162 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer/add_to_playlist",
163 this , SLOT(addSelected()) ); 163 this , SLOT(addSelected()) );
164 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist", 164 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer/remove_from_playlist",
165 this , SLOT(removeSelected()) ); 165 this , SLOT(removeSelected()) );
166// d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE ); 166// d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", /*this */mediaPlayerState , SLOT(setPlaying(bool) /* btnPlay() */), TRUE );
167 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play", 167 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer/play",
168 this , SLOT( btnPlay(bool) ), TRUE ); 168 this , SLOT( btnPlay(bool) ), TRUE );
169 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle", 169 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer/shuffle",
170 mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 170 mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
171 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop", 171 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer/loop",
172 mediaPlayerState, SLOT(setLooping(bool)), TRUE ); 172 mediaPlayerState, SLOT(setLooping(bool)), TRUE );
173 tbDeletePlaylist->hide(); 173 tbDeletePlaylist->hide();
174 174
175 QPopupMenu *pmPlayList = new QPopupMenu( this ); 175 QPopupMenu *pmPlayList = new QPopupMenu( this );
176 menu->insertItem( tr( "File" ), pmPlayList ); 176 menu->insertItem( tr( "File" ), pmPlayList );
177 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 177 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
178 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 178 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
179 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 179 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
180 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 180 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
181 pmPlayList->insertSeparator(-1); 181 pmPlayList->insertSeparator(-1);
182 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 182 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
183 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); 183 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
184 pmPlayList->insertSeparator(-1); 184 pmPlayList->insertSeparator(-1);
185 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); 185 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) );
186 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); 186 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) );
187 187
188 QPopupMenu *pmView = new QPopupMenu( this ); 188 QPopupMenu *pmView = new QPopupMenu( this );
189 menu->insertItem( tr( "View" ), pmView ); 189 menu->insertItem( tr( "View" ), pmView );
190 190
191 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0); 191 fullScreenButton = new QAction(tr("Full Screen"), Resource::loadPixmap("fullscreen"), QString::null, 0, this, 0);
192 fullScreenButton->addTo(pmView); 192 fullScreenButton->addTo(pmView);
193 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0); 193 scaleButton = new QAction(tr("Scale"), Resource::loadPixmap("opieplayer/scale"), QString::null, 0, this, 0);
194 scaleButton->addTo(pmView); 194 scaleButton->addTo(pmView);
195 195
196
197 skinsMenu = new QPopupMenu( this );
198 menu->insertItem( tr( "Skins" ), skinsMenu );
199 skinsMenu->isCheckable();
200 connect( skinsMenu, SIGNAL( activated( int ) ) ,
201 this, SLOT( skinsMenuActivated( int ) ) );
202 populateSkinsMenu();
203
196 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 204 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
197 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); 205 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
198 206
199 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); 207 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
200 208
201 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 209 tabWidget = new QTabWidget( hbox6, "tabWidget" );
202 tabWidget->setTabShape(QTabWidget::Triangular); 210 tabWidget->setTabShape(QTabWidget::Triangular);
203 211
204 QWidget *pTab; 212 QWidget *pTab;
205 pTab = new QWidget( tabWidget, "pTab" ); 213 pTab = new QWidget( tabWidget, "pTab" );
206// playlistView = new QListView( pTab, "playlistview" ); 214// playlistView = new QListView( pTab, "playlistview" );
207// playlistView->setMinimumSize(236,260); 215// playlistView->setMinimumSize(236,260);
208 tabWidget->insertTab( pTab,"Playlist"); 216 tabWidget->insertTab( pTab,"Playlist");
209 217
210 218
211 // Add the playlist area 219 // Add the playlist area
212 220
213 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); 221 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
214 d->playListFrame = vbox3; 222 d->playListFrame = vbox3;
215 d->playListFrame ->setMinimumSize(235,260); 223 d->playListFrame ->setMinimumSize(235,260);
216 224
217 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); 225 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
218 226
219 d->selectedFiles = new PlayListSelection( hbox2); 227 d->selectedFiles = new PlayListSelection( hbox2);
220 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); 228 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
221 229
222 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); 230 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold);
223 231
224 232
225 233
226 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch 234 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
227 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) ); 235 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer/up", d->selectedFiles, SLOT(moveSelectedUp()) );
228 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) ); 236 new ToolButton( vbox1, tr( "Remove" ), "opieplayer/cut", d->selectedFiles, SLOT(removeSelected()) );
229 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) ); 237 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer/down", d->selectedFiles, SLOT(moveSelectedDown()) );
230 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch 238 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
231 239
232 QWidget *aTab; 240 QWidget *aTab;
233 aTab = new QWidget( tabWidget, "aTab" ); 241 aTab = new QWidget( tabWidget, "aTab" );
234 audioView = new QListView( aTab, "Audioview" ); 242 audioView = new QListView( aTab, "Audioview" );
235 audioView->setMinimumSize(233,260); 243 audioView->setMinimumSize(233,260);
236 audioView->addColumn( tr("Title"),140); 244 audioView->addColumn( tr("Title"),140);
237 audioView->addColumn(tr("Size"), -1); 245 audioView->addColumn(tr("Size"), -1);
238 audioView->addColumn(tr("Media"),-1); 246 audioView->addColumn(tr("Media"),-1);
239 audioView->setColumnAlignment(1, Qt::AlignRight); 247 audioView->setColumnAlignment(1, Qt::AlignRight);
240 audioView->setColumnAlignment(2, Qt::AlignRight); 248 audioView->setColumnAlignment(2, Qt::AlignRight);
241 audioView->setAllColumnsShowFocus(TRUE); 249 audioView->setAllColumnsShowFocus(TRUE);
242 250
243 audioView->setMultiSelection( TRUE ); 251 audioView->setMultiSelection( TRUE );
244 audioView->setSelectionMode( QListView::Extended); 252 audioView->setSelectionMode( QListView::Extended);
245 253
246 tabWidget->insertTab(aTab,tr("Audio")); 254 tabWidget->insertTab(aTab,tr("Audio"));
247 255
248 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); 256 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold);
249 257
250// audioView 258// audioView
251// populateAudioView(); 259// populateAudioView();
252// videowidget 260// videowidget
253 261
254 QWidget *vTab; 262 QWidget *vTab;
255 vTab = new QWidget( tabWidget, "vTab" ); 263 vTab = new QWidget( tabWidget, "vTab" );
256 videoView = new QListView( vTab, "Videoview" ); 264 videoView = new QListView( vTab, "Videoview" );
257 videoView->setMinimumSize(233,260); 265 videoView->setMinimumSize(233,260);
258 266
259 videoView->addColumn(tr("Title"),140); 267 videoView->addColumn(tr("Title"),140);
260 videoView->addColumn(tr("Size"),-1); 268 videoView->addColumn(tr("Size"),-1);
261 videoView->addColumn(tr("Media"),-1); 269 videoView->addColumn(tr("Media"),-1);
262 videoView->setColumnAlignment(1, Qt::AlignRight); 270 videoView->setColumnAlignment(1, Qt::AlignRight);
263 videoView->setColumnAlignment(2, Qt::AlignRight); 271 videoView->setColumnAlignment(2, Qt::AlignRight);
264 videoView->setAllColumnsShowFocus(TRUE); 272 videoView->setAllColumnsShowFocus(TRUE);
265 videoView->setMultiSelection( TRUE ); 273 videoView->setMultiSelection( TRUE );
266 videoView->setSelectionMode( QListView::Extended); 274 videoView->setSelectionMode( QListView::Extended);
267 275
268 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); 276 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold);
269 277
270 tabWidget->insertTab( vTab,tr("Video")); 278 tabWidget->insertTab( vTab,tr("Video"));
271 279
272 QWidget *LTab; 280 QWidget *LTab;
273 LTab = new QWidget( tabWidget, "LTab" ); 281 LTab = new QWidget( tabWidget, "LTab" );
274 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy 282 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy
275 playLists->setMinimumSize(233,260); 283 playLists->setMinimumSize(233,260);
276 tabWidget->insertTab(LTab,tr("Lists")); 284 tabWidget->insertTab(LTab,tr("Lists"));
277 285
278 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); 286 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
279 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) ); 287 connect( fullScreenButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleFullscreen()) );
280 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) ); 288 connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled()) );
281 289
282 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 290 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
283 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); 291 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) );
284 292
285 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 293 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
286 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 294 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
287 295
288 connect( audioView, SIGNAL( returnPressed( QListViewItem *)), 296 connect( audioView, SIGNAL( returnPressed( QListViewItem *)),
289 this,SLOT( playIt( QListViewItem *)) ); 297 this,SLOT( playIt( QListViewItem *)) );
290 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 298 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
291 299
292 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 300 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
293 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 301 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
294 connect( videoView, SIGNAL( returnPressed( QListViewItem *)), 302 connect( videoView, SIGNAL( returnPressed( QListViewItem *)),
295 this,SLOT( playIt( QListViewItem *)) ); 303 this,SLOT( playIt( QListViewItem *)) );
296 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 304 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
297 305
298 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); 306 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
299 307
300 308
301 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); 309 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
302 310
303// connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 311// connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
304 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); 312 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
305 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 313 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
306 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 314 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
307 315
308 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 316 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
309 317
310 setCentralWidget( vbox5 ); 318 setCentralWidget( vbox5 );
311 319
312 Config cfg( "OpiePlayer" ); 320 Config cfg( "OpiePlayer" );
313 readConfig( cfg ); 321 readConfig( cfg );
314 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 322 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
315 loadList(DocLnk( currentPlaylist)); 323 loadList(DocLnk( currentPlaylist));
316 setCaption(tr("OpiePlayer: ")+ currentPlaylist ); 324 setCaption(tr("OpiePlayer: ")+ currentPlaylist );
317 325
318 initializeStates(); 326 initializeStates();
319} 327}
320 328
321 329
322PlayListWidget::~PlayListWidget() { 330PlayListWidget::~PlayListWidget() {
323 Config cfg( "OpiePlayer" ); 331 Config cfg( "OpiePlayer" );
324 writeConfig( cfg ); 332 writeConfig( cfg );
325 333
326 if ( d->current ) 334 if ( d->current )
327 delete d->current; 335 delete d->current;
328 delete d; 336 delete d;
329} 337}
330 338
331 339
332void PlayListWidget::initializeStates() { 340void PlayListWidget::initializeStates() {
333 341
334 d->tbPlay->setOn( mediaPlayerState->playing() ); 342 d->tbPlay->setOn( mediaPlayerState->playing() );
335 d->tbLoop->setOn( mediaPlayerState->looping() ); 343 d->tbLoop->setOn( mediaPlayerState->looping() );
336 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 344 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
337 setPlaylist( true); 345 setPlaylist( true);
338} 346}
339 347
340 348
341void PlayListWidget::readConfig( Config& cfg ) { 349void PlayListWidget::readConfig( Config& cfg ) {
342 cfg.setGroup("PlayList"); 350 cfg.setGroup("PlayList");
343 QString currentString = cfg.readEntry("current", "" ); 351 QString currentString = cfg.readEntry("current", "" );
344 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 352 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
345 for ( int i = 0; i < noOfFiles; i++ ) { 353 for ( int i = 0; i < noOfFiles; i++ ) {
346 QString entryName; 354 QString entryName;
347 entryName.sprintf( "File%i", i + 1 ); 355 entryName.sprintf( "File%i", i + 1 );
348 QString linkFile = cfg.readEntry( entryName ); 356 QString linkFile = cfg.readEntry( entryName );
349 DocLnk lnk( linkFile ); 357 DocLnk lnk( linkFile );
350 if ( lnk.isValid() ) { 358 if ( lnk.isValid() ) {
351 d->selectedFiles->addToSelection( lnk ); 359 d->selectedFiles->addToSelection( lnk );
352 } 360 }
353 } 361 }
354 d->selectedFiles->setSelectedItem( currentString); 362 d->selectedFiles->setSelectedItem( currentString);
355} 363}
356 364
357 365
358void PlayListWidget::writeConfig( Config& cfg ) const { 366void PlayListWidget::writeConfig( Config& cfg ) const {
359 367
360 d->selectedFiles->writeCurrent( cfg); 368 d->selectedFiles->writeCurrent( cfg);
361 cfg.setGroup("PlayList"); 369 cfg.setGroup("PlayList");
362 int noOfFiles = 0; 370 int noOfFiles = 0;
363 d->selectedFiles->first(); 371 d->selectedFiles->first();
364 do { 372 do {
365 const DocLnk *lnk = d->selectedFiles->current(); 373 const DocLnk *lnk = d->selectedFiles->current();
366 if ( lnk ) { 374 if ( lnk ) {
367 QString entryName; 375 QString entryName;
368 entryName.sprintf( "File%i", noOfFiles + 1 ); 376 entryName.sprintf( "File%i", noOfFiles + 1 );
369// qDebug(entryName); 377// qDebug(entryName);
370 cfg.writeEntry( entryName, lnk->linkFile() ); 378 cfg.writeEntry( entryName, lnk->linkFile() );
371 // if this link does exist, add it so we have the file 379 // if this link does exist, add it so we have the file
372 // next time... 380 // next time...
373 if ( !QFile::exists( lnk->linkFile() ) ) { 381 if ( !QFile::exists( lnk->linkFile() ) ) {
374 // the way writing lnks doesn't really check for out 382 // the way writing lnks doesn't really check for out
375 // of disk space, but check it anyway. 383 // of disk space, but check it anyway.
376 if ( !lnk->writeLink() ) { 384 if ( !lnk->writeLink() ) {
377 QMessageBox::critical( 0, tr("Out of space"), 385 QMessageBox::critical( 0, tr("Out of space"),
378 tr( "There was a problem saving " 386 tr( "There was a problem saving "
379 "the playlist.\n" 387 "the playlist.\n"
380 "Your playlist " 388 "Your playlist "
381 "may be missing some entries\n" 389 "may be missing some entries\n"
382 "the next time you start it." ) 390 "the next time you start it." )
383 ); 391 );
384 } 392 }
385 } 393 }
386 noOfFiles++; 394 noOfFiles++;
387 } 395 }
388 } 396 }
389 while ( d->selectedFiles->next() ); 397 while ( d->selectedFiles->next() );
390 cfg.writeEntry("NumberOfFiles", noOfFiles ); 398 cfg.writeEntry("NumberOfFiles", noOfFiles );
391} 399}
392 400
393 401
394void PlayListWidget::addToSelection( const DocLnk& lnk ) { 402void PlayListWidget::addToSelection( const DocLnk& lnk ) {
395 d->setDocumentUsed = false; 403 d->setDocumentUsed = false;
396 if ( mediaPlayerState->playlist() ) { 404 if ( mediaPlayerState->playlist() ) {
397 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) 405 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" )
398 d->selectedFiles->addToSelection( lnk ); 406 d->selectedFiles->addToSelection( lnk );
399 } 407 }
400 else 408 else
401 mediaPlayerState->setPlaying( true); 409 mediaPlayerState->setPlaying( true);
402} 410}
403 411
404 412
405void PlayListWidget::clearList() { 413void PlayListWidget::clearList() {
406 while ( first() ) 414 while ( first() )
407 d->selectedFiles->removeSelected(); 415 d->selectedFiles->removeSelected();
408} 416}
409 417
410 418
411void PlayListWidget::addAllToList() { 419void PlayListWidget::addAllToList() {
412 DocLnkSet filesAll; 420 DocLnkSet filesAll;
413 Global::findDocuments(&filesAll, "video/*;audio/*"); 421 Global::findDocuments(&filesAll, "video/*;audio/*");
414 QListIterator<DocLnk> Adit( filesAll.children() ); 422 QListIterator<DocLnk> Adit( filesAll.children() );
415 for ( ; Adit.current(); ++Adit ) 423 for ( ; Adit.current(); ++Adit )
416 if(QFileInfo(Adit.current()->file()).exists()) 424 if(QFileInfo(Adit.current()->file()).exists())
417 d->selectedFiles->addToSelection( **Adit ); 425 d->selectedFiles->addToSelection( **Adit );
418} 426}
419 427
420 428
421void PlayListWidget::addAllMusicToList() { 429void PlayListWidget::addAllMusicToList() {
422 QListIterator<DocLnk> dit( files.children() ); 430 QListIterator<DocLnk> dit( files.children() );
423 for ( ; dit.current(); ++dit ) 431 for ( ; dit.current(); ++dit )
424 if(QFileInfo(dit.current()->file()).exists()) 432 if(QFileInfo(dit.current()->file()).exists())
425 d->selectedFiles->addToSelection( **dit ); 433 d->selectedFiles->addToSelection( **dit );
426} 434}
427 435
428 436
429void PlayListWidget::addAllVideoToList() { 437void PlayListWidget::addAllVideoToList() {
430 QListIterator<DocLnk> dit( vFiles.children() ); 438 QListIterator<DocLnk> dit( vFiles.children() );
431 for ( ; dit.current(); ++dit ) 439 for ( ; dit.current(); ++dit )
432 if(QFileInfo( dit.current()->file()).exists()) 440 if(QFileInfo( dit.current()->file()).exists())
433 d->selectedFiles->addToSelection( **dit ); 441 d->selectedFiles->addToSelection( **dit );
434} 442}
435 443
436 444
437void PlayListWidget::setDocument(const QString& fileref) { 445void PlayListWidget::setDocument(const QString& fileref) {
438 qDebug(fileref); 446 qDebug(fileref);
439 fromSetDocument = TRUE; 447 fromSetDocument = TRUE;
440 if ( fileref.isNull() ) { 448 if ( fileref.isNull() ) {
441 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); 449 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) );
442 return; 450 return;
443 } 451 }
444// qDebug("setDocument "+fileref); 452// qDebug("setDocument "+fileref);
445 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u 453 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u
446 readm3u( fileref); 454 readm3u( fileref);
447 } 455 }
448 else if(fileref.find("pls",0,TRUE) != -1) { //is pls 456 else if(fileref.find("pls",0,TRUE) != -1) { //is pls
449 readPls( fileref); 457 readPls( fileref);
450 } 458 }
451 else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist 459 else if(fileref.find("playlist",0,TRUE) != -1) {//is playlist
452 clearList(); 460 clearList();
453 loadList(DocLnk(fileref)); 461 loadList(DocLnk(fileref));
454 d->selectedFiles->first(); 462 d->selectedFiles->first();
455 } else { 463 } else {
456 clearList(); 464 clearList();
457 addToSelection( DocLnk( fileref ) ); 465 addToSelection( DocLnk( fileref ) );
458 d->setDocumentUsed = TRUE; 466 d->setDocumentUsed = TRUE;
459 mediaPlayerState->setPlaying( FALSE ); 467 mediaPlayerState->setPlaying( FALSE );
460 qApp->processEvents(); 468 qApp->processEvents();
461 mediaPlayerState->setPlaying( TRUE ); 469 mediaPlayerState->setPlaying( TRUE );
462 qApp->processEvents(); 470 qApp->processEvents();
463 setCaption(tr("OpiePlayer")); 471 setCaption(tr("OpiePlayer"));
464 } 472 }
465} 473}
466 474
467 475
468void PlayListWidget::setActiveWindow() { 476void PlayListWidget::setActiveWindow() {
469 qDebug("SETTING active window"); 477 qDebug("SETTING active window");
470 478
471 // When we get raised we need to ensure that it switches views 479 // When we get raised we need to ensure that it switches views
472 char origView = mediaPlayerState->view(); 480 char origView = mediaPlayerState->view();
473 mediaPlayerState->setView( 'l' ); // invalidate 481 mediaPlayerState->setView( 'l' ); // invalidate
474 mediaPlayerState->setView( origView ); // now switch back 482 mediaPlayerState->setView( origView ); // now switch back
475} 483}
476 484
477 485
478void PlayListWidget::useSelectedDocument() { 486void PlayListWidget::useSelectedDocument() {
479 d->setDocumentUsed = FALSE; 487 d->setDocumentUsed = FALSE;
480} 488}
481 489
482 490
483const DocLnk *PlayListWidget::current() { // this is fugly 491const DocLnk *PlayListWidget::current() { // this is fugly
484 492
485// if( fromSetDocument) { 493// if( fromSetDocument) {
486// qDebug("from setDoc"); 494// qDebug("from setDoc");
487// DocLnkSet files; 495// DocLnkSet files;
488// Global::findDocuments(&files, "video/*;audio/*"); 496// Global::findDocuments(&files, "video/*;audio/*");
489// QListIterator<DocLnk> dit( files.children() ); 497// QListIterator<DocLnk> dit( files.children() );
490// for ( ; dit.current(); ++dit ) { 498// for ( ; dit.current(); ++dit ) {
491// if(dit.current()->linkFile() == setDocFileRef) { 499// if(dit.current()->linkFile() == setDocFileRef) {
492// qDebug(setDocFileRef); 500// qDebug(setDocFileRef);
493// return dit; 501// return dit;
494// } 502// }
495// } 503// }
496// } else 504// } else
497 505
498 qDebug("current"); 506 qDebug("current");
499 507
500 switch (tabWidget->currentPageIndex()) { 508 switch (tabWidget->currentPageIndex()) {
501 case 0: //playlist 509 case 0: //playlist
502 { 510 {
503 qDebug("playlist"); 511 qDebug("playlist");
504 if ( mediaPlayerState->playlist() ) { 512 if ( mediaPlayerState->playlist() ) {
505 return d->selectedFiles->current(); 513 return d->selectedFiles->current();
506 } 514 }
507 else if ( d->setDocumentUsed && d->current ) { 515 else if ( d->setDocumentUsed && d->current ) {
508 return d->current; 516 return d->current;
509 } else { 517 } else {
510 return &(d->files->selectedDocument()); 518 return &(d->files->selectedDocument());
511 } 519 }
512 } 520 }
513 break; 521 break;
514 case 1://audio 522 case 1://audio
515 { 523 {
516 qDebug("audioView"); 524 qDebug("audioView");
517 QListIterator<DocLnk> dit( files.children() ); 525 QListIterator<DocLnk> dit( files.children() );
518 for ( ; dit.current(); ++dit ) { 526 for ( ; dit.current(); ++dit ) {
519 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { 527 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) {
520 qDebug("here"); 528 qDebug("here");
521 insanityBool=TRUE; 529 insanityBool=TRUE;
522 return dit; 530 return dit;
523 } 531 }
524 } 532 }
525 } 533 }
526 break; 534 break;
527 case 2: // video 535 case 2: // video
528 { 536 {
529 qDebug("videoView"); 537 qDebug("videoView");
530 QListIterator<DocLnk> Vdit( vFiles.children() ); 538 QListIterator<DocLnk> Vdit( vFiles.children() );
531 for ( ; Vdit.current(); ++Vdit ) { 539 for ( ; Vdit.current(); ++Vdit ) {
532 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { 540 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) {
533 insanityBool=TRUE; 541 insanityBool=TRUE;
534 return Vdit; 542 return Vdit;
535 } 543 }
536 } 544 }
537 } 545 }
538 break; 546 break;
539 }; 547 };
540 return 0; 548 return 0;
541} 549}
542 550
543bool PlayListWidget::prev() { 551bool PlayListWidget::prev() {
544 if ( mediaPlayerState->playlist() ) { 552 if ( mediaPlayerState->playlist() ) {
545 if ( mediaPlayerState->shuffled() ) { 553 if ( mediaPlayerState->shuffled() ) {
546 const DocLnk *cur = current(); 554 const DocLnk *cur = current();
547 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 555 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
548 for ( int i = 0; i < j; i++ ) { 556 for ( int i = 0; i < j; i++ ) {
549 if ( !d->selectedFiles->next() ) 557 if ( !d->selectedFiles->next() )
550 d->selectedFiles->first(); 558 d->selectedFiles->first();
551 } 559 }
552 if ( cur == current() ) 560 if ( cur == current() )
553 if ( !d->selectedFiles->next() ) 561 if ( !d->selectedFiles->next() )
554 d->selectedFiles->first(); 562 d->selectedFiles->first();
555 return TRUE; 563 return TRUE;
556 } else { 564 } else {
557 if ( !d->selectedFiles->prev() ) { 565 if ( !d->selectedFiles->prev() ) {
558 if ( mediaPlayerState->looping() ) { 566 if ( mediaPlayerState->looping() ) {
559 return d->selectedFiles->last(); 567 return d->selectedFiles->last();
560 } else { 568 } else {
561 return FALSE; 569 return FALSE;
562 } 570 }
563 } 571 }
564 return TRUE; 572 return TRUE;
565 } 573 }
566 } else { 574 } else {
567 return mediaPlayerState->looping(); 575 return mediaPlayerState->looping();
568 } 576 }
569} 577}
570 578
571 579
572bool PlayListWidget::next() { 580bool PlayListWidget::next() {
573 if ( mediaPlayerState->playlist() ) { 581 if ( mediaPlayerState->playlist() ) {
574 if ( mediaPlayerState->shuffled() ) { 582 if ( mediaPlayerState->shuffled() ) {
575 return prev(); 583 return prev();
576 } else { 584 } else {
577 if ( !d->selectedFiles->next() ) { 585 if ( !d->selectedFiles->next() ) {
578 if ( mediaPlayerState->looping() ) { 586 if ( mediaPlayerState->looping() ) {
579 return d->selectedFiles->first(); 587 return d->selectedFiles->first();
580 } else { 588 } else {
581 return FALSE; 589 return FALSE;
582 } 590 }
583 } 591 }
584 return TRUE; 592 return TRUE;
585 } 593 }
586 } else { 594 } else {
587 return mediaPlayerState->looping(); 595 return mediaPlayerState->looping();
588 } 596 }
589} 597}
590 598
591 599
592bool PlayListWidget::first() { 600bool PlayListWidget::first() {
593 if ( mediaPlayerState->playlist() ) 601 if ( mediaPlayerState->playlist() )
594 return d->selectedFiles->first(); 602 return d->selectedFiles->first();
595 else 603 else
596 return mediaPlayerState->looping(); 604 return mediaPlayerState->looping();
597} 605}
598 606
599 607
600bool PlayListWidget::last() { 608bool PlayListWidget::last() {
601 if ( mediaPlayerState->playlist() ) 609 if ( mediaPlayerState->playlist() )
602 return d->selectedFiles->last(); 610 return d->selectedFiles->last();
603 else 611 else
604 return mediaPlayerState->looping(); 612 return mediaPlayerState->looping();
605} 613}
606 614
607 615
608void PlayListWidget::saveList() { 616void PlayListWidget::saveList() {
609 writem3u(); 617 writem3u();
610} 618}
611 619
612void PlayListWidget::loadList( const DocLnk & lnk) { 620void PlayListWidget::loadList( const DocLnk & lnk) {
613 QString name = lnk.name(); 621 QString name = lnk.name();
614// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name); 622// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<currentList is "+name);
615 623
616 if( name.length()>0) { 624 if( name.length()>0) {
617 setCaption("OpiePlayer: "+name); 625 setCaption("OpiePlayer: "+name);
618// qDebug("<<<<<<<<<<<<load list "+ lnk.file()); 626// qDebug("<<<<<<<<<<<<load list "+ lnk.file());
619 clearList(); 627 clearList();
620 readm3u(lnk.file()); 628 readm3u(lnk.file());
621 tabWidget->setCurrentPage(0); 629 tabWidget->setCurrentPage(0);
622 } 630 }
623} 631}
624 632
625void PlayListWidget::setPlaylist( bool shown ) { 633void PlayListWidget::setPlaylist( bool shown ) {
626 if ( shown ) 634 if ( shown )
627 d->playListFrame->show(); 635 d->playListFrame->show();
628 else 636 else
629 d->playListFrame->hide(); 637 d->playListFrame->hide();
630} 638}
631 639
632void PlayListWidget::setView( char view ) { 640void PlayListWidget::setView( char view ) {
633 if ( view == 'l' ) 641 if ( view == 'l' )
634 showMaximized(); 642 showMaximized();
635 else 643 else
636 hide(); 644 hide();
637} 645}
638 646
639void PlayListWidget::addSelected() { 647void PlayListWidget::addSelected() {
640 648
641 Config cfg( "OpiePlayer" ); 649 Config cfg( "OpiePlayer" );
642 cfg.setGroup("PlayList"); 650 cfg.setGroup("PlayList");
643 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 651 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
644// int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 652// int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
645 653
646 switch (tabWidget->currentPageIndex()) { 654 switch (tabWidget->currentPageIndex()) {
647 case 0: //playlist 655 case 0: //playlist
648 break; 656 break;
649 case 1: { //audio 657 case 1: { //audio
650// QString entryName; 658// QString entryName;
651// entryName.sprintf( "File%i", i + 1 ); 659// entryName.sprintf( "File%i", i + 1 );
652// QString linkFile = cfg.readEntry( entryName ); 660// QString linkFile = cfg.readEntry( entryName );
653 QListViewItemIterator it( audioView ); 661 QListViewItemIterator it( audioView );
654 // iterate through all items of the listview 662 // iterate through all items of the listview
655 for ( ; it.current(); ++it ) { 663 for ( ; it.current(); ++it ) {
656 if ( it.current()->isSelected() ) { 664 if ( it.current()->isSelected() ) {
657 QListIterator<DocLnk> dit( files.children() ); 665 QListIterator<DocLnk> dit( files.children() );
658 for ( ; dit.current(); ++dit ) { 666 for ( ; dit.current(); ++dit ) {
659 if( dit.current()->name() == it.current()->text(0) ) { 667 if( dit.current()->name() == it.current()->text(0) ) {
660 d->selectedFiles->addToSelection( **dit ); 668 d->selectedFiles->addToSelection( **dit );
661 } 669 }
662 } 670 }
663 audioView->setSelected( it.current(),FALSE); 671 audioView->setSelected( it.current(),FALSE);
664 } 672 }
665 } 673 }
666 tabWidget->setCurrentPage(0); 674 tabWidget->setCurrentPage(0);
667 } 675 }
668 break; 676 break;
669 case 2: { // video 677 case 2: { // video
670 QListViewItemIterator it( videoView ); 678 QListViewItemIterator it( videoView );
671 // iterate through all items of the listview 679 // iterate through all items of the listview
672 for ( ; it.current(); ++it ) { 680 for ( ; it.current(); ++it ) {
673 if ( it.current()->isSelected() ) { 681 if ( it.current()->isSelected() ) {
674 QListIterator<DocLnk> dit( vFiles.children() ); 682 QListIterator<DocLnk> dit( vFiles.children() );
675 for ( ; dit.current(); ++dit ) { 683 for ( ; dit.current(); ++dit ) {
676 if( dit.current()->name() == it.current()->text(0) ) { 684 if( dit.current()->name() == it.current()->text(0) ) {
677 d->selectedFiles->addToSelection( **dit ); 685 d->selectedFiles->addToSelection( **dit );
678 } 686 }
679 } 687 }
680 688
681 videoView->setSelected( it.current(),FALSE); 689 videoView->setSelected( it.current(),FALSE);
682 } 690 }
683 } 691 }
684// for ( int i = 0; i < noOfFiles; i++ ) { 692// for ( int i = 0; i < noOfFiles; i++ ) {
685// QString entryName; 693// QString entryName;
686// entryName.sprintf( "File%i", i + 1 ); 694// entryName.sprintf( "File%i", i + 1 );
687// QString linkFile = cfg.readEntry( entryName ); 695// QString linkFile = cfg.readEntry( entryName );
688// if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { 696// if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) {
689// int result= QMessageBox::warning(this,tr("OpiePlayer"), 697// int result= QMessageBox::warning(this,tr("OpiePlayer"),
690// tr("This is all ready in your playlist.\nContinue?"), 698// tr("This is all ready in your playlist.\nContinue?"),
691// tr("Yes"),tr("No"),0,0,1); 699// tr("Yes"),tr("No"),0,0,1);
692// if (result !=0) 700// if (result !=0)
693// return; 701// return;
694// } 702// }
695// } 703// }
696// addToSelection( videoView->selectedItem() ); 704// addToSelection( videoView->selectedItem() );
697 tabWidget->setCurrentPage(0); 705 tabWidget->setCurrentPage(0);
698 } 706 }
699 break; 707 break;
700 }; 708 };
701} 709}
702 710
703void PlayListWidget::removeSelected() { 711void PlayListWidget::removeSelected() {
704 d->selectedFiles->removeSelected( ); 712 d->selectedFiles->removeSelected( );
705} 713}
706 714
707void PlayListWidget::playIt( QListViewItem *) { 715void PlayListWidget::playIt( QListViewItem *) {
708// d->setDocumentUsed = FALSE; 716// d->setDocumentUsed = FALSE;
709// mediaPlayerState->curPosition =0; 717// mediaPlayerState->curPosition =0;
710 qDebug("playIt"); 718 qDebug("playIt");
711 mediaPlayerState->setPlaying(FALSE); 719 mediaPlayerState->setPlaying(FALSE);
712 mediaPlayerState->setPlaying(TRUE); 720 mediaPlayerState->setPlaying(TRUE);
713 d->selectedFiles->unSelect(); 721 d->selectedFiles->unSelect();
714} 722}
715 723
716void PlayListWidget::addToSelection( QListViewItem *it) { 724void PlayListWidget::addToSelection( QListViewItem *it) {
717 d->setDocumentUsed = FALSE; 725 d->setDocumentUsed = FALSE;
718 726
719 if(it) { 727 if(it) {
720 switch (tabWidget->currentPageIndex()) { 728 switch (tabWidget->currentPageIndex()) {
721 case 1: { 729 case 1: {
722 QListIterator<DocLnk> dit( files.children() ); 730 QListIterator<DocLnk> dit( files.children() );
723 for ( ; dit.current(); ++dit ) { 731 for ( ; dit.current(); ++dit ) {
724 if( dit.current()->name() == it->text(0)) { 732 if( dit.current()->name() == it->text(0)) {
725 d->selectedFiles->addToSelection( **dit ); 733 d->selectedFiles->addToSelection( **dit );
726 } 734 }
727 } 735 }
728 } 736 }
729 break; 737 break;
730 case 2: { 738 case 2: {
731 QListIterator<DocLnk> dit( vFiles.children() ); 739 QListIterator<DocLnk> dit( vFiles.children() );
732 for ( ; dit.current(); ++dit ) { 740 for ( ; dit.current(); ++dit ) {
733 if( dit.current()->name() == it->text(0)) { 741 if( dit.current()->name() == it->text(0)) {
734 d->selectedFiles->addToSelection( **dit ); 742 d->selectedFiles->addToSelection( **dit );
735 } 743 }
736 } 744 }
737 } 745 }
738 break; 746 break;
739 case 0: 747 case 0:
740 break; 748 break;
741 }; 749 };
742 tabWidget->setCurrentPage(0); 750 tabWidget->setCurrentPage(0);
743 } 751 }
744} 752}
745 753
746void PlayListWidget::tabChanged(QWidget *) { 754void PlayListWidget::tabChanged(QWidget *) {
747 755
748 switch ( tabWidget->currentPageIndex()) { 756 switch ( tabWidget->currentPageIndex()) {
749 case 0: 757 case 0:
750 { 758 {
751 if( !tbDeletePlaylist->isHidden()) 759 if( !tbDeletePlaylist->isHidden())
752 tbDeletePlaylist->hide(); 760 tbDeletePlaylist->hide();
753 d->tbRemoveFromList->setEnabled(TRUE); 761 d->tbRemoveFromList->setEnabled(TRUE);
754 d->tbAddToList->setEnabled(FALSE); 762 d->tbAddToList->setEnabled(FALSE);
755 } 763 }
756 break; 764 break;
757 case 1: 765 case 1:
758 { 766 {
759 audioView->clear(); 767 audioView->clear();
760 populateAudioView(); 768 populateAudioView();
761 769
762 if( !tbDeletePlaylist->isHidden()) 770 if( !tbDeletePlaylist->isHidden())
763 tbDeletePlaylist->hide(); 771 tbDeletePlaylist->hide();
764 d->tbRemoveFromList->setEnabled(FALSE); 772 d->tbRemoveFromList->setEnabled(FALSE);
765 d->tbAddToList->setEnabled(TRUE); 773 d->tbAddToList->setEnabled(TRUE);
766 } 774 }
767 break; 775 break;
768 case 2: 776 case 2:
769 { 777 {
770 videoView->clear(); 778 videoView->clear();
771 populateVideoView(); 779 populateVideoView();
772 if( !tbDeletePlaylist->isHidden()) 780 if( !tbDeletePlaylist->isHidden())
773 tbDeletePlaylist->hide(); 781 tbDeletePlaylist->hide();
774 d->tbRemoveFromList->setEnabled(FALSE); 782 d->tbRemoveFromList->setEnabled(FALSE);
775 d->tbAddToList->setEnabled(TRUE); 783 d->tbAddToList->setEnabled(TRUE);
776 } 784 }
777 break; 785 break;
778 case 3: 786 case 3:
779 { 787 {
780 if( tbDeletePlaylist->isHidden()) 788 if( tbDeletePlaylist->isHidden())
781 tbDeletePlaylist->show(); 789 tbDeletePlaylist->show();
782 playLists->reread(); 790 playLists->reread();
783 } 791 }
784 break; 792 break;
785 }; 793 };
786} 794}
787 795
788void PlayListWidget::btnPlay(bool b) { 796void PlayListWidget::btnPlay(bool b) {
789 qDebug("<<<<<<<<<<<<<<<BtnPlay"); 797 qDebug("<<<<<<<<<<<<<<<BtnPlay");
790// mediaPlayerState->setPlaying(b); 798// mediaPlayerState->setPlaying(b);
791 switch ( tabWidget->currentPageIndex()) { 799 switch ( tabWidget->currentPageIndex()) {
792 case 0: 800 case 0:
793 { 801 {
794 qDebug("1"); 802 qDebug("1");
795// if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1 803// if( d->selectedFiles->current()->file().find(" ",0,TRUE) != -1
796// if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) { 804// if( d->selectedFiles->current()->file().find("%20",0,TRUE) != -1) {
797// QMessageBox::message("Note","You are trying to play\na malformed url."); 805// QMessageBox::message("Note","You are trying to play\na malformed url.");
798// } else { 806// } else {
799 mediaPlayerState->setPlaying(b); 807 mediaPlayerState->setPlaying(b);
800 insanityBool=FALSE; 808 insanityBool=FALSE;
801 qDebug("insanity"); 809 qDebug("insanity");
802// } 810// }
803 } 811 }
804 break; 812 break;
805 case 1: 813 case 1:
806 { 814 {
807 qDebug("2"); 815 qDebug("2");
808 addToSelection( audioView->currentItem() ); 816 addToSelection( audioView->currentItem() );
809 mediaPlayerState->setPlaying(b); 817 mediaPlayerState->setPlaying(b);
810 d->selectedFiles->removeSelected( ); 818 d->selectedFiles->removeSelected( );
811 tabWidget->setCurrentPage(1); 819 tabWidget->setCurrentPage(1);
812 d->selectedFiles->unSelect(); 820 d->selectedFiles->unSelect();
813 insanityBool=FALSE; 821 insanityBool=FALSE;
814 }// audioView->clearSelection(); 822 }// audioView->clearSelection();
815 break; 823 break;
816 case 2: 824 case 2:
817 { 825 {
818 qDebug("3"); 826 qDebug("3");
819 827
820 addToSelection( videoView->currentItem() ); 828 addToSelection( videoView->currentItem() );
821 mediaPlayerState->setPlaying(b); 829 mediaPlayerState->setPlaying(b);
822 qApp->processEvents(); 830 qApp->processEvents();
823 d->selectedFiles->removeSelected( ); 831 d->selectedFiles->removeSelected( );
824 tabWidget->setCurrentPage(2); 832 tabWidget->setCurrentPage(2);
825 d->selectedFiles->unSelect(); 833 d->selectedFiles->unSelect();
826 insanityBool=FALSE; 834 insanityBool=FALSE;
827 }// videoView->clearSelection(); 835 }// videoView->clearSelection();
828 break; 836 break;
829 }; 837 };
830 838
831} 839}
832 840
833void PlayListWidget::deletePlaylist() { 841void PlayListWidget::deletePlaylist() {
834 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 842 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
835 (tr("You really want to delete\nthis playlist?")), 843 (tr("You really want to delete\nthis playlist?")),
836 (tr("Yes")), (tr("No")), 0 )){ 844 (tr("Yes")), (tr("No")), 0 )){
837 case 0: // Yes clicked, 845 case 0: // Yes clicked,
838 QFile().remove(playLists->selectedDocument().file()); 846 QFile().remove(playLists->selectedDocument().file());
839 QFile().remove(playLists->selectedDocument().linkFile()); 847 QFile().remove(playLists->selectedDocument().linkFile());
840 playLists->reread(); 848 playLists->reread();
841 break; 849 break;
842 case 1: // Cancel 850 case 1: // Cancel
843 break; 851 break;
844 }; 852 };
845} 853}
846 854
847void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int ) 855void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint&, int )
848{ 856{
849 switch (mouse) { 857 switch (mouse) {
850 case 1: 858 case 1:
851 break; 859 break;
852 case 2:{ 860 case 2:{
853 861
854 QPopupMenu m; 862 QPopupMenu m;
855 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 863 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
856 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 864 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
857 m.insertSeparator(); 865 m.insertSeparator();
858 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() ) 866 if( QFile(QPEApplication::qpeDir()+"lib/libopie.so").exists() )
859 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 867 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
860 868
861 m.exec( QCursor::pos() ); 869 m.exec( QCursor::pos() );
862 } 870 }
863 break; 871 break;
864 }; 872 };
865} 873}
866 874
867void PlayListWidget::playSelected() 875void PlayListWidget::playSelected()
868{ 876{
869 qDebug("playSelected"); 877 qDebug("playSelected");
870 btnPlay( true); 878 btnPlay( true);
871// d->selectedFiles->unSelect(); 879// d->selectedFiles->unSelect();
872} 880}
873 881
874void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int) 882void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint&, int)
875{ 883{
876 switch (mouse) { 884 switch (mouse) {
877 case 1: 885 case 1:
878 886
879 break; 887 break;
880 case 2:{ 888 case 2:{
881 QPopupMenu m; 889 QPopupMenu m;
882 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 890 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
883 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 891 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
884// m.insertSeparator(); 892// m.insertSeparator();
885// m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 893// m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
886 m.exec( QCursor::pos() ); 894 m.exec( QCursor::pos() );
887 } 895 }
888 break; 896 break;
889 }; 897 };
890 898
891} 899}
892 900
893void PlayListWidget::listDelete() { 901void PlayListWidget::listDelete() {
894 Config cfg( "OpiePlayer" ); 902 Config cfg( "OpiePlayer" );
895 cfg.setGroup("PlayList"); 903 cfg.setGroup("PlayList");
896 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 904 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
897 QString file; 905 QString file;
898// int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 906// int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
899 switch ( tabWidget->currentPageIndex()) { 907 switch ( tabWidget->currentPageIndex()) {
900 case 0: 908 case 0:
901 break; 909 break;
902 case 1: 910 case 1:
903 { 911 {
904 file = audioView->currentItem()->text(0); 912 file = audioView->currentItem()->text(0);
905 QListIterator<DocLnk> Pdit( files.children() ); 913 QListIterator<DocLnk> Pdit( files.children() );
906 for ( ; Pdit.current(); ++Pdit ) { 914 for ( ; Pdit.current(); ++Pdit ) {
907 if( Pdit.current()->name() == file) { 915 if( Pdit.current()->name() == file) {
908 LnkProperties prop( Pdit.current() ); 916 LnkProperties prop( Pdit.current() );
909 prop.showMaximized(); 917 prop.showMaximized();
910 prop.exec(); 918 prop.exec();
911 } 919 }
912 } 920 }
913 populateAudioView(); 921 populateAudioView();
914 } 922 }
915 break; 923 break;
916 case 2: 924 case 2:
917 { 925 {
918// file = videoView->selectedItem()->text(0); 926// file = videoView->selectedItem()->text(0);
919// for ( int i = 0; i < noOfFiles; i++ ) { 927// for ( int i = 0; i < noOfFiles; i++ ) {
920// QString entryName; 928// QString entryName;
921// entryName.sprintf( "File%i", i + 1 ); 929// entryName.sprintf( "File%i", i + 1 );
922// QString linkFile = cfg.readEntry( entryName ); 930// QString linkFile = cfg.readEntry( entryName );
923// AppLnk lnk( AppLnk(linkFile)); 931// AppLnk lnk( AppLnk(linkFile));
924// if( lnk.name() == file ) { 932// if( lnk.name() == file ) {
925// LnkProperties prop( &lnk); 933// LnkProperties prop( &lnk);
926// // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 934// // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
927// prop.showMaximized(); 935// prop.showMaximized();
928// prop.exec(); 936// prop.exec();
929// } 937// }
930// } 938// }
931 } 939 }
932 break; 940 break;
933 }; 941 };
934} 942}
935 943
936void PlayListWidget::scanForAudio() { 944void PlayListWidget::scanForAudio() {
937// qDebug("scan for audio"); 945// qDebug("scan for audio");
938 files.detachChildren(); 946 files.detachChildren();
939 QListIterator<DocLnk> sdit( files.children() ); 947 QListIterator<DocLnk> sdit( files.children() );
940 for ( ; sdit.current(); ++sdit ) { 948 for ( ; sdit.current(); ++sdit ) {
941 delete sdit.current(); 949 delete sdit.current();
942 } 950 }
943 Global::findDocuments( &files, audioMimes); 951 Global::findDocuments( &files, audioMimes);
944 audioScan = true; 952 audioScan = true;
945} 953}
946void PlayListWidget::scanForVideo() { 954void PlayListWidget::scanForVideo() {
947// qDebug("scan for video"); 955// qDebug("scan for video");
948 vFiles.detachChildren(); 956 vFiles.detachChildren();
949 QListIterator<DocLnk> sdit( vFiles.children() ); 957 QListIterator<DocLnk> sdit( vFiles.children() );
950 for ( ; sdit.current(); ++sdit ) { 958 for ( ; sdit.current(); ++sdit ) {
951 delete sdit.current(); 959 delete sdit.current();
952 } 960 }
953 Global::findDocuments(&vFiles, "video/*"); 961 Global::findDocuments(&vFiles, "video/*");
954 videoScan = true; 962 videoScan = true;
955} 963}
956 964
957void PlayListWidget::populateAudioView() { 965void PlayListWidget::populateAudioView() {
958 966
959 audioView->clear(); 967 audioView->clear();
960 StorageInfo storageInfo; 968 StorageInfo storageInfo;
961 const QList<FileSystem> &fs = storageInfo.fileSystems(); 969 const QList<FileSystem> &fs = storageInfo.fileSystems();
962 if(!audioScan) scanForAudio(); 970 if(!audioScan) scanForAudio();
963 971
964 QListIterator<DocLnk> dit( files.children() ); 972 QListIterator<DocLnk> dit( files.children() );
965 QListIterator<FileSystem> it ( fs ); 973 QListIterator<FileSystem> it ( fs );
966 974
967 QString storage; 975 QString storage;
968 for ( ; dit.current(); ++dit ) { 976 for ( ; dit.current(); ++dit ) {
969 for( ; it.current(); ++it ){ 977 for( ; it.current(); ++it ){
970 const QString name = (*it)->name(); 978 const QString name = (*it)->name();
971 const QString path = (*it)->path(); 979 const QString path = (*it)->path();
972 if(dit.current()->file().find(path) != -1 ) storage=name; 980 if(dit.current()->file().find(path) != -1 ) storage=name;
973 } 981 }
974 982
975 QListViewItem * newItem; 983 QListViewItem * newItem;
976 if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { 984 if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) {
977 long size; 985 long size;
978 if( dit.current()->file().left(4) == "http" ) 986 if( dit.current()->file().left(4) == "http" )
979 size=0; 987 size=0;
980 else 988 else
981 size = QFile( dit.current()->file() ).size(); 989 size = QFile( dit.current()->file() ).size();
982// qDebug(dit.current()->name()); 990// qDebug(dit.current()->name());
983 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), 991 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
984 QString::number(size ), storage); 992 QString::number(size ), storage);
985 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); 993 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" ));
986 } 994 }
987 } 995 }
988 996
989} 997}
990 998
991void PlayListWidget::populateVideoView() { 999void PlayListWidget::populateVideoView() {
992 videoView->clear(); 1000 videoView->clear();
993 StorageInfo storageInfo; 1001 StorageInfo storageInfo;
994 const QList<FileSystem> &fs = storageInfo.fileSystems(); 1002 const QList<FileSystem> &fs = storageInfo.fileSystems();
995 1003
996 if(!videoScan ) scanForVideo(); 1004 if(!videoScan ) scanForVideo();
997 1005
998 QListIterator<DocLnk> Vdit( vFiles.children() ); 1006 QListIterator<DocLnk> Vdit( vFiles.children() );
999 QListIterator<FileSystem> it ( fs ); 1007 QListIterator<FileSystem> it ( fs );
1000 videoView->clear(); 1008 videoView->clear();
1001 QString storage; 1009 QString storage;
1002 for ( ; Vdit.current(); ++Vdit ) { 1010 for ( ; Vdit.current(); ++Vdit ) {
1003 for( ; it.current(); ++it ){ 1011 for( ; it.current(); ++it ){
1004 const QString name = (*it)->name(); 1012 const QString name = (*it)->name();
1005 const QString path = (*it)->path(); 1013 const QString path = (*it)->path();
1006 if( Vdit.current()->file().find(path) != -1 ) storage=name; 1014 if( Vdit.current()->file().find(path) != -1 ) storage=name;
1007 } 1015 }
1008 1016
1009 QListViewItem * newItem; 1017 QListViewItem * newItem;
1010 if ( QFile( Vdit.current()->file()).exists() ) { 1018 if ( QFile( Vdit.current()->file()).exists() ) {
1011 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 1019 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
1012 QString::number( QFile( Vdit.current()->file()).size() ), storage); 1020 QString::number( QFile( Vdit.current()->file()).size() ), storage);
1013 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); 1021 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" ));
1014 } 1022 }
1015 } 1023 }
1016} 1024}
1017 1025
1018void PlayListWidget::openFile() { 1026void PlayListWidget::openFile() {
1019 qDebug("<<<<<<<<<OPEN File"); 1027 qDebug("<<<<<<<<<OPEN File");
1020 QString filename, name; 1028 QString filename, name;
1021 InputDialog *fileDlg; 1029 InputDialog *fileDlg;
1022 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 1030 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
1023 fileDlg->exec(); 1031 fileDlg->exec();
1024 if( fileDlg->result() == 1 ) { 1032 if( fileDlg->result() == 1 ) {
1025 filename = fileDlg->text(); 1033 filename = fileDlg->text();
1026 qDebug( "Selected filename is " + filename ); 1034 qDebug( "Selected filename is " + filename );
1027// Om3u *m3uList; 1035// Om3u *m3uList;
1028 DocLnk lnk; 1036 DocLnk lnk;
1029 Config cfg( "OpiePlayer" ); 1037 Config cfg( "OpiePlayer" );
1030 cfg.setGroup("PlayList"); 1038 cfg.setGroup("PlayList");
1031 1039
1032 if(filename.left(4) == "http") { 1040 if(filename.left(4) == "http") {
1033 QString m3uFile, m3uFilePath; 1041 QString m3uFile, m3uFilePath;
1034 if(filename.find(":",8,TRUE) != -1) { //found a port 1042 if(filename.find(":",8,TRUE) != -1) { //found a port
1035 m3uFile = filename.left( filename.find( ":",8,TRUE)); 1043 m3uFile = filename.left( filename.find( ":",8,TRUE));
1036 m3uFile = m3uFile.right( 7); 1044 m3uFile = m3uFile.right( 7);
1037 } else if(filename.left(4) == "http"){ 1045 } else if(filename.left(4) == "http"){
1038 m3uFile=filename; 1046 m3uFile=filename;
1039 m3uFile = m3uFile.right( m3uFile.length() - 7); 1047 m3uFile = m3uFile.right( m3uFile.length() - 7);
1040 } else{ 1048 } else{
1041 m3uFile=filename; 1049 m3uFile=filename;
1042 } 1050 }
1043 1051
1044// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile); 1052// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+ m3uFile);
1045 lnk.setName( filename ); //sets name 1053 lnk.setName( filename ); //sets name
1046 lnk.setFile( filename ); //sets file name 1054 lnk.setFile( filename ); //sets file name
1047 lnk.setIcon("opieplayer2/musicfile"); 1055 lnk.setIcon("opieplayer2/musicfile");
1048 d->selectedFiles->addToSelection( lnk ); 1056 d->selectedFiles->addToSelection( lnk );
1049 writeCurrentM3u(); 1057 writeCurrentM3u();
1050 } 1058 }
1051 else if( filename.right( 3) == "m3u" ) { 1059 else if( filename.right( 3) == "m3u" ) {
1052 readm3u( filename ); 1060 readm3u( filename );
1053 1061
1054 } else if( filename.right(3) == "pls" ) { 1062 } else if( filename.right(3) == "pls" ) {
1055 readPls( filename ); 1063 readPls( filename );
1056 } else { 1064 } else {
1057 d->selectedFiles->addToSelection( DocLnk(filename) ); 1065 d->selectedFiles->addToSelection( DocLnk(filename) );
1058 writeCurrentM3u(); 1066 writeCurrentM3u();
1059 } 1067 }
1060 } 1068 }
1061 1069
1062 if( fileDlg ) { 1070 if( fileDlg ) {
1063 delete fileDlg; 1071 delete fileDlg;
1064 } 1072 }
1065} 1073}
1066 1074
1067 1075
1068/* 1076/*
1069reads m3u and shows files/urls to playlist widget */ 1077reads m3u and shows files/urls to playlist widget */
1070void PlayListWidget::readm3u( const QString &filename ) { 1078void PlayListWidget::readm3u( const QString &filename ) {
1071 qDebug( "read m3u filename " + filename ); 1079 qDebug( "read m3u filename " + filename );
1072 1080
1073 Om3u *m3uList; 1081 Om3u *m3uList;
1074 QString s, name; 1082 QString s, name;
1075 m3uList = new Om3u( filename, IO_ReadOnly ); 1083 m3uList = new Om3u( filename, IO_ReadOnly );
1076 m3uList->readM3u(); 1084 m3uList->readM3u();
1077 DocLnk lnk; 1085 DocLnk lnk;
1078 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 1086 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
1079 s = *it; 1087 s = *it;
1080// qDebug("reading "+ s); 1088// qDebug("reading "+ s);
1081 if(s.left(4)=="http") { 1089 if(s.left(4)=="http") {
1082 lnk.setName( s ); //sets file name 1090 lnk.setName( s ); //sets file name
1083 lnk.setIcon("opieplayer2/musicfile"); 1091 lnk.setIcon("opieplayer2/musicfile");
1084 if(s.right(4) != '.' || s.right(5) != '.') 1092 if(s.right(4) != '.' || s.right(5) != '.')
1085 lnk.setFile( s+"/"); //if url with no extension 1093 lnk.setFile( s+"/"); //if url with no extension
1086 else 1094 else
1087 lnk.setFile( s ); //sets file name 1095 lnk.setFile( s ); //sets file name
1088 1096
1089 } else { 1097 } else {
1090 // if( QFileInfo( s ).exists() ) { 1098 // if( QFileInfo( s ).exists() ) {
1091 lnk.setName( QFileInfo(s).baseName()); 1099 lnk.setName( QFileInfo(s).baseName());
1092 // if(s.right(4) == '.') {//if regular file 1100 // if(s.right(4) == '.') {//if regular file
1093 if(s.left(1) != "/") { 1101 if(s.left(1) != "/") {
1094 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s); 1102 // qDebug("set link "+QFileInfo(filename).dirPath()+"/"+s);
1095 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s); 1103 lnk.setFile( QFileInfo(filename).dirPath()+"/"+s);
1096 lnk.setIcon("SoundPlayer"); 1104 lnk.setIcon("SoundPlayer");
1097 } else { 1105 } else {
1098 // qDebug("set link2 "+s); 1106 // qDebug("set link2 "+s);
1099 lnk.setFile( s); 1107 lnk.setFile( s);
1100 lnk.setIcon("SoundPlayer"); 1108 lnk.setIcon("SoundPlayer");
1101 } 1109 }
1102 } 1110 }
1103 d->selectedFiles->addToSelection( lnk ); 1111 d->selectedFiles->addToSelection( lnk );
1104 } 1112 }
1105 Config config( "OpiePlayer" ); 1113 Config config( "OpiePlayer" );
1106 config.setGroup( "PlayList" ); 1114 config.setGroup( "PlayList" );
1107 1115
1108 config.writeEntry("CurrentPlaylist",filename); 1116 config.writeEntry("CurrentPlaylist",filename);
1109 config.write(); 1117 config.write();
1110 currentPlayList=filename; 1118 currentPlayList=filename;
1111 1119
1112// m3uList->write(); 1120// m3uList->write();
1113 m3uList->close(); 1121 m3uList->close();
1114 if(m3uList) delete m3uList; 1122 if(m3uList) delete m3uList;
1115 1123
1116 d->selectedFiles->setSelectedItem( s); 1124 d->selectedFiles->setSelectedItem( s);
1117 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName()); 1125 setCaption(tr("OpiePlayer: ")+ QFileInfo(filename).baseName());
1118 1126
1119} 1127}
1120 1128
1121/* 1129/*
1122reads pls and adds files/urls to playlist */ 1130reads pls and adds files/urls to playlist */
1123void PlayListWidget::readPls( const QString &filename ) { 1131void PlayListWidget::readPls( const QString &filename ) {
1124 1132
1125 qDebug( "pls filename is " + filename ); 1133 qDebug( "pls filename is " + filename );
1126 Om3u *m3uList; 1134 Om3u *m3uList;
1127 QString s, name; 1135 QString s, name;
1128 m3uList = new Om3u( filename, IO_ReadOnly ); 1136 m3uList = new Om3u( filename, IO_ReadOnly );
1129 m3uList->readPls(); 1137 m3uList->readPls();
1130 1138
1131 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) { 1139 for ( QStringList::ConstIterator it = m3uList->begin(); it != m3uList->end(); ++it ) {
1132 s = *it; 1140 s = *it;
1133 // s.replace( QRegExp( "%20" )," " ); 1141 // s.replace( QRegExp( "%20" )," " );
1134 DocLnk lnk( s ); 1142 DocLnk lnk( s );
1135 QFileInfo f( s ); 1143 QFileInfo f( s );
1136 QString name = f.baseName(); 1144 QString name = f.baseName();
1137 1145
1138 if( name.left( 4 ) == "http" ) { 1146 if( name.left( 4 ) == "http" ) {
1139 name = s.right( s.length() - 7); 1147 name = s.right( s.length() - 7);
1140 } else { 1148 } else {
1141 name = s; 1149 name = s;
1142 } 1150 }
1143 1151
1144 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 1152 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
1145 1153
1146 lnk.setName( name ); 1154 lnk.setName( name );
1147 if( s.at( s.length() - 4) == '.') {// if this is probably a file 1155 if( s.at( s.length() - 4) == '.') {// if this is probably a file
1148 lnk.setFile( s ); 1156 lnk.setFile( s );
1149 } else { //if its a url 1157 } else { //if its a url
1150 if( name.right( 1 ).find( '/' ) == -1) { 1158 if( name.right( 1 ).find( '/' ) == -1) {
1151 s += "/"; 1159 s += "/";
1152 } 1160 }
1153 lnk.setFile( s ); 1161 lnk.setFile( s );
1154 } 1162 }
1155 lnk.setType( "audio/x-mpegurl" ); 1163 lnk.setType( "audio/x-mpegurl" );
1156 1164
1157 lnk.writeLink(); 1165 lnk.writeLink();
1158 d->selectedFiles->addToSelection( lnk ); 1166 d->selectedFiles->addToSelection( lnk );
1159 } 1167 }
1160 1168
1161 m3uList->close(); 1169 m3uList->close();
1162 if(m3uList) delete m3uList; 1170 if(m3uList) delete m3uList;
1163} 1171}
1164 1172
1165/* 1173/*
1166 writes current playlist to current m3u file */ 1174 writes current playlist to current m3u file */
1167void PlayListWidget::writeCurrentM3u() { 1175void PlayListWidget::writeCurrentM3u() {
1168 qDebug("writing to current m3u"); 1176 qDebug("writing to current m3u");
1169 Config cfg( "OpiePlayer" ); 1177 Config cfg( "OpiePlayer" );
1170 cfg.setGroup("PlayList"); 1178 cfg.setGroup("PlayList");
1171 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 1179 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
1172 1180
1173 if( d->selectedFiles->first()) { 1181 if( d->selectedFiles->first()) {
1174 Om3u *m3uList; 1182 Om3u *m3uList;
1175 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate ); 1183 m3uList = new Om3u( currentPlaylist, IO_ReadWrite | IO_Truncate );
1176 1184
1177 do { 1185 do {
1178 qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file()); 1186 qDebug( "writeCurrentM3u " +d->selectedFiles->current()->file());
1179 m3uList->add( d->selectedFiles->current()->file() ); 1187 m3uList->add( d->selectedFiles->current()->file() );
1180 } 1188 }
1181 while ( d->selectedFiles->next() ); 1189 while ( d->selectedFiles->next() );
1182 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" ); 1190 qDebug( "<<<<<<<<<<<<>>>>>>>>>>>>>>>>>" );
1183 m3uList->write(); 1191 m3uList->write();
1184 m3uList->close(); 1192 m3uList->close();
1185 1193
1186 if(m3uList) delete m3uList; 1194 if(m3uList) delete m3uList;
1187 } 1195 }
1188} 1196}
1189 1197
1190 /* 1198 /*
1191 writes current playlist to m3u file */ 1199 writes current playlist to m3u file */
1192void PlayListWidget::writem3u() { 1200void PlayListWidget::writem3u() {
1193 InputDialog *fileDlg; 1201 InputDialog *fileDlg;
1194 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 1202 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
1195 fileDlg->exec(); 1203 fileDlg->exec();
1196 QString name, filename, list; 1204 QString name, filename, list;
1197 Om3u *m3uList; 1205 Om3u *m3uList;
1198 1206
1199 if( fileDlg->result() == 1 ) { 1207 if( fileDlg->result() == 1 ) {
1200 name = fileDlg->text(); 1208 name = fileDlg->text();
1201// qDebug( filename ); 1209// qDebug( filename );
1202 1210
1203 if( name.left( 1) != "/" ) { 1211 if( name.left( 1) != "/" ) {
1204 filename = QPEApplication::documentDir() + "/" + name; 1212 filename = QPEApplication::documentDir() + "/" + name;
1205 } 1213 }
1206 1214
1207 if( name.right( 3 ) != "m3u" ) { 1215 if( name.right( 3 ) != "m3u" ) {
1208 filename = QPEApplication::documentDir() + "/" +name+".m3u"; 1216 filename = QPEApplication::documentDir() + "/" +name+".m3u";
1209 } 1217 }
1210 1218
1211 if( d->selectedFiles->first()) { 1219 if( d->selectedFiles->first()) {
1212 m3uList = new Om3u(filename, IO_ReadWrite); 1220 m3uList = new Om3u(filename, IO_ReadWrite);
1213 1221
1214 do { 1222 do {
1215 m3uList->add( d->selectedFiles->current()->file()); 1223 m3uList->add( d->selectedFiles->current()->file());
1216 } 1224 }
1217 while ( d->selectedFiles->next() ); 1225 while ( d->selectedFiles->next() );
1218 // qDebug( list ); 1226 // qDebug( list );
1219 m3uList->write(); 1227 m3uList->write();
1220 m3uList->close(); 1228 m3uList->close();
1221 if(m3uList) delete m3uList; 1229 if(m3uList) delete m3uList;
1222 1230
1223 if(fileDlg) delete fileDlg; 1231 if(fileDlg) delete fileDlg;
1224 1232
1225 DocLnk lnk; 1233 DocLnk lnk;
1226 lnk.setFile( filename); 1234 lnk.setFile( filename);
1227 lnk.setIcon("opieplayer2/playlist2"); 1235 lnk.setIcon("opieplayer2/playlist2");
1228 lnk.setName( name); //sets file name 1236 lnk.setName( name); //sets file name
1229 1237
1230 // qDebug(filename); 1238 // qDebug(filename);
1231 Config config( "OpiePlayer" ); 1239 Config config( "OpiePlayer" );
1232 config.setGroup( "PlayList" ); 1240 config.setGroup( "PlayList" );
1233 1241
1234 config.writeEntry("CurrentPlaylist",filename); 1242 config.writeEntry("CurrentPlaylist",filename);
1235 currentPlayList=filename; 1243 currentPlayList=filename;
1236 1244
1237 if(!lnk.writeLink()) { 1245 if(!lnk.writeLink()) {
1238 qDebug("Writing doclink did not work"); 1246 qDebug("Writing doclink did not work");
1239 } 1247 }
1240 1248
1241 setCaption(tr("OpiePlayer: ") + name); 1249 setCaption(tr("OpiePlayer: ") + name);
1242 } 1250 }
1243 } 1251 }
1244} 1252}
1245 1253
1246 1254
1247void PlayListWidget::keyReleaseEvent( QKeyEvent *e) 1255void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
1248{ 1256{
1249 switch ( e->key() ) { 1257 switch ( e->key() ) {
1250////////////////////////////// Zaurus keys 1258////////////////////////////// Zaurus keys
1251 case Key_F9: //activity 1259 case Key_F9: //activity
1252// if(audioUI->isHidden()) 1260// if(audioUI->isHidden())
1253// audioUI->showMaximized(); 1261// audioUI->showMaximized();
1254 break; 1262 break;
1255 case Key_F10: //contacts 1263 case Key_F10: //contacts
1256// if( videoUI->isHidden()) 1264// if( videoUI->isHidden())
1257// videoUI->showMaximized(); 1265// videoUI->showMaximized();
1258 break; 1266 break;
1259 case Key_F11: //menu 1267 case Key_F11: //menu
1260 break; 1268 break;
1261 case Key_F12: //home 1269 case Key_F12: //home
1262// doBlank(); 1270// doBlank();
1263 break; 1271 break;
1264 case Key_F13: //mail 1272 case Key_F13: //mail
1265// doUnblank(); 1273// doUnblank();
1266 break; 1274 break;
1267 case Key_Q: //add to playlist 1275 case Key_Q: //add to playlist
1268 qDebug("Add"); 1276 qDebug("Add");
1269 addSelected(); 1277 addSelected();
1270 break; 1278 break;
1271 case Key_R: //remove from playlist 1279 case Key_R: //remove from playlist
1272 removeSelected(); 1280 removeSelected();
1273 break; 1281 break;
1274// case Key_P: //play 1282// case Key_P: //play
1275// qDebug("Play"); 1283// qDebug("Play");
1276// playSelected(); 1284// playSelected();
1277// break; 1285// break;
1278 case Key_Space: 1286 case Key_Space:
1279 qDebug("Play"); 1287 qDebug("Play");
1280// playSelected(); puh 1288// playSelected(); puh
1281 break; 1289 break;
1282 case Key_1: 1290 case Key_1:
1283 tabWidget->setCurrentPage(0); 1291 tabWidget->setCurrentPage(0);
1284 break; 1292 break;
1285 case Key_2: 1293 case Key_2:
1286 tabWidget->setCurrentPage(1); 1294 tabWidget->setCurrentPage(1);
1287 break; 1295 break;
1288 case Key_3: 1296 case Key_3:
1289 tabWidget->setCurrentPage(2); 1297 tabWidget->setCurrentPage(2);
1290 break; 1298 break;
1291 case Key_4: 1299 case Key_4:
1292 tabWidget->setCurrentPage(3); 1300 tabWidget->setCurrentPage(3);
1293 break; 1301 break;
1294 case Key_Down: 1302 case Key_Down:
1295 if ( !d->selectedFiles->next() ) 1303 if ( !d->selectedFiles->next() )
1296 d->selectedFiles->first(); 1304 d->selectedFiles->first();
1297 1305
1298 break; 1306 break;
1299 case Key_Up: 1307 case Key_Up:
1300 if ( !d->selectedFiles->prev() ) 1308 if ( !d->selectedFiles->prev() )
1301 // d->selectedFiles->last(); 1309 // d->selectedFiles->last();
1302 1310
1303 break; 1311 break;
1304 1312
1305 } 1313 }
1306} 1314}
1307 1315
1308void PlayListWidget::keyPressEvent( QKeyEvent *) 1316void PlayListWidget::keyPressEvent( QKeyEvent *)
1309{ 1317{
1310// qDebug("Key press"); 1318// qDebug("Key press");
1311// switch ( e->key() ) { 1319// switch ( e->key() ) {
1312// ////////////////////////////// Zaurus keys 1320// ////////////////////////////// Zaurus keys
1313// case Key_A: //add to playlist 1321// case Key_A: //add to playlist
1314// qDebug("Add"); 1322// qDebug("Add");
1315// addSelected(); 1323// addSelected();
1316// break; 1324// break;
1317// case Key_R: //remove from playlist 1325// case Key_R: //remove from playlist
1318// removeSelected(); 1326// removeSelected();
1319// break; 1327// break;
1320// case Key_P: //play 1328// case Key_P: //play
1321// qDebug("Play"); 1329// qDebug("Play");
1322// playSelected(); 1330// playSelected();
1323// break; 1331// break;
1324// case Key_Space: 1332// case Key_Space:
1325// qDebug("Play"); 1333// qDebug("Play");
1326// playSelected(); 1334// playSelected();
1327// break; 1335// break;
1328// } 1336// }
1329} 1337}
1330 1338
1331void PlayListWidget::doBlank() { 1339void PlayListWidget::doBlank() {
1332 qDebug("do blanking"); 1340 qDebug("do blanking");
1333 fd=open("/dev/fb0",O_RDWR); 1341 fd=open("/dev/fb0",O_RDWR);
1334 if (fd != -1) { 1342 if (fd != -1) {
1335 ioctl(fd,FBIOBLANK,1); 1343 ioctl(fd,FBIOBLANK,1);
1336// close(fd); 1344// close(fd);
1337 } 1345 }
1338} 1346}
1339 1347
1340void PlayListWidget::doUnblank() { 1348void PlayListWidget::doUnblank() {
1341 // this crashes opieplayer with a segfault 1349 // this crashes opieplayer with a segfault
1342// int fd; 1350// int fd;
1343// fd=open("/dev/fb0",O_RDWR); 1351// fd=open("/dev/fb0",O_RDWR);
1344 qDebug("do unblanking"); 1352 qDebug("do unblanking");
1345 if (fd != -1) { 1353 if (fd != -1) {
1346 ioctl(fd,FBIOBLANK,0); 1354 ioctl(fd,FBIOBLANK,0);
1347 close(fd); 1355 close(fd);
1348 } 1356 }
1349 QCopEnvelope h("QPE/System", "setBacklight(int)"); 1357 QCopEnvelope h("QPE/System", "setBacklight(int)");
1350 h <<-3;// v[1]; // -3 Force on 1358 h <<-3;// v[1]; // -3 Force on
1351} 1359}
1352 1360
1361void PlayListWidget::populateSkinsMenu() {
1362 int item = 0;
1363 defaultSkinIndex = 0;
1364 QString skinName;
1365 Config cfg( "OpiePlayer" );
1366 cfg.setGroup("Options" );
1367 QString skin = cfg.readEntry( "Skin", "default" );
1368
1369 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" );
1370 skinsDir.setFilter( QDir::Dirs );
1371 skinsDir.setSorting(QDir::Name );
1372 const QFileInfoList *skinslist = skinsDir.entryInfoList();
1373 QFileInfoListIterator it( *skinslist );
1374 QFileInfo *fi;
1375 while ( ( fi = it.current() ) ) {
1376 skinName = fi->fileName();
1377// qDebug( fi->fileName() );
1378 if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
1379 item = skinsMenu->insertItem( fi->fileName() ) ;
1380 }
1381 if( skinName == "default" ) {
1382 defaultSkinIndex = item;
1383 }
1384 if( skinName == skin ) {
1385 skinsMenu->setItemChecked( item, TRUE );
1386 }
1387 ++it;
1388 }
1389}
1390
1391void PlayListWidget::skinsMenuActivated( int item ) {
1392 for( int i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) {
1393 skinsMenu->setItemChecked( i, FALSE );
1394 }
1395 skinsMenu->setItemChecked( item, TRUE );
1396
1397 Config cfg( "OpiePlayer" );
1398 cfg.setGroup("Options");
1399 cfg.writeEntry("Skin", skinsMenu->text( item ) );
1400}
diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h
index 1be5a15..1118b76 100644
--- a/core/multimedia/opieplayer/playlistwidget.h
+++ b/core/multimedia/opieplayer/playlistwidget.h
@@ -1,128 +1,133 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef PLAY_LIST_WIDGET_H 20#ifndef PLAY_LIST_WIDGET_H
21#define PLAY_LIST_WIDGET_H 21#define PLAY_LIST_WIDGET_H
22 22
23#include <qmainwindow.h> 23#include <qmainwindow.h>
24#include <qpe/applnk.h> 24#include <qpe/applnk.h>
25#include <qtabwidget.h> 25#include <qtabwidget.h>
26#include <qpe/fileselector.h> 26#include <qpe/fileselector.h>
27#include <qpushbutton.h> 27#include <qpushbutton.h>
28 28
29#include "om3u.h" 29#include "om3u.h"
30/* #include <qtimer.h> */ 30/* #include <qtimer.h> */
31 31
32 32
33class PlayListWidgetPrivate; 33class PlayListWidgetPrivate;
34class Config; 34class Config;
35class QListViewItem; 35class QListViewItem;
36class QListView; 36class QListView;
37class QPoint; 37class QPoint;
38class QAction; 38class QAction;
39class QLabel; 39class QLabel;
40class QPopupMenu;
40 41
41class PlayListWidget : public QMainWindow { 42class PlayListWidget : public QMainWindow {
42 Q_OBJECT 43 Q_OBJECT
43public: 44public:
44 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); 45 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 );
45 ~PlayListWidget(); 46 ~PlayListWidget();
46 QTabWidget * tabWidget; 47 QTabWidget * tabWidget;
47 QAction *fullScreenButton, *scaleButton; 48 QAction *fullScreenButton, *scaleButton;
48 DocLnkSet files; 49 DocLnkSet files;
49 DocLnkSet vFiles; 50 DocLnkSet vFiles;
50 QListView *audioView, *videoView, *playlistView; 51 QListView *audioView, *videoView, *playlistView;
51 QLabel *libString; 52 QLabel *libString;
52 bool fromSetDocument; 53 bool fromSetDocument;
53 bool insanityBool; 54 bool insanityBool;
54 QString setDocFileRef, currentPlayList; 55 QString setDocFileRef, currentPlayList;
55 // retrieve the current playlist entry (media file link) 56 // retrieve the current playlist entry (media file link)
56 const DocLnk *current(); 57 const DocLnk *current();
57 void useSelectedDocument(); 58 void useSelectedDocument();
58/* QTimer * menuTimer; */ 59/* QTimer * menuTimer; */
59 FileSelector* playLists; 60 FileSelector* playLists;
60 QPushButton *tbDeletePlaylist; 61 QPushButton *tbDeletePlaylist;
61 int fd, selected; 62 int fd, selected;
62public slots: 63public slots:
63 bool first(); 64 bool first();
64 bool last(); 65 bool last();
65 bool next(); 66 bool next();
66 bool prev(); 67 bool prev();
67/* void setFullScreen(); */ 68/* void setFullScreen(); */
68/* void setScaled(); */ 69/* void setScaled(); */
69protected: 70protected:
71 QPopupMenu *skinsMenu;
70/* void contentsMousePressEvent( QMouseEvent * e ); */ 72/* void contentsMousePressEvent( QMouseEvent * e ); */
71/* void contentsMouseReleaseEvent( QMouseEvent * e ); */ 73/* void contentsMouseReleaseEvent( QMouseEvent * e ); */
72void keyReleaseEvent( QKeyEvent *e); 74void keyReleaseEvent( QKeyEvent *e);
73void keyPressEvent( QKeyEvent *e); 75void keyPressEvent( QKeyEvent *e);
74private: 76private:
77 int defaultSkinIndex;
75 bool audioScan, videoScan; 78 bool audioScan, videoScan;
76 void doBlank(); 79 void doBlank();
77 void doUnblank(); 80 void doUnblank();
78 void readm3u(const QString &); 81 void readm3u(const QString &);
79 void readPls(const QString &); 82 void readPls(const QString &);
80 83
81 84
82 void initializeStates(); 85 void initializeStates();
83 void readConfig( Config& cfg ); 86 void readConfig( Config& cfg );
84 void writeConfig( Config& cfg ) const; 87 void writeConfig( Config& cfg ) const;
85 PlayListWidgetPrivate *d; // Private implementation data 88 PlayListWidgetPrivate *d; // Private implementation data
86 void populateAudioView(); 89 void populateAudioView();
87 void populateVideoView(); 90 void populateVideoView();
88private slots: 91private slots:
89 92
93 void populateSkinsMenu();
94 void skinsMenuActivated(int);
90 void writem3u(); 95 void writem3u();
91 void writeCurrentM3u(); 96 void writeCurrentM3u();
92 void scanForAudio(); 97 void scanForAudio();
93 void scanForVideo(); 98 void scanForVideo();
94 void openFile(); 99 void openFile();
95 void setDocument( const QString& fileref ); 100 void setDocument( const QString& fileref );
96 void addToSelection( const DocLnk& ); // Add a media file to the playlist 101 void addToSelection( const DocLnk& ); // Add a media file to the playlist
97 void addToSelection( QListViewItem* ); // Add a media file to the playlist 102 void addToSelection( QListViewItem* ); // Add a media file to the playlist
98 void setActiveWindow(); // need to handle this to show the right view 103 void setActiveWindow(); // need to handle this to show the right view
99 void setPlaylist( bool ); // Show/Hide the playlist 104 void setPlaylist( bool ); // Show/Hide the playlist
100 void setView( char ); 105 void setView( char );
101 void clearList(); 106 void clearList();
102 void addAllToList(); 107 void addAllToList();
103 void addAllMusicToList(); 108 void addAllMusicToList();
104 void addAllVideoToList(); 109 void addAllVideoToList();
105 void saveList(); // Save the playlist 110 void saveList(); // Save the playlist
106 void loadList( const DocLnk &); // Load a playlist 111 void loadList( const DocLnk &); // Load a playlist
107 void playIt( QListViewItem *); 112 void playIt( QListViewItem *);
108 113
109 void btnPlay(bool); 114 void btnPlay(bool);
110 void deletePlaylist(); 115 void deletePlaylist();
111 void addSelected(); 116 void addSelected();
112 void removeSelected(); 117 void removeSelected();
113 void tabChanged(QWidget*); 118 void tabChanged(QWidget*);
114 void viewPressed( int, QListViewItem *, const QPoint&, int); 119 void viewPressed( int, QListViewItem *, const QPoint&, int);
115 void playlistViewPressed( int, QListViewItem *, const QPoint&, int); 120 void playlistViewPressed( int, QListViewItem *, const QPoint&, int);
116 void playSelected(); 121 void playSelected();
117 void listDelete(); 122 void listDelete();
118 123
119protected slots: 124protected slots:
120/* void cancelMenuTimer(); */ 125/* void cancelMenuTimer(); */
121/* void showFileMenu(); */ 126/* void showFileMenu(); */
122 127
123 128
124}; 129};
125 130
126 131
127#endif // PLAY_LIST_WIDGET_H 132#endif // PLAY_LIST_WIDGET_H
128 133