summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-04-26 23:55:00 (UTC)
committer llornkcor <llornkcor>2002-04-26 23:55:00 (UTC)
commit8ca9c8dad17ccaee9b0b8132324176c2a8e40526 (patch) (unidiff)
tree2a6b7cf8a2d5a45d32065cde00ed8399b5ef91d8
parent75b32567bfeb67ed71877c4fa9e918c836a8a68b (diff)
downloadopie-8ca9c8dad17ccaee9b0b8132324176c2a8e40526.zip
opie-8ca9c8dad17ccaee9b0b8132324176c2a8e40526.tar.gz
opie-8ca9c8dad17ccaee9b0b8132324176c2a8e40526.tar.bz2
fixed playing from audio/video list. added images from config file
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/audiowidget.cpp26
-rw-r--r--core/multimedia/opieplayer/audiowidget.h3
-rw-r--r--core/multimedia/opieplayer/inputDialog.cpp29
-rw-r--r--core/multimedia/opieplayer/inputDialog.h7
-rw-r--r--core/multimedia/opieplayer/opieplayer.pro2
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp71
-rw-r--r--core/multimedia/opieplayer/playlistwidget.h6
-rw-r--r--core/multimedia/opieplayer/videowidget.cpp21
8 files changed, 97 insertions, 68 deletions
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp
index 94b979f..aa48961 100644
--- a/core/multimedia/opieplayer/audiowidget.cpp
+++ b/core/multimedia/opieplayer/audiowidget.cpp
@@ -1,362 +1,370 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21#include <qpe/resource.h> 21#include <qpe/resource.h>
22#include <qpe/config.h>
22 23
23#include <qwidget.h> 24#include <qwidget.h>
24#include <qpixmap.h> 25#include <qpixmap.h>
25#include <qbutton.h> 26#include <qbutton.h>
26#include <qpainter.h> 27#include <qpainter.h>
27#include <qframe.h> 28#include <qframe.h>
28#include <qlayout.h> 29#include <qlayout.h>
29 30
30#include "audiowidget.h" 31#include "audiowidget.h"
31#include "mediaplayerstate.h" 32#include "mediaplayerstate.h"
32 33
33extern MediaPlayerState *mediaPlayerState; 34extern MediaPlayerState *mediaPlayerState;
34 35
35 36
36static const int xo = -2; // movable x offset 37static const int xo = -2; // movable x offset
37static const int yo = 22; // movable y offset 38static const int yo = 22; // movable y offset
38 39
39 40
40struct MediaButton { 41struct MediaButton {
41 int xPos, yPos; 42 int xPos, yPos;
42 int color; 43 int color;
43 bool isToggle, isBig, isHeld, isDown; 44 bool isToggle, isBig, isHeld, isDown;
44}; 45};
45 46
46 47
47// Layout information for the audioButtons (and if it is a toggle button or not) 48// Layout information for the audioButtons (and if it is a toggle button or not)
48MediaButton audioButtons[] = { 49MediaButton audioButtons[] = {
49 { 3*30-15+xo, 3*30-13+yo, 0, TRUE, TRUE, FALSE, FALSE }, // play 50 { 3*30-15+xo, 3*30-13+yo, 0, TRUE, TRUE, FALSE, FALSE }, // play
50 { 1*30+xo, 5*30+yo, 2, FALSE, FALSE, FALSE, FALSE }, // stop 51 { 1*30+xo, 5*30+yo, 2, FALSE, FALSE, FALSE, FALSE }, // stop
51 { 5*30+xo, 5*30+yo, 2, TRUE, FALSE, FALSE, FALSE }, // pause 52 { 5*30+xo, 5*30+yo, 2, TRUE, FALSE, FALSE, FALSE }, // pause
52 { 6*30-5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // next 53 { 6*30-5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // next
53 { 0*30+5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // previous 54 { 0*30+5+xo, 3*30+yo, 1, FALSE, FALSE, FALSE, FALSE }, // previous
54 { 3*30+xo, 0*30+5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume up 55 { 3*30+xo, 0*30+5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume up
55 { 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down 56 { 3*30+xo, 6*30-5+yo, 3, FALSE, FALSE, FALSE, FALSE }, // volume down
56 { 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop 57 { 5*30+xo, 1*30+yo, 0, TRUE, FALSE, FALSE, FALSE }, // repeat/loop
57 { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist 58 { 1*30+xo, 1*30+yo, 0, FALSE, FALSE, FALSE, FALSE } // playlist
58}; 59};
59 60
60 61
61static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); 62static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
62 63
63 64
64AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : 65AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
65 QWidget( parent, name, f ) 66 QWidget( parent, name, f )
66{ 67{
67 setCaption( tr("OpiePlayer") ); 68 setCaption( tr("OpiePlayer") );
68 69 Config cfg("OpiePlayer");
70 cfg.setGroup("AudioWidget");
69// QGridLayout *layout = new QGridLayout( this ); 71// QGridLayout *layout = new QGridLayout( this );
70// layout->setSpacing( 2); 72// layout->setSpacing( 2);
71// layout->setMargin( 2); 73// layout->setMargin( 2);
72 74 QString backgroundPix, buttonsAllPix, buttonsBigPix, controlsPix, animatedPix;
73 setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); 75 backgroundPix=cfg.readEntry( " backgroundPix", "opieplayer/metalFinish");
74 pixmaps[0] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaButtonsAll" ) ); 76 buttonsAllPix=cfg.readEntry( "buttonsAllPix","opieplayer/mediaButtonsAll");
75 pixmaps[1] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaButtonsBig" ) ); 77 buttonsBigPix=cfg.readEntry( "buttonsBigPix","opieplayer/mediaButtonsBig");
76 pixmaps[2] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaControls" ) ); 78 controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls");
77 pixmaps[3] = new QPixmap( Resource::loadPixmap( "opieplayer/animatedButton" ) ); 79 animatedPix=cfg.readEntry( "animatedPix", "opieplayer/animatedButton");
80
81 setBackgroundPixmap( Resource::loadPixmap( backgroundPix) );
82 pixmaps[0] = new QPixmap( Resource::loadPixmap( buttonsAllPix ) );
83 pixmaps[1] = new QPixmap( Resource::loadPixmap( buttonsBigPix ) );
84 pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix ) );
85 pixmaps[3] = new QPixmap( Resource::loadPixmap( animatedPix) );
78 86
79 songInfo = new Ticker( this ); 87 songInfo = new Ticker( this );
80 songInfo->setFocusPolicy( QWidget::NoFocus ); 88 songInfo->setFocusPolicy( QWidget::NoFocus );
81 songInfo->setGeometry( QRect( 7, 3, 220, 20 ) ); 89 songInfo->setGeometry( QRect( 7, 3, 220, 20 ) );
82// layout->addMultiCellWidget( songInfo, 0, 0, 0, 2 ); 90// layout->addMultiCellWidget( songInfo, 0, 0, 0, 2 );
83 91
84 slider = new QSlider( Qt::Horizontal, this ); 92 slider = new QSlider( Qt::Horizontal, this );
85 slider->setFixedWidth( 220 ); 93 slider->setFixedWidth( 220 );
86 slider->setFixedHeight( 20 ); 94 slider->setFixedHeight( 20 );
87 slider->setMinValue( 0 ); 95 slider->setMinValue( 0 );
88 slider->setMaxValue( 1 ); 96 slider->setMaxValue( 1 );
89 slider->setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); 97 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
90 slider->setFocusPolicy( QWidget::NoFocus ); 98 slider->setFocusPolicy( QWidget::NoFocus );
91 slider->setGeometry( QRect( 7, 262, 220, 20 ) ); 99 slider->setGeometry( QRect( 7, 262, 220, 20 ) );
92 // layout->addMultiCellWidget( slider, 4, 4, 0, 2 ); 100 // layout->addMultiCellWidget( slider, 4, 4, 0, 2 );
93 101
94 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 102 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
95 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 103 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
96 104
97 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 105 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
98 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 106 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
99 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 107 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
100 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 108 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
101 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 109 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
102 110
103 // Intialise state 111 // Intialise state
104 setLength( mediaPlayerState->length() ); 112 setLength( mediaPlayerState->length() );
105 setPosition( mediaPlayerState->position() ); 113 setPosition( mediaPlayerState->position() );
106 setLooping( mediaPlayerState->fullscreen() ); 114 setLooping( mediaPlayerState->fullscreen() );
107 setPaused( mediaPlayerState->paused() ); 115 setPaused( mediaPlayerState->paused() );
108 setPlaying( mediaPlayerState->playing() ); 116 setPlaying( mediaPlayerState->playing() );
109 117
110} 118}
111 119
112 120
113AudioWidget::~AudioWidget() { 121AudioWidget::~AudioWidget() {
114 mediaPlayerState->isStreaming = FALSE; 122 mediaPlayerState->isStreaming = FALSE;
115 for ( int i = 0; i < 4; i++ ) 123 for ( int i = 0; i < 4; i++ )
116 delete pixmaps[i]; 124 delete pixmaps[i];
117} 125}
118 126
119 127
120static bool audioSliderBeingMoved = FALSE; 128static bool audioSliderBeingMoved = FALSE;
121 129
122 130
123void AudioWidget::sliderPressed() { 131void AudioWidget::sliderPressed() {
124 audioSliderBeingMoved = TRUE; 132 audioSliderBeingMoved = TRUE;
125} 133}
126 134
127 135
128void AudioWidget::sliderReleased() { 136void AudioWidget::sliderReleased() {
129 audioSliderBeingMoved = FALSE; 137 audioSliderBeingMoved = FALSE;
130 if ( slider->width() == 0 ) 138 if ( slider->width() == 0 )
131 return; 139 return;
132 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); 140 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width());
133 mediaPlayerState->setPosition( val ); 141 mediaPlayerState->setPosition( val );
134} 142}
135 143
136 144
137void AudioWidget::setPosition( long i ) { 145void AudioWidget::setPosition( long i ) {
138 updateSlider( i, mediaPlayerState->length() ); 146 updateSlider( i, mediaPlayerState->length() );
139} 147}
140 148
141 149
142void AudioWidget::setLength( long max ) { 150void AudioWidget::setLength( long max ) {
143 updateSlider( mediaPlayerState->position(), max ); 151 updateSlider( mediaPlayerState->position(), max );
144} 152}
145 153
146 154
147void AudioWidget::setView( char view ) { 155void AudioWidget::setView( char view ) {
148 156
149 if (mediaPlayerState->isStreaming) { 157 if (mediaPlayerState->isStreaming) {
150 if( !slider->isHidden()) slider->hide(); 158 if( !slider->isHidden()) slider->hide();
151 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 159 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
152 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 160 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
153 } else { 161 } else {
154// this stops the slider from being moved, thus 162// this stops the slider from being moved, thus
155 // does not stop stream when it reaches the end 163 // does not stop stream when it reaches the end
156 slider->show(); 164 slider->show();
157 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 165 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
158 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 166 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
159 } 167 }
160 168
161 if ( view == 'a' ) { 169 if ( view == 'a' ) {
162 startTimer( 150 ); 170 startTimer( 150 );
163// show(); 171// show();
164 showMaximized(); 172 showMaximized();
165 } else { 173 } else {
166 killTimers(); 174 killTimers();
167 hide(); 175 hide();
168 } 176 }
169} 177}
170 178
171 179
172void AudioWidget::updateSlider( long i, long max ) { 180void AudioWidget::updateSlider( long i, long max ) {
173 if ( max == 0 ) 181 if ( max == 0 )
174 return; 182 return;
175 // Will flicker too much if we don't do this 183 // Will flicker too much if we don't do this
176 // Scale to something reasonable 184 // Scale to something reasonable
177 int width = slider->width(); 185 int width = slider->width();
178 int val = int((double)i * width / max); 186 int val = int((double)i * width / max);
179 if ( !audioSliderBeingMoved ) { 187 if ( !audioSliderBeingMoved ) {
180 if ( slider->value() != val ) 188 if ( slider->value() != val )
181 slider->setValue( val ); 189 slider->setValue( val );
182 if ( slider->maxValue() != width ) 190 if ( slider->maxValue() != width )
183 slider->setMaxValue( width ); 191 slider->setMaxValue( width );
184 } 192 }
185} 193}
186 194
187 195
188void AudioWidget::setToggleButton( int i, bool down ) { 196void AudioWidget::setToggleButton( int i, bool down ) {
189 if ( down != audioButtons[i].isDown ) 197 if ( down != audioButtons[i].isDown )
190 toggleButton( i ); 198 toggleButton( i );
191} 199}
192 200
193 201
194void AudioWidget::toggleButton( int i ) { 202void AudioWidget::toggleButton( int i ) {
195 audioButtons[i].isDown = !audioButtons[i].isDown; 203 audioButtons[i].isDown = !audioButtons[i].isDown;
196 QPainter p(this); 204 QPainter p(this);
197 paintButton ( &p, i ); 205 paintButton ( &p, i );
198} 206}
199 207
200 208
201void AudioWidget::paintButton( QPainter *p, int i ) { 209void AudioWidget::paintButton( QPainter *p, int i ) {
202 int x = audioButtons[i].xPos; 210 int x = audioButtons[i].xPos;
203 int y = audioButtons[i].yPos; 211 int y = audioButtons[i].yPos;
204 int offset = 22 + 14 * audioButtons[i].isBig + audioButtons[i].isDown; 212 int offset = 22 + 14 * audioButtons[i].isBig + audioButtons[i].isDown;
205 int buttonSize = 64 + audioButtons[i].isBig * (90 - 64); 213 int buttonSize = 64 + audioButtons[i].isBig * (90 - 64);
206 p->drawPixmap( x, y, *pixmaps[audioButtons[i].isBig], buttonSize * (audioButtons[i].isDown + 2 * audioButtons[i].color), 0, buttonSize, buttonSize ); 214 p->drawPixmap( x, y, *pixmaps[audioButtons[i].isBig], buttonSize * (audioButtons[i].isDown + 2 * audioButtons[i].color), 0, buttonSize, buttonSize );
207 p->drawPixmap( x + offset, y + offset, *pixmaps[2], 18 * i, 0, 18, 18 ); 215 p->drawPixmap( x + offset, y + offset, *pixmaps[2], 18 * i, 0, 18, 18 );
208} 216}
209 217
210 218
211void AudioWidget::timerEvent( QTimerEvent * ) { 219void AudioWidget::timerEvent( QTimerEvent * ) {
212 static int frame = 0; 220 static int frame = 0;
213 if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) { 221 if ( !mediaPlayerState->paused() && audioButtons[ AudioPlay ].isDown ) {
214 frame = frame >= 7 ? 0 : frame + 1; 222 frame = frame >= 7 ? 0 : frame + 1;
215 int x = audioButtons[AudioPlay].xPos; 223 int x = audioButtons[AudioPlay].xPos;
216 int y = audioButtons[AudioPlay].yPos; 224 int y = audioButtons[AudioPlay].yPos;
217 QPainter p( this ); 225 QPainter p( this );
218 // Optimize to only draw the little bit of the changing images which is different 226 // Optimize to only draw the little bit of the changing images which is different
219 p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 ); 227 p.drawPixmap( x + 14, y + 8, *pixmaps[3], 32 * frame, 0, 32, 32 );
220 p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 ); 228 p.drawPixmap( x + 37, y + 37, *pixmaps[2], 18 * AudioPlay, 0, 6, 3 );
221 } 229 }
222} 230}
223 231
224 232
225void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 233void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
226 for ( int i = 0; i < numButtons; i++ ) { 234 for ( int i = 0; i < numButtons; i++ ) {
227 int size = audioButtons[i].isBig; 235 int size = audioButtons[i].isBig;
228 int x = audioButtons[i].xPos; 236 int x = audioButtons[i].xPos;
229 int y = audioButtons[i].yPos; 237 int y = audioButtons[i].yPos;
230 if ( event->state() == QMouseEvent::LeftButton ) { 238 if ( event->state() == QMouseEvent::LeftButton ) {
231 // The test to see if the mouse click is inside the circular button or not 239 // The test to see if the mouse click is inside the circular button or not
232 // (compared with the radius squared to avoid a square-root of our distance) 240 // (compared with the radius squared to avoid a square-root of our distance)
233 int radius = 32 + 13 * size; 241 int radius = 32 + 13 * size;
234 QPoint center = QPoint( x + radius, y + radius ); 242 QPoint center = QPoint( x + radius, y + radius );
235 QPoint dXY = center - event->pos(); 243 QPoint dXY = center - event->pos();
236 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); 244 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y();
237 bool isOnButton = dist <= (radius * radius); 245 bool isOnButton = dist <= (radius * radius);
238// QRect r( x, y, 64 + 22*size, 64 + 22*size ); 246// QRect r( x, y, 64 + 22*size, 64 + 22*size );
239// bool isOnButton = r.contains( event->pos() ); // Rectangular Button code 247// bool isOnButton = r.contains( event->pos() ); // Rectangular Button code
240 if ( isOnButton && !audioButtons[i].isHeld ) { 248 if ( isOnButton && !audioButtons[i].isHeld ) {
241 audioButtons[i].isHeld = TRUE; 249 audioButtons[i].isHeld = TRUE;
242 toggleButton(i); 250 toggleButton(i);
243 qDebug("button toggled1 %d",i); 251 qDebug("button toggled1 %d",i);
244 switch (i) { 252 switch (i) {
245 case AudioVolumeUp: emit moreClicked(); return; 253 case AudioVolumeUp: emit moreClicked(); return;
246 case AudioVolumeDown: emit lessClicked(); return; 254 case AudioVolumeDown: emit lessClicked(); return;
247 } 255 }
248 } else if ( !isOnButton && audioButtons[i].isHeld ) { 256 } else if ( !isOnButton && audioButtons[i].isHeld ) {
249 audioButtons[i].isHeld = FALSE; 257 audioButtons[i].isHeld = FALSE;
250 toggleButton(i); 258 toggleButton(i);
251 qDebug("button toggled2 %d",i); 259 qDebug("button toggled2 %d",i);
252 } 260 }
253 } else { 261 } else {
254 if ( audioButtons[i].isHeld ) { 262 if ( audioButtons[i].isHeld ) {
255 audioButtons[i].isHeld = FALSE; 263 audioButtons[i].isHeld = FALSE;
256 if ( !audioButtons[i].isToggle ) 264 if ( !audioButtons[i].isToggle )
257 setToggleButton( i, FALSE ); 265 setToggleButton( i, FALSE );
258 qDebug("button toggled3 %d",i); 266 qDebug("button toggled3 %d",i);
259 switch (i) { 267 switch (i) {
260 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return; 268 case AudioPlay: mediaPlayerState->setPlaying(audioButtons[i].isDown); return;
261 case AudioStop: mediaPlayerState->setPlaying(FALSE); return; 269 case AudioStop: mediaPlayerState->setPlaying(FALSE); return;
262 case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return; 270 case AudioPause: mediaPlayerState->setPaused(audioButtons[i].isDown); return;
263 case AudioNext: mediaPlayerState->setNext(); return; 271 case AudioNext: mediaPlayerState->setNext(); return;
264 case AudioPrevious: mediaPlayerState->setPrev(); return; 272 case AudioPrevious: mediaPlayerState->setPrev(); return;
265 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; 273 case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return;
266 case AudioVolumeUp: emit moreReleased(); return; 274 case AudioVolumeUp: emit moreReleased(); return;
267 case AudioVolumeDown: emit lessReleased(); return; 275 case AudioVolumeDown: emit lessReleased(); return;
268 case AudioPlayList: mediaPlayerState->setList(); return; 276 case AudioPlayList: mediaPlayerState->setList(); return;
269 } 277 }
270 } 278 }
271 } 279 }
272 } 280 }
273} 281}
274 282
275 283
276void AudioWidget::mousePressEvent( QMouseEvent *event ) { 284void AudioWidget::mousePressEvent( QMouseEvent *event ) {
277 mouseMoveEvent( event ); 285 mouseMoveEvent( event );
278} 286}
279 287
280 288
281void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { 289void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
282 mouseMoveEvent( event ); 290 mouseMoveEvent( event );
283} 291}
284 292
285 293
286void AudioWidget::showEvent( QShowEvent* ) { 294void AudioWidget::showEvent( QShowEvent* ) {
287 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 295 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
288 mouseMoveEvent( &event ); 296 mouseMoveEvent( &event );
289} 297}
290 298
291 299
292void AudioWidget::closeEvent( QCloseEvent* ) { 300void AudioWidget::closeEvent( QCloseEvent* ) {
293 mediaPlayerState->setList(); 301 mediaPlayerState->setList();
294} 302}
295 303
296 304
297void AudioWidget::paintEvent( QPaintEvent * ) { 305void AudioWidget::paintEvent( QPaintEvent * ) {
298 QPainter p( this ); 306 QPainter p( this );
299 for ( int i = 0; i < numButtons; i++ ) 307 for ( int i = 0; i < numButtons; i++ )
300 paintButton( &p, i ); 308 paintButton( &p, i );
301} 309}
302 310
303void AudioWidget::showMe() { 311void AudioWidget::showMe() {
304 show(); 312 show();
305} 313}
306void AudioWidget::keyReleaseEvent( QKeyEvent *e) 314void AudioWidget::keyReleaseEvent( QKeyEvent *e)
307{ 315{
308 switch ( e->key() ) { 316 switch ( e->key() ) {
309////////////////////////////// Zaurus keys 317////////////////////////////// Zaurus keys
310 case Key_Home: 318 case Key_Home:
311 break; 319 break;
312 case Key_F9: //activity 320 case Key_F9: //activity
313 hide(); 321 hide();
314// qDebug("Audio F9"); 322// qDebug("Audio F9");
315 break; 323 break;
316 case Key_F10: //contacts 324 case Key_F10: //contacts
317 break; 325 break;
318 case Key_F11: //menu 326 case Key_F11: //menu
319 break; 327 break;
320 case Key_F12: //home 328 case Key_F12: //home
321 break; 329 break;
322 case Key_F13: //mail 330 case Key_F13: //mail
323 break; 331 break;
324 case Key_Space: { 332 case Key_Space: {
325 if(mediaPlayerState->playing()) { 333 if(mediaPlayerState->playing()) {
326// toggleButton(1); 334// toggleButton(1);
327 mediaPlayerState->setPlaying(FALSE); 335 mediaPlayerState->setPlaying(FALSE);
328// toggleButton(1); 336// toggleButton(1);
329 } else { 337 } else {
330// toggleButton(0); 338// toggleButton(0);
331 mediaPlayerState->setPlaying(TRUE); 339 mediaPlayerState->setPlaying(TRUE);
332// toggleButton(0); 340// toggleButton(0);
333 } 341 }
334 } 342 }
335 break; 343 break;
336 case Key_Down: 344 case Key_Down:
337 toggleButton(6); 345 toggleButton(6);
338 emit lessClicked(); 346 emit lessClicked();
339 emit lessReleased(); 347 emit lessReleased();
340 toggleButton(6); 348 toggleButton(6);
341 break; 349 break;
342 case Key_Up: 350 case Key_Up:
343 toggleButton(5); 351 toggleButton(5);
344 emit moreClicked(); 352 emit moreClicked();
345 emit moreReleased(); 353 emit moreReleased();
346 toggleButton(5); 354 toggleButton(5);
347 break; 355 break;
348 case Key_Right: 356 case Key_Right:
349// toggleButton(3); 357// toggleButton(3);
350 mediaPlayerState->setNext(); 358 mediaPlayerState->setNext();
351// toggleButton(3); 359// toggleButton(3);
352 break; 360 break;
353 case Key_Left: 361 case Key_Left:
354// toggleButton(4); 362// toggleButton(4);
355 mediaPlayerState->setPrev(); 363 mediaPlayerState->setPrev();
356// toggleButton(4); 364// toggleButton(4);
357 break; 365 break;
358 case Key_Escape: 366 case Key_Escape:
359 break; 367 break;
360 368
361 }; 369 };
362} 370}
diff --git a/core/multimedia/opieplayer/audiowidget.h b/core/multimedia/opieplayer/audiowidget.h
index 41ae4b6..b3d39bf 100644
--- a/core/multimedia/opieplayer/audiowidget.h
+++ b/core/multimedia/opieplayer/audiowidget.h
@@ -1,145 +1,146 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#ifndef AUDIO_WIDGET_H 21#ifndef AUDIO_WIDGET_H
22#define AUDIO_WIDGET_H 22#define AUDIO_WIDGET_H
23 23
24#include <qwidget.h> 24#include <qwidget.h>
25#include <qpainter.h> 25#include <qpainter.h>
26#include <qdrawutil.h> 26#include <qdrawutil.h>
27#include <qpixmap.h> 27#include <qpixmap.h>
28#include <qstring.h> 28#include <qstring.h>
29#include <qslider.h> 29#include <qslider.h>
30#include <qframe.h> 30#include <qframe.h>
31 31
32 32
33class QPixmap; 33class QPixmap;
34 34
35 35
36enum AudioButtons { 36enum AudioButtons {
37 AudioPlay, 37 AudioPlay,
38 AudioStop, 38 AudioStop,
39 AudioPause, 39 AudioPause,
40 AudioNext, 40 AudioNext,
41 AudioPrevious, 41 AudioPrevious,
42 AudioVolumeUp, 42 AudioVolumeUp,
43 AudioVolumeDown, 43 AudioVolumeDown,
44 AudioLoop, 44 AudioLoop,
45 AudioPlayList 45 AudioPlayList
46}; 46};
47 47
48 48
49#define USE_DBLBUF 49#define USE_DBLBUF
50 50
51 51
52class Ticker : public QFrame { 52class Ticker : public QFrame {
53 Q_OBJECT 53 Q_OBJECT
54public: 54public:
55 Ticker( QWidget* parent=0 ) : QFrame( parent ) { 55 Ticker( QWidget* parent=0 ) : QFrame( parent ) {
56 setFrameStyle( WinPanel | Sunken ); 56 setFrameStyle( WinPanel | Sunken );
57 setText( "No Song" ); 57 setText( "No Song" );
58 } 58 }
59 ~Ticker() { } 59 ~Ticker() { }
60 void setText( const QString& text ) { 60 void setText( const QString& text ) {
61 pos = 0; // reset it everytime the text is changed 61 pos = 0; // reset it everytime the text is changed
62 scrollText = text; 62 scrollText = text;
63 pixelLen = fontMetrics().width( scrollText ); 63 pixelLen = fontMetrics().width( scrollText );
64 killTimers(); 64 killTimers();
65 if ( pixelLen > width() ) 65 if ( pixelLen > width() )
66 startTimer( 50 ); 66 startTimer( 50 );
67 update(); 67 update();
68 } 68 }
69protected: 69protected:
70 void timerEvent( QTimerEvent * ) { 70 void timerEvent( QTimerEvent * ) {
71 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; 71 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1;
72#ifndef USE_DBLBUF 72#ifndef USE_DBLBUF
73 scroll( -1, 0, contentsRect() ); 73 scroll( -1, 0, contentsRect() );
74#else 74#else
75 repaint( FALSE ); 75 repaint( FALSE );
76#endif 76#endif
77 } 77 }
78 void drawContents( QPainter *p ) { 78 void drawContents( QPainter *p ) {
79#ifndef USE_DBLBUF 79#ifndef USE_DBLBUF
80 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) 80 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen )
81 p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); 81 p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
82#else 82#else
83 // Double buffering code. 83 // Double buffering code.
84 // Looks like qvfb makes it look like it flickers but I don't think it really is 84 // Looks like qvfb makes it look like it flickers but I don't think it really is
85 QPixmap pm( width(), height() ); 85 QPixmap pm( width(), height() );
86 pm.fill( colorGroup().base() ); 86 pm.fill( colorGroup().base() );
87 QPainter pmp( &pm ); 87 QPainter pmp( &pm );
88 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) 88 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen )
89 pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); 89 pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
90 p->drawPixmap( 0, 0, pm ); 90 p->drawPixmap( 0, 0, pm );
91#endif 91#endif
92 } 92 }
93private: 93private:
94 QString scrollText; 94 QString scrollText;
95 int pos, pixelLen; 95 int pos, pixelLen;
96}; 96};
97 97
98 98
99class AudioWidget : public QWidget { 99class AudioWidget : public QWidget {
100 Q_OBJECT 100 Q_OBJECT
101public: 101public:
102 AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); 102 AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 );
103 ~AudioWidget(); 103 ~AudioWidget();
104 void setTickerText( const QString &text ) { songInfo->setText( text ); } 104 void setTickerText( const QString &text ) { songInfo->setText( text ); }
105 bool isStreaming; 105 bool isStreaming;
106public slots: 106public slots:
107 void updateSlider( long, long ); 107 void updateSlider( long, long );
108 void sliderPressed( ); 108 void sliderPressed( );
109 void sliderReleased( ); 109 void sliderReleased( );
110 void setPaused( bool b) { setToggleButton( AudioPause, b ); } 110 void setPaused( bool b) { setToggleButton( AudioPause, b ); }
111 void setLooping( bool b) { setToggleButton( AudioLoop, b ); } 111 void setLooping( bool b) { setToggleButton( AudioLoop, b ); }
112 void setPlaying( bool b) { setToggleButton( AudioPlay, b ); } 112 void setPlaying( bool b) { setToggleButton( AudioPlay, b ); }
113 void setPosition( long ); 113 void setPosition( long );
114 void setLength( long ); 114 void setLength( long );
115 void setView( char ); 115 void setView( char );
116 116
117signals: 117signals:
118 void moreClicked(); 118 void moreClicked();
119 void lessClicked(); 119 void lessClicked();
120 void moreReleased(); 120 void moreReleased();
121 void lessReleased(); 121 void lessReleased();
122 void sliderMoved(long); 122 void sliderMoved(long);
123 123
124protected: 124protected:
125 void doBlank();
126 void doUnblank();
125 void paintEvent( QPaintEvent *pe ); 127 void paintEvent( QPaintEvent *pe );
126 void showEvent( QShowEvent *se ); 128 void showEvent( QShowEvent *se );
127 void mouseMoveEvent( QMouseEvent *event ); 129 void mouseMoveEvent( QMouseEvent *event );
128 void mousePressEvent( QMouseEvent *event ); 130 void mousePressEvent( QMouseEvent *event );
129 void mouseReleaseEvent( QMouseEvent *event ); 131 void mouseReleaseEvent( QMouseEvent *event );
130 void timerEvent( QTimerEvent *event ); 132 void timerEvent( QTimerEvent *event );
131 void closeEvent( QCloseEvent *event ); 133 void closeEvent( QCloseEvent *event );
132 void keyReleaseEvent( QKeyEvent *e); 134 void keyReleaseEvent( QKeyEvent *e);
133 void showMe();
134private: 135private:
135 void toggleButton( int ); 136 void toggleButton( int );
136 void setToggleButton( int, bool ); 137 void setToggleButton( int, bool );
137 void paintButton( QPainter *p, int i ); 138 void paintButton( QPainter *p, int i );
138 QPixmap *pixmaps[4]; 139 QPixmap *pixmaps[4];
139 Ticker *songInfo; 140 Ticker *songInfo;
140 QSlider *slider; 141 QSlider *slider;
141}; 142};
142 143
143 144
144#endif // AUDIO_WIDGET_H 145#endif // AUDIO_WIDGET_H
145 146
diff --git a/core/multimedia/opieplayer/inputDialog.cpp b/core/multimedia/opieplayer/inputDialog.cpp
index b443747..b80d129 100644
--- a/core/multimedia/opieplayer/inputDialog.cpp
+++ b/core/multimedia/opieplayer/inputDialog.cpp
@@ -1,45 +1,52 @@
1/**************************************************************************** 1/****************************************************************************
2** Form implementation generated from reading ui file 'inputDialog.ui' 2** Form implementation generated from reading ui file 'inputDialog.ui'
3** 3**
4** Created: Sat Mar 2 07:55:03 2002 4** Created: Sat Mar 2 07:55:03 2002
5** by: The User Interface Compiler (uic) 5** by: The User Interface Compiler (uic)
6** 6**
7** WARNING! All changes made in this file will be lost! 7** WARNING! All changes made in this file will be lost!
8****************************************************************************/ 8****************************************************************************/
9#include "inputDialog.h" 9#include "inputDialog.h"
10 10
11#include <qpe/resource.h>
12
13#include <opie/ofiledialog.h>
14
11#include <qlineedit.h> 15#include <qlineedit.h>
12#include <qlayout.h> 16#include <qlayout.h>
13#include <qvariant.h> 17#include <qvariant.h>
14#include <qtooltip.h> 18#include <qpushbutton.h>
15#include <qwhatsthis.h> 19#include <qwhatsthis.h>
16 20
17/*
18 * Constructs a InputDialog which is a child of 'parent', with the
19 * name 'name' and widget flags set to 'f'
20 *
21 * The dialog will by default be modeless, unless you set 'modal' to
22 * TRUE to construct a modal dialog.
23 */
24InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) 21InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
25 : QDialog( parent, name, modal, fl ) 22 : QDialog( parent, name, modal, fl )
26{ 23{
27 if ( !name ) 24 if ( !name )
28 setName( "InputDialog" ); 25 setName( "InputDialog" );
29 resize( 234, 50 ); 26 resize( 234, 115);
30 setMaximumSize( QSize( 240, 50 ) ); 27 setMaximumSize( QSize( 240, 40));
31 setCaption( tr(name ) ); 28 setCaption( tr(name ) );
32 29
30 QPushButton *browserButton;
31 browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton");
32 browserButton->setGeometry( QRect( 205, 10, 22, 22));
33 connect( browserButton, SIGNAL(released()),this,SLOT(browse()));
33 LineEdit1 = new QLineEdit( this, "LineEdit1" ); 34 LineEdit1 = new QLineEdit( this, "LineEdit1" );
34 LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) ); 35 LineEdit1->setGeometry( QRect( 4, 10, 190, 22 ) );
35} 36}
36 37
37/* 38/*
38 * Destroys the object and frees any allocated resources 39 * Destroys the object and frees any allocated resources
39 */ 40 */
40InputDialog::~InputDialog() 41InputDialog::~InputDialog()
41{ 42{
42 inputText= LineEdit1->text(); 43 inputText= LineEdit1->text();
43 44
44} 45}
45 46
47void InputDialog::browse() {
48
49 QString str = OFileDialog::getOpenFileName( 1,"/","", "playlist/plain", 0 );
50 LineEdit1->setText(str);
51}
52
diff --git a/core/multimedia/opieplayer/inputDialog.h b/core/multimedia/opieplayer/inputDialog.h
index 26d5cd0..3e3e36f 100644
--- a/core/multimedia/opieplayer/inputDialog.h
+++ b/core/multimedia/opieplayer/inputDialog.h
@@ -1,31 +1,30 @@
1/**************************************************************************** 1/****************************************************************************
2** Form interface generated from reading ui file 'inputDialog.ui' 2** Form interface generated from reading ui file 'inputDialog.ui'
3** 3**
4** Created: Sat Mar 2 07:54:46 2002 4** Created: Sat Mar 2 07:54:46 2002
5** by: The User Interface Compiler (uic) 5** by: The User Interface Compiler (uic)
6** 6**
7** WARNING! All changes made in this file will be lost! 7** WARNING! All changes made in this file will be lost!
8****************************************************************************/ 8****************************************************************************/
9#ifndef INPUTDIALOG_H 9#ifndef INPUTDIALOG_H
10#define INPUTDIALOG_H 10#define INPUTDIALOG_H
11 11
12#include <qvariant.h> 12#include <qvariant.h>
13#include <qdialog.h> 13#include <qdialog.h>
14class QVBoxLayout; 14
15class QHBoxLayout;
16class QGridLayout;
17class QLineEdit; 15class QLineEdit;
18 16
19class InputDialog : public QDialog 17class InputDialog : public QDialog
20{ 18{
21 Q_OBJECT 19 Q_OBJECT
22 20
23public: 21public:
24 InputDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); 22 InputDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
25 ~InputDialog(); 23 ~InputDialog();
26 QString inputText; 24 QString inputText;
27 QLineEdit* LineEdit1; 25 QLineEdit* LineEdit1;
28 26protected slots:
27 void browse();
29}; 28};
30 29
31#endif // INPUTDIALOG_H 30#endif // INPUTDIALOG_H
diff --git a/core/multimedia/opieplayer/opieplayer.pro b/core/multimedia/opieplayer/opieplayer.pro
index 4cef319..6409bab 100644
--- a/core/multimedia/opieplayer/opieplayer.pro
+++ b/core/multimedia/opieplayer/opieplayer.pro
@@ -1,24 +1,24 @@
1TEMPLATE = app 1TEMPLATE = app
2CONFIG = qt warn_on release 2CONFIG = qt warn_on release
3#release 3#release
4DESTDIR = $(OPIEDIR)/bin 4DESTDIR = $(OPIEDIR)/bin
5HEADERS = loopcontrol.h mediaplayerplugininterface.h playlistselection.h mediaplayerstate.h \ 5HEADERS = loopcontrol.h mediaplayerplugininterface.h playlistselection.h mediaplayerstate.h \
6 videowidget.h audiowidget.h playlistwidget.h mediaplayer.h audiodevice.h inputDialog.h 6 videowidget.h audiowidget.h playlistwidget.h mediaplayer.h audiodevice.h inputDialog.h
7SOURCES = main.cpp \ 7SOURCES = main.cpp \
8 loopcontrol.cpp playlistselection.cpp mediaplayerstate.cpp \ 8 loopcontrol.cpp playlistselection.cpp mediaplayerstate.cpp \
9 videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp audiodevice.cpp inputDialog.cpp 9 videowidget.cpp audiowidget.cpp playlistwidget.cpp mediaplayer.cpp audiodevice.cpp inputDialog.cpp
10TARGET = opieplayer 10TARGET = opieplayer
11INCLUDEPATH += $(OPIEDIR)/include 11INCLUDEPATH += $(OPIEDIR)/include
12DEPENDPATH += $(OPIEDIR)/include 12DEPENDPATH += $(OPIEDIR)/include
13LIBS += -lqpe -lpthread 13LIBS += -lqpe -lpthread -lopie
14 14
15# INTERFACES = 15# INTERFACES =
16# INCLUDEPATH += $(OPIEDIR)/include 16# INCLUDEPATH += $(OPIEDIR)/include
17# CONFIG+=static 17# CONFIG+=static
18# TMAKE_CXXFLAGS += -DQPIM_STANDALONE 18# TMAKE_CXXFLAGS += -DQPIM_STANDALONE
19# LIBS += libmpeg3/libmpeg3.a -lpthread 19# LIBS += libmpeg3/libmpeg3.a -lpthread
20# LIBS += $(OPIEDIR)/plugins/codecs/liblibmadplugin.so 20# LIBS += $(OPIEDIR)/plugins/codecs/liblibmadplugin.so
21 21
22INCLUDEPATH += $(OPIEDIR)/include 22INCLUDEPATH += $(OPIEDIR)/include
23DEPENDPATH += $(OPIEDIR)/include 23DEPENDPATH += $(OPIEDIR)/include
24 24
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 70b7cef..2118051 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -246,862 +246,861 @@ PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
246 246
247 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); 247 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold);
248 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 248 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
249 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 249 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
250 250
251 251
252// audioView 252// audioView
253 populateAudioView(); 253 populateAudioView();
254// videowidget 254// videowidget
255 255
256 QWidget *vTab; 256 QWidget *vTab;
257 vTab = new QWidget( tabWidget, "vTab" ); 257 vTab = new QWidget( tabWidget, "vTab" );
258 videoView = new QListView( vTab, "Videoview" ); 258 videoView = new QListView( vTab, "Videoview" );
259 videoView->setMinimumSize(233,260); 259 videoView->setMinimumSize(233,260);
260 260
261 videoView->addColumn(tr("Title"),140); 261 videoView->addColumn(tr("Title"),140);
262 videoView->addColumn(tr("Size"),-1); 262 videoView->addColumn(tr("Size"),-1);
263 videoView->addColumn(tr("Media"),-1); 263 videoView->addColumn(tr("Media"),-1);
264 videoView->setColumnAlignment(1, Qt::AlignRight); 264 videoView->setColumnAlignment(1, Qt::AlignRight);
265 videoView->setColumnAlignment(2, Qt::AlignRight); 265 videoView->setColumnAlignment(2, Qt::AlignRight);
266 videoView->setAllColumnsShowFocus(TRUE); 266 videoView->setAllColumnsShowFocus(TRUE);
267 videoView->setMultiSelection( TRUE ); 267 videoView->setMultiSelection( TRUE );
268 videoView->setSelectionMode( QListView::Extended); 268 videoView->setSelectionMode( QListView::Extended);
269 269
270 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); 270 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold);
271 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 271 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
272 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 272 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
273 273
274 tabWidget->insertTab( vTab,tr("Video")); 274 tabWidget->insertTab( vTab,tr("Video"));
275populateVideoView(); 275populateVideoView();
276 276
277//playlists list 277//playlists list
278 QWidget *LTab; 278 QWidget *LTab;
279 LTab = new QWidget( tabWidget, "LTab" ); 279 LTab = new QWidget( tabWidget, "LTab" );
280 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy 280 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy
281 playLists->setMinimumSize(233,260);; 281 playLists->setMinimumSize(233,260);;
282 tabWidget->insertTab(LTab,tr("Lists")); 282 tabWidget->insertTab(LTab,tr("Lists"));
283 283
284 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); 284 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
285// connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); 285// connect( playLists, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) );
286 286
287 287
288// add the library area 288// add the library area
289 289
290// connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), 290// connect( audioView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)),
291// this, SLOT( fauxPlay( QListViewItem *) ) ); 291// this, SLOT( fauxPlay( QListViewItem *) ) );
292// connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)), 292// connect( videoView, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int)),
293// this, SLOT( fauxPlay( QListViewItem *)) ); 293// this, SLOT( fauxPlay( QListViewItem *)) );
294 294
295// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); 295// connect( audioView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) );
296// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) ); 296// connect( videoView, SIGNAL( clicked( QListViewItem *) ), this, SLOT( fauxPlay( QListViewItem *) ) );
297 297
298 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 298 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
299 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 299 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
300 300
301 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); 301 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
302 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 302 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
303 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); 303 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
304 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 304 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
305 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 305 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
306 306
307 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 307 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
308// connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) ); 308// connect( d->selectedFiles, SIGNAL( fileSelected( const DocLnk & ) ), this, SLOT( addToSelection( const DocLnk & ) ) );
309 309
310 setCentralWidget( vbox5 ); 310 setCentralWidget( vbox5 );
311 311
312 Config cfg( "OpiePlayer" ); 312 Config cfg( "OpiePlayer" );
313 readConfig( cfg ); 313 readConfig( cfg );
314 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 314 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
315// qDebug("currentList is "+currentPlaylist); 315// qDebug("currentList is "+currentPlaylist);
316 loadList(DocLnk( currentPlaylist)); 316 loadList(DocLnk( currentPlaylist));
317 setCaption(tr("OpiePlayer: ")+ currentPlaylist ); 317 setCaption(tr("OpiePlayer: ")+ currentPlaylist );
318 318
319 initializeStates(); 319 initializeStates();
320} 320}
321 321
322 322
323PlayListWidget::~PlayListWidget() { 323PlayListWidget::~PlayListWidget() {
324 Config cfg( "OpiePlayer" ); 324 Config cfg( "OpiePlayer" );
325 writeConfig( cfg ); 325 writeConfig( cfg );
326 326
327 327
328 if ( d->current ) 328 if ( d->current )
329 delete d->current; 329 delete d->current;
330 delete d; 330 delete d;
331} 331}
332 332
333 333
334void PlayListWidget::initializeStates() { 334void PlayListWidget::initializeStates() {
335 335
336 d->tbPlay->setOn( mediaPlayerState->playing() ); 336 d->tbPlay->setOn( mediaPlayerState->playing() );
337 d->tbLoop->setOn( mediaPlayerState->looping() ); 337 d->tbLoop->setOn( mediaPlayerState->looping() );
338 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 338 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
339// d->tbFull->setOn( mediaPlayerState->fullscreen() ); 339// d->tbFull->setOn( mediaPlayerState->fullscreen() );
340// d->tbScale->setOn( mediaPlayerState->scaled() ); 340// d->tbScale->setOn( mediaPlayerState->scaled() );
341// d->tbScale->setEnabled( mediaPlayerState->fullscreen() ); 341// d->tbScale->setEnabled( mediaPlayerState->fullscreen() );
342// setPlaylist( mediaPlayerState->playlist() ); 342// setPlaylist( mediaPlayerState->playlist() );
343 setPlaylist( true); 343 setPlaylist( true);
344// d->selectedFiles->first(); 344// d->selectedFiles->first();
345 345
346} 346}
347 347
348 348
349void PlayListWidget::readConfig( Config& cfg ) { 349void PlayListWidget::readConfig( Config& cfg ) {
350 cfg.setGroup("PlayList"); 350 cfg.setGroup("PlayList");
351 QString currentString = cfg.readEntry("current", "" ); 351 QString currentString = cfg.readEntry("current", "" );
352 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 352 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
353 for ( int i = 0; i < noOfFiles; i++ ) { 353 for ( int i = 0; i < noOfFiles; i++ ) {
354 QString entryName; 354 QString entryName;
355 entryName.sprintf( "File%i", i + 1 ); 355 entryName.sprintf( "File%i", i + 1 );
356 QString linkFile = cfg.readEntry( entryName ); 356 QString linkFile = cfg.readEntry( entryName );
357 DocLnk lnk( linkFile ); 357 DocLnk lnk( linkFile );
358 if ( lnk.isValid() ) { 358 if ( lnk.isValid() ) {
359 d->selectedFiles->addToSelection( lnk ); 359 d->selectedFiles->addToSelection( lnk );
360 } 360 }
361 } 361 }
362 d->selectedFiles->setSelectedItem( currentString); 362 d->selectedFiles->setSelectedItem( currentString);
363// d->selectedFiles->setSelectedItem( (const QString &)currentString); 363// d->selectedFiles->setSelectedItem( (const QString &)currentString);
364} 364}
365 365
366 366
367void PlayListWidget::writeConfig( Config& cfg ) const { 367void PlayListWidget::writeConfig( Config& cfg ) const {
368 368
369 d->selectedFiles->writeCurrent( cfg); 369 d->selectedFiles->writeCurrent( cfg);
370 cfg.setGroup("PlayList"); 370 cfg.setGroup("PlayList");
371 int noOfFiles = 0; 371 int noOfFiles = 0;
372 d->selectedFiles->first(); 372 d->selectedFiles->first();
373 do { 373 do {
374 const DocLnk *lnk = d->selectedFiles->current(); 374 const DocLnk *lnk = d->selectedFiles->current();
375 if ( lnk ) { 375 if ( lnk ) {
376 QString entryName; 376 QString entryName;
377 entryName.sprintf( "File%i", noOfFiles + 1 ); 377 entryName.sprintf( "File%i", noOfFiles + 1 );
378// qDebug(entryName); 378// qDebug(entryName);
379 cfg.writeEntry( entryName, lnk->linkFile() ); 379 cfg.writeEntry( entryName, lnk->linkFile() );
380 // if this link does exist, add it so we have the file 380 // if this link does exist, add it so we have the file
381 // next time... 381 // next time...
382 if ( !QFile::exists( lnk->linkFile() ) ) { 382 if ( !QFile::exists( lnk->linkFile() ) ) {
383 // the way writing lnks doesn't really check for out 383 // the way writing lnks doesn't really check for out
384 // of disk space, but check it anyway. 384 // of disk space, but check it anyway.
385 if ( !lnk->writeLink() ) { 385 if ( !lnk->writeLink() ) {
386 QMessageBox::critical( 0, tr("Out of space"), 386 QMessageBox::critical( 0, tr("Out of space"),
387 tr( "There was a problem saving " 387 tr( "There was a problem saving "
388 "the playlist.\n" 388 "the playlist.\n"
389 "Your playlist " 389 "Your playlist "
390 "may be missing some entries\n" 390 "may be missing some entries\n"
391 "the next time you start it." ) 391 "the next time you start it." )
392 ); 392 );
393 } 393 }
394 } 394 }
395 noOfFiles++; 395 noOfFiles++;
396 } 396 }
397 } 397 }
398 while ( d->selectedFiles->next() ); 398 while ( d->selectedFiles->next() );
399 cfg.writeEntry("NumberOfFiles", noOfFiles ); 399 cfg.writeEntry("NumberOfFiles", noOfFiles );
400} 400}
401 401
402 402
403void PlayListWidget::addToSelection( const DocLnk& lnk ) { 403void PlayListWidget::addToSelection( const DocLnk& lnk ) {
404// qDebug("add"); 404// qDebug("add");
405 d->setDocumentUsed = FALSE; 405 d->setDocumentUsed = FALSE;
406 if ( mediaPlayerState->playlist() ) 406 if ( mediaPlayerState->playlist() )
407 d->selectedFiles->addToSelection( lnk ); 407 d->selectedFiles->addToSelection( lnk );
408 else 408 else
409 mediaPlayerState->setPlaying( TRUE ); 409 mediaPlayerState->setPlaying( TRUE );
410} 410}
411 411
412 412
413void PlayListWidget::clearList() { 413void PlayListWidget::clearList() {
414 while ( first() ) 414 while ( first() )
415 d->selectedFiles->removeSelected(); 415 d->selectedFiles->removeSelected();
416} 416}
417 417
418 418
419void PlayListWidget::addAllToList() { 419void PlayListWidget::addAllToList() {
420 DocLnkSet filesAll; 420 DocLnkSet filesAll;
421 Global::findDocuments(&filesAll, "video/*;audio/*"); 421 Global::findDocuments(&filesAll, "video/*;audio/*");
422 QListIterator<DocLnk> Adit( filesAll.children() ); 422 QListIterator<DocLnk> Adit( filesAll.children() );
423 for ( ; Adit.current(); ++Adit ) 423 for ( ; Adit.current(); ++Adit )
424 d->selectedFiles->addToSelection( **Adit ); 424 d->selectedFiles->addToSelection( **Adit );
425} 425}
426 426
427 427
428void PlayListWidget::addAllMusicToList() { 428void PlayListWidget::addAllMusicToList() {
429// DocLnkSet files; 429// DocLnkSet files;
430// Global::findDocuments(&files, "audio/*"); 430// Global::findDocuments(&files, "audio/*");
431 QListIterator<DocLnk> dit( files.children() ); 431 QListIterator<DocLnk> dit( files.children() );
432 for ( ; dit.current(); ++dit ) 432 for ( ; dit.current(); ++dit )
433 d->selectedFiles->addToSelection( **dit ); 433 d->selectedFiles->addToSelection( **dit );
434} 434}
435 435
436 436
437void PlayListWidget::addAllVideoToList() { 437void PlayListWidget::addAllVideoToList() {
438 QListIterator<DocLnk> dit( vFiles.children() ); 438 QListIterator<DocLnk> dit( vFiles.children() );
439 for ( ; dit.current(); ++dit ) 439 for ( ; dit.current(); ++dit )
440 d->selectedFiles->addToSelection( **dit ); 440 d->selectedFiles->addToSelection( **dit );
441} 441}
442 442
443 443
444void PlayListWidget::setDocument(const QString& fileref) { 444void PlayListWidget::setDocument(const QString& fileref) {
445 qDebug(fileref); 445 qDebug(fileref);
446 fromSetDocument = TRUE; 446 fromSetDocument = TRUE;
447 if ( fileref.isNull() ) { 447 if ( fileref.isNull() ) {
448 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); 448 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) );
449 return; 449 return;
450 } 450 }
451// qDebug("setDocument "+fileref); 451// qDebug("setDocument "+fileref);
452// if(fileref.find("m3u",0,TRUE) != -1) { //is m3u 452// if(fileref.find("m3u",0,TRUE) != -1) { //is m3u
453// clearList(); 453// clearList();
454// addToSelection( DocLnk( fileref ) ); 454// addToSelection( DocLnk( fileref ) );
455// d->setDocumentUsed = TRUE; 455// d->setDocumentUsed = TRUE;
456// d->selectedFiles->first(); 456// d->selectedFiles->first();
457// qApp->processEvents(); 457// qApp->processEvents();
458// } 458// }
459// else 459// else
460 if(fileref.find("playlist",0,TRUE) != -1) {//is playlist 460 if(fileref.find("playlist",0,TRUE) != -1) {//is playlist
461 clearList(); 461 clearList();
462 loadList(DocLnk(fileref)); 462 loadList(DocLnk(fileref));
463 d->selectedFiles->first(); 463 d->selectedFiles->first();
464 } else { 464 } else {
465 clearList(); 465 clearList();
466 addToSelection( DocLnk( fileref ) ); 466 addToSelection( DocLnk( fileref ) );
467 d->setDocumentUsed = TRUE; 467 d->setDocumentUsed = TRUE;
468 mediaPlayerState->setPlaying( FALSE ); 468 mediaPlayerState->setPlaying( FALSE );
469 qApp->processEvents(); 469 qApp->processEvents();
470 mediaPlayerState->setPlaying( TRUE ); 470 mediaPlayerState->setPlaying( TRUE );
471 qApp->processEvents(); 471 qApp->processEvents();
472 setCaption(tr("OpiePlayer")); 472 setCaption(tr("OpiePlayer"));
473 } 473 }
474} 474}
475 475
476 476
477void PlayListWidget::setActiveWindow() { 477void PlayListWidget::setActiveWindow() {
478 // When we get raised we need to ensure that it switches views 478 // When we get raised we need to ensure that it switches views
479 char origView = mediaPlayerState->view(); 479 char origView = mediaPlayerState->view();
480 mediaPlayerState->setView( 'l' ); // invalidate 480 mediaPlayerState->setView( 'l' ); // invalidate
481 mediaPlayerState->setView( origView ); // now switch back 481 mediaPlayerState->setView( origView ); // now switch back
482} 482}
483 483
484 484
485void PlayListWidget::useSelectedDocument() { 485void PlayListWidget::useSelectedDocument() {
486 d->setDocumentUsed = FALSE; 486 d->setDocumentUsed = FALSE;
487} 487}
488 488
489 489
490const DocLnk *PlayListWidget::current() { // this is fugly 490const DocLnk *PlayListWidget::current() { // this is fugly
491 491
492// if( fromSetDocument) { 492// if( fromSetDocument) {
493// qDebug("from setDoc"); 493// qDebug("from setDoc");
494// DocLnkSet files; 494// DocLnkSet files;
495// Global::findDocuments(&files, "video/*;audio/*"); 495// Global::findDocuments(&files, "video/*;audio/*");
496// QListIterator<DocLnk> dit( files.children() ); 496// QListIterator<DocLnk> dit( files.children() );
497// for ( ; dit.current(); ++dit ) { 497// for ( ; dit.current(); ++dit ) {
498// if(dit.current()->linkFile() == setDocFileRef) { 498// if(dit.current()->linkFile() == setDocFileRef) {
499// qDebug(setDocFileRef); 499// qDebug(setDocFileRef);
500// return dit; 500// return dit;
501// } 501// }
502// } 502// }
503// } else 503// } else
504 504
505 505
506 switch (tabWidget->currentPageIndex()) { 506 switch (tabWidget->currentPageIndex()) {
507 case 0: //playlist 507 case 0: //playlist
508 { 508 {
509 qDebug("playlist"); 509 qDebug("playlist");
510 if ( mediaPlayerState->playlist() ) { 510 if ( mediaPlayerState->playlist() ) {
511 return d->selectedFiles->current(); 511 return d->selectedFiles->current();
512 } 512 }
513 else if ( d->setDocumentUsed && d->current ) { 513 else if ( d->setDocumentUsed && d->current ) {
514 return d->current; 514 return d->current;
515 } else { 515 } else {
516 return d->files->selected(); 516 return d->files->selected();
517 } 517 }
518 } 518 }
519 break; 519 break;
520 case 1://audio 520 case 1://audio
521 { 521 {
522 qDebug("audioView"); 522 qDebug("audioView");
523// Global::findDocuments(&files, "audio/*"); 523// Global::findDocuments(&files, "audio/*");
524 QListIterator<DocLnk> dit( files.children() ); 524 QListIterator<DocLnk> dit( files.children() );
525 for ( ; dit.current(); ++dit ) { 525 for ( ; dit.current(); ++dit ) {
526 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) { 526 if( dit.current()->name() == audioView->currentItem()->text(0) && !insanityBool) {
527 qDebug("here"); 527 qDebug("here");
528 insanityBool=TRUE; 528 insanityBool=TRUE;
529 return dit; 529 return dit;
530 } 530 }
531 } 531 }
532 } 532 }
533 break; 533 break;
534 case 2: // video 534 case 2: // video
535 { 535 {
536 qDebug("videoView"); 536 qDebug("videoView");
537// Global::findDocuments(&vFiles, "video/*"); 537// Global::findDocuments(&vFiles, "video/*");
538 QListIterator<DocLnk> Vdit( vFiles.children() ); 538 QListIterator<DocLnk> Vdit( vFiles.children() );
539 for ( ; Vdit.current(); ++Vdit ) { 539 for ( ; Vdit.current(); ++Vdit ) {
540 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) { 540 if( Vdit.current()->name() == videoView->currentItem()->text(0) && !insanityBool) {
541 insanityBool=TRUE; 541 insanityBool=TRUE;
542 return Vdit; 542 return Vdit;
543 } 543 }
544 } 544 }
545 } 545 }
546 break; 546 break;
547 }; 547 };
548 return 0; 548 return 0;
549} 549}
550 550
551bool PlayListWidget::prev() { 551bool PlayListWidget::prev() {
552 if ( mediaPlayerState->playlist() ) { 552 if ( mediaPlayerState->playlist() ) {
553 if ( mediaPlayerState->shuffled() ) { 553 if ( mediaPlayerState->shuffled() ) {
554 const DocLnk *cur = current(); 554 const DocLnk *cur = current();
555 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0)); 555 int j = 1 + (int)(97.0 * rand() / (RAND_MAX + 1.0));
556 for ( int i = 0; i < j; i++ ) { 556 for ( int i = 0; i < j; i++ ) {
557 if ( !d->selectedFiles->next() ) 557 if ( !d->selectedFiles->next() )
558 d->selectedFiles->first(); 558 d->selectedFiles->first();
559 } 559 }
560 if ( cur == current() ) 560 if ( cur == current() )
561 if ( !d->selectedFiles->next() ) 561 if ( !d->selectedFiles->next() )
562 d->selectedFiles->first(); 562 d->selectedFiles->first();
563 return TRUE; 563 return TRUE;
564 } else { 564 } else {
565 if ( !d->selectedFiles->prev() ) { 565 if ( !d->selectedFiles->prev() ) {
566 if ( mediaPlayerState->looping() ) { 566 if ( mediaPlayerState->looping() ) {
567 return d->selectedFiles->last(); 567 return d->selectedFiles->last();
568 } else { 568 } else {
569 return FALSE; 569 return FALSE;
570 } 570 }
571 } 571 }
572 return TRUE; 572 return TRUE;
573 } 573 }
574 } else { 574 } else {
575 return mediaPlayerState->looping(); 575 return mediaPlayerState->looping();
576 } 576 }
577} 577}
578 578
579 579
580bool PlayListWidget::next() { 580bool PlayListWidget::next() {
581 if ( mediaPlayerState->playlist() ) { 581 if ( mediaPlayerState->playlist() ) {
582 if ( mediaPlayerState->shuffled() ) { 582 if ( mediaPlayerState->shuffled() ) {
583 return prev(); 583 return prev();
584 } else { 584 } else {
585 if ( !d->selectedFiles->next() ) { 585 if ( !d->selectedFiles->next() ) {
586 if ( mediaPlayerState->looping() ) { 586 if ( mediaPlayerState->looping() ) {
587 return d->selectedFiles->first(); 587 return d->selectedFiles->first();
588 } else { 588 } else {
589 return FALSE; 589 return FALSE;
590 } 590 }
591 } 591 }
592 return TRUE; 592 return TRUE;
593 } 593 }
594 } else { 594 } else {
595 return mediaPlayerState->looping(); 595 return mediaPlayerState->looping();
596 } 596 }
597} 597}
598 598
599 599
600bool PlayListWidget::first() { 600bool PlayListWidget::first() {
601 if ( mediaPlayerState->playlist() ) 601 if ( mediaPlayerState->playlist() )
602 return d->selectedFiles->first(); 602 return d->selectedFiles->first();
603 else 603 else
604 return mediaPlayerState->looping(); 604 return mediaPlayerState->looping();
605} 605}
606 606
607 607
608bool PlayListWidget::last() { 608bool PlayListWidget::last() {
609 if ( mediaPlayerState->playlist() ) 609 if ( mediaPlayerState->playlist() )
610 return d->selectedFiles->last(); 610 return d->selectedFiles->last();
611 else 611 else
612 return mediaPlayerState->looping(); 612 return mediaPlayerState->looping();
613} 613}
614 614
615 615
616void PlayListWidget::saveList() { 616void PlayListWidget::saveList() {
617 617
618 QString filename; 618 QString filename;
619 InputDialog *fileDlg; 619 InputDialog *fileDlg;
620 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0); 620 fileDlg = new InputDialog(this,tr("Save Playlist"),TRUE, 0);
621 fileDlg->exec(); 621 fileDlg->exec();
622 if( fileDlg->result() == 1 ) { 622 if( fileDlg->result() == 1 ) {
623 if ( d->current ) 623 if ( d->current )
624 delete d->current; 624 delete d->current;
625 filename = fileDlg->LineEdit1->text();//+".playlist"; 625 filename = fileDlg->LineEdit1->text();//+".playlist";
626// qDebug("saving playlist "+filename+".playlist"); 626// qDebug("saving playlist "+filename+".playlist");
627 Config cfg( filename +".playlist"); 627 Config cfg( filename +".playlist");
628 writeConfig( cfg ); 628 writeConfig( cfg );
629 629
630// qDebug("same name so delete lnk??");
631// if( playLists->selected()->name() == filename) {
632
633// qDebug("same name so delete lnk");
634// QFile().remove(playLists->selected()->file());
635// QFile().remove(playLists->selected()->linkFile());
636// playLists->reread();
637// }
638// qDebug("new doclnk");
639 DocLnk lnk; 630 DocLnk lnk;
640// lnk.setComment( ""); 631// lnk.setComment( "");
641 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property 632 lnk.setFile(QDir::homeDirPath()+"/Settings/"+filename+".playlist.conf"); //sets File property
642 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D 633 lnk.setType("playlist/plain");// hey is this a REGISTERED mime type?!?!? ;D
643 lnk.setIcon("opieplayer/playlist2"); 634 lnk.setIcon("opieplayer/playlist2");
644 lnk.setName( filename); //sets file name 635 lnk.setName( filename); //sets file name
645// qDebug(filename); 636// qDebug(filename);
646 if(!lnk.writeLink()) 637 if(!lnk.writeLink())
647 qDebug("Writing doclink did not work"); 638 qDebug("Writing doclink did not work");
648 } 639 }
649 Config config( "OpiePlayer" ); 640 Config config( "OpiePlayer" );
650 config.writeEntry("CurrentPlaylist",filename); 641 config.writeEntry("CurrentPlaylist",filename);
651 setCaption(tr("OpiePlayer: ")+filename); 642 setCaption(tr("OpiePlayer: ")+filename);
652 d->selectedFiles->first(); 643 d->selectedFiles->first();
653 if(fileDlg) 644 if(fileDlg)
654 delete fileDlg; 645 delete fileDlg;
655} 646}
656 647
657void PlayListWidget::loadList( const DocLnk & lnk) { 648void PlayListWidget::loadList( const DocLnk & lnk) {
658 QString name= lnk.name(); 649 QString name= lnk.name();
659// qDebug("currentList is "+name); 650// qDebug("currentList is "+name);
660 if( name.length()>1) { 651 if( name.length()>1) {
661 setCaption("OpiePlayer: "+name); 652 setCaption("OpiePlayer: "+name);
662// qDebug("load list "+ name+".playlist"); 653// qDebug("load list "+ name+".playlist");
663 clearList(); 654 clearList();
664 Config cfg( name+".playlist"); 655 Config cfg( name+".playlist");
665 readConfig(cfg); 656 readConfig(cfg);
666 657
667 tabWidget->setCurrentPage(0); 658 tabWidget->setCurrentPage(0);
668 659
669 Config config( "OpiePlayer" ); 660 Config config( "OpiePlayer" );
670 config.writeEntry("CurrentPlaylist", name); 661 config.writeEntry("CurrentPlaylist", name);
671// d->selectedFiles->first(); 662// d->selectedFiles->first();
672 } 663 }
673 664
674} 665}
675 666
676void PlayListWidget::setPlaylist( bool shown ) { 667void PlayListWidget::setPlaylist( bool shown ) {
677 if ( shown ) 668 if ( shown )
678 d->playListFrame->show(); 669 d->playListFrame->show();
679 else 670 else
680 d->playListFrame->hide(); 671 d->playListFrame->hide();
681} 672}
682 673
683void PlayListWidget::setView( char view ) { 674void PlayListWidget::setView( char view ) {
684 if ( view == 'l' ) 675 if ( view == 'l' )
685 showMaximized(); 676 showMaximized();
686 else 677 else
687 hide(); 678 hide();
688} 679}
689 680
690void PlayListWidget::addSelected() { 681void PlayListWidget::addSelected() {
691 682
692 Config cfg( "OpiePlayer" ); 683 Config cfg( "OpiePlayer" );
693 cfg.setGroup("PlayList"); 684 cfg.setGroup("PlayList");
694 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 685 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
695 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 686 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
696 687
697 switch (tabWidget->currentPageIndex()) { 688 switch (tabWidget->currentPageIndex()) {
698 case 0: //playlist 689 case 0: //playlist
699 break; 690 break;
700 case 1: { //audio 691 case 1: { //audio
701// QString entryName; 692// QString entryName;
702// entryName.sprintf( "File%i", i + 1 ); 693// entryName.sprintf( "File%i", i + 1 );
703// QString linkFile = cfg.readEntry( entryName ); 694// QString linkFile = cfg.readEntry( entryName );
704 QListViewItemIterator it( audioView ); 695 QListViewItemIterator it( audioView );
705 // iterate through all items of the listview 696 // iterate through all items of the listview
706 for ( ; it.current(); ++it ) { 697 for ( ; it.current(); ++it ) {
707 if ( it.current()->isSelected() ) { 698 if ( it.current()->isSelected() ) {
708 QListIterator<DocLnk> dit( files.children() ); 699 QListIterator<DocLnk> dit( files.children() );
709 for ( ; dit.current(); ++dit ) { 700 for ( ; dit.current(); ++dit ) {
710 if( dit.current()->name() == it.current()->text(0) ) { 701 if( dit.current()->name() == it.current()->text(0) ) {
711 d->selectedFiles->addToSelection( **dit ); 702 d->selectedFiles->addToSelection( **dit );
712 } 703 }
713 } 704 }
714 audioView->setSelected( it.current(),FALSE); 705 audioView->setSelected( it.current(),FALSE);
715 } 706 }
716 } 707 }
717 tabWidget->setCurrentPage(0); 708 tabWidget->setCurrentPage(0);
718 } 709 }
719 break; 710 break;
720 case 2: { // video 711 case 2: { // video
721 QListViewItemIterator it( videoView ); 712 QListViewItemIterator it( videoView );
722 // iterate through all items of the listview 713 // iterate through all items of the listview
723 for ( ; it.current(); ++it ) { 714 for ( ; it.current(); ++it ) {
724 if ( it.current()->isSelected() ) { 715 if ( it.current()->isSelected() ) {
725 QListIterator<DocLnk> dit( vFiles.children() ); 716 QListIterator<DocLnk> dit( vFiles.children() );
726 for ( ; dit.current(); ++dit ) { 717 for ( ; dit.current(); ++dit ) {
727 if( dit.current()->name() == it.current()->text(0) ) { 718 if( dit.current()->name() == it.current()->text(0) ) {
728 d->selectedFiles->addToSelection( **dit ); 719 d->selectedFiles->addToSelection( **dit );
729 } 720 }
730 } 721 }
731 722
732 videoView->setSelected( it.current(),FALSE); 723 videoView->setSelected( it.current(),FALSE);
733 } 724 }
734 } 725 }
735// for ( int i = 0; i < noOfFiles; i++ ) { 726// for ( int i = 0; i < noOfFiles; i++ ) {
736// QString entryName; 727// QString entryName;
737// entryName.sprintf( "File%i", i + 1 ); 728// entryName.sprintf( "File%i", i + 1 );
738// QString linkFile = cfg.readEntry( entryName ); 729// QString linkFile = cfg.readEntry( entryName );
739// if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) { 730// if( DocLnk( linkFile).name() == videoView->selectedItem()->text(0) ) {
740// int result= QMessageBox::warning(this,tr("OpiePlayer"), 731// int result= QMessageBox::warning(this,tr("OpiePlayer"),
741// tr("This is all ready in your playlist.\nContinue?"), 732// tr("This is all ready in your playlist.\nContinue?"),
742// tr("Yes"),tr("No"),0,0,1); 733// tr("Yes"),tr("No"),0,0,1);
743// if (result !=0) 734// if (result !=0)
744// return; 735// return;
745// } 736// }
746// } 737// }
747// addToSelection( videoView->selectedItem() ); 738// addToSelection( videoView->selectedItem() );
748 tabWidget->setCurrentPage(0); 739 tabWidget->setCurrentPage(0);
749 } 740 }
750 break; 741 break;
751 }; 742 };
752} 743}
753 744
754void PlayListWidget::removeSelected() { 745void PlayListWidget::removeSelected() {
755 d->selectedFiles->removeSelected( ); 746 d->selectedFiles->removeSelected( );
756} 747}
757 748
758void PlayListWidget::playIt( QListViewItem *it) { 749void PlayListWidget::playIt( QListViewItem *it) {
759// d->setDocumentUsed = FALSE; 750// d->setDocumentUsed = FALSE;
760 mediaPlayerState->setPlaying(FALSE); 751 mediaPlayerState->setPlaying(FALSE);
761 mediaPlayerState->setPlaying(TRUE); 752 mediaPlayerState->setPlaying(TRUE);
762 d->selectedFiles->unSelect(); 753 d->selectedFiles->unSelect();
763} 754}
764 755
765void PlayListWidget::addToSelection( QListViewItem *it) { 756void PlayListWidget::addToSelection( QListViewItem *it) {
766 d->setDocumentUsed = FALSE; 757 d->setDocumentUsed = FALSE;
767 758
768 if(it) { 759 if(it) {
769 switch (tabWidget->currentPageIndex()) { 760 switch (tabWidget->currentPageIndex()) {
770 case 1: { 761 case 1: {
771 QListIterator<DocLnk> dit( files.children() ); 762 QListIterator<DocLnk> dit( files.children() );
772 for ( ; dit.current(); ++dit ) { 763 for ( ; dit.current(); ++dit ) {
773 if( dit.current()->name() == it->text(0)) { 764 if( dit.current()->name() == it->text(0)) {
774 d->selectedFiles->addToSelection( **dit ); 765 d->selectedFiles->addToSelection( **dit );
775 } 766 }
776 } 767 }
777 } 768 }
778 break; 769 break;
779 case 2: { 770 case 2: {
780 QListIterator<DocLnk> dit( vFiles.children() ); 771 QListIterator<DocLnk> dit( vFiles.children() );
781 for ( ; dit.current(); ++dit ) { 772 for ( ; dit.current(); ++dit ) {
782 if( dit.current()->name() == it->text(0)) { 773 if( dit.current()->name() == it->text(0)) {
783 d->selectedFiles->addToSelection( **dit ); 774 d->selectedFiles->addToSelection( **dit );
784 } 775 }
785 } 776 }
786 } 777 }
787 break; 778 break;
788 case 0: 779 case 0:
789 break; 780 break;
790 }; 781 };
791 tabWidget->setCurrentPage(0); 782 tabWidget->setCurrentPage(0);
792 } 783 }
793} 784}
794 785
795void PlayListWidget::tabChanged(QWidget *widg) { 786void PlayListWidget::tabChanged(QWidget *widg) {
796 787
797 switch ( tabWidget->currentPageIndex()) { 788 switch ( tabWidget->currentPageIndex()) {
798 case 0: 789 case 0:
799 { 790 {
800 if( !tbDeletePlaylist->isHidden()) 791 if( !tbDeletePlaylist->isHidden())
801 tbDeletePlaylist->hide(); 792 tbDeletePlaylist->hide();
802 d->tbRemoveFromList->setEnabled(TRUE); 793 d->tbRemoveFromList->setEnabled(TRUE);
803 d->tbAddToList->setEnabled(FALSE); 794 d->tbAddToList->setEnabled(FALSE);
804 } 795 }
805 break; 796 break;
806 case 1: 797 case 1:
807 { 798 {
808 if( !tbDeletePlaylist->isHidden()) 799 if( !tbDeletePlaylist->isHidden())
809 tbDeletePlaylist->hide(); 800 tbDeletePlaylist->hide();
810 d->tbRemoveFromList->setEnabled(FALSE); 801 d->tbRemoveFromList->setEnabled(FALSE);
811 d->tbAddToList->setEnabled(TRUE); 802 d->tbAddToList->setEnabled(TRUE);
812 } 803 }
813 break; 804 break;
814 case 2: 805 case 2:
815 { 806 {
816 if( !tbDeletePlaylist->isHidden()) 807 if( !tbDeletePlaylist->isHidden())
817 tbDeletePlaylist->hide(); 808 tbDeletePlaylist->hide();
818 d->tbRemoveFromList->setEnabled(FALSE); 809 d->tbRemoveFromList->setEnabled(FALSE);
819 d->tbAddToList->setEnabled(TRUE); 810 d->tbAddToList->setEnabled(TRUE);
820 } 811 }
821 break; 812 break;
822 case 3: 813 case 3:
823 { 814 {
824 if( tbDeletePlaylist->isHidden()) 815 if( tbDeletePlaylist->isHidden())
825 tbDeletePlaylist->show(); 816 tbDeletePlaylist->show();
826 playLists->reread(); 817 playLists->reread();
827 } 818 }
828 break; 819 break;
829 }; 820 };
830} 821}
831 822
832 823
833 824
834void PlayListWidget::btnPlay(bool b) { 825void PlayListWidget::btnPlay(bool b) {
835 826
836// mediaPlayerState->setPlaying(b); 827// mediaPlayerState->setPlaying(b);
837 switch ( tabWidget->currentPageIndex()) { 828 switch ( tabWidget->currentPageIndex()) {
838 case 0: 829 case 0:
839 { 830 {
840 mediaPlayerState->setPlaying(b); 831 mediaPlayerState->setPlaying(b);
841 } 832 }
842 break; 833 break;
843 case 1: 834 case 1:
844 { 835 {
845 addToSelection( audioView->selectedItem() ); 836 addToSelection( audioView->selectedItem() );
846 mediaPlayerState->setPlaying(b); 837 mediaPlayerState->setPlaying(b);
847 d->selectedFiles->removeSelected( ); 838 d->selectedFiles->removeSelected( );
848 tabWidget->setCurrentPage(1); 839 tabWidget->setCurrentPage(1);
849 d->selectedFiles->unSelect(); 840 d->selectedFiles->unSelect();
841 insanityBool=FALSE;
850// audioView->clearSelection(); 842// audioView->clearSelection();
851 } 843 }
852 break; 844 break;
853 case 2: 845 case 2:
854 { 846 {
855 addToSelection( videoView->selectedItem() ); 847 addToSelection( videoView->selectedItem() );
856 mediaPlayerState->setPlaying(b); 848 mediaPlayerState->setPlaying(b);
857 qApp->processEvents(); 849 qApp->processEvents();
858 d->selectedFiles->removeSelected( ); 850 d->selectedFiles->removeSelected( );
859 tabWidget->setCurrentPage(2); 851 tabWidget->setCurrentPage(2);
860 d->selectedFiles->unSelect(); 852 d->selectedFiles->unSelect();
853 insanityBool=FALSE;
861// videoView->clearSelection(); 854// videoView->clearSelection();
862 } 855 }
863 break; 856 break;
864 }; 857 };
865} 858}
866 859
867void PlayListWidget::deletePlaylist() { 860void PlayListWidget::deletePlaylist() {
868 switch( QMessageBox::information( this, (tr("Remove Playlist?")), 861 switch( QMessageBox::information( this, (tr("Remove Playlist?")),
869 (tr("You really want to delete\nthis playlist?")), 862 (tr("You really want to delete\nthis playlist?")),
870 (tr("Yes")), (tr("No")), 0 )){ 863 (tr("Yes")), (tr("No")), 0 )){
871 case 0: // Yes clicked, 864 case 0: // Yes clicked,
872 QFile().remove(playLists->selected()->file()); 865 QFile().remove(playLists->selected()->file());
873 QFile().remove(playLists->selected()->linkFile()); 866 QFile().remove(playLists->selected()->linkFile());
874 playLists->reread(); 867 playLists->reread();
875 break; 868 break;
876 case 1: // Cancel 869 case 1: // Cancel
877 break; 870 break;
878 }; 871 };
879 872
880} 873}
881 874
882void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) 875void PlayListWidget::viewPressed( int mouse, QListViewItem *item, const QPoint& point, int i)
883{ 876{
884 switch (mouse) { 877 switch (mouse) {
885 case 1: 878 case 1:
886 break; 879 break;
887 case 2:{ 880 case 2:{
888 QPopupMenu m; 881 QPopupMenu m;
889 m.insertItem( tr( "Play" ), this, SLOT( playSelected() )); 882 m.insertItem( tr( "Play" ), this, SLOT( playSelected() ));
890 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() )); 883 m.insertItem( tr( "Add to Playlist" ), this, SLOT( addSelected() ));
891 m.insertSeparator(); 884 m.insertSeparator();
892 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() )); 885 m.insertItem( tr( "Properties" ), this, SLOT( listDelete() ));
893 m.exec( QCursor::pos() ); 886 m.exec( QCursor::pos() );
894 } 887 }
895 break; 888 break;
896 }; 889 };
897} 890}
898 891
899void PlayListWidget::playSelected() 892void PlayListWidget::playSelected()
900{ 893{
901 btnPlay( TRUE); 894 btnPlay( TRUE);
902 d->selectedFiles->unSelect(); 895// d->selectedFiles->unSelect();
903} 896}
904 897
905void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i) 898void PlayListWidget::playlistViewPressed( int mouse, QListViewItem *item, const QPoint& point, int i)
906{ 899{
907 switch (mouse) { 900 switch (mouse) {
908 case 1: 901 case 1:
909 902
910 break; 903 break;
911 case 2:{ 904 case 2:{
912 QPopupMenu m; 905 QPopupMenu m;
913 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() )); 906 m.insertItem( tr( "Play Selected" ), this, SLOT( playSelected() ));
914 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() )); 907 m.insertItem( tr( "Remove" ), this, SLOT( removeSelected() ));
915// m.insertSeparator(); 908// m.insertSeparator();
916 m.exec( QCursor::pos() ); 909 m.exec( QCursor::pos() );
917 } 910 }
918 break; 911 break;
919 }; 912 };
920 913
921} 914}
922 915
923void PlayListWidget::listDelete() { 916void PlayListWidget::listDelete() {
924 Config cfg( "OpiePlayer" ); 917 Config cfg( "OpiePlayer" );
925 cfg.setGroup("PlayList"); 918 cfg.setGroup("PlayList");
926 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 919 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
927 QString file; 920 QString file;
928 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 921 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
929 switch ( tabWidget->currentPageIndex()) { 922 switch ( tabWidget->currentPageIndex()) {
930 case 0: 923 case 0:
931 break; 924 break;
932 case 1: 925 case 1:
933 { 926 {
934 file = audioView->selectedItem()->text(0); 927 file = audioView->selectedItem()->text(0);
935// Global::findDocuments(&files, "audio/*"); 928// Global::findDocuments(&files, "audio/*");
936// AppLnkSet appFiles; 929// AppLnkSet appFiles;
937 QListIterator<DocLnk> dit( files.children() ); 930 QListIterator<DocLnk> dit( files.children() );
938 for ( ; dit.current(); ++dit ) { 931 for ( ; dit.current(); ++dit ) {
939 if( dit.current()->name() == file) { 932 if( dit.current()->name() == file) {
940// qDebug(file); 933// qDebug(file);
941 LnkProperties prop( dit.current() ); 934 LnkProperties prop( dit.current() );
942// connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 935// connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
943 prop.showMaximized(); 936 prop.showMaximized();
944 prop.exec(); 937 prop.exec();
945 } 938 }
946 } 939 }
947 populateAudioView(); 940 populateAudioView();
948 } 941 }
949 break; 942 break;
950 case 2: 943 case 2:
951 { 944 {
952// file = videoView->selectedItem()->text(0); 945// file = videoView->selectedItem()->text(0);
953// for ( int i = 0; i < noOfFiles; i++ ) { 946// for ( int i = 0; i < noOfFiles; i++ ) {
954// QString entryName; 947// QString entryName;
955// entryName.sprintf( "File%i", i + 1 ); 948// entryName.sprintf( "File%i", i + 1 );
956// QString linkFile = cfg.readEntry( entryName ); 949// QString linkFile = cfg.readEntry( entryName );
957// AppLnk lnk( AppLnk(linkFile)); 950// AppLnk lnk( AppLnk(linkFile));
958// if( lnk.name() == file ) { 951// if( lnk.name() == file ) {
959// LnkProperties prop( &lnk); 952// LnkProperties prop( &lnk);
960// // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 953// // connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
961// prop.showMaximized(); 954// prop.showMaximized();
962// prop.exec(); 955// prop.exec();
963// } 956// }
964// } 957// }
965 } 958 }
966 break; 959 break;
967 }; 960 };
968} 961}
969 962
970void PlayListWidget::populateAudioView() { 963void PlayListWidget::populateAudioView() {
971// if(files) 964// if(files)
972// files.~DocLnkSet(); 965// files.~DocLnkSet();
973 StorageInfo storageInfo; 966 StorageInfo storageInfo;
974 const QList<FileSystem> &fs = storageInfo.fileSystems(); 967 const QList<FileSystem> &fs = storageInfo.fileSystems();
975 968
976 Global::findDocuments(&files, "audio/*"); 969 Global::findDocuments(&files, "audio/*");
977 QListIterator<DocLnk> dit( files.children() ); 970 QListIterator<DocLnk> dit( files.children() );
978 QListIterator<FileSystem> it ( fs ); 971 QListIterator<FileSystem> it ( fs );
979 audioView->clear(); 972 audioView->clear();
980 QString storage; 973 QString storage;
981 for ( ; dit.current(); ++dit ) { 974 for ( ; dit.current(); ++dit ) {
982 for( ; it.current(); ++it ){ 975 for( ; it.current(); ++it ){
983 const QString name = (*it)->name(); 976 const QString name = (*it)->name();
984 const QString path = (*it)->path(); 977 const QString path = (*it)->path();
985 if(dit.current()->file().find(path) != -1 ) storage=name; 978 if(dit.current()->file().find(path) != -1 ) storage=name;
986 } 979 }
987 980
988 QListViewItem * newItem; 981 QListViewItem * newItem;
989 if ( QFile( dit.current()->file()).exists() ) { 982 if ( QFile( dit.current()->file()).exists() ) {
990 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage); 983 newItem= /*(void)*/ new QListViewItem( audioView, dit.current()->name(), QString::number( QFile( dit.current()->file()).size() ), storage);
991 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" )); 984 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/musicfile" ));
992 } 985 }
993 } 986 }
994} 987}
995 988
996void PlayListWidget::populateVideoView() { 989void PlayListWidget::populateVideoView() {
997 StorageInfo storageInfo; 990 StorageInfo storageInfo;
998 const QList<FileSystem> &fs = storageInfo.fileSystems(); 991 const QList<FileSystem> &fs = storageInfo.fileSystems();
999 992
1000 Global::findDocuments(&vFiles, "video/*"); 993 Global::findDocuments(&vFiles, "video/*");
1001 QListIterator<DocLnk> Vdit( vFiles.children() ); 994 QListIterator<DocLnk> Vdit( vFiles.children() );
1002 QListIterator<FileSystem> it ( fs ); 995 QListIterator<FileSystem> it ( fs );
1003 videoView->clear(); 996 videoView->clear();
1004 QString storage; 997 QString storage;
1005 for ( ; Vdit.current(); ++Vdit ) { 998 for ( ; Vdit.current(); ++Vdit ) {
1006 for( ; it.current(); ++it ){ 999 for( ; it.current(); ++it ){
1007 const QString name = (*it)->name(); 1000 const QString name = (*it)->name();
1008 const QString path = (*it)->path(); 1001 const QString path = (*it)->path();
1009 if( Vdit.current()->file().find(path) != -1 ) storage=name; 1002 if( Vdit.current()->file().find(path) != -1 ) storage=name;
1010 } 1003 }
1011 1004
1012 QListViewItem * newItem; 1005 QListViewItem * newItem;
1013 if ( QFile( Vdit.current()->file()).exists() ) { 1006 if ( QFile( Vdit.current()->file()).exists() ) {
1014 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage); 1007 newItem= /*(void)*/ new QListViewItem( videoView, Vdit.current()->name(), QString::number( QFile( Vdit.current()->file()).size() ), storage);
1015 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" )); 1008 newItem->setPixmap(0, Resource::loadPixmap( "opieplayer/videofile" ));
1016 } 1009 }
1017 } 1010 }
1018} 1011}
1019 1012
1020void PlayListWidget::openFile() { 1013void PlayListWidget::openFile() {
1021 QString filename, name; 1014 QString filename, name;
1022 InputDialog *fileDlg; 1015 InputDialog *fileDlg;
1023 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0); 1016 fileDlg = new InputDialog(this,tr("Open file or URL"),TRUE, 0);
1024 fileDlg->exec(); 1017 fileDlg->exec();
1025 if( fileDlg->result() == 1 ) { 1018 if( fileDlg->result() == 1 ) {
1026 filename = fileDlg->LineEdit1->text(); 1019 filename = fileDlg->LineEdit1->text();
1027
1028// InputDialog *fileDlg2;
1029// fileDlg2 = new InputDialog(this,tr("Name"),TRUE, 0);
1030// fileDlg2->exec();
1031// if( fileDlg2->result() == 1 ) {
1032// name = fileDlg2->LineEdit1->text();
1033// }
1034//http://205.188.234.129:8030 1020//http://205.188.234.129:8030
1035// http://66.28.68.70:8000 1021// http://66.28.68.70:8000
1036 qDebug(filename); 1022 qDebug(filename);
1037 DocLnk lnk; 1023 if(filename.right(3) == "m3u")
1038// if(filename.left(7) == "http://") 1024 readm3u( filename);
1039// name= filename.right(filename.length()-filename.find("http://")-7); 1025 else if(filename.right(3) == "pls")
1040// else name = filename; 1026 readPls( filename);
1041// qDebug("name is "+name); 1027 else {
1042// lnk.setComment(filename); 1028 DocLnk lnk;
1043 lnk.setName(filename); //sets file name 1029
1044 if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3") 1030 lnk.setName(filename); //sets file name
1045 filename += "/"; 1031 if(filename.right(1) != "/" && filename.right(3) != "mp3" && filename.right(3) != "MP3")
1046 lnk.setFile(filename); //sets File property 1032 filename += "/";
1047 1033 lnk.setFile(filename); //sets File property
1048 lnk.setType("audio/x-mpegurl"); 1034
1049 lnk.setExec("opieplayer"); 1035 lnk.setType("audio/x-mpegurl");
1050 lnk.setIcon("opieplayer/MPEGPlayer"); 1036 lnk.setExec("opieplayer");
1051 1037 lnk.setIcon("opieplayer/MPEGPlayer");
1052 if(!lnk.writeLink()) 1038
1053 qDebug("Writing doclink did not work"); 1039 if(!lnk.writeLink())
1054 d->selectedFiles->addToSelection( lnk); 1040 qDebug("Writing doclink did not work");
1041 d->selectedFiles->addToSelection( lnk);
1055// if(fileDlg2) 1042// if(fileDlg2)
1056// delete fileDlg2; 1043// delete fileDlg2;
1044 }
1057 } 1045 }
1058
1059 if(fileDlg) 1046 if(fileDlg)
1060 delete fileDlg; 1047 delete fileDlg;
1061} 1048}
1062 1049
1063void PlayListWidget::keyReleaseEvent( QKeyEvent *e) 1050void PlayListWidget::keyReleaseEvent( QKeyEvent *e)
1064{ 1051{
1065 switch ( e->key() ) { 1052 switch ( e->key() ) {
1066////////////////////////////// Zaurus keys 1053////////////////////////////// Zaurus keys
1067 case Key_F9: //activity 1054 case Key_F9: //activity
1068// if(audioUI->isHidden()) 1055// if(audioUI->isHidden())
1069// audioUI->showMaximized(); 1056// audioUI->showMaximized();
1070 break; 1057 break;
1071 case Key_F10: //contacts 1058 case Key_F10: //contacts
1072// if( videoUI->isHidden()) 1059// if( videoUI->isHidden())
1073// videoUI->showMaximized(); 1060// videoUI->showMaximized();
1074 break; 1061 break;
1075 case Key_F11: //menu 1062 case Key_F11: //menu
1076 break; 1063 break;
1077 case Key_F12: //home 1064 case Key_F12: //home
1078// doBlank(); 1065// doBlank();
1079 break; 1066 break;
1080 case Key_F13: //mail 1067 case Key_F13: //mail
1081// doUnblank(); 1068// doUnblank();
1082 break; 1069 break;
1083 1070
1084 } 1071 }
1085} 1072}
1086 1073
1087void PlayListWidget::doBlank() { 1074void PlayListWidget::doBlank() {
1088 qDebug("do blanking"); 1075 qDebug("do blanking");
1089 fd=open("/dev/fb0",O_RDWR); 1076 fd=open("/dev/fb0",O_RDWR);
1090 if (fd != -1) { 1077 if (fd != -1) {
1091 ioctl(fd,FBIOBLANK,1); 1078 ioctl(fd,FBIOBLANK,1);
1092// close(fd); 1079// close(fd);
1093 } 1080 }
1094} 1081}
1095 1082
1096void PlayListWidget::doUnblank() { 1083void PlayListWidget::doUnblank() {
1097 // this crashes opieplayer with a segfault 1084 // this crashes opieplayer with a segfault
1098// int fd; 1085// int fd;
1099// fd=open("/dev/fb0",O_RDWR); 1086// fd=open("/dev/fb0",O_RDWR);
1100 qDebug("do unblanking"); 1087 qDebug("do unblanking");
1101 if (fd != -1) { 1088 if (fd != -1) {
1102 ioctl(fd,FBIOBLANK,0); 1089 ioctl(fd,FBIOBLANK,0);
1103 close(fd); 1090 close(fd);
1104 } 1091 }
1105 QCopEnvelope h("QPE/System", "setBacklight(int)"); 1092 QCopEnvelope h("QPE/System", "setBacklight(int)");
1106 h <<-3;// v[1]; // -3 Force on 1093 h <<-3;// v[1]; // -3 Force on
1107} 1094}
1095
1096void PlayListWidget::readm3u(const QString &filename) {
1097
1098}
1099
1100void PlayListWidget::writem3u(const QString &filename) {
1101
1102}
1103
1104void PlayListWidget::readPls(const QString &filename) {
1105
1106}
diff --git a/core/multimedia/opieplayer/playlistwidget.h b/core/multimedia/opieplayer/playlistwidget.h
index f22770f..c07d4f8 100644
--- a/core/multimedia/opieplayer/playlistwidget.h
+++ b/core/multimedia/opieplayer/playlistwidget.h
@@ -1,117 +1,121 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef PLAY_LIST_WIDGET_H 20#ifndef PLAY_LIST_WIDGET_H
21#define PLAY_LIST_WIDGET_H 21#define PLAY_LIST_WIDGET_H
22 22
23#include <qmainwindow.h> 23#include <qmainwindow.h>
24#include <qpe/applnk.h> 24#include <qpe/applnk.h>
25#include <qtabwidget.h> 25#include <qtabwidget.h>
26#include <qpe/fileselector.h> 26#include <qpe/fileselector.h>
27#include <qpushbutton.h> 27#include <qpushbutton.h>
28 28
29/* #include <qtimer.h> */ 29/* #include <qtimer.h> */
30 30
31 31
32class PlayListWidgetPrivate; 32class PlayListWidgetPrivate;
33class Config; 33class Config;
34class QListViewItem; 34class QListViewItem;
35class QListView; 35class QListView;
36class QPoint; 36class QPoint;
37class QAction; 37class QAction;
38class QLabel; 38class QLabel;
39 39
40class PlayListWidget : public QMainWindow { 40class PlayListWidget : public QMainWindow {
41 Q_OBJECT 41 Q_OBJECT
42public: 42public:
43 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 ); 43 PlayListWidget( QWidget* parent=0, const char* name=0, WFlags fl=0 );
44 ~PlayListWidget(); 44 ~PlayListWidget();
45 QTabWidget * tabWidget; 45 QTabWidget * tabWidget;
46 QAction *fullScreenButton, *scaleButton; 46 QAction *fullScreenButton, *scaleButton;
47 DocLnkSet files; 47 DocLnkSet files;
48 DocLnkSet vFiles; 48 DocLnkSet vFiles;
49 QListView *audioView, *videoView, *playlistView; 49 QListView *audioView, *videoView, *playlistView;
50 QLabel *libString; 50 QLabel *libString;
51 bool fromSetDocument; 51 bool fromSetDocument;
52 bool insanityBool; 52 bool insanityBool;
53 QString setDocFileRef; 53 QString setDocFileRef;
54 // retrieve the current playlist entry (media file link) 54 // retrieve the current playlist entry (media file link)
55 const DocLnk *current(); 55 const DocLnk *current();
56 void useSelectedDocument(); 56 void useSelectedDocument();
57/* QTimer * menuTimer; */ 57/* QTimer * menuTimer; */
58 FileSelector* playLists; 58 FileSelector* playLists;
59 QPushButton *tbDeletePlaylist; 59 QPushButton *tbDeletePlaylist;
60 int fd; 60 int fd;
61public slots: 61public slots:
62 bool first(); 62 bool first();
63 bool last(); 63 bool last();
64 bool next(); 64 bool next();
65 bool prev(); 65 bool prev();
66/* void setFullScreen(); */ 66/* void setFullScreen(); */
67/* void setScaled(); */ 67/* void setScaled(); */
68protected: 68protected:
69/* void contentsMousePressEvent( QMouseEvent * e ); */ 69/* void contentsMousePressEvent( QMouseEvent * e ); */
70/* void contentsMouseReleaseEvent( QMouseEvent * e ); */ 70/* void contentsMouseReleaseEvent( QMouseEvent * e ); */
71void keyReleaseEvent( QKeyEvent *e); 71void keyReleaseEvent( QKeyEvent *e);
72private: 72private:
73 void doBlank(); 73 void doBlank();
74 void doUnblank(); 74 void doUnblank();
75 75 void readm3u(const QString &);
76 void writem3u(const QString &);
77 void readPls(const QString &);
78
79
76 void initializeStates(); 80 void initializeStates();
77 void readConfig( Config& cfg ); 81 void readConfig( Config& cfg );
78 void writeConfig( Config& cfg ) const; 82 void writeConfig( Config& cfg ) const;
79 PlayListWidgetPrivate *d; // Private implementation data 83 PlayListWidgetPrivate *d; // Private implementation data
80 void populateAudioView(); 84 void populateAudioView();
81 void populateVideoView(); 85 void populateVideoView();
82private slots: 86private slots:
83 void openFile(); 87 void openFile();
84 void setDocument( const QString& fileref ); 88 void setDocument( const QString& fileref );
85 void addToSelection( const DocLnk& ); // Add a media file to the playlist 89 void addToSelection( const DocLnk& ); // Add a media file to the playlist
86 void addToSelection( QListViewItem* ); // Add a media file to the playlist 90 void addToSelection( QListViewItem* ); // Add a media file to the playlist
87 void setActiveWindow(); // need to handle this to show the right view 91 void setActiveWindow(); // need to handle this to show the right view
88 void setPlaylist( bool ); // Show/Hide the playlist 92 void setPlaylist( bool ); // Show/Hide the playlist
89 void setView( char ); 93 void setView( char );
90 void clearList(); 94 void clearList();
91 void addAllToList(); 95 void addAllToList();
92 void addAllMusicToList(); 96 void addAllMusicToList();
93 void addAllVideoToList(); 97 void addAllVideoToList();
94 void saveList(); // Save the playlist 98 void saveList(); // Save the playlist
95 void loadList( const DocLnk &); // Load a playlist 99 void loadList( const DocLnk &); // Load a playlist
96 void playIt( QListViewItem *); 100 void playIt( QListViewItem *);
97 101
98 void btnPlay(bool); 102 void btnPlay(bool);
99 void deletePlaylist(); 103 void deletePlaylist();
100 void addSelected(); 104 void addSelected();
101 void removeSelected(); 105 void removeSelected();
102 void tabChanged(QWidget*); 106 void tabChanged(QWidget*);
103 void viewPressed( int, QListViewItem *, const QPoint&, int); 107 void viewPressed( int, QListViewItem *, const QPoint&, int);
104 void playlistViewPressed( int, QListViewItem *, const QPoint&, int); 108 void playlistViewPressed( int, QListViewItem *, const QPoint&, int);
105 void playSelected(); 109 void playSelected();
106 void listDelete(); 110 void listDelete();
107 111
108protected slots: 112protected slots:
109/* void cancelMenuTimer(); */ 113/* void cancelMenuTimer(); */
110/* void showFileMenu(); */ 114/* void showFileMenu(); */
111 115
112 116
113}; 117};
114 118
115 119
116#endif // PLAY_LIST_WIDGET_H 120#endif // PLAY_LIST_WIDGET_H
117 121
diff --git a/core/multimedia/opieplayer/videowidget.cpp b/core/multimedia/opieplayer/videowidget.cpp
index 3bce996..97997f9 100644
--- a/core/multimedia/opieplayer/videowidget.cpp
+++ b/core/multimedia/opieplayer/videowidget.cpp
@@ -1,463 +1,474 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qpe/resource.h> 20#include <qpe/resource.h>
21#include <qpe/mediaplayerplugininterface.h> 21#include <qpe/mediaplayerplugininterface.h>
22#include <qpe/config.h>
23
22#include <qwidget.h> 24#include <qwidget.h>
23#include <qpainter.h> 25#include <qpainter.h>
24#include <qpixmap.h> 26#include <qpixmap.h>
25#include <qslider.h> 27#include <qslider.h>
26#include <qdrawutil.h> 28#include <qdrawutil.h>
27#include "videowidget.h" 29#include "videowidget.h"
28#include "mediaplayerstate.h" 30#include "mediaplayerstate.h"
29 31
30 32
31#ifdef Q_WS_QWS 33#ifdef Q_WS_QWS
32# define USE_DIRECT_PAINTER 34# define USE_DIRECT_PAINTER
33# include <qdirectpainter_qws.h> 35# include <qdirectpainter_qws.h>
34# include <qgfxraster_qws.h> 36# include <qgfxraster_qws.h>
35#endif 37#endif
36 38
37 39
38extern MediaPlayerState *mediaPlayerState; 40extern MediaPlayerState *mediaPlayerState;
39 41
40 42
41static const int xo = 2; // movable x offset 43static const int xo = 2; // movable x offset
42static const int yo = 0; // movable y offset 44static const int yo = 0; // movable y offset
43 45
44 46
45struct MediaButton { 47struct MediaButton {
46 int xPos, yPos; 48 int xPos, yPos;
47 bool isToggle, isHeld, isDown; 49 bool isToggle, isHeld, isDown;
48 int controlType; 50 int controlType;
49}; 51};
50 52
51 53
52// Layout information for the videoButtons (and if it is a toggle button or not) 54// Layout information for the videoButtons (and if it is a toggle button or not)
53MediaButton videoButtons[] = { 55MediaButton videoButtons[] = {
54 { 5+0*32+xo, 200+yo, FALSE, FALSE, FALSE, 4 }, // previous 56 { 5+0*32+xo, 200+yo, FALSE, FALSE, FALSE, 4 }, // previous
55 { 5+1*32+xo, 200+yo, FALSE, FALSE, FALSE, 1 }, // stop 57 { 5+1*32+xo, 200+yo, FALSE, FALSE, FALSE, 1 }, // stop
56 { 5+2*32+xo, 200+yo, TRUE, FALSE, FALSE, 0 }, // play 58 { 5+2*32+xo, 200+yo, TRUE, FALSE, FALSE, 0 }, // play
57 { 5+3*32+xo, 200+yo, TRUE, FALSE, FALSE, 2 }, // pause 59 { 5+3*32+xo, 200+yo, TRUE, FALSE, FALSE, 2 }, // pause
58 { 5+4*32+xo, 200+yo, FALSE, FALSE, FALSE, 3 }, // next 60 { 5+4*32+xo, 200+yo, FALSE, FALSE, FALSE, 3 }, // next
59 { 5+5*32+xo, 200+yo, FALSE, FALSE, FALSE, 8 }, // playlist 61 { 5+5*32+xo, 200+yo, FALSE, FALSE, FALSE, 8 }, // playlist
60 { 5+6*32+xo, 200+yo, TRUE, FALSE, FALSE, 9 } // fullscreen 62 { 5+6*32+xo, 200+yo, TRUE, FALSE, FALSE, 9 } // fullscreen
61}; 63};
62 64
63 65
64static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton)); 66static const int numButtons = (sizeof(videoButtons)/sizeof(MediaButton));
65 67
66 68
67VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : 69VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) :
68 QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { 70 QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) {
69 setCaption( tr("OpiePlayer") ); 71 setCaption( tr("OpiePlayer") );
70 setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); 72 Config cfg("OpiePlayer");
71 pixmaps[0] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaButton0a" ) ); 73 cfg.setGroup("VideoWidget");
72 pixmaps[1] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaButton0b" ) ); 74
73 pixmaps[2] = new QPixmap( Resource::loadPixmap( "opieplayer/mediaControls0" ) ); 75 QString backgroundPix, Button0aPix, Button0bPix, controlsPix;
76 backgroundPix=cfg.readEntry( "backgroundPix", "opieplayer/metalFinish");
77 Button0aPix=cfg.readEntry( "Button0aPix", "opieplayer/mediaButton0a");
78 Button0bPix=cfg.readEntry( "Button0bPix","opieplayer/mediaButton0b");
79 controlsPix=cfg.readEntry( "controlsPix","opieplayer/mediaControls0" );
80
81 setBackgroundPixmap( Resource::loadPixmap( backgroundPix) );
82 pixmaps[0] = new QPixmap( Resource::loadPixmap( Button0aPix ) );
83 pixmaps[1] = new QPixmap( Resource::loadPixmap( Button0bPix ) );
84 pixmaps[2] = new QPixmap( Resource::loadPixmap( controlsPix) );
74 currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 ); 85 currentFrame = new QImage( 220 + 2, 160, (QPixmap::defaultDepth() == 16) ? 16 : 32 );
75 86
76 slider = new QSlider( Qt::Horizontal, this ); 87 slider = new QSlider( Qt::Horizontal, this );
77 slider->setMinValue( 0 ); 88 slider->setMinValue( 0 );
78 slider->setMaxValue( 1 ); 89 slider->setMaxValue( 1 );
79 slider->setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); 90 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
80 slider->setFocusPolicy( QWidget::NoFocus ); 91 slider->setFocusPolicy( QWidget::NoFocus );
81 slider->setGeometry( QRect( 7, 250, 220, 20 ) ); 92 slider->setGeometry( QRect( 7, 250, 220, 20 ) );
82 93
83 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 94 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
84 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 95 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
85 96
86 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 97 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
87 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 98 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
88 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 99 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
89 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 100 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
90 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 101 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
91 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 102 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
92 103
93 // Intialise state 104 // Intialise state
94 setLength( mediaPlayerState->length() ); 105 setLength( mediaPlayerState->length() );
95 setPosition( mediaPlayerState->position() ); 106 setPosition( mediaPlayerState->position() );
96 setFullscreen( mediaPlayerState->fullscreen() ); 107 setFullscreen( mediaPlayerState->fullscreen() );
97 setPaused( mediaPlayerState->paused() ); 108 setPaused( mediaPlayerState->paused() );
98 setPlaying( mediaPlayerState->playing() ); 109 setPlaying( mediaPlayerState->playing() );
99} 110}
100 111
101 112
102VideoWidget::~VideoWidget() { 113VideoWidget::~VideoWidget() {
103 for ( int i = 0; i < 3; i++ ) 114 for ( int i = 0; i < 3; i++ )
104 delete pixmaps[i]; 115 delete pixmaps[i];
105 delete currentFrame; 116 delete currentFrame;
106} 117}
107 118
108 119
109static bool videoSliderBeingMoved = FALSE; 120static bool videoSliderBeingMoved = FALSE;
110 121
111 122
112void VideoWidget::sliderPressed() { 123void VideoWidget::sliderPressed() {
113 videoSliderBeingMoved = TRUE; 124 videoSliderBeingMoved = TRUE;
114} 125}
115 126
116 127
117void VideoWidget::sliderReleased() { 128void VideoWidget::sliderReleased() {
118 videoSliderBeingMoved = FALSE; 129 videoSliderBeingMoved = FALSE;
119 if ( slider->width() == 0 ) 130 if ( slider->width() == 0 )
120 return; 131 return;
121 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); 132 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width());
122 mediaPlayerState->setPosition( val ); 133 mediaPlayerState->setPosition( val );
123} 134}
124 135
125 136
126void VideoWidget::setPosition( long i ) { 137void VideoWidget::setPosition( long i ) {
127 updateSlider( i, mediaPlayerState->length() ); 138 updateSlider( i, mediaPlayerState->length() );
128} 139}
129 140
130 141
131void VideoWidget::setLength( long max ) { 142void VideoWidget::setLength( long max ) {
132 updateSlider( mediaPlayerState->position(), max ); 143 updateSlider( mediaPlayerState->position(), max );
133} 144}
134 145
135 146
136void VideoWidget::setView( char view ) { 147void VideoWidget::setView( char view ) {
137 if ( view == 'v' ) { 148 if ( view == 'v' ) {
138 makeVisible(); 149 makeVisible();
139 } else { 150 } else {
140 // Effectively blank the view next time we show it so it looks nicer 151 // Effectively blank the view next time we show it so it looks nicer
141 scaledWidth = 0; 152 scaledWidth = 0;
142 scaledHeight = 0; 153 scaledHeight = 0;
143 hide(); 154 hide();
144 } 155 }
145} 156}
146 157
147 158
148void VideoWidget::updateSlider( long i, long max ) { 159void VideoWidget::updateSlider( long i, long max ) {
149 // Will flicker too much if we don't do this 160 // Will flicker too much if we don't do this
150 if ( max == 0 ) 161 if ( max == 0 )
151 return; 162 return;
152 int width = slider->width(); 163 int width = slider->width();
153 int val = int((double)i * width / max); 164 int val = int((double)i * width / max);
154 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { 165 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) {
155 if ( slider->value() != val ) 166 if ( slider->value() != val )
156 slider->setValue( val ); 167 slider->setValue( val );
157 if ( slider->maxValue() != width ) 168 if ( slider->maxValue() != width )
158 slider->setMaxValue( width ); 169 slider->setMaxValue( width );
159 } 170 }
160} 171}
161 172
162 173
163void VideoWidget::setToggleButton( int i, bool down ) { 174void VideoWidget::setToggleButton( int i, bool down ) {
164 if ( down != videoButtons[i].isDown ) 175 if ( down != videoButtons[i].isDown )
165 toggleButton( i ); 176 toggleButton( i );
166} 177}
167 178
168 179
169void VideoWidget::toggleButton( int i ) { 180void VideoWidget::toggleButton( int i ) {
170 videoButtons[i].isDown = !videoButtons[i].isDown; 181 videoButtons[i].isDown = !videoButtons[i].isDown;
171 QPainter p(this); 182 QPainter p(this);
172 paintButton ( &p, i ); 183 paintButton ( &p, i );
173} 184}
174 185
175 186
176void VideoWidget::paintButton( QPainter *p, int i ) { 187void VideoWidget::paintButton( QPainter *p, int i ) {
177 int x = videoButtons[i].xPos; 188 int x = videoButtons[i].xPos;
178 int y = videoButtons[i].yPos; 189 int y = videoButtons[i].yPos;
179 int offset = 10 + videoButtons[i].isDown; 190 int offset = 10 + videoButtons[i].isDown;
180 p->drawPixmap( x, y, *pixmaps[videoButtons[i].isDown] ); 191 p->drawPixmap( x, y, *pixmaps[videoButtons[i].isDown] );
181 p->drawPixmap( x + 1 + offset, y + offset, *pixmaps[2], 9 * videoButtons[i].controlType, 0, 9, 9 ); 192 p->drawPixmap( x + 1 + offset, y + offset, *pixmaps[2], 9 * videoButtons[i].controlType, 0, 9, 9 );
182} 193}
183 194
184 195
185void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 196void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
186 for ( int i = 0; i < numButtons; i++ ) { 197 for ( int i = 0; i < numButtons; i++ ) {
187 int x = videoButtons[i].xPos; 198 int x = videoButtons[i].xPos;
188 int y = videoButtons[i].yPos; 199 int y = videoButtons[i].yPos;
189 if ( event->state() == QMouseEvent::LeftButton ) { 200 if ( event->state() == QMouseEvent::LeftButton ) {
190 // The test to see if the mouse click is inside the circular button or not 201 // The test to see if the mouse click is inside the circular button or not
191 // (compared with the radius squared to avoid a square-root of our distance) 202 // (compared with the radius squared to avoid a square-root of our distance)
192 int radius = 16; 203 int radius = 16;
193 QPoint center = QPoint( x + radius, y + radius ); 204 QPoint center = QPoint( x + radius, y + radius );
194 QPoint dXY = center - event->pos(); 205 QPoint dXY = center - event->pos();
195 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y(); 206 int dist = dXY.x() * dXY.x() + dXY.y() * dXY.y();
196 bool isOnButton = dist <= (radius * radius); 207 bool isOnButton = dist <= (radius * radius);
197 if ( isOnButton != videoButtons[i].isHeld ) { 208 if ( isOnButton != videoButtons[i].isHeld ) {
198 videoButtons[i].isHeld = isOnButton; 209 videoButtons[i].isHeld = isOnButton;
199 toggleButton(i); 210 toggleButton(i);
200 } 211 }
201 } else { 212 } else {
202 if ( videoButtons[i].isHeld ) { 213 if ( videoButtons[i].isHeld ) {
203 videoButtons[i].isHeld = FALSE; 214 videoButtons[i].isHeld = FALSE;
204 if ( !videoButtons[i].isToggle ) 215 if ( !videoButtons[i].isToggle )
205 setToggleButton( i, FALSE ); 216 setToggleButton( i, FALSE );
206 } 217 }
207 } 218 }
208 switch (i) { 219 switch (i) {
209 case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return; 220 case VideoPlay: mediaPlayerState->setPlaying(videoButtons[i].isDown); return;
210 case VideoStop: mediaPlayerState->setPlaying(FALSE); return; 221 case VideoStop: mediaPlayerState->setPlaying(FALSE); return;
211 case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return; 222 case VideoPause: mediaPlayerState->setPaused(videoButtons[i].isDown); return;
212 case VideoNext: mediaPlayerState->setNext(); return; 223 case VideoNext: mediaPlayerState->setNext(); return;
213 case VideoPrevious: mediaPlayerState->setPrev(); return; 224 case VideoPrevious: mediaPlayerState->setPrev(); return;
214 case VideoPlayList: mediaPlayerState->setList(); return; 225 case VideoPlayList: mediaPlayerState->setList(); return;
215 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; 226 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
216 } 227 }
217 228
218 } 229 }
219} 230}
220 231
221 232
222void VideoWidget::mousePressEvent( QMouseEvent *event ) { 233void VideoWidget::mousePressEvent( QMouseEvent *event ) {
223 mouseMoveEvent( event ); 234 mouseMoveEvent( event );
224} 235}
225 236
226 237
227void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 238void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
228 if ( mediaPlayerState->fullscreen() ) { 239 if ( mediaPlayerState->fullscreen() ) {
229 mediaPlayerState->setFullscreen( FALSE ); 240 mediaPlayerState->setFullscreen( FALSE );
230 makeVisible(); 241 makeVisible();
231 242
232 mouseMoveEvent( event ); 243 mouseMoveEvent( event );
233 } 244 }
234} 245}
235 246
236 247
237void VideoWidget::makeVisible() { 248void VideoWidget::makeVisible() {
238 if ( mediaPlayerState->fullscreen() ) { 249 if ( mediaPlayerState->fullscreen() ) {
239 setBackgroundMode( QWidget::NoBackground ); 250 setBackgroundMode( QWidget::NoBackground );
240 showFullScreen(); 251 showFullScreen();
241 resize( qApp->desktop()->size() ); 252 resize( qApp->desktop()->size() );
242 slider->hide(); 253 slider->hide();
243 } else { 254 } else {
244 setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) ); 255 setBackgroundPixmap( Resource::loadPixmap( "opieplayer/metalFinish" ) );
245 showNormal(); 256 showNormal();
246 showMaximized(); 257 showMaximized();
247 slider->show(); 258 slider->show();
248 } 259 }
249} 260}
250 261
251 262
252void VideoWidget::paintEvent( QPaintEvent * ) { 263void VideoWidget::paintEvent( QPaintEvent * ) {
253 QPainter p( this ); 264 QPainter p( this );
254 265
255 if ( mediaPlayerState->fullscreen() ) { 266 if ( mediaPlayerState->fullscreen() ) {
256 // Clear the background 267 // Clear the background
257 p.setBrush( QBrush( Qt::black ) ); 268 p.setBrush( QBrush( Qt::black ) );
258 p.drawRect( rect() ); 269 p.drawRect( rect() );
259 270
260 // Draw the current frame 271 // Draw the current frame
261 //p.drawImage( ); // If using directpainter we won't have a copy except whats on the screen 272 //p.drawImage( ); // If using directpainter we won't have a copy except whats on the screen
262 } else { 273 } else {
263 // draw border 274 // draw border
264 qDrawShadePanel( &p, 4, 15, 230, 170, colorGroup(), TRUE, 5, NULL ); 275 qDrawShadePanel( &p, 4, 15, 230, 170, colorGroup(), TRUE, 5, NULL );
265 276
266 // Clear the movie screen first 277 // Clear the movie screen first
267 p.setBrush( QBrush( Qt::black ) ); 278 p.setBrush( QBrush( Qt::black ) );
268 p.drawRect( 9, 20, 220, 160 ); 279 p.drawRect( 9, 20, 220, 160 );
269 280
270 // draw current frame (centrally positioned from scaling to maintain aspect ratio) 281 // draw current frame (centrally positioned from scaling to maintain aspect ratio)
271 p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); 282 p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight );
272 283
273 // draw the buttons 284 // draw the buttons
274 for ( int i = 0; i < numButtons; i++ ) 285 for ( int i = 0; i < numButtons; i++ )
275 paintButton( &p, i ); 286 paintButton( &p, i );
276 287
277 // draw the slider 288 // draw the slider
278 slider->repaint( TRUE ); 289 slider->repaint( TRUE );
279 } 290 }
280} 291}
281 292
282 293
283void VideoWidget::closeEvent( QCloseEvent* ) { 294void VideoWidget::closeEvent( QCloseEvent* ) {
284 mediaPlayerState->setList(); 295 mediaPlayerState->setList();
285} 296}
286 297
287 298
288bool VideoWidget::playVideo() { 299bool VideoWidget::playVideo() {
289 bool result = FALSE; 300 bool result = FALSE;
290 301
291 int stream = 0; 302 int stream = 0;
292 303
293 int sw = mediaPlayerState->curDecoder()->videoWidth( stream ); 304 int sw = mediaPlayerState->curDecoder()->videoWidth( stream );
294 int sh = mediaPlayerState->curDecoder()->videoHeight( stream ); 305 int sh = mediaPlayerState->curDecoder()->videoHeight( stream );
295 int dd = QPixmap::defaultDepth(); 306 int dd = QPixmap::defaultDepth();
296 int w = height(); 307 int w = height();
297 int h = width(); 308 int h = width();
298 309
299 ColorFormat format = (dd == 16) ? RGB565 : BGRA8888; 310 ColorFormat format = (dd == 16) ? RGB565 : BGRA8888;
300 311
301 if ( mediaPlayerState->fullscreen() ) { 312 if ( mediaPlayerState->fullscreen() ) {
302#ifdef USE_DIRECT_PAINTER 313#ifdef USE_DIRECT_PAINTER
303 QDirectPainter p(this); 314 QDirectPainter p(this);
304 315
305 if ( ( qt_screen->transformOrientation() == 3 ) && 316 if ( ( qt_screen->transformOrientation() == 3 ) &&
306 ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) ) { 317 ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) ) {
307 318
308 w = 320; 319 w = 320;
309 h = 240; 320 h = 240;
310 321
311 if ( mediaPlayerState->scaled() ) { 322 if ( mediaPlayerState->scaled() ) {
312 // maintain aspect ratio 323 // maintain aspect ratio
313 if ( w * sh > sw * h ) 324 if ( w * sh > sw * h )
314 w = sw * h / sh; 325 w = sw * h / sh;
315 else 326 else
316 h = sh * w / sw; 327 h = sh * w / sw;
317 } else { 328 } else {
318 w = sw; 329 w = sw;
319 h = sh; 330 h = sh;
320 } 331 }
321 332
322 w--; // we can't allow libmpeg to overwrite. 333 w--; // we can't allow libmpeg to overwrite.
323 QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) ); 334 QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) );
324 335
325 int ox = roff.x() - height() + 2 + (height() - w) / 2; 336 int ox = roff.x() - height() + 2 + (height() - w) / 2;
326 int oy = roff.y() + (width() - h) / 2; 337 int oy = roff.y() + (width() - h) / 2;
327 int sx = 0, sy = 0; 338 int sx = 0, sy = 0;
328 339
329 uchar* fp = p.frameBuffer() + p.lineStep() * oy; 340 uchar* fp = p.frameBuffer() + p.lineStep() * oy;
330 fp += dd * ox / 8; 341 fp += dd * ox / 8;
331 uchar **jt = new uchar*[h]; 342 uchar **jt = new uchar*[h];
332 for ( int i = h; i; i-- ) { 343 for ( int i = h; i; i-- ) {
333 jt[h - i] = fp; 344 jt[h - i] = fp;
334 fp += p.lineStep(); 345 fp += p.lineStep();
335 } 346 }
336 347
337 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0; 348 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0;
338 349
339 delete [] jt; 350 delete [] jt;
340 } else { 351 } else {
341#endif 352#endif
342 QPainter p(this); 353 QPainter p(this);
343 354
344 w = 320; 355 w = 320;
345 h = 240; 356 h = 240;
346 357
347 if ( mediaPlayerState->scaled() ) { 358 if ( mediaPlayerState->scaled() ) {
348 // maintain aspect ratio 359 // maintain aspect ratio
349 if ( w * sh > sw * h ) 360 if ( w * sh > sw * h )
350 w = sw * h / sh; 361 w = sw * h / sh;
351 else 362 else
352 h = sh * w / sw; 363 h = sh * w / sw;
353 } else { 364 } else {
354 w = sw; 365 w = sw;
355 h = sh; 366 h = sh;
356 } 367 }
357 368
358 int bytes = ( dd == 16 ) ? 2 : 4; 369 int bytes = ( dd == 16 ) ? 2 : 4;
359 QImage tempFrame( w, h, bytes << 3 ); 370 QImage tempFrame( w, h, bytes << 3 );
360 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(), 371 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(),
361 0, 0, sw, sh, w, h, format, 0) == 0; 372 0, 0, sw, sh, w, h, format, 0) == 0;
362 if ( result && mediaPlayerState->fullscreen() ) { 373 if ( result && mediaPlayerState->fullscreen() ) {
363 374
364 int rw = h, rh = w; 375 int rw = h, rh = w;
365 QImage rotatedFrame( rw, rh, bytes << 3 ); 376 QImage rotatedFrame( rw, rh, bytes << 3 );
366 377
367 ushort* in = (ushort*)tempFrame.bits(); 378 ushort* in = (ushort*)tempFrame.bits();
368 ushort* out = (ushort*)rotatedFrame.bits(); 379 ushort* out = (ushort*)rotatedFrame.bits();
369 int spl = rotatedFrame.bytesPerLine() / bytes; 380 int spl = rotatedFrame.bytesPerLine() / bytes;
370 for (int x=0; x<h; x++) { 381 for (int x=0; x<h; x++) {
371 if ( bytes == 2 ) { 382 if ( bytes == 2 ) {
372 ushort* lout = out++ + (w - 1)*spl; 383 ushort* lout = out++ + (w - 1)*spl;
373 for (int y=0; y<w; y++) { 384 for (int y=0; y<w; y++) {
374 *lout=*in++; 385 *lout=*in++;
375 lout-=spl; 386 lout-=spl;
376 } 387 }
377 } else { 388 } else {
378 ulong* lout = ((ulong *)out)++ + (w - 1)*spl; 389 ulong* lout = ((ulong *)out)++ + (w - 1)*spl;
379 for (int y=0; y<w; y++) { 390 for (int y=0; y<w; y++) {
380 *lout=*((ulong*)in)++; 391 *lout=*((ulong*)in)++;
381 lout-=spl; 392 lout-=spl;
382 } 393 }
383 } 394 }
384 } 395 }
385 396
386 p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh ); 397 p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh );
387 } 398 }
388#ifdef USE_DIRECT_PAINTER 399#ifdef USE_DIRECT_PAINTER
389 } 400 }
390#endif 401#endif
391 } else { 402 } else {
392 403
393 w = 220; 404 w = 220;
394 h = 160; 405 h = 160;
395 406
396 // maintain aspect ratio 407 // maintain aspect ratio
397 if ( w * sh > sw * h ) 408 if ( w * sh > sw * h )
398 w = sw * h / sh; 409 w = sw * h / sh;
399 else 410 else
400 h = sh * w / sw; 411 h = sh * w / sw;
401 412
402 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0; 413 result = mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0;
403 414
404 QPainter p( this ); 415 QPainter p( this );
405 416
406 // Image changed size, therefore need to blank the possibly unpainted regions first 417 // Image changed size, therefore need to blank the possibly unpainted regions first
407 if ( scaledWidth != w || scaledHeight != h ) { 418 if ( scaledWidth != w || scaledHeight != h ) {
408 p.setBrush( QBrush( Qt::black ) ); 419 p.setBrush( QBrush( Qt::black ) );
409 p.drawRect( 9, 20, 220, 160 ); 420 p.drawRect( 9, 20, 220, 160 );
410 } 421 }
411 422
412 scaledWidth = w; 423 scaledWidth = w;
413 scaledHeight = h; 424 scaledHeight = h;
414 425
415 if ( result ) { 426 if ( result ) {
416 p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); 427 p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight );
417 } 428 }
418 429
419 } 430 }
420 431
421 return result; 432 return result;
422} 433}
423 434
424 435
425 436
426void VideoWidget::keyReleaseEvent( QKeyEvent *e) 437void VideoWidget::keyReleaseEvent( QKeyEvent *e)
427{ 438{
428 switch ( e->key() ) { 439 switch ( e->key() ) {
429////////////////////////////// Zaurus keys 440////////////////////////////// Zaurus keys
430 case Key_Home: 441 case Key_Home:
431 break; 442 break;
432 case Key_F9: //activity 443 case Key_F9: //activity
433 break; 444 break;
434 case Key_F10: //contacts 445 case Key_F10: //contacts
435// hide(); 446// hide();
436 break; 447 break;
437 case Key_F11: //menu 448 case Key_F11: //menu
438 break; 449 break;
439 case Key_F12: //home 450 case Key_F12: //home
440 break; 451 break;
441 case Key_F13: //mail 452 case Key_F13: //mail
442 break; 453 break;
443 case Key_Space: { 454 case Key_Space: {
444 if(mediaPlayerState->playing()) { 455 if(mediaPlayerState->playing()) {
445 mediaPlayerState->setPlaying(FALSE); 456 mediaPlayerState->setPlaying(FALSE);
446 } else { 457 } else {
447 mediaPlayerState->setPlaying(TRUE); 458 mediaPlayerState->setPlaying(TRUE);
448 } 459 }
449 } 460 }
450 break; 461 break;
451 case Key_Down: 462 case Key_Down:
452// toggleButton(6); 463// toggleButton(6);
453// emit lessClicked(); 464// emit lessClicked();
454// emit lessReleased(); 465// emit lessReleased();
455// toggleButton(6); 466// toggleButton(6);
456 break; 467 break;
457 case Key_Up: 468 case Key_Up:
458// toggleButton(5); 469// toggleButton(5);
459// emit moreClicked(); 470// emit moreClicked();
460// emit moreReleased(); 471// emit moreReleased();
461// toggleButton(5); 472// toggleButton(5);
462 break; 473 break;
463 case Key_Right: 474 case Key_Right: