summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp6
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp5
2 files changed, 4 insertions, 7 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 3838e2c..37c565b 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -1,448 +1,446 @@
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
59const MediaWidget::SkinButtonInfo skinInfo[] = 59const MediaWidget::SkinButtonInfo skinInfo[] =
60{ 60{
61 { MediaWidget::Play, "play", MediaWidget::ToggleButton }, 61 { MediaWidget::Play, "play", MediaWidget::ToggleButton },
62 { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, 62 { MediaWidget::Stop, "stop", MediaWidget::NormalButton },
63 { MediaWidget::Next, "next", MediaWidget::NormalButton }, 63 { MediaWidget::Next, "next", MediaWidget::NormalButton },
64 { MediaWidget::Previous, "prev", MediaWidget::NormalButton }, 64 { MediaWidget::Previous, "prev", MediaWidget::NormalButton },
65 { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, 65 { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton },
66 { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, 66 { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton },
67 { MediaWidget::Loop, "loop", MediaWidget::ToggleButton }, 67 { MediaWidget::Loop, "loop", MediaWidget::ToggleButton },
68 { MediaWidget::PlayList, "playlist", MediaWidget::NormalButton }, 68 { MediaWidget::PlayList, "playlist", MediaWidget::NormalButton },
69 { MediaWidget::Forward, "forward", MediaWidget::NormalButton }, 69 { MediaWidget::Forward, "forward", MediaWidget::NormalButton },
70 { MediaWidget::Back, "back", MediaWidget::NormalButton } 70 { MediaWidget::Back, "back", MediaWidget::NormalButton }
71}; 71};
72 72
73const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); 73const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] );
74 74
75void changeTextColor( QWidget * w) { 75void changeTextColor( QWidget * w) {
76 QPalette p = w->palette(); 76 QPalette p = w->palette();
77 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); 77 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) );
78 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); 78 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) );
79 w->setPalette( p ); 79 w->setPalette( p );
80} 80}
81 81
82} 82}
83 83
84AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : 84AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) :
85 85
86 MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ), 86 MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ),
87 audioSliderBeingMoved( false ) 87 audioSliderBeingMoved( false )
88{ 88{
89 setCaption( tr("OpiePlayer") ); 89 setCaption( tr("OpiePlayer") );
90 90
91 Config cfg("OpiePlayer"); 91 Config cfg("OpiePlayer");
92 cfg.setGroup("Options"); 92 cfg.setGroup("Options");
93 skin = cfg.readEntry("Skin","default"); 93 skin = cfg.readEntry("Skin","default");
94 //skin = "scaleTest"; 94 //skin = "scaleTest";
95 // color of background, frame, degree of transparency 95 // color of background, frame, degree of transparency
96 96
97 QString skinPath = "opieplayer2/skins/" + skin; 97 QString skinPath = "opieplayer2/skins/" + skin;
98 backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 98 backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
99 imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); 99 imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
100 imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); 100 imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
101 101
102 buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); 102 buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 );
103 buttonMask.fill( 0 ); 103 buttonMask.fill( 0 );
104 104
105 for ( uint i = 0; i < buttonCount; i++ ) { 105 for ( uint i = 0; i < buttonCount; i++ ) {
106 Button button; 106 Button button;
107 button.command = skinInfo[ i ].command; 107 button.command = skinInfo[ i ].command;
108 button.type = skinInfo[ i ].type; 108 button.type = skinInfo[ i ].type;
109 109
110 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skinInfo[i].fileName + ".png" ); 110 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skinInfo[i].fileName + ".png" );
111 button.mask =QBitmap( filename ); 111 button.mask =QBitmap( filename );
112 112
113 if ( !button.mask.isNull() ) { 113 if ( !button.mask.isNull() ) {
114 QImage imgMask = button.mask.convertToImage(); 114 QImage imgMask = button.mask.convertToImage();
115 uchar **dest = buttonMask.jumpTable(); 115 uchar **dest = buttonMask.jumpTable();
116 for ( int y = 0; y < imgUp.height(); y++ ) { 116 for ( int y = 0; y < imgUp.height(); y++ ) {
117 uchar *line = dest[y]; 117 uchar *line = dest[y];
118 for ( int x = 0; x < imgUp.width(); x++ ) 118 for ( int x = 0; x < imgUp.width(); x++ )
119 if ( !qRed( imgMask.pixel( x, y ) ) ) 119 if ( !qRed( imgMask.pixel( x, y ) ) )
120 line[x] = button.command + 1; 120 line[x] = button.command + 1;
121 } 121 }
122 } 122 }
123 123
124 buttons.push_back( button ); 124 buttons.push_back( button );
125 } 125 }
126 126
127 setBackgroundPixmap( backgroundPixmap ); 127 setBackgroundPixmap( backgroundPixmap );
128 128
129 songInfo.setFocusPolicy( QWidget::NoFocus ); 129 songInfo.setFocusPolicy( QWidget::NoFocus );
130// changeTextColor( &songInfo ); 130// changeTextColor( &songInfo );
131// songInfo.setBackgroundColor( QColor( 167, 212, 167 )); 131// songInfo.setBackgroundColor( QColor( 167, 212, 167 ));
132// songInfo.setFrameStyle( QFrame::NoFrame); 132// songInfo.setFrameStyle( QFrame::NoFrame);
133 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); 133 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
134// songInfo.setForegroundColor(Qt::white); 134// songInfo.setForegroundColor(Qt::white);
135 135
136 slider.setFixedHeight( 20 ); 136 slider.setFixedHeight( 20 );
137 slider.setMinValue( 0 ); 137 slider.setMinValue( 0 );
138 slider.setMaxValue( 1 ); 138 slider.setMaxValue( 1 );
139 slider.setFocusPolicy( QWidget::NoFocus ); 139 slider.setFocusPolicy( QWidget::NoFocus );
140 slider.setBackgroundPixmap( backgroundPixmap ); 140 slider.setBackgroundPixmap( backgroundPixmap );
141 141
142// Config cofg("qpe"); 142// Config cofg("qpe");
143// cofg.setGroup("Appearance"); 143// cofg.setGroup("Appearance");
144// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); 144// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) );
145 145
146 time.setFocusPolicy( QWidget::NoFocus ); 146 time.setFocusPolicy( QWidget::NoFocus );
147 time.setAlignment( Qt::AlignCenter ); 147 time.setAlignment( Qt::AlignCenter );
148 148
149// time.setFrame(FALSE); 149// time.setFrame(FALSE);
150// changeTextColor( &time ); 150// changeTextColor( &time );
151 151
152 resizeEvent( NULL ); 152 resizeEvent( NULL );
153 153
154 connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 154 connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
155 connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); 155 connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) );
156 156
157 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); 157 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) );
158 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); 158 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) );
159 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); 159 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) );
160 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); 160 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) );
161 161
162 // Intialise state 162 // Intialise state
163 setLength( mediaPlayerState.length() ); 163 setLength( mediaPlayerState.length() );
164 setPosition( mediaPlayerState.position() ); 164 setPosition( mediaPlayerState.position() );
165 setLooping( mediaPlayerState.isFullscreen() ); 165 setLooping( mediaPlayerState.isFullscreen() );
166 // setPaused( mediaPlayerState->paused() ); 166 // setPaused( mediaPlayerState->paused() );
167 setPlaying( mediaPlayerState.isPlaying() ); 167 setPlaying( mediaPlayerState.isPlaying() );
168 168
169} 169}
170 170
171AudioWidget::~AudioWidget() { 171AudioWidget::~AudioWidget() {
172 172
173// mediaPlayerState->setPlaying(false); 173// mediaPlayerState->setPlaying(false);
174} 174}
175 175
176namespace { 176namespace {
177 177
178QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 178QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
179 QPixmap pix( img.width(), img.height() ); 179 QPixmap pix( img.width(), img.height() );
180 QPainter p( &pix ); 180 QPainter p( &pix );
181 p.drawTiledPixmap( pix.rect(), bg, offset ); 181 p.drawTiledPixmap( pix.rect(), bg, offset );
182 p.drawImage( 0, 0, img ); 182 p.drawImage( 0, 0, img );
183 return pix; 183 return pix;
184} 184}
185 185
186 186
187QPixmap maskPixToMask( QPixmap pix, QBitmap mask ) { 187QPixmap maskPixToMask( QPixmap pix, QBitmap mask ) {
188 QPixmap pixmap( pix ); 188 QPixmap pixmap( pix );
189 pixmap.setMask( mask ); 189 pixmap.setMask( mask );
190 return pixmap; 190 return pixmap;
191} 191}
192 192
193}; 193};
194 194
195void AudioWidget::resizeEvent( QResizeEvent * ) { 195void AudioWidget::resizeEvent( QResizeEvent * ) {
196 int h = height(); 196 int h = height();
197 int w = width(); 197 int w = width();
198 198
199 songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); 199 songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) );
200 slider.setFixedWidth( w - 110 ); 200 slider.setFixedWidth( w - 110 );
201 slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 201 slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
202 slider.setBackgroundOrigin( QWidget::ParentOrigin ); 202 slider.setBackgroundOrigin( QWidget::ParentOrigin );
203 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); 203 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
204 204
205 upperLeftOfButtonMask.rx() = ( w - imgUp.width() ) / 2; 205 upperLeftOfButtonMask.rx() = ( w - imgUp.width() ) / 2;
206 upperLeftOfButtonMask.ry() = (( h - imgUp.height() ) / 2) - 10; 206 upperLeftOfButtonMask.ry() = (( h - imgUp.height() ) / 2) - 10;
207 QPoint p = upperLeftOfButtonMask; 207 QPoint p = upperLeftOfButtonMask;
208 208
209 QPixmap pixUp = combineImageWithBackground( imgUp, backgroundPixmap, p ); 209 QPixmap pixUp = combineImageWithBackground( imgUp, backgroundPixmap, p );
210 QPixmap pixDn = combineImageWithBackground( imgDn, backgroundPixmap, p ); 210 QPixmap pixDn = combineImageWithBackground( imgDn, backgroundPixmap, p );
211 211
212 for ( uint i = 0; i < buttons.size(); i++ ) { 212 for ( uint i = 0; i < buttons.size(); i++ ) {
213 if ( !buttons[i].mask.isNull() ) { 213 if ( !buttons[i].mask.isNull() ) {
214 buttons[i].pixUp = maskPixToMask( pixUp, buttons[i].mask ); 214 buttons[i].pixUp = maskPixToMask( pixUp, buttons[i].mask );
215 buttons[i].pixDown = maskPixToMask( pixDn, buttons[i].mask ); 215 buttons[i].pixDown = maskPixToMask( pixDn, buttons[i].mask );
216 } 216 }
217 } 217 }
218} 218}
219 219
220void AudioWidget::sliderPressed() { 220void AudioWidget::sliderPressed() {
221 audioSliderBeingMoved = TRUE; 221 audioSliderBeingMoved = TRUE;
222} 222}
223 223
224 224
225void AudioWidget::sliderReleased() { 225void AudioWidget::sliderReleased() {
226 audioSliderBeingMoved = FALSE; 226 audioSliderBeingMoved = FALSE;
227 if ( slider.width() == 0 ) 227 if ( slider.width() == 0 )
228 return; 228 return;
229 long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); 229 long val = long((double)slider.value() * mediaPlayerState.length() / slider.width());
230 mediaPlayerState.setPosition( val ); 230 mediaPlayerState.setPosition( val );
231} 231}
232 232
233void AudioWidget::setPosition( long i ) { 233void AudioWidget::setPosition( long i ) {
234 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); 234 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i);
235 updateSlider( i, mediaPlayerState.length() ); 235 updateSlider( i, mediaPlayerState.length() );
236} 236}
237 237
238 238
239void AudioWidget::setLength( long max ) { 239void AudioWidget::setLength( long max ) {
240 updateSlider( mediaPlayerState.position(), max ); 240 updateSlider( mediaPlayerState.position(), max );
241} 241}
242 242
243 243
244void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { 244void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) {
245 if ( mediaType == MediaPlayerState::Audio ) { 245 if ( mediaType == MediaPlayerState::Audio ) {
246 // startTimer( 150 ); 246 // startTimer( 150 );
247 showMaximized(); 247 showMaximized();
248 return; 248 return;
249 } 249 }
250 250
251 killTimers(); 251 killTimers();
252 hide(); 252 hide();
253} 253}
254 254
255 255
256void AudioWidget::setSeekable( bool isSeekable ) { 256void AudioWidget::setSeekable( bool isSeekable ) {
257 257
258 if ( !isSeekable ) { 258 if ( !isSeekable ) {
259 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); 259 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>");
260 if( !slider.isHidden()) { 260 if( !slider.isHidden()) {
261 slider.hide(); 261 slider.hide();
262 } 262 }
263 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 263 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
264 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 264 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
265 disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 265 disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
266 disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 266 disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
267 } else { 267 } else {
268 // this stops the slider from being moved, thus 268 // this stops the slider from being moved, thus
269 // does not stop stream when it reaches the end 269 // does not stop stream when it reaches the end
270 slider.show(); 270 slider.show();
271 qDebug( " CONNECT SET POSTION " ); 271 qDebug( " CONNECT SET POSTION " );
272 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 272 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
273 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 273 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
274 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 274 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
275 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 275 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
276 } 276 }
277} 277}
278 278
279 279
280static QString timeAsString( long length ) { 280static QString timeAsString( long length ) {
281 int minutes = length / 60; 281 int minutes = length / 60;
282 int seconds = length % 60; 282 int seconds = length % 60;
283 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); 283 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 );
284} 284}
285 285
286void AudioWidget::updateSlider( long i, long max ) { 286void AudioWidget::updateSlider( long i, long max ) {
287 287
288 time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); 288 time.setText( timeAsString( i ) + " / " + timeAsString( max ) );
289// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; 289// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ;
290 290
291 if ( max == 0 ) { 291 if ( max == 0 ) {
292 return; 292 return;
293 } 293 }
294 // Will flicker too much if we don't do this 294 // Will flicker too much if we don't do this
295 // Scale to something reasonable 295 // Scale to something reasonable
296 int width = slider.width(); 296 int width = slider.width();
297 int val = int((double)i * width / max); 297 int val = int((double)i * width / max);
298 if ( !audioSliderBeingMoved ) { 298 if ( !audioSliderBeingMoved ) {
299 if ( slider.value() != val ) { 299 if ( slider.value() != val ) {
300 slider.setValue( val ); 300 slider.setValue( val );
301 } 301 }
302 302
303 if ( slider.maxValue() != width ) { 303 if ( slider.maxValue() != width ) {
304 slider.setMaxValue( width ); 304 slider.setMaxValue( width );
305 } 305 }
306 } 306 }
307} 307}
308 308
309void AudioWidget::skipFor() { 309void AudioWidget::skipFor() {
310 skipDirection = +1; 310 skipDirection = +1;
311 startTimer( 50 ); 311 startTimer( 50 );
312 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); 312 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
313} 313}
314 314
315void AudioWidget::skipBack() { 315void AudioWidget::skipBack() {
316 skipDirection = -1; 316 skipDirection = -1;
317 startTimer( 50 ); 317 startTimer( 50 );
318 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); 318 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
319} 319}
320 320
321 321
322 322
323void AudioWidget::stopSkip() { 323void AudioWidget::stopSkip() {
324 killTimers(); 324 killTimers();
325} 325}
326 326
327 327
328void AudioWidget::timerEvent( QTimerEvent * ) { 328void AudioWidget::timerEvent( QTimerEvent * ) {
329 if ( skipDirection == +1 ) { 329 if ( skipDirection == +1 ) {
330 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); 330 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
331 } else if ( skipDirection == -1 ) { 331 } else if ( skipDirection == -1 ) {
332 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); 332 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
333 } 333 }
334} 334}
335 335
336 336
337void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { 337void AudioWidget::mouseMoveEvent( QMouseEvent *event ) {
338 for ( unsigned int i = 0; i < buttons.size(); i++ ) { 338 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) {
339 339 Button &button = *it;
340 Button &button = buttons[ i ];
341 Command command = button.command; 340 Command command = button.command;
342 341
343 if ( event->state() == QMouseEvent::LeftButton ) { 342 if ( event->state() == QMouseEvent::LeftButton ) {
344 // The test to see if the mouse click is inside the button or not 343 // The test to see if the mouse click is inside the button or not
345 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, command ); 344 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, command );
346 345
347 if ( isOnButton && !button.isHeld ) { 346 if ( isOnButton && !button.isHeld ) {
348 button.isHeld = TRUE; 347 button.isHeld = TRUE;
349 toggleButton( button ); 348 toggleButton( button );
350 switch ( command ) { 349 switch ( command ) {
351 case VolumeUp: 350 case VolumeUp:
352 emit moreClicked(); 351 emit moreClicked();
353 return; 352 return;
354 case VolumeDown: 353 case VolumeDown:
355 emit lessClicked(); 354 emit lessClicked();
356 return; 355 return;
357 case Forward: 356 case Forward:
358 emit forwardClicked(); 357 emit forwardClicked();
359 return; 358 return;
360 case Back: 359 case Back:
361 emit backClicked(); 360 emit backClicked();
362 return; 361 return;
363 default: break; 362 default: break;
364 } 363 }
365 } else if ( !isOnButton && button.isHeld ) { 364 } else if ( !isOnButton && button.isHeld ) {
366 button.isHeld = FALSE; 365 button.isHeld = FALSE;
367 toggleButton( button ); 366 toggleButton( button );
368 } 367 }
369 } else { 368 } else {
370 if ( button.isHeld ) { 369 if ( button.isHeld ) {
371 button.isHeld = FALSE; 370 button.isHeld = FALSE;
372 if ( button.type != ToggleButton ) { 371 if ( button.type != ToggleButton ) {
373 setToggleButton( button, FALSE ); 372 setToggleButton( button, FALSE );
374 } 373 }
375 qDebug("mouseEvent %d", i);
376 handleCommand( command, button.isDown ); 374 handleCommand( command, button.isDown );
377 } 375 }
378 } 376 }
379 } 377 }
380} 378}
381 379
382 380
383void AudioWidget::mousePressEvent( QMouseEvent *event ) { 381void AudioWidget::mousePressEvent( QMouseEvent *event ) {
384 mouseMoveEvent( event ); 382 mouseMoveEvent( event );
385} 383}
386 384
387 385
388void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { 386void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) {
389 mouseMoveEvent( event ); 387 mouseMoveEvent( event );
390} 388}
391 389
392 390
393void AudioWidget::showEvent( QShowEvent* ) { 391void AudioWidget::showEvent( QShowEvent* ) {
394 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 392 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
395 mouseMoveEvent( &event ); 393 mouseMoveEvent( &event );
396} 394}
397 395
398void AudioWidget::keyReleaseEvent( QKeyEvent *e) { 396void AudioWidget::keyReleaseEvent( QKeyEvent *e) {
399 switch ( e->key() ) { 397 switch ( e->key() ) {
400 ////////////////////////////// Zaurus keys 398 ////////////////////////////// Zaurus keys
401 case Key_Home: 399 case Key_Home:
402 break; 400 break;
403 case Key_F9: //activity 401 case Key_F9: //activity
404 hide(); 402 hide();
405 // qDebug("Audio F9"); 403 // qDebug("Audio F9");
406 break; 404 break;
407 case Key_F10: //contacts 405 case Key_F10: //contacts
408 break; 406 break;
409 case Key_F11: //menu 407 case Key_F11: //menu
410 mediaPlayerState.toggleBlank(); 408 mediaPlayerState.toggleBlank();
411 break; 409 break;
412 case Key_F12: //home 410 case Key_F12: //home
413 break; 411 break;
414 case Key_F13: //mail 412 case Key_F13: //mail
415 mediaPlayerState.toggleBlank(); 413 mediaPlayerState.toggleBlank();
416 break; 414 break;
417 case Key_Space: { 415 case Key_Space: {
418 mediaPlayerState.togglePaused(); 416 mediaPlayerState.togglePaused();
419 } 417 }
420 break; 418 break;
421 case Key_Down: 419 case Key_Down:
422 // toggleButton(6); 420 // toggleButton(6);
423 emit lessClicked(); 421 emit lessClicked();
424 emit lessReleased(); 422 emit lessReleased();
425 // toggleButton(6); 423 // toggleButton(6);
426 break; 424 break;
427 case Key_Up: 425 case Key_Up:
428 // toggleButton(5); 426 // toggleButton(5);
429 emit moreClicked(); 427 emit moreClicked();
430 emit moreReleased(); 428 emit moreReleased();
431 // toggleButton(5); 429 // toggleButton(5);
432 break; 430 break;
433 case Key_Right: 431 case Key_Right:
434 // toggleButton(3); 432 // toggleButton(3);
435 mediaPlayerState.setNext(); 433 mediaPlayerState.setNext();
436 // toggleButton(3); 434 // toggleButton(3);
437 break; 435 break;
438 case Key_Left: 436 case Key_Left:
439 // toggleButton(4); 437 // toggleButton(4);
440 mediaPlayerState.setPrev(); 438 mediaPlayerState.setPrev();
441 // toggleButton(4); 439 // toggleButton(4);
442 break; 440 break;
443 case Key_Escape: { 441 case Key_Escape: {
444 } 442 }
445 break; 443 break;
446 444
447 }; 445 };
448} 446}
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 06f6cd2..12316f8 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -1,440 +1,439 @@
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
62const MediaWidget::SkinButtonInfo skinInfo[] = 62const MediaWidget::SkinButtonInfo skinInfo[] =
63{ 63{
64 { MediaWidget::Play, "play", MediaWidget::ToggleButton }, 64 { MediaWidget::Play, "play", MediaWidget::ToggleButton },
65 { MediaWidget::Stop, "stop", MediaWidget::NormalButton }, 65 { MediaWidget::Stop, "stop", MediaWidget::NormalButton },
66 { MediaWidget::Next, "fwd", MediaWidget::NormalButton }, 66 { MediaWidget::Next, "fwd", MediaWidget::NormalButton },
67 { MediaWidget::Previous, "back", MediaWidget::NormalButton }, 67 { MediaWidget::Previous, "back", MediaWidget::NormalButton },
68 { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton }, 68 { MediaWidget::VolumeUp, "up", MediaWidget::NormalButton },
69 { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton }, 69 { MediaWidget::VolumeDown, "down", MediaWidget::NormalButton },
70 { MediaWidget::FullScreen, "full", MediaWidget::ToggleButton } 70 { MediaWidget::FullScreen, "full", MediaWidget::ToggleButton }
71}; 71};
72 72
73const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] ); 73const uint buttonCount = sizeof( skinInfo ) / sizeof( skinInfo[ 0 ] );
74 74
75} 75}
76 76
77VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name ) 77VideoWidget::VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name )
78 : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ) 78 : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 )
79{ 79{
80 setCaption( tr("OpiePlayer - Video") ); 80 setCaption( tr("OpiePlayer - Video") );
81 81
82 82
83 videoFrame = new XineVideoWidget ( this, "Video frame" ); 83 videoFrame = new XineVideoWidget ( this, "Video frame" );
84 84
85 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); 85 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & )));
86 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); 86 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) );
87 87
88 Config cfg("OpiePlayer"); 88 Config cfg("OpiePlayer");
89 cfg.setGroup("Options"); 89 cfg.setGroup("Options");
90 skin = cfg.readEntry("Skin","default"); 90 skin = cfg.readEntry("Skin","default");
91 91
92 QString skinPath = "opieplayer2/skins/" + skin; 92 QString skinPath = "opieplayer2/skins/" + skin;
93 backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 93 backgroundPixmap = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
94 imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) ); 94 imgUp = QImage( Resource::loadImage( QString("%1/skinV_up").arg(skinPath) ) );
95 imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) ); 95 imgDn = QImage( Resource::loadImage( QString("%1/skinV_down").arg(skinPath) ) );
96 96
97 buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); 97 buttonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 );
98 buttonMask.fill( 0 ); 98 buttonMask.fill( 0 );
99 99
100 for ( uint i = 0; i < buttonCount; i++ ) { 100 for ( uint i = 0; i < buttonCount; i++ ) {
101 Button button; 101 Button button;
102 button.command = skinInfo[ i ].command; 102 button.command = skinInfo[ i ].command;
103 button.type = skinInfo[ i ].type; 103 button.type = skinInfo[ i ].type;
104 104
105 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinInfo[i].fileName + ".png" ); 105 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinInfo[i].fileName + ".png" );
106 button.mask =QBitmap( filename ); 106 button.mask =QBitmap( filename );
107 107
108 if ( !button.mask.isNull() ) { 108 if ( !button.mask.isNull() ) {
109 QImage imgMask = button.mask.convertToImage(); 109 QImage imgMask = button.mask.convertToImage();
110 uchar **dest = buttonMask.jumpTable(); 110 uchar **dest = buttonMask.jumpTable();
111 for ( int y = 0; y < imgUp.height(); y++ ) { 111 for ( int y = 0; y < imgUp.height(); y++ ) {
112 uchar *line = dest[y]; 112 uchar *line = dest[y];
113 for ( int x = 0; x < imgUp.width(); x++ ) 113 for ( int x = 0; x < imgUp.width(); x++ )
114 if ( !qRed( imgMask.pixel( x, y ) ) ) 114 if ( !qRed( imgMask.pixel( x, y ) ) )
115 line[x] = button.command + 1; 115 line[x] = button.command + 1;
116 } 116 }
117 } 117 }
118 118
119 buttons.push_back( button ); 119 buttons.push_back( button );
120 } 120 }
121 121
122 setBackgroundPixmap( backgroundPixmap ); 122 setBackgroundPixmap( backgroundPixmap );
123 123
124 slider = new QSlider( Qt::Horizontal, this ); 124 slider = new QSlider( Qt::Horizontal, this );
125 slider->setMinValue( 0 ); 125 slider->setMinValue( 0 );
126 slider->setMaxValue( 1 ); 126 slider->setMaxValue( 1 );
127 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 127 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
128 //slider->setFocusPolicy( QWidget::NoFocus ); 128 //slider->setFocusPolicy( QWidget::NoFocus );
129 129
130 resizeEvent( NULL ); 130 resizeEvent( NULL );
131 131
132 setLength( mediaPlayerState.length() ); 132 setLength( mediaPlayerState.length() );
133 setPosition( mediaPlayerState.position() ); 133 setPosition( mediaPlayerState.position() );
134 setFullscreen( mediaPlayerState.isFullscreen() ); 134 setFullscreen( mediaPlayerState.isFullscreen() );
135 setPlaying( mediaPlayerState.isPlaying() ); 135 setPlaying( mediaPlayerState.isPlaying() );
136} 136}
137 137
138 138
139VideoWidget::~VideoWidget() 139VideoWidget::~VideoWidget()
140{ 140{
141} 141}
142 142
143QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 143QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
144 QPixmap pix( img.width(), img.height() ); 144 QPixmap pix( img.width(), img.height() );
145 QPainter p( &pix ); 145 QPainter p( &pix );
146 p.drawTiledPixmap( pix.rect(), bg, offset ); 146 p.drawTiledPixmap( pix.rect(), bg, offset );
147 p.drawImage( 0, 0, img ); 147 p.drawImage( 0, 0, img );
148 return new QPixmap( pix ); 148 return new QPixmap( pix );
149} 149}
150 150
151QPixmap maskVPixToMask( QPixmap pix, QBitmap mask ) { 151QPixmap maskVPixToMask( QPixmap pix, QBitmap mask ) {
152 QPixmap pixmap( pix ); 152 QPixmap pixmap( pix );
153 pixmap.setMask( mask ); 153 pixmap.setMask( mask );
154 return pixmap; 154 return pixmap;
155} 155}
156 156
157void VideoWidget::resizeEvent( QResizeEvent * ) { 157void VideoWidget::resizeEvent( QResizeEvent * ) {
158 int h = height(); 158 int h = height();
159 int w = width(); 159 int w = width();
160 //int Vh = 160; 160 //int Vh = 160;
161 //int Vw = 220; 161 //int Vw = 220;
162 162
163 slider->setFixedWidth( w - 20 ); 163 slider->setFixedWidth( w - 20 );
164 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 164 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
165 slider->setBackgroundOrigin( QWidget::ParentOrigin ); 165 slider->setBackgroundOrigin( QWidget::ParentOrigin );
166 slider->setFocusPolicy( QWidget::NoFocus ); 166 slider->setFocusPolicy( QWidget::NoFocus );
167 slider->setBackgroundPixmap( backgroundPixmap ); 167 slider->setBackgroundPixmap( backgroundPixmap );
168 168
169 upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; 169 upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2;
170 if(w>h) 170 if(w>h)
171 upperLeftOfButtonMask.ry() = 0; 171 upperLeftOfButtonMask.ry() = 0;
172 else 172 else
173 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; 173 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10;
174 QPoint p = upperLeftOfButtonMask; 174 QPoint p = upperLeftOfButtonMask;
175 175
176 QPixmap *pixUp = combineVImageWithBackground( imgUp, backgroundPixmap, p ); 176 QPixmap *pixUp = combineVImageWithBackground( imgUp, backgroundPixmap, p );
177 QPixmap *pixDn = combineVImageWithBackground( imgDn, backgroundPixmap, p ); 177 QPixmap *pixDn = combineVImageWithBackground( imgDn, backgroundPixmap, p );
178 178
179 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) { 179 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) {
180 Button &button = *it; 180 Button &button = *it;
181 181
182 if ( !button.mask.isNull() ) { 182 if ( !button.mask.isNull() ) {
183 button.pixUp = maskVPixToMask( *pixUp, button.mask ); 183 button.pixUp = maskVPixToMask( *pixUp, button.mask );
184 button.pixDown = maskVPixToMask( *pixDn, button.mask ); 184 button.pixDown = maskVPixToMask( *pixDn, button.mask );
185 } 185 }
186 } 186 }
187 187
188 delete pixUp; 188 delete pixUp;
189 delete pixDn; 189 delete pixDn;
190} 190}
191 191
192static bool videoSliderBeingMoved = FALSE; 192static bool videoSliderBeingMoved = FALSE;
193 193
194void VideoWidget::sliderPressed() { 194void VideoWidget::sliderPressed() {
195 videoSliderBeingMoved = TRUE; 195 videoSliderBeingMoved = TRUE;
196} 196}
197 197
198void VideoWidget::sliderReleased() { 198void VideoWidget::sliderReleased() {
199 videoSliderBeingMoved = FALSE; 199 videoSliderBeingMoved = FALSE;
200 if ( slider->width() == 0 ) { 200 if ( slider->width() == 0 ) {
201 return; 201 return;
202 } 202 }
203 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); 203 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width());
204 mediaPlayerState.setPosition( val ); 204 mediaPlayerState.setPosition( val );
205} 205}
206 206
207void VideoWidget::setPosition( long i ) { 207void VideoWidget::setPosition( long i ) {
208 updateSlider( i, mediaPlayerState.length() ); 208 updateSlider( i, mediaPlayerState.length() );
209} 209}
210 210
211 211
212void VideoWidget::setLength( long max ) { 212void VideoWidget::setLength( long max ) {
213 updateSlider( mediaPlayerState.position(), max ); 213 updateSlider( mediaPlayerState.position(), max );
214} 214}
215 215
216void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) 216void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType )
217{ 217{
218 if ( displayType == MediaPlayerState::Video ) { 218 if ( displayType == MediaPlayerState::Video ) {
219 makeVisible(); 219 makeVisible();
220 return; 220 return;
221 } 221 }
222 222
223 // Effectively blank the view next time we show it so it looks nicer 223 // Effectively blank the view next time we show it so it looks nicer
224 scaledWidth = 0; 224 scaledWidth = 0;
225 scaledHeight = 0; 225 scaledHeight = 0;
226 hide(); 226 hide();
227} 227}
228 228
229void VideoWidget::updateSlider( long i, long max ) { 229void VideoWidget::updateSlider( long i, long max ) {
230 // Will flicker too much if we don't do this 230 // Will flicker too much if we don't do this
231 if ( max == 0 ) { 231 if ( max == 0 ) {
232 return; 232 return;
233 } 233 }
234 int width = slider->width(); 234 int width = slider->width();
235 int val = int((double)i * width / max); 235 int val = int((double)i * width / max);
236 if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { 236 if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) {
237 if ( slider->value() != val ) { 237 if ( slider->value() != val ) {
238 slider->setValue( val ); 238 slider->setValue( val );
239 } 239 }
240 if ( slider->maxValue() != width ) { 240 if ( slider->maxValue() != width ) {
241 slider->setMaxValue( width ); 241 slider->setMaxValue( width );
242 } 242 }
243 } 243 }
244} 244}
245 245
246void VideoWidget::mouseMoveEvent( QMouseEvent *event ) { 246void VideoWidget::mouseMoveEvent( QMouseEvent *event ) {
247 for ( unsigned int i = 0; i < buttons.size(); i++ ) { 247 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) {
248 248 Button &button = *it;
249 Button &button = buttons[ i ];
250 Command command = button.command; 249 Command command = button.command;
251 250
252 if ( event->state() == QMouseEvent::LeftButton ) { 251 if ( event->state() == QMouseEvent::LeftButton ) {
253 // The test to see if the mouse click is inside the button or not 252 // The test to see if the mouse click is inside the button or not
254 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, command ); 253 bool isOnButton = isOverButton( event->pos() - upperLeftOfButtonMask, command );
255 254
256 if ( isOnButton && !button.isHeld ) { 255 if ( isOnButton && !button.isHeld ) {
257 button.isHeld = TRUE; 256 button.isHeld = TRUE;
258 toggleButton( button ); 257 toggleButton( button );
259 258
260 switch ( command ) { 259 switch ( command ) {
261 case VolumeUp: 260 case VolumeUp:
262 emit moreClicked(); 261 emit moreClicked();
263 return; 262 return;
264 case VolumeDown: 263 case VolumeDown:
265 emit lessClicked(); 264 emit lessClicked();
266 return; 265 return;
267 default: break; 266 default: break;
268 } 267 }
269 } else if ( !isOnButton && button.isHeld ) { 268 } else if ( !isOnButton && button.isHeld ) {
270 button.isHeld = FALSE; 269 button.isHeld = FALSE;
271 toggleButton( button ); 270 toggleButton( button );
272 } 271 }
273 } else { 272 } else {
274 273
275 if ( button.isHeld ) { 274 if ( button.isHeld ) {
276 button.isHeld = FALSE; 275 button.isHeld = FALSE;
277 if ( button.type != ToggleButton ) { 276 if ( button.type != ToggleButton ) {
278 setToggleButton( button, FALSE ); 277 setToggleButton( button, FALSE );
279 } 278 }
280 279
281 switch( command ) { 280 switch( command ) {
282 281
283 case Play: { 282 case Play: {
284 if( mediaPlayerState.isPaused() ) { 283 if( mediaPlayerState.isPaused() ) {
285 setToggleButton( button, FALSE ); 284 setToggleButton( button, FALSE );
286 mediaPlayerState.setPaused( FALSE ); 285 mediaPlayerState.setPaused( FALSE );
287 return; 286 return;
288 } else if( !mediaPlayerState.isPaused() ) { 287 } else if( !mediaPlayerState.isPaused() ) {
289 setToggleButton( button, TRUE ); 288 setToggleButton( button, TRUE );
290 mediaPlayerState.setPaused( TRUE ); 289 mediaPlayerState.setPaused( TRUE );
291 return; 290 return;
292 } else { 291 } else {
293 return; 292 return;
294 } 293 }
295 } 294 }
296 295
297 case Stop: mediaPlayerState.setPlaying( FALSE ); return; 296 case Stop: mediaPlayerState.setPlaying( FALSE ); return;
298 case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; 297 case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return;
299 case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; 298 case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return;
300 case VolumeUp: emit moreReleased(); return; 299 case VolumeUp: emit moreReleased(); return;
301 case VolumeDown: emit lessReleased(); return; 300 case VolumeDown: emit lessReleased(); return;
302 case FullScreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return; 301 case FullScreen: mediaPlayerState.setFullscreen( TRUE ); makeVisible(); return;
303 default: break; 302 default: break;
304 } 303 }
305 } 304 }
306 } 305 }
307 } 306 }
308} 307}
309 308
310void VideoWidget::mousePressEvent( QMouseEvent *event ) { 309void VideoWidget::mousePressEvent( QMouseEvent *event ) {
311 mouseMoveEvent( event ); 310 mouseMoveEvent( event );
312} 311}
313 312
314void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 313void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
315 if ( mediaPlayerState.isFullscreen() ) { 314 if ( mediaPlayerState.isFullscreen() ) {
316 mediaPlayerState.setFullscreen( FALSE ); 315 mediaPlayerState.setFullscreen( FALSE );
317 makeVisible(); 316 makeVisible();
318 } 317 }
319 mouseMoveEvent( event ); 318 mouseMoveEvent( event );
320} 319}
321 320
322void VideoWidget::showEvent( QShowEvent* ) { 321void VideoWidget::showEvent( QShowEvent* ) {
323 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); 322 QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 );
324 mouseMoveEvent( &event ); 323 mouseMoveEvent( &event );
325} 324}
326 325
327 326
328 void VideoWidget::backToNormal() { 327 void VideoWidget::backToNormal() {
329 mediaPlayerState.setFullscreen( FALSE ); 328 mediaPlayerState.setFullscreen( FALSE );
330 makeVisible(); 329 makeVisible();
331 } 330 }
332 331
333void VideoWidget::makeVisible() { 332void VideoWidget::makeVisible() {
334 if ( mediaPlayerState.isFullscreen() ) { 333 if ( mediaPlayerState.isFullscreen() ) {
335 setBackgroundMode( QWidget::NoBackground ); 334 setBackgroundMode( QWidget::NoBackground );
336 showFullScreen(); 335 showFullScreen();
337 resize( qApp->desktop()->size() ); 336 resize( qApp->desktop()->size() );
338 videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); 337 videoFrame-> setGeometry ( 0, 0, width ( ), height ( ));
339 338
340 slider->hide(); 339 slider->hide();
341 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 340 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
342 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 341 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
343 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 342 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
344 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 343 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
345 344
346 } else { 345 } else {
347 showNormal(); 346 showNormal();
348 showMaximized(); 347 showMaximized();
349 setBackgroundPixmap( backgroundPixmap ); 348 setBackgroundPixmap( backgroundPixmap );
350 QWidget *d = QApplication::desktop(); 349 QWidget *d = QApplication::desktop();
351 int w = d->width(); 350 int w = d->width();
352 int h = d->height(); 351 int h = d->height();
353 352
354 if(w>h) { 353 if(w>h) {
355 int newW=(w/2)-(246/2); //this will only work with 320x240 354 int newW=(w/2)-(246/2); //this will only work with 320x240
356 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); 355 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) );
357 } else { 356 } else {
358 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); 357 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) );
359 } 358 }
360 359
361 if ( !mediaPlayerState.isSeekable() ) { 360 if ( !mediaPlayerState.isSeekable() ) {
362 if( !slider->isHidden()) { 361 if( !slider->isHidden()) {
363 slider->hide(); 362 slider->hide();
364 } 363 }
365 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 364 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
366 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 365 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
367 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 366 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
368 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 367 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
369 } else { 368 } else {
370 slider->show(); 369 slider->show();
371 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 370 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
372 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 371 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
373 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 372 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
374 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 373 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
375 } 374 }
376 } 375 }
377} 376}
378 377
379void VideoWidget::keyReleaseEvent( QKeyEvent *e) { 378void VideoWidget::keyReleaseEvent( QKeyEvent *e) {
380 switch ( e->key() ) { 379 switch ( e->key() ) {
381////////////////////////////// Zaurus keys 380////////////////////////////// Zaurus keys
382 case Key_Home: 381 case Key_Home:
383 break; 382 break;
384 case Key_F9: //activity 383 case Key_F9: //activity
385 break; 384 break;
386 case Key_F10: //contacts 385 case Key_F10: //contacts
387// hide(); 386// hide();
388 break; 387 break;
389 case Key_F11: //menu 388 case Key_F11: //menu
390 break; 389 break;
391 case Key_F12: //home 390 case Key_F12: //home
392 break; 391 break;
393 case Key_F13: //mail 392 case Key_F13: //mail
394 break; 393 break;
395 case Key_Space: { 394 case Key_Space: {
396 if(mediaPlayerState.isPlaying()) { 395 if(mediaPlayerState.isPlaying()) {
397 mediaPlayerState.setPlaying(FALSE); 396 mediaPlayerState.setPlaying(FALSE);
398 } else { 397 } else {
399 mediaPlayerState.setPlaying(TRUE); 398 mediaPlayerState.setPlaying(TRUE);
400 } 399 }
401 } 400 }
402 break; 401 break;
403 case Key_Down: 402 case Key_Down:
404// toggleButton(6); 403// toggleButton(6);
405 emit lessClicked(); 404 emit lessClicked();
406 emit lessReleased(); 405 emit lessReleased();
407// toggleButton(6); 406// toggleButton(6);
408 break; 407 break;
409 case Key_Up: 408 case Key_Up:
410// toggleButton(5); 409// toggleButton(5);
411 emit moreClicked(); 410 emit moreClicked();
412 emit moreReleased(); 411 emit moreReleased();
413// toggleButton(5); 412// toggleButton(5);
414 break; 413 break;
415 case Key_Right: 414 case Key_Right:
416 mediaPlayerState.setNext(); 415 mediaPlayerState.setNext();
417 break; 416 break;
418 case Key_Left: 417 case Key_Left:
419 mediaPlayerState.setPrev(); 418 mediaPlayerState.setPrev();
420 break; 419 break;
421 case Key_Escape: 420 case Key_Escape:
422 break; 421 break;
423 422
424 }; 423 };
425} 424}
426 425
427XineVideoWidget* VideoWidget::vidWidget() { 426XineVideoWidget* VideoWidget::vidWidget() {
428 return videoFrame; 427 return videoFrame;
429} 428}
430 429
431 430
432void VideoWidget::setFullscreen ( bool b ) { 431void VideoWidget::setFullscreen ( bool b ) {
433 setToggleButton( FullScreen, b ); 432 setToggleButton( FullScreen, b );
434} 433}
435 434
436 435
437void VideoWidget::setPlaying( bool b) { 436void VideoWidget::setPlaying( bool b) {
438 setToggleButton( Play, b ); 437 setToggleButton( Play, b );
439} 438}
440 439