summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/audiowidget.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/core/multimedia/opieplayer/audiowidget.cpp b/core/multimedia/opieplayer/audiowidget.cpp
index 3dfe182..a1973e9 100644
--- a/core/multimedia/opieplayer/audiowidget.cpp
+++ b/core/multimedia/opieplayer/audiowidget.cpp
@@ -1,282 +1,282 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21#include <qpe/resource.h> 21#include <qpe/resource.h>
22#include <qpe/config.h> 22#include <qpe/config.h>
23 23
24#include <qwidget.h> 24#include <qwidget.h>
25#include <qpixmap.h> 25#include <qpixmap.h>
26#include <qbutton.h> 26#include <qbutton.h>
27#include <qpainter.h> 27#include <qpainter.h>
28#include <qframe.h> 28#include <qframe.h>
29#include <qlayout.h> 29#include <qlayout.h>
30#include <qdir.h> 30#include <qdir.h>
31#include "audiowidget.h" 31#include "audiowidget.h"
32#include "mediaplayerstate.h" 32#include "mediaplayerstate.h"
33 33
34#include <stdlib.h> 34#include <stdlib.h>
35#include <stdio.h> 35#include <stdio.h>
36 36
37extern MediaPlayerState *mediaPlayerState; 37extern MediaPlayerState *mediaPlayerState;
38 38
39 39
40static const int xo = -2; // movable x offset 40static const int xo = -2; // movable x offset
41static const int yo = 22; // movable y offset 41static const int yo = 22; // movable y offset
42 42
43struct MediaButton { 43struct MediaButton {
44 bool isToggle, isHeld, isDown; 44 bool isToggle, isHeld, isDown;
45}; 45};
46 46
47//Layout information for the audioButtons (and if it is a toggle button or not) 47//Layout information for the audioButtons (and if it is a toggle button or not)
48MediaButton audioButtons[] = { 48MediaButton audioButtons[] = {
49 { TRUE, FALSE, FALSE }, // play 49 { TRUE, FALSE, FALSE }, // play
50 { FALSE, FALSE, FALSE }, // stop 50 { FALSE, FALSE, FALSE }, // stop
51 { FALSE, FALSE, FALSE }, // next 51 { FALSE, FALSE, FALSE }, // next
52 { FALSE, FALSE, FALSE }, // previous 52 { FALSE, FALSE, FALSE }, // previous
53 { FALSE, FALSE, FALSE }, // volume up 53 { FALSE, FALSE, FALSE }, // volume up
54 { FALSE, FALSE, FALSE }, // volume down 54 { FALSE, FALSE, FALSE }, // volume down
55 { TRUE, FALSE, FALSE }, // repeat/loop 55 { TRUE, FALSE, FALSE }, // repeat/loop
56 { FALSE, FALSE, FALSE }, // playlist 56 { FALSE, FALSE, FALSE }, // playlist
57 { FALSE, FALSE, FALSE }, // forward 57 { FALSE, FALSE, FALSE }, // forward
58 { FALSE, FALSE, FALSE } // back 58 { FALSE, FALSE, FALSE } // back
59}; 59};
60 60
61const char *skin_mask_file_names[10] = { 61const char *skin_mask_file_names[10] = {
62 "play", "stop", "next", "prev", "up", 62 "play", "stop", "next", "prev", "up",
63 "down", "loop", "playlist", "forward", "back" 63 "down", "loop", "playlist", "forward", "back"
64}; 64};
65 65
66static void changeTextColor( QWidget *w ) { 66static void changeTextColor( QWidget *w ) {
67 QPalette p = w->palette(); 67 QPalette p = w->palette();
68 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); 68 p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) );
69 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); 69 p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) );
70 w->setPalette( p ); 70 w->setPalette( p );
71} 71}
72 72
73static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); 73static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton));
74 74
75AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : 75AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) :
76 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) 76 QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this )
77{ 77{
78 setCaption( tr("OpiePlayer") ); 78 setCaption( tr("OpiePlayer") );
79 qDebug("<<<<<audioWidget"); 79 qDebug("<<<<<audioWidget");
80 80
81 Config cfg("OpiePlayer"); 81 Config cfg("OpiePlayer");
82 cfg.setGroup("Options"); 82 cfg.setGroup("Options");
83 skin = cfg.readEntry("Skin","default"); 83 skin = cfg.readEntry("Skin","default");
84 //skin = "scaleTest"; 84 //skin = "scaleTest";
85// color of background, frame, degree of transparency 85// color of background, frame, degree of transparency
86 86
87// QString skinPath = "opieplayer/skins/" + skin; 87// QString skinPath = "opieplayer/skins/" + skin;
88 QString skinPath; 88 QString skinPath;
89 skinPath = "opieplayer2/skins/" + skin; 89 skinPath = "opieplayer2/skins/" + skin;
90 if(!QDir(skinPath).exists()) 90 if(!QDir(QString(getenv("OPIEDIR")) +"/pics/"+skinPath).exists())
91 skinPath = "opieplayer2/skins/default"; 91 skinPath = "opieplayer2/skins/default";
92 92
93 qDebug("skin path " + skinPath); 93 qDebug("skin path " + skinPath);
94 94
95 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); 95 pixBg = new QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) );
96 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); 96 imgUp = new QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) );
97 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); 97 imgDn = new QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) );
98 98
99 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 ); 99 imgButtonMask = new QImage( imgUp->width(), imgUp->height(), 8, 255 );
100 imgButtonMask->fill( 0 ); 100 imgButtonMask->fill( 0 );
101 101
102 for ( int i = 0; i < 10; i++ ) { 102 for ( int i = 0; i < 10; i++ ) {
103 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png"; 103 QString filename = QString(getenv("OPIEDIR")) + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png";
104 masks[i] = new QBitmap( filename ); 104 masks[i] = new QBitmap( filename );
105 105
106 if ( !masks[i]->isNull() ) { 106 if ( !masks[i]->isNull() ) {
107 QImage imgMask = masks[i]->convertToImage(); 107 QImage imgMask = masks[i]->convertToImage();
108 uchar **dest = imgButtonMask->jumpTable(); 108 uchar **dest = imgButtonMask->jumpTable();
109 for ( int y = 0; y < imgUp->height(); y++ ) { 109 for ( int y = 0; y < imgUp->height(); y++ ) {
110 uchar *line = dest[y]; 110 uchar *line = dest[y];
111 for ( int x = 0; x < imgUp->width(); x++ ) 111 for ( int x = 0; x < imgUp->width(); x++ )
112 if ( !qRed( imgMask.pixel( x, y ) ) ) 112 if ( !qRed( imgMask.pixel( x, y ) ) )
113 line[x] = i + 1; 113 line[x] = i + 1;
114 } 114 }
115 } 115 }
116 116
117 } 117 }
118 118
119 for ( int i = 0; i < 11; i++ ) { 119 for ( int i = 0; i < 11; i++ ) {
120 buttonPixUp[i] = NULL; 120 buttonPixUp[i] = NULL;
121 buttonPixDown[i] = NULL; 121 buttonPixDown[i] = NULL;
122 } 122 }
123 123
124 setBackgroundPixmap( *pixBg ); 124 setBackgroundPixmap( *pixBg );
125 125
126 songInfo.setFocusPolicy( QWidget::NoFocus ); 126 songInfo.setFocusPolicy( QWidget::NoFocus );
127 127
128// changeTextColor( &songInfo ); 128// changeTextColor( &songInfo );
129// songInfo.setBackgroundColor( QColor( 167, 212, 167 )); 129// songInfo.setBackgroundColor( QColor( 167, 212, 167 ));
130// songInfo.setFrameStyle( QFrame::NoFrame); 130// songInfo.setFrameStyle( QFrame::NoFrame);
131// songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); 131// songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken );
132 //NoFrame 132 //NoFrame
133// songInfo.setForegroundColor(Qt::white); 133// songInfo.setForegroundColor(Qt::white);
134 134
135 slider.setFixedHeight( 20 ); 135 slider.setFixedHeight( 20 );
136 slider.setMinValue( 0 ); 136 slider.setMinValue( 0 );
137 slider.setMaxValue( 1 ); 137 slider.setMaxValue( 1 );
138 slider.setFocusPolicy( QWidget::NoFocus ); 138 slider.setFocusPolicy( QWidget::NoFocus );
139 slider.setBackgroundPixmap( *pixBg ); 139 slider.setBackgroundPixmap( *pixBg );
140 140
141 time.setFocusPolicy( QWidget::NoFocus ); 141 time.setFocusPolicy( QWidget::NoFocus );
142 time.setAlignment( Qt::AlignCenter ); 142 time.setAlignment( Qt::AlignCenter );
143 time.setFrame(FALSE); 143 time.setFrame(FALSE);
144 changeTextColor( &time ); 144 changeTextColor( &time );
145 145
146 resizeEvent( NULL ); 146 resizeEvent( NULL );
147 147
148 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); 148 connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) );
149 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); 149 connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) );
150 150
151 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); 151 connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) );
152 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); 152 connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) );
153 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); 153 connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) );
154// connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 154// connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
155 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); 155 connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) );
156 156
157 // Intialise state 157 // Intialise state
158 setLength( mediaPlayerState->length() ); 158 setLength( mediaPlayerState->length() );
159 setPosition( mediaPlayerState->position() ); 159 setPosition( mediaPlayerState->position() );
160 setLooping( mediaPlayerState->fullscreen() ); 160 setLooping( mediaPlayerState->fullscreen() );
161// setPaused( mediaPlayerState->paused() ); 161// setPaused( mediaPlayerState->paused() );
162 setPlaying( mediaPlayerState->playing() ); 162 setPlaying( mediaPlayerState->playing() );
163 163
164} 164}
165 165
166 166
167AudioWidget::~AudioWidget() { 167AudioWidget::~AudioWidget() {
168 168
169 for ( int i = 0; i < 10; i++ ) { 169 for ( int i = 0; i < 10; i++ ) {
170 delete buttonPixUp[i]; 170 delete buttonPixUp[i];
171 delete buttonPixDown[i]; 171 delete buttonPixDown[i];
172 } 172 }
173 delete pixBg; 173 delete pixBg;
174 delete imgUp; 174 delete imgUp;
175 delete imgDn; 175 delete imgDn;
176 delete imgButtonMask; 176 delete imgButtonMask;
177 for ( int i = 0; i < 10; i++ ) { 177 for ( int i = 0; i < 10; i++ ) {
178 delete masks[i]; 178 delete masks[i];
179 } 179 }
180} 180}
181 181
182 182
183QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { 183QPixmap *combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) {
184 QPixmap pix( img.width(), img.height() ); 184 QPixmap pix( img.width(), img.height() );
185 QPainter p( &pix ); 185 QPainter p( &pix );
186 p.drawTiledPixmap( pix.rect(), bg, offset ); 186 p.drawTiledPixmap( pix.rect(), bg, offset );
187 p.drawImage( 0, 0, img ); 187 p.drawImage( 0, 0, img );
188 return new QPixmap( pix ); 188 return new QPixmap( pix );
189} 189}
190 190
191 191
192QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) 192QPixmap *maskPixToMask( QPixmap pix, QBitmap mask )
193{ 193{
194 QPixmap *pixmap = new QPixmap( pix ); 194 QPixmap *pixmap = new QPixmap( pix );
195 pixmap->setMask( mask ); 195 pixmap->setMask( mask );
196 return pixmap; 196 return pixmap;
197} 197}
198 198
199 199
200 200
201void AudioWidget::resizeEvent( QResizeEvent * ) { 201void AudioWidget::resizeEvent( QResizeEvent * ) {
202 int h = height(); 202 int h = height();
203 int w = width(); 203 int w = width();
204 204
205 songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) ); 205 songInfo.setGeometry( QRect( 2, 10, w - 4, 20 ) );
206 slider.setFixedWidth( w - 110 ); 206 slider.setFixedWidth( w - 110 );
207 slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) ); 207 slider.setGeometry( QRect( 15, h - 30, w - 90, 20 ) );
208 slider.setBackgroundOrigin( QWidget::ParentOrigin ); 208 slider.setBackgroundOrigin( QWidget::ParentOrigin );
209 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); 209 time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) );
210 210
211 xoff = ( w - imgUp->width() ) / 2; 211 xoff = ( w - imgUp->width() ) / 2;
212 yoff = (( h - imgUp->height() ) / 2) - 10; 212 yoff = (( h - imgUp->height() ) / 2) - 10;
213 QPoint p( xoff, yoff ); 213 QPoint p( xoff, yoff );
214 214
215 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p ); 215 QPixmap *pixUp = combineImageWithBackground( *imgUp, *pixBg, p );
216 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p ); 216 QPixmap *pixDn = combineImageWithBackground( *imgDn, *pixBg, p );
217 217
218 for ( int i = 0; i < 10; i++ ) { 218 for ( int i = 0; i < 10; i++ ) {
219 if ( !masks[i]->isNull() ) { 219 if ( !masks[i]->isNull() ) {
220 delete buttonPixUp[i]; 220 delete buttonPixUp[i];
221 delete buttonPixDown[i]; 221 delete buttonPixDown[i];
222 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] ); 222 buttonPixUp[i] = maskPixToMask( *pixUp, *masks[i] );
223 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] ); 223 buttonPixDown[i] = maskPixToMask( *pixDn, *masks[i] );
224 } 224 }
225 } 225 }
226 226
227 delete pixUp; 227 delete pixUp;
228 delete pixDn; 228 delete pixDn;
229} 229}
230 230
231 231
232static bool audioSliderBeingMoved = FALSE; 232static bool audioSliderBeingMoved = FALSE;
233 233
234void AudioWidget::sliderPressed() { 234void AudioWidget::sliderPressed() {
235 audioSliderBeingMoved = TRUE; 235 audioSliderBeingMoved = TRUE;
236} 236}
237 237
238 238
239void AudioWidget::sliderReleased() { 239void AudioWidget::sliderReleased() {
240 audioSliderBeingMoved = FALSE; 240 audioSliderBeingMoved = FALSE;
241 if ( slider.width() == 0 ) 241 if ( slider.width() == 0 )
242 return; 242 return;
243 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); 243 long val = long((double)slider.value() * mediaPlayerState->length() / slider.width());
244 mediaPlayerState->setPosition( val ); 244 mediaPlayerState->setPosition( val );
245} 245}
246 246
247 247
248void AudioWidget::setPosition( long i ) { 248void AudioWidget::setPosition( long i ) {
249// qDebug("set position %d",i); 249// qDebug("set position %d",i);
250 long length = mediaPlayerState->length(); 250 long length = mediaPlayerState->length();
251 updateSlider( i, length ); 251 updateSlider( i, length );
252} 252}
253 253
254 254
255void AudioWidget::setLength( long max ) { 255void AudioWidget::setLength( long max ) {
256 updateSlider( mediaPlayerState->position(), max ); 256 updateSlider( mediaPlayerState->position(), max );
257} 257}
258 258
259 259
260void AudioWidget::setView( char view ) { 260void AudioWidget::setView( char view ) {
261 261
262 if (mediaPlayerState->isStreaming) { 262 if (mediaPlayerState->isStreaming) {
263 if( !slider.isHidden()) slider.hide(); 263 if( !slider.isHidden()) slider.hide();
264 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 264 disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
265 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 265 disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
266 } else { 266 } else {
267// this stops the slider from being moved, thus 267// this stops the slider from being moved, thus
268 // does not stop stream when it reaches the end 268 // does not stop stream when it reaches the end
269 slider.show(); 269 slider.show();
270 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); 270 connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) );
271 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); 271 connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) );
272 } 272 }
273 273
274 if ( view == 'a' ) { 274 if ( view == 'a' ) {
275 startTimer( 150 ); 275 startTimer( 150 );
276// show(); 276// show();
277 showMaximized(); 277 showMaximized();
278 } else { 278 } else {
279 killTimers(); 279 killTimers();
280 hide(); 280 hide();
281 } 281 }
282} 282}