summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp25
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp43
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h5
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp25
4 files changed, 50 insertions, 48 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 23d12ec..fd18dbb 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -1,394 +1,371 @@
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 setupButtons( skinInfo, buttonCount, QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_", imgUp.size() );
103 buttonMask.fill( 0 );
104
105 for ( uint i = 0; i < buttonCount; i++ ) {
106 Button button;
107 button.command = skinInfo[ i ].command;
108 button.type = skinInfo[ i ].type;
109
110 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skinInfo[i].fileName + ".png" );
111 button.mask =QBitmap( filename );
112
113 if ( !button.mask.isNull() ) {
114 QImage imgMask = button.mask.convertToImage();
115 uchar **dest = buttonMask.jumpTable();
116 for ( int y = 0; y < imgUp.height(); y++ ) {
117 uchar *line = dest[y];
118 for ( int x = 0; x < imgUp.width(); x++ )
119 if ( !qRed( imgMask.pixel( x, y ) ) )
120 line[x] = button.command + 1;
121 }
122 }
123
124 buttons.push_back( button );
125 }
126 103
127 setBackgroundPixmap( backgroundPixmap ); 104 setBackgroundPixmap( backgroundPixmap );
128 105
129 songInfo.setFocusPolicy( QWidget::NoFocus ); 106 songInfo.setFocusPolicy( QWidget::NoFocus );
130// changeTextColor( &songInfo ); 107// changeTextColor( &songInfo );
131// songInfo.setBackgroundColor( QColor( 167, 212, 167 )); 108// songInfo.setBackgroundColor( QColor( 167, 212, 167 ));
132// songInfo.setFrameStyle( QFrame::NoFrame); 109// songInfo.setFrameStyle( QFrame::NoFrame);
133 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); 110 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
134// songInfo.setForegroundColor(Qt::white); 111// songInfo.setForegroundColor(Qt::white);
135 112
136 slider.setFixedHeight( 20 ); 113 slider.setFixedHeight( 20 );
137 slider.setMinValue( 0 ); 114 slider.setMinValue( 0 );
138 slider.setMaxValue( 1 ); 115 slider.setMaxValue( 1 );
139 slider.setFocusPolicy( QWidget::NoFocus ); 116 slider.setFocusPolicy( QWidget::NoFocus );
140 slider.setBackgroundPixmap( backgroundPixmap ); 117 slider.setBackgroundPixmap( backgroundPixmap );
141 118
142// Config cofg("qpe"); 119// Config cofg("qpe");
143// cofg.setGroup("Appearance"); 120// cofg.setGroup("Appearance");
144// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); 121// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) );
145 122
146 time.setFocusPolicy( QWidget::NoFocus ); 123 time.setFocusPolicy( QWidget::NoFocus );
147 time.setAlignment( Qt::AlignCenter ); 124 time.setAlignment( Qt::AlignCenter );
148 125
149// time.setFrame(FALSE); 126// time.setFrame(FALSE);
150// changeTextColor( &time ); 127// changeTextColor( &time );
151 128
152 resizeEvent( NULL ); 129 resizeEvent( NULL );
153 130
154 connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 131 connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
155 connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); 132 connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) );
156 133
157 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); 134 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) );
158 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); 135 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) );
159 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); 136 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) );
160 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); 137 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) );
161 138
162 // Intialise state 139 // Intialise state
163 setLength( mediaPlayerState.length() ); 140 setLength( mediaPlayerState.length() );
164 setPosition( mediaPlayerState.position() ); 141 setPosition( mediaPlayerState.position() );
165 setLooping( mediaPlayerState.isFullscreen() ); 142 setLooping( mediaPlayerState.isFullscreen() );
166 // setPaused( mediaPlayerState->paused() ); 143 // setPaused( mediaPlayerState->paused() );
167 setPlaying( mediaPlayerState.isPlaying() ); 144 setPlaying( mediaPlayerState.isPlaying() );
168 145
169} 146}
170 147
171AudioWidget::~AudioWidget() { 148AudioWidget::~AudioWidget() {
172 149
173// mediaPlayerState->setPlaying(false); 150// mediaPlayerState->setPlaying(false);
174} 151}
175 152
176namespace { 153namespace {
177 154
178QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 155QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
179 QPixmap pix( img.width(), img.height() ); 156 QPixmap pix( img.width(), img.height() );
180 QPainter p( &pix ); 157 QPainter p( &pix );
181 p.drawTiledPixmap( pix.rect(), bg, offset ); 158 p.drawTiledPixmap( pix.rect(), bg, offset );
182 p.drawImage( 0, 0, img ); 159 p.drawImage( 0, 0, img );
183 return pix; 160 return pix;
184} 161}
185 162
186 163
187QPixmap maskPixToMask( QPixmap pix, QBitmap mask ) { 164QPixmap maskPixToMask( QPixmap pix, QBitmap mask ) {
188 QPixmap pixmap( pix ); 165 QPixmap pixmap( pix );
189 pixmap.setMask( mask ); 166 pixmap.setMask( mask );
190 return pixmap; 167 return pixmap;
191} 168}
192 169
193}; 170};
194 171
195void AudioWidget::resizeEvent( QResizeEvent * ) { 172void AudioWidget::resizeEvent( QResizeEvent * ) {
196 int h = height(); 173 int h = height();
197 int w = width(); 174 int w = width();
198 175
199 songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); 176 songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) );
200 slider.setFixedWidth( w - 110 ); 177 slider.setFixedWidth( w - 110 );
201 slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 178 slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
202 slider.setBackgroundOrigin( QWidget::ParentOrigin ); 179 slider.setBackgroundOrigin( QWidget::ParentOrigin );
203 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); 180 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
204 181
205 upperLeftOfButtonMask.rx() = ( w - imgUp.width() ) / 2; 182 upperLeftOfButtonMask.rx() = ( w - imgUp.width() ) / 2;
206 upperLeftOfButtonMask.ry() = (( h - imgUp.height() ) / 2) - 10; 183 upperLeftOfButtonMask.ry() = (( h - imgUp.height() ) / 2) - 10;
207 QPoint p = upperLeftOfButtonMask; 184 QPoint p = upperLeftOfButtonMask;
208 185
209 QPixmap pixUp = combineImageWithBackground( imgUp, backgroundPixmap, p ); 186 QPixmap pixUp = combineImageWithBackground( imgUp, backgroundPixmap, p );
210 QPixmap pixDn = combineImageWithBackground( imgDn, backgroundPixmap, p ); 187 QPixmap pixDn = combineImageWithBackground( imgDn, backgroundPixmap, p );
211 188
212 for ( uint i = 0; i < buttons.size(); i++ ) { 189 for ( uint i = 0; i < buttons.size(); i++ ) {
213 if ( !buttons[i].mask.isNull() ) { 190 if ( !buttons[i].mask.isNull() ) {
214 buttons[i].pixUp = maskPixToMask( pixUp, buttons[i].mask ); 191 buttons[i].pixUp = maskPixToMask( pixUp, buttons[i].mask );
215 buttons[i].pixDown = maskPixToMask( pixDn, buttons[i].mask ); 192 buttons[i].pixDown = maskPixToMask( pixDn, buttons[i].mask );
216 } 193 }
217 } 194 }
218} 195}
219 196
220void AudioWidget::sliderPressed() { 197void AudioWidget::sliderPressed() {
221 audioSliderBeingMoved = TRUE; 198 audioSliderBeingMoved = TRUE;
222} 199}
223 200
224 201
225void AudioWidget::sliderReleased() { 202void AudioWidget::sliderReleased() {
226 audioSliderBeingMoved = FALSE; 203 audioSliderBeingMoved = FALSE;
227 if ( slider.width() == 0 ) 204 if ( slider.width() == 0 )
228 return; 205 return;
229 long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); 206 long val = long((double)slider.value() * mediaPlayerState.length() / slider.width());
230 mediaPlayerState.setPosition( val ); 207 mediaPlayerState.setPosition( val );
231} 208}
232 209
233void AudioWidget::setPosition( long i ) { 210void AudioWidget::setPosition( long i ) {
234 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); 211 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i);
235 updateSlider( i, mediaPlayerState.length() ); 212 updateSlider( i, mediaPlayerState.length() );
236} 213}
237 214
238 215
239void AudioWidget::setLength( long max ) { 216void AudioWidget::setLength( long max ) {
240 updateSlider( mediaPlayerState.position(), max ); 217 updateSlider( mediaPlayerState.position(), max );
241} 218}
242 219
243 220
244void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { 221void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) {
245 if ( mediaType == MediaPlayerState::Audio ) { 222 if ( mediaType == MediaPlayerState::Audio ) {
246 // startTimer( 150 ); 223 // startTimer( 150 );
247 showMaximized(); 224 showMaximized();
248 return; 225 return;
249 } 226 }
250 227
251 killTimers(); 228 killTimers();
252 hide(); 229 hide();
253} 230}
254 231
255 232
256void AudioWidget::setSeekable( bool isSeekable ) { 233void AudioWidget::setSeekable( bool isSeekable ) {
257 234
258 if ( !isSeekable ) { 235 if ( !isSeekable ) {
259 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); 236 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>");
260 if( !slider.isHidden()) { 237 if( !slider.isHidden()) {
261 slider.hide(); 238 slider.hide();
262 } 239 }
263 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 240 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
264 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 241 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
265 disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 242 disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
266 disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 243 disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
267 } else { 244 } else {
268 // this stops the slider from being moved, thus 245 // this stops the slider from being moved, thus
269 // does not stop stream when it reaches the end 246 // does not stop stream when it reaches the end
270 slider.show(); 247 slider.show();
271 qDebug( " CONNECT SET POSTION " ); 248 qDebug( " CONNECT SET POSTION " );
272 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 249 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
273 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 250 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
274 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 251 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
275 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 252 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
276 } 253 }
277} 254}
278 255
279 256
280static QString timeAsString( long length ) { 257static QString timeAsString( long length ) {
281 int minutes = length / 60; 258 int minutes = length / 60;
282 int seconds = length % 60; 259 int seconds = length % 60;
283 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); 260 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 );
284} 261}
285 262
286void AudioWidget::updateSlider( long i, long max ) { 263void AudioWidget::updateSlider( long i, long max ) {
287 264
288 time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); 265 time.setText( timeAsString( i ) + " / " + timeAsString( max ) );
289// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; 266// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ;
290 267
291 if ( max == 0 ) { 268 if ( max == 0 ) {
292 return; 269 return;
293 } 270 }
294 // Will flicker too much if we don't do this 271 // Will flicker too much if we don't do this
295 // Scale to something reasonable 272 // Scale to something reasonable
296 int width = slider.width(); 273 int width = slider.width();
297 int val = int((double)i * width / max); 274 int val = int((double)i * width / max);
298 if ( !audioSliderBeingMoved ) { 275 if ( !audioSliderBeingMoved ) {
299 if ( slider.value() != val ) { 276 if ( slider.value() != val ) {
300 slider.setValue( val ); 277 slider.setValue( val );
301 } 278 }
302 279
303 if ( slider.maxValue() != width ) { 280 if ( slider.maxValue() != width ) {
304 slider.setMaxValue( width ); 281 slider.setMaxValue( width );
305 } 282 }
306 } 283 }
307} 284}
308 285
309void AudioWidget::skipFor() { 286void AudioWidget::skipFor() {
310 skipDirection = +1; 287 skipDirection = +1;
311 startTimer( 50 ); 288 startTimer( 50 );
312 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); 289 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
313} 290}
314 291
315void AudioWidget::skipBack() { 292void AudioWidget::skipBack() {
316 skipDirection = -1; 293 skipDirection = -1;
317 startTimer( 50 ); 294 startTimer( 50 );
318 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); 295 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
319} 296}
320 297
321 298
322 299
323void AudioWidget::stopSkip() { 300void AudioWidget::stopSkip() {
324 killTimers(); 301 killTimers();
325} 302}
326 303
327 304
328void AudioWidget::timerEvent( QTimerEvent * ) { 305void AudioWidget::timerEvent( QTimerEvent * ) {
329 if ( skipDirection == +1 ) { 306 if ( skipDirection == +1 ) {
330 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); 307 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
331 } else if ( skipDirection == -1 ) { 308 } else if ( skipDirection == -1 ) {
332 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); 309 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
333 } 310 }
334} 311}
335 312
336void AudioWidget::keyReleaseEvent( QKeyEvent *e) { 313void AudioWidget::keyReleaseEvent( QKeyEvent *e) {
337 switch ( e->key() ) { 314 switch ( e->key() ) {
338 ////////////////////////////// Zaurus keys 315 ////////////////////////////// Zaurus keys
339 case Key_Home: 316 case Key_Home:
340 break; 317 break;
341 case Key_F9: //activity 318 case Key_F9: //activity
342 hide(); 319 hide();
343 // qDebug("Audio F9"); 320 // qDebug("Audio F9");
344 e->accept(); 321 e->accept();
345 break; 322 break;
346 case Key_F10: //contacts 323 case Key_F10: //contacts
347 break; 324 break;
348 case Key_F11: //menu 325 case Key_F11: //menu
349 mediaPlayerState.toggleBlank(); 326 mediaPlayerState.toggleBlank();
350 e->accept(); 327 e->accept();
351 break; 328 break;
352 case Key_F12: //home 329 case Key_F12: //home
353 break; 330 break;
354 case Key_F13: //mail 331 case Key_F13: //mail
355 mediaPlayerState.toggleBlank(); 332 mediaPlayerState.toggleBlank();
356 e->accept(); 333 e->accept();
357 break; 334 break;
358 case Key_Space: { 335 case Key_Space: {
359 e->accept(); 336 e->accept();
360 mediaPlayerState.togglePaused(); 337 mediaPlayerState.togglePaused();
361 } 338 }
362 break; 339 break;
363 case Key_Down: 340 case Key_Down:
364 // toggleButton(6); 341 // toggleButton(6);
365 emit lessClicked(); 342 emit lessClicked();
366 emit lessReleased(); 343 emit lessReleased();
367 // toggleButton(6); 344 // toggleButton(6);
368 e->accept(); 345 e->accept();
369 break; 346 break;
370 case Key_Up: 347 case Key_Up:
371 // toggleButton(5); 348 // toggleButton(5);
372 emit moreClicked(); 349 emit moreClicked();
373 emit moreReleased(); 350 emit moreReleased();
374 // toggleButton(5); 351 // toggleButton(5);
375 e->accept(); 352 e->accept();
376 break; 353 break;
377 case Key_Right: 354 case Key_Right:
378 // toggleButton(3); 355 // toggleButton(3);
379 mediaPlayerState.setNext(); 356 mediaPlayerState.setNext();
380 // toggleButton(3); 357 // toggleButton(3);
381 e->accept(); 358 e->accept();
382 break; 359 break;
383 case Key_Left: 360 case Key_Left:
384 // toggleButton(4); 361 // toggleButton(4);
385 mediaPlayerState.setPrev(); 362 mediaPlayerState.setPrev();
386 // toggleButton(4); 363 // toggleButton(4);
387 e->accept(); 364 e->accept();
388 break; 365 break;
389 case Key_Escape: { 366 case Key_Escape: {
390 } 367 }
391 break; 368 break;
392 369
393 }; 370 };
394} 371}
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index 4c4cead..db16b44 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -1,194 +1,237 @@
1/* 1/*
2 Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> 2 Copyright (C) 2002 Simon Hausmann <hausmann@kde.org>
3 (C) 2002 Max Reiss <harlekin@handhelds.org> 3 (C) 2002 Max Reiss <harlekin@handhelds.org>
4 (C) 2002 L. Potter <ljp@llornkcor.com> 4 (C) 2002 L. Potter <ljp@llornkcor.com>
5 (C) 2002 Holger Freyther <zecke@handhelds.org> 5 (C) 2002 Holger Freyther <zecke@handhelds.org>
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23 23
24#include "mediawidget.h" 24#include "mediawidget.h"
25#include "playlistwidget.h" 25#include "playlistwidget.h"
26 26
27MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name ) 27MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name )
28 : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) 28 : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList )
29{ 29{
30 connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ), 30 connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ),
31 this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) ); 31 this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) );
32 connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ), 32 connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ),
33 this, SLOT( setLength( long ) ) ); 33 this, SLOT( setLength( long ) ) );
34 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), 34 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ),
35 this, SLOT( setPlaying( bool ) ) ); 35 this, SLOT( setPlaying( bool ) ) );
36} 36}
37 37
38MediaWidget::~MediaWidget() 38MediaWidget::~MediaWidget()
39{ 39{
40} 40}
41 41
42void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount,
43 const QString &imagePrefix, const QSize &buttonAreaSize )
44{
45 buttonMask = QImage( buttonAreaSize, 8, 255 );
46 buttonMask.fill( 0 );
47
48 for ( uint i = 0; i < buttonCount; ++i ) {
49 Button button = setupButton( skinInfo[ i ], imagePrefix );
50 buttons.push_back( button );
51 }
52}
53
54MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const QString &imagePrefix )
55{
56 Button button;
57 button.command = buttonInfo.command;
58 button.type = buttonInfo.type;
59
60 QString fileName = imagePrefix + buttonInfo.fileName + ".png";
61
62 button.mask = setupButtonMask( button.command, fileName );
63
64 return button;
65}
66
67QBitmap MediaWidget::setupButtonMask( const Command &command, const QString &fileName )
68{
69 QBitmap mask( fileName );
70 if ( mask.isNull() )
71 return mask;
72
73 QImage imgMask = mask.convertToImage();
74 uchar **dest = buttonMask.jumpTable();
75 for ( int y = 0; y < buttonMask.height(); y++ ) {
76 uchar *line = dest[y];
77 for ( int x = 0; x < buttonMask.width(); x++ )
78 if ( !qRed( imgMask.pixel( x, y ) ) )
79 line[x] = command + 1;
80 }
81
82 return mask;
83}
84
42void MediaWidget::closeEvent( QCloseEvent * ) 85void MediaWidget::closeEvent( QCloseEvent * )
43{ 86{
44 mediaPlayerState.setList(); 87 mediaPlayerState.setList();
45} 88}
46 89
47void MediaWidget::paintEvent( QPaintEvent *pe ) 90void MediaWidget::paintEvent( QPaintEvent *pe )
48{ 91{
49 QPainter p( this ); 92 QPainter p( this );
50 93
51 if ( mediaPlayerState.isFullscreen() ) { 94 if ( mediaPlayerState.isFullscreen() ) {
52 // Clear the background 95 // Clear the background
53 p.setBrush( QBrush( Qt::black ) ); 96 p.setBrush( QBrush( Qt::black ) );
54 return; 97 return;
55 } 98 }
56 99
57 if ( !pe->erased() ) { 100 if ( !pe->erased() ) {
58 // Combine with background and double buffer 101 // Combine with background and double buffer
59 QPixmap pix( pe->rect().size() ); 102 QPixmap pix( pe->rect().size() );
60 QPainter p( &pix ); 103 QPainter p( &pix );
61 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 104 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
62 p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() ); 105 p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() );
63 paintAllButtons( p ); 106 paintAllButtons( p );
64 QPainter p2( this ); 107 QPainter p2( this );
65 p2.drawPixmap( pe->rect().topLeft(), pix ); 108 p2.drawPixmap( pe->rect().topLeft(), pix );
66 } else { 109 } else {
67 QPainter p( this ); 110 QPainter p( this );
68 paintAllButtons( p ); 111 paintAllButtons( p );
69 } 112 }
70} 113}
71 114
72MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position ) 115MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position )
73{ 116{
74 if ( position.x() <= 0 || position.y() <= 0 || 117 if ( position.x() <= 0 || position.y() <= 0 ||
75 position.x() >= buttonMask.width() || 118 position.x() >= buttonMask.width() ||
76 position.y() >= buttonMask.height() ) 119 position.y() >= buttonMask.height() )
77 return 0; 120 return 0;
78 121
79 int pixelIdx = buttonMask.pixelIndex( position.x(), position.y() ); 122 int pixelIdx = buttonMask.pixelIndex( position.x(), position.y() );
80 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) 123 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it )
81 if ( it->command + 1 == pixelIdx ) 124 if ( it->command + 1 == pixelIdx )
82 return &( *it ); 125 return &( *it );
83 126
84 return 0; 127 return 0;
85} 128}
86 129
87void MediaWidget::mousePressEvent( QMouseEvent *event ) 130void MediaWidget::mousePressEvent( QMouseEvent *event )
88{ 131{
89 Button *button = buttonAt( event->pos() - upperLeftOfButtonMask ); 132 Button *button = buttonAt( event->pos() - upperLeftOfButtonMask );
90 133
91 if ( !button ) { 134 if ( !button ) {
92 QWidget::mousePressEvent( event ); 135 QWidget::mousePressEvent( event );
93 return; 136 return;
94 } 137 }
95 138
96 switch ( button->command ) { 139 switch ( button->command ) {
97 case VolumeUp: emit moreClicked(); return; 140 case VolumeUp: emit moreClicked(); return;
98 case VolumeDown: emit lessClicked(); return; 141 case VolumeDown: emit lessClicked(); return;
99 case Back: emit backClicked(); return; 142 case Back: emit backClicked(); return;
100 case Forward: emit forwardClicked(); return; 143 case Forward: emit forwardClicked(); return;
101 default: break; 144 default: break;
102 } 145 }
103} 146}
104 147
105void MediaWidget::mouseReleaseEvent( QMouseEvent *event ) 148void MediaWidget::mouseReleaseEvent( QMouseEvent *event )
106{ 149{
107 Button *button = buttonAt( event->pos() - upperLeftOfButtonMask ); 150 Button *button = buttonAt( event->pos() - upperLeftOfButtonMask );
108 151
109 if ( !button ) { 152 if ( !button ) {
110 QWidget::mouseReleaseEvent( event ); 153 QWidget::mouseReleaseEvent( event );
111 return; 154 return;
112 } 155 }
113 156
114 if ( button->type == ToggleButton ) 157 if ( button->type == ToggleButton )
115 toggleButton( *button ); 158 toggleButton( *button );
116 159
117 handleCommand( button->command, button->isDown ); 160 handleCommand( button->command, button->isDown );
118} 161}
119 162
120void MediaWidget::makeVisible() 163void MediaWidget::makeVisible()
121{ 164{
122} 165}
123 166
124void MediaWidget::handleCommand( Command command, bool buttonDown ) 167void MediaWidget::handleCommand( Command command, bool buttonDown )
125{ 168{
126 switch ( command ) { 169 switch ( command ) {
127 case Play: mediaPlayerState.togglePaused(); return; 170 case Play: mediaPlayerState.togglePaused(); return;
128 case Stop: mediaPlayerState.setPlaying(FALSE); return; 171 case Stop: mediaPlayerState.setPlaying(FALSE); return;
129 case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; 172 case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return;
130 case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; 173 case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return;
131 case Loop: mediaPlayerState.setLooping( buttonDown ); return; 174 case Loop: mediaPlayerState.setLooping( buttonDown ); return;
132 case VolumeUp: emit moreReleased(); return; 175 case VolumeUp: emit moreReleased(); return;
133 case VolumeDown: emit lessReleased(); return; 176 case VolumeDown: emit lessReleased(); return;
134 case PlayList: mediaPlayerState.setList(); return; 177 case PlayList: mediaPlayerState.setList(); return;
135 case Forward: emit forwardReleased(); return; 178 case Forward: emit forwardReleased(); return;
136 case Back: emit backReleased(); return; 179 case Back: emit backReleased(); return;
137 case FullScreen: mediaPlayerState.setFullscreen( true ); makeVisible(); return; 180 case FullScreen: mediaPlayerState.setFullscreen( true ); makeVisible(); return;
138 default: assert( false ); 181 default: assert( false );
139 } 182 }
140} 183}
141 184
142bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const 185bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const
143{ 186{
144 return ( position.x() > 0 && position.y() > 0 && 187 return ( position.x() > 0 && position.y() > 0 &&
145 position.x() < buttonMask.width() && 188 position.x() < buttonMask.width() &&
146 position.y() < buttonMask.height() && 189 position.y() < buttonMask.height() &&
147 buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 ); 190 buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 );
148} 191}
149 192
150void MediaWidget::paintAllButtons( QPainter &p ) 193void MediaWidget::paintAllButtons( QPainter &p )
151{ 194{
152 for ( ButtonVector::const_iterator it = buttons.begin(); 195 for ( ButtonVector::const_iterator it = buttons.begin();
153 it != buttons.end(); ++it ) 196 it != buttons.end(); ++it )
154 paintButton( p, *it ); 197 paintButton( p, *it );
155} 198}
156 199
157void MediaWidget::paintButton( const Button &button ) 200void MediaWidget::paintButton( const Button &button )
158{ 201{
159 QPainter p( this ); 202 QPainter p( this );
160 paintButton( p, button ); 203 paintButton( p, button );
161} 204}
162 205
163void MediaWidget::paintButton( QPainter &p, const Button &button ) 206void MediaWidget::paintButton( QPainter &p, const Button &button )
164{ 207{
165 if ( button.isDown ) 208 if ( button.isDown )
166 p.drawPixmap( upperLeftOfButtonMask, button.pixDown ); 209 p.drawPixmap( upperLeftOfButtonMask, button.pixDown );
167 else 210 else
168 p.drawPixmap( upperLeftOfButtonMask, button.pixUp ); 211 p.drawPixmap( upperLeftOfButtonMask, button.pixUp );
169} 212}
170 213
171void MediaWidget::setToggleButton( Command command, bool down ) 214void MediaWidget::setToggleButton( Command command, bool down )
172{ 215{
173 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) 216 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it )
174 if ( it->command == command ) { 217 if ( it->command == command ) {
175 setToggleButton( *it, down ); 218 setToggleButton( *it, down );
176 return; 219 return;
177 } 220 }
178} 221}
179 222
180void MediaWidget::setToggleButton( Button &button, bool down ) 223void MediaWidget::setToggleButton( Button &button, bool down )
181{ 224{
182 if ( down != button.isDown ) 225 if ( down != button.isDown )
183 toggleButton( button ); 226 toggleButton( button );
184} 227}
185 228
186void MediaWidget::toggleButton( Button &button ) 229void MediaWidget::toggleButton( Button &button )
187{ 230{
188 button.isDown = !button.isDown; 231 button.isDown = !button.isDown;
189 232
190 paintButton( button ); 233 paintButton( button );
191} 234}
192 235
193/* vim: et sw=4 ts=4 236/* vim: et sw=4 ts=4
194 */ 237 */
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index 8031371..148948a 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -1,123 +1,128 @@
1/* 1/*
2 Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> 2 Copyright (C) 2002 Simon Hausmann <hausmann@kde.org>
3 (C) 2002 Max Reiss <harlekin@handhelds.org> 3 (C) 2002 Max Reiss <harlekin@handhelds.org>
4 (C) 2002 L. Potter <ljp@llornkcor.com> 4 (C) 2002 L. Potter <ljp@llornkcor.com>
5 (C) 2002 Holger Freyther <zecke@handhelds.org> 5 (C) 2002 Holger Freyther <zecke@handhelds.org>
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23#ifndef MEDIAWIDGET_H 23#ifndef MEDIAWIDGET_H
24#define MEDIAWIDGET_H 24#define MEDIAWIDGET_H
25 25
26#include <qwidget.h> 26#include <qwidget.h>
27#include <qmap.h> 27#include <qmap.h>
28 28
29#include "mediaplayerstate.h" 29#include "mediaplayerstate.h"
30#include "playlistwidget.h" 30#include "playlistwidget.h"
31 31
32#include <vector> 32#include <vector>
33 33
34class MediaWidget : public QWidget 34class MediaWidget : public QWidget
35{ 35{
36 Q_OBJECT 36 Q_OBJECT
37public: 37public:
38 enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back, FullScreen, Undefined }; 38 enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back, FullScreen, Undefined };
39 enum ButtonType { NormalButton, ToggleButton }; 39 enum ButtonType { NormalButton, ToggleButton };
40 40
41 struct Button 41 struct Button
42 { 42 {
43 Button() : command( Undefined ), type( NormalButton ), isHeld( false ), isDown( false ) {} 43 Button() : command( Undefined ), type( NormalButton ), isHeld( false ), isDown( false ) {}
44 44
45 Command command; 45 Command command;
46 46
47 ButtonType type; // this should be part of the bitfield but gcc2 is too buggy to support this :-( 47 ButtonType type; // this should be part of the bitfield but gcc2 is too buggy to support this :-(
48 bool isHeld : 1; 48 bool isHeld : 1;
49 bool isDown : 1; 49 bool isDown : 1;
50 50
51 QBitmap mask; 51 QBitmap mask;
52 QPixmap pixUp; 52 QPixmap pixUp;
53 QPixmap pixDown; 53 QPixmap pixDown;
54 }; 54 };
55 typedef std::vector<Button> ButtonVector; 55 typedef std::vector<Button> ButtonVector;
56 56
57 struct SkinButtonInfo 57 struct SkinButtonInfo
58 { 58 {
59 Command command; 59 Command command;
60 const char *fileName; 60 const char *fileName;
61 ButtonType type; 61 ButtonType type;
62 }; 62 };
63 63
64 typedef std::vector<QBitmap> MaskVector; 64 typedef std::vector<QBitmap> MaskVector;
65 typedef std::vector<QPixmap> PixmapVector; 65 typedef std::vector<QPixmap> PixmapVector;
66 66
67 MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); 67 MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 );
68 virtual ~MediaWidget(); 68 virtual ~MediaWidget();
69 69
70public slots: 70public slots:
71 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; 71 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0;
72 virtual void setLength( long length ) = 0; 72 virtual void setLength( long length ) = 0;
73 virtual void setPlaying( bool playing ) = 0; 73 virtual void setPlaying( bool playing ) = 0;
74 74
75signals: 75signals:
76 void moreReleased(); 76 void moreReleased();
77 void lessReleased(); 77 void lessReleased();
78 void forwardReleased(); 78 void forwardReleased();
79 void backReleased(); 79 void backReleased();
80 void forwardClicked(); 80 void forwardClicked();
81 void backClicked(); 81 void backClicked();
82 void moreClicked(); 82 void moreClicked();
83 void lessClicked(); 83 void lessClicked();
84 84
85protected: 85protected:
86 void setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount,
87 const QString &imagePrefix, const QSize &buttonAreaSize );
88 Button setupButton( const SkinButtonInfo &buttonInfo, const QString &imagePrefix );
89 QBitmap setupButtonMask( const Command &command, const QString &fileName );
90
86 virtual void closeEvent( QCloseEvent * ); 91 virtual void closeEvent( QCloseEvent * );
87 92
88 virtual void paintEvent( QPaintEvent *pe ); 93 virtual void paintEvent( QPaintEvent *pe );
89 94
90 Button *buttonAt( const QPoint &position ); 95 Button *buttonAt( const QPoint &position );
91 96
92 virtual void mousePressEvent( QMouseEvent *event ); 97 virtual void mousePressEvent( QMouseEvent *event );
93 virtual void mouseReleaseEvent( QMouseEvent *event ); 98 virtual void mouseReleaseEvent( QMouseEvent *event );
94 99
95 virtual void makeVisible(); 100 virtual void makeVisible();
96 101
97 void handleCommand( Command command, bool buttonDown ); 102 void handleCommand( Command command, bool buttonDown );
98 103
99 bool isOverButton( const QPoint &position, int buttonId ) const; 104 bool isOverButton( const QPoint &position, int buttonId ) const;
100 105
101 void paintAllButtons( QPainter &p ); 106 void paintAllButtons( QPainter &p );
102 void paintButton( const Button &button ); 107 void paintButton( const Button &button );
103 void paintButton( QPainter &p, const Button &button ); 108 void paintButton( QPainter &p, const Button &button );
104 109
105 void setToggleButton( Button &button, bool down ); 110 void setToggleButton( Button &button, bool down );
106 void setToggleButton( Command command, bool down ); 111 void setToggleButton( Command command, bool down );
107 void toggleButton( Button &button ); 112 void toggleButton( Button &button );
108 113
109 MediaPlayerState &mediaPlayerState; 114 MediaPlayerState &mediaPlayerState;
110 PlayListWidget &playList; 115 PlayListWidget &playList;
111 116
112 ButtonVector buttons; 117 ButtonVector buttons;
113 118
114 QImage buttonMask; 119 QImage buttonMask;
115 120
116 QPoint upperLeftOfButtonMask; 121 QPoint upperLeftOfButtonMask;
117 122
118 QPixmap backgroundPixmap; 123 QPixmap backgroundPixmap;
119}; 124};
120 125
121#endif // MEDIAWIDGET_H 126#endif // MEDIAWIDGET_H
122/* vim: et sw=4 ts=4 127/* vim: et sw=4 ts=4
123 */ 128 */
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 4901e47..d1efaad 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -1,364 +1,341 @@
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 ), videoSliderBeingMoved( false ) 78 : MediaWidget( playList, mediaPlayerState, parent, name ), scaledWidth( 0 ), scaledHeight( 0 ), videoSliderBeingMoved( false )
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 setupButtons( skinInfo, buttonCount, QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_", imgUp.size() );
98 buttonMask.fill( 0 );
99
100 for ( uint i = 0; i < buttonCount; i++ ) {
101 Button button;
102 button.command = skinInfo[ i ].command;
103 button.type = skinInfo[ i ].type;
104
105 QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skinV_mask_" + skinInfo[i].fileName + ".png" );
106 button.mask =QBitmap( filename );
107
108 if ( !button.mask.isNull() ) {
109 QImage imgMask = button.mask.convertToImage();
110 uchar **dest = buttonMask.jumpTable();
111 for ( int y = 0; y < imgUp.height(); y++ ) {
112 uchar *line = dest[y];
113 for ( int x = 0; x < imgUp.width(); x++ )
114 if ( !qRed( imgMask.pixel( x, y ) ) )
115 line[x] = button.command + 1;
116 }
117 }
118
119 buttons.push_back( button );
120 }
121 98
122 setBackgroundPixmap( backgroundPixmap ); 99 setBackgroundPixmap( backgroundPixmap );
123 100
124 slider = new QSlider( Qt::Horizontal, this ); 101 slider = new QSlider( Qt::Horizontal, this );
125 slider->setMinValue( 0 ); 102 slider->setMinValue( 0 );
126 slider->setMaxValue( 1 ); 103 slider->setMaxValue( 1 );
127 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) ); 104 slider->setBackgroundPixmap( Resource::loadPixmap( backgroundPix ) );
128 //slider->setFocusPolicy( QWidget::NoFocus ); 105 //slider->setFocusPolicy( QWidget::NoFocus );
129 106
130 resizeEvent( NULL ); 107 resizeEvent( NULL );
131 108
132 setLength( mediaPlayerState.length() ); 109 setLength( mediaPlayerState.length() );
133 setPosition( mediaPlayerState.position() ); 110 setPosition( mediaPlayerState.position() );
134 setFullscreen( mediaPlayerState.isFullscreen() ); 111 setFullscreen( mediaPlayerState.isFullscreen() );
135 setPlaying( mediaPlayerState.isPlaying() ); 112 setPlaying( mediaPlayerState.isPlaying() );
136} 113}
137 114
138 115
139VideoWidget::~VideoWidget() 116VideoWidget::~VideoWidget()
140{ 117{
141} 118}
142 119
143QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 120QPixmap *combineVImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
144 QPixmap pix( img.width(), img.height() ); 121 QPixmap pix( img.width(), img.height() );
145 QPainter p( &pix ); 122 QPainter p( &pix );
146 p.drawTiledPixmap( pix.rect(), bg, offset ); 123 p.drawTiledPixmap( pix.rect(), bg, offset );
147 p.drawImage( 0, 0, img ); 124 p.drawImage( 0, 0, img );
148 return new QPixmap( pix ); 125 return new QPixmap( pix );
149} 126}
150 127
151QPixmap maskVPixToMask( QPixmap pix, QBitmap mask ) { 128QPixmap maskVPixToMask( QPixmap pix, QBitmap mask ) {
152 QPixmap pixmap( pix ); 129 QPixmap pixmap( pix );
153 pixmap.setMask( mask ); 130 pixmap.setMask( mask );
154 return pixmap; 131 return pixmap;
155} 132}
156 133
157void VideoWidget::resizeEvent( QResizeEvent * ) { 134void VideoWidget::resizeEvent( QResizeEvent * ) {
158 int h = height(); 135 int h = height();
159 int w = width(); 136 int w = width();
160 //int Vh = 160; 137 //int Vh = 160;
161 //int Vw = 220; 138 //int Vw = 220;
162 139
163 slider->setFixedWidth( w - 20 ); 140 slider->setFixedWidth( w - 20 );
164 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 141 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
165 slider->setBackgroundOrigin( QWidget::ParentOrigin ); 142 slider->setBackgroundOrigin( QWidget::ParentOrigin );
166 slider->setFocusPolicy( QWidget::NoFocus ); 143 slider->setFocusPolicy( QWidget::NoFocus );
167 slider->setBackgroundPixmap( backgroundPixmap ); 144 slider->setBackgroundPixmap( backgroundPixmap );
168 145
169 upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; 146 upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2;
170 if(w>h) 147 if(w>h)
171 upperLeftOfButtonMask.ry() = 0; 148 upperLeftOfButtonMask.ry() = 0;
172 else 149 else
173 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; 150 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10;
174 QPoint p = upperLeftOfButtonMask; 151 QPoint p = upperLeftOfButtonMask;
175 152
176 QPixmap *pixUp = combineVImageWithBackground( imgUp, backgroundPixmap, p ); 153 QPixmap *pixUp = combineVImageWithBackground( imgUp, backgroundPixmap, p );
177 QPixmap *pixDn = combineVImageWithBackground( imgDn, backgroundPixmap, p ); 154 QPixmap *pixDn = combineVImageWithBackground( imgDn, backgroundPixmap, p );
178 155
179 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) { 156 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) {
180 Button &button = *it; 157 Button &button = *it;
181 158
182 if ( !button.mask.isNull() ) { 159 if ( !button.mask.isNull() ) {
183 button.pixUp = maskVPixToMask( *pixUp, button.mask ); 160 button.pixUp = maskVPixToMask( *pixUp, button.mask );
184 button.pixDown = maskVPixToMask( *pixDn, button.mask ); 161 button.pixDown = maskVPixToMask( *pixDn, button.mask );
185 } 162 }
186 } 163 }
187 164
188 delete pixUp; 165 delete pixUp;
189 delete pixDn; 166 delete pixDn;
190} 167}
191 168
192void VideoWidget::sliderPressed() { 169void VideoWidget::sliderPressed() {
193 videoSliderBeingMoved = TRUE; 170 videoSliderBeingMoved = TRUE;
194} 171}
195 172
196void VideoWidget::sliderReleased() { 173void VideoWidget::sliderReleased() {
197 videoSliderBeingMoved = FALSE; 174 videoSliderBeingMoved = FALSE;
198 if ( slider->width() == 0 ) { 175 if ( slider->width() == 0 ) {
199 return; 176 return;
200 } 177 }
201 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); 178 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width());
202 mediaPlayerState.setPosition( val ); 179 mediaPlayerState.setPosition( val );
203} 180}
204 181
205void VideoWidget::setPosition( long i ) { 182void VideoWidget::setPosition( long i ) {
206 updateSlider( i, mediaPlayerState.length() ); 183 updateSlider( i, mediaPlayerState.length() );
207} 184}
208 185
209 186
210void VideoWidget::setLength( long max ) { 187void VideoWidget::setLength( long max ) {
211 updateSlider( mediaPlayerState.position(), max ); 188 updateSlider( mediaPlayerState.position(), max );
212} 189}
213 190
214void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) 191void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType )
215{ 192{
216 if ( displayType == MediaPlayerState::Video ) { 193 if ( displayType == MediaPlayerState::Video ) {
217 makeVisible(); 194 makeVisible();
218 return; 195 return;
219 } 196 }
220 197
221 // Effectively blank the view next time we show it so it looks nicer 198 // Effectively blank the view next time we show it so it looks nicer
222 scaledWidth = 0; 199 scaledWidth = 0;
223 scaledHeight = 0; 200 scaledHeight = 0;
224 hide(); 201 hide();
225} 202}
226 203
227void VideoWidget::updateSlider( long i, long max ) { 204void VideoWidget::updateSlider( long i, long max ) {
228 // Will flicker too much if we don't do this 205 // Will flicker too much if we don't do this
229 if ( max == 0 ) { 206 if ( max == 0 ) {
230 return; 207 return;
231 } 208 }
232 int width = slider->width(); 209 int width = slider->width();
233 int val = int((double)i * width / max); 210 int val = int((double)i * width / max);
234 if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { 211 if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) {
235 if ( slider->value() != val ) { 212 if ( slider->value() != val ) {
236 slider->setValue( val ); 213 slider->setValue( val );
237 } 214 }
238 if ( slider->maxValue() != width ) { 215 if ( slider->maxValue() != width ) {
239 slider->setMaxValue( width ); 216 slider->setMaxValue( width );
240 } 217 }
241 } 218 }
242} 219}
243 220
244void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 221void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
245 if ( mediaPlayerState.isFullscreen() ) { 222 if ( mediaPlayerState.isFullscreen() ) {
246 mediaPlayerState.setFullscreen( FALSE ); 223 mediaPlayerState.setFullscreen( FALSE );
247 makeVisible(); 224 makeVisible();
248 } 225 }
249 MediaWidget::mouseReleaseEvent( event ); 226 MediaWidget::mouseReleaseEvent( event );
250} 227}
251 228
252void VideoWidget::backToNormal() { 229void VideoWidget::backToNormal() {
253 mediaPlayerState.setFullscreen( FALSE ); 230 mediaPlayerState.setFullscreen( FALSE );
254 makeVisible(); 231 makeVisible();
255} 232}
256 233
257void VideoWidget::makeVisible() { 234void VideoWidget::makeVisible() {
258 if ( mediaPlayerState.isFullscreen() ) { 235 if ( mediaPlayerState.isFullscreen() ) {
259 setBackgroundMode( QWidget::NoBackground ); 236 setBackgroundMode( QWidget::NoBackground );
260 showFullScreen(); 237 showFullScreen();
261 resize( qApp->desktop()->size() ); 238 resize( qApp->desktop()->size() );
262 videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); 239 videoFrame-> setGeometry ( 0, 0, width ( ), height ( ));
263 240
264 slider->hide(); 241 slider->hide();
265 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 242 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
266 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 243 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
267 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 244 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
268 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 245 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
269 246
270 } else { 247 } else {
271 showNormal(); 248 showNormal();
272 showMaximized(); 249 showMaximized();
273 setBackgroundPixmap( backgroundPixmap ); 250 setBackgroundPixmap( backgroundPixmap );
274 QWidget *d = QApplication::desktop(); 251 QWidget *d = QApplication::desktop();
275 int w = d->width(); 252 int w = d->width();
276 int h = d->height(); 253 int h = d->height();
277 254
278 if(w>h) { 255 if(w>h) {
279 int newW=(w/2)-(246/2); //this will only work with 320x240 256 int newW=(w/2)-(246/2); //this will only work with 320x240
280 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); 257 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) );
281 } else { 258 } else {
282 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); 259 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) );
283 } 260 }
284 261
285 if ( !mediaPlayerState.isSeekable() ) { 262 if ( !mediaPlayerState.isSeekable() ) {
286 if( !slider->isHidden()) { 263 if( !slider->isHidden()) {
287 slider->hide(); 264 slider->hide();
288 } 265 }
289 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 266 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
290 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 267 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
291 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 268 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
292 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 269 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
293 } else { 270 } else {
294 slider->show(); 271 slider->show();
295 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 272 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
296 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 273 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
297 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 274 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
298 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 275 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
299 } 276 }
300 } 277 }
301} 278}
302 279
303void VideoWidget::keyReleaseEvent( QKeyEvent *e) { 280void VideoWidget::keyReleaseEvent( QKeyEvent *e) {
304 switch ( e->key() ) { 281 switch ( e->key() ) {
305////////////////////////////// Zaurus keys 282////////////////////////////// Zaurus keys
306 case Key_Home: 283 case Key_Home:
307 break; 284 break;
308 case Key_F9: //activity 285 case Key_F9: //activity
309 break; 286 break;
310 case Key_F10: //contacts 287 case Key_F10: //contacts
311// hide(); 288// hide();
312 break; 289 break;
313 case Key_F11: //menu 290 case Key_F11: //menu
314 break; 291 break;
315 case Key_F12: //home 292 case Key_F12: //home
316 break; 293 break;
317 case Key_F13: //mail 294 case Key_F13: //mail
318 break; 295 break;
319 case Key_Space: { 296 case Key_Space: {
320 if(mediaPlayerState.isPlaying()) { 297 if(mediaPlayerState.isPlaying()) {
321 mediaPlayerState.setPlaying(FALSE); 298 mediaPlayerState.setPlaying(FALSE);
322 } else { 299 } else {
323 mediaPlayerState.setPlaying(TRUE); 300 mediaPlayerState.setPlaying(TRUE);
324 } 301 }
325 } 302 }
326 break; 303 break;
327 case Key_Down: 304 case Key_Down:
328// toggleButton(6); 305// toggleButton(6);
329 emit lessClicked(); 306 emit lessClicked();
330 emit lessReleased(); 307 emit lessReleased();
331// toggleButton(6); 308// toggleButton(6);
332 break; 309 break;
333 case Key_Up: 310 case Key_Up:
334// toggleButton(5); 311// toggleButton(5);
335 emit moreClicked(); 312 emit moreClicked();
336 emit moreReleased(); 313 emit moreReleased();
337// toggleButton(5); 314// toggleButton(5);
338 break; 315 break;
339 case Key_Right: 316 case Key_Right:
340 mediaPlayerState.setNext(); 317 mediaPlayerState.setNext();
341 break; 318 break;
342 case Key_Left: 319 case Key_Left:
343 mediaPlayerState.setPrev(); 320 mediaPlayerState.setPrev();
344 break; 321 break;
345 case Key_Escape: 322 case Key_Escape:
346 break; 323 break;
347 324
348 }; 325 };
349} 326}
350 327
351XineVideoWidget* VideoWidget::vidWidget() { 328XineVideoWidget* VideoWidget::vidWidget() {
352 return videoFrame; 329 return videoFrame;
353} 330}
354 331
355 332
356void VideoWidget::setFullscreen ( bool b ) { 333void VideoWidget::setFullscreen ( bool b ) {
357 setToggleButton( FullScreen, b ); 334 setToggleButton( FullScreen, b );
358} 335}
359 336
360 337
361void VideoWidget::setPlaying( bool b) { 338void VideoWidget::setPlaying( bool b) {
362 setToggleButton( Play, b ); 339 setToggleButton( Play, b );
363} 340}
364 341