summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp1
-rw-r--r--noncore/multimedia/opieplayer2/inputDialog.cpp1
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp100
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.h3
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp92
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.h3
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidgetgui.cpp2
7 files changed, 127 insertions, 75 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 040e965..446fa45 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -1,595 +1,596 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include <qpe/qpeapplication.h> 34#include <qpe/qpeapplication.h>
35#include <qpe/resource.h> 35#include <qpe/resource.h>
36#include <qpe/config.h> 36#include <qpe/config.h>
37 37
38#include <qwidget.h> 38#include <qwidget.h>
39#include <qpixmap.h> 39#include <qpixmap.h>
40#include <qbutton.h> 40#include <qbutton.h>
41#include <qpainter.h> 41#include <qpainter.h>
42#include <qframe.h> 42#include <qframe.h>
43#include <qlayout.h> 43#include <qlayout.h>
44 44
45#include <stdlib.h> 45#include <stdlib.h>
46#include <stdio.h> 46#include <stdio.h>
47 47
48#include "audiowidget.h" 48#include "audiowidget.h"
49#include "mediaplayerstate.h" 49#include "mediaplayerstate.h"
50 50
51extern MediaPlayerState *mediaPlayerState; 51extern MediaPlayerState *mediaPlayerState;
52 52
53static const int xo = -2; // movable x offset 53static const int xo = -2; // movable x offset
54static const int yo = 22; // movable y offset 54static const int yo = 22; // movable y offset
55 55
56 56
57Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) { 57Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) {
58 setFrameStyle( WinPanel | Sunken ); 58 setFrameStyle( WinPanel | Sunken );
59 setText( "No Song" ); 59 setText( "No Song" );
60} 60}
61 61
62Ticker::~Ticker() { 62Ticker::~Ticker() {
63} 63}
64 64
65void Ticker::setText( const QString& text ) { 65void Ticker::setText( const QString& text ) {
66 pos = 0; // reset it everytime the text is changed 66 pos = 0; // reset it everytime the text is changed
67 scrollText = text; 67 scrollText = text;
68 pixelLen = fontMetrics().width( scrollText ); 68 pixelLen = fontMetrics().width( scrollText );
69 killTimers(); 69 killTimers();
70 if ( pixelLen > width() ) { 70 if ( pixelLen > width() ) {
71 startTimer( 50 ); 71 startTimer( 50 );
72 } 72 }
73 update(); 73 update();
74} 74}
75 75
76 76
77void Ticker::timerEvent( QTimerEvent * ) { 77void Ticker::timerEvent( QTimerEvent * ) {
78 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; 78 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1;
79 scroll( -1, 0, contentsRect() ); 79 scroll( -1, 0, contentsRect() );
80 repaint( FALSE ); 80 repaint( FALSE );
81} 81}
82 82
83void Ticker::drawContents( QPainter *p ) { 83void Ticker::drawContents( QPainter *p ) {
84 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { 84 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) {
85 p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); 85 p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
86 } 86 }
87 QPixmap pm( width(), height() ); 87 QPixmap pm( width(), height() );
88 pm.fill( colorGroup().base() ); 88 pm.fill( colorGroup().base() );
89 QPainter pmp( &pm ); 89 QPainter pmp( &pm );
90 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { 90 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) {
91 pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); 91 pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
92 } 92 }
93 p->drawPixmap( 0, 0, pm ); 93 p->drawPixmap( 0, 0, pm );
94} 94}
95 95
96struct MediaButton { 96struct MediaButton {
97 bool isToggle, isHeld, isDown; 97 bool isToggle, isHeld, isDown;
98}; 98};
99 99
100//Layout information for the audioButtons (and if it is a toggle button or not) 100//Layout information for the audioButtons (and if it is a toggle button or not)
101MediaButton audioButtons[] = { 101MediaButton audioButtons[] = {
102 { TRUE, FALSE, FALSE }, // play 102 { TRUE, FALSE, FALSE }, // play
103 { FALSE, FALSE, FALSE }, // stop 103 { FALSE, FALSE, FALSE }, // stop
104 { FALSE, FALSE, FALSE }, // next 104 { FALSE, FALSE, FALSE }, // next
105 { FALSE, FALSE, FALSE }, // previous 105 { FALSE, FALSE, FALSE }, // previous
106 { FALSE, FALSE, FALSE }, // volume up 106 { FALSE, FALSE, FALSE }, // volume up
107 { FALSE, FALSE, FALSE }, // volume down 107 { FALSE, FALSE, FALSE }, // volume down
108 { TRUE, FALSE, FALSE }, // repeat/loop 108 { TRUE, FALSE, FALSE }, // repeat/loop
109 { FALSE, FALSE, FALSE }, // playlist 109 { FALSE, FALSE, FALSE }, // playlist
110 { FALSE, FALSE, FALSE }, // forward 110 { FALSE, FALSE, FALSE }, // forward
111 { FALSE, FALSE, FALSE } // back 111 { FALSE, FALSE, FALSE } // back
112}; 112};
113 113
114const char *skin_mask_file_names[10] = { 114const char *skin_mask_file_names[10] = {
115 "play", "stop", "next", "prev", "up", 115 "play", "stop", "next", "prev", "up",
116 "down", "loop", "playlist", "forward", "back" 116 "down", "loop", "playlist", "forward", "back"
117}; 117};
118 118
119 119
120static void changeTextColor( QWidget *w ) { 120static void changeTextColor( QWidget *w ) {
121 QPalette p = w->palette(); 121 QPalette p = w->palette();
122 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); 122 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) );
123 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); 123 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) );
124 w->setPalette( p ); 124 w->setPalette( p );
125} 125}
126 126
127static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); 127static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
128 128
129 129
130AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : 130AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
131 131
132 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { 132 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) {
133 133
134 setCaption( tr("OpiePlayer") ); 134 setCaption( tr("OpiePlayer") );
135 135
136 Config cfg("OpiePlayer"); 136 Config cfg("OpiePlayer");
137 cfg.setGroup("Options"); 137 cfg.setGroup("Options");
138 skin = cfg.readEntry("Skin","default"); 138 skin = cfg.readEntry("Skin","default");
139 //skin = "scaleTest"; 139 //skin = "scaleTest";
140 // color of background, frame, degree of transparency 140 // color of background, frame, degree of transparency
141 141
142 QString skinPath = "opieplayer2/skins/" + skin; 142 QString skinPath = "opieplayer2/skins/" + skin;
143 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 143 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
144 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); 144 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
145 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); 145 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
146 146
147 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); 147 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
148 imgButtonMask->fill( 0 ); 148 imgButtonMask->fill( 0 );
149 149
150 for ( int i = 0; i < 10; i++ ) { 150 for ( int i = 0; i < 10; i++ ) {
151 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" ); 151 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" );
152 masks[i] = new QBitmap( filename ); 152 masks[i] = new QBitmap( filename );
153 153
154 if ( !masks[i]->isNull() ) { 154 if ( !masks[i]->isNull() ) {
155 QImage imgMask = masks[i]->convertToImage(); 155 QImage imgMask = masks[i]->convertToImage();
156 uchar **dest = imgButtonMask->jumpTable(); 156 uchar **dest = imgButtonMask->jumpTable();
157 for ( int y = 0; y < imgUp->height(); y++ ) { 157 for ( int y = 0; y < imgUp->height(); y++ ) {
158 uchar *line = dest[y]; 158 uchar *line = dest[y];
159 for ( int x = 0; x < imgUp->width(); x++ ) 159 for ( int x = 0; x < imgUp->width(); x++ )
160 if ( !qRed( imgMask.pixel( x, y ) ) ) 160 if ( !qRed( imgMask.pixel( x, y ) ) )
161 line[x] = i + 1; 161 line[x] = i + 1;
162 } 162 }
163 } 163 }
164 164
165 } 165 }
166 166
167 for ( int i = 0; i < 10; i++ ) { 167 for ( int i = 0; i < 10; i++ ) {
168 buttonPixUp[i] = 0l; 168 buttonPixUp[i] = 0l;
169 buttonPixDown[i] = 0l; 169 buttonPixDown[i] = 0l;
170 } 170 }
171 171
172 setBackgroundPixmap( *pixBg ); 172 setBackgroundPixmap( *pixBg );
173 173
174 songInfo.setFocusPolicy( QWidget::NoFocus ); 174 songInfo.setFocusPolicy( QWidget::NoFocus );
175 changeTextColor( &songInfo ); 175 changeTextColor( &songInfo );
176 176
177 slider.setFixedHeight( 20 ); 177 slider.setFixedHeight( 20 );
178 slider.setMinValue( 0 ); 178 slider.setMinValue( 0 );
179 slider.setMaxValue( 1 ); 179 slider.setMaxValue( 1 );
180 slider.setFocusPolicy( QWidget::NoFocus ); 180 slider.setFocusPolicy( QWidget::NoFocus );
181 slider.setBackgroundPixmap( *pixBg ); 181 slider.setBackgroundPixmap( *pixBg );
182 182
183 time.setFocusPolicy( QWidget::NoFocus ); 183 time.setFocusPolicy( QWidget::NoFocus );
184 time.setAlignment( Qt::AlignCenter ); 184 time.setAlignment( Qt::AlignCenter );
185 time.setFrame(FALSE); 185 time.setFrame(FALSE);
186 changeTextColor( &time ); 186 changeTextColor( &time );
187 187
188 resizeEvent( NULL ); 188 resizeEvent( NULL );
189 189
190 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 190 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
191 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 191 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
192 192
193 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 193 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
194 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 194 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
195 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 195 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
196 // connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 196 // connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
197 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 197 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
198 198
199 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); 199 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) );
200 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); 200 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) );
201 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); 201 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) );
202 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); 202 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) );
203 203
204 204
205 205
206 // Intialise state 206 // Intialise state
207 setLength( mediaPlayerState->length() ); 207 setLength( mediaPlayerState->length() );
208 setPosition( mediaPlayerState->position() ); 208 setPosition( mediaPlayerState->position() );
209 setLooping( mediaPlayerState->fullscreen() ); 209 setLooping( mediaPlayerState->fullscreen() );
210 // setPaused( mediaPlayerState->paused() ); 210 // setPaused( mediaPlayerState->paused() );
211 setPlaying( mediaPlayerState->playing() ); 211 setPlaying( mediaPlayerState->playing() );
212 212
213} 213}
214 214
215AudioWidget::~AudioWidget() { 215AudioWidget::~AudioWidget() {
216 216
217 for ( int i = 0; i < 10; i++ ) { 217 for ( int i = 0; i < 10; i++ ) {
218 delete buttonPixUp[i]; 218 delete buttonPixUp[i];
219 delete buttonPixDown[i]; 219 delete buttonPixDown[i];
220 } 220 }
221 delete pixBg; 221 delete pixBg;
222 delete imgUp; 222 delete imgUp;
223 delete imgDn; 223 delete imgDn;
224 delete imgButtonMask; 224 delete imgButtonMask;
225 for ( int i = 0; i < 10; i++ ) { 225 for ( int i = 0; i < 10; i++ ) {
226 delete masks[i]; 226 delete masks[i];
227 } 227 }
228} 228}
229 229
230namespace { 230namespace {
231 231
232QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 232QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
233 QPixmap pix( img.width(), img.height() ); 233 QPixmap pix( img.width(), img.height() );
234 QPainter p( &pix ); 234 QPainter p( &pix );
235 p.drawTiledPixmap( pix.rect(), bg, offset ); 235 p.drawTiledPixmap( pix.rect(), bg, offset );
236 p.drawImage( 0, 0, img ); 236 p.drawImage( 0, 0, img );
237 return new QPixmap( pix ); 237 return new QPixmap( pix );
238} 238}
239 239
240 240
241QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { 241QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) {
242 QPixmap *pixmap = new QPixmap( pix ); 242 QPixmap *pixmap = new QPixmap( pix );
243 pixmap->setMask( mask ); 243 pixmap->setMask( mask );
244 return pixmap; 244 return pixmap;
245} 245}
246 246
247}; 247};
248 248
249void AudioWidget::resizeEvent( QResizeEvent * ) { 249void AudioWidget::resizeEvent( QResizeEvent * ) {
250 int h = height(); 250 int h = height();
251 int w = width(); 251 int w = width();
252 252
253 songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); 253 songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) );
254 slider.setFixedWidth( w - 110 ); 254 slider.setFixedWidth( w - 110 );
255 slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); 255 slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) );
256 slider.setBackgroundOrigin( QWidget::ParentOrigin ); 256 slider.setBackgroundOrigin( QWidget::ParentOrigin );
257 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); 257 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
258 258
259 xoff = ( w - imgUp->width() ) / 2; 259 xoff = ( w - imgUp->width() ) / 2;
260 yoff = (( h - imgUp->height() ) / 2) - 10; 260 yoff = (( h - imgUp->height() ) / 2) - 10;
261 QPoint p( xoff, yoff ); 261 QPoint p( xoff, yoff );
262 262
263 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); 263 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p );
264 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); 264 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p );
265 265
266 for ( int i = 0; i < 10; i++ ) { 266 for ( int i = 0; i < 10; i++ ) {
267 if ( !masks[i]->isNull() ) { 267 if ( !masks[i]->isNull() ) {
268 delete buttonPixUp[i]; 268 delete buttonPixUp[i];
269 delete buttonPixDown[i]; 269 delete buttonPixDown[i];
270 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); 270 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] );
271 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); 271 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] );
272 } 272 }
273 } 273 }
274 274
275 delete pixUp; 275 delete pixUp;
276 delete pixDn; 276 delete pixDn;
277} 277}
278 278
279static bool audioSliderBeingMoved = FALSE; 279static bool audioSliderBeingMoved = FALSE;
280 280
281 281
282void AudioWidget::sliderPressed() { 282void AudioWidget::sliderPressed() {
283 audioSliderBeingMoved = TRUE; 283 audioSliderBeingMoved = TRUE;
284} 284}
285 285
286 286
287void AudioWidget::sliderReleased() { 287void AudioWidget::sliderReleased() {
288 audioSliderBeingMoved = FALSE; 288 audioSliderBeingMoved = FALSE;
289 if ( slider.width() == 0 ) 289 if ( slider.width() == 0 )
290 return; 290 return;
291 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); 291 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width());
292 mediaPlayerState->setPosition( val ); 292 mediaPlayerState->setPosition( val );
293} 293}
294 294
295void AudioWidget::setPosition( long i ) { 295void AudioWidget::setPosition( long i ) {
296 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); 296 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i);
297 updateSlider( i, mediaPlayerState->length() ); 297 updateSlider( i, mediaPlayerState->length() );
298} 298}
299 299
300 300
301void AudioWidget::setLength( long max ) { 301void AudioWidget::setLength( long max ) {
302 updateSlider( mediaPlayerState->position(), max ); 302 updateSlider( mediaPlayerState->position(), max );
303} 303}
304 304
305 305
306void AudioWidget::setView( char view ) { 306void AudioWidget::setView( char view ) {
307 307
308 // this isnt working for some reason 308 // this isnt working for some reason
309 309
310 if ( mediaPlayerState->streaming() ) { 310 if ( mediaPlayerState->streaming() ) {
311 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); 311 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>");
312 if( !slider.isHidden()) { 312 if( !slider.isHidden()) {
313 slider.hide(); 313 slider.hide();
314 } 314 }
315 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 315 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
316 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 316 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
317 } else { 317 } else {
318 // this stops the slider from being moved, thus 318 // this stops the slider from being moved, thus
319 // does not stop stream when it reaches the end 319 // does not stop stream when it reaches the end
320 slider.show(); 320 slider.show();
321 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 321 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
322 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 322 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
323 } 323 }
324 324
325 if ( view == 'a' ) { 325 if ( view == 'a' ) {
326 // startTimer( 150 ); 326 // startTimer( 150 );
327 showMaximized(); 327 showMaximized();
328 } else { 328 } else {
329 killTimers(); 329 killTimers();
330 hide(); 330 hide();
331 } 331 }
332 qApp->processEvents(); 332 qApp->processEvents();
333} 333}
334 334
335 335
336static QString timeAsString( long length ) { 336static QString timeAsString( long length ) {
337 int minutes = length / 60; 337 int minutes = length / 60;
338 int seconds = length % 60; 338 int seconds = length % 60;
339 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); 339 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 );
340} 340}
341 341
342void AudioWidget::updateSlider( long i, long max ) { 342void AudioWidget::updateSlider( long i, long max ) {
343 343
344 time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); 344 time.setText( timeAsString( i ) + " / " + timeAsString( max ) );
345// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; 345// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ;
346 346
347 if ( max == 0 ) { 347 if ( max == 0 ) {
348 return; 348 return;
349 } 349 }
350 // Will flicker too much if we don't do this 350 // Will flicker too much if we don't do this
351 // Scale to something reasonable 351 // Scale to something reasonable
352 int width = slider.width(); 352 int width = slider.width();
353 int val = int((double)i * width / max); 353 int val = int((double)i * width / max);
354 if ( !audioSliderBeingMoved ) { 354 if ( !audioSliderBeingMoved ) {
355 if ( slider.value() != val ) { 355 if ( slider.value() != val ) {
356 slider.setValue( val ); 356 slider.setValue( val );
357 } 357 }
358 358
359 if ( slider.maxValue() != width ) { 359 if ( slider.maxValue() != width ) {
360 slider.setMaxValue( width ); 360 slider.setMaxValue( width );
361 } 361 }
362 } 362 }
363} 363}
364 364
365 365
366void AudioWidget::setToggleButton( int i, bool down ) { 366void AudioWidget::setToggleButton( int i, bool down ) {
367 qDebug("setToggleButton %d", i); 367 qDebug("setToggleButton %d", i);
368 if ( down != audioButtons[i].isDown ) { 368 if ( down != audioButtons[i].isDown ) {
369 toggleButton( i ); 369 toggleButton( i );
370 } 370 }
371} 371}
372 372
373 373
374void AudioWidget::toggleButton( int i ) { 374void AudioWidget::toggleButton( int i ) {
375 audioButtons[i].isDown = !audioButtons[i].isDown; 375 audioButtons[i].isDown = !audioButtons[i].isDown;
376 QPainter p(this); 376 QPainter p(this);
377 paintButton ( &p, i ); 377 paintButton ( &p, i );
378} 378}
379 379
380 380
381void AudioWidget::paintButton( QPainter *p, int i ) { 381void AudioWidget::paintButton( QPainter *p, int i ) {
382 if ( audioButtons[i].isDown ) { 382 if ( audioButtons[i].isDown ) {
383 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 383 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
384 } else { 384 } else {
385 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 385 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
386 } 386 }
387} 387}
388 388
389 389
390void AudioWidget::skipFor() { 390void AudioWidget::skipFor() {
391 skipDirection = +1; 391 skipDirection = +1;
392 startTimer( 50 ); 392 startTimer( 50 );
393 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); 393 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 );
394} 394}
395 395
396void AudioWidget::skipBack() { 396void AudioWidget::skipBack() {
397 skipDirection = -1; 397 skipDirection = -1;
398 startTimer( 50 ); 398 startTimer( 50 );
399 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); 399 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 );
400} 400}
401 401
402 402
403 403
404void AudioWidget::stopSkip() { 404void AudioWidget::stopSkip() {
405 killTimers(); 405 killTimers();
406} 406}
407 407
408 408
409void AudioWidget::timerEvent( QTimerEvent * ) { 409void AudioWidget::timerEvent( QTimerEvent * ) {
410 if ( skipDirection == +1 ) { 410 if ( skipDirection == +1 ) {
411 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); 411 mediaPlayerState->setPosition( mediaPlayerState->position() + 2 );
412 } else if ( skipDirection == -1 ) { 412 } else if ( skipDirection == -1 ) {
413 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); 413 mediaPlayerState->setPosition( mediaPlayerState->position() - 2 );
414 } 414 }
415} 415}
416 416
417 417
418void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 418void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
419 for ( int i = 0; i < numButtons; i++ ) { 419 for ( int i = 0; i < numButtons; i++ ) {
420 if ( event->state() == QMouseEvent::LeftButton ) { 420 if ( event->state() == QMouseEvent::LeftButton ) {
421 // The test to see if the mouse click is inside the button or not 421 // The test to see if the mouse click is inside the button or not
422 int x = event->pos().x() - xoff; 422 int x = event->pos().x() - xoff;
423 int y = event->pos().y() - yoff; 423 int y = event->pos().y() - yoff;
424 424
425 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() 425 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
426 && y < imgButtonMask->height() 426 && y < imgButtonMask->height()
427 && imgButtonMask->pixelIndex( x, y ) == i + 1 ); 427 && imgButtonMask->pixelIndex( x, y ) == i + 1 );
428 428
429 if ( isOnButton && !audioButtons[i].isHeld ) { 429 if ( isOnButton && !audioButtons[i].isHeld ) {
430 audioButtons[i].isHeld = TRUE; 430 audioButtons[i].isHeld = TRUE;
431 toggleButton(i); 431 toggleButton(i);
432 switch (i) { 432 switch (i) {
433 case AudioVolumeUp: 433 case AudioVolumeUp:
434 emit moreClicked(); 434 emit moreClicked();
435 return; 435 return;
436 case AudioVolumeDown: 436 case AudioVolumeDown:
437 emit lessClicked(); 437 emit lessClicked();
438 return; 438 return;
439 case AudioForward: 439 case AudioForward:
440 emit forwardClicked(); 440 emit forwardClicked();
441 return; 441 return;
442 case AudioBack: 442 case AudioBack:
443 emit backClicked(); 443 emit backClicked();
444 return; 444 return;
445 } 445 }
446 } else if ( !isOnButton && audioButtons[i].isHeld ) { 446 } else if ( !isOnButton && audioButtons[i].isHeld ) {
447 audioButtons[i].isHeld = FALSE; 447 audioButtons[i].isHeld = FALSE;
448 toggleButton(i); 448 toggleButton(i);
449 } 449 }
450 } else { 450 } else {
451 if ( audioButtons[i].isHeld ) { 451 if ( audioButtons[i].isHeld ) {
452 audioButtons[i].isHeld = FALSE; 452 audioButtons[i].isHeld = FALSE;
453 if ( !audioButtons[i].isToggle ) { 453 if ( !audioButtons[i].isToggle ) {
454 setToggleButton( i, FALSE ); 454 setToggleButton( i, FALSE );
455 } 455 }
456 qDebug("mouseEvent %d", i);
456 switch (i) { 457 switch (i) {
457 case AudioPlay: 458 case AudioPlay:
458 if( mediaPlayerState->isPaused ) { 459 if( mediaPlayerState->isPaused ) {
459// setToggleButton( i, FALSE ); 460// setToggleButton( i, FALSE );
460 mediaPlayerState->setPaused( FALSE ); 461 mediaPlayerState->setPaused( FALSE );
461 return; 462 return;
462 } else if( !mediaPlayerState->isPaused ) { 463 } else if( !mediaPlayerState->isPaused ) {
463// setToggleButton( i, TRUE ); 464// setToggleButton( i, TRUE );
464 mediaPlayerState->setPaused( TRUE ); 465 mediaPlayerState->setPaused( TRUE );
465 return; 466 return;
466 } else { 467 } else {
467 // setToggleButton( i, TRUE ); 468 // setToggleButton( i, TRUE );
468 // mediaPlayerState->setPlaying( videoButtons[i].isDown ); 469 // mediaPlayerState->setPlaying( videoButtons[i].isDown );
469 } 470 }
470 case AudioStop: mediaPlayerState->setPlaying(FALSE); return; 471 case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
471 case AudioNext: mediaPlayerState->setNext(); return; 472 case AudioNext: mediaPlayerState->setNext(); return;
472 case AudioPrevious: mediaPlayerState->setPrev(); return; 473 case AudioPrevious: mediaPlayerState->setPrev(); return;
473 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; 474 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return;
474 case AudioVolumeUp: emit moreReleased(); return; 475 case AudioVolumeUp: emit moreReleased(); return;
475 case AudioVolumeDown: emit lessReleased(); return; 476 case AudioVolumeDown: emit lessReleased(); return;
476 case AudioPlayList: mediaPlayerState->setList(); return; 477 case AudioPlayList: mediaPlayerState->setList(); return;
477 case AudioForward: emit forwardReleased(); return; 478 case AudioForward: emit forwardReleased(); return;
478 case AudioBack: emit backReleased(); return; 479 case AudioBack: emit backReleased(); return;
479 } 480 }
480 } 481 }
481 } 482 }
482 } 483 }
483} 484}
484 485
485 486
486void AudioWidget::mousePressEvent( QMouseEvent *event ) { 487void AudioWidget::mousePressEvent( QMouseEvent *event ) {
487 mouseMoveEvent( event ); 488 mouseMoveEvent( event );
488} 489}
489 490
490 491
491void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { 492void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
492 mouseMoveEvent( event ); 493 mouseMoveEvent( event );
493} 494}
494 495
495 496
496void AudioWidget::showEvent( QShowEvent* ) { 497void AudioWidget::showEvent( QShowEvent* ) {
497 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 498 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
498 mouseMoveEvent( &event ); 499 mouseMoveEvent( &event );
499} 500}
500 501
501 502
502void AudioWidget::closeEvent( QCloseEvent* ) { 503void AudioWidget::closeEvent( QCloseEvent* ) {
503 mediaPlayerState->setList(); 504 mediaPlayerState->setList();
504} 505}
505 506
506 507
507void AudioWidget::paintEvent( QPaintEvent * pe) { 508void AudioWidget::paintEvent( QPaintEvent * pe) {
508 if ( !pe->erased() ) { 509 if ( !pe->erased() ) {
509 // Combine with background and double buffer 510 // Combine with background and double buffer
510 QPixmap pix( pe->rect().size() ); 511 QPixmap pix( pe->rect().size() );
511 QPainter p( &pix ); 512 QPainter p( &pix );
512 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 513 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
513 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); 514 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
514 for ( int i = 0; i < numButtons; i++ ) 515 for ( int i = 0; i < numButtons; i++ )
515 paintButton( &p, i ); 516 paintButton( &p, i );
516 QPainter p2( this ); 517 QPainter p2( this );
517 p2.drawPixmap( pe->rect().topLeft(), pix ); 518 p2.drawPixmap( pe->rect().topLeft(), pix );
518 } else { 519 } else {
519 QPainter p( this ); 520 QPainter p( this );
520 for ( int i = 0; i < numButtons; i++ ) 521 for ( int i = 0; i < numButtons; i++ )
521 paintButton( &p, i ); 522 paintButton( &p, i );
522 } 523 }
523} 524}
524 525
525void AudioWidget::keyReleaseEvent( QKeyEvent *e) { 526void AudioWidget::keyReleaseEvent( QKeyEvent *e) {
526 switch ( e->key() ) { 527 switch ( e->key() ) {
527 ////////////////////////////// Zaurus keys 528 ////////////////////////////// Zaurus keys
528 case Key_Home: 529 case Key_Home:
529 break; 530 break;
530 case Key_F9: //activity 531 case Key_F9: //activity
531 hide(); 532 hide();
532 // qDebug("Audio F9"); 533 // qDebug("Audio F9");
533 break; 534 break;
534 case Key_F10: //contacts 535 case Key_F10: //contacts
535 break; 536 break;
536 case Key_F11: //menu 537 case Key_F11: //menu
537 mediaPlayerState->toggleBlank(); 538 mediaPlayerState->toggleBlank();
538 break; 539 break;
539 case Key_F12: //home 540 case Key_F12: //home
540 break; 541 break;
541 case Key_F13: //mail 542 case Key_F13: //mail
542 mediaPlayerState->toggleBlank(); 543 mediaPlayerState->toggleBlank();
543 break; 544 break;
544 case Key_Space: { 545 case Key_Space: {
545 if(mediaPlayerState->playing()) { 546 if(mediaPlayerState->playing()) {
546 // toggleButton(1); 547 // toggleButton(1);
547 mediaPlayerState->setPlaying(FALSE); 548 mediaPlayerState->setPlaying(FALSE);
548 // toggleButton(1); 549 // toggleButton(1);
549 } else { 550 } else {
550 // toggleButton(0); 551 // toggleButton(0);
551 mediaPlayerState->setPlaying(TRUE); 552 mediaPlayerState->setPlaying(TRUE);
552 // toggleButton(0); 553 // toggleButton(0);
553 } 554 }
554 } 555 }
555 break; 556 break;
556 case Key_Down: 557 case Key_Down:
557 // toggleButton(6); 558 // toggleButton(6);
558 emit lessClicked(); 559 emit lessClicked();
559 emit lessReleased(); 560 emit lessReleased();
560 // toggleButton(6); 561 // toggleButton(6);
561 break; 562 break;
562 case Key_Up: 563 case Key_Up:
563 // toggleButton(5); 564 // toggleButton(5);
564 emit moreClicked(); 565 emit moreClicked();
565 emit moreReleased(); 566 emit moreReleased();
566 // toggleButton(5); 567 // toggleButton(5);
567 break; 568 break;
568 case Key_Right: 569 case Key_Right:
569 // toggleButton(3); 570 // toggleButton(3);
570 mediaPlayerState->setNext(); 571 mediaPlayerState->setNext();
571 // toggleButton(3); 572 // toggleButton(3);
572 break; 573 break;
573 case Key_Left: 574 case Key_Left:
574 // toggleButton(4); 575 // toggleButton(4);
575 mediaPlayerState->setPrev(); 576 mediaPlayerState->setPrev();
576 // toggleButton(4); 577 // toggleButton(4);
577 break; 578 break;
578 case Key_Escape: { 579 case Key_Escape: {
579/* 580/*
580 * author pleas tell me where the i come from .-) 581 * author pleas tell me where the i come from .-)
581 #if defined(QT_QWS_IPAQ) 582 #if defined(QT_QWS_IPAQ)
582 if( mediaPlayerState->isPaused ) { 583 if( mediaPlayerState->isPaused ) {
583 setToggleButton( i, FALSE ); 584 setToggleButton( i, FALSE );
584 mediaPlayerState->setPaused( FALSE ); 585 mediaPlayerState->setPaused( FALSE );
585 } else if( !mediaPlayerState->isPaused ) { 586 } else if( !mediaPlayerState->isPaused ) {
586 setToggleButton( i, TRUE ); 587 setToggleButton( i, TRUE );
587 mediaPlayerState->setPaused( TRUE ); 588 mediaPlayerState->setPaused( TRUE );
588 } 589 }
589#endif 590#endif
590*/ 591*/
591 } 592 }
592 break; 593 break;
593 594
594 }; 595 };
595} 596}
diff --git a/noncore/multimedia/opieplayer2/inputDialog.cpp b/noncore/multimedia/opieplayer2/inputDialog.cpp
index 9edb1d3..62240b2 100644
--- a/noncore/multimedia/opieplayer2/inputDialog.cpp
+++ b/noncore/multimedia/opieplayer2/inputDialog.cpp
@@ -1,61 +1,62 @@
1#include "inputDialog.h" 1#include "inputDialog.h"
2 2
3#include <qpe/resource.h> 3#include <qpe/resource.h>
4 4
5#include <opie/ofiledialog.h> 5#include <opie/ofiledialog.h>
6 6
7#include <qlineedit.h> 7#include <qlineedit.h>
8#include <qlayout.h> 8#include <qlayout.h>
9#include <qvariant.h> 9#include <qvariant.h>
10#include <qpushbutton.h> 10#include <qpushbutton.h>
11#include <qwhatsthis.h> 11#include <qwhatsthis.h>
12 12
13InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) 13InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
14 : QDialog( parent, name, modal, fl ) { 14 : QDialog( parent, name, modal, fl ) {
15 if ( !name ) { 15 if ( !name ) {
16 setName( "InputDialog" ); 16 setName( "InputDialog" );
17 } 17 }
18 resize( 234, 115); 18 resize( 234, 115);
19 setMaximumSize( QSize( 240, 40)); 19 setMaximumSize( QSize( 240, 40));
20 setCaption( tr( name ) ); 20 setCaption( tr( name ) );
21 21
22 QPushButton *browserButton; 22 QPushButton *browserButton;
23 browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton"); 23 browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton");
24 browserButton->setGeometry( QRect( 205, 10, 22, 22)); 24 browserButton->setGeometry( QRect( 205, 10, 22, 22));
25 connect( browserButton, SIGNAL(released()),this,SLOT(browse())); 25 connect( browserButton, SIGNAL(released()),this,SLOT(browse()));
26 LineEdit1 = new QLineEdit( this, "LineEdit1" ); 26 LineEdit1 = new QLineEdit( this, "LineEdit1" );
27 LineEdit1->setGeometry( QRect( 4, 10, 190, 22 ) ); 27 LineEdit1->setGeometry( QRect( 4, 10, 190, 22 ) );
28 LineEdit1->setFocus();
28} 29}
29/* 30/*
30 * return the current text(input) 31 * return the current text(input)
31 */ 32 */
32QString InputDialog::text() const { 33QString InputDialog::text() const {
33 return LineEdit1->text(); 34 return LineEdit1->text();
34} 35}
35/* 36/*
36 * Destroys the object and frees any allocated resources 37 * Destroys the object and frees any allocated resources
37 */ 38 */
38InputDialog::~InputDialog() { 39InputDialog::~InputDialog() {
39} 40}
40 41
41void InputDialog::browse() { 42void InputDialog::browse() {
42 43
43 MimeTypes types; 44 MimeTypes types;
44 QStringList audio, video, all; 45 QStringList audio, video, all;
45 audio << "audio/*"; 46 audio << "audio/*";
46 audio << "playlist/plain"; 47 audio << "playlist/plain";
47 audio << "audio/x-mpegurl"; 48 audio << "audio/x-mpegurl";
48 49
49 video << "video/*"; 50 video << "video/*";
50 video << "playlist/plain"; 51 video << "playlist/plain";
51 52
52 all += audio; 53 all += audio;
53 all += video; 54 all += video;
54 types.insert("All Media Files", all ); 55 types.insert("All Media Files", all );
55 types.insert("Audio", audio ); 56 types.insert("Audio", audio );
56 types.insert("Video", video ); 57 types.insert("Video", video );
57 58
58 QString str = OFileDialog::getOpenFileName( 1,"/","", types, 0 ); 59 QString str = OFileDialog::getOpenFileName( 1,"/","", types, 0 );
59 LineEdit1->setText(str); 60 LineEdit1->setText(str);
60} 61}
61 62
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index bf2acc8..553e3c1 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -1,303 +1,333 @@
1#include <qpe/qpeapplication.h> 1#include <qpe/qpeapplication.h>
2#include <qpe/qlibrary.h> 2#include <qpe/qlibrary.h>
3#include <qpe/resource.h> 3#include <qpe/resource.h>
4#include <qpe/config.h> 4#include <qpe/config.h>
5#include <qpe/qcopenvelope_qws.h> 5#include <qpe/qcopenvelope_qws.h>
6#include <qfileinfo.h>
6 7
7#include <qmainwindow.h> 8#include <qmainwindow.h>
8#include <qmessagebox.h> 9#include <qmessagebox.h>
9#include <qwidgetstack.h> 10#include <qwidgetstack.h>
10#include <qfile.h> 11#include <qfile.h>
11 12
12#include "mediaplayer.h" 13#include "mediaplayer.h"
13#include "playlistwidget.h" 14#include "playlistwidget.h"
14#include "audiowidget.h" 15#include "audiowidget.h"
15#include "videowidget.h" 16#include "videowidget.h"
16#include "volumecontrol.h" 17#include "volumecontrol.h"
17 18
18#include "mediaplayerstate.h" 19#include "mediaplayerstate.h"
19 20
20// for setBacklight() 21// for setBacklight()
21#include <linux/fb.h> 22#include <linux/fb.h>
22#include <sys/file.h> 23#include <sys/file.h>
23#include <sys/ioctl.h> 24#include <sys/ioctl.h>
24 25
25 26
26extern AudioWidget *audioUI; 27extern AudioWidget *audioUI;
27extern VideoWidget *videoUI; 28extern VideoWidget *videoUI;
28extern PlayListWidget *playList; 29extern PlayListWidget *playList;
29extern MediaPlayerState *mediaPlayerState; 30extern MediaPlayerState *mediaPlayerState;
30 31
31 32
32#define FBIOBLANK 0x4611 33#define FBIOBLANK 0x4611
33 34
34MediaPlayer::MediaPlayer( QObject *parent, const char *name ) 35MediaPlayer::MediaPlayer( QObject *parent, const char *name )
35 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { 36 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) {
36 37
37 playList->setCaption(tr("OpiePlayer: Initializating")); 38 playList->setCaption(tr("OpiePlayer: Initializating"));
38 39
39 qApp->processEvents(); 40 qApp->processEvents();
40 // QPEApplication::grabKeyboard(); // EVIL 41 // QPEApplication::grabKeyboard(); // EVIL
41 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 42 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
42 43
43 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); 44 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) );
44 45
45 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); 46 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) );
46 47
47 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); 48 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) );
48 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); 49 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) );
49 connect( mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); 50 connect( mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) );
50 51
51 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 52 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
52 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 53 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
53 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 54 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
54 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 55 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
55 56
56 connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 57 connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
57 connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 58 connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
58 connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 59 connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
59 connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 60 connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
60 61
61 volControl = new VolumeControl; 62 volControl = new VolumeControl;
62 xineControl = new XineControl(); 63 xineControl = new XineControl();
63 playList->setCaption(tr("OpiePlayer")); 64 playList->setCaption(tr("OpiePlayer"));
64} 65}
65 66
66MediaPlayer::~MediaPlayer() { 67MediaPlayer::~MediaPlayer() {
67 delete xineControl; 68 delete xineControl;
68 delete volControl; 69 delete volControl;
69} 70}
70 71
71void MediaPlayer::pauseCheck( bool b ) { 72void MediaPlayer::pauseCheck( bool b ) {
72 if ( b && !mediaPlayerState->playing() ) { 73 if ( b && !mediaPlayerState->playing() ) {
73 mediaPlayerState->setPaused( FALSE ); 74 mediaPlayerState->setPaused( FALSE );
74 } 75 }
75} 76}
76 77
77void MediaPlayer::play() { 78void MediaPlayer::play() {
78 mediaPlayerState->setPlaying( FALSE ); 79 mediaPlayerState->setPlaying( FALSE );
79 mediaPlayerState->setPlaying( TRUE ); 80 mediaPlayerState->setPlaying( TRUE );
80} 81}
81 82
82void MediaPlayer::setPlaying( bool play ) { 83void MediaPlayer::setPlaying( bool play ) {
83 if ( !play ) { 84 if ( !play ) {
84 return; 85 return;
85 } 86 }
86 87
87 if ( mediaPlayerState->paused() ) { 88 if ( mediaPlayerState->paused() ) {
88 mediaPlayerState->setPaused( FALSE ); 89 mediaPlayerState->setPaused( FALSE );
89 return; 90 return;
90 }
91
92 const DocLnk *playListCurrent = playList->current();
93 if ( playListCurrent != NULL ) {
94 currentFile = playListCurrent;
95 } 91 }
96 92
97 xineControl->play( currentFile->file() ); 93 QString tickerText, time, fileName;
98 94 if( playList->whichList() == 0 ) { //check for filelist
99 long seconds = mediaPlayerState->length();// 95 const DocLnk *playListCurrent = playList->current();
100 QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); 96 if ( playListCurrent != NULL ) {
101 qDebug(time); 97 currentFile = playListCurrent;
102 98 }
103 QString tickerText; 99 xineControl->play( currentFile->file() );
104 if( currentFile->file().left(4) == "http" ) 100 fileName = currentFile->name();
105 tickerText= tr( " File: " ) + currentFile->name(); 101 long seconds = mediaPlayerState->length();//
106 else 102 time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
107 tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time; 103 qDebug(time);
108 104
109 audioUI->setTickerText( currentFile->file( ) ); 105 } else { //if playing in file list.. play in a different way
106 // random and looping settings enabled causes problems here,
107 // since there is no selected file in the playlist, but a selected file in the file list,
108 // so we remember and shutoff
109 l = mediaPlayerState->looping();
110 if(l)
111 mediaPlayerState->setLooping( false );
112 r = mediaPlayerState->shuffled();
113 mediaPlayerState->setShuffled(false);
114
115 fileName = playList->currentFileListPathName();
116 xineControl->play( fileName);
117 long seconds = mediaPlayerState->length();//
118 time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
119 qDebug(time);
120 if( fileName.left(4) != "http" )
121 fileName = QFileInfo( fileName).baseName();
110 122
123 }
124 if( fileName.left(4) == "http" )
125 tickerText= tr( " File: " ) + fileName;
126 else
127 tickerText = tr( " File: " ) + fileName + tr(", Length: ") + time;
128 audioUI->setTickerText( tickerText );
111} 129}
112 130
113 131
114void MediaPlayer::prev() { 132void MediaPlayer::prev() {
115 if ( playList->prev() ) { 133 if(playList->whichList() == 0) { //if using the playlist
116 play(); 134 if ( playList->prev() ) {
117 } else if ( mediaPlayerState->looping() ) {
118 if ( playList->last() ) {
119 play(); 135 play();
136 } else if ( mediaPlayerState->looping() ) {
137 if ( playList->last() ) {
138 play();
139 }
140 } else {
141 mediaPlayerState->setList();
120 } 142 }
121 } else {
122 mediaPlayerState->setList();
123 } 143 }
124} 144}
125 145
126 146
127void MediaPlayer::next() { 147void MediaPlayer::next() {
128 if ( playList->next() ) { 148
129 play(); 149 if(playList->whichList() == 0) { //if using the playlist
130 } else if ( mediaPlayerState->looping() ) { 150 if ( playList->next() ) {
131 if ( playList->first() ) {
132 play(); 151 play();
152 } else if ( mediaPlayerState->looping() ) {
153 if ( playList->first() ) {
154 play();
155 }
156 } else {
157 mediaPlayerState->setList();
133 } 158 }
134 } else { 159 } else { //if playing from file list, let's just stop
135 mediaPlayerState->setList(); 160 qDebug("<<<<<<<<<<<<<<<<<stop for filelists");
161 mediaPlayerState->setPlaying(false);
162 mediaPlayerState->setView('l');
163 if(l) mediaPlayerState->setLooping(l);
164 if(r) mediaPlayerState->setShuffled(r);
136 } 165 }
166 qApp->processEvents();
137} 167}
138 168
139 169
140void MediaPlayer::startDecreasingVolume() { 170void MediaPlayer::startDecreasingVolume() {
141 volumeDirection = -1; 171 volumeDirection = -1;
142 startTimer( 100 ); 172 startTimer( 100 );
143 volControl->decVol(2); 173 volControl->decVol(2);
144} 174}
145 175
146 176
147void MediaPlayer::startIncreasingVolume() { 177void MediaPlayer::startIncreasingVolume() {
148 volumeDirection = +1; 178 volumeDirection = +1;
149 startTimer( 100 ); 179 startTimer( 100 );
150 volControl->incVol(2); 180 volControl->incVol(2);
151} 181}
152 182
153 183
154bool drawnOnScreenDisplay = FALSE; 184bool drawnOnScreenDisplay = FALSE;
155unsigned int onScreenDisplayVolume = 0; 185unsigned int onScreenDisplayVolume = 0;
156const int yoff = 110; 186const int yoff = 110;
157 187
158void MediaPlayer::stopChangingVolume() { 188void MediaPlayer::stopChangingVolume() {
159 killTimers(); 189 killTimers();
160 // Get rid of the on-screen display stuff 190 // Get rid of the on-screen display stuff
161 drawnOnScreenDisplay = FALSE; 191 drawnOnScreenDisplay = FALSE;
162 onScreenDisplayVolume = 0; 192 onScreenDisplayVolume = 0;
163 int w=0; 193 int w=0;
164 int h=0; 194 int h=0;
165 if( !xineControl->hasVideo()) { 195 if( !xineControl->hasVideo()) {
166 w = audioUI->width(); 196 w = audioUI->width();
167 h = audioUI->height(); 197 h = audioUI->height();
168 audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); 198 audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE );
169 } else { 199 } else {
170 w = videoUI->width(); 200 w = videoUI->width();
171 h = videoUI->height(); 201 h = videoUI->height();
172 videoUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); 202 videoUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE );
173 } 203 }
174} 204}
175 205
176 206
177void MediaPlayer::timerEvent( QTimerEvent * ) { 207void MediaPlayer::timerEvent( QTimerEvent * ) {
178 if ( volumeDirection == +1 ) { 208 if ( volumeDirection == +1 ) {
179 volControl->incVol(2); 209 volControl->incVol(2);
180 } else if ( volumeDirection == -1 ) { 210 } else if ( volumeDirection == -1 ) {
181 volControl->decVol(2); 211 volControl->decVol(2);
182 } 212 }
183 213
184 214
185 // TODO FIXME 215 // TODO FIXME
186 // huh?? 216 // huh??
187 unsigned int v= 0; 217 unsigned int v= 0;
188 v = volControl->volume(); 218 v = volControl->volume();
189 v = v / 10; 219 v = v / 10;
190 220
191 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { 221 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) {
192 return; 222 return;
193 } 223 }
194 224
195 int w=0; int h=0; 225 int w=0; int h=0;
196 if( !xineControl->hasVideo()) { 226 if( !xineControl->hasVideo()) {
197 w = audioUI->width(); 227 w = audioUI->width();
198 h = audioUI->height(); 228 h = audioUI->height();
199 229
200 if ( drawnOnScreenDisplay ) { 230 if ( drawnOnScreenDisplay ) {
201 if ( onScreenDisplayVolume > v ) { 231 if ( onScreenDisplayVolume > v ) {
202 audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); 232 audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE );
203 } 233 }
204 } 234 }
205 drawnOnScreenDisplay = TRUE; 235 drawnOnScreenDisplay = TRUE;
206 onScreenDisplayVolume = v; 236 onScreenDisplayVolume = v;
207 QPainter p( audioUI ); 237 QPainter p( audioUI );
208 p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); 238 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
209 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); 239 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
210 240
211 QFont f; 241 QFont f;
212 f.setPixelSize( 20 ); 242 f.setPixelSize( 20 );
213 f.setBold( TRUE ); 243 f.setBold( TRUE );
214 p.setFont( f ); 244 p.setFont( f );
215 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); 245 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") );
216 246
217 for ( unsigned int i = 0; i < 10; i++ ) { 247 for ( unsigned int i = 0; i < 10; i++ ) {
218 if ( v > i ) { 248 if ( v > i ) {
219 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); 249 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
220 } else { 250 } else {
221 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); 251 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
222 } 252 }
223 } 253 }
224 } else { 254 } else {
225 w = videoUI->width(); 255 w = videoUI->width();
226 h = videoUI->height(); 256 h = videoUI->height();
227 257
228 if ( drawnOnScreenDisplay ) { 258 if ( drawnOnScreenDisplay ) {
229 if ( onScreenDisplayVolume > v ) { 259 if ( onScreenDisplayVolume > v ) {
230 videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); 260 videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE );
231 } 261 }
232 } 262 }
233 drawnOnScreenDisplay = TRUE; 263 drawnOnScreenDisplay = TRUE;
234 onScreenDisplayVolume = v; 264 onScreenDisplayVolume = v;
235 QPainter p( videoUI ); 265 QPainter p( videoUI );
236 p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); 266 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
237 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); 267 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
238 268
239 QFont f; 269 QFont f;
240 f.setPixelSize( 20 ); 270 f.setPixelSize( 20 );
241 f.setBold( TRUE ); 271 f.setBold( TRUE );
242 p.setFont( f ); 272 p.setFont( f );
243 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); 273 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") );
244 274
245 for ( unsigned int i = 0; i < 10; i++ ) { 275 for ( unsigned int i = 0; i < 10; i++ ) {
246 if ( v > i ) { 276 if ( v > i ) {
247 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); 277 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
248 } else { 278 } else {
249 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); 279 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
250 } 280 }
251 } 281 }
252 } 282 }
253} 283}
254 284
255 285
256void MediaPlayer::blank( bool b ) { 286void MediaPlayer::blank( bool b ) {
257 fd=open("/dev/fb0",O_RDWR); 287 fd=open("/dev/fb0",O_RDWR);
258 if (fd != -1) { 288 if (fd != -1) {
259 if ( b ) { 289 if ( b ) {
260 qDebug("do blanking"); 290 qDebug("do blanking");
261 ioctl( fd, FBIOBLANK, 3 ); 291 ioctl( fd, FBIOBLANK, 3 );
262 isBlanked = TRUE; 292 isBlanked = TRUE;
263 } else { 293 } else {
264 qDebug("do unblanking"); 294 qDebug("do unblanking");
265 ioctl( fd, FBIOBLANK, 0); 295 ioctl( fd, FBIOBLANK, 0);
266 isBlanked = FALSE; 296 isBlanked = FALSE;
267 } 297 }
268 close( fd ); 298 close( fd );
269 } else { 299 } else {
270 qDebug("<< /dev/fb0 could not be opened >>"); 300 qDebug("<< /dev/fb0 could not be opened >>");
271 } 301 }
272} 302}
273 303
274void MediaPlayer::keyReleaseEvent( QKeyEvent *e) { 304void MediaPlayer::keyReleaseEvent( QKeyEvent *e) {
275 switch ( e->key() ) { 305 switch ( e->key() ) {
276////////////////////////////// Zaurus keys 306////////////////////////////// Zaurus keys
277 case Key_Home: 307 case Key_Home:
278 break; 308 break;
279 case Key_F9: //activity 309 case Key_F9: //activity
280 break; 310 break;
281 case Key_F10: //contacts 311 case Key_F10: //contacts
282 break; 312 break;
283 case Key_F11: //menu 313 case Key_F11: //menu
284 break; 314 break;
285 case Key_F12: //home 315 case Key_F12: //home
286 qDebug("Blank here"); 316 qDebug("Blank here");
287// mediaPlayerState->toggleBlank(); 317// mediaPlayerState->toggleBlank();
288 break; 318 break;
289 case Key_F13: //mail 319 case Key_F13: //mail
290 qDebug("Blank here"); 320 qDebug("Blank here");
291 // mediaPlayerState->toggleBlank(); 321 // mediaPlayerState->toggleBlank();
292 break; 322 break;
293 } 323 }
294} 324}
295 325
296void MediaPlayer::cleanUp() {// this happens on closing 326void MediaPlayer::cleanUp() {// this happens on closing
297 Config cfg( "OpiePlayer" ); 327 Config cfg( "OpiePlayer" );
298 mediaPlayerState->writeConfig( cfg ); 328 mediaPlayerState->writeConfig( cfg );
299 playList->writeConfig( cfg ); 329 playList->writeConfig( cfg );
300 330
301// QPEApplication::grabKeyboard(); 331// QPEApplication::grabKeyboard();
302// QPEApplication::ungrabKeyboard(); 332// QPEApplication::ungrabKeyboard();
303} 333}
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.h b/noncore/multimedia/opieplayer2/mediaplayer.h
index 81fab88..05be128 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.h
+++ b/noncore/multimedia/opieplayer2/mediaplayer.h
@@ -1,47 +1,46 @@
1 1
2#ifndef MEDIA_PLAYER_H 2#ifndef MEDIA_PLAYER_H
3#define MEDIA_PLAYER_H 3#define MEDIA_PLAYER_H
4 4
5#include <qmainwindow.h> 5#include <qmainwindow.h>
6#include <qframe.h> 6#include <qframe.h>
7#include <qpe/qlibrary.h> 7#include <qpe/qlibrary.h>
8#include <qpe/mediaplayerplugininterface.h> 8#include <qpe/mediaplayerplugininterface.h>
9 9
10#include "xinecontrol.h" 10#include "xinecontrol.h"
11 11
12class DocLnk; 12class DocLnk;
13class VolumeControl; 13class VolumeControl;
14 14
15class MediaPlayer : public QObject { 15class MediaPlayer : public QObject {
16 Q_OBJECT 16 Q_OBJECT
17public: 17public:
18 MediaPlayer( QObject *parent, const char *name ); 18 MediaPlayer( QObject *parent, const char *name );
19 ~MediaPlayer(); 19 ~MediaPlayer();
20
21private slots: 20private slots:
22 void setPlaying( bool ); 21 void setPlaying( bool );
23 void pauseCheck( bool ); 22 void pauseCheck( bool );
24 void play(); 23 void play();
25 void next(); 24 void next();
26 void prev(); 25 void prev();
27 void startIncreasingVolume(); 26 void startIncreasingVolume();
28 void startDecreasingVolume(); 27 void startDecreasingVolume();
29 void stopChangingVolume(); 28 void stopChangingVolume();
30 void cleanUp(); 29 void cleanUp();
31 void blank( bool ); 30 void blank( bool );
32 31
33protected: 32protected:
34 void timerEvent( QTimerEvent *e ); 33 void timerEvent( QTimerEvent *e );
35 void keyReleaseEvent( QKeyEvent *e); 34 void keyReleaseEvent( QKeyEvent *e);
36private: 35private:
37 bool isBlanked; 36 bool isBlanked, l, r;
38 int fd; 37 int fd;
39 int volumeDirection; 38 int volumeDirection;
40 const DocLnk *currentFile; 39 const DocLnk *currentFile;
41 XineControl *xineControl; 40 XineControl *xineControl;
42 VolumeControl *volControl; 41 VolumeControl *volControl;
43}; 42};
44 43
45 44
46#endif // MEDIA_PLAYER_H 45#endif // MEDIA_PLAYER_H
47 46
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 3bd04bc..15c70c3 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -1,1064 +1,1082 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include <qpe/qpetoolbar.h> 34#include <qpe/qpetoolbar.h>
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36#include <qpe/storage.h> 36#include <qpe/storage.h>
37#include <qpe/mimetype.h> 37#include <qpe/mimetype.h>
38#include <qpe/global.h> 38#include <qpe/global.h>
39#include <qpe/resource.h> 39#include <qpe/resource.h>
40 40
41#include <qdir.h> 41#include <qdir.h>
42#include <qmessagebox.h> 42#include <qmessagebox.h>
43#include <qregexp.h> 43#include <qregexp.h>
44#include <qtextstream.h> 44#include <qtextstream.h>
45 45
46#include "playlistselection.h" 46#include "playlistselection.h"
47#include "playlistwidget.h" 47#include "playlistwidget.h"
48#include "mediaplayerstate.h" 48#include "mediaplayerstate.h"
49#include "inputDialog.h" 49#include "inputDialog.h"
50 50
51//only needed for the random play 51//only needed for the random play
52#include <stdlib.h> 52#include <stdlib.h>
53 53
54#include "audiowidget.h" 54#include "audiowidget.h"
55#include "videowidget.h" 55#include "videowidget.h"
56 56
57extern MediaPlayerState *mediaPlayerState; 57extern MediaPlayerState *mediaPlayerState;
58 58
59 59
60PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 60PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
61 : PlayListWidgetGui( parent, name, fl ) { 61 : PlayListWidgetGui( parent, name, fl ) {
62 62
63 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer2/add_to_playlist", 63 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer2/add_to_playlist",
64 this , SLOT(addSelected() ) ); 64 this , SLOT(addSelected() ) );
65 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer2/remove_from_playlist", 65 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer2/remove_from_playlist",
66 this , SLOT(removeSelected() ) ); 66 this , SLOT(removeSelected() ) );
67 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", 67 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play",
68 this , SLOT( btnPlay( bool) ), TRUE ); 68 this , SLOT( btnPlay( bool) ), TRUE );
69 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", 69 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle",
70 mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE ); 70 mediaPlayerState, SLOT( setShuffled( bool ) ), TRUE );
71 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop", 71 d->tbLoop = new ToolButton( bar, tr( "Loop" ), "opieplayer2/loop",
72 mediaPlayerState, SLOT( setLooping( bool ) ), TRUE ); 72 mediaPlayerState, SLOT( setLooping( bool ) ), TRUE );
73 73
74 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 74 (void)new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
75 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 75 (void)new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
76 (void)new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 76 (void)new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
77 (void)new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 77 (void)new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
78 pmPlayList->insertSeparator(-1); 78 pmPlayList->insertSeparator(-1);
79 (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 79 (void)new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
80 (void)new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); 80 (void)new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) );
81 pmPlayList->insertSeparator(-1); 81 pmPlayList->insertSeparator(-1);
82 (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); 82 (void)new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
83 pmPlayList->insertSeparator(-1); 83 pmPlayList->insertSeparator(-1);
84 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); 84 (void)new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) );
85 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); 85 (void)new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) );
86 86
87 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), mediaPlayerState, SLOT( toggleFullscreen() ) ); 87 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), mediaPlayerState, SLOT( toggleFullscreen() ) );
88 88
89 Config cfg( "OpiePlayer" ); 89 Config cfg( "OpiePlayer" );
90 bool b= cfg.readBoolEntry("FullScreen", 0); 90 bool b= cfg.readBoolEntry("FullScreen", 0);
91 mediaPlayerState->setFullscreen( b ); 91 mediaPlayerState->setFullscreen( b );
92 pmView->setItemChecked( -16, b ); 92 pmView->setItemChecked( -16, b );
93 93
94 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", d->selectedFiles, SLOT(moveSelectedUp() ) ); 94 (void)new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", d->selectedFiles, SLOT(moveSelectedUp() ) );
95 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", d->selectedFiles, SLOT(removeSelected() ) ); 95 (void)new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", d->selectedFiles, SLOT(removeSelected() ) );
96 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", d->selectedFiles, SLOT(moveSelectedDown() ) ); 96 (void)new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", d->selectedFiles, SLOT(moveSelectedDown() ) );
97 QVBox *stretch2 = new QVBox( vbox1 ); 97 QVBox *stretch2 = new QVBox( vbox1 );
98 98
99 connect( tbDeletePlaylist, ( SIGNAL( released() ) ), SLOT( deletePlaylist() ) ); 99 connect( tbDeletePlaylist, ( SIGNAL( released() ) ), SLOT( deletePlaylist() ) );
100 connect( pmView, SIGNAL( activated( int ) ), this, SLOT( pmViewActivated( int ) ) ); 100 connect( pmView, SIGNAL( activated( int ) ), this, SLOT( pmViewActivated( int ) ) );
101 connect( skinsMenu, SIGNAL( activated( int ) ) , this, SLOT( skinsMenuActivated( int ) ) ); 101 connect( skinsMenu, SIGNAL( activated( int ) ) , this, SLOT( skinsMenuActivated( int ) ) );
102 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), 102 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
103 this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) ); 103 this,SLOT( playlistViewPressed( int, QListViewItem *, const QPoint&, int ) ) );
104 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ), 104 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int ) ),
105 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) ); 105 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int ) ) );
106 connect( audioView, SIGNAL( returnPressed( QListViewItem *) ), 106 connect( audioView, SIGNAL( returnPressed( QListViewItem *) ),
107 this,SLOT( playIt( QListViewItem *) ) ); 107 this,SLOT( playIt( QListViewItem *) ) );
108 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 108 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
109 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ), 109 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int) ),
110 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) ); 110 this,SLOT( viewPressed( int, QListViewItem *, const QPoint&, int) ) );
111 connect( videoView, SIGNAL( returnPressed( QListViewItem *) ), 111 connect( videoView, SIGNAL( returnPressed( QListViewItem *) ),
112 this,SLOT( playIt( QListViewItem *) ) ); 112 this,SLOT( playIt( QListViewItem *) ) );
113 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 113 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
114 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); 114 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
115 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), this, SLOT( tabChanged( QWidget* ) ) ); 115 connect( tabWidget, SIGNAL ( currentChanged(QWidget*) ), this, SLOT( tabChanged( QWidget* ) ) );
116 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 116 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
117 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); 117 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
118 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 118 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
119 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 119 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
120 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 120 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
121 connect ( gammaSlider, SIGNAL( valueChanged( int ) ), mediaPlayerState, SLOT( setVideoGamma( int ) ) ); 121 connect ( gammaSlider, SIGNAL( valueChanged( int ) ), mediaPlayerState, SLOT( setVideoGamma( int ) ) );
122 122
123 readConfig( cfg ); 123 readConfig( cfg );
124 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" ); 124 QString currentPlaylist = cfg.readEntry( "CurrentPlaylist", "" );
125 loadList(DocLnk( currentPlaylist ) ); 125 loadList(DocLnk( currentPlaylist ) );
126 setCaption( tr( "OpiePlayer: " ) + currentPlaylist ); 126 setCaption( tr( "OpiePlayer: " ) + currentPlaylist );
127 127
128 // see which skins are installed 128 // see which skins are installed
129 videoScan=FALSE; 129 videoScan=FALSE;
130 audioScan=FALSE; 130 audioScan=FALSE;
131 populateSkinsMenu(); 131 populateSkinsMenu();
132 initializeStates(); 132 initializeStates();
133} 133}
134 134
135 135
136PlayListWidget::~PlayListWidget() { 136PlayListWidget::~PlayListWidget() {
137 // WTF?!@?! 137 // WTF?!@?!
138 138
139 if ( d->current ) { 139 if ( d->current ) {
140 delete d->current; 140 delete d->current;
141 } 141 }
142 delete d; 142 delete d;
143} 143}
144 144
145 145
146void PlayListWidget::initializeStates() { 146void PlayListWidget::initializeStates() {
147 d->tbPlay->setOn( mediaPlayerState->playing() ); 147 d->tbPlay->setOn( mediaPlayerState->playing() );
148 d->tbLoop->setOn( mediaPlayerState->looping() ); 148 d->tbLoop->setOn( mediaPlayerState->looping() );
149 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 149 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
150 setPlaylist( true ); 150 setPlaylist( true );
151} 151}
152 152
153 153
154void PlayListWidget::readConfig( Config& cfg ) { 154void PlayListWidget::readConfig( Config& cfg ) {
155 cfg.setGroup( "PlayList" ); 155 cfg.setGroup( "PlayList" );
156 QString currentString = cfg.readEntry( "current", "" ); 156 QString currentString = cfg.readEntry( "current", "" );
157 int noOfFiles = cfg.readNumEntry( "NumberOfFiles", 0 ); 157 int noOfFiles = cfg.readNumEntry( "NumberOfFiles", 0 );
158 for ( int i = 0; i < noOfFiles; i++ ) { 158 for ( int i = 0; i < noOfFiles; i++ ) {
159 QString entryName; 159 QString entryName;
160 entryName.sprintf( "File%i", i + 1 ); 160 entryName.sprintf( "File%i", i + 1 );
161 QString linkFile = cfg.readEntry( entryName ); 161 QString linkFile = cfg.readEntry( entryName );
162 if( QFileInfo( linkFile ).exists() ) { 162 if( QFileInfo( linkFile ).exists() ) {
163 DocLnk lnk( linkFile ); 163 DocLnk lnk( linkFile );
164 if ( QFileInfo( lnk.file() ).exists() || linkFile.find( "http" , 0, TRUE) != -1) { 164 if ( QFileInfo( lnk.file() ).exists() || linkFile.find( "http" , 0, TRUE) != -1) {
165 d->selectedFiles->addToSelection( lnk ); 165 d->selectedFiles->addToSelection( lnk );
166 } 166 }
167 } 167 }
168 } 168 }
169 d->selectedFiles->setSelectedItem( currentString ); 169 d->selectedFiles->setSelectedItem( currentString );
170} 170}
171 171
172 172
173void PlayListWidget::writeConfig( Config& cfg ) const { 173void PlayListWidget::writeConfig( Config& cfg ) const {
174 d->selectedFiles->writeCurrent( cfg ); 174 d->selectedFiles->writeCurrent( cfg );
175 cfg.setGroup( "PlayList" ); 175 cfg.setGroup( "PlayList" );
176 int noOfFiles = 0; 176 int noOfFiles = 0;
177 d->selectedFiles->first(); 177 d->selectedFiles->first();
178 do { 178 do {
179 const DocLnk *lnk = d->selectedFiles->current(); 179 const DocLnk *lnk = d->selectedFiles->current();
180 if ( lnk ) { 180 if ( lnk ) {
181 QString entryName; 181 QString entryName;
182 entryName.sprintf( "File%i", noOfFiles + 1 ); 182 entryName.sprintf( "File%i", noOfFiles + 1 );
183 cfg.writeEntry( entryName, lnk->linkFile() ); 183 cfg.writeEntry( entryName, lnk->linkFile() );
184 // if this link does exist, add it so we have the file 184 // if this link does exist, add it so we have the file
185 // next time... 185 // next time...
186 if ( !QFile::exists( lnk->linkFile() ) ) { 186 if ( !QFile::exists( lnk->linkFile() ) ) {
187 // the way writing lnks doesn't really check for out 187 // the way writing lnks doesn't really check for out
188 // of disk space, but check it anyway. 188 // of disk space, but check it anyway.
189 if ( !lnk->writeLink() ) { 189 if ( !lnk->writeLink() ) {
190 QMessageBox::critical( 0, tr("Out of space"), 190 QMessageBox::critical( 0, tr("Out of space"),
191 tr( "There was a problem saving " 191 tr( "There was a problem saving "
192 "the playlist.\n" 192 "the playlist.\n"
193 "Your playlist " 193 "Your playlist "
194 "may be missing some entries\n" 194 "may be missing some entries\n"
195 "the next time you start it." ) 195 "the next time you start it." )
196 ); 196 );
197 } 197 }
198 } 198 }
199 noOfFiles++; 199 noOfFiles++;
200 } 200 }
201 } 201 }
202 while ( d->selectedFiles->next() ); 202 while ( d->selectedFiles->next() );
203 cfg.writeEntry("NumberOfFiles", noOfFiles ); 203 cfg.writeEntry("NumberOfFiles", noOfFiles );
204} 204}
205 205
206 206
207void PlayListWidget::addToSelection( const DocLnk& lnk ) { 207void PlayListWidget::addToSelection( const DocLnk& lnk ) {
208 d->setDocumentUsed = FALSE; 208 d->setDocumentUsed = FALSE;
209 if ( mediaPlayerState->playlist() ) { 209 if ( mediaPlayerState->playlist() ) {
210 if( QFileInfo( lnk.file() ).exists() || lnk.file().left(4) == "http" ) 210 if( QFileInfo( lnk.file() ).exists() || lnk.file().left(4) == "http" )
211 d->selectedFiles->addToSelection( lnk ); 211 d->selectedFiles->addToSelection( lnk );
212 } 212 }
213 else 213 else
214 mediaPlayerState->setPlaying( TRUE ); 214 mediaPlayerState->setPlaying( TRUE );
215} 215}
216 216
217 217
218void PlayListWidget::clearList() { 218void PlayListWidget::clearList() {
219 while ( first() ) { 219 while ( first() ) {
220 d->selectedFiles->removeSelected(); 220 d->selectedFiles->removeSelected();
221 } 221 }
222} 222}
223 223
224 224
225void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) { 225void PlayListWidget::viewPressed( int mouse, QListViewItem *, const QPoint& , int) {
226 switch (mouse) { 226 switch (mouse) {
227 case 1: 227 case 1:
228 break; 228 break;
229 case 2: 229 case 2:
230 { 230 {
231 QPopupMenu m; 231 QPopupMenu m;
232 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 232 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
233 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 233 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
234 m.exec( QCursor::pos() ); 234 m.exec( QCursor::pos() );
235 } 235 }
236 break; 236 break;
237 } 237 }
238} 238}
239 239
240 240
241void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) { 241void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *, const QPoint& , int ) {
242 switch (mouse) { 242 switch (mouse) {
243 case 1: 243 case 1:
244 break; 244 break;
245 case 2: 245 case 2:
246 { 246 {
247 QPopupMenu m; 247 QPopupMenu m;
248 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 248 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
249 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 249 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
250 m.exec( QCursor::pos() ); 250 m.exec( QCursor::pos() );
251 } 251 }
252 break; 252 break;
253 } 253 }
254} 254}
255 255
256 256
257void PlayListWidget::addAllToList() { 257void PlayListWidget::addAllToList() {
258 DocLnkSet filesAll; 258 DocLnkSet filesAll;
259 Global::findDocuments(&filesAll, "video/*;audio/*"); 259 Global::findDocuments(&filesAll, "video/*;audio/*");
260 QListIterator<DocLnk> Adit( filesAll.children() ); 260 QListIterator<DocLnk> Adit( filesAll.children() );
261 for ( ; Adit.current(); ++Adit ) { 261 for ( ; Adit.current(); ++Adit ) {
262 if( QFileInfo( Adit.current()->file() ).exists() ) { 262 if( QFileInfo( Adit.current()->file() ).exists() ) {
263 d->selectedFiles->addToSelection( **Adit ); 263 d->selectedFiles->addToSelection( **Adit );
264 } 264 }
265 } 265 }
266} 266}
267 267
268 268
269void PlayListWidget::addAllMusicToList() { 269void PlayListWidget::addAllMusicToList() {
270 QListIterator<DocLnk> dit( files.children() ); 270 QListIterator<DocLnk> dit( files.children() );
271 for ( ; dit.current(); ++dit ) { 271 for ( ; dit.current(); ++dit ) {
272 if( QFileInfo(dit.current()->file() ).exists() ) { 272 if( QFileInfo(dit.current()->file() ).exists() ) {
273 d->selectedFiles->addToSelection( **dit ); 273 d->selectedFiles->addToSelection( **dit );
274 } 274 }
275 } 275 }
276} 276}
277 277
278 278
279void PlayListWidget::addAllVideoToList() { 279void PlayListWidget::addAllVideoToList() {
280 QListIterator<DocLnk> dit( vFiles.children() ); 280 QListIterator<DocLnk> dit( vFiles.children() );
281 for ( ; dit.current(); ++dit ) { 281 for ( ; dit.current(); ++dit ) {
282 if( QFileInfo( dit.current()->file() ).exists() ) { 282 if( QFileInfo( dit.current()->file() ).exists() ) {
283 d->selectedFiles->addToSelection( **dit ); 283 d->selectedFiles->addToSelection( **dit );
284 } 284 }
285 } 285 }
286} 286}
287 287
288 288
289void PlayListWidget::setDocument( const QString& fileref ) { 289void PlayListWidget::setDocument( const QString& fileref ) {
290 //qDebug( fileref ); 290 //qDebug( fileref );
291 fromSetDocument = TRUE; 291 fromSetDocument = TRUE;
292 if ( fileref.isNull() ) { 292 if ( fileref.isNull() ) {
293 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); 293 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) );
294 return; 294 return;
295 } 295 }
296 296
297 if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u 297 if( fileref.find( "m3u", 0, TRUE) != -1 ) { //is m3u
298 readm3u( fileref ); 298 readm3u( fileref );
299 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls 299 } else if( fileref.find( "pls", 0, TRUE) != -1 ) { //is pls
300 readPls( fileref ); 300 readPls( fileref );
301 } else if( fileref.find( "playlist", 0, TRUE) != -1 ) {//is playlist 301 } else if( fileref.find( "playlist", 0, TRUE) != -1 ) {//is playlist
302 clearList(); 302 clearList();
303 loadList( DocLnk( fileref ) ); 303 loadList( DocLnk( fileref ) );
304 d->selectedFiles->first(); 304 d->selectedFiles->first();
305 } else { 305 } else {
306 clearList(); 306 clearList();
307 addToSelection( DocLnk( fileref ) ); 307 addToSelection( DocLnk( fileref ) );
308 d->setDocumentUsed = TRUE; 308 d->setDocumentUsed = TRUE;
309 mediaPlayerState->setPlaying( FALSE ); 309 mediaPlayerState->setPlaying( FALSE );
310 qApp->processEvents(); 310 qApp->processEvents();
311 mediaPlayerState->setPlaying( TRUE ); 311 mediaPlayerState->setPlaying( TRUE );
312 qApp->processEvents(); 312 qApp->processEvents();
313 setCaption( tr("OpiePlayer") ); 313 setCaption( tr("OpiePlayer") );
314 } 314 }
315} 315}
316 316
317 317
318void PlayListWidget::useSelectedDocument() { 318void PlayListWidget::useSelectedDocument() {
319 d->setDocumentUsed = FALSE; 319 d->setDocumentUsed = FALSE;
320} 320}
321 321
322 322
323const DocLnk *PlayListWidget::current() { // this is fugly 323const DocLnk *PlayListWidget::current() { // this is fugly
324 switch ( tabWidget->currentPageIndex() ) { 324 switch ( whichList() ) {
325 case 0: //playlist 325 case 0: //playlist
326 { 326 {
327// qDebug("playlist"); 327// qDebug("playlist");
328 if ( mediaPlayerState->playlist() ) { 328 if ( mediaPlayerState->playlist() ) {
329 return d->selectedFiles->current(); 329 return d->selectedFiles->current();
330 } else if ( d->setDocumentUsed && d->current ) { 330 } else if ( d->setDocumentUsed && d->current ) {
331 return d->current; 331 return d->current;
332 } else { 332 } else {
333 return d->files->selected(); 333 return d->files->selected();
334 } 334 }
335 } 335 }
336 break; 336 break;
337 case 1://audio 337 case 1://audio
338 { 338 {
339// qDebug("audioView"); 339// qDebug("audioView");
340 QListIterator<DocLnk> dit( files.children() ); 340 QListIterator<DocLnk> dit( files.children() );
341 for ( ; dit.current(); ++dit ) { 341 for ( ; dit.current(); ++dit ) {
342 if( dit.current()->name() == audioView->currentItem()->text( 0 ) && !insanityBool ) { 342 if( dit.current()->name() == audioView->currentItem()->text( 0 ) && !insanityBool ) {
343 insanityBool = TRUE; 343 insanityBool = TRUE;
344 return dit; 344 return dit;
345 } 345 }
346 } 346 }
347 } 347 }
348 break; 348 break;
349 case 2: // video 349 case 2: // video
350 { 350 {
351// qDebug("videoView"); 351// qDebug("videoView");
352 QListIterator<DocLnk> Vdit( vFiles.children() ); 352 QListIterator<DocLnk> Vdit( vFiles.children() );
353 for ( ; Vdit.current(); ++Vdit ) { 353 for ( ; Vdit.current(); ++Vdit ) {
354 if( Vdit.current()->name() == videoView->currentItem()->text( 0 ) && !insanityBool) { 354 if( Vdit.current()->name() == videoView->currentItem()->text( 0 ) && !insanityBool) {
355 insanityBool = TRUE; 355 insanityBool = TRUE;
356 return Vdit; 356 return Vdit;
357 } 357 }
358 } 358 }
359 } 359 }
360 break; 360 break;
361 }; 361 };
362 return 0; 362 return 0;
363} 363}
364 364
365 365
366bool PlayListWidget::prev() { 366bool PlayListWidget::prev() {
367 if ( mediaPlayerState->playlist() ) { 367 if ( mediaPlayerState->playlist() ) {
368 if ( mediaPlayerState->shuffled() ) { 368 if ( mediaPlayerState->shuffled() ) {
369 const DocLnk *cur = current(); 369 const DocLnk *cur = current();
370 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 370 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
371 for ( int i = 0; i < j; i++ ) { 371 for ( int i = 0; i < j; i++ ) {
372 if ( !d->selectedFiles->next() ) 372 if ( !d->selectedFiles->next() )
373 d->selectedFiles->first(); 373 d->selectedFiles->first();
374 } 374 }
375 if ( cur == current() ) 375 if ( cur == current() )
376 if ( !d->selectedFiles->next() ) { 376 if ( !d->selectedFiles->next() ) {
377 d->selectedFiles->first(); 377 d->selectedFiles->first();
378 } 378 }
379 return TRUE; 379 return TRUE;
380 } else { 380 } else {
381 if ( !d->selectedFiles->prev() ) { 381 if ( !d->selectedFiles->prev() ) {
382 if ( mediaPlayerState->looping() ) { 382 if ( mediaPlayerState->looping() ) {
383 return d->selectedFiles->last(); 383 return d->selectedFiles->last();
384 } else { 384 } else {
385 return FALSE; 385 return FALSE;
386 } 386 }
387 } 387 }
388 return TRUE; 388 return TRUE;
389 } 389 }
390 } else { 390 } else {
391 return mediaPlayerState->looping(); 391 return mediaPlayerState->looping();
392 } 392 }
393} 393}
394 394
395 395
396bool PlayListWidget::next() { 396bool PlayListWidget::next() {
397 if ( mediaPlayerState->playlist() ) { 397qDebug("<<<<<<<<<<<<next()");
398 if ( mediaPlayerState->playlist() ) {
398 if ( mediaPlayerState->shuffled() ) { 399 if ( mediaPlayerState->shuffled() ) {
399 return prev(); 400 return prev();
400 } else { 401 } else {
401 if ( !d->selectedFiles->next() ) { 402 if ( !d->selectedFiles->next() ) {
402 if ( mediaPlayerState->looping() ) { 403 if ( mediaPlayerState->looping() ) {
403 return d->selectedFiles->first(); 404 return d->selectedFiles->first();
404 } else { 405 } else {
405 return FALSE; 406 return FALSE;
406 } 407 }
407 } 408 }
408 return TRUE; 409 return TRUE;
409 } 410 }
410 } else { 411 } else {
411 return mediaPlayerState->looping(); 412 return mediaPlayerState->looping();
412 } 413 }
413} 414}
414 415
415 416
416bool PlayListWidget::first() { 417bool PlayListWidget::first() {
417 if ( mediaPlayerState->playlist() ) 418 if ( mediaPlayerState->playlist() )
418 return d->selectedFiles->first(); 419 return d->selectedFiles->first();
419 else 420 else
420 return mediaPlayerState->looping(); 421 return mediaPlayerState->looping();
421} 422}
422 423
423 424
424bool PlayListWidget::last() { 425bool PlayListWidget::last() {
425 if ( mediaPlayerState->playlist() ) 426 if ( mediaPlayerState->playlist() )
426 return d->selectedFiles->last(); 427 return d->selectedFiles->last();
427 else 428 else
428 return mediaPlayerState->looping(); 429 return mediaPlayerState->looping();
429} 430}
430 431
431 432
432void PlayListWidget::saveList() { 433void PlayListWidget::saveList() {
433 434
434 QString filename; 435 QString filename;
435 InputDialog *fileDlg = 0l; 436 InputDialog *fileDlg = 0l;
436 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); 437 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0);
437 fileDlg->exec(); 438 fileDlg->exec();
438 if( fileDlg->result() == 1 ) { 439 if( fileDlg->result() == 1 ) {
439 if ( d->current ) 440 if ( d->current )
440 delete d->current; 441 delete d->current;
441 filename = fileDlg->text();//+".playlist"; 442 filename = fileDlg->text();//+".playlist";
442 // qDebug("saving playlist "+filename+".playlist"); 443 // qDebug("saving playlist "+filename+".playlist");
443 Config cfg( filename +".playlist"); 444 Config cfg( filename +".playlist");
444 writeConfig( cfg ); 445 writeConfig( cfg );
445 446
446 DocLnk lnk; 447 DocLnk lnk;
447 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property 448 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property
448 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D 449 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D
449 lnk.setIcon("opieplayer2/playlist2"); 450 lnk.setIcon("opieplayer2/playlist2");
450 lnk.setName( filename); //sets file name 451 lnk.setName( filename); //sets file name
451 // qDebug(filename); 452 // qDebug(filename);
452 if(!lnk.writeLink()) { 453 if(!lnk.writeLink()) {
453 qDebug("Writing doclink did not work"); 454 qDebug("Writing doclink did not work");
454 } 455 }
455 } 456 }
456 Config config( "OpiePlayer" ); 457 Config config( "OpiePlayer" );
457 config.writeEntry("CurrentPlaylist",filename); 458 config.writeEntry("CurrentPlaylist",filename);
458 setCaption(tr("OpiePlayer: ")+filename); 459 setCaption(tr("OpiePlayer: ")+filename);
459 d->selectedFiles->first(); 460 d->selectedFiles->first();
460 if(fileDlg) { 461 if(fileDlg) {
461 delete fileDlg; 462 delete fileDlg;
462 } 463 }
463} 464}
464 465
465void PlayListWidget::loadList( const DocLnk & lnk) { 466void PlayListWidget::loadList( const DocLnk & lnk) {
466 QString name= lnk.name(); 467 QString name= lnk.name();
467 // qDebug("currentList is "+name); 468 // qDebug("currentList is "+name);
468 if( name.length()>1) { 469 if( name.length()>1) {
469 setCaption("OpiePlayer: "+name); 470 setCaption("OpiePlayer: "+name);
470 // qDebug("load list "+ name+".playlist"); 471 // qDebug("load list "+ name+".playlist");
471 clearList(); 472 clearList();
472 Config cfg( name+".playlist"); 473 Config cfg( name+".playlist");
473 readConfig(cfg); 474 readConfig(cfg);
474 475
475 tabWidget->setCurrentPage(0); 476 tabWidget->setCurrentPage(0);
476 477
477 Config config( "OpiePlayer" ); 478 Config config( "OpiePlayer" );
478 config.writeEntry("CurrentPlaylist", name); 479 config.writeEntry("CurrentPlaylist", name);
479 // d->selectedFiles->first(); 480 // d->selectedFiles->first();
480 } 481 }
481} 482}
482 483
483 484
484void PlayListWidget::setPlaylist( bool shown ) { 485void PlayListWidget::setPlaylist( bool shown ) {
485 if ( shown ) { 486 if ( shown ) {
486 d->playListFrame->show(); 487 d->playListFrame->show();
487 } else { 488 } else {
488 d->playListFrame->hide(); 489 d->playListFrame->hide();
489 } 490 }
490} 491}
491 492
492 493
493void PlayListWidget::addSelected() { 494void PlayListWidget::addSelected() {
494 495
495 Config cfg( "OpiePlayer" ); 496 Config cfg( "OpiePlayer" );
496 cfg.setGroup("PlayList"); 497 cfg.setGroup("PlayList");
497 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 498 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
498 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 499 // int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
499 500
500 switch (tabWidget->currentPageIndex()) { 501 switch (whichList()) {
501 case 0: //playlist 502 case 0: //playlist
502 break; 503 break;
503 case 1: { //audio 504 case 1: { //audio
504 QListViewItemIterator it( audioView ); 505 QListViewItemIterator it( audioView );
505 // iterate through all items of the listview 506 // iterate through all items of the listview
506 for ( ; it.current(); ++it ) { 507 for ( ; it.current(); ++it ) {
507 if ( it.current()->isSelected() ) { 508 if ( it.current()->isSelected() ) {
508 QListIterator<DocLnk> dit( files.children() ); 509 QListIterator<DocLnk> dit( files.children() );
509 for ( ; dit.current(); ++dit ) { 510 for ( ; dit.current(); ++dit ) {
510 if( dit.current()->name() == it.current()->text(0) ) { 511 if( dit.current()->name() == it.current()->text(0) ) {
511 if(QFileInfo( dit.current()->file()).exists()) 512 if(QFileInfo( dit.current()->file()).exists())
512 d->selectedFiles->addToSelection( **dit ); 513 d->selectedFiles->addToSelection( **dit );
513 } 514 }
514 } 515 }
515 audioView->setSelected( it.current(),FALSE); 516 audioView->setSelected( it.current(),FALSE);
516 } 517 }
517 } 518 }
518 tabWidget->setCurrentPage(0); 519 tabWidget->setCurrentPage(0);
519 } 520 }
520 break; 521 break;
521 case 2: { // video 522 case 2: { // video
522 QListViewItemIterator it( videoView ); 523 QListViewItemIterator it( videoView );
523 // iterate through all items of the listview 524 // iterate through all items of the listview
524 for ( ; it.current(); ++it ) { 525 for ( ; it.current(); ++it ) {
525 if ( it.current()->isSelected() ) { 526 if ( it.current()->isSelected() ) {
526 QListIterator<DocLnk> dit( vFiles.children() ); 527 QListIterator<DocLnk> dit( vFiles.children() );
527 for ( ; dit.current(); ++dit ) { 528 for ( ; dit.current(); ++dit ) {
528 if( dit.current()->name() == it.current()->text(0) ) { 529 if( dit.current()->name() == it.current()->text(0) ) {
529 if(QFileInfo( dit.current()->file()).exists()) 530 if(QFileInfo( dit.current()->file()).exists())
530 d->selectedFiles->addToSelection( **dit ); 531 d->selectedFiles->addToSelection( **dit );
531 } 532 }
532 } 533 }
533 videoView->setSelected( it.current(),FALSE); 534 videoView->setSelected( it.current(),FALSE);
534 } 535 }
535 } 536 }
536 tabWidget->setCurrentPage(0); 537 tabWidget->setCurrentPage(0);
537 } 538 }
538 break; 539 break;
539 }; 540 };
540} 541}
541 542
542 543
543void PlayListWidget::removeSelected() { 544void PlayListWidget::removeSelected() {
544 d->selectedFiles->removeSelected( ); 545 d->selectedFiles->removeSelected( );
545} 546}
546 547
547 548
548void PlayListWidget::playIt( QListViewItem *it) { 549void PlayListWidget::playIt( QListViewItem *it) {
549 if(!it) return; 550 if(!it) return;
550 mediaPlayerState->setPlaying(FALSE); 551 mediaPlayerState->setPlaying(FALSE);
551 mediaPlayerState->setPlaying(TRUE); 552 mediaPlayerState->setPlaying(TRUE);
552 d->selectedFiles->unSelect(); 553 d->selectedFiles->unSelect();
553} 554}
554 555
555 556
556void PlayListWidget::addToSelection( QListViewItem *it) { 557void PlayListWidget::addToSelection( QListViewItem *it) {
557 d->setDocumentUsed = FALSE; 558 d->setDocumentUsed = FALSE;
558 559
559 if(it) { 560 if(it) {
560 switch (tabWidget->currentPageIndex()) { 561 switch ( whichList()) {
561 case 1: { 562 case 1: {
562 QListIterator<DocLnk> dit( files.children() ); 563 QListIterator<DocLnk> dit( files.children() );
563 for ( ; dit.current(); ++dit ) { 564 for ( ; dit.current(); ++dit ) {
564 if( dit.current()->name() == it->text(0)) { 565 if( dit.current()->name() == it->text(0)) {
565 if(QFileInfo( dit.current()->file()).exists()) 566 if(QFileInfo( dit.current()->file()).exists())
566 d->selectedFiles->addToSelection( **dit ); 567 d->selectedFiles->addToSelection( **dit );
567 } 568 }
568 } 569 }
569 } 570 }
570 break; 571 break;
571 case 2: { 572 case 2: {
572 QListIterator<DocLnk> dit( vFiles.children() ); 573 QListIterator<DocLnk> dit( vFiles.children() );
573 for ( ; dit.current(); ++dit ) { 574 for ( ; dit.current(); ++dit ) {
574 if( dit.current()->name() == it->text(0)) { 575 if( dit.current()->name() == it->text(0)) {
575 if(QFileInfo( dit.current()->file()).exists()) 576 if(QFileInfo( dit.current()->file()).exists())
576 d->selectedFiles->addToSelection( **dit ); 577 d->selectedFiles->addToSelection( **dit );
577 } 578 }
578 } 579 }
579 } 580 }
580 break; 581 break;
581 case 0: 582 case 0:
582 break; 583 break;
583 }; 584 };
584 tabWidget->setCurrentPage(0); 585 tabWidget->setCurrentPage(0);
585 } 586 }
586} 587}
587 588
588 589
589void PlayListWidget::tabChanged(QWidget *) { 590void PlayListWidget::tabChanged(QWidget *) {
590 591
591 switch ( tabWidget->currentPageIndex()) { 592 switch ( whichList()) {
592 case 0: 593 case 0:
593 { 594 {
594 if( !tbDeletePlaylist->isHidden() ) { 595 if( !tbDeletePlaylist->isHidden() ) {
595 tbDeletePlaylist->hide(); 596 tbDeletePlaylist->hide();
596 } 597 }
597 d->tbRemoveFromList->setEnabled(TRUE); 598 d->tbRemoveFromList->setEnabled(TRUE);
598 d->tbAddToList->setEnabled(FALSE); 599 d->tbAddToList->setEnabled(FALSE);
599 } 600 }
600 break; 601 break;
601 case 1: 602 case 1:
602 { 603 {
603 audioView->clear(); 604 audioView->clear();
604 populateAudioView(); 605 populateAudioView();
605 606
606 if( !tbDeletePlaylist->isHidden() ) { 607 if( !tbDeletePlaylist->isHidden() ) {
607 tbDeletePlaylist->hide(); 608 tbDeletePlaylist->hide();
608 } 609 }
609 d->tbRemoveFromList->setEnabled(FALSE); 610 d->tbRemoveFromList->setEnabled(FALSE);
610 d->tbAddToList->setEnabled(TRUE); 611 d->tbAddToList->setEnabled(TRUE);
611 } 612 }
612 break; 613 break;
613 case 2: 614 case 2:
614 { 615 {
615 videoView->clear(); 616 videoView->clear();
616 populateVideoView(); 617 populateVideoView();
617 if( !tbDeletePlaylist->isHidden() ) { 618 if( !tbDeletePlaylist->isHidden() ) {
618 tbDeletePlaylist->hide(); 619 tbDeletePlaylist->hide();
619 } 620 }
620 d->tbRemoveFromList->setEnabled(FALSE); 621 d->tbRemoveFromList->setEnabled(FALSE);
621 d->tbAddToList->setEnabled(TRUE); 622 d->tbAddToList->setEnabled(TRUE);
622 } 623 }
623 break; 624 break;
624 case 3: 625 case 3:
625 { 626 {
626 if( tbDeletePlaylist->isHidden() ) { 627 if( tbDeletePlaylist->isHidden() ) {
627 tbDeletePlaylist->show(); 628 tbDeletePlaylist->show();
628 } 629 }
629 playLists->reread(); 630 playLists->reread();
630 } 631 }
631 break; 632 break;
632 }; 633 };
633} 634}
634 635
635 636
636void PlayListWidget::btnPlay(bool b) { 637void PlayListWidget::btnPlay(bool b) {
637 // mediaPlayerState->setPlaying(b); 638 mediaPlayerState->setPlaying(b);
638 switch ( tabWidget->currentPageIndex()) { 639 qApp->processEvents();
639 case 0: 640 insanityBool=FALSE;
640 { 641// switch ( whichList()) {
641 mediaPlayerState->setPlaying(b); 642// case 0:
642 } 643// {
643 break; 644// mediaPlayerState->setPlaying(b);
644 case 1: 645// }
645 { 646// break;
646 addToSelection( audioView->currentItem() ); 647// case 1:
647 mediaPlayerState->setPlaying(b); 648// {
648 d->selectedFiles->removeSelected( ); 649// mediaPlayerState->setPlaying(b);
649 tabWidget->setCurrentPage(1); 650// qApp->processEvents();
650 d->selectedFiles->unSelect(); 651// insanityBool=FALSE;
651 insanityBool=FALSE; 652// }// audioView->clearSelection();
652 }// audioView->clearSelection(); 653// break;
653 break; 654// case 2:
654 case 2: 655// {
655 { 656// // addToSelection( videoView->currentItem() );
656 addToSelection( videoView->currentItem() ); 657// mediaPlayerState->setPlaying(b);
657 mediaPlayerState->setPlaying(b); 658// qApp->processEvents();
658 qApp->processEvents(); 659// // d->selectedFiles->removeSelected( );
659 d->selectedFiles->removeSelected( ); 660// // tabWidget->setCurrentPage(2);
660 tabWidget->setCurrentPage(2); 661// // d->selectedFiles->unSelect();
661 d->selectedFiles->unSelect(); 662// insanityBool=FALSE;
662 insanityBool=FALSE; 663// }// videoView->clearSelection();
663 }// videoView->clearSelection(); 664// break;
664 break; 665// };
665 };
666 666
667} 667}
668 668
669void PlayListWidget::deletePlaylist() { 669void PlayListWidget::deletePlaylist() {
670 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 670 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
671 (tr("You really want to delete\nthis playlist?")), 671 (tr("You really want to delete\nthis playlist?")),
672 (tr("Yes")), (tr("No")), 0 )){ 672 (tr("Yes")), (tr("No")), 0 )){
673 case 0: // Yes clicked, 673 case 0: // Yes clicked,
674 QFile().remove(playLists->selected()->file()); 674 QFile().remove(playLists->selected()->file());
675 QFile().remove(playLists->selected()->linkFile()); 675 QFile().remove(playLists->selected()->linkFile());
676 playLists->reread(); 676 playLists->reread();
677 break; 677 break;
678 case 1: // Cancel 678 case 1: // Cancel
679 break; 679 break;
680 }; 680 };
681} 681}
682 682
683 683
684void PlayListWidget::playSelected() { 684void PlayListWidget::playSelected() {
685 btnPlay( TRUE); 685 btnPlay( TRUE);
686} 686}
687 687
688 688
689void PlayListWidget::scanForAudio() { 689void PlayListWidget::scanForAudio() {
690// qDebug("scan for audio"); 690// qDebug("scan for audio");
691 files.detachChildren(); 691 files.detachChildren();
692 QListIterator<DocLnk> sdit( files.children() ); 692 QListIterator<DocLnk> sdit( files.children() );
693 for ( ; sdit.current(); ++sdit ) { 693 for ( ; sdit.current(); ++sdit ) {
694 delete sdit.current(); 694 delete sdit.current();
695 } 695 }
696 Global::findDocuments(&files, "audio/*"); 696 Global::findDocuments(&files, "audio/*");
697 audioScan = TRUE; 697 audioScan = TRUE;
698} 698}
699 699
700void PlayListWidget::scanForVideo() { 700void PlayListWidget::scanForVideo() {
701// qDebug("scan for video"); 701// qDebug("scan for video");
702 vFiles.detachChildren(); 702 vFiles.detachChildren();
703 QListIterator<DocLnk> sdit( vFiles.children() ); 703 QListIterator<DocLnk> sdit( vFiles.children() );
704 for ( ; sdit.current(); ++sdit ) { 704 for ( ; sdit.current(); ++sdit ) {
705 delete sdit.current(); 705 delete sdit.current();
706 } 706 }
707 Global::findDocuments(&vFiles, "video/*"); 707 Global::findDocuments(&vFiles, "video/*");
708 videoScan = TRUE; 708 videoScan = TRUE;
709} 709}
710 710
711void PlayListWidget::populateAudioView() { 711void PlayListWidget::populateAudioView() {
712 audioView->clear(); 712 audioView->clear();
713 StorageInfo storageInfo; 713 StorageInfo storageInfo;
714 const QList<FileSystem> &fs = storageInfo.fileSystems(); 714 const QList<FileSystem> &fs = storageInfo.fileSystems();
715 if(!audioScan) { 715 if(!audioScan) {
716 scanForAudio(); 716 scanForAudio();
717 } 717 }
718 718
719 QListIterator<DocLnk> dit( files.children() ); 719 QListIterator<DocLnk> dit( files.children() );
720 QListIterator<FileSystem> it ( fs ); 720 QListIterator<FileSystem> it ( fs );
721 721
722 QString storage; 722 QString storage;
723 for ( ; dit.current(); ++dit ) { 723 for ( ; dit.current(); ++dit ) {
724 for( ; it.current(); ++it ){ 724 for( ; it.current(); ++it ){
725 const QString name = (*it)->name(); 725 const QString name = (*it)->name();
726 const QString path = (*it)->path(); 726 const QString path = (*it)->path();
727 if(dit.current()->file().find(path) != -1 ) { 727 if(dit.current()->file().find(path) != -1 ) {
728 storage = name; 728 storage = name;
729 } 729 }
730 } 730 }
731 731
732 QListViewItem * newItem; 732 QListViewItem * newItem;
733 if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) { 733 if ( QFile( dit.current()->file()).exists() || dit.current()->file().left(4) == "http" ) {
734 long size; 734 long size;
735 if( dit.current()->file().left(4) == "http" ) 735 if( dit.current()->file().left(4) == "http" )
736 size=0; 736 size=0;
737 else 737 else
738 size = QFile( dit.current()->file() ).size(); 738 size = QFile( dit.current()->file() ).size();
739 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number(size ), storage); 739 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(),
740 QString::number(size ), storage, dit.current()->file());
740 newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) ); 741 newItem->setPixmap( 0, Resource::loadPixmap( "opieplayer2/musicfile" ) );
741 } 742 }
742 } 743 }
743} 744}
744 745
745 746
746void PlayListWidget::populateVideoView() { 747void PlayListWidget::populateVideoView() {
747 videoView->clear(); 748 videoView->clear();
748 StorageInfo storageInfo; 749 StorageInfo storageInfo;
749 const QList<FileSystem> &fs = storageInfo.fileSystems(); 750 const QList<FileSystem> &fs = storageInfo.fileSystems();
750 751
751 if(!videoScan ) { 752 if(!videoScan ) {
752 scanForVideo(); 753 scanForVideo();
753 } 754 }
754 755
755 QListIterator<DocLnk> Vdit( vFiles.children() ); 756 QListIterator<DocLnk> Vdit( vFiles.children() );
756 QListIterator<FileSystem> it ( fs ); 757 QListIterator<FileSystem> it ( fs );
757 videoView->clear(); 758 videoView->clear();
758 QString storage; 759 QString storage, pathName;
759 for ( ; Vdit.current(); ++Vdit ) { 760 for ( ; Vdit.current(); ++Vdit ) {
760 for( ; it.current(); ++it ) { 761 for( ; it.current(); ++it ) {
761 const QString name = (*it)->name(); 762 const QString name = (*it)->name();
762 const QString path = (*it)->path(); 763 const QString path = (*it)->path();
763 if( Vdit.current()->file().find(path) != -1 ) { 764 if( Vdit.current()->file().find(path) != -1 ) {
764 storage=name; 765 storage=name;
766 pathName=path;
765 } 767 }
766 } 768 }
767 769
768 QListViewItem * newItem; 770 QListViewItem * newItem;
769 if ( QFile( Vdit.current()->file() ).exists() ) { 771 if ( QFile( Vdit.current()->file() ).exists() ) {
770 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), 772 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(),
771 QString::number( QFile( Vdit.current()->file() ).size() ), storage ); 773 QString::number( QFile( Vdit.current()->file() ).size() ), storage, Vdit.current()->file());
772 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) ); 774 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer2/videofile" ) );
773 } 775 }
774 } 776 }
775} 777}
776 778
777 779
778void PlayListWidget::openFile() { 780void PlayListWidget::openFile() {
779 QString filename, name; 781 QString filename, name;
780 InputDialog *fileDlg; 782 InputDialog *fileDlg;
781 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 783 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
782 fileDlg->exec(); 784 fileDlg->exec();
783 if( fileDlg->result() == 1 ) { 785 if( fileDlg->result() == 1 ) {
784 filename = fileDlg->text(); 786 filename = fileDlg->text();
785 787
786 qDebug( "Selected filename is " + filename ); 788 qDebug( "Selected filename is " + filename );
787 if( filename.right( 3 ) == "m3u" ) { 789 if( filename.right( 3 ) == "m3u" ) {
788 readm3u( filename ); 790 readm3u( filename );
789 } else if( filename.right(3) == "pls" ) { 791 } else if( filename.right(3) == "pls" ) {
790 readPls( filename ); 792 readPls( filename );
791 } else { 793 } else {
792 // this doesnt need fixing 794 // this doesnt need fixing
793 DocLnk lnk; 795 DocLnk lnk;
794 lnk.setName( filename ); //sets file name 796 lnk.setName( filename ); //sets file name
795 lnk.setFile( filename ); //sets File property 797 lnk.setFile( filename ); //sets File property
796 //qWarning( "Mimetype: " + MimeType( QFile::encodeName(filename) ).id() ); 798 //qWarning( "Mimetype: " + MimeType( QFile::encodeName(filename) ).id() );
797 lnk.setType( MimeType( QFile::encodeName(filename) ).id() ); 799 lnk.setType( MimeType( QFile::encodeName(filename) ).id() );
798 lnk.setExec( "opieplayer" ); 800 lnk.setExec( "opieplayer" );
799 lnk.setIcon( "opieplayer2/MPEGPlayer" ); 801 lnk.setIcon( "opieplayer2/MPEGPlayer" );
800 802
801 if( !lnk.writeLink() ) { 803 if( !lnk.writeLink() ) {
802 qDebug( "Writing doclink did not work" ); 804 qDebug( "Writing doclink did not work" );
803 } 805 }
804 d->selectedFiles->addToSelection( lnk ); 806 d->selectedFiles->addToSelection( lnk );
805 } 807 }
806 } 808 }
807 if( fileDlg ) { 809 if( fileDlg ) {
808 delete fileDlg; 810 delete fileDlg;
809 } 811 }
810} 812}
811 813
812void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) { 814void PlayListWidget::keyReleaseEvent( QKeyEvent *e ) {
813 switch ( e->key() ) { 815 switch ( e->key() ) {
814 ////////////////////////////// Zaurus keys 816 ////////////////////////////// Zaurus keys
815 case Key_F9: //activity 817 case Key_F9: //activity
816 // if(audioUI->isHidden()) 818 // if(audioUI->isHidden())
817 // audioUI->showMaximized(); 819 // audioUI->showMaximized();
818 break; 820 break;
819 case Key_F10: //contacts 821 case Key_F10: //contacts
820 // if( videoUI->isHidden()) 822 // if( videoUI->isHidden())
821 // videoUI->showMaximized(); 823 // videoUI->showMaximized();
822 break; 824 break;
823 case Key_F11: //menu 825 case Key_F11: //menu
824 break; 826 break;
825 case Key_F12: //home 827 case Key_F12: //home
826 // doBlank(); 828 // doBlank();
827 break; 829 break;
828 case Key_F13: //mail 830 case Key_F13: //mail
829 // doUnblank(); 831 // doUnblank();
830 break; 832 break;
831 case Key_Q: //add to playlist 833 case Key_Q: //add to playlist
832 addSelected(); 834 addSelected();
833 break; 835 break;
834 case Key_R: //remove from playlist 836 case Key_R: //remove from playlist
835 removeSelected(); 837 removeSelected();
836 break; 838 break;
837 // case Key_P: //play 839 // case Key_P: //play
838 // qDebug("Play"); 840 // qDebug("Play");
839 // playSelected(); 841 // playSelected();
840 // break; 842 // break;
841 case Key_Space: 843 case Key_Space:
842 // playSelected(); puh 844 // playSelected(); puh
843 break; 845 break;
844 case Key_1: 846 case Key_1:
845 tabWidget->setCurrentPage( 0 ); 847 tabWidget->setCurrentPage( 0 );
846 break; 848 break;
847 case Key_2: 849 case Key_2:
848 tabWidget->setCurrentPage( 1 ); 850 tabWidget->setCurrentPage( 1 );
849 break; 851 break;
850 case Key_3: 852 case Key_3:
851 tabWidget->setCurrentPage( 2 ); 853 tabWidget->setCurrentPage( 2 );
852 break; 854 break;
853 case Key_4: 855 case Key_4:
854 tabWidget->setCurrentPage( 3 ); 856 tabWidget->setCurrentPage( 3 );
855 break; 857 break;
856 case Key_Down: 858 case Key_Down:
857 if ( !d->selectedFiles->next() ) 859 if ( !d->selectedFiles->next() )
858 d->selectedFiles->first(); 860 d->selectedFiles->first();
859 861
860 break; 862 break;
861 case Key_Up: 863 case Key_Up:
862 if ( !d->selectedFiles->prev() ) 864 if ( !d->selectedFiles->prev() )
863 // d->selectedFiles->last(); 865 // d->selectedFiles->last();
864 866
865 break; 867 break;
866 868
867 } 869 }
868} 870}
869 871
870void PlayListWidget::readm3u( const QString &filename ) { 872void PlayListWidget::readm3u( const QString &filename ) {
871 qDebug( "m3u filename is " + filename ); 873 qDebug( "m3u filename is " + filename );
872 QFile f( filename ); 874 QFile f( filename );
873 875
874 if( f.open( IO_ReadOnly ) ) { 876 if( f.open( IO_ReadOnly ) ) {
875 QTextStream t(&f); 877 QTextStream t(&f);
876 QString s;//, first, second; 878 QString s;//, first, second;
877 int i=0; 879 int i=0;
878 while ( !t.atEnd() ) { 880 while ( !t.atEnd() ) {
879 s=t.readLine(); 881 s=t.readLine();
880 882
881 if( s.find( "#", 0, TRUE) == -1 ) { 883 if( s.find( "#", 0, TRUE) == -1 ) {
882 if( s.find( " ", 0, TRUE) == -1 ) { // not sure if this is neede since cf uses vfat 884 if( s.find( " ", 0, TRUE) == -1 ) { // not sure if this is neede since cf uses vfat
883 if( s.left(2) == "E:" || s.left(2) == "P:" ) { 885 if( s.left(2) == "E:" || s.left(2) == "P:" ) {
884 s = s.right( s.length() -2 ); 886 s = s.right( s.length() -2 );
885 DocLnk lnk( s ); 887 DocLnk lnk( s );
886 QFileInfo f( s ); 888 QFileInfo f( s );
887 QString name = f.baseName(); 889 QString name = f.baseName();
888 name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); 890 name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 );
889 lnk.setName( name ); 891 lnk.setName( name );
890 s=s.replace( QRegExp( "\\" ), "/" ); 892 s=s.replace( QRegExp( "\\" ), "/" );
891 lnk.setFile( s ); 893 lnk.setFile( s );
892 lnk.writeLink(); 894 lnk.writeLink();
893 qDebug( "add " + name); 895 qDebug( "add " + name);
894 d->selectedFiles->addToSelection( lnk ); 896 d->selectedFiles->addToSelection( lnk );
895 } else { // is url 897 } else { // is url
896 s.replace( QRegExp( "%20" )," " ); 898 s.replace( QRegExp( "%20" )," " );
897 DocLnk lnk( s ); 899 DocLnk lnk( s );
898 QString name; 900 QString name;
899 if( name.left( 4 ) == "http" ) { 901 if( name.left( 4 ) == "http" ) {
900 name = s.right( s.length() - 7 ); 902 name = s.right( s.length() - 7 );
901 } else { 903 } else {
902 name = s; 904 name = s;
903 } 905 }
904 lnk.setName( name ); 906 lnk.setName( name );
905 if( s.at( s.length() - 4) == '.' ) { 907 if( s.at( s.length() - 4) == '.' ) {
906 lnk.setFile( s ); 908 lnk.setFile( s );
907 } else { 909 } else {
908 lnk.setFile( s + "/" ); 910 lnk.setFile( s + "/" );
909 } 911 }
910 lnk.setType( "audio/x-mpegurl" ); 912 lnk.setType( "audio/x-mpegurl" );
911 lnk.writeLink(); 913 lnk.writeLink();
912 d->selectedFiles->addToSelection( lnk ); 914 d->selectedFiles->addToSelection( lnk );
913 } 915 }
914 i++; 916 i++;
915 } 917 }
916 } 918 }
917 } 919 }
918 } 920 }
919 f.close(); 921 f.close();
920} 922}
921 923
922void PlayListWidget::writem3u() { 924void PlayListWidget::writem3u() {
923 InputDialog *fileDlg; 925 InputDialog *fileDlg;
924 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0); 926 fileDlg = new InputDialog( this, tr( "Save m3u Playlist " ), TRUE, 0);
925 fileDlg->exec(); 927 fileDlg->exec();
926 QString filename, list; 928 QString filename, list;
927 if( fileDlg->result() == 1 ) { 929 if( fileDlg->result() == 1 ) {
928 filename = fileDlg->text(); 930 filename = fileDlg->text();
929 qDebug( filename ); 931 qDebug( filename );
930 int noOfFiles = 0; 932 int noOfFiles = 0;
931 d->selectedFiles->first(); 933 d->selectedFiles->first();
932 do { 934 do {
933 // we dont check for existance because of url's 935 // we dont check for existance because of url's
934 // qDebug(d->selectedFiles->current()->file()); 936 // qDebug(d->selectedFiles->current()->file());
935 937
936 // so maybe we should do some net checking to ,-) 938 // so maybe we should do some net checking to ,-)
937 // no, cause it takes to long... 939 // no, cause it takes to long...
938 940
939 list += d->selectedFiles->current()->file() + "\n"; 941 list += d->selectedFiles->current()->file() + "\n";
940 noOfFiles++; 942 noOfFiles++;
941 } 943 }
942 while ( d->selectedFiles->next() ); 944 while ( d->selectedFiles->next() );
943 qDebug( list ); 945 qDebug( list );
944 if( filename.left( 1) != "/" ) { 946 if( filename.left( 1) != "/" ) {
945 filename=QPEApplication::documentDir() + "/" + filename; 947 filename=QPEApplication::documentDir() + "/" + filename;
946 } 948 }
947 if( filename.right( 3 ) != "m3u" ) { 949 if( filename.right( 3 ) != "m3u" ) {
948 filename=filename+".m3u"; 950 filename=filename+".m3u";
949 } 951 }
950 QFile f( filename ); 952 QFile f( filename );
951 f.open( IO_WriteOnly ); 953 f.open( IO_WriteOnly );
952 f.writeBlock( list, list.length() ); 954 f.writeBlock( list, list.length() );
953 f.close(); 955 f.close();
954 } 956 }
955 if( fileDlg ) { 957 if( fileDlg ) {
956 delete fileDlg; 958 delete fileDlg;
957 } 959 }
958} 960}
959 961
960void PlayListWidget::readPls( const QString &filename ) { 962void PlayListWidget::readPls( const QString &filename ) {
961 963
962 qDebug( "pls filename is " + filename ); 964 qDebug( "pls filename is " + filename );
963 QFile f( filename ); 965 QFile f( filename );
964 966
965 if( f.open( IO_ReadOnly ) ) { 967 if( f.open( IO_ReadOnly ) ) {
966 QTextStream t( &f ); 968 QTextStream t( &f );
967 QString s;//, first, second; 969 QString s;//, first, second;
968 int i = 0; 970 int i = 0;
969 while ( !t.atEnd() ) { 971 while ( !t.atEnd() ) {
970 s = t.readLine(); 972 s = t.readLine();
971 if( s.left(4) == "File" ) { 973 if( s.left(4) == "File" ) {
972 s = s.right( s.length() - 6 ); 974 s = s.right( s.length() - 6 );
973 s.replace( QRegExp( "%20" )," "); 975 s.replace( QRegExp( "%20" )," ");
974 qDebug( "adding " + s + " to playlist" ); 976 qDebug( "adding " + s + " to playlist" );
975 // numberofentries=2 977 // numberofentries=2
976 // File1=http 978 // File1=http
977 // Title 979 // Title
978 // Length 980 // Length
979 // Version 981 // Version
980 // File2=http 982 // File2=http
981 s = s.replace( QRegExp( "\\" ), "/" ); 983 s = s.replace( QRegExp( "\\" ), "/" );
982 DocLnk lnk( s ); 984 DocLnk lnk( s );
983 QFileInfo f( s ); 985 QFileInfo f( s );
984 QString name = f.baseName(); 986 QString name = f.baseName();
985 if( name.left( 4 ) == "http" ) { 987 if( name.left( 4 ) == "http" ) {
986 name = s.right( s.length() - 7); 988 name = s.right( s.length() - 7);
987 } else { 989 } else {
988 name = s; 990 name = s;
989 } 991 }
990 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); 992 name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 );
991 lnk.setName( name ); 993 lnk.setName( name );
992 if( s.at( s.length() - 4) == '.') // if this is probably a file 994 if( s.at( s.length() - 4) == '.') // if this is probably a file
993 lnk.setFile( s ); 995 lnk.setFile( s );
994 else { //if its a url 996 else { //if its a url
995 if( name.right( 1 ).find( '/' ) == -1) { 997 if( name.right( 1 ).find( '/' ) == -1) {
996 s += "/"; 998 s += "/";
997 } 999 }
998 lnk.setFile( s ); 1000 lnk.setFile( s );
999 } 1001 }
1000 lnk.setType( "audio/x-mpegurl" ); 1002 lnk.setType( "audio/x-mpegurl" );
1001 1003
1002 //qDebug("DocLnk add "+name); 1004 //qDebug("DocLnk add "+name);
1003 d->selectedFiles->addToSelection( lnk ); 1005 d->selectedFiles->addToSelection( lnk );
1004 } 1006 }
1005 } 1007 }
1006 i++; 1008 i++;
1007 } 1009 }
1008} 1010}
1009 1011
1010void PlayListWidget::pmViewActivated(int index) { 1012void PlayListWidget::pmViewActivated(int index) {
1011// qDebug("%d", index); 1013// qDebug("%d", index);
1012 switch(index) { 1014 switch(index) {
1013 case -16: 1015 case -16:
1014 { 1016 {
1015 mediaPlayerState->toggleFullscreen(); 1017 mediaPlayerState->toggleFullscreen();
1016 bool b=mediaPlayerState->fullscreen(); 1018 bool b=mediaPlayerState->fullscreen();
1017 pmView->setItemChecked( index, b); 1019 pmView->setItemChecked( index, b);
1018 Config cfg( "OpiePlayer" ); 1020 Config cfg( "OpiePlayer" );
1019 cfg.writeEntry( "FullScreen", b ); 1021 cfg.writeEntry( "FullScreen", b );
1020 } 1022 }
1021 break; 1023 break;
1022 }; 1024 };
1023} 1025}
1024 1026
1025void PlayListWidget::populateSkinsMenu() { 1027void PlayListWidget::populateSkinsMenu() {
1026 int item = 0; 1028 int item = 0;
1027 defaultSkinIndex = 0; 1029 defaultSkinIndex = 0;
1028 QString skinName; 1030 QString skinName;
1029 Config cfg( "OpiePlayer" ); 1031 Config cfg( "OpiePlayer" );
1030 cfg.setGroup("Options" ); 1032 cfg.setGroup("Options" );
1031 QString skin = cfg.readEntry( "Skin", "default" ); 1033 QString skin = cfg.readEntry( "Skin", "default" );
1032 1034
1033 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" ); 1035 QDir skinsDir( QPEApplication::qpeDir() + "/pics/opieplayer2/skins" );
1034 skinsDir.setFilter( QDir::Dirs ); 1036 skinsDir.setFilter( QDir::Dirs );
1035 skinsDir.setSorting(QDir::Name ); 1037 skinsDir.setSorting(QDir::Name );
1036 const QFileInfoList *skinslist = skinsDir.entryInfoList(); 1038 const QFileInfoList *skinslist = skinsDir.entryInfoList();
1037 QFileInfoListIterator it( *skinslist ); 1039 QFileInfoListIterator it( *skinslist );
1038 QFileInfo *fi; 1040 QFileInfo *fi;
1039 while ( ( fi = it.current() ) ) { 1041 while ( ( fi = it.current() ) ) {
1040 skinName = fi->fileName(); 1042 skinName = fi->fileName();
1041 qDebug( fi->fileName() ); 1043 qDebug( fi->fileName() );
1042 if( skinName != "." && skinName != ".." && skinName !="CVS" ) { 1044 if( skinName != "." && skinName != ".." && skinName !="CVS" ) {
1043 item = skinsMenu->insertItem( fi->fileName() ) ; 1045 item = skinsMenu->insertItem( fi->fileName() ) ;
1044 } 1046 }
1045 if( skinName == "default" ) { 1047 if( skinName == "default" ) {
1046 defaultSkinIndex = item; 1048 defaultSkinIndex = item;
1047 } 1049 }
1048 if( skinName == skin ) { 1050 if( skinName == skin ) {
1049 skinsMenu->setItemChecked( item, TRUE ); 1051 skinsMenu->setItemChecked( item, TRUE );
1050 } 1052 }
1051 ++it; 1053 ++it;
1052 } 1054 }
1053} 1055}
1054 1056
1055void PlayListWidget::skinsMenuActivated( int item ) { 1057void PlayListWidget::skinsMenuActivated( int item ) {
1056 for( uint i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) { 1058 for( uint i = defaultSkinIndex; i > defaultSkinIndex - skinsMenu->count(); i-- ) {
1057 skinsMenu->setItemChecked( i, FALSE ); 1059 skinsMenu->setItemChecked( i, FALSE );
1058 } 1060 }
1059 skinsMenu->setItemChecked( item, TRUE ); 1061 skinsMenu->setItemChecked( item, TRUE );
1060 1062
1061 Config cfg( "OpiePlayer" ); 1063 Config cfg( "OpiePlayer" );
1062 cfg.setGroup("Options"); 1064 cfg.setGroup("Options");
1063 cfg.writeEntry("Skin", skinsMenu->text( item ) ); 1065 cfg.writeEntry("Skin", skinsMenu->text( item ) );
1064} 1066}
1067
1068int PlayListWidget::whichList() {
1069 return tabWidget->currentPageIndex();
1070}
1071
1072QString PlayListWidget::currentFileListPathName() {
1073 switch (whichList()) {
1074 case 1:
1075 return audioView->currentItem()->text(3);
1076 break;
1077 case 2:
1078 return videoView->currentItem()->text(3);
1079 break;
1080 };
1081 return "";
1082}
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.h b/noncore/multimedia/opieplayer2/playlistwidget.h
index dcfdd48..2873dca 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.h
+++ b/noncore/multimedia/opieplayer2/playlistwidget.h
@@ -1,120 +1,121 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef PLAY_LIST_WIDGET_H 34#ifndef PLAY_LIST_WIDGET_H
35#define PLAY_LIST_WIDGET_H 35#define PLAY_LIST_WIDGET_H
36 36
37#include <qmainwindow.h> 37#include <qmainwindow.h>
38#include <qpe/applnk.h> 38#include <qpe/applnk.h>
39#include <qtabwidget.h> 39#include <qtabwidget.h>
40#include <qpe/fileselector.h> 40#include <qpe/fileselector.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qpopupmenu.h> 42#include <qpopupmenu.h>
43 43
44#include "playlistwidgetgui.h" 44#include "playlistwidgetgui.h"
45 45
46 46
47//class PlayListWidgetPrivate; 47//class PlayListWidgetPrivate;
48class Config; 48class Config;
49class QListViewItem; 49class QListViewItem;
50class QListView; 50class QListView;
51class QPoint; 51class QPoint;
52class QAction; 52class QAction;
53class QLabel; 53class QLabel;
54 54
55class PlayListWidget : public PlayListWidgetGui { 55class PlayListWidget : public PlayListWidgetGui {
56 Q_OBJECT 56 Q_OBJECT
57public: 57public:
58 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); 58 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 );
59 ~PlayListWidget(); 59 ~PlayListWidget();
60 DocLnkSet files; 60 DocLnkSet files;
61 DocLnkSet vFiles; 61 DocLnkSet vFiles;
62 bool fromSetDocument; 62 bool fromSetDocument;
63 bool insanityBool; 63 bool insanityBool;
64 QString setDocFileRef; 64 QString setDocFileRef;
65 // retrieve the current playlist entry (media file link) 65 // retrieve the current playlist entry (media file link)
66 const DocLnk *current(); 66 const DocLnk *current();
67 void useSelectedDocument(); 67 void useSelectedDocument();
68 int selected; 68 int selected;
69 int whichList();
69 70
70public slots: 71public slots:
71 bool first(); 72 bool first();
72 bool last(); 73 bool last();
73 bool next(); 74 bool next();
74 bool prev(); 75 bool prev();
75 void writeConfig( Config& cfg ) const; 76 void writeConfig( Config& cfg ) const;
76 77 QString currentFileListPathName();
77protected: 78protected:
78 void keyReleaseEvent( QKeyEvent *e); 79 void keyReleaseEvent( QKeyEvent *e);
79 80
80private: 81private:
81 int defaultSkinIndex; 82 int defaultSkinIndex;
82 bool audioScan, videoScan; 83 bool audioScan, videoScan;
83 void readm3u(const QString &); 84 void readm3u(const QString &);
84 void readPls(const QString &); 85 void readPls(const QString &);
85 void initializeStates(); 86 void initializeStates();
86 void readConfig( Config& cfg ); 87 void readConfig( Config& cfg );
87 void populateAudioView(); 88 void populateAudioView();
88 void populateVideoView(); 89 void populateVideoView();
89 90
90private slots: 91private slots:
91 void populateSkinsMenu(); 92 void populateSkinsMenu();
92 void skinsMenuActivated(int); 93 void skinsMenuActivated(int);
93 void pmViewActivated(int); 94 void pmViewActivated(int);
94 void writem3u(); 95 void writem3u();
95 void scanForAudio(); 96 void scanForAudio();
96 void scanForVideo(); 97 void scanForVideo();
97 void openFile(); 98 void openFile();
98 void setDocument( const QString& fileref ); 99 void setDocument( const QString& fileref );
99 void addToSelection( const DocLnk& ); // Add a media file to the playlist 100 void addToSelection( const DocLnk& ); // Add a media file to the playlist
100 void addToSelection( QListViewItem* ); // Add a media file to the playlist 101 void addToSelection( QListViewItem* ); // Add a media file to the playlist
101 void setPlaylist( bool ); // Show/Hide the playlist 102 void setPlaylist( bool ); // Show/Hide the playlist
102 void clearList(); 103 void clearList();
103 void addAllToList(); 104 void addAllToList();
104 void addAllMusicToList(); 105 void addAllMusicToList();
105 void addAllVideoToList(); 106 void addAllVideoToList();
106 void saveList(); // Save the playlist 107 void saveList(); // Save the playlist
107 void loadList( const DocLnk &); // Load a playlist 108 void loadList( const DocLnk &); // Load a playlist
108 void playIt( QListViewItem *); 109 void playIt( QListViewItem *);
109 void btnPlay(bool); 110 void btnPlay(bool);
110 void deletePlaylist(); 111 void deletePlaylist();
111 void addSelected(); 112 void addSelected();
112 void removeSelected(); 113 void removeSelected();
113 void tabChanged(QWidget*); 114 void tabChanged(QWidget*);
114 void viewPressed( int, QListViewItem *, const QPoint&, int); 115 void viewPressed( int, QListViewItem *, const QPoint&, int);
115 void playlistViewPressed( int, QListViewItem *, const QPoint&, int); 116 void playlistViewPressed( int, QListViewItem *, const QPoint&, int);
116 void playSelected(); 117 void playSelected();
117}; 118};
118 119
119#endif // PLAY_LIST_WIDGET_H 120#endif // PLAY_LIST_WIDGET_H
120 121
diff --git a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp
index 250833c..f073102 100644
--- a/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidgetgui.cpp
@@ -1,226 +1,228 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; General Public License for more 22..}^=.=       =       ; General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = General Public License along with 26  -_. . .   )=.  = General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include <qpe/qpemenubar.h> 34#include <qpe/qpemenubar.h>
35#include <qpe/qpetoolbar.h> 35#include <qpe/qpetoolbar.h>
36#include <qpe/fileselector.h> 36#include <qpe/fileselector.h>
37#include <qpe/qpeapplication.h> 37#include <qpe/qpeapplication.h>
38#include <qpe/storage.h> 38#include <qpe/storage.h>
39#include <qpe/mimetype.h> 39#include <qpe/mimetype.h>
40#include <qpe/config.h> 40#include <qpe/config.h>
41#include <qpe/global.h> 41#include <qpe/global.h>
42#include <qpe/resource.h> 42#include <qpe/resource.h>
43 43
44#include <qpopupmenu.h> 44#include <qpopupmenu.h>
45#include <qaction.h> 45#include <qaction.h>
46#include <qcursor.h> 46#include <qcursor.h>
47#include <qdir.h> 47#include <qdir.h>
48#include <qlayout.h> 48#include <qlayout.h>
49 49
50#include "playlistselection.h" 50#include "playlistselection.h"
51#include "playlistwidget.h" 51#include "playlistwidget.h"
52#include "mediaplayerstate.h" 52#include "mediaplayerstate.h"
53#include "inputDialog.h" 53#include "inputDialog.h"
54 54
55//only needed for the random play 55//only needed for the random play
56#include <stdlib.h> 56#include <stdlib.h>
57 57
58#include "audiowidget.h" 58#include "audiowidget.h"
59#include "videowidget.h" 59#include "videowidget.h"
60#include "mediaplayerstate.h" 60#include "mediaplayerstate.h"
61 61
62extern MediaPlayerState *mediaPlayerState; 62extern MediaPlayerState *mediaPlayerState;
63 63
64PlayListWidgetGui::PlayListWidgetGui( QWidget* parent, const char* name, WFlags fl ) 64PlayListWidgetGui::PlayListWidgetGui( QWidget* parent, const char* name, WFlags fl )
65 : QMainWindow( parent, name, fl ) { 65 : QMainWindow( parent, name, fl ) {
66 66
67 d = new PlayListWidgetPrivate; 67 d = new PlayListWidgetPrivate;
68 d->setDocumentUsed = FALSE; 68 d->setDocumentUsed = FALSE;
69 d->current = NULL; 69 d->current = NULL;
70 70
71 setBackgroundMode( PaletteButton ); 71 setBackgroundMode( PaletteButton );
72 setToolBarsMovable( FALSE ); 72 setToolBarsMovable( FALSE );
73 73
74 // Create Toolbar 74 // Create Toolbar
75 QPEToolBar *toolbar = new QPEToolBar( this ); 75 QPEToolBar *toolbar = new QPEToolBar( this );
76 toolbar->setHorizontalStretchable( TRUE ); 76 toolbar->setHorizontalStretchable( TRUE );
77 77
78 // Create Menubar 78 // Create Menubar
79 QPEMenuBar *menu = new QPEMenuBar( toolbar ); 79 QPEMenuBar *menu = new QPEMenuBar( toolbar );
80 menu->setMargin( 0 ); 80 menu->setMargin( 0 );
81 81
82 bar = new QPEToolBar( this ); 82 bar = new QPEToolBar( this );
83 bar->setLabel( tr( "Play Operations" ) ); 83 bar->setLabel( tr( "Play Operations" ) );
84 84
85 tbDeletePlaylist = new QPushButton( Resource::loadIconSet( "trash" ), "", bar, "close" ); 85 tbDeletePlaylist = new QPushButton( Resource::loadIconSet( "trash" ), "", bar, "close" );
86 tbDeletePlaylist->setFlat( TRUE ); 86 tbDeletePlaylist->setFlat( TRUE );
87 tbDeletePlaylist->setFixedSize( 20, 20 ); 87 tbDeletePlaylist->setFixedSize( 20, 20 );
88 88
89 tbDeletePlaylist->hide(); 89 tbDeletePlaylist->hide();
90 90
91 pmPlayList = new QPopupMenu( this ); 91 pmPlayList = new QPopupMenu( this );
92 menu->insertItem( tr( "File" ), pmPlayList ); 92 menu->insertItem( tr( "File" ), pmPlayList );
93 93
94 pmView = new QPopupMenu( this ); 94 pmView = new QPopupMenu( this );
95 menu->insertItem( tr( "View" ), pmView ); 95 menu->insertItem( tr( "View" ), pmView );
96 pmView->isCheckable(); 96 pmView->isCheckable();
97 97
98 skinsMenu = new QPopupMenu( this ); 98 skinsMenu = new QPopupMenu( this );
99 pmView->insertItem( tr( "Skins" ), skinsMenu ); 99 pmView->insertItem( tr( "Skins" ), skinsMenu );
100 skinsMenu->isCheckable(); 100 skinsMenu->isCheckable();
101 101
102 gammaMenu = new QPopupMenu( this ); 102 gammaMenu = new QPopupMenu( this );
103 pmView->insertItem( tr( "Gamma" ), gammaMenu ); 103 pmView->insertItem( tr( "Gamma" ), gammaMenu );
104 gammaMenu->setMinimumHeight( 50 ); 104 gammaMenu->setMinimumHeight( 50 );
105 105
106 gammaSlider = new QSlider( QSlider::Vertical, gammaMenu ); 106 gammaSlider = new QSlider( QSlider::Vertical, gammaMenu );
107 gammaSlider->setRange( -100, 100 ); 107 gammaSlider->setRange( -100, 100 );
108 gammaSlider->setTickmarks( QSlider::Left ); 108 gammaSlider->setTickmarks( QSlider::Left );
109 gammaSlider->setTickInterval( 20 ); 109 gammaSlider->setTickInterval( 20 );
110 gammaSlider->setFocusPolicy( QWidget::NoFocus ); 110 gammaSlider->setFocusPolicy( QWidget::NoFocus );
111 gammaSlider->setValue( 0 ); 111 gammaSlider->setValue( 0 );
112 gammaSlider->setMinimumHeight( 50 ); 112 gammaSlider->setMinimumHeight( 50 );
113 113
114 gammaLCD = new QLCDNumber( 3, gammaMenu ); 114 gammaLCD = new QLCDNumber( 3, gammaMenu );
115 115
116 gammaMenu->insertItem( gammaSlider ); 116 gammaMenu->insertItem( gammaSlider );
117 gammaMenu->insertItem( gammaLCD ); 117 gammaMenu->insertItem( gammaLCD );
118 118
119 connect( gammaSlider, SIGNAL( valueChanged( int ) ), gammaLCD, SLOT( display( int ) ) ); 119 connect( gammaSlider, SIGNAL( valueChanged( int ) ), gammaLCD, SLOT( display( int ) ) );
120 120
121 vbox5 = new QVBox( this ); 121 vbox5 = new QVBox( this );
122 QVBox *vbox4 = new QVBox( vbox5 ); 122 QVBox *vbox4 = new QVBox( vbox5 );
123 QHBox *hbox6 = new QHBox( vbox4 ); 123 QHBox *hbox6 = new QHBox( vbox4 );
124 124
125 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 125 tabWidget = new QTabWidget( hbox6, "tabWidget" );
126 126
127 QWidget *pTab; 127 QWidget *pTab;
128 pTab = new QWidget( tabWidget, "pTab" ); 128 pTab = new QWidget( tabWidget, "pTab" );
129 tabWidget->insertTab( pTab, "Playlist"); 129 tabWidget->insertTab( pTab, "Playlist");
130 130
131 QGridLayout *Playout = new QGridLayout( pTab ); 131 QGridLayout *Playout = new QGridLayout( pTab );
132 Playout->setSpacing( 2); 132 Playout->setSpacing( 2);
133 Playout->setMargin( 2); 133 Playout->setMargin( 2);
134 134
135 // Add the playlist area 135 // Add the playlist area
136 QVBox *vbox3 = new QVBox( pTab ); 136 QVBox *vbox3 = new QVBox( pTab );
137 d->playListFrame = vbox3; 137 d->playListFrame = vbox3;
138 138
139 QHBox *hbox2 = new QHBox( vbox3 ); 139 QHBox *hbox2 = new QHBox( vbox3 );
140 d->selectedFiles = new PlayListSelection( hbox2 ); 140 d->selectedFiles = new PlayListSelection( hbox2 );
141 141
142 vbox1 = new QVBox( hbox2 ); 142 vbox1 = new QVBox( hbox2 );
143 QPEApplication::setStylusOperation( d->selectedFiles->viewport(), QPEApplication::RightOnHold ); 143 QPEApplication::setStylusOperation( d->selectedFiles->viewport(), QPEApplication::RightOnHold );
144 QVBox *stretch1 = new QVBox( vbox1 ); // add stretch 144 QVBox *stretch1 = new QVBox( vbox1 ); // add stretch
145 145
146 Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 ); 146 Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 );
147 147
148 QWidget *aTab; 148 QWidget *aTab;
149 aTab = new QWidget( tabWidget, "aTab" ); 149 aTab = new QWidget( tabWidget, "aTab" );
150 150
151 QGridLayout *Alayout = new QGridLayout( aTab ); 151 QGridLayout *Alayout = new QGridLayout( aTab );
152 Alayout->setSpacing( 2 ); 152 Alayout->setSpacing( 2 );
153 Alayout->setMargin( 2 ); 153 Alayout->setMargin( 2 );
154 audioView = new QListView( aTab, "Audioview" ); 154 audioView = new QListView( aTab, "Audioview" );
155 audioView->addColumn( tr( "Title" ), 140 ); 155 audioView->addColumn( tr( "Title" ), 140 );
156 audioView->addColumn( tr( "Size" ), -1 ); 156 audioView->addColumn( tr( "Size" ), -1 );
157 audioView->addColumn( tr( "Media" ), -1 ); 157 audioView->addColumn( tr( "Media" ), -1 );
158 audioView->addColumn( tr( "Path" ), 0 );
158 audioView->setColumnAlignment( 1, Qt::AlignRight ); 159 audioView->setColumnAlignment( 1, Qt::AlignRight );
159 audioView->setColumnAlignment( 2, Qt::AlignRight ); 160 audioView->setColumnAlignment( 2, Qt::AlignRight );
160 audioView->setAllColumnsShowFocus( TRUE ); 161 audioView->setAllColumnsShowFocus( TRUE );
161 audioView->setSorting( 0, TRUE ); 162 audioView->setSorting( 0, TRUE );
162 audioView->setMultiSelection( TRUE ); 163 audioView->setMultiSelection( TRUE );
163 audioView->setSelectionMode( QListView::Extended ); 164 audioView->setSelectionMode( QListView::Extended );
164 Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 ); 165 Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 );
165 tabWidget->insertTab( aTab, tr( "Audio" ) ); 166 tabWidget->insertTab( aTab, tr( "Audio" ) );
166 167
167 QPEApplication::setStylusOperation( audioView->viewport(), QPEApplication::RightOnHold ); 168 QPEApplication::setStylusOperation( audioView->viewport(), QPEApplication::RightOnHold );
168 169
169 QWidget *vTab; 170 QWidget *vTab;
170 vTab = new QWidget( tabWidget, "vTab" ); 171 vTab = new QWidget( tabWidget, "vTab" );
171 172
172 QGridLayout *Vlayout = new QGridLayout( vTab ); 173 QGridLayout *Vlayout = new QGridLayout( vTab );
173 Vlayout->setSpacing( 2 ); 174 Vlayout->setSpacing( 2 );
174 Vlayout->setMargin( 2 ); 175 Vlayout->setMargin( 2 );
175 videoView = new QListView( vTab, "Videoview" ); 176 videoView = new QListView( vTab, "Videoview" );
176 videoView->addColumn( tr( "Title" ), 140); 177 videoView->addColumn( tr( "Title" ), 140);
177 videoView->addColumn( tr( "Size" ), -1 ); 178 videoView->addColumn( tr( "Size" ), -1 );
178 videoView->addColumn(tr( "Media" ), -1 ); 179 videoView->addColumn(tr( "Media" ), -1 );
180 videoView->addColumn(tr( "Path" ), 0 );
179 videoView->setColumnAlignment( 1, Qt::AlignRight ); 181 videoView->setColumnAlignment( 1, Qt::AlignRight );
180 videoView->setColumnAlignment( 2, Qt::AlignRight ); 182 videoView->setColumnAlignment( 2, Qt::AlignRight );
181 videoView->setAllColumnsShowFocus( TRUE ); 183 videoView->setAllColumnsShowFocus( TRUE );
182 videoView->setSorting( 0, TRUE ); 184 videoView->setSorting( 0, TRUE );
183 videoView->setMultiSelection( TRUE ); 185 videoView->setMultiSelection( TRUE );
184 videoView->setSelectionMode( QListView::Extended ); 186 videoView->setSelectionMode( QListView::Extended );
185 Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 ); 187 Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 );
186 188
187 QPEApplication::setStylusOperation( videoView->viewport(), QPEApplication::RightOnHold ); 189 QPEApplication::setStylusOperation( videoView->viewport(), QPEApplication::RightOnHold );
188 190
189 tabWidget->insertTab( vTab, tr( "Video" ) ); 191 tabWidget->insertTab( vTab, tr( "Video" ) );
190 192
191 //playlists list 193 //playlists list
192 QWidget *LTab; 194 QWidget *LTab;
193 LTab = new QWidget( tabWidget, "LTab" ); 195 LTab = new QWidget( tabWidget, "LTab" );
194 QGridLayout *Llayout = new QGridLayout( LTab ); 196 QGridLayout *Llayout = new QGridLayout( LTab );
195 Llayout->setSpacing( 2 ); 197 Llayout->setSpacing( 2 );
196 Llayout->setMargin( 2 ); 198 Llayout->setMargin( 2 );
197 199
198 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE ); //buggy 200 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE ); //buggy
199 Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 ); 201 Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 );
200 202
201 tabWidget->insertTab( LTab, tr( "Lists" ) ); 203 tabWidget->insertTab( LTab, tr( "Lists" ) );
202 204
203 setCentralWidget( vbox5 ); 205 setCentralWidget( vbox5 );
204} 206}
205 207
206 208
207 209
208PlayListWidgetGui::~PlayListWidgetGui() { 210PlayListWidgetGui::~PlayListWidgetGui() {
209} 211}
210 212
211void PlayListWidgetGui::setView( char view ) { 213void PlayListWidgetGui::setView( char view ) {
212 if ( view == 'l' ) 214 if ( view == 'l' )
213 showMaximized(); 215 showMaximized();
214 else 216 else
215 hide(); 217 hide();
216} 218}
217 219
218 220
219void PlayListWidgetGui::setActiveWindow() { 221void PlayListWidgetGui::setActiveWindow() {
220 // qDebug("SETTING active window"); 222 // qDebug("SETTING active window");
221 // When we get raised we need to ensure that it switches views 223 // When we get raised we need to ensure that it switches views
222 char origView = mediaPlayerState->view(); 224 char origView = mediaPlayerState->view();
223 mediaPlayerState->setView( 'l' ); // invalidate 225 mediaPlayerState->setView( 'l' ); // invalidate
224 mediaPlayerState->setView( origView ); // now switch back 226 mediaPlayerState->setView( origView ); // now switch back
225} 227}
226 228