summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-02 20:01:57 (UTC)
committer simon <simon>2002-12-02 20:01:57 (UTC)
commitacfbc79f2acf59fa5e4494dde4ea1c4ea5e429b7 (patch) (unidiff)
tree0589832714da4838a678b2e40e431816087efc39
parent262f335a055e189130a3c0dd7028388ab103504e (diff)
downloadopie-acfbc79f2acf59fa5e4494dde4ea1c4ea5e429b7.zip
opie-acfbc79f2acf59fa5e4494dde4ea1c4ea5e429b7.tar.gz
opie-acfbc79f2acf59fa5e4494dde4ea1c4ea5e429b7.tar.bz2
- less header inclusions
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayer.h2
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp1
2 files changed, 0 insertions, 3 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayer.h b/noncore/multimedia/opieplayer2/mediaplayer.h
index 1e34c88..de3886e 100644
--- a/noncore/multimedia/opieplayer2/mediaplayer.h
+++ b/noncore/multimedia/opieplayer2/mediaplayer.h
@@ -1,77 +1,75 @@
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 LJP <> 5 Copyright (c) 2002 LJP <>
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#ifndef MEDIA_PLAYER_H 34#ifndef MEDIA_PLAYER_H
35#define MEDIA_PLAYER_H 35#define MEDIA_PLAYER_H
36 36
37#include <qmainwindow.h> 37#include <qmainwindow.h>
38#include <qframe.h> 38#include <qframe.h>
39#include <qpe/qlibrary.h>
40#include <qpe/mediaplayerplugininterface.h>
41 39
42#include "xinecontrol.h" 40#include "xinecontrol.h"
43 41
44class DocLnk; 42class DocLnk;
45class VolumeControl; 43class VolumeControl;
46 44
47class MediaPlayer : public QObject { 45class MediaPlayer : public QObject {
48 Q_OBJECT 46 Q_OBJECT
49public: 47public:
50 MediaPlayer( QObject *parent, const char *name ); 48 MediaPlayer( QObject *parent, const char *name );
51 ~MediaPlayer(); 49 ~MediaPlayer();
52private slots: 50private slots:
53 void setPlaying( bool ); 51 void setPlaying( bool );
54 void pauseCheck( bool ); 52 void pauseCheck( bool );
55 void play(); 53 void play();
56 void next(); 54 void next();
57 void prev(); 55 void prev();
58 void startIncreasingVolume(); 56 void startIncreasingVolume();
59 void startDecreasingVolume(); 57 void startDecreasingVolume();
60 void stopChangingVolume(); 58 void stopChangingVolume();
61 void cleanUp(); 59 void cleanUp();
62 void blank( bool ); 60 void blank( bool );
63 61
64protected: 62protected:
65 void timerEvent( QTimerEvent *e ); 63 void timerEvent( QTimerEvent *e );
66 void keyReleaseEvent( QKeyEvent *e); 64 void keyReleaseEvent( QKeyEvent *e);
67private: 65private:
68 bool isBlanked, l, r; 66 bool isBlanked, l, r;
69 int fd, fl; 67 int fd, fl;
70 int volumeDirection; 68 int volumeDirection;
71 XineControl *xineControl; 69 XineControl *xineControl;
72 VolumeControl *volControl; 70 VolumeControl *volControl;
73}; 71};
74 72
75 73
76#endif // MEDIA_PLAYER_H 74#endif // MEDIA_PLAYER_H
77 75
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 888fcf4..e0ca243 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -1,518 +1,517 @@
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/mediaplayerplugininterface.h>
37#include <qpe/config.h> 36#include <qpe/config.h>
38 37
39 38
40#include <qwidget.h> 39#include <qwidget.h>
41#include <qpainter.h> 40#include <qpainter.h>
42#include <qpixmap.h> 41#include <qpixmap.h>
43#include <qslider.h> 42#include <qslider.h>
44#include <qdrawutil.h> 43#include <qdrawutil.h>
45#include "videowidget.h" 44#include "videowidget.h"
46#include "mediaplayerstate.h" 45#include "mediaplayerstate.h"
47#include "playlistwidget.h" 46#include "playlistwidget.h"
48 47
49 48
50#ifdef Q_WS_QWS 49#ifdef Q_WS_QWS
51# define USE_DIRECT_PAINTER 50# define USE_DIRECT_PAINTER
52# include <qdirectpainter_qws.h> 51# include <qdirectpainter_qws.h>
53# include <qgfxraster_qws.h> 52# include <qgfxraster_qws.h>
54#endif 53#endif
55 54
56 55
57extern MediaPlayerState *mediaPlayerState; 56extern MediaPlayerState *mediaPlayerState;
58extern PlayListWidget *playList; 57extern PlayListWidget *playList;
59 58
60 59
61static const int xo = 2; // movable x offset 60static const int xo = 2; // movable x offset
62static const int yo = 0; // movable y offset 61static const int yo = 0; // movable y offset
63 62
64 63
65struct MediaButton { 64struct MediaButton {
66 bool isToggle, isHeld, isDown; 65 bool isToggle, isHeld, isDown;
67}; 66};
68 67
69MediaButton videoButtons[] = { 68MediaButton videoButtons[] = {
70 { FALSE, FALSE, FALSE }, // stop 69 { FALSE, FALSE, FALSE }, // stop
71 { TRUE, FALSE, FALSE }, // play 70 { TRUE, FALSE, FALSE }, // play
72 { FALSE, FALSE, FALSE }, // previous 71 { FALSE, FALSE, FALSE }, // previous
73 { FALSE, FALSE, FALSE }, // next 72 { FALSE, FALSE, FALSE }, // next
74 { FALSE, FALSE, FALSE }, // volUp 73 { FALSE, FALSE, FALSE }, // volUp
75 { FALSE, FALSE, FALSE }, // volDown 74 { FALSE, FALSE, FALSE }, // volDown
76 { TRUE, FALSE, FALSE } // fullscreen 75 { TRUE, FALSE, FALSE } // fullscreen
77}; 76};
78 77
79const char *skinV_mask_file_names[7] = { 78const char *skinV_mask_file_names[7] = {
80"stop","play","back","fwd","up","down","full" 79"stop","play","back","fwd","up","down","full"
81}; 80};
82 81
83static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton)); 82static const int numVButtons = (sizeof(videoButtons)/sizeof(MediaButton));
84 83
85 84
86VideoWidget::VideoWidget(QWidget* parent, const char* name) : 85VideoWidget::VideoWidget(QWidget* parent, const char* name) :
87MediaWidget( parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) { 86MediaWidget( parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) {
88 87
89 88
90 setCaption( tr("OpiePlayer - Video") ); 89 setCaption( tr("OpiePlayer - Video") );
91 90
92 videoFrame = new XineVideoWidget ( this, "Video frame" ); 91 videoFrame = new XineVideoWidget ( this, "Video frame" );
93 92
94 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); 93 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & )));
95 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); 94 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) );
96 95
97 Config cfg("OpiePlayer"); 96 Config cfg("OpiePlayer");
98 cfg.setGroup("Options"); 97 cfg.setGroup("Options");
99 skin = cfg.readEntry("Skin","default"); 98 skin = cfg.readEntry("Skin","default");
100 99
101 QString skinPath = "opieplayer2/skins/" + skin; 100 QString skinPath = "opieplayer2/skins/" + skin;
102 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 101 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
103 imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); 102 imgUp = new QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) );
104 imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); 103 imgDn = new QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) );
105 104
106 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); 105 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
107 imgButtonMask->fill( 0 ); 106 imgButtonMask->fill( 0 );
108 107
109 for ( int i = 0; i < 7; i++ ) { 108 for ( int i = 0; i < 7; i++ ) {
110 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); 109 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" );
111 masks[i] = new QBitmap( filename ); 110 masks[i] = new QBitmap( filename );
112 111
113 if ( !masks[i]->isNull() ) { 112 if ( !masks[i]->isNull() ) {
114 QImage imgMask = masks[i]->convertToImage(); 113 QImage imgMask = masks[i]->convertToImage();
115 uchar **dest = imgButtonMask->jumpTable(); 114 uchar **dest = imgButtonMask->jumpTable();
116 for ( int y = 0; y < imgUp->height(); y++ ) { 115 for ( int y = 0; y < imgUp->height(); y++ ) {
117 uchar *line = dest[y]; 116 uchar *line = dest[y];
118 for ( int x = 0; x < imgUp->width(); x++ ) { 117 for ( int x = 0; x < imgUp->width(); x++ ) {
119 if ( !qRed( imgMask.pixel( x, y ) ) ) 118 if ( !qRed( imgMask.pixel( x, y ) ) )
120 line[x] = i + 1; 119 line[x] = i + 1;
121 } 120 }
122 } 121 }
123 } 122 }
124 } 123 }
125 124
126 for ( int i = 0; i < 7; i++ ) { 125 for ( int i = 0; i < 7; i++ ) {
127 buttonPixUp[i] = NULL; 126 buttonPixUp[i] = NULL;
128 buttonPixDown[i] = NULL; 127 buttonPixDown[i] = NULL;
129 } 128 }
130 129
131 setBackgroundPixmap( *pixBg ); 130 setBackgroundPixmap( *pixBg );
132 131
133 slider = new QSlider( Qt::Horizontal, this ); 132 slider = new QSlider( Qt::Horizontal, this );
134 slider->setMinValue( 0 ); 133 slider->setMinValue( 0 );
135 slider->setMaxValue( 1 ); 134 slider->setMaxValue( 1 );
136 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 135 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
137 //slider->setFocusPolicy( QWidget::NoFocus ); 136 //slider->setFocusPolicy( QWidget::NoFocus );
138 137
139 resizeEvent( NULL ); 138 resizeEvent( NULL );
140 139
141 setLength( mediaPlayerState->length() ); 140 setLength( mediaPlayerState->length() );
142 setPosition( mediaPlayerState->position() ); 141 setPosition( mediaPlayerState->position() );
143 setFullscreen( mediaPlayerState->isFullscreen() ); 142 setFullscreen( mediaPlayerState->isFullscreen() );
144 setPlaying( mediaPlayerState->isPlaying() ); 143 setPlaying( mediaPlayerState->isPlaying() );
145} 144}
146 145
147 146
148VideoWidget::~VideoWidget() { 147VideoWidget::~VideoWidget() {
149 148
150 for ( int i = 0; i < 7; i++ ) { 149 for ( int i = 0; i < 7; i++ ) {
151 delete buttonPixUp[i]; 150 delete buttonPixUp[i];
152 delete buttonPixDown[i]; 151 delete buttonPixDown[i];
153 } 152 }
154 153
155 delete pixBg; 154 delete pixBg;
156 delete imgUp; 155 delete imgUp;
157 delete imgDn; 156 delete imgDn;
158 delete imgButtonMask; 157 delete imgButtonMask;
159 for ( int i = 0; i < 7; i++ ) { 158 for ( int i = 0; i < 7; i++ ) {
160 delete masks[i]; 159 delete masks[i];
161 } 160 }
162 161
163} 162}
164 163
165QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 164QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
166 QPixmap pix( img.width(), img.height() ); 165 QPixmap pix( img.width(), img.height() );
167 QPainter p( &pix ); 166 QPainter p( &pix );
168 p.drawTiledPixmap( pix.rect(), bg, offset ); 167 p.drawTiledPixmap( pix.rect(), bg, offset );
169 p.drawImage( 0, 0, img ); 168 p.drawImage( 0, 0, img );
170 return new QPixmap( pix ); 169 return new QPixmap( pix );
171} 170}
172 171
173QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { 172QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) {
174 QPixmap *pixmap = new QPixmap( pix ); 173 QPixmap *pixmap = new QPixmap( pix );
175 pixmap->setMask( mask ); 174 pixmap->setMask( mask );
176 return pixmap; 175 return pixmap;
177} 176}
178 177
179void VideoWidget::resizeEvent( QResizeEvent * ) { 178void VideoWidget::resizeEvent( QResizeEvent * ) {
180 int h = height(); 179 int h = height();
181 int w = width(); 180 int w = width();
182 //int Vh = 160; 181 //int Vh = 160;
183 //int Vw = 220; 182 //int Vw = 220;
184 183
185 slider->setFixedWidth( w - 20 ); 184 slider->setFixedWidth( w - 20 );
186 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 185 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
187 slider->setBackgroundOrigin( QWidget::ParentOrigin ); 186 slider->setBackgroundOrigin( QWidget::ParentOrigin );
188 slider->setFocusPolicy( QWidget::NoFocus ); 187 slider->setFocusPolicy( QWidget::NoFocus );
189 slider->setBackgroundPixmap( *pixBg ); 188 slider->setBackgroundPixmap( *pixBg );
190 189
191 xoff = 0;// ( imgUp->width() ) / 2; 190 xoff = 0;// ( imgUp->width() ) / 2;
192 if(w>h) 191 if(w>h)
193 yoff = 0; 192 yoff = 0;
194 else 193 else
195 yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; 194 yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10;
196 QPoint p( xoff, yoff ); 195 QPoint p( xoff, yoff );
197 196
198 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p ); 197 QPixmap *pixUp = combineVImageWithBackground( *imgUp, *pixBg, p );
199 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p ); 198 QPixmap *pixDn = combineVImageWithBackground( *imgDn, *pixBg, p );
200 199
201 for ( int i = 0; i < 7; i++ ) { 200 for ( int i = 0; i < 7; i++ ) {
202 if ( !masks[i]->isNull() ) { 201 if ( !masks[i]->isNull() ) {
203 delete buttonPixUp[i]; 202 delete buttonPixUp[i];
204 delete buttonPixDown[i]; 203 delete buttonPixDown[i];
205 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); 204 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] );
206 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); 205 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] );
207 } 206 }
208 } 207 }
209 208
210 delete pixUp; 209 delete pixUp;
211 delete pixDn; 210 delete pixDn;
212} 211}
213 212
214static bool videoSliderBeingMoved = FALSE; 213static bool videoSliderBeingMoved = FALSE;
215 214
216void VideoWidget::sliderPressed() { 215void VideoWidget::sliderPressed() {
217 videoSliderBeingMoved = TRUE; 216 videoSliderBeingMoved = TRUE;
218} 217}
219 218
220void VideoWidget::sliderReleased() { 219void VideoWidget::sliderReleased() {
221 videoSliderBeingMoved = FALSE; 220 videoSliderBeingMoved = FALSE;
222 if ( slider->width() == 0 ) { 221 if ( slider->width() == 0 ) {
223 return; 222 return;
224 } 223 }
225 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width()); 224 long val = long((double)slider->value() * mediaPlayerState->length() / slider->width());
226 mediaPlayerState->setPosition( val ); 225 mediaPlayerState->setPosition( val );
227} 226}
228 227
229void VideoWidget::setPosition( long i ) { 228void VideoWidget::setPosition( long i ) {
230 updateSlider( i, mediaPlayerState->length() ); 229 updateSlider( i, mediaPlayerState->length() );
231} 230}
232 231
233 232
234void VideoWidget::setLength( long max ) { 233void VideoWidget::setLength( long max ) {
235 updateSlider( mediaPlayerState->position(), max ); 234 updateSlider( mediaPlayerState->position(), max );
236} 235}
237 236
238void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) 237void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType )
239{ 238{
240 if ( displayType == MediaPlayerState::Video ) { 239 if ( displayType == MediaPlayerState::Video ) {
241 makeVisible(); 240 makeVisible();
242 return; 241 return;
243 } 242 }
244 243
245 // Effectively blank the view next time we show it so it looks nicer 244 // Effectively blank the view next time we show it so it looks nicer
246 scaledWidth = 0; 245 scaledWidth = 0;
247 scaledHeight = 0; 246 scaledHeight = 0;
248 hide(); 247 hide();
249} 248}
250 249
251void VideoWidget::updateSlider( long i, long max ) { 250void VideoWidget::updateSlider( long i, long max ) {
252 // Will flicker too much if we don't do this 251 // Will flicker too much if we don't do this
253 if ( max == 0 ) { 252 if ( max == 0 ) {
254 return; 253 return;
255 } 254 }
256 int width = slider->width(); 255 int width = slider->width();
257 int val = int((double)i * width / max); 256 int val = int((double)i * width / max);
258 if ( !mediaPlayerState->isFullscreen() && !videoSliderBeingMoved ) { 257 if ( !mediaPlayerState->isFullscreen() && !videoSliderBeingMoved ) {
259 if ( slider->value() != val ) { 258 if ( slider->value() != val ) {
260 slider->setValue( val ); 259 slider->setValue( val );
261 } 260 }
262 if ( slider->maxValue() != width ) { 261 if ( slider->maxValue() != width ) {
263 slider->setMaxValue( width ); 262 slider->setMaxValue( width );
264 } 263 }
265 } 264 }
266} 265}
267 266
268void VideoWidget::setToggleButton( int i, bool down ) { 267void VideoWidget::setToggleButton( int i, bool down ) {
269 if ( down != videoButtons[i].isDown ) { 268 if ( down != videoButtons[i].isDown ) {
270 toggleButton( i ); 269 toggleButton( i );
271 } 270 }
272} 271}
273 272
274void VideoWidget::toggleButton( int i ) { 273void VideoWidget::toggleButton( int i ) {
275 videoButtons[i].isDown = !videoButtons[i].isDown; 274 videoButtons[i].isDown = !videoButtons[i].isDown;
276 QPainter p(this); 275 QPainter p(this);
277 paintButton ( &p, i ); 276 paintButton ( &p, i );
278} 277}
279 278
280void VideoWidget::paintButton( QPainter *p, int i ) { 279void VideoWidget::paintButton( QPainter *p, int i ) {
281 280
282 if ( videoButtons[i].isDown ) { 281 if ( videoButtons[i].isDown ) {
283 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 282 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
284 } else { 283 } else {
285 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 284 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
286 } 285 }
287} 286}
288 287
289void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 288void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
290 for ( int i = 0; i < numVButtons; i++ ) { 289 for ( int i = 0; i < numVButtons; i++ ) {
291 if ( event->state() == QMouseEvent::LeftButton ) { 290 if ( event->state() == QMouseEvent::LeftButton ) {
292 // The test to see if the mouse click is inside the button or not 291 // The test to see if the mouse click is inside the button or not
293 int x = event->pos().x() - xoff; 292 int x = event->pos().x() - xoff;
294 int y = event->pos().y() - yoff; 293 int y = event->pos().y() - yoff;
295 294
296 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width() 295 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask->width()
297 && y < imgButtonMask->height() 296 && y < imgButtonMask->height()
298 && imgButtonMask->pixelIndex( x, y ) == i + 1 ); 297 && imgButtonMask->pixelIndex( x, y ) == i + 1 );
299 298
300 if ( isOnButton && !videoButtons[i].isHeld ) { 299 if ( isOnButton && !videoButtons[i].isHeld ) {
301 videoButtons[i].isHeld = TRUE; 300 videoButtons[i].isHeld = TRUE;
302 toggleButton(i); 301 toggleButton(i);
303 302
304 switch (i) { 303 switch (i) {
305 case VideoVolUp: 304 case VideoVolUp:
306 emit moreClicked(); 305 emit moreClicked();
307 return; 306 return;
308 case VideoVolDown: 307 case VideoVolDown:
309 emit lessClicked(); 308 emit lessClicked();
310 return; 309 return;
311 } 310 }
312 } else if ( !isOnButton && videoButtons[i].isHeld ) { 311 } else if ( !isOnButton && videoButtons[i].isHeld ) {
313 videoButtons[i].isHeld = FALSE; 312 videoButtons[i].isHeld = FALSE;
314 toggleButton(i); 313 toggleButton(i);
315 } 314 }
316 } else { 315 } else {
317 316
318 if ( videoButtons[i].isHeld ) { 317 if ( videoButtons[i].isHeld ) {
319 videoButtons[i].isHeld = FALSE; 318 videoButtons[i].isHeld = FALSE;
320 if ( !videoButtons[i].isToggle ) { 319 if ( !videoButtons[i].isToggle ) {
321 setToggleButton( i, FALSE ); 320 setToggleButton( i, FALSE );
322 } 321 }
323 322
324 switch(i) { 323 switch(i) {
325 324
326 case VideoPlay: { 325 case VideoPlay: {
327 if( mediaPlayerState->isPaused() ) { 326 if( mediaPlayerState->isPaused() ) {
328 setToggleButton( i, FALSE ); 327 setToggleButton( i, FALSE );
329 mediaPlayerState->setPaused( FALSE ); 328 mediaPlayerState->setPaused( FALSE );
330 return; 329 return;
331 } else if( !mediaPlayerState->isPaused() ) { 330 } else if( !mediaPlayerState->isPaused() ) {
332 setToggleButton( i, TRUE ); 331 setToggleButton( i, TRUE );
333 mediaPlayerState->setPaused( TRUE ); 332 mediaPlayerState->setPaused( TRUE );
334 return; 333 return;
335 } else { 334 } else {
336 return; 335 return;
337 } 336 }
338 } 337 }
339 338
340 case VideoStop: mediaPlayerState->setPlaying( FALSE ); return; 339 case VideoStop: mediaPlayerState->setPlaying( FALSE ); return;
341 case VideoNext: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState->setNext(); return; 340 case VideoNext: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState->setNext(); return;
342 case VideoPrevious: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState->setPrev(); return; 341 case VideoPrevious: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState->setPrev(); return;
343 case VideoVolUp: emit moreReleased(); return; 342 case VideoVolUp: emit moreReleased(); return;
344 case VideoVolDown: emit lessReleased(); return; 343 case VideoVolDown: emit lessReleased(); return;
345 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return; 344 case VideoFullscreen: mediaPlayerState->setFullscreen( TRUE ); makeVisible(); return;
346 } 345 }
347 } 346 }
348 } 347 }
349 } 348 }
350} 349}
351 350
352void VideoWidget::mousePressEvent( QMouseEvent *event ) { 351void VideoWidget::mousePressEvent( QMouseEvent *event ) {
353 mouseMoveEvent( event ); 352 mouseMoveEvent( event );
354} 353}
355 354
356void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 355void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
357 if ( mediaPlayerState->isFullscreen() ) { 356 if ( mediaPlayerState->isFullscreen() ) {
358 mediaPlayerState->setFullscreen( FALSE ); 357 mediaPlayerState->setFullscreen( FALSE );
359 makeVisible(); 358 makeVisible();
360 } 359 }
361 mouseMoveEvent( event ); 360 mouseMoveEvent( event );
362} 361}
363 362
364void VideoWidget::showEvent( QShowEvent* ) { 363void VideoWidget::showEvent( QShowEvent* ) {
365 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 364 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
366 mouseMoveEvent( &event ); 365 mouseMoveEvent( &event );
367} 366}
368 367
369 368
370 void VideoWidget::backToNormal() { 369 void VideoWidget::backToNormal() {
371 mediaPlayerState->setFullscreen( FALSE ); 370 mediaPlayerState->setFullscreen( FALSE );
372 makeVisible(); 371 makeVisible();
373 } 372 }
374 373
375void VideoWidget::makeVisible() { 374void VideoWidget::makeVisible() {
376 if ( mediaPlayerState->isFullscreen() ) { 375 if ( mediaPlayerState->isFullscreen() ) {
377 setBackgroundMode( QWidget::NoBackground ); 376 setBackgroundMode( QWidget::NoBackground );
378 showFullScreen(); 377 showFullScreen();
379 resize( qApp->desktop()->size() ); 378 resize( qApp->desktop()->size() );
380 videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); 379 videoFrame-> setGeometry ( 0, 0, width ( ), height ( ));
381 380
382 slider->hide(); 381 slider->hide();
383 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 382 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
384 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 383 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
385 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 384 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
386 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 385 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
387 386
388 } else { 387 } else {
389 showNormal(); 388 showNormal();
390 showMaximized(); 389 showMaximized();
391 setBackgroundPixmap( *pixBg ); 390 setBackgroundPixmap( *pixBg );
392 QWidget *d = QApplication::desktop(); 391 QWidget *d = QApplication::desktop();
393 int w = d->width(); 392 int w = d->width();
394 int h = d->height(); 393 int h = d->height();
395 394
396 if(w>h) { 395 if(w>h) {
397 int newW=(w/2)-(246/2); //this will only work with 320x240 396 int newW=(w/2)-(246/2); //this will only work with 320x240
398 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); 397 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) );
399 } else { 398 } else {
400 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); 399 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) );
401 } 400 }
402 401
403 if ( !mediaPlayerState->isSeekable() ) { 402 if ( !mediaPlayerState->isSeekable() ) {
404 if( !slider->isHidden()) { 403 if( !slider->isHidden()) {
405 slider->hide(); 404 slider->hide();
406 } 405 }
407 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 406 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
408 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 407 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
409 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 408 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
410 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 409 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
411 } else { 410 } else {
412 slider->show(); 411 slider->show();
413 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 412 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
414 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 413 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
415 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 414 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
416 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 415 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
417 } 416 }
418 } 417 }
419} 418}
420 419
421 420
422 421
423 422
424void VideoWidget::paintEvent( QPaintEvent * pe) { 423void VideoWidget::paintEvent( QPaintEvent * pe) {
425 QPainter p( this ); 424 QPainter p( this );
426 425
427 if ( mediaPlayerState->isFullscreen() ) { 426 if ( mediaPlayerState->isFullscreen() ) {
428 // Clear the background 427 // Clear the background
429 p.setBrush( QBrush( Qt::black ) ); 428 p.setBrush( QBrush( Qt::black ) );
430 } else { 429 } else {
431 if ( !pe->erased() ) { 430 if ( !pe->erased() ) {
432 // Combine with background and double buffer 431 // Combine with background and double buffer
433 QPixmap pix( pe->rect().size() ); 432 QPixmap pix( pe->rect().size() );
434 QPainter p( &pix ); 433 QPainter p( &pix );
435 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 434 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
436 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() ); 435 p.drawTiledPixmap( pe->rect(), *pixBg, pe->rect().topLeft() );
437 for ( int i = 0; i < numVButtons; i++ ) { 436 for ( int i = 0; i < numVButtons; i++ ) {
438 paintButton( &p, i ); 437 paintButton( &p, i );
439 } 438 }
440 QPainter p2( this ); 439 QPainter p2( this );
441 p2.drawPixmap( pe->rect().topLeft(), pix ); 440 p2.drawPixmap( pe->rect().topLeft(), pix );
442 } else { 441 } else {
443 QPainter p( this ); 442 QPainter p( this );
444 for ( int i = 0; i < numVButtons; i++ ) 443 for ( int i = 0; i < numVButtons; i++ )
445 paintButton( &p, i ); 444 paintButton( &p, i );
446 } 445 }
447 //slider->repaint( TRUE ); 446 //slider->repaint( TRUE );
448 } 447 }
449} 448}
450 449
451 450
452void VideoWidget::closeEvent( QCloseEvent* ) { 451void VideoWidget::closeEvent( QCloseEvent* ) {
453 mediaPlayerState->setList(); 452 mediaPlayerState->setList();
454} 453}
455 454
456 455
457void VideoWidget::keyReleaseEvent( QKeyEvent *e) { 456void VideoWidget::keyReleaseEvent( QKeyEvent *e) {
458 switch ( e->key() ) { 457 switch ( e->key() ) {
459////////////////////////////// Zaurus keys 458////////////////////////////// Zaurus keys
460 case Key_Home: 459 case Key_Home:
461 break; 460 break;
462 case Key_F9: //activity 461 case Key_F9: //activity
463 break; 462 break;
464 case Key_F10: //contacts 463 case Key_F10: //contacts
465// hide(); 464// hide();
466 break; 465 break;
467 case Key_F11: //menu 466 case Key_F11: //menu
468 break; 467 break;
469 case Key_F12: //home 468 case Key_F12: //home
470 break; 469 break;
471 case Key_F13: //mail 470 case Key_F13: //mail
472 break; 471 break;
473 case Key_Space: { 472 case Key_Space: {
474 if(mediaPlayerState->isPlaying()) { 473 if(mediaPlayerState->isPlaying()) {
475 mediaPlayerState->setPlaying(FALSE); 474 mediaPlayerState->setPlaying(FALSE);
476 } else { 475 } else {
477 mediaPlayerState->setPlaying(TRUE); 476 mediaPlayerState->setPlaying(TRUE);
478 } 477 }
479 } 478 }
480 break; 479 break;
481 case Key_Down: 480 case Key_Down:
482// toggleButton(6); 481// toggleButton(6);
483 emit lessClicked(); 482 emit lessClicked();
484 emit lessReleased(); 483 emit lessReleased();
485// toggleButton(6); 484// toggleButton(6);
486 break; 485 break;
487 case Key_Up: 486 case Key_Up:
488// toggleButton(5); 487// toggleButton(5);
489 emit moreClicked(); 488 emit moreClicked();
490 emit moreReleased(); 489 emit moreReleased();
491// toggleButton(5); 490// toggleButton(5);
492 break; 491 break;
493 case Key_Right: 492 case Key_Right:
494 mediaPlayerState->setNext(); 493 mediaPlayerState->setNext();
495 break; 494 break;
496 case Key_Left: 495 case Key_Left:
497 mediaPlayerState->setPrev(); 496 mediaPlayerState->setPrev();
498 break; 497 break;
499 case Key_Escape: 498 case Key_Escape:
500 break; 499 break;
501 500
502 }; 501 };
503} 502}
504 503
505XineVideoWidget* VideoWidget::vidWidget() { 504XineVideoWidget* VideoWidget::vidWidget() {
506 return videoFrame; 505 return videoFrame;
507} 506}
508 507
509 508
510void VideoWidget::setFullscreen ( bool b ) { 509void VideoWidget::setFullscreen ( bool b ) {
511 setToggleButton( VideoFullscreen, b ); 510 setToggleButton( VideoFullscreen, b );
512} 511}
513 512
514 513
515void VideoWidget::setPlaying( bool b) { 514void VideoWidget::setPlaying( bool b) {
516 setToggleButton( VideoPlay, b ); 515 setToggleButton( VideoPlay, b );
517} 516}
518 517