summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp3
-rw-r--r--noncore/multimedia/opieplayer2/main.cpp3
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.cpp5
-rw-r--r--noncore/multimedia/opieplayer2/playlistwidget.cpp6
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp3
5 files changed, 13 insertions, 7 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 604ed3a..6d867e5 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -1,322 +1,325 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include <qpe/qpeapplication.h> 34#include <qpe/qpeapplication.h>
35#include <qpe/resource.h> 35#include <qpe/resource.h>
36#include <qpe/config.h> 36#include <qpe/config.h>
37 37
38#include <qwidget.h> 38#include <qwidget.h>
39#include <qpixmap.h> 39#include <qpixmap.h>
40#include <qbutton.h> 40#include <qbutton.h>
41#include <qpainter.h> 41#include <qpainter.h>
42#include <qframe.h> 42#include <qframe.h>
43#include <qlayout.h> 43#include <qlayout.h>
44 44
45#include <stdlib.h> 45#include <stdlib.h>
46#include <stdio.h> 46#include <stdio.h>
47 47
48#include "audiowidget.h" 48#include "audiowidget.h"
49#include "mediaplayerstate.h" 49#include "mediaplayerstate.h"
50 50
51extern MediaPlayerState *mediaPlayerState; 51extern MediaPlayerState *mediaPlayerState;
52 52
53static const int xo = -2; // movable x offset 53static const int xo = -2; // movable x offset
54static const int yo = 22; // movable y offset 54static const int yo = 22; // movable y offset
55 55
56 56
57Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) { 57Ticker::Ticker( QWidget* parent=0 ) : QFrame( parent ) {
58 setFrameStyle( WinPanel | Sunken ); 58 setFrameStyle( WinPanel | Sunken );
59 setText( "No Song" ); 59 setText( "No Song" );
60} 60}
61 61
62Ticker::~Ticker() { 62Ticker::~Ticker() {
63} 63}
64 64
65void Ticker::setText( const QString& text ) { 65void Ticker::setText( const QString& text ) {
66 pos = 0; // reset it everytime the text is changed 66 pos = 0; // reset it everytime the text is changed
67 scrollText = text; 67 scrollText = text;
68 pixelLen = fontMetrics().width( scrollText ); 68 pixelLen = fontMetrics().width( scrollText );
69 killTimers(); 69 killTimers();
70 if ( pixelLen > width() ) { 70 if ( pixelLen > width() ) {
71 startTimer( 50 ); 71 startTimer( 50 );
72 } 72 }
73 update(); 73 update();
74} 74}
75 75
76 76
77void Ticker::timerEvent( QTimerEvent * ) { 77void Ticker::timerEvent( QTimerEvent * ) {
78 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1; 78 pos = ( pos + 1 > pixelLen ) ? 0 : pos + 1;
79 scroll( -1, 0, contentsRect() ); 79 scroll( -1, 0, contentsRect() );
80 repaint( FALSE ); 80 repaint( FALSE );
81} 81}
82 82
83void Ticker::drawContents( QPainter *p ) { 83void Ticker::drawContents( QPainter *p ) {
84 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) 84 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen )
85 p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); 85 p->drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
86 QPixmap pm( width(), height() ); 86 QPixmap pm( width(), height() );
87 pm.fill( colorGroup().base() ); 87 pm.fill( colorGroup().base() );
88 QPainter pmp( &pm ); 88 QPainter pmp( &pm );
89 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) { 89 for ( int i = 0; i - pos < width() && (i < 1 || pixelLen > width()); i += pixelLen ) {
90 pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText ); 90 pmp.drawText( i - pos, 0, INT_MAX, height(), AlignVCenter, scrollText );
91 } 91 }
92 p->drawPixmap( 0, 0, pm ); 92 p->drawPixmap( 0, 0, pm );
93} 93}
94 94
95struct MediaButton { 95struct MediaButton {
96 bool isToggle, isHeld, isDown; 96 bool isToggle, isHeld, isDown;
97}; 97};
98 98
99//Layout information for the audioButtons (and if it is a toggle button or not) 99//Layout information for the audioButtons (and if it is a toggle button or not)
100MediaButton audioButtons[] = { 100MediaButton audioButtons[] = {
101 { TRUE, FALSE, FALSE }, // play 101 { TRUE, FALSE, FALSE }, // play
102 { FALSE, FALSE, FALSE }, // stop 102 { FALSE, FALSE, FALSE }, // stop
103 { FALSE, FALSE, FALSE }, // next 103 { FALSE, FALSE, FALSE }, // next
104 { FALSE, FALSE, FALSE }, // previous 104 { FALSE, FALSE, FALSE }, // previous
105 { FALSE, FALSE, FALSE }, // volume up 105 { FALSE, FALSE, FALSE }, // volume up
106 { FALSE, FALSE, FALSE }, // volume down 106 { FALSE, FALSE, FALSE }, // volume down
107 { TRUE, FALSE, FALSE }, // repeat/loop 107 { TRUE, FALSE, FALSE }, // repeat/loop
108 { FALSE, FALSE, FALSE }, // playlist 108 { FALSE, FALSE, FALSE }, // playlist
109 { FALSE, FALSE, FALSE }, // forward 109 { FALSE, FALSE, FALSE }, // forward
110 { FALSE, FALSE, FALSE } // back 110 { FALSE, FALSE, FALSE } // back
111}; 111};
112 112
113const char *skin_mask_file_names[10] = { 113const char *skin_mask_file_names[10] = {
114 "play", "stop", "next", "prev", "up", 114 "play", "stop", "next", "prev", "up",
115 "down", "loop", "playlist", "forward", "back" 115 "down", "loop", "playlist", "forward", "back"
116}; 116};
117 117
118 118
119static void changeTextColor( QWidget *w ) { 119static void changeTextColor( QWidget *w ) {
120 QPalette p = w->palette(); 120 QPalette p = w->palette();
121 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); 121 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) );
122 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); 122 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) );
123 w->setPalette( p ); 123 w->setPalette( p );
124} 124}
125 125
126static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); 126static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
127 127
128 128
129AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : 129AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
130 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { 130 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) {
131
132
133
131 setCaption( tr("OpiePlayer") ); 134 setCaption( tr("OpiePlayer") );
132 135
133 Config cfg("OpiePlayer"); 136 Config cfg("OpiePlayer");
134 cfg.setGroup("Options"); 137 cfg.setGroup("Options");
135 skin = cfg.readEntry("Skin","default"); 138 skin = cfg.readEntry("Skin","default");
136 //skin = "scaleTest"; 139 //skin = "scaleTest";
137// color of background, frame, degree of transparency 140// color of background, frame, degree of transparency
138 141
139 QString skinPath = "opieplayer2/skins/" + skin; 142 QString skinPath = "opieplayer2/skins/" + skin;
140 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 143 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
141 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); 144 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
142 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); 145 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
143 146
144 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); 147 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
145 imgButtonMask->fill( 0 ); 148 imgButtonMask->fill( 0 );
146 149
147 for ( int i = 0; i < 10; i++ ) { 150 for ( int i = 0; i < 10; i++ ) {
148 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; 151 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png";
149 masks[i] = new QBitmap( filename ); 152 masks[i] = new QBitmap( filename );
150 153
151 if ( !masks[i]->isNull() ) { 154 if ( !masks[i]->isNull() ) {
152 QImage imgMask = masks[i]->convertToImage(); 155 QImage imgMask = masks[i]->convertToImage();
153 uchar **dest = imgButtonMask->jumpTable(); 156 uchar **dest = imgButtonMask->jumpTable();
154 for ( int y = 0; y < imgUp->height(); y++ ) { 157 for ( int y = 0; y < imgUp->height(); y++ ) {
155 uchar *line = dest[y]; 158 uchar *line = dest[y];
156 for ( int x = 0; x < imgUp->width(); x++ ) 159 for ( int x = 0; x < imgUp->width(); x++ )
157 if ( !qRed( imgMask.pixel( x, y ) ) ) 160 if ( !qRed( imgMask.pixel( x, y ) ) )
158 line[x] = i + 1; 161 line[x] = i + 1;
159 } 162 }
160 } 163 }
161 164
162 } 165 }
163 166
164 for ( int i = 0; i < 10; i++ ) { 167 for ( int i = 0; i < 10; i++ ) {
165 buttonPixUp[i] = NULL; 168 buttonPixUp[i] = NULL;
166 buttonPixDown[i] = NULL; 169 buttonPixDown[i] = NULL;
167 } 170 }
168 171
169 setBackgroundPixmap( *pixBg ); 172 setBackgroundPixmap( *pixBg );
170 173
171 songInfo.setFocusPolicy( QWidget::NoFocus ); 174 songInfo.setFocusPolicy( QWidget::NoFocus );
172 changeTextColor( &songInfo ); 175 changeTextColor( &songInfo );
173 176
174 slider.setFixedHeight( 20 ); 177 slider.setFixedHeight( 20 );
175 slider.setMinValue( 0 ); 178 slider.setMinValue( 0 );
176 slider.setMaxValue( 1 ); 179 slider.setMaxValue( 1 );
177 slider.setFocusPolicy( QWidget::NoFocus ); 180 slider.setFocusPolicy( QWidget::NoFocus );
178 slider.setBackgroundPixmap( *pixBg ); 181 slider.setBackgroundPixmap( *pixBg );
179 182
180 time.setFocusPolicy( QWidget::NoFocus ); 183 time.setFocusPolicy( QWidget::NoFocus );
181 time.setAlignment( Qt::AlignCenter ); 184 time.setAlignment( Qt::AlignCenter );
182 time.setFrame(FALSE); 185 time.setFrame(FALSE);
183 changeTextColor( &time ); 186 changeTextColor( &time );
184 187
185 resizeEvent( NULL ); 188 resizeEvent( NULL );
186 189
187 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 190 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
188 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 191 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
189 192
190 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 193 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
191 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 194 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
192 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 195 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
193// connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 196// connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
194 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 197 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
195 198
196 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); 199 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) );
197 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); 200 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) );
198 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); 201 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) );
199 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); 202 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) );
200 203
201 204
202 205
203 // Intialise state 206 // Intialise state
204 setLength( mediaPlayerState->length() ); 207 setLength( mediaPlayerState->length() );
205 setPosition( mediaPlayerState->position() ); 208 setPosition( mediaPlayerState->position() );
206 setLooping( mediaPlayerState->fullscreen() ); 209 setLooping( mediaPlayerState->fullscreen() );
207// setPaused( mediaPlayerState->paused() ); 210// setPaused( mediaPlayerState->paused() );
208 setPlaying( mediaPlayerState->playing() ); 211 setPlaying( mediaPlayerState->playing() );
209 212
210} 213}
211 214
212AudioWidget::~AudioWidget() { 215AudioWidget::~AudioWidget() {
213 216
214 for ( int i = 0; i < 10; i++ ) { 217 for ( int i = 0; i < 10; i++ ) {
215 delete buttonPixUp[i]; 218 delete buttonPixUp[i];
216 delete buttonPixDown[i]; 219 delete buttonPixDown[i];
217 } 220 }
218 delete pixBg; 221 delete pixBg;
219 delete imgUp; 222 delete imgUp;
220 delete imgDn; 223 delete imgDn;
221 delete imgButtonMask; 224 delete imgButtonMask;
222 for ( int i = 0; i < 10; i++ ) { 225 for ( int i = 0; i < 10; i++ ) {
223 delete masks[i]; 226 delete masks[i];
224 } 227 }
225} 228}
226 229
227QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 230QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
228 QPixmap pix( img.width(), img.height() ); 231 QPixmap pix( img.width(), img.height() );
229 QPainter p( &pix ); 232 QPainter p( &pix );
230 p.drawTiledPixmap( pix.rect(), bg, offset ); 233 p.drawTiledPixmap( pix.rect(), bg, offset );
231 p.drawImage( 0, 0, img ); 234 p.drawImage( 0, 0, img );
232 return new QPixmap( pix ); 235 return new QPixmap( pix );
233} 236}
234 237
235 238
236QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) 239QPixmap *maskPixToMask( QPixmap pix, QBitmap mask )
237{ 240{
238 QPixmap *pixmap = new QPixmap( pix ); 241 QPixmap *pixmap = new QPixmap( pix );
239 pixmap->setMask( mask ); 242 pixmap->setMask( mask );
240 return pixmap; 243 return pixmap;
241} 244}
242 245
243 246
244 247
245void AudioWidget::resizeEvent( QResizeEvent * ) { 248void AudioWidget::resizeEvent( QResizeEvent * ) {
246 int h = height(); 249 int h = height();
247 int w = width(); 250 int w = width();
248 251
249 songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); 252 songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) );
250 slider.setFixedWidth( w - 110 ); 253 slider.setFixedWidth( w - 110 );
251 slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); 254 slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) );
252 slider.setBackgroundOrigin( QWidget::ParentOrigin ); 255 slider.setBackgroundOrigin( QWidget::ParentOrigin );
253 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); 256 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
254 257
255 xoff = ( w - imgUp->width() ) / 2; 258 xoff = ( w - imgUp->width() ) / 2;
256 yoff = (( h - imgUp->height() ) / 2) - 10; 259 yoff = (( h - imgUp->height() ) / 2) - 10;
257 QPoint p( xoff, yoff ); 260 QPoint p( xoff, yoff );
258 261
259 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); 262 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p );
260 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); 263 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p );
261 264
262 for ( int i = 0; i < 10; i++ ) { 265 for ( int i = 0; i < 10; i++ ) {
263 if ( !masks[i]->isNull() ) { 266 if ( !masks[i]->isNull() ) {
264 delete buttonPixUp[i]; 267 delete buttonPixUp[i];
265 delete buttonPixDown[i]; 268 delete buttonPixDown[i];
266 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); 269 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] );
267 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); 270 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] );
268 } 271 }
269 } 272 }
270 273
271 delete pixUp; 274 delete pixUp;
272 delete pixDn; 275 delete pixDn;
273} 276}
274 277
275static bool audioSliderBeingMoved = FALSE; 278static bool audioSliderBeingMoved = FALSE;
276 279
277 280
278void AudioWidget::sliderPressed() { 281void AudioWidget::sliderPressed() {
279 audioSliderBeingMoved = TRUE; 282 audioSliderBeingMoved = TRUE;
280} 283}
281 284
282 285
283void AudioWidget::sliderReleased() { 286void AudioWidget::sliderReleased() {
284 audioSliderBeingMoved = FALSE; 287 audioSliderBeingMoved = FALSE;
285 if ( slider.width() == 0 ) 288 if ( slider.width() == 0 )
286 return; 289 return;
287 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); 290 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width());
288 mediaPlayerState->setPosition( val ); 291 mediaPlayerState->setPosition( val );
289} 292}
290 293
291void AudioWidget::setPosition( long i ) { 294void AudioWidget::setPosition( long i ) {
292// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); 295// qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i);
293 updateSlider( i, mediaPlayerState->length() ); 296 updateSlider( i, mediaPlayerState->length() );
294} 297}
295 298
296 299
297void AudioWidget::setLength( long max ) { 300void AudioWidget::setLength( long max ) {
298 updateSlider( mediaPlayerState->position(), max ); 301 updateSlider( mediaPlayerState->position(), max );
299} 302}
300 303
301 304
302void AudioWidget::setView( char view ) { 305void AudioWidget::setView( char view ) {
303 306
304// this isnt working for some reason 307// this isnt working for some reason
305 308
306 if ( mediaPlayerState->streaming() ) { 309 if ( mediaPlayerState->streaming() ) {
307 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); 310 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>");
308 if( !slider.isHidden()) { 311 if( !slider.isHidden()) {
309 slider.hide(); 312 slider.hide();
310 } 313 }
311 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 314 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
312 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 315 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
313 } else { 316 } else {
314 // this stops the slider from being moved, thus 317 // this stops the slider from being moved, thus
315 // does not stop stream when it reaches the end 318 // does not stop stream when it reaches the end
316 slider.show(); 319 slider.show();
317 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 320 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
318 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 321 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
319 } 322 }
320 323
321 if ( view == 'a' ) { 324 if ( view == 'a' ) {
322 // startTimer( 150 ); 325 // startTimer( 150 );
diff --git a/noncore/multimedia/opieplayer2/main.cpp b/noncore/multimedia/opieplayer2/main.cpp
index 827f773..e951554 100644
--- a/noncore/multimedia/opieplayer2/main.cpp
+++ b/noncore/multimedia/opieplayer2/main.cpp
@@ -1,33 +1,34 @@
1 1
2#include <qpe/qpeapplication.h> 2#include <qpe/qpeapplication.h>
3#include "mediaplayerstate.h" 3#include "mediaplayerstate.h"
4#include "playlistwidget.h" 4#include "playlistwidget.h"
5#include "audiowidget.h" 5#include "audiowidget.h"
6#include "videowidget.h" 6#include "videowidget.h"
7#include "mediaplayer.h" 7#include "mediaplayer.h"
8 8
9MediaPlayerState *mediaPlayerState; 9MediaPlayerState *mediaPlayerState;
10PlayListWidget *playList; 10PlayListWidget *playList;
11AudioWidget *audioUI; 11AudioWidget *audioUI;
12VideoWidget *videoUI; 12VideoWidget *videoUI;
13 13
14int main(int argc, char **argv) { 14int main(int argc, char **argv) {
15 QPEApplication a(argc,argv); 15 QPEApplication a(argc,argv);
16 16
17 MediaPlayerState st( 0, "mediaPlayerState" ); 17 MediaPlayerState st( 0, "mediaPlayerState" );
18 mediaPlayerState = &st; 18 mediaPlayerState = &st;
19 PlayListWidget pl( 0, "playList" ); 19 PlayListWidget pl( 0, "playList" );
20 playList = &pl; 20 playList = &pl;
21 pl.showMaximized();
21 AudioWidget aw( 0, "audioUI" ); 22 AudioWidget aw( 0, "audioUI" );
22 audioUI = &aw; 23 audioUI = &aw;
23 VideoWidget vw( 0, "videoUI" ); 24 VideoWidget vw( 0, "videoUI" );
24 videoUI = &vw; 25 videoUI = &vw;
25 26 a.processEvents();
26 MediaPlayer mp( 0, "mediaPlayer" ); 27 MediaPlayer mp( 0, "mediaPlayer" );
27 28
28 a.showMainDocumentWidget(&pl); 29 a.showMainDocumentWidget(&pl);
29 30
30 return a.exec(); 31 return a.exec();
31} 32}
32 33
33 34
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.cpp b/noncore/multimedia/opieplayer2/mediaplayer.cpp
index 87f4f0c..5531e81 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayer.cpp
@@ -1,231 +1,230 @@
1#include <qpe/qpeapplication.h> 1#include <qpe/qpeapplication.h>
2#include <qpe/qlibrary.h> 2#include <qpe/qlibrary.h>
3#include <qpe/resource.h> 3#include <qpe/resource.h>
4#include <qpe/config.h> 4#include <qpe/config.h>
5#include <qpe/qcopenvelope_qws.h> 5#include <qpe/qcopenvelope_qws.h>
6 6
7#include <qmainwindow.h> 7#include <qmainwindow.h>
8#include <qmessagebox.h> 8#include <qmessagebox.h>
9#include <qwidgetstack.h> 9#include <qwidgetstack.h>
10#include <qfile.h> 10#include <qfile.h>
11 11
12#include "mediaplayer.h" 12#include "mediaplayer.h"
13#include "playlistwidget.h" 13#include "playlistwidget.h"
14#include "audiowidget.h" 14#include "audiowidget.h"
15#include "videowidget.h" 15#include "videowidget.h"
16#include "volumecontrol.h" 16#include "volumecontrol.h"
17 17
18#include "mediaplayerstate.h" 18#include "mediaplayerstate.h"
19 19
20// for setBacklight() 20// for setBacklight()
21#include <linux/fb.h> 21#include <linux/fb.h>
22#include <sys/file.h> 22#include <sys/file.h>
23#include <sys/ioctl.h> 23#include <sys/ioctl.h>
24 24
25 25
26extern AudioWidget *audioUI; 26extern AudioWidget *audioUI;
27extern VideoWidget *videoUI; 27extern VideoWidget *videoUI;
28extern PlayListWidget *playList; 28extern PlayListWidget *playList;
29extern MediaPlayerState *mediaPlayerState; 29extern MediaPlayerState *mediaPlayerState;
30 30
31 31
32#define FBIOBLANK 0x4611 32#define FBIOBLANK 0x4611
33 33
34MediaPlayer::MediaPlayer( QObject *parent, const char *name ) 34MediaPlayer::MediaPlayer( QObject *parent, const char *name )
35 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) { 35 : QObject( parent, name ), volumeDirection( 0 ), currentFile( NULL ) {
36 36
37 37 qApp->processEvents();
38 // xineControl = new XineControl(); 38 // QPEApplication::grabKeyboard(); // EVIL
39// QPEApplication::grabKeyboard(); // EVIL
40 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 39 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
41 40
42 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) ); 41 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), this, SLOT( setPlaying( bool ) ) );
43 42
44 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) ); 43 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( pauseCheck( bool ) ) );
45 44
46 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) ); 45 connect( mediaPlayerState, SIGNAL( next() ), this, SLOT( next() ) );
47 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) ); 46 connect( mediaPlayerState, SIGNAL( prev() ), this, SLOT( prev() ) );
48 connect( mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) ); 47 connect( mediaPlayerState, SIGNAL( blankToggled( bool ) ), this, SLOT ( blank( bool ) ) );
49 48
50 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 49 connect( audioUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
51 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 50 connect( audioUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
52 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 51 connect( audioUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
53 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 52 connect( audioUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
54 53
55 connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) ); 54 connect( videoUI, SIGNAL( moreClicked() ), this, SLOT( startIncreasingVolume() ) );
56 connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) ); 55 connect( videoUI, SIGNAL( lessClicked() ), this, SLOT( startDecreasingVolume() ) );
57 connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) ); 56 connect( videoUI, SIGNAL( moreReleased() ), this, SLOT( stopChangingVolume() ) );
58 connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) ); 57 connect( videoUI, SIGNAL( lessReleased() ), this, SLOT( stopChangingVolume() ) );
59 58
60 volControl = new VolumeControl; 59 volControl = new VolumeControl;
61 xineControl = new XineControl(); 60 xineControl = new XineControl();
62} 61}
63 62
64MediaPlayer::~MediaPlayer() { 63MediaPlayer::~MediaPlayer() {
65 delete xineControl; 64 delete xineControl;
66 delete volControl; 65 delete volControl;
67} 66}
68 67
69void MediaPlayer::pauseCheck( bool b ) { 68void MediaPlayer::pauseCheck( bool b ) {
70 if ( b && !mediaPlayerState->playing() ) { 69 if ( b && !mediaPlayerState->playing() ) {
71 mediaPlayerState->setPaused( FALSE ); 70 mediaPlayerState->setPaused( FALSE );
72 } 71 }
73} 72}
74 73
75void MediaPlayer::play() { 74void MediaPlayer::play() {
76 mediaPlayerState->setPlaying( FALSE ); 75 mediaPlayerState->setPlaying( FALSE );
77 mediaPlayerState->setPlaying( TRUE ); 76 mediaPlayerState->setPlaying( TRUE );
78} 77}
79 78
80void MediaPlayer::setPlaying( bool play ) { 79void MediaPlayer::setPlaying( bool play ) {
81 if ( !play ) { 80 if ( !play ) {
82 return; 81 return;
83 } 82 }
84 83
85 if ( mediaPlayerState->paused() ) { 84 if ( mediaPlayerState->paused() ) {
86 mediaPlayerState->setPaused( FALSE ); 85 mediaPlayerState->setPaused( FALSE );
87 return; 86 return;
88 } 87 }
89 88
90 const DocLnk *playListCurrent = playList->current(); 89 const DocLnk *playListCurrent = playList->current();
91 if ( playListCurrent != NULL ) { 90 if ( playListCurrent != NULL ) {
92 currentFile = playListCurrent; 91 currentFile = playListCurrent;
93 } 92 }
94 93
95 xineControl->play( currentFile->file() ); 94 xineControl->play( currentFile->file() );
96 95
97 xineControl->length(); 96 xineControl->length();
98 long seconds = mediaPlayerState->length();// 97 long seconds = mediaPlayerState->length();//
99 QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 ); 98 QString time; time.sprintf("%li:%02i", seconds/60, (int)seconds%60 );
100 qDebug(time); 99 qDebug(time);
101 100
102 QString tickerText; 101 QString tickerText;
103 if( currentFile->file().left(4) == "http" ) 102 if( currentFile->file().left(4) == "http" )
104 tickerText= tr( " File: " ) + currentFile->name(); 103 tickerText= tr( " File: " ) + currentFile->name();
105 else 104 else
106 tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time; 105 tickerText = tr( " File: " ) + currentFile->name() + tr(", Length: ") + time;
107 106
108 audioUI->setTickerText( currentFile->file( ) ); 107 audioUI->setTickerText( currentFile->file( ) );
109 108
110} 109}
111 110
112 111
113void MediaPlayer::prev() { 112void MediaPlayer::prev() {
114 if ( playList->prev() ) { 113 if ( playList->prev() ) {
115 play(); 114 play();
116 } else if ( mediaPlayerState->looping() ) { 115 } else if ( mediaPlayerState->looping() ) {
117 if ( playList->last() ) { 116 if ( playList->last() ) {
118 play(); 117 play();
119 } 118 }
120 } else { 119 } else {
121 mediaPlayerState->setList(); 120 mediaPlayerState->setList();
122 } 121 }
123} 122}
124 123
125 124
126void MediaPlayer::next() { 125void MediaPlayer::next() {
127 if ( playList->next() ) { 126 if ( playList->next() ) {
128 play(); 127 play();
129 } else if ( mediaPlayerState->looping() ) { 128 } else if ( mediaPlayerState->looping() ) {
130 if ( playList->first() ) { 129 if ( playList->first() ) {
131 play(); 130 play();
132 } 131 }
133 } else { 132 } else {
134 mediaPlayerState->setList(); 133 mediaPlayerState->setList();
135 } 134 }
136} 135}
137 136
138 137
139void MediaPlayer::startDecreasingVolume() { 138void MediaPlayer::startDecreasingVolume() {
140 volumeDirection = -1; 139 volumeDirection = -1;
141 startTimer( 100 ); 140 startTimer( 100 );
142 volControl->decVol(2); 141 volControl->decVol(2);
143} 142}
144 143
145 144
146void MediaPlayer::startIncreasingVolume() { 145void MediaPlayer::startIncreasingVolume() {
147 volumeDirection = +1; 146 volumeDirection = +1;
148 startTimer( 100 ); 147 startTimer( 100 );
149 volControl->incVol(2); 148 volControl->incVol(2);
150} 149}
151 150
152 151
153bool drawnOnScreenDisplay = FALSE; 152bool drawnOnScreenDisplay = FALSE;
154unsigned int onScreenDisplayVolume = 0; 153unsigned int onScreenDisplayVolume = 0;
155const int yoff = 110; 154const int yoff = 110;
156 155
157void MediaPlayer::stopChangingVolume() { 156void MediaPlayer::stopChangingVolume() {
158 killTimers(); 157 killTimers();
159 // Get rid of the on-screen display stuff 158 // Get rid of the on-screen display stuff
160 drawnOnScreenDisplay = FALSE; 159 drawnOnScreenDisplay = FALSE;
161 onScreenDisplayVolume = 0; 160 onScreenDisplayVolume = 0;
162 int w=0; 161 int w=0;
163 int h=0; 162 int h=0;
164 if( !xineControl->hasVideo()) { 163 if( !xineControl->hasVideo()) {
165 w = audioUI->width(); 164 w = audioUI->width();
166 h = audioUI->height(); 165 h = audioUI->height();
167 audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); 166 audioUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE );
168 } else { 167 } else {
169 w = videoUI->width(); 168 w = videoUI->width();
170 h = videoUI->height(); 169 h = videoUI->height();
171 videoUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE ); 170 videoUI->repaint( (w - 200) / 2, h - yoff, 200 + 9, 70, FALSE );
172 } 171 }
173} 172}
174 173
175 174
176void MediaPlayer::timerEvent( QTimerEvent * ) { 175void MediaPlayer::timerEvent( QTimerEvent * ) {
177 if ( volumeDirection == +1 ) { 176 if ( volumeDirection == +1 ) {
178 volControl->incVol(2); 177 volControl->incVol(2);
179 } else if ( volumeDirection == -1 ) { 178 } else if ( volumeDirection == -1 ) {
180 volControl->decVol(2); 179 volControl->decVol(2);
181 } 180 }
182 181
183 182
184 // TODO FIXME 183 // TODO FIXME
185 unsigned int v; 184 unsigned int v;
186 v = volControl->getVolume(); 185 v = volControl->getVolume();
187 v = v / 10; 186 v = v / 10;
188 187
189 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) { 188 if ( drawnOnScreenDisplay && onScreenDisplayVolume == v ) {
190 return; 189 return;
191 } 190 }
192 191
193 int w=0; int h=0; 192 int w=0; int h=0;
194 if( !xineControl->hasVideo()) { 193 if( !xineControl->hasVideo()) {
195 w = audioUI->width(); 194 w = audioUI->width();
196 h = audioUI->height(); 195 h = audioUI->height();
197 196
198 if ( drawnOnScreenDisplay ) { 197 if ( drawnOnScreenDisplay ) {
199 if ( onScreenDisplayVolume > v ) { 198 if ( onScreenDisplayVolume > v ) {
200 audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); 199 audioUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE );
201 } 200 }
202 } 201 }
203 drawnOnScreenDisplay = TRUE; 202 drawnOnScreenDisplay = TRUE;
204 onScreenDisplayVolume = v; 203 onScreenDisplayVolume = v;
205 QPainter p( audioUI ); 204 QPainter p( audioUI );
206 p.setPen( QColor( 0x10, 0xD0, 0x10 ) ); 205 p.setPen( QColor( 0x10, 0xD0, 0x10 ) );
207 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) ); 206 p.setBrush( QColor( 0x10, 0xD0, 0x10 ) );
208 207
209 QFont f; 208 QFont f;
210 f.setPixelSize( 20 ); 209 f.setPixelSize( 20 );
211 f.setBold( TRUE ); 210 f.setBold( TRUE );
212 p.setFont( f ); 211 p.setFont( f );
213 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") ); 212 p.drawText( (w - 200) / 2, h - yoff + 20, tr("Volume") );
214 213
215 for ( unsigned int i = 0; i < 10; i++ ) { 214 for ( unsigned int i = 0; i < 10; i++ ) {
216 if ( v > i ) { 215 if ( v > i ) {
217 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 ); 216 p.drawRect( (w - 200) / 2 + i * 20 + 0, h - yoff + 40, 9, 30 );
218 } else { 217 } else {
219 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 ); 218 p.drawRect( (w - 200) / 2 + i * 20 + 3, h - yoff + 50, 3, 10 );
220 } 219 }
221 } 220 }
222 } else { 221 } else {
223 w = videoUI->width(); 222 w = videoUI->width();
224 h = videoUI->height(); 223 h = videoUI->height();
225 224
226 if ( drawnOnScreenDisplay ) { 225 if ( drawnOnScreenDisplay ) {
227 if ( onScreenDisplayVolume > v ) { 226 if ( onScreenDisplayVolume > v ) {
228 videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE ); 227 videoUI->repaint( (w - 200) / 2 + v * 20 + 0, h - yoff + 40, (onScreenDisplayVolume - v) * 20 + 9, 30, FALSE );
229 } 228 }
230 } 229 }
231 drawnOnScreenDisplay = TRUE; 230 drawnOnScreenDisplay = TRUE;
diff --git a/noncore/multimedia/opieplayer2/playlistwidget.cpp b/noncore/multimedia/opieplayer2/playlistwidget.cpp
index 874800a..39f5090 100644
--- a/noncore/multimedia/opieplayer2/playlistwidget.cpp
+++ b/noncore/multimedia/opieplayer2/playlistwidget.cpp
@@ -13,429 +13,429 @@
13#include <qpe/global.h> 13#include <qpe/global.h>
14#include <qpe/resource.h> 14#include <qpe/resource.h>
15#include <qaction.h> 15#include <qaction.h>
16#include <qcursor.h> 16#include <qcursor.h>
17#include <qimage.h> 17#include <qimage.h>
18#include <qfile.h> 18#include <qfile.h>
19#include <qdir.h> 19#include <qdir.h>
20#include <qlayout.h> 20#include <qlayout.h>
21#include <qlabel.h> 21#include <qlabel.h>
22#include <qlist.h> 22#include <qlist.h>
23#include <qlistbox.h> 23#include <qlistbox.h>
24#include <qmainwindow.h> 24#include <qmainwindow.h>
25#include <qmessagebox.h> 25#include <qmessagebox.h>
26#include <qtoolbutton.h> 26#include <qtoolbutton.h>
27#include <qtabwidget.h> 27#include <qtabwidget.h>
28#include <qlistview.h> 28#include <qlistview.h>
29#include <qpoint.h> 29#include <qpoint.h>
30#include <qlineedit.h> 30#include <qlineedit.h>
31#include <qpushbutton.h> 31#include <qpushbutton.h>
32#include <qregexp.h> 32#include <qregexp.h>
33#include <qtextstream.h> 33#include <qtextstream.h>
34 34
35 35
36#include "playlistselection.h" 36#include "playlistselection.h"
37#include "playlistwidget.h" 37#include "playlistwidget.h"
38#include "mediaplayerstate.h" 38#include "mediaplayerstate.h"
39 39
40#include "inputDialog.h" 40#include "inputDialog.h"
41 41
42#include <stdlib.h> 42#include <stdlib.h>
43#include "audiowidget.h" 43#include "audiowidget.h"
44#include "videowidget.h" 44#include "videowidget.h"
45 45
46#define BUTTONS_ON_TOOLBAR 46#define BUTTONS_ON_TOOLBAR
47#define SIDE_BUTTONS 47#define SIDE_BUTTONS
48#define CAN_SAVE_LOAD_PLAYLISTS 48#define CAN_SAVE_LOAD_PLAYLISTS
49 49
50extern MediaPlayerState *mediaPlayerState; 50extern MediaPlayerState *mediaPlayerState;
51 51
52 52
53class PlayListWidgetPrivate { 53class PlayListWidgetPrivate {
54public: 54public:
55 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove; 55 QToolButton *tbPlay, *tbFull, *tbLoop, *tbScale, *tbShuffle, *tbAddToList, *tbRemoveFromList, *tbMoveUp, *tbMoveDown, *tbRemove;
56 QFrame *playListFrame; 56 QFrame *playListFrame;
57 FileSelector *files; 57 FileSelector *files;
58 PlayListSelection *selectedFiles; 58 PlayListSelection *selectedFiles;
59 bool setDocumentUsed; 59 bool setDocumentUsed;
60 DocLnk *current; 60 DocLnk *current;
61}; 61};
62 62
63 63
64class ToolButton : public QToolButton { 64class ToolButton : public QToolButton {
65public: 65public:
66 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE ) 66 ToolButton( QWidget *parent, const char *name, const QString& icon, QObject *handler, const QString& slot, bool t = FALSE )
67 : QToolButton( parent, name ) { 67 : QToolButton( parent, name ) {
68 setTextLabel( name ); 68 setTextLabel( name );
69 setPixmap( Resource::loadPixmap( icon ) ); 69 setPixmap( Resource::loadPixmap( icon ) );
70 setAutoRaise( TRUE ); 70 setAutoRaise( TRUE );
71 setFocusPolicy( QWidget::NoFocus ); 71 setFocusPolicy( QWidget::NoFocus );
72 setToggleButton( t ); 72 setToggleButton( t );
73 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot ); 73 connect( this, t ? SIGNAL( toggled(bool) ) : SIGNAL( clicked() ), handler, slot );
74 QPEMenuToolFocusManager::manager()->addWidget( this ); 74 QPEMenuToolFocusManager::manager()->addWidget( this );
75 } 75 }
76}; 76};
77 77
78 78
79class MenuItem : public QAction { 79class MenuItem : public QAction {
80public: 80public:
81 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot ) 81 MenuItem( QWidget *parent, const QString& text, QObject *handler, const QString& slot )
82 : QAction( text, QString::null, 0, 0 ) { 82 : QAction( text, QString::null, 0, 0 ) {
83 connect( this, SIGNAL( activated() ), handler, slot ); 83 connect( this, SIGNAL( activated() ), handler, slot );
84 addTo( parent ); 84 addTo( parent );
85 } 85 }
86}; 86};
87 87
88 88
89PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl ) 89PlayListWidget::PlayListWidget( QWidget* parent, const char* name, WFlags fl )
90 : QMainWindow( parent, name, fl ) { 90 : QMainWindow( parent, name, fl ) {
91 91
92 d = new PlayListWidgetPrivate; 92 d = new PlayListWidgetPrivate;
93 d->setDocumentUsed = FALSE; 93 d->setDocumentUsed = FALSE;
94 d->current = NULL; 94 d->current = NULL;
95 fromSetDocument = FALSE; 95 fromSetDocument = FALSE;
96 insanityBool=FALSE; 96 insanityBool=FALSE;
97 audioScan = FALSE; 97 audioScan = FALSE;
98 videoScan = FALSE; 98 videoScan = FALSE;
99 99
100 setBackgroundMode( PaletteButton ); 100 setBackgroundMode( PaletteButton );
101 101
102 setCaption( tr("OpiePlayer") ); 102 setCaption( tr("OpiePlayer") );
103 setIcon( Resource::loadPixmap( "opieplayer2/MPEGPlayer" ) ); 103 setIcon( Resource::loadPixmap( "opieplayer2/MPEGPlayer" ) );
104 104
105 setToolBarsMovable( FALSE ); 105 setToolBarsMovable( FALSE );
106 106
107 // Create Toolbar 107 // Create Toolbar
108 QPEToolBar *toolbar = new QPEToolBar( this ); 108 QPEToolBar *toolbar = new QPEToolBar( this );
109 toolbar->setHorizontalStretchable( TRUE ); 109 toolbar->setHorizontalStretchable( TRUE );
110 110
111 // Create Menubar 111 // Create Menubar
112 QPEMenuBar *menu = new QPEMenuBar( toolbar ); 112 QPEMenuBar *menu = new QPEMenuBar( toolbar );
113 menu->setMargin( 0 ); 113 menu->setMargin( 0 );
114 114
115 QPEToolBar *bar = new QPEToolBar( this ); 115 QPEToolBar *bar = new QPEToolBar( this );
116 bar->setLabel( tr( "Play Operations" ) ); 116 bar->setLabel( tr( "Play Operations" ) );
117 117
118 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close"); 118 tbDeletePlaylist = new QPushButton( Resource::loadIconSet("trash"),"",bar,"close");
119 tbDeletePlaylist->setFlat(TRUE); 119 tbDeletePlaylist->setFlat(TRUE);
120 tbDeletePlaylist->setFixedSize(20,20); 120 tbDeletePlaylist->setFixedSize(20,20);
121 121
122 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer2/add_to_playlist", 122 d->tbAddToList = new ToolButton( bar, tr( "Add to Playlist" ), "opieplayer2/add_to_playlist",
123 this , SLOT(addSelected()) ); 123 this , SLOT(addSelected()) );
124 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer2/remove_from_playlist", 124 d->tbRemoveFromList = new ToolButton( bar, tr( "Remove from Playlist" ), "opieplayer2/remove_from_playlist",
125 this , SLOT(removeSelected()) ); 125 this , SLOT(removeSelected()) );
126 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play", 126 d->tbPlay = new ToolButton( bar, tr( "Play" ), "opieplayer2/play",
127 this , SLOT( btnPlay(bool) ), TRUE ); 127 this , SLOT( btnPlay(bool) ), TRUE );
128 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle", 128 d->tbShuffle = new ToolButton( bar, tr( "Randomize" ),"opieplayer2/shuffle",
129 mediaPlayerState, SLOT(setShuffled(bool)), TRUE ); 129 mediaPlayerState, SLOT(setShuffled(bool)), TRUE );
130 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer2/loop", 130 d->tbLoop = new ToolButton( bar, tr( "Loop" ),"opieplayer2/loop",
131 mediaPlayerState, SLOT(setLooping(bool)), TRUE ); 131 mediaPlayerState, SLOT(setLooping(bool)), TRUE );
132 tbDeletePlaylist->hide(); 132 tbDeletePlaylist->hide();
133 133
134 QPopupMenu *pmPlayList = new QPopupMenu( this ); 134 QPopupMenu *pmPlayList = new QPopupMenu( this );
135 menu->insertItem( tr( "File" ), pmPlayList ); 135 menu->insertItem( tr( "File" ), pmPlayList );
136 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) ); 136 new MenuItem( pmPlayList, tr( "Clear List" ), this, SLOT( clearList() ) );
137 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) ); 137 new MenuItem( pmPlayList, tr( "Add all audio files" ), this, SLOT( addAllMusicToList() ) );
138 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) ); 138 new MenuItem( pmPlayList, tr( "Add all video files" ), this, SLOT( addAllVideoToList() ) );
139 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) ); 139 new MenuItem( pmPlayList, tr( "Add all files" ), this, SLOT( addAllToList() ) );
140 pmPlayList->insertSeparator(-1); 140 pmPlayList->insertSeparator(-1);
141 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) ); 141 new MenuItem( pmPlayList, tr( "Save PlayList" ), this, SLOT( saveList() ) );
142 new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) ); 142 new MenuItem( pmPlayList, tr( "Export playlist to m3u" ), this, SLOT(writem3u() ) );
143 pmPlayList->insertSeparator(-1); 143 pmPlayList->insertSeparator(-1);
144 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) ); 144 new MenuItem( pmPlayList, tr( "Open File or URL" ), this,SLOT( openFile() ) );
145 pmPlayList->insertSeparator(-1); 145 pmPlayList->insertSeparator(-1);
146 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) ); 146 new MenuItem( pmPlayList, tr( "Rescan for Audio Files" ), this,SLOT( scanForAudio() ) );
147 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) ); 147 new MenuItem( pmPlayList, tr( "Rescan for Video Files" ), this,SLOT( scanForVideo() ) );
148 148
149 149
150 pmView = new QPopupMenu( this ); 150 pmView = new QPopupMenu( this );
151 menu->insertItem( tr( "View" ), pmView ); 151 menu->insertItem( tr( "View" ), pmView );
152 pmView->isCheckable(); 152 pmView->isCheckable();
153 153
154 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), mediaPlayerState, SLOT( toggleFullscreen() ) ); 154 pmView->insertItem( Resource::loadPixmap("fullscreen") , tr( "Full Screen"), mediaPlayerState, SLOT( toggleFullscreen() ) );
155 155
156 Config cfg( "OpiePlayer" ); 156 Config cfg( "OpiePlayer" );
157 bool b= cfg.readBoolEntry("FullScreen", 0); 157 bool b= cfg.readBoolEntry("FullScreen", 0);
158 mediaPlayerState->setFullscreen( b ); 158 mediaPlayerState->setFullscreen( b );
159 pmView->setItemChecked( -16, b ); 159 pmView->setItemChecked( -16, b );
160 160
161 // pmView->insertItem( Resource::loadPixmap("opieplayer/scale") , tr( "Scale"), mediaPlayerState, SLOT(toggleScaled() ) ); 161 // pmView->insertItem( Resource::loadPixmap("opieplayer/scale") , tr( "Scale"), mediaPlayerState, SLOT(toggleScaled() ) );
162 162
163 pmView->insertSeparator(-1); 163 pmView->insertSeparator(-1);
164 164
165 skinsMenu = new QPopupMenu( this ); 165 skinsMenu = new QPopupMenu( this );
166 pmView->insertItem( tr( "Skins" ), skinsMenu ); 166 pmView->insertItem( tr( "Skins" ), skinsMenu );
167 skinsMenu->isCheckable(); 167 skinsMenu->isCheckable();
168 populateSkinsMenu(); 168 populateSkinsMenu();
169 169
170 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton ); 170 QVBox *vbox5 = new QVBox( this ); vbox5->setBackgroundMode( PaletteButton );
171 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton ); 171 QVBox *vbox4 = new QVBox( vbox5 ); vbox4->setBackgroundMode( PaletteButton );
172 172
173 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton ); 173 QHBox *hbox6 = new QHBox( vbox4 ); hbox6->setBackgroundMode( PaletteButton );
174 174
175 tabWidget = new QTabWidget( hbox6, "tabWidget" ); 175 tabWidget = new QTabWidget( hbox6, "tabWidget" );
176 // tabWidget->setTabShape(QTabWidget::Triangular); 176 // tabWidget->setTabShape(QTabWidget::Triangular);
177 177
178 QWidget *pTab; 178 QWidget *pTab;
179 pTab = new QWidget( tabWidget, "pTab" ); 179 pTab = new QWidget( tabWidget, "pTab" );
180 tabWidget->insertTab( pTab,"Playlist"); 180 tabWidget->insertTab( pTab,"Playlist");
181 181
182 182
183 QGridLayout *Playout = new QGridLayout( pTab ); 183 QGridLayout *Playout = new QGridLayout( pTab );
184 Playout->setSpacing( 2); 184 Playout->setSpacing( 2);
185 Playout->setMargin( 2); 185 Playout->setMargin( 2);
186 186
187 // Add the playlist area 187 // Add the playlist area
188 188
189 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton ); 189 QVBox *vbox3 = new QVBox( pTab ); vbox3->setBackgroundMode( PaletteButton );
190 d->playListFrame = vbox3; 190 d->playListFrame = vbox3;
191 191
192 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton ); 192 QHBox *hbox2 = new QHBox( vbox3 ); hbox2->setBackgroundMode( PaletteButton );
193 193
194 d->selectedFiles = new PlayListSelection( hbox2); 194 d->selectedFiles = new PlayListSelection( hbox2);
195 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton ); 195 QVBox *vbox1 = new QVBox( hbox2 ); vbox1->setBackgroundMode( PaletteButton );
196 196
197 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold); 197 QPEApplication::setStylusOperation( d->selectedFiles->viewport(),QPEApplication::RightOnHold);
198 198
199 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch 199 QVBox *stretch1 = new QVBox( vbox1 ); stretch1->setBackgroundMode( PaletteButton ); // add stretch
200 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", d->selectedFiles, SLOT(moveSelectedUp()) ); 200 new ToolButton( vbox1, tr( "Move Up" ), "opieplayer2/up", d->selectedFiles, SLOT(moveSelectedUp()) );
201 new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", d->selectedFiles, SLOT(removeSelected()) ); 201 new ToolButton( vbox1, tr( "Remove" ), "opieplayer2/cut", d->selectedFiles, SLOT(removeSelected()) );
202 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", d->selectedFiles, SLOT(moveSelectedDown()) ); 202 new ToolButton( vbox1, tr( "Move Down" ), "opieplayer2/down", d->selectedFiles, SLOT(moveSelectedDown()) );
203 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch 203 QVBox *stretch2 = new QVBox( vbox1 ); stretch2->setBackgroundMode( PaletteButton ); // add stretch
204 204
205 205
206 Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 ); 206 Playout->addMultiCellWidget( vbox3, 0, 0, 0, 1 );
207 207
208 QWidget *aTab; 208 QWidget *aTab;
209 aTab = new QWidget( tabWidget, "aTab" ); 209 aTab = new QWidget( tabWidget, "aTab" );
210 210
211 QGridLayout *Alayout = new QGridLayout( aTab ); 211 QGridLayout *Alayout = new QGridLayout( aTab );
212 Alayout->setSpacing( 2); 212 Alayout->setSpacing( 2);
213 Alayout->setMargin( 2); 213 Alayout->setMargin( 2);
214 214
215 audioView = new QListView( aTab, "Audioview" ); 215 audioView = new QListView( aTab, "Audioview" );
216 audioView->addColumn( tr("Title"),140); 216 audioView->addColumn( tr("Title"),140);
217 audioView->addColumn(tr("Size"), -1); 217 audioView->addColumn(tr("Size"), -1);
218 audioView->addColumn(tr("Media"),-1); 218 audioView->addColumn(tr("Media"),-1);
219 audioView->setColumnAlignment(1, Qt::AlignRight); 219 audioView->setColumnAlignment(1, Qt::AlignRight);
220 audioView->setColumnAlignment(2, Qt::AlignRight); 220 audioView->setColumnAlignment(2, Qt::AlignRight);
221 audioView->setAllColumnsShowFocus(TRUE); 221 audioView->setAllColumnsShowFocus(TRUE);
222 audioView->setSorting(0,TRUE); 222 audioView->setSorting(0,TRUE);
223 223
224 audioView->setMultiSelection( TRUE ); 224 audioView->setMultiSelection( TRUE );
225 audioView->setSelectionMode( QListView::Extended); 225 audioView->setSelectionMode( QListView::Extended);
226 226
227 Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 ); 227 Alayout->addMultiCellWidget( audioView, 0, 0, 0, 1 );
228 228
229 tabWidget->insertTab(aTab,tr("Audio")); 229 tabWidget->insertTab(aTab,tr("Audio"));
230 230
231 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold); 231 QPEApplication::setStylusOperation( audioView->viewport(),QPEApplication::RightOnHold);
232 232
233 QWidget *vTab; 233 QWidget *vTab;
234 vTab = new QWidget( tabWidget, "vTab" ); 234 vTab = new QWidget( tabWidget, "vTab" );
235 235
236 QGridLayout *Vlayout = new QGridLayout( vTab ); 236 QGridLayout *Vlayout = new QGridLayout( vTab );
237 Vlayout->setSpacing( 2); 237 Vlayout->setSpacing( 2);
238 Vlayout->setMargin( 2); 238 Vlayout->setMargin( 2);
239 239
240 videoView = new QListView( vTab, "Videoview" ); 240 videoView = new QListView( vTab, "Videoview" );
241 241
242 videoView->addColumn(tr("Title"),140); 242 videoView->addColumn(tr("Title"),140);
243 videoView->addColumn(tr("Size"),-1); 243 videoView->addColumn(tr("Size"),-1);
244 videoView->addColumn(tr("Media"),-1); 244 videoView->addColumn(tr("Media"),-1);
245 videoView->setColumnAlignment(1, Qt::AlignRight); 245 videoView->setColumnAlignment(1, Qt::AlignRight);
246 videoView->setColumnAlignment(2, Qt::AlignRight); 246 videoView->setColumnAlignment(2, Qt::AlignRight);
247 videoView->setAllColumnsShowFocus(TRUE); 247 videoView->setAllColumnsShowFocus(TRUE);
248 videoView->setSorting(0,TRUE); 248 videoView->setSorting(0,TRUE);
249 249
250 videoView->setMultiSelection( TRUE ); 250 videoView->setMultiSelection( TRUE );
251 videoView->setSelectionMode( QListView::Extended); 251 videoView->setSelectionMode( QListView::Extended);
252 252
253 Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 ); 253 Vlayout->addMultiCellWidget( videoView, 0, 0, 0, 1 );
254 254
255 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold); 255 QPEApplication::setStylusOperation( videoView->viewport(),QPEApplication::RightOnHold);
256 256
257 tabWidget->insertTab( vTab,tr("Video")); 257 tabWidget->insertTab( vTab,tr("Video"));
258 258
259 //playlists list 259 //playlists list
260 QWidget *LTab; 260 QWidget *LTab;
261 LTab = new QWidget( tabWidget, "LTab" ); 261 LTab = new QWidget( tabWidget, "LTab" );
262 QGridLayout *Llayout = new QGridLayout( LTab ); 262 QGridLayout *Llayout = new QGridLayout( LTab );
263 Llayout->setSpacing( 2); 263 Llayout->setSpacing( 2);
264 Llayout->setMargin( 2); 264 Llayout->setMargin( 2);
265 265
266 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy 266 playLists = new FileSelector( "playlist/plain", LTab, "fileselector" , FALSE, FALSE); //buggy
267 Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 ); 267 Llayout->addMultiCellWidget( playLists, 0, 0, 0, 1 );
268 268
269 tabWidget->insertTab(LTab,tr("Lists")); 269 tabWidget->insertTab(LTab,tr("Lists"));
270 270
271 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist())); 271 connect(tbDeletePlaylist,(SIGNAL(released())),SLOT( deletePlaylist()));
272 272
273 connect( pmView, SIGNAL( activated(int)), this, SLOT( pmViewActivated(int) ) ); 273 connect( pmView, SIGNAL( activated(int)), this, SLOT( pmViewActivated(int) ) );
274 274
275 connect( skinsMenu, SIGNAL( activated(int)), this, SLOT(skinsMenuActivated(int) ) ); 275 connect( skinsMenu, SIGNAL( activated(int)), this, SLOT(skinsMenuActivated(int) ) );
276 276
277 // connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled() ) ); 277 // connect( scaleButton, SIGNAL(activated()), mediaPlayerState, SLOT(toggleScaled() ) );
278 278
279 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 279 connect( d->selectedFiles, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
280 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) ); 280 this,SLOT( playlistViewPressed(int, QListViewItem *, const QPoint&, int)) );
281 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 281 connect( audioView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
282 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 282 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
283 connect( audioView, SIGNAL( returnPressed( QListViewItem *)), 283 connect( audioView, SIGNAL( returnPressed( QListViewItem *)),
284 this,SLOT( playIt( QListViewItem *)) ); 284 this,SLOT( playIt( QListViewItem *)) );
285 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 285 connect( audioView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
286 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 286 connect( videoView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
287 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) ); 287 this,SLOT( viewPressed(int, QListViewItem *, const QPoint&, int)) );
288 connect( videoView, SIGNAL( returnPressed( QListViewItem *)), 288 connect( videoView, SIGNAL( returnPressed( QListViewItem *)),
289 this,SLOT( playIt( QListViewItem *)) ); 289 this,SLOT( playIt( QListViewItem *)) );
290 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) ); 290 connect( videoView, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( addToSelection( QListViewItem *) ) );
291 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) ); 291 connect( playLists, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( loadList( const DocLnk & ) ) );
292 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*))); 292 connect( tabWidget, SIGNAL (currentChanged(QWidget*)),this,SLOT(tabChanged(QWidget*)));
293 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) ); 293 connect( mediaPlayerState, SIGNAL( playingToggled( bool ) ), d->tbPlay, SLOT( setOn( bool ) ) );
294 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) ); 294 connect( mediaPlayerState, SIGNAL( loopingToggled( bool ) ), d->tbLoop, SLOT( setOn( bool ) ) );
295 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) ); 295 connect( mediaPlayerState, SIGNAL( shuffledToggled( bool ) ), d->tbShuffle, SLOT( setOn( bool ) ) );
296 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) ); 296 connect( mediaPlayerState, SIGNAL( playlistToggled( bool ) ), this, SLOT( setPlaylist( bool ) ) );
297 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) ); 297 connect( d->selectedFiles, SIGNAL( doubleClicked( QListViewItem *) ), this, SLOT( playIt( QListViewItem *) ) );
298 298
299 setCentralWidget( vbox5 ); 299 setCentralWidget( vbox5 );
300 300
301 readConfig( cfg ); 301 readConfig( cfg );
302 QString currentPlaylist = cfg.readEntry("CurrentPlaylist",""); 302 QString currentPlaylist = cfg.readEntry("CurrentPlaylist","");
303 loadList(DocLnk( currentPlaylist)); 303 loadList(DocLnk( currentPlaylist));
304 setCaption(tr("OpiePlayer: ")+ currentPlaylist ); 304 setCaption(tr("OpiePlayer: ")+ currentPlaylist );
305 305
306 initializeStates(); 306 initializeStates();
307} 307}
308 308
309 309
310PlayListWidget::~PlayListWidget() { 310PlayListWidget::~PlayListWidget() {
311 Config cfg( "OpiePlayer" ); 311 Config cfg( "OpiePlayer" );
312 writeConfig( cfg ); 312 writeConfig( cfg );
313 313
314 if ( d->current ) { 314 if ( d->current ) {
315 delete d->current; 315 delete d->current;
316 } 316 }
317 delete d; 317 delete d;
318} 318}
319 319
320 320
321void PlayListWidget::initializeStates() { 321void PlayListWidget::initializeStates() {
322 322
323 d->tbPlay->setOn( mediaPlayerState->playing() ); 323 d->tbPlay->setOn( mediaPlayerState->playing() );
324 d->tbLoop->setOn( mediaPlayerState->looping() ); 324 d->tbLoop->setOn( mediaPlayerState->looping() );
325 d->tbShuffle->setOn( mediaPlayerState->shuffled() ); 325 d->tbShuffle->setOn( mediaPlayerState->shuffled() );
326 setPlaylist( true); 326 setPlaylist( true);
327} 327}
328 328
329 329
330void PlayListWidget::readConfig( Config& cfg ) { 330void PlayListWidget::readConfig( Config& cfg ) {
331 cfg.setGroup("PlayList"); 331 cfg.setGroup("PlayList");
332 QString currentString = cfg.readEntry("current", "" ); 332 QString currentString = cfg.readEntry("current", "" );
333 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 333 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
334 for ( int i = 0; i < noOfFiles; i++ ) { 334 for ( int i = 0; i < noOfFiles; i++ ) {
335 QString entryName; 335 QString entryName;
336 entryName.sprintf( "File%i", i + 1 ); 336 entryName.sprintf( "File%i", i + 1 );
337 QString linkFile = cfg.readEntry( entryName ); 337 QString linkFile = cfg.readEntry( entryName );
338 if(QFileInfo( linkFile).exists() ) { 338 if(QFileInfo( linkFile).exists() ) {
339 DocLnk lnk( linkFile ); 339 DocLnk lnk( linkFile );
340 if ( QFileInfo( lnk.file()).exists() || linkFile.find("http",0,TRUE) != -1) { 340 if ( QFileInfo( lnk.file()).exists() || linkFile.find("http",0,TRUE) != -1) {
341 d->selectedFiles->addToSelection( lnk ); 341 d->selectedFiles->addToSelection( lnk );
342 } 342 }
343 } 343 }
344 } 344 }
345 d->selectedFiles->setSelectedItem( currentString); 345 d->selectedFiles->setSelectedItem( currentString);
346} 346}
347 347
348 348
349void PlayListWidget::writeConfig( Config& cfg ) const { 349void PlayListWidget::writeConfig( Config& cfg ) const {
350 350
351 d->selectedFiles->writeCurrent( cfg); 351 d->selectedFiles->writeCurrent( cfg);
352 cfg.setGroup("PlayList"); 352 cfg.setGroup("PlayList");
353 int noOfFiles = 0; 353 int noOfFiles = 0;
354 d->selectedFiles->first(); 354 d->selectedFiles->first();
355 do { 355 do {
356 const DocLnk *lnk = d->selectedFiles->current(); 356 const DocLnk *lnk = d->selectedFiles->current();
357 if ( lnk ) { 357 if ( lnk ) {
358 QString entryName; 358 QString entryName;
359 entryName.sprintf( "File%i", noOfFiles + 1 ); 359 entryName.sprintf( "File%i", noOfFiles + 1 );
360 cfg.writeEntry( entryName, lnk->linkFile() ); 360 cfg.writeEntry( entryName, lnk->linkFile() );
361 // if this link does exist, add it so we have the file 361 // if this link does exist, add it so we have the file
362 // next time... 362 // next time...
363 if ( !QFile::exists( lnk->linkFile() ) ) { 363 if ( !QFile::exists( lnk->linkFile() ) ) {
364 // the way writing lnks doesn't really check for out 364 // the way writing lnks doesn't really check for out
365 // of disk space, but check it anyway. 365 // of disk space, but check it anyway.
366 if ( !lnk->writeLink() ) { 366 if ( !lnk->writeLink() ) {
367 QMessageBox::critical( 0, tr("Out of space"), 367 QMessageBox::critical( 0, tr("Out of space"),
368 tr( "There was a problem saving " 368 tr( "There was a problem saving "
369 "the playlist.\n" 369 "the playlist.\n"
370 "Your playlist " 370 "Your playlist "
371 "may be missing some entries\n" 371 "may be missing some entries\n"
372 "the next time you start it." ) 372 "the next time you start it." )
373 ); 373 );
374 } 374 }
375 } 375 }
376 noOfFiles++; 376 noOfFiles++;
377 } 377 }
378 } 378 }
379 while ( d->selectedFiles->next() ); 379 while ( d->selectedFiles->next() );
380 cfg.writeEntry("NumberOfFiles", noOfFiles ); 380 cfg.writeEntry("NumberOfFiles", noOfFiles );
381} 381}
382 382
383 383
384void PlayListWidget::addToSelection( const DocLnk& lnk ) { 384void PlayListWidget::addToSelection( const DocLnk& lnk ) {
385 d->setDocumentUsed = FALSE; 385 d->setDocumentUsed = FALSE;
386 if ( mediaPlayerState->playlist() ) { 386 if ( mediaPlayerState->playlist() ) {
387 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" ) 387 if(QFileInfo(lnk.file()).exists() || lnk.file().left(4) == "http" )
388 d->selectedFiles->addToSelection( lnk ); 388 d->selectedFiles->addToSelection( lnk );
389 } 389 }
390 else 390 else
391 mediaPlayerState->setPlaying( TRUE ); 391 mediaPlayerState->setPlaying( TRUE );
392} 392}
393 393
394 394
395void PlayListWidget::clearList() { 395void PlayListWidget::clearList() {
396 while ( first() ) { 396 while ( first() ) {
397 d->selectedFiles->removeSelected(); 397 d->selectedFiles->removeSelected();
398 } 398 }
399} 399}
400 400
401 401
402void PlayListWidget::addAllToList() { 402void PlayListWidget::addAllToList() {
403 DocLnkSet filesAll; 403 DocLnkSet filesAll;
404 Global::findDocuments(&filesAll, "video/*;audio/*"); 404 Global::findDocuments(&filesAll, "video/*;audio/*");
405 QListIterator<DocLnk> Adit( filesAll.children() ); 405 QListIterator<DocLnk> Adit( filesAll.children() );
406 for ( ; Adit.current(); ++Adit ) { 406 for ( ; Adit.current(); ++Adit ) {
407 if(QFileInfo(Adit.current()->file()).exists()) { 407 if(QFileInfo(Adit.current()->file()).exists()) {
408 d->selectedFiles->addToSelection( **Adit ); 408 d->selectedFiles->addToSelection( **Adit );
409 } 409 }
410 } 410 }
411} 411}
412 412
413 413
414void PlayListWidget::addAllMusicToList() { 414void PlayListWidget::addAllMusicToList() {
415 QListIterator<DocLnk> dit( files.children() ); 415 QListIterator<DocLnk> dit( files.children() );
416 for ( ; dit.current(); ++dit ) { 416 for ( ; dit.current(); ++dit ) {
417 if(QFileInfo(dit.current()->file()).exists()) { 417 if(QFileInfo(dit.current()->file()).exists()) {
418 d->selectedFiles->addToSelection( **dit ); 418 d->selectedFiles->addToSelection( **dit );
419 } 419 }
420 } 420 }
421} 421}
422 422
423 423
424void PlayListWidget::addAllVideoToList() { 424void PlayListWidget::addAllVideoToList() {
425 QListIterator<DocLnk> dit( vFiles.children() ); 425 QListIterator<DocLnk> dit( vFiles.children() );
426 for ( ; dit.current(); ++dit ) 426 for ( ; dit.current(); ++dit )
427 if(QFileInfo( dit.current()->file()).exists()) 427 if(QFileInfo( dit.current()->file()).exists())
428 d->selectedFiles->addToSelection( **dit ); 428 d->selectedFiles->addToSelection( **dit );
429} 429}
430 430
431 431
432void PlayListWidget::setDocument(const QString& fileref) { 432void PlayListWidget::setDocument(const QString& fileref) {
433 qDebug(fileref); 433 qDebug(fileref);
434 fromSetDocument = TRUE; 434 fromSetDocument = TRUE;
435 if ( fileref.isNull() ) { 435 if ( fileref.isNull() ) {
436 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) ); 436 QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) );
437 return; 437 return;
438 } 438 }
439 439
440 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u 440 if(fileref.find("m3u",0,TRUE) != -1) { //is m3u
441 readm3u( fileref); 441 readm3u( fileref);
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index ddb4d74..60a3563 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -1,275 +1,278 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 5 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.--   : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include <qpe/resource.h> 34#include <qpe/resource.h>
35#include <qpe/mediaplayerplugininterface.h> 35#include <qpe/mediaplayerplugininterface.h>
36#include <qpe/config.h> 36#include <qpe/config.h>
37 37
38
38#include <qwidget.h> 39#include <qwidget.h>
39#include <qpainter.h> 40#include <qpainter.h>
40#include <qpixmap.h> 41#include <qpixmap.h>
41#include <qslider.h> 42#include <qslider.h>
42#include <qdrawutil.h> 43#include <qdrawutil.h>
43#include "videowidget.h" 44#include "videowidget.h"
44#include "mediaplayerstate.h" 45#include "mediaplayerstate.h"
45 46
46 47
47#ifdef Q_WS_QWS 48#ifdef Q_WS_QWS
48# define USE_DIRECT_PAINTER 49# define USE_DIRECT_PAINTER
49# include <qdirectpainter_qws.h> 50# include <qdirectpainter_qws.h>
50# include <qgfxraster_qws.h> 51# include <qgfxraster_qws.h>
51#endif 52#endif
52 53
53 54
54extern MediaPlayerState *mediaPlayerState; 55extern MediaPlayerState *mediaPlayerState;
55 56
56 57
57static const int xo = 2; // movable x offset 58static const int xo = 2; // movable x offset
58static const int yo = 0; // movable y offset 59static const int yo = 0; // movable y offset
59 60
60 61
61struct MediaButton { 62struct MediaButton {
62 bool isToggle, isHeld, isDown; 63 bool isToggle, isHeld, isDown;
63}; 64};
64 65
65MediaButton videoButtons[] = { 66MediaButton videoButtons[] = {
66 { FALSE, FALSE, FALSE }, // stop 67 { FALSE, FALSE, FALSE }, // stop
67 { TRUE, FALSE, FALSE }, // play 68 { TRUE, FALSE, FALSE }, // play
68 { FALSE, FALSE, FALSE }, // previous 69 { FALSE, FALSE, FALSE }, // previous
69 { FALSE, FALSE, FALSE }, // next 70 { FALSE, FALSE, FALSE }, // next
70 { FALSE, FALSE, FALSE }, // volUp 71 { FALSE, FALSE, FALSE }, // volUp
71 { FALSE, FALSE, FALSE }, // volDown 72 { FALSE, FALSE, FALSE }, // volDown
72 { TRUE, FALSE, FALSE } // fullscreen 73 { TRUE, FALSE, FALSE } // fullscreen
73}; 74};
74 75
75const char *skinV_mask_file_names[7] = { 76const char *skinV_mask_file_names[7] = {
76"stop","play","back","fwd","up","down","full" 77"stop","play","back","fwd","up","down","full"
77}; 78};
78 79
79static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); 80static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton));
80 81
81 82
82VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : 83VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) :
83QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) { 84QWidget( parent, name, f ), scaledWidth( 0 ), scaledHeight( 0 ) {
85
86
84 setCaption( tr("OpiePlayer - Video") ); 87 setCaption( tr("OpiePlayer - Video") );
85 88
86 videoFrame = new XineVideoWidget ( this, "Video frame" ); 89 videoFrame = new XineVideoWidget ( this, "Video frame" );
87 90
88 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); 91 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & )));
89 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); 92 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) );
90 93
91 Config cfg("OpiePlayer"); 94 Config cfg("OpiePlayer");
92 cfg.setGroup("Options"); 95 cfg.setGroup("Options");
93 skin = cfg.readEntry("Skin","default"); 96 skin = cfg.readEntry("Skin","default");
94 97
95 QString skinPath = "opieplayer2/skins/" + skin; 98 QString skinPath = "opieplayer2/skins/" + skin;
96 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 99 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
97 imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); 100 imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) );
98 imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); 101 imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) );
99 102
100 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); 103 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
101 imgButtonMask->fill( 0 ); 104 imgButtonMask->fill( 0 );
102 105
103 for ( int i = 0; i < 7; i++ ) { 106 for ( int i = 0; i < 7; i++ ) {
104 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png"; 107 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png";
105 masks[i] = new QBitmap( filename ); 108 masks[i] = new QBitmap( filename );
106 109
107 if ( !masks[i]->isNull() ) { 110 if ( !masks[i]->isNull() ) {
108 QImage imgMask = masks[i]->convertToImage(); 111 QImage imgMask = masks[i]->convertToImage();
109 uchar **dest = imgButtonMask->jumpTable(); 112 uchar **dest = imgButtonMask->jumpTable();
110 for ( int y = 0; y < imgUp->height(); y++ ) { 113 for ( int y = 0; y < imgUp->height(); y++ ) {
111 uchar *line = dest[y]; 114 uchar *line = dest[y];
112 for ( int x = 0; x < imgUp->width(); x++ ) { 115 for ( int x = 0; x < imgUp->width(); x++ ) {
113 if ( !qRed( imgMask.pixel( x, y ) ) ) 116 if ( !qRed( imgMask.pixel( x, y ) ) )
114 line[x] = i + 1; 117 line[x] = i + 1;
115 } 118 }
116 } 119 }
117 } 120 }
118 } 121 }
119 122
120 for ( int i = 0; i < 7; i++ ) { 123 for ( int i = 0; i < 7; i++ ) {
121 buttonPixUp[i] = NULL; 124 buttonPixUp[i] = NULL;
122 buttonPixDown[i] = NULL; 125 buttonPixDown[i] = NULL;
123 } 126 }
124 127
125 setBackgroundPixmap( *pixBg ); 128 setBackgroundPixmap( *pixBg );
126 129
127 slider = new QSlider( Qt::Horizontal, this ); 130 slider = new QSlider( Qt::Horizontal, this );
128 slider->setMinValue( 0 ); 131 slider->setMinValue( 0 );
129 slider->setMaxValue( 1 ); 132 slider->setMaxValue( 1 );
130 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 133 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
131 slider->setFocusPolicy( QWidget::NoFocus ); 134 slider->setFocusPolicy( QWidget::NoFocus );
132 135
133 resizeEvent( NULL ); 136 resizeEvent( NULL );
134 137
135 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 138 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
136 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 139 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
137 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 140 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
138 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 141 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
139 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 142 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
140 143
141 setLength( mediaPlayerState->length() ); 144 setLength( mediaPlayerState->length() );
142 setPosition( mediaPlayerState->position() ); 145 setPosition( mediaPlayerState->position() );
143 setFullscreen( mediaPlayerState->fullscreen() ); 146 setFullscreen( mediaPlayerState->fullscreen() );
144 setPlaying( mediaPlayerState->playing() ); 147 setPlaying( mediaPlayerState->playing() );
145} 148}
146 149
147 150
148VideoWidget::~VideoWidget() { 151VideoWidget::~VideoWidget() {
149 152
150 for ( int i = 0; i < 7; i++ ) { 153 for ( int i = 0; i < 7; i++ ) {
151 delete buttonPixUp[i]; 154 delete buttonPixUp[i];
152 delete buttonPixDown[i]; 155 delete buttonPixDown[i];
153 } 156 }
154 157
155 delete pixBg; 158 delete pixBg;
156 delete imgUp; 159 delete imgUp;
157 delete imgDn; 160 delete imgDn;
158 delete imgButtonMask; 161 delete imgButtonMask;
159 for ( int i = 0; i < 7; i++ ) { 162 for ( int i = 0; i < 7; i++ ) {
160 delete masks[i]; 163 delete masks[i];
161 } 164 }
162 165
163} 166}
164 167
165QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 168QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
166 QPixmap pix( img.width(), img.height() ); 169 QPixmap pix( img.width(), img.height() );
167 QPainter p( &pix ); 170 QPainter p( &pix );
168 p.drawTiledPixmap( pix.rect(), bg, offset ); 171 p.drawTiledPixmap( pix.rect(), bg, offset );
169 p.drawImage( 0, 0, img ); 172 p.drawImage( 0, 0, img );
170 return new QPixmap( pix ); 173 return new QPixmap( pix );
171} 174}
172 175
173QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { 176QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) {
174 QPixmap *pixmap = new QPixmap( pix ); 177 QPixmap *pixmap = new QPixmap( pix );
175 pixmap->setMask( mask ); 178 pixmap->setMask( mask );
176 return pixmap; 179 return pixmap;
177} 180}
178 181
179void VideoWidget::resizeEvent( QResizeEvent * ) { 182void VideoWidget::resizeEvent( QResizeEvent * ) {
180 int h = height(); 183 int h = height();
181 int w = width(); 184 int w = width();
182 int Vh = 160; 185 int Vh = 160;
183 int Vw = 220; 186 int Vw = 220;
184 187
185 slider->setFixedWidth( w - 20 ); 188 slider->setFixedWidth( w - 20 );
186 slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); 189 slider->setGeometry( QRect( 15, h - 30, w - 90, 20 ) );
187 slider->setBackgroundOrigin( QWidget::ParentOrigin ); 190 slider->setBackgroundOrigin( QWidget::ParentOrigin );
188 slider->setFocusPolicy( QWidget::NoFocus ); 191 slider->setFocusPolicy( QWidget::NoFocus );
189 slider->setBackgroundPixmap( *pixBg ); 192 slider->setBackgroundPixmap( *pixBg );
190 193
191 xoff = 0;// ( imgUp->width() ) / 2; 194 xoff = 0;// ( imgUp->width() ) / 2;
192 yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; 195 yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10;
193 QPoint p( xoff, yoff ); 196 QPoint p( xoff, yoff );
194 197
195 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); 198 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p );
196 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); 199 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p );
197 200
198 for ( int i = 0; i < 7; i++ ) { 201 for ( int i = 0; i < 7; i++ ) {
199 if ( !masks[i]->isNull() ) { 202 if ( !masks[i]->isNull() ) {
200 delete buttonPixUp[i]; 203 delete buttonPixUp[i];
201 delete buttonPixDown[i]; 204 delete buttonPixDown[i];
202 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); 205 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] );
203 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); 206 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] );
204 } 207 }
205 } 208 }
206 209
207 delete pixUp; 210 delete pixUp;
208 delete pixDn; 211 delete pixDn;
209} 212}
210 213
211static bool videoSliderBeingMoved = FALSE; 214static bool videoSliderBeingMoved = FALSE;
212 215
213void VideoWidget::sliderPressed() { 216void VideoWidget::sliderPressed() {
214 videoSliderBeingMoved = TRUE; 217 videoSliderBeingMoved = TRUE;
215} 218}
216 219
217void VideoWidget::sliderReleased() { 220void VideoWidget::sliderReleased() {
218 videoSliderBeingMoved = FALSE; 221 videoSliderBeingMoved = FALSE;
219 if ( slider->width() == 0 ) { 222 if ( slider->width() == 0 ) {
220 return; 223 return;
221 } 224 }
222 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); 225 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width());
223 mediaPlayerState->setPosition( val ); 226 mediaPlayerState->setPosition( val );
224} 227}
225 228
226void VideoWidget::setPosition( long i ) { 229void VideoWidget::setPosition( long i ) {
227 updateSlider( i, mediaPlayerState->length() ); 230 updateSlider( i, mediaPlayerState->length() );
228} 231}
229 232
230 233
231void VideoWidget::setLength( long max ) { 234void VideoWidget::setLength( long max ) {
232 updateSlider( mediaPlayerState->position(), max ); 235 updateSlider( mediaPlayerState->position(), max );
233} 236}
234 237
235void VideoWidget::setView( char view ) { 238void VideoWidget::setView( char view ) {
236 239
237 if ( view == 'v' ) { 240 if ( view == 'v' ) {
238 makeVisible(); 241 makeVisible();
239 } else { 242 } else {
240 // Effectively blank the view next time we show it so it looks nicer 243 // Effectively blank the view next time we show it so it looks nicer
241 scaledWidth = 0; 244 scaledWidth = 0;
242 scaledHeight = 0; 245 scaledHeight = 0;
243 hide(); 246 hide();
244 } 247 }
245} 248}
246 249
247void VideoWidget::updateSlider( long i, long max ) { 250void VideoWidget::updateSlider( long i, long max ) {
248 // Will flicker too much if we don't do this 251 // Will flicker too much if we don't do this
249 if ( max == 0 ) { 252 if ( max == 0 ) {
250 return; 253 return;
251 } 254 }
252 int width = slider->width(); 255 int width = slider->width();
253 int val = int((double)i * width / max); 256 int val = int((double)i * width / max);
254 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) { 257 if ( !mediaPlayerState->fullscreen() && !videoSliderBeingMoved ) {
255 if ( slider->value() != val ) { 258 if ( slider->value() != val ) {
256 slider->setValue( val ); 259 slider->setValue( val );
257 } 260 }
258 if ( slider->maxValue() != width ) { 261 if ( slider->maxValue() != width ) {
259 slider->setMaxValue( width ); 262 slider->setMaxValue( width );
260 } 263 }
261 } 264 }
262} 265}
263 266
264void VideoWidget::setToggleButton( int i, bool down ) { 267void VideoWidget::setToggleButton( int i, bool down ) {
265 if ( down != videoButtons[i].isDown ) { 268 if ( down != videoButtons[i].isDown ) {
266 toggleButton( i ); 269 toggleButton( i );
267 } 270 }
268} 271}
269 272
270void VideoWidget::toggleButton( int i ) { 273void VideoWidget::toggleButton( int i ) {
271 videoButtons[i].isDown = !videoButtons[i].isDown; 274 videoButtons[i].isDown = !videoButtons[i].isDown;
272 QPainter p(this); 275 QPainter p(this);
273 paintButton ( &p, i ); 276 paintButton ( &p, i );
274} 277}
275 278