summaryrefslogtreecommitdiff
authorsimon <simon>2002-12-11 17:34:19 (UTC)
committer simon <simon>2002-12-11 17:34:19 (UTC)
commitaaac5c934e7053fa4323b03f7ea31c32c6388883 (patch) (unidiff)
treead9eb3da0efebbb862cbd8063978186c5b9d8190
parent75f0ed4978579eb4b27cdece64c597741ed24b79 (diff)
downloadopie-aaac5c934e7053fa4323b03f7ea31c32c6388883.zip
opie-aaac5c934e7053fa4323b03f7ea31c32c6388883.tar.gz
opie-aaac5c934e7053fa4323b03f7ea31c32c6388883.tar.bz2
- collect arguments passed to the skin loading into a structure
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.cpp11
-rw-r--r--noncore/multimedia/opieplayer2/audiowidget.h3
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.cpp6
-rw-r--r--noncore/multimedia/opieplayer2/mediawidget.h14
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.cpp11
-rw-r--r--noncore/multimedia/opieplayer2/videowidget.h3
6 files changed, 24 insertions, 24 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp
index 4db444a..cd5bea4 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.cpp
+++ b/noncore/multimedia/opieplayer2/audiowidget.cpp
@@ -1,345 +1,340 @@
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 loadSkin(); 91 loadSkin();
92 92
93 connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 93 connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
94 connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); 94 connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) );
95 95
96 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); 96 connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) );
97 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); 97 connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) );
98 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); 98 connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) );
99 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); 99 connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) );
100 100
101 // Intialise state 101 // Intialise state
102 setLength( mediaPlayerState.length() ); 102 setLength( mediaPlayerState.length() );
103 setPosition( mediaPlayerState.position() ); 103 setPosition( mediaPlayerState.position() );
104 setLooping( mediaPlayerState.isFullscreen() ); 104 setLooping( mediaPlayerState.isFullscreen() );
105 // setPaused( mediaPlayerState->paused() ); 105 // setPaused( mediaPlayerState->paused() );
106 setPlaying( mediaPlayerState.isPlaying() ); 106 setPlaying( mediaPlayerState.isPlaying() );
107} 107}
108 108
109AudioWidget::~AudioWidget() { 109AudioWidget::~AudioWidget() {
110 110
111// mediaPlayerState->setPlaying(false); 111// mediaPlayerState->setPlaying(false);
112} 112}
113 113
114const MediaWidget::SkinButtonInfo *AudioWidget::skinInfo() 114MediaWidget::GUIInfo AudioWidget::guiInfo()
115{ 115{
116 return ::skinInfo; 116 return GUIInfo( QString::null /* infix */, ::skinInfo, ::buttonCount );
117}
118
119const uint AudioWidget::buttonCount()
120{
121 return ::buttonCount;
122} 117}
123 118
124void AudioWidget::resizeEvent( QResizeEvent *e ) { 119void AudioWidget::resizeEvent( QResizeEvent *e ) {
125 int h = height(); 120 int h = height();
126 int w = width(); 121 int w = width();
127 122
128 songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); 123 songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) );
129 slider.setFixedWidth( w - 110 ); 124 slider.setFixedWidth( w - 110 );
130 slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 125 slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
131 slider.setBackgroundOrigin( QWidget::ParentOrigin ); 126 slider.setBackgroundOrigin( QWidget::ParentOrigin );
132 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); 127 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
133 128
134 upperLeftOfButtonMask.rx() = ( w - buttonUpImage.width() ) / 2; 129 upperLeftOfButtonMask.rx() = ( w - buttonUpImage.width() ) / 2;
135 upperLeftOfButtonMask.ry() = (( h - buttonUpImage.height() ) / 2) - 10; 130 upperLeftOfButtonMask.ry() = (( h - buttonUpImage.height() ) / 2) - 10;
136 131
137 MediaWidget::resizeEvent( e ); 132 MediaWidget::resizeEvent( e );
138} 133}
139 134
140void AudioWidget::sliderPressed() { 135void AudioWidget::sliderPressed() {
141 audioSliderBeingMoved = TRUE; 136 audioSliderBeingMoved = TRUE;
142} 137}
143 138
144 139
145void AudioWidget::sliderReleased() { 140void AudioWidget::sliderReleased() {
146 audioSliderBeingMoved = FALSE; 141 audioSliderBeingMoved = FALSE;
147 if ( slider.width() == 0 ) 142 if ( slider.width() == 0 )
148 return; 143 return;
149 long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); 144 long val = long((double)slider.value() * mediaPlayerState.length() / slider.width());
150 mediaPlayerState.setPosition( val ); 145 mediaPlayerState.setPosition( val );
151} 146}
152 147
153void AudioWidget::setPosition( long i ) { 148void AudioWidget::setPosition( long i ) {
154 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); 149 // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i);
155 updateSlider( i, mediaPlayerState.length() ); 150 updateSlider( i, mediaPlayerState.length() );
156} 151}
157 152
158 153
159void AudioWidget::setLength( long max ) { 154void AudioWidget::setLength( long max ) {
160 updateSlider( mediaPlayerState.position(), max ); 155 updateSlider( mediaPlayerState.position(), max );
161} 156}
162 157
163 158
164void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { 159void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) {
165 if ( mediaType == MediaPlayerState::Audio ) { 160 if ( mediaType == MediaPlayerState::Audio ) {
166 // startTimer( 150 ); 161 // startTimer( 150 );
167 showMaximized(); 162 showMaximized();
168 return; 163 return;
169 } 164 }
170 165
171 killTimers(); 166 killTimers();
172 hide(); 167 hide();
173} 168}
174 169
175void AudioWidget::loadSkin() 170void AudioWidget::loadSkin()
176{ 171{
177 loadDefaultSkin( ::skinInfo, ::buttonCount ); 172 loadDefaultSkin( guiInfo() );
178 173
179 setBackgroundPixmap( backgroundPixmap ); 174 setBackgroundPixmap( backgroundPixmap );
180 175
181 songInfo.setFocusPolicy( QWidget::NoFocus ); 176 songInfo.setFocusPolicy( QWidget::NoFocus );
182// changeTextColor( &songInfo ); 177// changeTextColor( &songInfo );
183// songInfo.setBackgroundColor( QColor( 167, 212, 167 )); 178// songInfo.setBackgroundColor( QColor( 167, 212, 167 ));
184// songInfo.setFrameStyle( QFrame::NoFrame); 179// songInfo.setFrameStyle( QFrame::NoFrame);
185 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); 180 songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
186// songInfo.setForegroundColor(Qt::white); 181// songInfo.setForegroundColor(Qt::white);
187 182
188 slider.setFixedHeight( 20 ); 183 slider.setFixedHeight( 20 );
189 slider.setMinValue( 0 ); 184 slider.setMinValue( 0 );
190 slider.setMaxValue( 1 ); 185 slider.setMaxValue( 1 );
191 slider.setFocusPolicy( QWidget::NoFocus ); 186 slider.setFocusPolicy( QWidget::NoFocus );
192 slider.setBackgroundPixmap( backgroundPixmap ); 187 slider.setBackgroundPixmap( backgroundPixmap );
193 188
194// Config cofg("qpe"); 189// Config cofg("qpe");
195// cofg.setGroup("Appearance"); 190// cofg.setGroup("Appearance");
196// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); 191// QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) );
197 192
198 time.setFocusPolicy( QWidget::NoFocus ); 193 time.setFocusPolicy( QWidget::NoFocus );
199 time.setAlignment( Qt::AlignCenter ); 194 time.setAlignment( Qt::AlignCenter );
200 195
201// time.setFrame(FALSE); 196// time.setFrame(FALSE);
202// changeTextColor( &time ); 197// changeTextColor( &time );
203 198
204 resizeEvent( 0 ); 199 resizeEvent( 0 );
205} 200}
206 201
207void AudioWidget::setSeekable( bool isSeekable ) { 202void AudioWidget::setSeekable( bool isSeekable ) {
208 203
209 if ( !isSeekable ) { 204 if ( !isSeekable ) {
210 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); 205 qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>");
211 if( !slider.isHidden()) { 206 if( !slider.isHidden()) {
212 slider.hide(); 207 slider.hide();
213 } 208 }
214 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 209 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
215 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 210 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
216 disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 211 disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
217 disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 212 disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
218 } else { 213 } else {
219 // this stops the slider from being moved, thus 214 // this stops the slider from being moved, thus
220 // does not stop stream when it reaches the end 215 // does not stop stream when it reaches the end
221 slider.show(); 216 slider.show();
222 qDebug( " CONNECT SET POSTION " ); 217 qDebug( " CONNECT SET POSTION " );
223 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 218 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
224 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 219 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
225 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 220 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
226 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 221 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
227 } 222 }
228} 223}
229 224
230 225
231static QString timeAsString( long length ) { 226static QString timeAsString( long length ) {
232 int minutes = length / 60; 227 int minutes = length / 60;
233 int seconds = length % 60; 228 int seconds = length % 60;
234 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); 229 return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 );
235} 230}
236 231
237void AudioWidget::updateSlider( long i, long max ) { 232void AudioWidget::updateSlider( long i, long max ) {
238 233
239 time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); 234 time.setText( timeAsString( i ) + " / " + timeAsString( max ) );
240// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; 235// qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ;
241 236
242 if ( max == 0 ) { 237 if ( max == 0 ) {
243 return; 238 return;
244 } 239 }
245 // Will flicker too much if we don't do this 240 // Will flicker too much if we don't do this
246 // Scale to something reasonable 241 // Scale to something reasonable
247 int width = slider.width(); 242 int width = slider.width();
248 int val = int((double)i * width / max); 243 int val = int((double)i * width / max);
249 if ( !audioSliderBeingMoved ) { 244 if ( !audioSliderBeingMoved ) {
250 if ( slider.value() != val ) { 245 if ( slider.value() != val ) {
251 slider.setValue( val ); 246 slider.setValue( val );
252 } 247 }
253 248
254 if ( slider.maxValue() != width ) { 249 if ( slider.maxValue() != width ) {
255 slider.setMaxValue( width ); 250 slider.setMaxValue( width );
256 } 251 }
257 } 252 }
258} 253}
259 254
260void AudioWidget::skipFor() { 255void AudioWidget::skipFor() {
261 skipDirection = +1; 256 skipDirection = +1;
262 startTimer( 50 ); 257 startTimer( 50 );
263 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); 258 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
264} 259}
265 260
266void AudioWidget::skipBack() { 261void AudioWidget::skipBack() {
267 skipDirection = -1; 262 skipDirection = -1;
268 startTimer( 50 ); 263 startTimer( 50 );
269 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); 264 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
270} 265}
271 266
272 267
273 268
274void AudioWidget::stopSkip() { 269void AudioWidget::stopSkip() {
275 killTimers(); 270 killTimers();
276} 271}
277 272
278 273
279void AudioWidget::timerEvent( QTimerEvent * ) { 274void AudioWidget::timerEvent( QTimerEvent * ) {
280 if ( skipDirection == +1 ) { 275 if ( skipDirection == +1 ) {
281 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); 276 mediaPlayerState.setPosition( mediaPlayerState.position() + 2 );
282 } else if ( skipDirection == -1 ) { 277 } else if ( skipDirection == -1 ) {
283 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); 278 mediaPlayerState.setPosition( mediaPlayerState.position() - 2 );
284 } 279 }
285} 280}
286 281
287void AudioWidget::keyReleaseEvent( QKeyEvent *e) { 282void AudioWidget::keyReleaseEvent( QKeyEvent *e) {
288 switch ( e->key() ) { 283 switch ( e->key() ) {
289 ////////////////////////////// Zaurus keys 284 ////////////////////////////// Zaurus keys
290 case Key_Home: 285 case Key_Home:
291 break; 286 break;
292 case Key_F9: //activity 287 case Key_F9: //activity
293 hide(); 288 hide();
294 // qDebug("Audio F9"); 289 // qDebug("Audio F9");
295 e->accept(); 290 e->accept();
296 break; 291 break;
297 case Key_F10: //contacts 292 case Key_F10: //contacts
298 break; 293 break;
299 case Key_F11: //menu 294 case Key_F11: //menu
300 mediaPlayerState.toggleBlank(); 295 mediaPlayerState.toggleBlank();
301 e->accept(); 296 e->accept();
302 break; 297 break;
303 case Key_F12: //home 298 case Key_F12: //home
304 break; 299 break;
305 case Key_F13: //mail 300 case Key_F13: //mail
306 mediaPlayerState.toggleBlank(); 301 mediaPlayerState.toggleBlank();
307 e->accept(); 302 e->accept();
308 break; 303 break;
309 case Key_Space: { 304 case Key_Space: {
310 e->accept(); 305 e->accept();
311 mediaPlayerState.togglePaused(); 306 mediaPlayerState.togglePaused();
312 } 307 }
313 break; 308 break;
314 case Key_Down: 309 case Key_Down:
315 // toggleButton(6); 310 // toggleButton(6);
316 emit lessClicked(); 311 emit lessClicked();
317 emit lessReleased(); 312 emit lessReleased();
318 // toggleButton(6); 313 // toggleButton(6);
319 e->accept(); 314 e->accept();
320 break; 315 break;
321 case Key_Up: 316 case Key_Up:
322 // toggleButton(5); 317 // toggleButton(5);
323 emit moreClicked(); 318 emit moreClicked();
324 emit moreReleased(); 319 emit moreReleased();
325 // toggleButton(5); 320 // toggleButton(5);
326 e->accept(); 321 e->accept();
327 break; 322 break;
328 case Key_Right: 323 case Key_Right:
329 // toggleButton(3); 324 // toggleButton(3);
330 mediaPlayerState.setNext(); 325 mediaPlayerState.setNext();
331 // toggleButton(3); 326 // toggleButton(3);
332 e->accept(); 327 e->accept();
333 break; 328 break;
334 case Key_Left: 329 case Key_Left:
335 // toggleButton(4); 330 // toggleButton(4);
336 mediaPlayerState.setPrev(); 331 mediaPlayerState.setPrev();
337 // toggleButton(4); 332 // toggleButton(4);
338 e->accept(); 333 e->accept();
339 break; 334 break;
340 case Key_Escape: { 335 case Key_Escape: {
341 } 336 }
342 break; 337 break;
343 338
344 }; 339 };
345} 340}
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h
index 75d4857..53dbb88 100644
--- a/noncore/multimedia/opieplayer2/audiowidget.h
+++ b/noncore/multimedia/opieplayer2/audiowidget.h
@@ -1,103 +1,102 @@
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#ifndef AUDIO_WIDGET_H 34#ifndef AUDIO_WIDGET_H
35#define AUDIO_WIDGET_H 35#define AUDIO_WIDGET_H
36 36
37#include <qpainter.h> 37#include <qpainter.h>
38#include <qdrawutil.h> 38#include <qdrawutil.h>
39#include <qpixmap.h> 39#include <qpixmap.h>
40#include <qstring.h> 40#include <qstring.h>
41#include <qslider.h> 41#include <qslider.h>
42#include <qframe.h> 42#include <qframe.h>
43#include <qlineedit.h> 43#include <qlineedit.h>
44#include <qimage.h> 44#include <qimage.h>
45 45
46#include <opie/oticker.h> 46#include <opie/oticker.h>
47 47
48#include "mediawidget.h" 48#include "mediawidget.h"
49 49
50class QPixmap; 50class QPixmap;
51 51
52class AudioWidget : public MediaWidget { 52class AudioWidget : public MediaWidget {
53 Q_OBJECT 53 Q_OBJECT
54public: 54public:
55 AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); 55 AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 );
56 ~AudioWidget(); 56 ~AudioWidget();
57 void setTickerText( const QString &text ) { songInfo.setText( text ); } 57 void setTickerText( const QString &text ) { songInfo.setText( text ); }
58 58
59 static const MediaWidget::SkinButtonInfo *skinInfo(); 59 static MediaWidget::GUIInfo guiInfo();
60 static const uint buttonCount();
61 60
62public slots: 61public slots:
63 void updateSlider( long, long ); 62 void updateSlider( long, long );
64 void sliderPressed( ); 63 void sliderPressed( );
65 void sliderReleased( ); 64 void sliderReleased( );
66 void setLooping( bool b) { setToggleButton( Loop, b ); } 65 void setLooping( bool b) { setToggleButton( Loop, b ); }
67 void setPosition( long ); 66 void setPosition( long );
68 void setSeekable( bool ); 67 void setSeekable( bool );
69 68
70public: 69public:
71 virtual void setLength( long ); 70 virtual void setLength( long );
72 virtual void setPlaying( bool b) { setToggleButton( Play, b ); } 71 virtual void setPlaying( bool b) { setToggleButton( Play, b ); }
73 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); 72 virtual void setDisplayType( MediaPlayerState::DisplayType displayType );
74 73
75 virtual void loadSkin(); 74 virtual void loadSkin();
76 75
77signals: 76signals:
78 void sliderMoved(long); 77 void sliderMoved(long);
79 78
80protected: 79protected:
81 void doBlank(); 80 void doBlank();
82 void doUnblank(); 81 void doUnblank();
83 void resizeEvent( QResizeEvent *re ); 82 void resizeEvent( QResizeEvent *re );
84 void timerEvent( QTimerEvent *event ); 83 void timerEvent( QTimerEvent *event );
85 void keyReleaseEvent( QKeyEvent *e); 84 void keyReleaseEvent( QKeyEvent *e);
86private slots: 85private slots:
87 void skipFor(); 86 void skipFor();
88 void skipBack(); 87 void skipBack();
89 void stopSkip(); 88 void stopSkip();
90private: 89private:
91 int skipDirection; 90 int skipDirection;
92 QString skin; 91 QString skin;
93 92
94 OTicker songInfo; 93 OTicker songInfo;
95 QSlider slider; 94 QSlider slider;
96 QLineEdit time; 95 QLineEdit time;
97 bool isStreaming : 1; 96 bool isStreaming : 1;
98 bool audioSliderBeingMoved : 1; 97 bool audioSliderBeingMoved : 1;
99}; 98};
100 99
101 100
102#endif // AUDIO_WIDGET_H 101#endif // AUDIO_WIDGET_H
103 102
diff --git a/noncore/multimedia/opieplayer2/mediawidget.cpp b/noncore/multimedia/opieplayer2/mediawidget.cpp
index ab2ec50..c0106d4 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.cpp
+++ b/noncore/multimedia/opieplayer2/mediawidget.cpp
@@ -1,267 +1,267 @@
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#include "skin.h" 26#include "skin.h"
27 27
28MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name ) 28MediaWidget::MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent, const char *name )
29 : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList ) 29 : QWidget( parent, name ), mediaPlayerState( _mediaPlayerState ), playList( _playList )
30{ 30{
31 connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ), 31 connect( &mediaPlayerState, SIGNAL( displayTypeChanged( MediaPlayerState::DisplayType ) ),
32 this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) ); 32 this, SLOT( setDisplayType( MediaPlayerState::DisplayType ) ) );
33 connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ), 33 connect( &mediaPlayerState, SIGNAL( lengthChanged( long ) ),
34 this, SLOT( setLength( long ) ) ); 34 this, SLOT( setLength( long ) ) );
35 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ), 35 connect( &mediaPlayerState, SIGNAL( playingToggled( bool ) ),
36 this, SLOT( setPlaying( bool ) ) ); 36 this, SLOT( setPlaying( bool ) ) );
37} 37}
38 38
39MediaWidget::~MediaWidget() 39MediaWidget::~MediaWidget()
40{ 40{
41} 41}
42 42
43void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, 43void MediaWidget::setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount,
44 const Skin &skin ) 44 const Skin &skin )
45{ 45{
46 buttonMask = skin.buttonMask( skinInfo, buttonCount ); 46 buttonMask = skin.buttonMask( skinInfo, buttonCount );
47 47
48 buttons.clear(); 48 buttons.clear();
49 buttons.reserve( buttonCount ); 49 buttons.reserve( buttonCount );
50 50
51 for ( uint i = 0; i < buttonCount; ++i ) { 51 for ( uint i = 0; i < buttonCount; ++i ) {
52 Button button = setupButton( skinInfo[ i ], skin ); 52 Button button = setupButton( skinInfo[ i ], skin );
53 buttons.push_back( button ); 53 buttons.push_back( button );
54 } 54 }
55} 55}
56 56
57MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin ) 57MediaWidget::Button MediaWidget::setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin )
58{ 58{
59 Button button; 59 Button button;
60 button.command = buttonInfo.command; 60 button.command = buttonInfo.command;
61 button.type = buttonInfo.type; 61 button.type = buttonInfo.type;
62 button.mask = skin.buttonMaskImage( buttonInfo.fileName ); 62 button.mask = skin.buttonMaskImage( buttonInfo.fileName );
63 63
64 return button; 64 return button;
65} 65}
66 66
67void MediaWidget::loadDefaultSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &fileNameInfix ) 67void MediaWidget::loadDefaultSkin( const GUIInfo &guiInfo )
68{ 68{
69 Skin skin( fileNameInfix ); 69 Skin skin( guiInfo.fileNameInfix );
70 loadSkin( skinInfo, buttonCount, skin ); 70 loadSkin( guiInfo.buttonInfo, guiInfo.buttonCount, skin );
71} 71}
72 72
73void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const Skin &skin ) 73void MediaWidget::loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const Skin &skin )
74{ 74{
75 backgroundPixmap = skin.backgroundImage(); 75 backgroundPixmap = skin.backgroundImage();
76 buttonUpImage = skin.buttonUpImage(); 76 buttonUpImage = skin.buttonUpImage();
77 buttonDownImage = skin.buttonDownImage(); 77 buttonDownImage = skin.buttonDownImage();
78 78
79 setupButtons( skinInfo, buttonCount, skin ); 79 setupButtons( skinInfo, buttonCount, skin );
80} 80}
81 81
82void MediaWidget::closeEvent( QCloseEvent * ) 82void MediaWidget::closeEvent( QCloseEvent * )
83{ 83{
84 mediaPlayerState.setList(); 84 mediaPlayerState.setList();
85} 85}
86 86
87void MediaWidget::paintEvent( QPaintEvent *pe ) 87void MediaWidget::paintEvent( QPaintEvent *pe )
88{ 88{
89 QPainter p( this ); 89 QPainter p( this );
90 90
91 if ( mediaPlayerState.isFullscreen() ) { 91 if ( mediaPlayerState.isFullscreen() ) {
92 // Clear the background 92 // Clear the background
93 p.setBrush( QBrush( Qt::black ) ); 93 p.setBrush( QBrush( Qt::black ) );
94 return; 94 return;
95 } 95 }
96 96
97 if ( !pe->erased() ) { 97 if ( !pe->erased() ) {
98 // Combine with background and double buffer 98 // Combine with background and double buffer
99 QPixmap pix( pe->rect().size() ); 99 QPixmap pix( pe->rect().size() );
100 QPainter p( &pix ); 100 QPainter p( &pix );
101 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); 101 p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() );
102 p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() ); 102 p.drawTiledPixmap( pe->rect(), backgroundPixmap, pe->rect().topLeft() );
103 paintAllButtons( p ); 103 paintAllButtons( p );
104 QPainter p2( this ); 104 QPainter p2( this );
105 p2.drawPixmap( pe->rect().topLeft(), pix ); 105 p2.drawPixmap( pe->rect().topLeft(), pix );
106 } else { 106 } else {
107 QPainter p( this ); 107 QPainter p( this );
108 paintAllButtons( p ); 108 paintAllButtons( p );
109 } 109 }
110} 110}
111 111
112void MediaWidget::resizeEvent( QResizeEvent *e ) 112void MediaWidget::resizeEvent( QResizeEvent *e )
113{ 113{
114 QPixmap pixUp = combineImageWithBackground( buttonUpImage, backgroundPixmap, upperLeftOfButtonMask ); 114 QPixmap pixUp = combineImageWithBackground( buttonUpImage, backgroundPixmap, upperLeftOfButtonMask );
115 QPixmap pixDn = combineImageWithBackground( buttonDownImage, backgroundPixmap, upperLeftOfButtonMask ); 115 QPixmap pixDn = combineImageWithBackground( buttonDownImage, backgroundPixmap, upperLeftOfButtonMask );
116 116
117 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) { 117 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) {
118 Button &button = *it; 118 Button &button = *it;
119 119
120 if ( button.mask.isNull() ) 120 if ( button.mask.isNull() )
121 continue; 121 continue;
122 button.pixUp = addMaskToPixmap( pixUp, button.mask ); 122 button.pixUp = addMaskToPixmap( pixUp, button.mask );
123 button.pixDown = addMaskToPixmap( pixDn, button.mask ); 123 button.pixDown = addMaskToPixmap( pixDn, button.mask );
124 } 124 }
125 125
126 QWidget::resizeEvent( e ); 126 QWidget::resizeEvent( e );
127} 127}
128 128
129MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position ) 129MediaWidget::Button *MediaWidget::buttonAt( const QPoint &position )
130{ 130{
131 if ( position.x() <= 0 || position.y() <= 0 || 131 if ( position.x() <= 0 || position.y() <= 0 ||
132 position.x() >= buttonMask.width() || 132 position.x() >= buttonMask.width() ||
133 position.y() >= buttonMask.height() ) 133 position.y() >= buttonMask.height() )
134 return 0; 134 return 0;
135 135
136 int pixelIdx = buttonMask.pixelIndex( position.x(), position.y() ); 136 int pixelIdx = buttonMask.pixelIndex( position.x(), position.y() );
137 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) 137 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it )
138 if ( it->command + 1 == pixelIdx ) 138 if ( it->command + 1 == pixelIdx )
139 return &( *it ); 139 return &( *it );
140 140
141 return 0; 141 return 0;
142} 142}
143 143
144void MediaWidget::mousePressEvent( QMouseEvent *event ) 144void MediaWidget::mousePressEvent( QMouseEvent *event )
145{ 145{
146 Button *button = buttonAt( event->pos() - upperLeftOfButtonMask ); 146 Button *button = buttonAt( event->pos() - upperLeftOfButtonMask );
147 147
148 if ( !button ) { 148 if ( !button ) {
149 QWidget::mousePressEvent( event ); 149 QWidget::mousePressEvent( event );
150 return; 150 return;
151 } 151 }
152 152
153 switch ( button->command ) { 153 switch ( button->command ) {
154 case VolumeUp: emit moreClicked(); return; 154 case VolumeUp: emit moreClicked(); return;
155 case VolumeDown: emit lessClicked(); return; 155 case VolumeDown: emit lessClicked(); return;
156 case Back: emit backClicked(); return; 156 case Back: emit backClicked(); return;
157 case Forward: emit forwardClicked(); return; 157 case Forward: emit forwardClicked(); return;
158 default: break; 158 default: break;
159 } 159 }
160} 160}
161 161
162void MediaWidget::mouseReleaseEvent( QMouseEvent *event ) 162void MediaWidget::mouseReleaseEvent( QMouseEvent *event )
163{ 163{
164 Button *button = buttonAt( event->pos() - upperLeftOfButtonMask ); 164 Button *button = buttonAt( event->pos() - upperLeftOfButtonMask );
165 165
166 if ( !button ) { 166 if ( !button ) {
167 QWidget::mouseReleaseEvent( event ); 167 QWidget::mouseReleaseEvent( event );
168 return; 168 return;
169 } 169 }
170 170
171 if ( button->type == ToggleButton ) 171 if ( button->type == ToggleButton )
172 toggleButton( *button ); 172 toggleButton( *button );
173 173
174 handleCommand( button->command, button->isDown ); 174 handleCommand( button->command, button->isDown );
175} 175}
176 176
177void MediaWidget::makeVisible() 177void MediaWidget::makeVisible()
178{ 178{
179} 179}
180 180
181void MediaWidget::handleCommand( Command command, bool buttonDown ) 181void MediaWidget::handleCommand( Command command, bool buttonDown )
182{ 182{
183 switch ( command ) { 183 switch ( command ) {
184 case Play: mediaPlayerState.togglePaused(); return; 184 case Play: mediaPlayerState.togglePaused(); return;
185 case Stop: mediaPlayerState.setPlaying(FALSE); return; 185 case Stop: mediaPlayerState.setPlaying(FALSE); return;
186 case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return; 186 case Next: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setNext(); return;
187 case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return; 187 case Previous: if( playList.currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState.setPrev(); return;
188 case Loop: mediaPlayerState.setLooping( buttonDown ); return; 188 case Loop: mediaPlayerState.setLooping( buttonDown ); return;
189 case VolumeUp: emit moreReleased(); return; 189 case VolumeUp: emit moreReleased(); return;
190 case VolumeDown: emit lessReleased(); return; 190 case VolumeDown: emit lessReleased(); return;
191 case PlayList: mediaPlayerState.setList(); return; 191 case PlayList: mediaPlayerState.setList(); return;
192 case Forward: emit forwardReleased(); return; 192 case Forward: emit forwardReleased(); return;
193 case Back: emit backReleased(); return; 193 case Back: emit backReleased(); return;
194 case FullScreen: mediaPlayerState.setFullscreen( true ); makeVisible(); return; 194 case FullScreen: mediaPlayerState.setFullscreen( true ); makeVisible(); return;
195 default: assert( false ); 195 default: assert( false );
196 } 196 }
197} 197}
198 198
199bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const 199bool MediaWidget::isOverButton( const QPoint &position, int buttonId ) const
200{ 200{
201 return ( position.x() > 0 && position.y() > 0 && 201 return ( position.x() > 0 && position.y() > 0 &&
202 position.x() < buttonMask.width() && 202 position.x() < buttonMask.width() &&
203 position.y() < buttonMask.height() && 203 position.y() < buttonMask.height() &&
204 buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 ); 204 buttonMask.pixelIndex( position.x(), position.y() ) == buttonId + 1 );
205} 205}
206 206
207void MediaWidget::paintAllButtons( QPainter &p ) 207void MediaWidget::paintAllButtons( QPainter &p )
208{ 208{
209 for ( ButtonVector::const_iterator it = buttons.begin(); 209 for ( ButtonVector::const_iterator it = buttons.begin();
210 it != buttons.end(); ++it ) 210 it != buttons.end(); ++it )
211 paintButton( p, *it ); 211 paintButton( p, *it );
212} 212}
213 213
214void MediaWidget::paintButton( const Button &button ) 214void MediaWidget::paintButton( const Button &button )
215{ 215{
216 QPainter p( this ); 216 QPainter p( this );
217 paintButton( p, button ); 217 paintButton( p, button );
218} 218}
219 219
220void MediaWidget::paintButton( QPainter &p, const Button &button ) 220void MediaWidget::paintButton( QPainter &p, const Button &button )
221{ 221{
222 if ( button.isDown ) 222 if ( button.isDown )
223 p.drawPixmap( upperLeftOfButtonMask, button.pixDown ); 223 p.drawPixmap( upperLeftOfButtonMask, button.pixDown );
224 else 224 else
225 p.drawPixmap( upperLeftOfButtonMask, button.pixUp ); 225 p.drawPixmap( upperLeftOfButtonMask, button.pixUp );
226} 226}
227 227
228void MediaWidget::setToggleButton( Command command, bool down ) 228void MediaWidget::setToggleButton( Command command, bool down )
229{ 229{
230 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it ) 230 for ( ButtonVector::iterator it = buttons.begin(); it != buttons.end(); ++it )
231 if ( it->command == command ) { 231 if ( it->command == command ) {
232 setToggleButton( *it, down ); 232 setToggleButton( *it, down );
233 return; 233 return;
234 } 234 }
235} 235}
236 236
237void MediaWidget::setToggleButton( Button &button, bool down ) 237void MediaWidget::setToggleButton( Button &button, bool down )
238{ 238{
239 if ( down != button.isDown ) 239 if ( down != button.isDown )
240 toggleButton( button ); 240 toggleButton( button );
241} 241}
242 242
243void MediaWidget::toggleButton( Button &button ) 243void MediaWidget::toggleButton( Button &button )
244{ 244{
245 button.isDown = !button.isDown; 245 button.isDown = !button.isDown;
246 246
247 paintButton( button ); 247 paintButton( button );
248} 248}
249 249
250QPixmap MediaWidget::combineImageWithBackground( const QImage &image, const QPixmap &background, const QPoint &offset ) 250QPixmap MediaWidget::combineImageWithBackground( const QImage &image, const QPixmap &background, const QPoint &offset )
251{ 251{
252 QPixmap pix( image.size() ); 252 QPixmap pix( image.size() );
253 QPainter p( &pix ); 253 QPainter p( &pix );
254 p.drawTiledPixmap( pix.rect(), background, offset ); 254 p.drawTiledPixmap( pix.rect(), background, offset );
255 p.drawImage( 0, 0, image ); 255 p.drawImage( 0, 0, image );
256 return pix; 256 return pix;
257} 257}
258 258
259QPixmap MediaWidget::addMaskToPixmap( const QPixmap &pix, const QBitmap &mask ) 259QPixmap MediaWidget::addMaskToPixmap( const QPixmap &pix, const QBitmap &mask )
260{ 260{
261 QPixmap result( pix ); 261 QPixmap result( pix );
262 result.setMask( mask ); 262 result.setMask( mask );
263 return result; 263 return result;
264} 264}
265 265
266/* vim: et sw=4 ts=4 266/* vim: et sw=4 ts=4
267 */ 267 */
diff --git a/noncore/multimedia/opieplayer2/mediawidget.h b/noncore/multimedia/opieplayer2/mediawidget.h
index 4599637..64483d8 100644
--- a/noncore/multimedia/opieplayer2/mediawidget.h
+++ b/noncore/multimedia/opieplayer2/mediawidget.h
@@ -1,155 +1,167 @@
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#include <memory> 33#include <memory>
34 34
35namespace 35namespace
36{ 36{
37 struct simpleAndStupidAllocator 37 struct simpleAndStupidAllocator
38 { 38 {
39 static void *allocate( size_t amount ) 39 static void *allocate( size_t amount )
40 { return ::operator new( amount ); } 40 { return ::operator new( amount ); }
41 static void deallocate( void *p, size_t ) 41 static void deallocate( void *p, size_t )
42 { ::operator delete( p ); } 42 { ::operator delete( p ); }
43 }; 43 };
44} 44}
45 45
46class Skin; 46class Skin;
47 47
48class MediaWidget : public QWidget 48class MediaWidget : public QWidget
49{ 49{
50 Q_OBJECT 50 Q_OBJECT
51public: 51public:
52 enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back, FullScreen, Undefined }; 52 enum Command { Play = 0, Stop, Next, Previous, VolumeUp, VolumeDown, Loop, PlayList, Forward, Back, FullScreen, Undefined };
53 enum ButtonType { NormalButton, ToggleButton }; 53 enum ButtonType { NormalButton, ToggleButton };
54 54
55 struct Button 55 struct Button
56 { 56 {
57 Button() : command( Undefined ), type( NormalButton ), isDown( false ) {} 57 Button() : command( Undefined ), type( NormalButton ), isDown( false ) {}
58 58
59 Command command; 59 Command command;
60 60
61 ButtonType type; // this should be part of the bitfield but gcc2 is too buggy to support this :-( 61 ButtonType type; // this should be part of the bitfield but gcc2 is too buggy to support this :-(
62 bool isDown : 1; 62 bool isDown : 1;
63 63
64 QBitmap mask; 64 QBitmap mask;
65 QPixmap pixUp; 65 QPixmap pixUp;
66 QPixmap pixDown; 66 QPixmap pixDown;
67 }; 67 };
68#if defined( _CC_GNU_ ) 68#if defined( _CC_GNU_ )
69 // use that allocator to avoid the default allocator that on gcc2 requires libstdc++ because 69 // use that allocator to avoid the default allocator that on gcc2 requires libstdc++ because
70 // in the BAD_ALLOC macro it uses std::cerr and friends :-( 70 // in the BAD_ALLOC macro it uses std::cerr and friends :-(
71 typedef std::vector<Button, std::__allocator<Button, simpleAndStupidAllocator> > ButtonVector; 71 typedef std::vector<Button, std::__allocator<Button, simpleAndStupidAllocator> > ButtonVector;
72#else 72#else
73 typedef std::vector<Button> ButtonVector; 73 typedef std::vector<Button> ButtonVector;
74#endif 74#endif
75 75
76 struct SkinButtonInfo 76 struct SkinButtonInfo
77 { 77 {
78 Command command; 78 Command command;
79 const char *fileName; 79 const char *fileName;
80 ButtonType type; 80 ButtonType type;
81 }; 81 };
82 82
83 struct GUIInfo
84 {
85 GUIInfo() : buttonInfo( 0 ), buttonCount( 0 ) {}
86 GUIInfo( const QString &_fileNameInfix, const SkinButtonInfo *_buttonInfo, const uint _buttonCount )
87 : fileNameInfix( _fileNameInfix ), buttonInfo( _buttonInfo ), buttonCount( _buttonCount )
88 {}
89
90 QString fileNameInfix;
91 const SkinButtonInfo *buttonInfo;
92 const uint buttonCount;
93 };
94
83 MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 ); 95 MediaWidget( PlayListWidget &_playList, MediaPlayerState &_mediaPlayerState, QWidget *parent = 0, const char *name = 0 );
84 virtual ~MediaWidget(); 96 virtual ~MediaWidget();
85 97
86public slots: 98public slots:
87 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0; 99 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ) = 0;
88 virtual void setLength( long length ) = 0; 100 virtual void setLength( long length ) = 0;
89 virtual void setPlaying( bool playing ) = 0; 101 virtual void setPlaying( bool playing ) = 0;
90 102
91 virtual void loadSkin() = 0; 103 virtual void loadSkin() = 0;
92 104
93signals: 105signals:
94 void moreReleased(); 106 void moreReleased();
95 void lessReleased(); 107 void lessReleased();
96 void forwardReleased(); 108 void forwardReleased();
97 void backReleased(); 109 void backReleased();
98 void forwardClicked(); 110 void forwardClicked();
99 void backClicked(); 111 void backClicked();
100 void moreClicked(); 112 void moreClicked();
101 void lessClicked(); 113 void lessClicked();
102 114
103protected: 115protected:
104 void setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount, 116 void setupButtons( const SkinButtonInfo *skinInfo, uint buttonCount,
105 const Skin &skin ); 117 const Skin &skin );
106 Button setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin ); 118 Button setupButton( const SkinButtonInfo &buttonInfo, const Skin &skin );
107 119
108 void loadDefaultSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const QString &fileNameInfix = QString::null ); 120 void loadDefaultSkin( const GUIInfo &guiInfo );
109 void loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const Skin &skin ); 121 void loadSkin( const SkinButtonInfo *skinInfo, uint buttonCount, const Skin &skin );
110 122
111 virtual void closeEvent( QCloseEvent * ); 123 virtual void closeEvent( QCloseEvent * );
112 124
113 virtual void paintEvent( QPaintEvent *pe ); 125 virtual void paintEvent( QPaintEvent *pe );
114 126
115 virtual void resizeEvent( QResizeEvent *e ); 127 virtual void resizeEvent( QResizeEvent *e );
116 128
117 Button *buttonAt( const QPoint &position ); 129 Button *buttonAt( const QPoint &position );
118 130
119 virtual void mousePressEvent( QMouseEvent *event ); 131 virtual void mousePressEvent( QMouseEvent *event );
120 virtual void mouseReleaseEvent( QMouseEvent *event ); 132 virtual void mouseReleaseEvent( QMouseEvent *event );
121 133
122 virtual void makeVisible(); 134 virtual void makeVisible();
123 135
124 void handleCommand( Command command, bool buttonDown ); 136 void handleCommand( Command command, bool buttonDown );
125 137
126 bool isOverButton( const QPoint &position, int buttonId ) const; 138 bool isOverButton( const QPoint &position, int buttonId ) const;
127 139
128 void paintAllButtons( QPainter &p ); 140 void paintAllButtons( QPainter &p );
129 void paintButton( const Button &button ); 141 void paintButton( const Button &button );
130 void paintButton( QPainter &p, const Button &button ); 142 void paintButton( QPainter &p, const Button &button );
131 143
132 void setToggleButton( Button &button, bool down ); 144 void setToggleButton( Button &button, bool down );
133 void setToggleButton( Command command, bool down ); 145 void setToggleButton( Command command, bool down );
134 void toggleButton( Button &button ); 146 void toggleButton( Button &button );
135 147
136 MediaPlayerState &mediaPlayerState; 148 MediaPlayerState &mediaPlayerState;
137 PlayListWidget &playList; 149 PlayListWidget &playList;
138 150
139 ButtonVector buttons; 151 ButtonVector buttons;
140 152
141 QImage buttonMask; 153 QImage buttonMask;
142 154
143 QPoint upperLeftOfButtonMask; 155 QPoint upperLeftOfButtonMask;
144 156
145 QPixmap backgroundPixmap; 157 QPixmap backgroundPixmap;
146 QImage buttonUpImage; 158 QImage buttonUpImage;
147 QImage buttonDownImage; 159 QImage buttonDownImage;
148 160
149 static QPixmap combineImageWithBackground( const QImage &background, const QPixmap &pixmap, const QPoint &offset ); 161 static QPixmap combineImageWithBackground( const QImage &background, const QPixmap &pixmap, const QPoint &offset );
150 static QPixmap addMaskToPixmap( const QPixmap &pix, const QBitmap &mask ); 162 static QPixmap addMaskToPixmap( const QPixmap &pix, const QBitmap &mask );
151}; 163};
152 164
153#endif // MEDIAWIDGET_H 165#endif // MEDIAWIDGET_H
154/* vim: et sw=4 ts=4 166/* vim: et sw=4 ts=4
155 */ 167 */
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp
index 058730f..2a345e3 100644
--- a/noncore/multimedia/opieplayer2/videowidget.cpp
+++ b/noncore/multimedia/opieplayer2/videowidget.cpp
@@ -1,321 +1,316 @@
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 videoFrame = new XineVideoWidget ( this, "Video frame" ); 82 videoFrame = new XineVideoWidget ( this, "Video frame" );
83 83
84 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & ))); 84 connect ( videoFrame, SIGNAL( videoResized ( const QSize & )), this, SIGNAL( videoResized ( const QSize & )));
85 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) ); 85 connect ( videoFrame, SIGNAL( clicked () ), this, SLOT ( backToNormal() ) );
86 86
87 slider = 0; 87 slider = 0;
88 88
89 loadSkin(); 89 loadSkin();
90 90
91 setLength( mediaPlayerState.length() ); 91 setLength( mediaPlayerState.length() );
92 setPosition( mediaPlayerState.position() ); 92 setPosition( mediaPlayerState.position() );
93 setFullscreen( mediaPlayerState.isFullscreen() ); 93 setFullscreen( mediaPlayerState.isFullscreen() );
94 setPlaying( mediaPlayerState.isPlaying() ); 94 setPlaying( mediaPlayerState.isPlaying() );
95} 95}
96 96
97 97
98VideoWidget::~VideoWidget() 98VideoWidget::~VideoWidget()
99{ 99{
100} 100}
101 101
102const MediaWidget::SkinButtonInfo *VideoWidget::skinInfo() 102MediaWidget::GUIInfo VideoWidget::guiInfo()
103{ 103{
104 return ::skinInfo; 104 return GUIInfo( "V" /* infix */, ::skinInfo, ::buttonCount );
105}
106
107const uint VideoWidget::buttonCount()
108{
109 return ::buttonCount;
110} 105}
111 106
112void VideoWidget::resizeEvent( QResizeEvent *e ) { 107void VideoWidget::resizeEvent( QResizeEvent *e ) {
113 int h = height(); 108 int h = height();
114 int w = width(); 109 int w = width();
115 //int Vh = 160; 110 //int Vh = 160;
116 //int Vw = 220; 111 //int Vw = 220;
117 112
118 slider->setFixedWidth( w - 20 ); 113 slider->setFixedWidth( w - 20 );
119 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); 114 slider->setGeometry( QRect( 15, h - 22, w - 90, 20 ) );
120 slider->setBackgroundOrigin( QWidget::ParentOrigin ); 115 slider->setBackgroundOrigin( QWidget::ParentOrigin );
121 slider->setFocusPolicy( QWidget::NoFocus ); 116 slider->setFocusPolicy( QWidget::NoFocus );
122 slider->setBackgroundPixmap( backgroundPixmap ); 117 slider->setBackgroundPixmap( backgroundPixmap );
123 118
124 upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2; 119 upperLeftOfButtonMask.rx() = 0;// ( imgUp->width() ) / 2;
125 if(w>h) 120 if(w>h)
126 upperLeftOfButtonMask.ry() = 0; 121 upperLeftOfButtonMask.ry() = 0;
127 else 122 else
128 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10; 123 upperLeftOfButtonMask.ry() = 185;//(( Vh - imgUp->height() ) / 2) - 10;
129 124
130 MediaWidget::resizeEvent( e ); 125 MediaWidget::resizeEvent( e );
131} 126}
132 127
133void VideoWidget::sliderPressed() { 128void VideoWidget::sliderPressed() {
134 videoSliderBeingMoved = TRUE; 129 videoSliderBeingMoved = TRUE;
135} 130}
136 131
137void VideoWidget::sliderReleased() { 132void VideoWidget::sliderReleased() {
138 videoSliderBeingMoved = FALSE; 133 videoSliderBeingMoved = FALSE;
139 if ( slider->width() == 0 ) { 134 if ( slider->width() == 0 ) {
140 return; 135 return;
141 } 136 }
142 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width()); 137 long val = long((double)slider->value() * mediaPlayerState.length() / slider->width());
143 mediaPlayerState.setPosition( val ); 138 mediaPlayerState.setPosition( val );
144} 139}
145 140
146void VideoWidget::setPosition( long i ) { 141void VideoWidget::setPosition( long i ) {
147 updateSlider( i, mediaPlayerState.length() ); 142 updateSlider( i, mediaPlayerState.length() );
148} 143}
149 144
150 145
151void VideoWidget::setLength( long max ) { 146void VideoWidget::setLength( long max ) {
152 updateSlider( mediaPlayerState.position(), max ); 147 updateSlider( mediaPlayerState.position(), max );
153} 148}
154 149
155void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType ) 150void VideoWidget::setDisplayType( MediaPlayerState::DisplayType displayType )
156{ 151{
157 if ( displayType == MediaPlayerState::Video ) { 152 if ( displayType == MediaPlayerState::Video ) {
158 makeVisible(); 153 makeVisible();
159 return; 154 return;
160 } 155 }
161 156
162 // Effectively blank the view next time we show it so it looks nicer 157 // Effectively blank the view next time we show it so it looks nicer
163 scaledWidth = 0; 158 scaledWidth = 0;
164 scaledHeight = 0; 159 scaledHeight = 0;
165 hide(); 160 hide();
166} 161}
167 162
168void VideoWidget::loadSkin() 163void VideoWidget::loadSkin()
169{ 164{
170 loadDefaultSkin( ::skinInfo, ::buttonCount, "V" ); 165 loadDefaultSkin( guiInfo() );
171 166
172 setBackgroundPixmap( backgroundPixmap ); 167 setBackgroundPixmap( backgroundPixmap );
173 168
174 delete slider; 169 delete slider;
175 slider = new QSlider( Qt::Horizontal, this ); 170 slider = new QSlider( Qt::Horizontal, this );
176 slider->setMinValue( 0 ); 171 slider->setMinValue( 0 );
177 slider->setMaxValue( 1 ); 172 slider->setMaxValue( 1 );
178 slider->setBackgroundPixmap( backgroundPixmap ); 173 slider->setBackgroundPixmap( backgroundPixmap );
179 //slider->setFocusPolicy( QWidget::NoFocus ); 174 //slider->setFocusPolicy( QWidget::NoFocus );
180 175
181 resizeEvent( 0 ); 176 resizeEvent( 0 );
182} 177}
183 178
184void VideoWidget::updateSlider( long i, long max ) { 179void VideoWidget::updateSlider( long i, long max ) {
185 // Will flicker too much if we don't do this 180 // Will flicker too much if we don't do this
186 if ( max == 0 ) { 181 if ( max == 0 ) {
187 return; 182 return;
188 } 183 }
189 int width = slider->width(); 184 int width = slider->width();
190 int val = int((double)i * width / max); 185 int val = int((double)i * width / max);
191 if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) { 186 if ( !mediaPlayerState.isFullscreen() && !videoSliderBeingMoved ) {
192 if ( slider->value() != val ) { 187 if ( slider->value() != val ) {
193 slider->setValue( val ); 188 slider->setValue( val );
194 } 189 }
195 if ( slider->maxValue() != width ) { 190 if ( slider->maxValue() != width ) {
196 slider->setMaxValue( width ); 191 slider->setMaxValue( width );
197 } 192 }
198 } 193 }
199} 194}
200 195
201void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) { 196void VideoWidget::mouseReleaseEvent( QMouseEvent *event ) {
202 if ( mediaPlayerState.isFullscreen() ) { 197 if ( mediaPlayerState.isFullscreen() ) {
203 mediaPlayerState.setFullscreen( FALSE ); 198 mediaPlayerState.setFullscreen( FALSE );
204 makeVisible(); 199 makeVisible();
205 } 200 }
206 MediaWidget::mouseReleaseEvent( event ); 201 MediaWidget::mouseReleaseEvent( event );
207} 202}
208 203
209void VideoWidget::backToNormal() { 204void VideoWidget::backToNormal() {
210 mediaPlayerState.setFullscreen( FALSE ); 205 mediaPlayerState.setFullscreen( FALSE );
211 makeVisible(); 206 makeVisible();
212} 207}
213 208
214void VideoWidget::makeVisible() { 209void VideoWidget::makeVisible() {
215 if ( mediaPlayerState.isFullscreen() ) { 210 if ( mediaPlayerState.isFullscreen() ) {
216 setBackgroundMode( QWidget::NoBackground ); 211 setBackgroundMode( QWidget::NoBackground );
217 showFullScreen(); 212 showFullScreen();
218 resize( qApp->desktop()->size() ); 213 resize( qApp->desktop()->size() );
219 videoFrame-> setGeometry ( 0, 0, width ( ), height ( )); 214 videoFrame-> setGeometry ( 0, 0, width ( ), height ( ));
220 215
221 slider->hide(); 216 slider->hide();
222 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 217 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
223 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 218 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
224 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 219 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
225 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 220 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
226 221
227 } else { 222 } else {
228 showNormal(); 223 showNormal();
229 showMaximized(); 224 showMaximized();
230 setBackgroundPixmap( backgroundPixmap ); 225 setBackgroundPixmap( backgroundPixmap );
231 QWidget *d = QApplication::desktop(); 226 QWidget *d = QApplication::desktop();
232 int w = d->width(); 227 int w = d->width();
233 int h = d->height(); 228 int h = d->height();
234 229
235 if(w>h) { 230 if(w>h) {
236 int newW=(w/2)-(246/2); //this will only work with 320x240 231 int newW=(w/2)-(246/2); //this will only work with 320x240
237 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) ); 232 videoFrame->setGeometry( QRect( newW, 4, 240, 170 ) );
238 } else { 233 } else {
239 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) ); 234 videoFrame->setGeometry( QRect( 0, 30, 240, 170 ) );
240 } 235 }
241 236
242 if ( !mediaPlayerState.isSeekable() ) { 237 if ( !mediaPlayerState.isSeekable() ) {
243 if( !slider->isHidden()) { 238 if( !slider->isHidden()) {
244 slider->hide(); 239 slider->hide();
245 } 240 }
246 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 241 disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
247 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 242 disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
248 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 243 disconnect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
249 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 244 disconnect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
250 } else { 245 } else {
251 slider->show(); 246 slider->show();
252 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 247 connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
253 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 248 connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
254 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 249 connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
255 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 250 connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
256 } 251 }
257 } 252 }
258} 253}
259 254
260void VideoWidget::keyReleaseEvent( QKeyEvent *e) { 255void VideoWidget::keyReleaseEvent( QKeyEvent *e) {
261 switch ( e->key() ) { 256 switch ( e->key() ) {
262////////////////////////////// Zaurus keys 257////////////////////////////// Zaurus keys
263 case Key_Home: 258 case Key_Home:
264 break; 259 break;
265 case Key_F9: //activity 260 case Key_F9: //activity
266 break; 261 break;
267 case Key_F10: //contacts 262 case Key_F10: //contacts
268// hide(); 263// hide();
269 break; 264 break;
270 case Key_F11: //menu 265 case Key_F11: //menu
271 break; 266 break;
272 case Key_F12: //home 267 case Key_F12: //home
273 break; 268 break;
274 case Key_F13: //mail 269 case Key_F13: //mail
275 break; 270 break;
276 case Key_Space: { 271 case Key_Space: {
277 if(mediaPlayerState.isPlaying()) { 272 if(mediaPlayerState.isPlaying()) {
278 mediaPlayerState.setPlaying(FALSE); 273 mediaPlayerState.setPlaying(FALSE);
279 } else { 274 } else {
280 mediaPlayerState.setPlaying(TRUE); 275 mediaPlayerState.setPlaying(TRUE);
281 } 276 }
282 } 277 }
283 break; 278 break;
284 case Key_Down: 279 case Key_Down:
285// toggleButton(6); 280// toggleButton(6);
286 emit lessClicked(); 281 emit lessClicked();
287 emit lessReleased(); 282 emit lessReleased();
288// toggleButton(6); 283// toggleButton(6);
289 break; 284 break;
290 case Key_Up: 285 case Key_Up:
291// toggleButton(5); 286// toggleButton(5);
292 emit moreClicked(); 287 emit moreClicked();
293 emit moreReleased(); 288 emit moreReleased();
294// toggleButton(5); 289// toggleButton(5);
295 break; 290 break;
296 case Key_Right: 291 case Key_Right:
297 mediaPlayerState.setNext(); 292 mediaPlayerState.setNext();
298 break; 293 break;
299 case Key_Left: 294 case Key_Left:
300 mediaPlayerState.setPrev(); 295 mediaPlayerState.setPrev();
301 break; 296 break;
302 case Key_Escape: 297 case Key_Escape:
303 break; 298 break;
304 299
305 }; 300 };
306} 301}
307 302
308XineVideoWidget* VideoWidget::vidWidget() { 303XineVideoWidget* VideoWidget::vidWidget() {
309 return videoFrame; 304 return videoFrame;
310} 305}
311 306
312 307
313void VideoWidget::setFullscreen ( bool b ) { 308void VideoWidget::setFullscreen ( bool b ) {
314 setToggleButton( FullScreen, b ); 309 setToggleButton( FullScreen, b );
315} 310}
316 311
317 312
318void VideoWidget::setPlaying( bool b) { 313void VideoWidget::setPlaying( bool b) {
319 setToggleButton( Play, b ); 314 setToggleButton( Play, b );
320} 315}
321 316
diff --git a/noncore/multimedia/opieplayer2/videowidget.h b/noncore/multimedia/opieplayer2/videowidget.h
index 80e9356..84bc964 100644
--- a/noncore/multimedia/opieplayer2/videowidget.h
+++ b/noncore/multimedia/opieplayer2/videowidget.h
@@ -1,100 +1,99 @@
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#ifndef VIDEO_WIDGET_H 34#ifndef VIDEO_WIDGET_H
35#define VIDEO_WIDGET_H 35#define VIDEO_WIDGET_H
36 36
37#include <qwidget.h> 37#include <qwidget.h>
38#include <qimage.h> 38#include <qimage.h>
39#include <qpixmap.h> 39#include <qpixmap.h>
40#include "xinevideowidget.h" 40#include "xinevideowidget.h"
41 41
42#include "mediawidget.h" 42#include "mediawidget.h"
43 43
44class QPixmap; 44class QPixmap;
45class QSlider; 45class QSlider;
46 46
47class VideoWidget : public MediaWidget { 47class VideoWidget : public MediaWidget {
48 Q_OBJECT 48 Q_OBJECT
49public: 49public:
50 VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 ); 50 VideoWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent=0, const char* name=0 );
51 ~VideoWidget(); 51 ~VideoWidget();
52 52
53 static const MediaWidget::SkinButtonInfo *skinInfo(); 53 static MediaWidget::GUIInfo guiInfo();
54 static const uint buttonCount();
55 54
56 XineVideoWidget* vidWidget(); 55 XineVideoWidget* vidWidget();
57public slots: 56public slots:
58 void updateSlider( long, long ); 57 void updateSlider( long, long );
59 void sliderPressed( ); 58 void sliderPressed( );
60 void sliderReleased( ); 59 void sliderReleased( );
61 void setFullscreen( bool b ); 60 void setFullscreen( bool b );
62 virtual void makeVisible(); 61 virtual void makeVisible();
63 void backToNormal(); 62 void backToNormal();
64 void setPosition( long ); 63 void setPosition( long );
65 64
66public: 65public:
67 virtual void setPlaying( bool b); 66 virtual void setPlaying( bool b);
68 virtual void setLength( long ); 67 virtual void setLength( long );
69 virtual void setDisplayType( MediaPlayerState::DisplayType displayType ); 68 virtual void setDisplayType( MediaPlayerState::DisplayType displayType );
70 69
71 virtual void loadSkin(); 70 virtual void loadSkin();
72 71
73signals: 72signals:
74 void moreClicked(); 73 void moreClicked();
75 void lessClicked(); 74 void lessClicked();
76 void sliderMoved( long ); 75 void sliderMoved( long );
77 void videoResized ( const QSize &s ); 76 void videoResized ( const QSize &s );
78 77
79protected: 78protected:
80 79
81 void resizeEvent( QResizeEvent * ); 80 void resizeEvent( QResizeEvent * );
82 void mouseReleaseEvent( QMouseEvent *event ); 81 void mouseReleaseEvent( QMouseEvent *event );
83 void keyReleaseEvent( QKeyEvent *e); 82 void keyReleaseEvent( QKeyEvent *e);
84 83
85private: 84private:
86// Ticker songInfo; 85// Ticker songInfo;
87 86
88 QSlider *slider; 87 QSlider *slider;
89 QImage *currentFrame; 88 QImage *currentFrame;
90 int scaledWidth; 89 int scaledWidth;
91 int scaledHeight; 90 int scaledHeight;
92 XineVideoWidget* videoFrame; 91 XineVideoWidget* videoFrame;
93 92
94 bool videoSliderBeingMoved; 93 bool videoSliderBeingMoved;
95}; 94};
96 95
97#endif // VIDEO_WIDGET_H 96#endif // VIDEO_WIDGET_H
98 97
99 98
100 99