summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-08 21:22:34 (UTC)
committer simon <simon>2002-12-08 21:22:34 (UTC)
commit10cf937a493866cfa0df9569f67c8cad25c62a5b (patch) (unidiff)
tree95719a27fb96ecb6c115f7816265a0377787db64
parenta78a8d830d81adc8c6e9b2131329d72aa0c18b55 (diff)
downloadopie-10cf937a493866cfa0df9569f67c8cad25c62a5b.zip
opie-10cf937a493866cfa0df9569f67c8cad25c62a5b.tar.gz
opie-10cf937a493866cfa0df9569f67c8cad25c62a5b.tar.bz2
- unused variables removed
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp22
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h4
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp14
3 files changed, 1 insertions, 39 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 4172da0..7fb3781 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -1,540 +1,518 @@
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#include <opie/oticker.h> 37#include <opie/oticker.h>
38 38
39#include <qwidget.h> 39#include <qwidget.h>
40#include <qpixmap.h> 40#include <qpixmap.h>
41#include <qbutton.h> 41#include <qbutton.h>
42#include <qpainter.h> 42#include <qpainter.h>
43#include <qframe.h> 43#include <qframe.h>
44#include <qlayout.h> 44#include <qlayout.h>
45#include <qdir.h> 45#include <qdir.h>
46#include <stdlib.h> 46#include <stdlib.h>
47#include <stdio.h> 47#include <stdio.h>
48 48
49#include "audiowidget.h" 49#include "audiowidget.h"
50#include "mediaplayerstate.h" 50#include "mediaplayerstate.h"
51#include "playlistwidget.h" 51#include "playlistwidget.h"
52 52
53namespace 53namespace
54{ 54{
55 55
56const int xo = -2; // movable x offset 56const int xo = -2; // movable x offset
57const int yo = 22; // movable y offset 57const int yo = 22; // movable y offset
58 58
59struct MediaButton {
60 bool isToggle, isHeld, isDown;
61};
62
63//Layout information for the audioButtons (and if it is a toggle button or not)
64/*
65MediaWidget::Button audioButtons[] = {
66 { TRUE, FALSE, FALSE }, // play
67 { FALSE, FALSE, FALSE }, // stop
68 { FALSE, FALSE, FALSE }, // next
69 { FALSE, FALSE, FALSE }, // previous
70 { FALSE, FALSE, FALSE }, // volume up
71 { FALSE, FALSE, FALSE }, // volume down
72 { TRUE, FALSE, FALSE }, // repeat/loop
73 { FALSE, FALSE, FALSE }, // playlist
74 { FALSE, FALSE, FALSE }, // forward
75 { FALSE, FALSE, FALSE } // back
76};
77*/
78
79const char * const skin_mask_file_names[10] = { 59const char * const skin_mask_file_names[10] = {
80 "play", "stop", "next", "prev", "up", 60 "play", "stop", "next", "prev", "up",
81 "down", "loop", "playlist", "forward", "back" 61 "down", "loop", "playlist", "forward", "back"
82}; 62};
83 63
84void changeTextColor( QWidget * w) { 64void changeTextColor( QWidget * w) {
85 QPalette p = w->palette(); 65 QPalette p = w->palette();
86 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); 66 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) );
87 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); 67 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) );
88 w->setPalette( p ); 68 w->setPalette( p );
89} 69}
90 70
91//const int numButtons = (sizeof(audioButtons)/sizeof(MediaWidget::Button));
92
93} 71}
94 72
95AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : 73AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) :
96 74
97 MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { 75 MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) {
98 76
99 Button defaultButton; 77 Button defaultButton;
100 defaultButton.isToggle = defaultButton.isHeld = defaultButton.isDown = false; 78 defaultButton.isToggle = defaultButton.isHeld = defaultButton.isDown = false;
101 Button toggleButton; 79 Button toggleButton;
102 toggleButton.isToggle = true; 80 toggleButton.isToggle = true;
103 toggleButton.isHeld = toggleButton.isDown = false; 81 toggleButton.isHeld = toggleButton.isDown = false;
104 82
105 audioButtons.reserve( 10 ); 83 audioButtons.reserve( 10 );
106 audioButtons.push_back( toggleButton ); // play 84 audioButtons.push_back( toggleButton ); // play
107 audioButtons.push_back( defaultButton ); // stop 85 audioButtons.push_back( defaultButton ); // stop
108 audioButtons.push_back( defaultButton ); // next 86 audioButtons.push_back( defaultButton ); // next
109 audioButtons.push_back( defaultButton ); // previous 87 audioButtons.push_back( defaultButton ); // previous
110 audioButtons.push_back( defaultButton ); // volume up 88 audioButtons.push_back( defaultButton ); // volume up
111 audioButtons.push_back( defaultButton ); // volume down 89 audioButtons.push_back( defaultButton ); // volume down
112 audioButtons.push_back( toggleButton ); // repeat/loop 90 audioButtons.push_back( toggleButton ); // repeat/loop
113 audioButtons.push_back( defaultButton ); // playlist 91 audioButtons.push_back( defaultButton ); // playlist
114 audioButtons.push_back( defaultButton ); // forward 92 audioButtons.push_back( defaultButton ); // forward
115 audioButtons.push_back( defaultButton ); // back 93 audioButtons.push_back( defaultButton ); // back
116 94
117 setCaption( tr("OpiePlayer") ); 95 setCaption( tr("OpiePlayer") );
118 96
119 Config cfg("OpiePlayer"); 97 Config cfg("OpiePlayer");
120 cfg.setGroup("Options"); 98 cfg.setGroup("Options");
121 skin = cfg.readEntry("Skin","default"); 99 skin = cfg.readEntry("Skin","default");
122 //skin = "scaleTest"; 100 //skin = "scaleTest";
123 // color of background, frame, degree of transparency 101 // color of background, frame, degree of transparency
124 102
125 QString skinPath = "opieplayer2/skins/" + skin; 103 QString skinPath = "opieplayer2/skins/" + skin;
126 pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 104 pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
127 imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); 105 imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
128 imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); 106 imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
129 107
130 imgButtonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); 108 imgButtonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 );
131 imgButtonMask.fill( 0 ); 109 imgButtonMask.fill( 0 );
132 110
133 for ( int i = 0; i < 10; i++ ) { 111 for ( int i = 0; i < 10; i++ ) {
134 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" ); 112 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" );
135 masks[i] = new QBitmap( filename ); 113 masks[i] = new QBitmap( filename );
136 114
137 if ( !masks[i]->isNull() ) { 115 if ( !masks[i]->isNull() ) {
138 QImage imgMask = masks[i]->convertToImage(); 116 QImage imgMask = masks[i]->convertToImage();
139 uchar **dest = imgButtonMask.jumpTable(); 117 uchar **dest = imgButtonMask.jumpTable();
140 for ( int y = 0; y < imgUp.height(); y++ ) { 118 for ( int y = 0; y < imgUp.height(); y++ ) {
141 uchar *line = dest[y]; 119 uchar *line = dest[y];
142 for ( int x = 0; x < imgUp.width(); x++ ) 120 for ( int x = 0; x < imgUp.width(); x++ )
143 if ( !qRed( imgMask.pixel( x, y ) ) ) 121 if ( !qRed( imgMask.pixel( x, y ) ) )
144 line[x] = i + 1; 122 line[x] = i + 1;
145 } 123 }
146 } 124 }
147 125
148 } 126 }
149 127
150 for ( int i = 0; i < 10; i++ ) { 128 for ( int i = 0; i < 10; i++ ) {
151 buttonPixUp[i] = 0l; 129 buttonPixUp[i] = 0l;
152 buttonPixDown[i] = 0l; 130 buttonPixDown[i] = 0l;
153 } 131 }
154 132
155 setBackgroundPixmap( pixBg ); 133 setBackgroundPixmap( pixBg );
156 134
157 songInfo.setFocusPolicy( QWidget::NoFocus ); 135 songInfo.setFocusPolicy( QWidget::NoFocus );
158// changeTextColor( &songInfo ); 136// changeTextColor( &songInfo );
159// songInfo.setBackgroundColor( QColor( 167, 212, 167 )); 137// songInfo.setBackgroundColor( QColor( 167, 212, 167 ));
160// songInfo.setFrameStyle( QFrame::NoFrame); 138// songInfo.setFrameStyle( QFrame::NoFrame);
161 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); 139 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
162// songInfo.setForegroundColor(Qt::white); 140// songInfo.setForegroundColor(Qt::white);
163 141
164 slider.setFixedHeight( 20 ); 142 slider.setFixedHeight( 20 );
165 slider.setMinValue( 0 ); 143 slider.setMinValue( 0 );
166 slider.setMaxValue( 1 ); 144 slider.setMaxValue( 1 );
167 slider.setFocusPolicy( QWidget::NoFocus ); 145 slider.setFocusPolicy( QWidget::NoFocus );
168 slider.setBackgroundPixmap( pixBg ); 146 slider.setBackgroundPixmap( pixBg );
169 147
170// Config cofg("qpe"); 148// Config cofg("qpe");
171// cofg.setGroup("Appearance"); 149// cofg.setGroup("Appearance");
172// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); 150// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) );
173 151
174 time.setFocusPolicy( QWidget::NoFocus ); 152 time.setFocusPolicy( QWidget::NoFocus );
175 time.setAlignment( Qt::AlignCenter ); 153 time.setAlignment( Qt::AlignCenter );
176 154
177// time.setFrame(FALSE); 155// time.setFrame(FALSE);
178// changeTextColor( &time ); 156// changeTextColor( &time );
179 157
180 resizeEvent( NULL ); 158 resizeEvent( NULL );
181 159
182 connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 160 connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
183 connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); 161 connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) );
184 162
185 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); 163 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) );
186 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); 164 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) );
187 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); 165 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) );
188 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); 166 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) );
189 167
190 // Intialise state 168 // Intialise state
191 setLength( mediaPlayerState.length() ); 169 setLength( mediaPlayerState.length() );
192 setPosition( mediaPlayerState.position() ); 170 setPosition( mediaPlayerState.position() );
193 setLooping( mediaPlayerState.isFullscreen() ); 171 setLooping( mediaPlayerState.isFullscreen() );
194 // setPaused( mediaPlayerState->paused() ); 172 // setPaused( mediaPlayerState->paused() );
195 setPlaying( mediaPlayerState.isPlaying() ); 173 setPlaying( mediaPlayerState.isPlaying() );
196 174
197} 175}
198 176
199AudioWidget::~AudioWidget() { 177AudioWidget::~AudioWidget() {
200 178
201 for ( int i = 0; i < 10; i++ ) { 179 for ( int i = 0; i < 10; i++ ) {
202 delete buttonPixUp[i]; 180 delete buttonPixUp[i];
203 delete buttonPixDown[i]; 181 delete buttonPixDown[i];
204 } 182 }
205 for ( int i = 0; i < 10; i++ ) { 183 for ( int i = 0; i < 10; i++ ) {
206 delete masks[i]; 184 delete masks[i];
207 } 185 }
208// mediaPlayerState->setPlaying(false); 186// mediaPlayerState->setPlaying(false);
209} 187}
210 188
211namespace { 189namespace {
212 190
213QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 191QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
214 QPixmap pix( img.width(), img.height() ); 192 QPixmap pix( img.width(), img.height() );
215 QPainter p( &pix ); 193 QPainter p( &pix );
216 p.drawTiledPixmap( pix.rect(), bg, offset ); 194 p.drawTiledPixmap( pix.rect(), bg, offset );
217 p.drawImage( 0, 0, img ); 195 p.drawImage( 0, 0, img );
218 return pix; 196 return pix;
219} 197}
220 198
221 199
222QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { 200QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) {
223 QPixmap *pixmap = new QPixmap( pix ); 201 QPixmap *pixmap = new QPixmap( pix );
224 pixmap->setMask( mask ); 202 pixmap->setMask( mask );
225 return pixmap; 203 return pixmap;
226} 204}
227 205
228}; 206};
229 207
230void AudioWidget::resizeEvent( QResizeEvent * ) { 208void AudioWidget::resizeEvent( QResizeEvent * ) {
231 int h = height(); 209 int h = height();
232 int w = width(); 210 int w = width();
233 211
234 songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); 212 songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) );
235 slider.setFixedWidth( w - 110 ); 213 slider.setFixedWidth( w - 110 );
236 slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 214 slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
237 slider.setBackgroundOrigin( QWidget::ParentOrigin ); 215 slider.setBackgroundOrigin( QWidget::ParentOrigin );
238 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); 216 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
239 217
240 xoff = ( w - imgUp.width() ) / 2; 218 xoff = ( w - imgUp.width() ) / 2;
241 yoff = (( h - imgUp.height() ) / 2) - 10; 219 yoff = (( h - imgUp.height() ) / 2) - 10;
242 QPoint p( xoff, yoff ); 220 QPoint p( xoff, yoff );
243 221
244 QPixmap pixUp = combineImageWithBackground( imgUp, pixBg, p ); 222 QPixmap pixUp = combineImageWithBackground( imgUp, pixBg, p );
245 QPixmap pixDn = combineImageWithBackground( imgDn, pixBg, p ); 223 QPixmap pixDn = combineImageWithBackground( imgDn, pixBg, p );
246 224
247 for ( int i = 0; i < 10; i++ ) { 225 for ( int i = 0; i < 10; i++ ) {
248 if ( !masks[i]->isNull() ) { 226 if ( !masks[i]->isNull() ) {
249 delete buttonPixUp[i]; 227 delete buttonPixUp[i];
250 delete buttonPixDown[i]; 228 delete buttonPixDown[i];
251 buttonPixUp[i] = maskPixToMask( pixUp, *masks[i] ); 229 buttonPixUp[i] = maskPixToMask( pixUp, *masks[i] );
252 buttonPixDown[i] = maskPixToMask( pixDn, *masks[i] ); 230 buttonPixDown[i] = maskPixToMask( pixDn, *masks[i] );
253 } 231 }
254 } 232 }
255} 233}
256 234
257static bool audioSliderBeingMoved = FALSE; 235static bool audioSliderBeingMoved = FALSE;
258 236
259 237
260void AudioWidget::sliderPressed() { 238void AudioWidget::sliderPressed() {
261 audioSliderBeingMoved = TRUE; 239 audioSliderBeingMoved = TRUE;
262} 240}
263 241
264 242
265void AudioWidget::sliderReleased() { 243void AudioWidget::sliderReleased() {
266 audioSliderBeingMoved = FALSE; 244 audioSliderBeingMoved = FALSE;
267 if ( slider.width() == 0 ) 245 if ( slider.width() == 0 )
268 return; 246 return;
269 long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); 247 long val = long((double)slider.value() * mediaPlayerState.length() / slider.width());
270 mediaPlayerState.setPosition( val ); 248 mediaPlayerState.setPosition( val );
271} 249}
272 250
273void AudioWidget::setPosition( long i ) { 251void AudioWidget::setPosition( long i ) {
274 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); 252 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i);
275 updateSlider( i, mediaPlayerState.length() ); 253 updateSlider( i, mediaPlayerState.length() );
276} 254}
277 255
278 256
279void AudioWidget::setLength( long max ) { 257void AudioWidget::setLength( long max ) {
280 updateSlider( mediaPlayerState.position(), max ); 258 updateSlider( mediaPlayerState.position(), max );
281} 259}
282 260
283 261
284void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { 262void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) {
285 if ( mediaType == MediaPlayerState::Audio ) { 263 if ( mediaType == MediaPlayerState::Audio ) {
286 // startTimer( 150 ); 264 // startTimer( 150 );
287 showMaximized(); 265 showMaximized();
288 return; 266 return;
289 } 267 }
290 268
291 killTimers(); 269 killTimers();
292 hide(); 270 hide();
293} 271}
294 272
295 273
296void AudioWidget::setSeekable( bool isSeekable ) { 274void AudioWidget::setSeekable( bool isSeekable ) {
297 275
298 if ( !isSeekable ) { 276 if ( !isSeekable ) {
299 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); 277 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>");
300 if( !slider.isHidden()) { 278 if( !slider.isHidden()) {
301 slider.hide(); 279 slider.hide();
302 } 280 }
303 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 281 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
304 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 282 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
305 disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 283 disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
306 disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 284 disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
307 } else { 285 } else {
308 // this stops the slider from being moved, thus 286 // this stops the slider from being moved, thus
309 // does not stop stream when it reaches the end 287 // does not stop stream when it reaches the end
310 slider.show(); 288 slider.show();
311 qDebug( " CONNECT SET POSTION " ); 289 qDebug( " CONNECT SET POSTION " );
312 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 290 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
313 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 291 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
314 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 292 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
315 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 293 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
316 } 294 }
317} 295}
318 296
319 297
320static QString timeAsString( long length ) { 298static QString timeAsString( long length ) {
321 int minutes = length / 60; 299 int minutes = length / 60;
322 int seconds = length % 60; 300 int seconds = length % 60;
323 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); 301 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 );
324} 302}
325 303
326void AudioWidget::updateSlider( long i, long max ) { 304void AudioWidget::updateSlider( long i, long max ) {
327 305
328 time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); 306 time.setText( timeAsString( i ) + " / " + timeAsString( max ) );
329// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; 307// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ;
330 308
331 if ( max == 0 ) { 309 if ( max == 0 ) {
332 return; 310 return;
333 } 311 }
334 // Will flicker too much if we don't do this 312 // Will flicker too much if we don't do this
335 // Scale to something reasonable 313 // Scale to something reasonable
336 int width = slider.width(); 314 int width = slider.width();
337 int val = int((double)i * width / max); 315 int val = int((double)i * width / max);
338 if ( !audioSliderBeingMoved ) { 316 if ( !audioSliderBeingMoved ) {
339 if ( slider.value() != val ) { 317 if ( slider.value() != val ) {
340 slider.setValue( val ); 318 slider.setValue( val );
341 } 319 }
342 320
343 if ( slider.maxValue() != width ) { 321 if ( slider.maxValue() != width ) {
344 slider.setMaxValue( width ); 322 slider.setMaxValue( width );
345 } 323 }
346 } 324 }
347} 325}
348 326
349 327
350void AudioWidget::setToggleButton( int i, bool down ) { 328void AudioWidget::setToggleButton( int i, bool down ) {
351 qDebug("setToggleButton %d", i); 329 qDebug("setToggleButton %d", i);
352 if ( down != audioButtons[i].isDown ) { 330 if ( down != audioButtons[i].isDown ) {
353 toggleButton( i ); 331 toggleButton( i );
354 } 332 }
355} 333}
356 334
357 335
358void AudioWidget::toggleButton( int i ) { 336void AudioWidget::toggleButton( int i ) {
359 audioButtons[i].isDown = !audioButtons[i].isDown; 337 audioButtons[i].isDown = !audioButtons[i].isDown;
360 QPainter p(this); 338 QPainter p(this);
361 paintButton ( &p, i ); 339 paintButton ( &p, i );
362} 340}
363 341
364 342
365void AudioWidget::paintButton( QPainter *p, int i ) { 343void AudioWidget::paintButton( QPainter *p, int i ) {
366 if ( audioButtons[i].isDown ) { 344 if ( audioButtons[i].isDown ) {
367 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 345 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
368 } else { 346 } else {
369 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 347 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
370 } 348 }
371} 349}
372 350
373 351
374void AudioWidget::skipFor() { 352void AudioWidget::skipFor() {
375 skipDirection = +1; 353 skipDirection = +1;
376 startTimer( 50 ); 354 startTimer( 50 );
377 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); 355 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
378} 356}
379 357
380void AudioWidget::skipBack() { 358void AudioWidget::skipBack() {
381 skipDirection = -1; 359 skipDirection = -1;
382 startTimer( 50 ); 360 startTimer( 50 );
383 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); 361 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
384} 362}
385 363
386 364
387 365
388void AudioWidget::stopSkip() { 366void AudioWidget::stopSkip() {
389 killTimers(); 367 killTimers();
390} 368}
391 369
392 370
393void AudioWidget::timerEvent( QTimerEvent * ) { 371void AudioWidget::timerEvent( QTimerEvent * ) {
394 if ( skipDirection == +1 ) { 372 if ( skipDirection == +1 ) {
395 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); 373 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
396 } else if ( skipDirection == -1 ) { 374 } else if ( skipDirection == -1 ) {
397 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); 375 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
398 } 376 }
399} 377}
400 378
401 379
402void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 380void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
403 for ( unsigned int i = 0; i < audioButtons.size(); i++ ) { 381 for ( unsigned int i = 0; i < audioButtons.size(); i++ ) {
404 if ( event->state() == QMouseEvent::LeftButton ) { 382 if ( event->state() == QMouseEvent::LeftButton ) {
405 // The test to see if the mouse click is inside the button or not 383 // The test to see if the mouse click is inside the button or not
406 int x = event->pos().x() - xoff; 384 int x = event->pos().x() - xoff;
407 int y = event->pos().y() - yoff; 385 int y = event->pos().y() - yoff;
408 386
409 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask.width() 387 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask.width()
410 && y < imgButtonMask.height() 388 && y < imgButtonMask.height()
411 && imgButtonMask.pixelIndex( x, y ) == i + 1 ); 389 && imgButtonMask.pixelIndex( x, y ) == i + 1 );
412 390
413 if ( isOnButton && !audioButtons[i].isHeld ) { 391 if ( isOnButton && !audioButtons[i].isHeld ) {
414 audioButtons[i].isHeld = TRUE; 392 audioButtons[i].isHeld = TRUE;
415 toggleButton(i); 393 toggleButton(i);
416 switch (i) { 394 switch (i) {
417 case VolumeUp: 395 case VolumeUp:
418 emit moreClicked(); 396 emit moreClicked();
419 return; 397 return;
420 case VolumeDown: 398 case VolumeDown:
421 emit lessClicked(); 399 emit lessClicked();
422 return; 400 return;
423 case Forward: 401 case Forward:
424 emit forwardClicked(); 402 emit forwardClicked();
425 return; 403 return;
426 case Back: 404 case Back:
427 emit backClicked(); 405 emit backClicked();
428 return; 406 return;
429 } 407 }
430 } else if ( !isOnButton && audioButtons[i].isHeld ) { 408 } else if ( !isOnButton && audioButtons[i].isHeld ) {
431 audioButtons[i].isHeld = FALSE; 409 audioButtons[i].isHeld = FALSE;
432 toggleButton(i); 410 toggleButton(i);
433 } 411 }
434 } else { 412 } else {
435 if ( audioButtons[i].isHeld ) { 413 if ( audioButtons[i].isHeld ) {
436 audioButtons[i].isHeld = FALSE; 414 audioButtons[i].isHeld = FALSE;
437 if ( !audioButtons[i].isToggle ) { 415 if ( !audioButtons[i].isToggle ) {
438 setToggleButton( i, FALSE ); 416 setToggleButton( i, FALSE );
439 } 417 }
440 qDebug("mouseEvent %d", i); 418 qDebug("mouseEvent %d", i);
441 handleCommand( static_cast<Command>( i ), audioButtons[ i ].isDown ); 419 handleCommand( static_cast<Command>( i ), audioButtons[ i ].isDown );
442 } 420 }
443 } 421 }
444 } 422 }
445} 423}
446 424
447 425
448void AudioWidget::mousePressEvent( QMouseEvent *event ) { 426void AudioWidget::mousePressEvent( QMouseEvent *event ) {
449 mouseMoveEvent( event ); 427 mouseMoveEvent( event );
450} 428}
451 429
452 430
453void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { 431void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
454 mouseMoveEvent( event ); 432 mouseMoveEvent( event );
455} 433}
456 434
457 435
458void AudioWidget::showEvent( QShowEvent* ) { 436void AudioWidget::showEvent( QShowEvent* ) {
459 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 437 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
460 mouseMoveEvent( &event ); 438 mouseMoveEvent( &event );
461} 439}
462 440
463 441
464void AudioWidget::paintEvent( QPaintEvent * pe ) { 442void AudioWidget::paintEvent( QPaintEvent * pe ) {
465 if ( !pe->erased() ) { 443 if ( !pe->erased() ) {
466 // Combine with background and double buffer 444 // Combine with background and double buffer
467 QPixmap pix( pe->rect().size() ); 445 QPixmap pix( pe->rect().size() );
468 QPainter p( &pix ); 446 QPainter p( &pix );
469 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 447 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
470 p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); 448 p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() );
471 for ( unsigned int i = 0; i < audioButtons.size(); i++ ) 449 for ( unsigned int i = 0; i < audioButtons.size(); i++ )
472 paintButton( &p, i ); 450 paintButton( &p, i );
473 QPainter p2( this ); 451 QPainter p2( this );
474 p2.drawPixmap( pe->rect().topLeft(), pix ); 452 p2.drawPixmap( pe->rect().topLeft(), pix );
475 } else { 453 } else {
476 QPainter p( this ); 454 QPainter p( this );
477 for ( unsigned int i = 0; i < audioButtons.size(); i++ ) 455 for ( unsigned int i = 0; i < audioButtons.size(); i++ )
478 paintButton( &p, i ); 456 paintButton( &p, i );
479 } 457 }
480} 458}
481 459
482void AudioWidget::keyReleaseEvent( QKeyEvent *e) { 460void AudioWidget::keyReleaseEvent( QKeyEvent *e) {
483 switch ( e->key() ) { 461 switch ( e->key() ) {
484 ////////////////////////////// Zaurus keys 462 ////////////////////////////// Zaurus keys
485 case Key_Home: 463 case Key_Home:
486 break; 464 break;
487 case Key_F9: //activity 465 case Key_F9: //activity
488 hide(); 466 hide();
489 // qDebug("Audio F9"); 467 // qDebug("Audio F9");
490 break; 468 break;
491 case Key_F10: //contacts 469 case Key_F10: //contacts
492 break; 470 break;
493 case Key_F11: //menu 471 case Key_F11: //menu
494 mediaPlayerState.toggleBlank(); 472 mediaPlayerState.toggleBlank();
495 break; 473 break;
496 case Key_F12: //home 474 case Key_F12: //home
497 break; 475 break;
498 case Key_F13: //mail 476 case Key_F13: //mail
499 mediaPlayerState.toggleBlank(); 477 mediaPlayerState.toggleBlank();
500 break; 478 break;
501 case Key_Space: { 479 case Key_Space: {
502 if(mediaPlayerState.isPlaying()) { 480 if(mediaPlayerState.isPlaying()) {
503 // toggleButton(1); 481 // toggleButton(1);
504 mediaPlayerState.setPlaying(FALSE); 482 mediaPlayerState.setPlaying(FALSE);
505 // toggleButton(1); 483 // toggleButton(1);
506 } else { 484 } else {
507 // toggleButton(0); 485 // toggleButton(0);
508 mediaPlayerState.setPlaying(TRUE); 486 mediaPlayerState.setPlaying(TRUE);
509 // toggleButton(0); 487 // toggleButton(0);
510 } 488 }
511 } 489 }
512 break; 490 break;
513 case Key_Down: 491 case Key_Down:
514 // toggleButton(6); 492 // toggleButton(6);
515 emit lessClicked(); 493 emit lessClicked();
516 emit lessReleased(); 494 emit lessReleased();
517 // toggleButton(6); 495 // toggleButton(6);
518 break; 496 break;
519 case Key_Up: 497 case Key_Up:
520 // toggleButton(5); 498 // toggleButton(5);
521 emit moreClicked(); 499 emit moreClicked();
522 emit moreReleased(); 500 emit moreReleased();
523 // toggleButton(5); 501 // toggleButton(5);
524 break; 502 break;
525 case Key_Right: 503 case Key_Right:
526 // toggleButton(3); 504 // toggleButton(3);
527 mediaPlayerState.setNext(); 505 mediaPlayerState.setNext();
528 // toggleButton(3); 506 // toggleButton(3);
529 break; 507 break;
530 case Key_Left: 508 case Key_Left:
531 // toggleButton(4); 509 // toggleButton(4);
532 mediaPlayerState.setPrev(); 510 mediaPlayerState.setPrev();
533 // toggleButton(4); 511 // toggleButton(4);
534 break; 512 break;
535 case Key_Escape: { 513 case Key_Escape: {
536 } 514 }
537 break; 515 break;
538 516
539 }; 517 };
540} 518}
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index 9cb75ae..8b0d48c 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -1,73 +1,71 @@
1/* 1/*
2 Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> 2 Copyright (C) 2002 Simon Hausmann <hausmann@kde.org>
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#ifndef MEDIAWIDGET_H 20#ifndef MEDIAWIDGET_H
21#define MEDIAWIDGET_H 21#define MEDIAWIDGET_H
22 22
23#include <qwidget.h> 23#include <qwidget.h>
24 24
25#include "mediaplayerstate.h" 25#include "mediaplayerstate.h"
26#include "playlistwidget.h" 26#include "playlistwidget.h"
27 27
28#include <vector> 28#include <vector>
29 29
30class MediaWidget : public QWidget 30class MediaWidget : public QWidget
31{ 31{
32 Q_OBJECT 32 Q_OBJECT
33public: 33public:
34 enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back }; 34 enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back };
35 35
36 struct Button 36 struct Button
37 { 37 {
38 //Button() : isToggle( false ), isHeld( false ), isDown( false ) {} 38 Button() : isToggle( false ), isHeld( false ), isDown( false ) {}
39// Button( bool toggle, bool held, bool down )
40// : isToggle( toggle ), isHeld( held ), isDown( down ) {}
41 39
42 bool isToggle : 1; 40 bool isToggle : 1;
43 bool isHeld : 1; 41 bool isHeld : 1;
44 bool isDown : 1; 42 bool isDown : 1;
45 }; 43 };
46 typedef std::vector<Button> ButtonVector; 44 typedef std::vector<Button> ButtonVector;
47 45
48 MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); 46 MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 );
49 virtual ~MediaWidget(); 47 virtual ~MediaWidget();
50 48
51public slots: 49public slots:
52 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; 50 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0;
53 virtual void setLength( long length ) = 0; 51 virtual void setLength( long length ) = 0;
54 virtual void setPlaying( bool playing ) = 0; 52 virtual void setPlaying( bool playing ) = 0;
55 53
56signals: 54signals:
57 void moreReleased(); 55 void moreReleased();
58 void lessReleased(); 56 void lessReleased();
59 void forwardReleased(); 57 void forwardReleased();
60 void backReleased(); 58 void backReleased();
61 59
62protected: 60protected:
63 virtual void closeEvent( QCloseEvent * ); 61 virtual void closeEvent( QCloseEvent * );
64 62
65 void handleCommand( Command command, bool buttonDown ); 63 void handleCommand( Command command, bool buttonDown );
66 64
67 MediaPlayerState &mediaPlayerState; 65 MediaPlayerState &mediaPlayerState;
68 PlayListWidget &playList; 66 PlayListWidget &playList;
69}; 67};
70 68
71#endif // MEDIAWIDGET_H 69#endif // MEDIAWIDGET_H
72/* vim: et sw=4 ts=4 70/* vim: et sw=4 ts=4
73 */ 71 */
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index efd756c..6e2e03e 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -1,519 +1,505 @@
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 38
39#include <qwidget.h> 39#include <qwidget.h>
40#include <qpainter.h> 40#include <qpainter.h>
41#include <qpixmap.h> 41#include <qpixmap.h>
42#include <qslider.h> 42#include <qslider.h>
43#include <qdrawutil.h> 43#include <qdrawutil.h>
44#include "videowidget.h" 44#include "videowidget.h"
45#include "mediaplayerstate.h" 45#include "mediaplayerstate.h"
46#include "playlistwidget.h" 46#include "playlistwidget.h"
47 47
48 48
49#ifdef Q_WS_QWS 49#ifdef Q_WS_QWS
50# define USE_DIRECT_PAINTER 50# define USE_DIRECT_PAINTER
51# include <qdirectpainter_qws.h> 51# include <qdirectpainter_qws.h>
52# include <qgfxraster_qws.h> 52# include <qgfxraster_qws.h>
53#endif 53#endif
54 54
55 55
56namespace 56namespace
57{ 57{
58 58
59const int xo = 2; // movable x offset 59const int xo = 2; // movable x offset
60const int yo = 0; // movable y offset 60const int yo = 0; // movable y offset
61 61
62/*
63MediaWidget::Button videoButtons[] = {
64 { FALSE, FALSE, FALSE }, // stop
65 { TRUE, FALSE, FALSE }, // play
66 { FALSE, FALSE, FALSE }, // previous
67 { FALSE, FALSE, FALSE }, // next
68 { FALSE, FALSE, FALSE }, // volUp
69 { FALSE, FALSE, FALSE }, // volDown
70 { TRUE, FALSE, FALSE } // fullscreen
71};
72*/
73
74const char * const skinV_mask_file_names[7] = { 62const char * const skinV_mask_file_names[7] = {
75"stop","play","back","fwd","up","down","full" 63"stop","play","back","fwd","up","down","full"
76}; 64};
77 65
78//const int numVButtons = (sizeof(videoButtons)/sizeof(MediaWidget::Button));
79
80} 66}
81 67
82VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) 68VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name )
83 : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) 69 : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 )
84{ 70{
85 setCaption( tr("OpiePlayer - Video") ); 71 setCaption( tr("OpiePlayer - Video") );
86 72
87 Button defaultButton; 73 Button defaultButton;
88 defaultButton.isToggle = defaultButton.isHeld = defaultButton.isDown = false; 74 defaultButton.isToggle = defaultButton.isHeld = defaultButton.isDown = false;
89 Button toggleButton; 75 Button toggleButton;
90 toggleButton.isToggle = true; 76 toggleButton.isToggle = true;
91 toggleButton.isHeld = toggleButton.isDown = false; 77 toggleButton.isHeld = toggleButton.isDown = false;
92 78
93 videoButtons.reserve( 7 ); 79 videoButtons.reserve( 7 );
94 videoButtons.push_back( defaultButton ); // stop 80 videoButtons.push_back( defaultButton ); // stop
95 videoButtons.push_back( toggleButton ); // play 81 videoButtons.push_back( toggleButton ); // play
96 videoButtons.push_back( defaultButton ); // previous 82 videoButtons.push_back( defaultButton ); // previous
97 videoButtons.push_back( defaultButton ); // next 83 videoButtons.push_back( defaultButton ); // next
98 videoButtons.push_back( defaultButton ); // volUp 84 videoButtons.push_back( defaultButton ); // volUp
99 videoButtons.push_back( defaultButton ); // volDown 85 videoButtons.push_back( defaultButton ); // volDown
100 videoButtons.push_back( toggleButton ); //fullscreen 86 videoButtons.push_back( toggleButton ); //fullscreen
101 87
102 videoFrame = new XineVideoWidget ( this, "Video frame" ); 88 videoFrame = new XineVideoWidget ( this, "Video frame" );
103 89
104 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); 90 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & )));
105 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); 91 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) );
106 92
107 Config cfg("OpiePlayer"); 93 Config cfg("OpiePlayer");
108 cfg.setGroup("Options"); 94 cfg.setGroup("Options");
109 skin = cfg.readEntry("Skin","default"); 95 skin = cfg.readEntry("Skin","default");
110 96
111 QString skinPath = "opieplayer2/skins/" + skin; 97 QString skinPath = "opieplayer2/skins/" + skin;
112 pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 98 pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
113 imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); 99 imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) );
114 imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); 100 imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) );
115 101
116 imgButtonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); 102 imgButtonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 );
117 imgButtonMask.fill( 0 ); 103 imgButtonMask.fill( 0 );
118 104
119 for ( int i = 0; i < 7; i++ ) { 105 for ( int i = 0; i < 7; i++ ) {
120 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" ); 106 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinV_mask_file_names[i] + ".png" );
121 masks[i] = new QBitmap( filename ); 107 masks[i] = new QBitmap( filename );
122 108
123 if ( !masks[i]->isNull() ) { 109 if ( !masks[i]->isNull() ) {
124 QImage imgMask = masks[i]->convertToImage(); 110 QImage imgMask = masks[i]->convertToImage();
125 uchar **dest = imgButtonMask.jumpTable(); 111 uchar **dest = imgButtonMask.jumpTable();
126 for ( int y = 0; y < imgUp.height(); y++ ) { 112 for ( int y = 0; y < imgUp.height(); y++ ) {
127 uchar *line = dest[y]; 113 uchar *line = dest[y];
128 for ( int x = 0; x < imgUp.width(); x++ ) { 114 for ( int x = 0; x < imgUp.width(); x++ ) {
129 if ( !qRed( imgMask.pixel( x, y ) ) ) 115 if ( !qRed( imgMask.pixel( x, y ) ) )
130 line[x] = i + 1; 116 line[x] = i + 1;
131 } 117 }
132 } 118 }
133 } 119 }
134 } 120 }
135 121
136 for ( int i = 0; i < 7; i++ ) { 122 for ( int i = 0; i < 7; i++ ) {
137 buttonPixUp[i] = NULL; 123 buttonPixUp[i] = NULL;
138 buttonPixDown[i] = NULL; 124 buttonPixDown[i] = NULL;
139 } 125 }
140 126
141 setBackgroundPixmap( pixBg ); 127 setBackgroundPixmap( pixBg );
142 128
143 slider = new QSlider( Qt::Horizontal, this ); 129 slider = new QSlider( Qt::Horizontal, this );
144 slider->setMinValue( 0 ); 130 slider->setMinValue( 0 );
145 slider->setMaxValue( 1 ); 131 slider->setMaxValue( 1 );
146 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 132 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
147 //slider->setFocusPolicy( QWidget::NoFocus ); 133 //slider->setFocusPolicy( QWidget::NoFocus );
148 134
149 resizeEvent( NULL ); 135 resizeEvent( NULL );
150 136
151 setLength( mediaPlayerState.length() ); 137 setLength( mediaPlayerState.length() );
152 setPosition( mediaPlayerState.position() ); 138 setPosition( mediaPlayerState.position() );
153 setFullscreen( mediaPlayerState.isFullscreen() ); 139 setFullscreen( mediaPlayerState.isFullscreen() );
154 setPlaying( mediaPlayerState.isPlaying() ); 140 setPlaying( mediaPlayerState.isPlaying() );
155} 141}
156 142
157 143
158VideoWidget::~VideoWidget() { 144VideoWidget::~VideoWidget() {
159 145
160 for ( int i = 0; i < 7; i++ ) { 146 for ( int i = 0; i < 7; i++ ) {
161 delete buttonPixUp[i]; 147 delete buttonPixUp[i];
162 delete buttonPixDown[i]; 148 delete buttonPixDown[i];
163 } 149 }
164 150
165 for ( int i = 0; i < 7; i++ ) { 151 for ( int i = 0; i < 7; i++ ) {
166 delete masks[i]; 152 delete masks[i];
167 } 153 }
168 154
169} 155}
170 156
171QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 157QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
172 QPixmap pix( img.width(), img.height() ); 158 QPixmap pix( img.width(), img.height() );
173 QPainter p( &pix ); 159 QPainter p( &pix );
174 p.drawTiledPixmap( pix.rect(), bg, offset ); 160 p.drawTiledPixmap( pix.rect(), bg, offset );
175 p.drawImage( 0, 0, img ); 161 p.drawImage( 0, 0, img );
176 return new QPixmap( pix ); 162 return new QPixmap( pix );
177} 163}
178 164
179QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) { 165QPixmap *maskVPixToMask( QPixmap pix, QBitmap mask ) {
180 QPixmap *pixmap = new QPixmap( pix ); 166 QPixmap *pixmap = new QPixmap( pix );
181 pixmap->setMask( mask ); 167 pixmap->setMask( mask );
182 return pixmap; 168 return pixmap;
183} 169}
184 170
185void VideoWidget::resizeEvent( QResizeEvent * ) { 171void VideoWidget::resizeEvent( QResizeEvent * ) {
186 int h = height(); 172 int h = height();
187 int w = width(); 173 int w = width();
188 //int Vh = 160; 174 //int Vh = 160;
189 //int Vw = 220; 175 //int Vw = 220;
190 176
191 slider->setFixedWidth( w - 20 ); 177 slider->setFixedWidth( w - 20 );
192 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 178 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
193 slider->setBackgroundOrigin( QWidget::ParentOrigin ); 179 slider->setBackgroundOrigin( QWidget::ParentOrigin );
194 slider->setFocusPolicy( QWidget::NoFocus ); 180 slider->setFocusPolicy( QWidget::NoFocus );
195 slider->setBackgroundPixmap( pixBg ); 181 slider->setBackgroundPixmap( pixBg );
196 182
197 xoff = 0;// ( imgUp->width() ) / 2; 183 xoff = 0;// ( imgUp->width() ) / 2;
198 if(w>h) 184 if(w>h)
199 yoff = 0; 185 yoff = 0;
200 else 186 else
201 yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10; 187 yoff = 185;//(( Vh - imgUp->height() ) / 2) - 10;
202 QPoint p( xoff, yoff ); 188 QPoint p( xoff, yoff );
203 189
204 QPixmap *pixUp = combineVImageWithBackground( imgUp, pixBg, p ); 190 QPixmap *pixUp = combineVImageWithBackground( imgUp, pixBg, p );
205 QPixmap *pixDn = combineVImageWithBackground( imgDn, pixBg, p ); 191 QPixmap *pixDn = combineVImageWithBackground( imgDn, pixBg, p );
206 192
207 for ( int i = 0; i < 7; i++ ) { 193 for ( int i = 0; i < 7; i++ ) {
208 if ( !masks[i]->isNull() ) { 194 if ( !masks[i]->isNull() ) {
209 delete buttonPixUp[i]; 195 delete buttonPixUp[i];
210 delete buttonPixDown[i]; 196 delete buttonPixDown[i];
211 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] ); 197 buttonPixUp[i] = maskVPixToMask( *pixUp, *masks[i] );
212 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] ); 198 buttonPixDown[i] = maskVPixToMask( *pixDn, *masks[i] );
213 } 199 }
214 } 200 }
215 201
216 delete pixUp; 202 delete pixUp;
217 delete pixDn; 203 delete pixDn;
218} 204}
219 205
220static bool videoSliderBeingMoved = FALSE; 206static bool videoSliderBeingMoved = FALSE;
221 207
222void VideoWidget::sliderPressed() { 208void VideoWidget::sliderPressed() {
223 videoSliderBeingMoved = TRUE; 209 videoSliderBeingMoved = TRUE;
224} 210}
225 211
226void VideoWidget::sliderReleased() { 212void VideoWidget::sliderReleased() {
227 videoSliderBeingMoved = FALSE; 213 videoSliderBeingMoved = FALSE;
228 if ( slider->width() == 0 ) { 214 if ( slider->width() == 0 ) {
229 return; 215 return;
230 } 216 }
231 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); 217 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width());
232 mediaPlayerState.setPosition( val ); 218 mediaPlayerState.setPosition( val );
233} 219}
234 220
235void VideoWidget::setPosition( long i ) { 221void VideoWidget::setPosition( long i ) {
236 updateSlider( i, mediaPlayerState.length() ); 222 updateSlider( i, mediaPlayerState.length() );
237} 223}
238 224
239 225
240void VideoWidget::setLength( long max ) { 226void VideoWidget::setLength( long max ) {
241 updateSlider( mediaPlayerState.position(), max ); 227 updateSlider( mediaPlayerState.position(), max );
242} 228}
243 229
244void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) 230void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType )
245{ 231{
246 if ( displayType == MediaPlayerState::Video ) { 232 if ( displayType == MediaPlayerState::Video ) {
247 makeVisible(); 233 makeVisible();
248 return; 234 return;
249 } 235 }
250 236
251 // Effectively blank the view next time we show it so it looks nicer 237 // Effectively blank the view next time we show it so it looks nicer
252 scaledWidth = 0; 238 scaledWidth = 0;
253 scaledHeight = 0; 239 scaledHeight = 0;
254 hide(); 240 hide();
255} 241}
256 242
257void VideoWidget::updateSlider( long i, long max ) { 243void VideoWidget::updateSlider( long i, long max ) {
258 // Will flicker too much if we don't do this 244 // Will flicker too much if we don't do this
259 if ( max == 0 ) { 245 if ( max == 0 ) {
260 return; 246 return;
261 } 247 }
262 int width = slider->width(); 248 int width = slider->width();
263 int val = int((double)i * width / max); 249 int val = int((double)i * width / max);
264 if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { 250 if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) {
265 if ( slider->value() != val ) { 251 if ( slider->value() != val ) {
266 slider->setValue( val ); 252 slider->setValue( val );
267 } 253 }
268 if ( slider->maxValue() != width ) { 254 if ( slider->maxValue() != width ) {
269 slider->setMaxValue( width ); 255 slider->setMaxValue( width );
270 } 256 }
271 } 257 }
272} 258}
273 259
274void VideoWidget::setToggleButton( int i, bool down ) { 260void VideoWidget::setToggleButton( int i, bool down ) {
275 if ( down != videoButtons[i].isDown ) { 261 if ( down != videoButtons[i].isDown ) {
276 toggleButton( i ); 262 toggleButton( i );
277 } 263 }
278} 264}
279 265
280void VideoWidget::toggleButton( int i ) { 266void VideoWidget::toggleButton( int i ) {
281 videoButtons[i].isDown = !videoButtons[i].isDown; 267 videoButtons[i].isDown = !videoButtons[i].isDown;
282 QPainter p(this); 268 QPainter p(this);
283 paintButton ( &p, i ); 269 paintButton ( &p, i );
284} 270}
285 271
286void VideoWidget::paintButton( QPainter *p, int i ) { 272void VideoWidget::paintButton( QPainter *p, int i ) {
287 273
288 if ( videoButtons[i].isDown ) { 274 if ( videoButtons[i].isDown ) {
289 p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); 275 p->drawPixmap( xoff, yoff, *buttonPixDown[i] );
290 } else { 276 } else {
291 p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); 277 p->drawPixmap( xoff, yoff, *buttonPixUp[i] );
292 } 278 }
293} 279}
294 280
295void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 281void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
296 for ( unsigned int i = 0; i < videoButtons.size(); i++ ) { 282 for ( unsigned int i = 0; i < videoButtons.size(); i++ ) {
297 if ( event->state() == QMouseEvent::LeftButton ) { 283 if ( event->state() == QMouseEvent::LeftButton ) {
298 // The test to see if the mouse click is inside the button or not 284 // The test to see if the mouse click is inside the button or not
299 int x = event->pos().x() - xoff; 285 int x = event->pos().x() - xoff;
300 int y = event->pos().y() - yoff; 286 int y = event->pos().y() - yoff;
301 287
302 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask.width() 288 bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask.width()
303 && y < imgButtonMask.height() 289 && y < imgButtonMask.height()
304 && imgButtonMask.pixelIndex( x, y ) == i + 1 ); 290 && imgButtonMask.pixelIndex( x, y ) == i + 1 );
305 291
306 if ( isOnButton && !videoButtons[i].isHeld ) { 292 if ( isOnButton && !videoButtons[i].isHeld ) {
307 videoButtons[i].isHeld = TRUE; 293 videoButtons[i].isHeld = TRUE;
308 toggleButton(i); 294 toggleButton(i);
309 295
310 switch (i) { 296 switch (i) {
311 case VideoVolUp: 297 case VideoVolUp:
312 emit moreClicked(); 298 emit moreClicked();
313 return; 299 return;
314 case VideoVolDown: 300 case VideoVolDown:
315 emit lessClicked(); 301 emit lessClicked();
316 return; 302 return;
317 } 303 }
318 } else if ( !isOnButton && videoButtons[i].isHeld ) { 304 } else if ( !isOnButton && videoButtons[i].isHeld ) {
319 videoButtons[i].isHeld = FALSE; 305 videoButtons[i].isHeld = FALSE;
320 toggleButton(i); 306 toggleButton(i);
321 } 307 }
322 } else { 308 } else {
323 309
324 if ( videoButtons[i].isHeld ) { 310 if ( videoButtons[i].isHeld ) {
325 videoButtons[i].isHeld = FALSE; 311 videoButtons[i].isHeld = FALSE;
326 if ( !videoButtons[i].isToggle ) { 312 if ( !videoButtons[i].isToggle ) {
327 setToggleButton( i, FALSE ); 313 setToggleButton( i, FALSE );
328 } 314 }
329 315
330 switch(i) { 316 switch(i) {
331 317
332 case VideoPlay: { 318 case VideoPlay: {
333 if( mediaPlayerState.isPaused() ) { 319 if( mediaPlayerState.isPaused() ) {
334 setToggleButton( i, FALSE ); 320 setToggleButton( i, FALSE );
335 mediaPlayerState.setPaused( FALSE ); 321 mediaPlayerState.setPaused( FALSE );
336 return; 322 return;
337 } else if( !mediaPlayerState.isPaused() ) { 323 } else if( !mediaPlayerState.isPaused() ) {
338 setToggleButton( i, TRUE ); 324 setToggleButton( i, TRUE );
339 mediaPlayerState.setPaused( TRUE ); 325 mediaPlayerState.setPaused( TRUE );
340 return; 326 return;
341 } else { 327 } else {
342 return; 328 return;
343 } 329 }
344 } 330 }
345 331
346 case VideoStop: mediaPlayerState.setPlaying( FALSE ); return; 332 case VideoStop: mediaPlayerState.setPlaying( FALSE ); return;
347 case VideoNext: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; 333 case VideoNext: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return;
348 case VideoPrevious: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; 334 case VideoPrevious: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return;
349 case VideoVolUp: emit moreReleased(); return; 335 case VideoVolUp: emit moreReleased(); return;
350 case VideoVolDown: emit lessReleased(); return; 336 case VideoVolDown: emit lessReleased(); return;
351 case VideoFullscreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return; 337 case VideoFullscreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return;
352 } 338 }
353 } 339 }
354 } 340 }
355 } 341 }
356} 342}
357 343
358void VideoWidget::mousePressEvent( QMouseEvent *event ) { 344void VideoWidget::mousePressEvent( QMouseEvent *event ) {
359 mouseMoveEvent( event ); 345 mouseMoveEvent( event );
360} 346}
361 347
362void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 348void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
363 if ( mediaPlayerState.isFullscreen() ) { 349 if ( mediaPlayerState.isFullscreen() ) {
364 mediaPlayerState.setFullscreen( FALSE ); 350 mediaPlayerState.setFullscreen( FALSE );
365 makeVisible(); 351 makeVisible();
366 } 352 }
367 mouseMoveEvent( event ); 353 mouseMoveEvent( event );
368} 354}
369 355
370void VideoWidget::showEvent( QShowEvent* ) { 356void VideoWidget::showEvent( QShowEvent* ) {
371 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 357 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
372 mouseMoveEvent( &event ); 358 mouseMoveEvent( &event );
373} 359}
374 360
375 361
376 void VideoWidget::backToNormal() { 362 void VideoWidget::backToNormal() {
377 mediaPlayerState.setFullscreen( FALSE ); 363 mediaPlayerState.setFullscreen( FALSE );
378 makeVisible(); 364 makeVisible();
379 } 365 }
380 366
381void VideoWidget::makeVisible() { 367void VideoWidget::makeVisible() {
382 if ( mediaPlayerState.isFullscreen() ) { 368 if ( mediaPlayerState.isFullscreen() ) {
383 setBackgroundMode( QWidget::NoBackground ); 369 setBackgroundMode( QWidget::NoBackground );
384 showFullScreen(); 370 showFullScreen();
385 resize( qApp->desktop()->size() ); 371 resize( qApp->desktop()->size() );
386 videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); 372 videoFrame-> setGeometry ( 0, 0, width ( ), height ( ));
387 373
388 slider->hide(); 374 slider->hide();
389 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 375 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
390 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 376 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
391 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 377 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
392 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 378 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
393 379
394 } else { 380 } else {
395 showNormal(); 381 showNormal();
396 showMaximized(); 382 showMaximized();
397 setBackgroundPixmap( pixBg ); 383 setBackgroundPixmap( pixBg );
398 QWidget *d = QApplication::desktop(); 384 QWidget *d = QApplication::desktop();
399 int w = d->width(); 385 int w = d->width();
400 int h = d->height(); 386 int h = d->height();
401 387
402 if(w>h) { 388 if(w>h) {
403 int newW=(w/2)-(246/2); //this will only work with 320x240 389 int newW=(w/2)-(246/2); //this will only work with 320x240
404 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); 390 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) );
405 } else { 391 } else {
406 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); 392 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) );
407 } 393 }
408 394
409 if ( !mediaPlayerState.isSeekable() ) { 395 if ( !mediaPlayerState.isSeekable() ) {
410 if( !slider->isHidden()) { 396 if( !slider->isHidden()) {
411 slider->hide(); 397 slider->hide();
412 } 398 }
413 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 399 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
414 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 400 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
415 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 401 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
416 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 402 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
417 } else { 403 } else {
418 slider->show(); 404 slider->show();
419 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 405 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
420 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 406 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
421 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 407 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
422 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 408 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
423 } 409 }
424 } 410 }
425} 411}
426 412
427 413
428 414
429 415
430void VideoWidget::paintEvent( QPaintEvent * pe) { 416void VideoWidget::paintEvent( QPaintEvent * pe) {
431 QPainter p( this ); 417 QPainter p( this );
432 418
433 if ( mediaPlayerState.isFullscreen() ) { 419 if ( mediaPlayerState.isFullscreen() ) {
434 // Clear the background 420 // Clear the background
435 p.setBrush( QBrush( Qt::black ) ); 421 p.setBrush( QBrush( Qt::black ) );
436 } else { 422 } else {
437 if ( !pe->erased() ) { 423 if ( !pe->erased() ) {
438 // Combine with background and double buffer 424 // Combine with background and double buffer
439 QPixmap pix( pe->rect().size() ); 425 QPixmap pix( pe->rect().size() );
440 QPainter p( &pix ); 426 QPainter p( &pix );
441 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 427 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
442 p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); 428 p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() );
443 for ( unsigned int i = 0; i < videoButtons.size(); i++ ) { 429 for ( unsigned int i = 0; i < videoButtons.size(); i++ ) {
444 paintButton( &p, i ); 430 paintButton( &p, i );
445 } 431 }
446 QPainter p2( this ); 432 QPainter p2( this );
447 p2.drawPixmap( pe->rect().topLeft(), pix ); 433 p2.drawPixmap( pe->rect().topLeft(), pix );
448 } else { 434 } else {
449 QPainter p( this ); 435 QPainter p( this );
450 for ( unsigned int i = 0; i < videoButtons.size(); i++ ) 436 for ( unsigned int i = 0; i < videoButtons.size(); i++ )
451 paintButton( &p, i ); 437 paintButton( &p, i );
452 } 438 }
453 //slider->repaint( TRUE ); 439 //slider->repaint( TRUE );
454 } 440 }
455} 441}
456 442
457 443
458void VideoWidget::keyReleaseEvent( QKeyEvent *e) { 444void VideoWidget::keyReleaseEvent( QKeyEvent *e) {
459 switch ( e->key() ) { 445 switch ( e->key() ) {
460////////////////////////////// Zaurus keys 446////////////////////////////// Zaurus keys
461 case Key_Home: 447 case Key_Home:
462 break; 448 break;
463 case Key_F9: //activity 449 case Key_F9: //activity
464 break; 450 break;
465 case Key_F10: //contacts 451 case Key_F10: //contacts
466// hide(); 452// hide();
467 break; 453 break;
468 case Key_F11: //menu 454 case Key_F11: //menu
469 break; 455 break;
470 case Key_F12: //home 456 case Key_F12: //home
471 break; 457 break;
472 case Key_F13: //mail 458 case Key_F13: //mail
473 break; 459 break;
474 case Key_Space: { 460 case Key_Space: {
475 if(mediaPlayerState.isPlaying()) { 461 if(mediaPlayerState.isPlaying()) {
476 mediaPlayerState.setPlaying(FALSE); 462 mediaPlayerState.setPlaying(FALSE);
477 } else { 463 } else {
478 mediaPlayerState.setPlaying(TRUE); 464 mediaPlayerState.setPlaying(TRUE);
479 } 465 }
480 } 466 }
481 break; 467 break;
482 case Key_Down: 468 case Key_Down:
483// toggleButton(6); 469// toggleButton(6);
484 emit lessClicked(); 470 emit lessClicked();
485 emit lessReleased(); 471 emit lessReleased();
486// toggleButton(6); 472// toggleButton(6);
487 break; 473 break;
488 case Key_Up: 474 case Key_Up:
489// toggleButton(5); 475// toggleButton(5);
490 emit moreClicked(); 476 emit moreClicked();
491 emit moreReleased(); 477 emit moreReleased();
492// toggleButton(5); 478// toggleButton(5);
493 break; 479 break;
494 case Key_Right: 480 case Key_Right:
495 mediaPlayerState.setNext(); 481 mediaPlayerState.setNext();
496 break; 482 break;
497 case Key_Left: 483 case Key_Left:
498 mediaPlayerState.setPrev(); 484 mediaPlayerState.setPrev();
499 break; 485 break;
500 case Key_Escape: 486 case Key_Escape:
501 break; 487 break;
502 488
503 }; 489 };
504} 490}
505 491
506XineVideoWidget* VideoWidget::vidWidget() { 492XineVideoWidget* VideoWidget::vidWidget() {
507 return videoFrame; 493 return videoFrame;
508} 494}
509 495
510 496
511void VideoWidget::setFullscreen ( bool b ) { 497void VideoWidget::setFullscreen ( bool b ) {
512 setToggleButton( VideoFullscreen, b ); 498 setToggleButton( VideoFullscreen, b );
513} 499}
514 500
515 501
516void VideoWidget::setPlaying( bool b) { 502void VideoWidget::setPlaying( bool b) {
517 setToggleButton( VideoPlay, b ); 503 setToggleButton( VideoPlay, b );
518} 504}
519 505