-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/om3u.cpp | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index b573c45..3d6428d 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -1,272 +1,272 @@ | |||
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 | ||
53 | static const int xo = -2; // movable x offset | 53 | static const int xo = -2; // movable x offset |
54 | static const int yo = 22; // movable y offset | 54 | static const int yo = 22; // movable y offset |
55 | 55 | ||
56 | struct MediaButton { | 56 | struct MediaButton { |
57 | bool isToggle, isHeld, isDown; | 57 | bool isToggle, isHeld, isDown; |
58 | }; | 58 | }; |
59 | 59 | ||
60 | //Layout information for the audioButtons (and if it is a toggle button or not) | 60 | //Layout information for the audioButtons (and if it is a toggle button or not) |
61 | MediaButton audioButtons[] = { | 61 | MediaButton audioButtons[] = { |
62 | { TRUE, FALSE, FALSE }, // play | 62 | { TRUE, FALSE, FALSE }, // play |
63 | { FALSE, FALSE, FALSE }, // stop | 63 | { FALSE, FALSE, FALSE }, // stop |
64 | { FALSE, FALSE, FALSE }, // next | 64 | { FALSE, FALSE, FALSE }, // next |
65 | { FALSE, FALSE, FALSE }, // previous | 65 | { FALSE, FALSE, FALSE }, // previous |
66 | { FALSE, FALSE, FALSE }, // volume up | 66 | { FALSE, FALSE, FALSE }, // volume up |
67 | { FALSE, FALSE, FALSE }, // volume down | 67 | { FALSE, FALSE, FALSE }, // volume down |
68 | { TRUE, FALSE, FALSE }, // repeat/loop | 68 | { TRUE, FALSE, FALSE }, // repeat/loop |
69 | { FALSE, FALSE, FALSE }, // playlist | 69 | { FALSE, FALSE, FALSE }, // playlist |
70 | { FALSE, FALSE, FALSE }, // forward | 70 | { FALSE, FALSE, FALSE }, // forward |
71 | { FALSE, FALSE, FALSE } // back | 71 | { FALSE, FALSE, FALSE } // back |
72 | }; | 72 | }; |
73 | 73 | ||
74 | const char * const skin_mask_file_names[10] = { | 74 | const char * const skin_mask_file_names[10] = { |
75 | "play", "stop", "next", "prev", "up", | 75 | "play", "stop", "next", "prev", "up", |
76 | "down", "loop", "playlist", "forward", "back" | 76 | "down", "loop", "playlist", "forward", "back" |
77 | }; | 77 | }; |
78 | 78 | ||
79 | 79 | ||
80 | static void changeTextColor( QWidget *w ) { | 80 | static void changeTextColor( QWidget * ) { |
81 | QPalette p = w->palette(); | 81 | QPalette p = w->palette(); |
82 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); | 82 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); |
83 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); | 83 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); |
84 | w->setPalette( p ); | 84 | w->setPalette( p ); |
85 | } | 85 | } |
86 | 86 | ||
87 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); | 87 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); |
88 | 88 | ||
89 | 89 | ||
90 | AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : | 90 | AudioWidget::AudioWidget( PlayListWidget &playList, MediaPlayerState &mediaPlayerState, QWidget* parent, const char* name) : |
91 | 91 | ||
92 | MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { | 92 | MediaWidget( playList, mediaPlayerState, parent, name ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { |
93 | 93 | ||
94 | setCaption( tr("OpiePlayer") ); | 94 | setCaption( tr("OpiePlayer") ); |
95 | 95 | ||
96 | Config cfg("OpiePlayer"); | 96 | Config cfg("OpiePlayer"); |
97 | cfg.setGroup("Options"); | 97 | cfg.setGroup("Options"); |
98 | skin = cfg.readEntry("Skin","default"); | 98 | skin = cfg.readEntry("Skin","default"); |
99 | //skin = "scaleTest"; | 99 | //skin = "scaleTest"; |
100 | // color of background, frame, degree of transparency | 100 | // color of background, frame, degree of transparency |
101 | 101 | ||
102 | QString skinPath = "opieplayer2/skins/" + skin; | 102 | QString skinPath = "opieplayer2/skins/" + skin; |
103 | pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 103 | pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
104 | imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); | 104 | imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); |
105 | imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); | 105 | imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); |
106 | 106 | ||
107 | imgButtonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); | 107 | imgButtonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); |
108 | imgButtonMask.fill( 0 ); | 108 | imgButtonMask.fill( 0 ); |
109 | 109 | ||
110 | for ( int i = 0; i < 10; i++ ) { | 110 | for ( int i = 0; i < 10; i++ ) { |
111 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" ); | 111 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" ); |
112 | masks[i] = new QBitmap( filename ); | 112 | masks[i] = new QBitmap( filename ); |
113 | 113 | ||
114 | if ( !masks[i]->isNull() ) { | 114 | if ( !masks[i]->isNull() ) { |
115 | QImage imgMask = masks[i]->convertToImage(); | 115 | QImage imgMask = masks[i]->convertToImage(); |
116 | uchar **dest = imgButtonMask.jumpTable(); | 116 | uchar **dest = imgButtonMask.jumpTable(); |
117 | for ( int y = 0; y < imgUp.height(); y++ ) { | 117 | for ( int y = 0; y < imgUp.height(); y++ ) { |
118 | uchar *line = dest[y]; | 118 | uchar *line = dest[y]; |
119 | for ( int x = 0; x < imgUp.width(); x++ ) | 119 | for ( int x = 0; x < imgUp.width(); x++ ) |
120 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 120 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
121 | line[x] = i + 1; | 121 | line[x] = i + 1; |
122 | } | 122 | } |
123 | } | 123 | } |
124 | 124 | ||
125 | } | 125 | } |
126 | 126 | ||
127 | for ( int i = 0; i < 10; i++ ) { | 127 | for ( int i = 0; i < 10; i++ ) { |
128 | buttonPixUp[i] = 0l; | 128 | buttonPixUp[i] = 0l; |
129 | buttonPixDown[i] = 0l; | 129 | buttonPixDown[i] = 0l; |
130 | } | 130 | } |
131 | 131 | ||
132 | setBackgroundPixmap( pixBg ); | 132 | setBackgroundPixmap( pixBg ); |
133 | 133 | ||
134 | songInfo.setFocusPolicy( QWidget::NoFocus ); | 134 | songInfo.setFocusPolicy( QWidget::NoFocus ); |
135 | // changeTextColor( &songInfo ); | 135 | // changeTextColor( &songInfo ); |
136 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); | 136 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); |
137 | // songInfo.setFrameStyle( QFrame::NoFrame); | 137 | // songInfo.setFrameStyle( QFrame::NoFrame); |
138 | songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); | 138 | songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); |
139 | // songInfo.setForegroundColor(Qt::white); | 139 | // songInfo.setForegroundColor(Qt::white); |
140 | 140 | ||
141 | slider.setFixedHeight( 20 ); | 141 | slider.setFixedHeight( 20 ); |
142 | slider.setMinValue( 0 ); | 142 | slider.setMinValue( 0 ); |
143 | slider.setMaxValue( 1 ); | 143 | slider.setMaxValue( 1 ); |
144 | slider.setFocusPolicy( QWidget::NoFocus ); | 144 | slider.setFocusPolicy( QWidget::NoFocus ); |
145 | slider.setBackgroundPixmap( pixBg ); | 145 | slider.setBackgroundPixmap( pixBg ); |
146 | 146 | ||
147 | // Config cofg("qpe"); | 147 | // Config cofg("qpe"); |
148 | // cofg.setGroup("Appearance"); | 148 | // cofg.setGroup("Appearance"); |
149 | // QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); | 149 | // QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); |
150 | 150 | ||
151 | time.setFocusPolicy( QWidget::NoFocus ); | 151 | time.setFocusPolicy( QWidget::NoFocus ); |
152 | time.setAlignment( Qt::AlignCenter ); | 152 | time.setAlignment( Qt::AlignCenter ); |
153 | 153 | ||
154 | // time.setFrame(FALSE); | 154 | // time.setFrame(FALSE); |
155 | // changeTextColor( &time ); | 155 | // changeTextColor( &time ); |
156 | 156 | ||
157 | resizeEvent( NULL ); | 157 | resizeEvent( NULL ); |
158 | 158 | ||
159 | connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); | 159 | connect( &mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); |
160 | connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); | 160 | connect( &mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); |
161 | 161 | ||
162 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); | 162 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); |
163 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); | 163 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); |
164 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); | 164 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); |
165 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); | 165 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); |
166 | 166 | ||
167 | // Intialise state | 167 | // Intialise state |
168 | setLength( mediaPlayerState.length() ); | 168 | setLength( mediaPlayerState.length() ); |
169 | setPosition( mediaPlayerState.position() ); | 169 | setPosition( mediaPlayerState.position() ); |
170 | setLooping( mediaPlayerState.isFullscreen() ); | 170 | setLooping( mediaPlayerState.isFullscreen() ); |
171 | // setPaused( mediaPlayerState->paused() ); | 171 | // setPaused( mediaPlayerState->paused() ); |
172 | setPlaying( mediaPlayerState.isPlaying() ); | 172 | setPlaying( mediaPlayerState.isPlaying() ); |
173 | 173 | ||
174 | } | 174 | } |
175 | 175 | ||
176 | AudioWidget::~AudioWidget() { | 176 | AudioWidget::~AudioWidget() { |
177 | 177 | ||
178 | for ( int i = 0; i < 10; i++ ) { | 178 | for ( int i = 0; i < 10; i++ ) { |
179 | delete buttonPixUp[i]; | 179 | delete buttonPixUp[i]; |
180 | delete buttonPixDown[i]; | 180 | delete buttonPixDown[i]; |
181 | } | 181 | } |
182 | for ( int i = 0; i < 10; i++ ) { | 182 | for ( int i = 0; i < 10; i++ ) { |
183 | delete masks[i]; | 183 | delete masks[i]; |
184 | } | 184 | } |
185 | // mediaPlayerState->setPlaying(false); | 185 | // mediaPlayerState->setPlaying(false); |
186 | } | 186 | } |
187 | 187 | ||
188 | namespace { | 188 | namespace { |
189 | 189 | ||
190 | QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 190 | QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
191 | QPixmap pix( img.width(), img.height() ); | 191 | QPixmap pix( img.width(), img.height() ); |
192 | QPainter p( &pix ); | 192 | QPainter p( &pix ); |
193 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 193 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
194 | p.drawImage( 0, 0, img ); | 194 | p.drawImage( 0, 0, img ); |
195 | return pix; | 195 | return pix; |
196 | } | 196 | } |
197 | 197 | ||
198 | 198 | ||
199 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { | 199 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { |
200 | QPixmap *pixmap = new QPixmap( pix ); | 200 | QPixmap *pixmap = new QPixmap( pix ); |
201 | pixmap->setMask( mask ); | 201 | pixmap->setMask( mask ); |
202 | return pixmap; | 202 | return pixmap; |
203 | } | 203 | } |
204 | 204 | ||
205 | }; | 205 | }; |
206 | 206 | ||
207 | void AudioWidget::resizeEvent( QResizeEvent * ) { | 207 | void AudioWidget::resizeEvent( QResizeEvent * ) { |
208 | int h = height(); | 208 | int h = height(); |
209 | int w = width(); | 209 | int w = width(); |
210 | 210 | ||
211 | songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); | 211 | songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); |
212 | slider.setFixedWidth( w - 110 ); | 212 | slider.setFixedWidth( w - 110 ); |
213 | slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); | 213 | slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); |
214 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); | 214 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); |
215 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); | 215 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); |
216 | 216 | ||
217 | xoff = ( w - imgUp.width() ) / 2; | 217 | xoff = ( w - imgUp.width() ) / 2; |
218 | yoff = (( h - imgUp.height() ) / 2) - 10; | 218 | yoff = (( h - imgUp.height() ) / 2) - 10; |
219 | QPoint p( xoff, yoff ); | 219 | QPoint p( xoff, yoff ); |
220 | 220 | ||
221 | QPixmap pixUp = combineImageWithBackground( imgUp, pixBg, p ); | 221 | QPixmap pixUp = combineImageWithBackground( imgUp, pixBg, p ); |
222 | QPixmap pixDn = combineImageWithBackground( imgDn, pixBg, p ); | 222 | QPixmap pixDn = combineImageWithBackground( imgDn, pixBg, p ); |
223 | 223 | ||
224 | for ( int i = 0; i < 10; i++ ) { | 224 | for ( int i = 0; i < 10; i++ ) { |
225 | if ( !masks[i]->isNull() ) { | 225 | if ( !masks[i]->isNull() ) { |
226 | delete buttonPixUp[i]; | 226 | delete buttonPixUp[i]; |
227 | delete buttonPixDown[i]; | 227 | delete buttonPixDown[i]; |
228 | buttonPixUp[i] = maskPixToMask( pixUp, *masks[i] ); | 228 | buttonPixUp[i] = maskPixToMask( pixUp, *masks[i] ); |
229 | buttonPixDown[i] = maskPixToMask( pixDn, *masks[i] ); | 229 | buttonPixDown[i] = maskPixToMask( pixDn, *masks[i] ); |
230 | } | 230 | } |
231 | } | 231 | } |
232 | } | 232 | } |
233 | 233 | ||
234 | static bool audioSliderBeingMoved = FALSE; | 234 | static bool audioSliderBeingMoved = FALSE; |
235 | 235 | ||
236 | 236 | ||
237 | void AudioWidget::sliderPressed() { | 237 | void AudioWidget::sliderPressed() { |
238 | audioSliderBeingMoved = TRUE; | 238 | audioSliderBeingMoved = TRUE; |
239 | } | 239 | } |
240 | 240 | ||
241 | 241 | ||
242 | void AudioWidget::sliderReleased() { | 242 | void AudioWidget::sliderReleased() { |
243 | audioSliderBeingMoved = FALSE; | 243 | audioSliderBeingMoved = FALSE; |
244 | if ( slider.width() == 0 ) | 244 | if ( slider.width() == 0 ) |
245 | return; | 245 | return; |
246 | long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); | 246 | long val = long((double)slider.value() * mediaPlayerState.length() / slider.width()); |
247 | mediaPlayerState.setPosition( val ); | 247 | mediaPlayerState.setPosition( val ); |
248 | } | 248 | } |
249 | 249 | ||
250 | void AudioWidget::setPosition( long i ) { | 250 | void AudioWidget::setPosition( long i ) { |
251 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); | 251 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); |
252 | updateSlider( i, mediaPlayerState.length() ); | 252 | updateSlider( i, mediaPlayerState.length() ); |
253 | } | 253 | } |
254 | 254 | ||
255 | 255 | ||
256 | void AudioWidget::setLength( long max ) { | 256 | void AudioWidget::setLength( long max ) { |
257 | updateSlider( mediaPlayerState.position(), max ); | 257 | updateSlider( mediaPlayerState.position(), max ); |
258 | } | 258 | } |
259 | 259 | ||
260 | 260 | ||
261 | void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { | 261 | void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { |
262 | if ( mediaType == MediaPlayerState::Audio ) { | 262 | if ( mediaType == MediaPlayerState::Audio ) { |
263 | // startTimer( 150 ); | 263 | // startTimer( 150 ); |
264 | showMaximized(); | 264 | showMaximized(); |
265 | return; | 265 | return; |
266 | } | 266 | } |
267 | 267 | ||
268 | killTimers(); | 268 | killTimers(); |
269 | hide(); | 269 | hide(); |
270 | } | 270 | } |
271 | 271 | ||
272 | 272 | ||
diff --git a/noncore/multimedia/opieplayer2/om3u.cpp b/noncore/multimedia/opieplayer2/om3u.cpp index 4617c59..235d973 100644 --- a/noncore/multimedia/opieplayer2/om3u.cpp +++ b/noncore/multimedia/opieplayer2/om3u.cpp | |||
@@ -1,165 +1,165 @@ | |||
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 L. Potter <ljp@llornkcor.com> | 4 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; General Public License for more | 20 | ..}^=.= = ; General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = General Public License along with | 24 | -_. . . )=. = General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #include "playlistwidget.h" | 32 | #include "playlistwidget.h" |
33 | #include "om3u.h" | 33 | #include "om3u.h" |
34 | 34 | ||
35 | #include <qpe/applnk.h> | 35 | #include <qpe/applnk.h> |
36 | #include <qpe/qpeapplication.h> | 36 | #include <qpe/qpeapplication.h> |
37 | #include <qpe/storage.h> | 37 | #include <qpe/storage.h> |
38 | #include <qpe/mimetype.h> | 38 | #include <qpe/mimetype.h> |
39 | #include <qpe/global.h> | 39 | #include <qpe/global.h> |
40 | #include <qpe/resource.h> | 40 | #include <qpe/resource.h> |
41 | 41 | ||
42 | #include <qdir.h> | 42 | #include <qdir.h> |
43 | #include <qregexp.h> | 43 | #include <qregexp.h> |
44 | #include <qstring.h> | 44 | #include <qstring.h> |
45 | #include <qtextstream.h> | 45 | #include <qtextstream.h> |
46 | #include <qstringlist.h> | 46 | #include <qstringlist.h> |
47 | #include <qcstring.h> | 47 | #include <qcstring.h> |
48 | 48 | ||
49 | //extern PlayListWidget *playList; | 49 | //extern PlayListWidget *playList; |
50 | 50 | ||
51 | Om3u::Om3u( const QString &filePath, int mode) | 51 | Om3u::Om3u( const QString &filePath, int mode) |
52 | : QStringList (){ | 52 | : QStringList (){ |
53 | qDebug("<<<<<<<new m3u "+filePath); | 53 | qDebug("<<<<<<<new m3u "+filePath); |
54 | f.setName(filePath); | 54 | f.setName(filePath); |
55 | f.open(mode); | 55 | f.open(mode); |
56 | } | 56 | } |
57 | 57 | ||
58 | Om3u::~Om3u(){} | 58 | Om3u::~Om3u(){} |
59 | 59 | ||
60 | void Om3u::readM3u() { | 60 | void Om3u::readM3u() { |
61 | // qDebug("<<<<<<reading m3u "+f.name()); | 61 | // qDebug("<<<<<<reading m3u "+f.name()); |
62 | QTextStream t(&f); | 62 | QTextStream t(&f); |
63 | QString s; | 63 | QString s; |
64 | while ( !t.atEnd() ) { | 64 | while ( !t.atEnd() ) { |
65 | s=t.readLine(); | 65 | s=t.readLine(); |
66 | // qDebug(s); | 66 | // qDebug(s); |
67 | if( s.find( "#", 0, TRUE) == -1 ) { | 67 | if( s.find( "#", 0, TRUE) == -1 ) { |
68 | if( s.left(2) == "E:" || s.left(2) == "P:" ) { | 68 | if( s.left(2) == "E:" || s.left(2) == "P:" ) { |
69 | s = s.right( s.length() -2 ); | 69 | s = s.right( s.length() -2 ); |
70 | QFileInfo f( s ); | 70 | QFileInfo f( s ); |
71 | QString name = f.baseName(); | 71 | QString name = f.baseName(); |
72 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); | 72 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE ) -1 ); |
73 | s=s.replace( QRegExp( "\\" ), "/" ); | 73 | s=s.replace( QRegExp( "\\" ), "/" ); |
74 | append(s); | 74 | append(s); |
75 | // qDebug(s); | 75 | // qDebug(s); |
76 | } else { // is url | 76 | } else { // is url |
77 | s.replace( QRegExp( "%20" )," " ); | 77 | s.replace( QRegExp( "%20" )," " ); |
78 | QString name; | 78 | QString name; |
79 | // if( name.left( 4 ) == "http" ) { | 79 | // if( name.left( 4 ) == "http" ) { |
80 | // name = s.right( s.length() - 7 ); | 80 | // name = s.right( s.length() - 7 ); |
81 | // } else { | 81 | // } else { |
82 | name = s; | 82 | name = s; |
83 | // } | 83 | // } |
84 | append(name); | 84 | append(name); |
85 | // qDebug(name); | 85 | // qDebug(name); |
86 | } | 86 | } |
87 | } | 87 | } |
88 | } | 88 | } |
89 | } | 89 | } |
90 | 90 | ||
91 | void Om3u::readPls() { //it's a pls file | 91 | void Om3u::readPls() { //it's a pls file |
92 | QTextStream t( &f ); | 92 | QTextStream t( &f ); |
93 | QString s; | 93 | QString s; |
94 | while ( !t.atEnd() ) { | 94 | while ( !t.atEnd() ) { |
95 | s = t.readLine(); | 95 | s = t.readLine(); |
96 | if( s.left(4) == "File" ) { | 96 | if( s.left(4) == "File" ) { |
97 | s = s.right( s.length() - 6 ); | 97 | s = s.right( s.length() - 6 ); |
98 | s.replace( QRegExp( "%20" )," "); | 98 | s.replace( QRegExp( "%20" )," "); |
99 | // qDebug( "adding " + s + " to playlist" ); | 99 | // qDebug( "adding " + s + " to playlist" ); |
100 | // numberofentries=2 | 100 | // numberofentries=2 |
101 | // File1=http | 101 | // File1=http |
102 | // Title | 102 | // Title |
103 | // Length | 103 | // Length |
104 | // Version | 104 | // Version |
105 | // File2=http | 105 | // File2=http |
106 | s = s.replace( QRegExp( "\\" ), "/" ); | 106 | s = s.replace( QRegExp( "\\" ), "/" ); |
107 | QFileInfo f( s ); | 107 | QFileInfo f( s ); |
108 | QString name = f.baseName(); | 108 | QString name = f.baseName(); |
109 | if( name.left( 4 ) == "http" ) { | 109 | if( name.left( 4 ) == "http" ) { |
110 | name = s.right( s.length() - 7); | 110 | name = s.right( s.length() - 7); |
111 | } else { | 111 | } else { |
112 | name = s; | 112 | name = s; |
113 | } | 113 | } |
114 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); | 114 | name = name.right( name.length() - name.findRev( "\\", -1, TRUE) - 1 ); |
115 | if( s.at( s.length() - 4) == '.') // if this is probably a file | 115 | if( s.at( s.length() - 4) == '.') // if this is probably a file |
116 | append(s); | 116 | append(s); |
117 | else { //if its a url | 117 | else { //if its a url |
118 | // if( name.right( 1 ).find( '/' ) == -1) { | 118 | // if( name.right( 1 ).find( '/' ) == -1) { |
119 | // s += "/"; | 119 | // s += "/"; |
120 | // } | 120 | // } |
121 | append(s); | 121 | append(s); |
122 | } | 122 | } |
123 | } | 123 | } |
124 | } | 124 | } |
125 | } | 125 | } |
126 | 126 | ||
127 | void Om3u::write() { //writes list to m3u file | 127 | void Om3u::write() { //writes list to m3u file |
128 | QString list; | 128 | QString list; |
129 | if(count()>0) { | 129 | if(count()>0) { |
130 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { | 130 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { |
131 | // qDebug(*it); | 131 | // qDebug(*it); |
132 | list += *it+"\n"; | 132 | list += *it+"\n"; |
133 | } | 133 | } |
134 | f.writeBlock( list, list.length() ); | 134 | f.writeBlock( list, list.length() ); |
135 | } | 135 | } |
136 | // f.close(); | 136 | // f.close(); |
137 | } | 137 | } |
138 | 138 | ||
139 | void Om3u::add(const QString &filePath) { //adds to m3u file | 139 | void Om3u::add(const QString &filePath) { //adds to m3u file |
140 | append(filePath); | 140 | append(filePath); |
141 | } | 141 | } |
142 | 142 | ||
143 | void Om3u::remove(const QString &filePath) { //removes from m3u list | 143 | void Om3u::remove(const QString &filePath) { //removes from m3u list |
144 | QString list, currentFile; | 144 | QString list, currentFile; |
145 | if(count()>0) { | 145 | if(count()>0) { |
146 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { | 146 | for ( QStringList::ConstIterator it = begin(); it != end(); ++it ) { |
147 | currentFile=*it; | 147 | currentFile=*it; |
148 | // qDebug(*it); | 148 | // qDebug(*it); |
149 | 149 | ||
150 | if( filePath != currentFile) | 150 | if( filePath != currentFile) |
151 | list += currentFile+"\n"; | 151 | list += currentFile+"\n"; |
152 | } | 152 | } |
153 | f.writeBlock( list, list.length() ); | 153 | f.writeBlock( list, list.length() ); |
154 | } | 154 | } |
155 | } | 155 | } |
156 | 156 | ||
157 | void Om3u::deleteFile(const QString &filePath) {//deletes m3u file | 157 | void Om3u::deleteFile(const QString &/*filePath*/) {//deletes m3u file |
158 | f.close(); | 158 | f.close(); |
159 | f.remove(); | 159 | f.remove(); |
160 | 160 | ||
161 | } | 161 | } |
162 | 162 | ||
163 | void Om3u::close() { //closes m3u file | 163 | void Om3u::close() { //closes m3u file |
164 | f.close(); | 164 | f.close(); |
165 | } | 165 | } |