summaryrefslogtreecommitdiff
Unidiff
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,405 +1,405 @@
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* ) {
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
@@ -4,384 +4,392 @@
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 }
@@ -1161,192 +1169,232 @@ void PlayListWidget::readPls( const QString &filename ) {
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