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