author | llornkcor <llornkcor> | 2002-12-05 00:24:55 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-12-05 00:24:55 (UTC) |
commit | 1763bcf5df7bf5564a88d41be88cbb882c85a7c0 (patch) (unidiff) | |
tree | 04165a4a1c31f84daa4a1aebeacc86da20e5662d | |
parent | 35d40e65116cee8b430cdc586db187f81488aa1d (diff) | |
download | opie-1763bcf5df7bf5564a88d41be88cbb882c85a7c0.zip opie-1763bcf5df7bf5564a88d41be88cbb882c85a7c0.tar.gz opie-1763bcf5df7bf5564a88d41be88cbb882c85a7c0.tar.bz2 |
trying to keep up with tronical.. just removed unused parameters.
-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,517 +1,517 @@ | |||
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 | ||
273 | void AudioWidget::setSeekable( bool isSeekable ) { | 273 | void AudioWidget::setSeekable( bool isSeekable ) { |
274 | 274 | ||
275 | if ( !isSeekable ) { | 275 | if ( !isSeekable ) { |
276 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); | 276 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); |
277 | if( !slider.isHidden()) { | 277 | if( !slider.isHidden()) { |
278 | slider.hide(); | 278 | slider.hide(); |
279 | } | 279 | } |
280 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 280 | disconnect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
281 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 281 | disconnect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
282 | disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 282 | disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
283 | disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 283 | disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
284 | } else { | 284 | } else { |
285 | // this stops the slider from being moved, thus | 285 | // this stops the slider from being moved, thus |
286 | // does not stop stream when it reaches the end | 286 | // does not stop stream when it reaches the end |
287 | slider.show(); | 287 | slider.show(); |
288 | qDebug( " CONNECT SET POSTION " ); | 288 | qDebug( " CONNECT SET POSTION " ); |
289 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 289 | connect( &mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
290 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 290 | connect( &mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
291 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 291 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
292 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 292 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
293 | } | 293 | } |
294 | } | 294 | } |
295 | 295 | ||
296 | 296 | ||
297 | static QString timeAsString( long length ) { | 297 | static QString timeAsString( long length ) { |
298 | int minutes = length / 60; | 298 | int minutes = length / 60; |
299 | int seconds = length % 60; | 299 | int seconds = length % 60; |
300 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); | 300 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); |
301 | } | 301 | } |
302 | 302 | ||
303 | void AudioWidget::updateSlider( long i, long max ) { | 303 | void AudioWidget::updateSlider( long i, long max ) { |
304 | 304 | ||
305 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); | 305 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); |
306 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; | 306 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; |
307 | 307 | ||
308 | if ( max == 0 ) { | 308 | if ( max == 0 ) { |
309 | return; | 309 | return; |
310 | } | 310 | } |
311 | // Will flicker too much if we don't do this | 311 | // Will flicker too much if we don't do this |
312 | // Scale to something reasonable | 312 | // Scale to something reasonable |
313 | int width = slider.width(); | 313 | int width = slider.width(); |
314 | int val = int((double)i * width / max); | 314 | int val = int((double)i * width / max); |
315 | if ( !audioSliderBeingMoved ) { | 315 | if ( !audioSliderBeingMoved ) { |
316 | if ( slider.value() != val ) { | 316 | if ( slider.value() != val ) { |
317 | slider.setValue( val ); | 317 | slider.setValue( val ); |
318 | } | 318 | } |
319 | 319 | ||
320 | if ( slider.maxValue() != width ) { | 320 | if ( slider.maxValue() != width ) { |
321 | slider.setMaxValue( width ); | 321 | slider.setMaxValue( width ); |
322 | } | 322 | } |
323 | } | 323 | } |
324 | } | 324 | } |
325 | 325 | ||
326 | 326 | ||
327 | void AudioWidget::setToggleButton( int i, bool down ) { | 327 | void AudioWidget::setToggleButton( int i, bool down ) { |
328 | qDebug("setToggleButton %d", i); | 328 | qDebug("setToggleButton %d", i); |
329 | if ( down != audioButtons[i].isDown ) { | 329 | if ( down != audioButtons[i].isDown ) { |
330 | toggleButton( i ); | 330 | toggleButton( i ); |
331 | } | 331 | } |
332 | } | 332 | } |
333 | 333 | ||
334 | 334 | ||
335 | void AudioWidget::toggleButton( int i ) { | 335 | void AudioWidget::toggleButton( int i ) { |
336 | audioButtons[i].isDown = !audioButtons[i].isDown; | 336 | audioButtons[i].isDown = !audioButtons[i].isDown; |
337 | QPainter p(this); | 337 | QPainter p(this); |
338 | paintButton ( &p, i ); | 338 | paintButton ( &p, i ); |
339 | } | 339 | } |
340 | 340 | ||
341 | 341 | ||
342 | void AudioWidget::paintButton( QPainter *p, int i ) { | 342 | void AudioWidget::paintButton( QPainter *p, int i ) { |
343 | if ( audioButtons[i].isDown ) { | 343 | if ( audioButtons[i].isDown ) { |
344 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | 344 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); |
345 | } else { | 345 | } else { |
346 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | 346 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); |
347 | } | 347 | } |
348 | } | 348 | } |
349 | 349 | ||
350 | 350 | ||
351 | void AudioWidget::skipFor() { | 351 | void AudioWidget::skipFor() { |
352 | skipDirection = +1; | 352 | skipDirection = +1; |
353 | startTimer( 50 ); | 353 | startTimer( 50 ); |
354 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); | 354 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); |
355 | } | 355 | } |
356 | 356 | ||
357 | void AudioWidget::skipBack() { | 357 | void AudioWidget::skipBack() { |
358 | skipDirection = -1; | 358 | skipDirection = -1; |
359 | startTimer( 50 ); | 359 | startTimer( 50 ); |
360 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); | 360 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); |
361 | } | 361 | } |
362 | 362 | ||
363 | 363 | ||
364 | 364 | ||
365 | void AudioWidget::stopSkip() { | 365 | void AudioWidget::stopSkip() { |
366 | killTimers(); | 366 | killTimers(); |
367 | } | 367 | } |
368 | 368 | ||
369 | 369 | ||
370 | void AudioWidget::timerEvent( QTimerEvent * ) { | 370 | void AudioWidget::timerEvent( QTimerEvent * ) { |
371 | if ( skipDirection == +1 ) { | 371 | if ( skipDirection == +1 ) { |
372 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); | 372 | mediaPlayerState.setPosition( mediaPlayerState.position() + 2 ); |
373 | } else if ( skipDirection == -1 ) { | 373 | } else if ( skipDirection == -1 ) { |
374 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); | 374 | mediaPlayerState.setPosition( mediaPlayerState.position() - 2 ); |
375 | } | 375 | } |
376 | } | 376 | } |
377 | 377 | ||
378 | 378 | ||
379 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | 379 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { |
380 | for ( int i = 0; i < numButtons; i++ ) { | 380 | for ( int i = 0; i < numButtons; i++ ) { |
381 | if ( event->state() == QMouseEvent::LeftButton ) { | 381 | if ( event->state() == QMouseEvent::LeftButton ) { |
382 | // The test to see if the mouse click is inside the button or not | 382 | // The test to see if the mouse click is inside the button or not |
383 | int x = event->pos().x() - xoff; | 383 | int x = event->pos().x() - xoff; |
384 | int y = event->pos().y() - yoff; | 384 | int y = event->pos().y() - yoff; |
385 | 385 | ||
386 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask.width() | 386 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask.width() |
387 | && y < imgButtonMask.height() | 387 | && y < imgButtonMask.height() |
388 | && imgButtonMask.pixelIndex( x, y ) == i + 1 ); | 388 | && imgButtonMask.pixelIndex( x, y ) == i + 1 ); |
389 | 389 | ||
390 | if ( isOnButton && !audioButtons[i].isHeld ) { | 390 | if ( isOnButton && !audioButtons[i].isHeld ) { |
391 | audioButtons[i].isHeld = TRUE; | 391 | audioButtons[i].isHeld = TRUE; |
392 | toggleButton(i); | 392 | toggleButton(i); |
393 | switch (i) { | 393 | switch (i) { |
394 | case VolumeUp: | 394 | case VolumeUp: |
395 | emit moreClicked(); | 395 | emit moreClicked(); |
396 | return; | 396 | return; |
397 | case VolumeDown: | 397 | case VolumeDown: |
398 | emit lessClicked(); | 398 | emit lessClicked(); |
399 | return; | 399 | return; |
400 | case Forward: | 400 | case Forward: |
401 | emit forwardClicked(); | 401 | emit forwardClicked(); |
402 | return; | 402 | return; |
403 | case Back: | 403 | case Back: |
404 | emit backClicked(); | 404 | emit backClicked(); |
405 | return; | 405 | return; |
406 | } | 406 | } |
407 | } else if ( !isOnButton && audioButtons[i].isHeld ) { | 407 | } else if ( !isOnButton && audioButtons[i].isHeld ) { |
408 | audioButtons[i].isHeld = FALSE; | 408 | audioButtons[i].isHeld = FALSE; |
409 | toggleButton(i); | 409 | toggleButton(i); |
410 | } | 410 | } |
411 | } else { | 411 | } else { |
412 | if ( audioButtons[i].isHeld ) { | 412 | if ( audioButtons[i].isHeld ) { |
413 | audioButtons[i].isHeld = FALSE; | 413 | audioButtons[i].isHeld = FALSE; |
414 | if ( !audioButtons[i].isToggle ) { | 414 | if ( !audioButtons[i].isToggle ) { |
415 | setToggleButton( i, FALSE ); | 415 | setToggleButton( i, FALSE ); |
416 | } | 416 | } |
417 | qDebug("mouseEvent %d", i); | 417 | qDebug("mouseEvent %d", i); |
418 | handleCommand( static_cast<Command>( i ), audioButtons[ i ].isDown ); | 418 | handleCommand( static_cast<Command>( i ), audioButtons[ i ].isDown ); |
419 | } | 419 | } |
420 | } | 420 | } |
421 | } | 421 | } |
422 | } | 422 | } |
423 | 423 | ||
424 | 424 | ||
425 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { | 425 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { |
426 | mouseMoveEvent( event ); | 426 | mouseMoveEvent( event ); |
427 | } | 427 | } |
428 | 428 | ||
429 | 429 | ||
430 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { | 430 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { |
431 | mouseMoveEvent( event ); | 431 | mouseMoveEvent( event ); |
432 | } | 432 | } |
433 | 433 | ||
434 | 434 | ||
435 | void AudioWidget::showEvent( QShowEvent* ) { | 435 | void AudioWidget::showEvent( QShowEvent* ) { |
436 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 436 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
437 | mouseMoveEvent( &event ); | 437 | mouseMoveEvent( &event ); |
438 | } | 438 | } |
439 | 439 | ||
440 | 440 | ||
441 | void AudioWidget::paintEvent( QPaintEvent * pe ) { | 441 | void AudioWidget::paintEvent( QPaintEvent * pe ) { |
442 | if ( !pe->erased() ) { | 442 | if ( !pe->erased() ) { |
443 | // Combine with background and double buffer | 443 | // Combine with background and double buffer |
444 | QPixmap pix( pe->rect().size() ); | 444 | QPixmap pix( pe->rect().size() ); |
445 | QPainter p( &pix ); | 445 | QPainter p( &pix ); |
446 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 446 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
447 | p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); | 447 | p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); |
448 | for ( int i = 0; i < numButtons; i++ ) | 448 | for ( int i = 0; i < numButtons; i++ ) |
449 | paintButton( &p, i ); | 449 | paintButton( &p, i ); |
450 | QPainter p2( this ); | 450 | QPainter p2( this ); |
451 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 451 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
452 | } else { | 452 | } else { |
453 | QPainter p( this ); | 453 | QPainter p( this ); |
454 | for ( int i = 0; i < numButtons; i++ ) | 454 | for ( int i = 0; i < numButtons; i++ ) |
455 | paintButton( &p, i ); | 455 | paintButton( &p, i ); |
456 | } | 456 | } |
457 | } | 457 | } |
458 | 458 | ||
459 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { | 459 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { |
460 | switch ( e->key() ) { | 460 | switch ( e->key() ) { |
461 | ////////////////////////////// Zaurus keys | 461 | ////////////////////////////// Zaurus keys |
462 | case Key_Home: | 462 | case Key_Home: |
463 | break; | 463 | break; |
464 | case Key_F9: //activity | 464 | case Key_F9: //activity |
465 | hide(); | 465 | hide(); |
466 | // qDebug("Audio F9"); | 466 | // qDebug("Audio F9"); |
467 | break; | 467 | break; |
468 | case Key_F10: //contacts | 468 | case Key_F10: //contacts |
469 | break; | 469 | break; |
470 | case Key_F11: //menu | 470 | case Key_F11: //menu |
471 | mediaPlayerState.toggleBlank(); | 471 | mediaPlayerState.toggleBlank(); |
472 | break; | 472 | break; |
473 | case Key_F12: //home | 473 | case Key_F12: //home |
474 | break; | 474 | break; |
475 | case Key_F13: //mail | 475 | case Key_F13: //mail |
476 | mediaPlayerState.toggleBlank(); | 476 | mediaPlayerState.toggleBlank(); |
477 | break; | 477 | break; |
478 | case Key_Space: { | 478 | case Key_Space: { |
479 | if(mediaPlayerState.isPlaying()) { | 479 | if(mediaPlayerState.isPlaying()) { |
480 | // toggleButton(1); | 480 | // toggleButton(1); |
481 | mediaPlayerState.setPlaying(FALSE); | 481 | mediaPlayerState.setPlaying(FALSE); |
482 | // toggleButton(1); | 482 | // toggleButton(1); |
483 | } else { | 483 | } else { |
484 | // toggleButton(0); | 484 | // toggleButton(0); |
485 | mediaPlayerState.setPlaying(TRUE); | 485 | mediaPlayerState.setPlaying(TRUE); |
486 | // toggleButton(0); | 486 | // toggleButton(0); |
487 | } | 487 | } |
488 | } | 488 | } |
489 | break; | 489 | break; |
490 | case Key_Down: | 490 | case Key_Down: |
491 | // toggleButton(6); | 491 | // toggleButton(6); |
492 | emit lessClicked(); | 492 | emit lessClicked(); |
493 | emit lessReleased(); | 493 | emit lessReleased(); |
494 | // toggleButton(6); | 494 | // toggleButton(6); |
495 | break; | 495 | break; |
496 | case Key_Up: | 496 | case Key_Up: |
497 | // toggleButton(5); | 497 | // toggleButton(5); |
498 | emit moreClicked(); | 498 | emit moreClicked(); |
499 | emit moreReleased(); | 499 | emit moreReleased(); |
500 | // toggleButton(5); | 500 | // toggleButton(5); |
501 | break; | 501 | break; |
502 | case Key_Right: | 502 | case Key_Right: |
503 | // toggleButton(3); | 503 | // toggleButton(3); |
504 | mediaPlayerState.setNext(); | 504 | mediaPlayerState.setNext(); |
505 | // toggleButton(3); | 505 | // toggleButton(3); |
506 | break; | 506 | break; |
507 | case Key_Left: | 507 | case Key_Left: |
508 | // toggleButton(4); | 508 | // toggleButton(4); |
509 | mediaPlayerState.setPrev(); | 509 | mediaPlayerState.setPrev(); |
510 | // toggleButton(4); | 510 | // toggleButton(4); |
511 | break; | 511 | break; |
512 | case Key_Escape: { | 512 | case Key_Escape: { |
513 | } | 513 | } |
514 | break; | 514 | break; |
515 | 515 | ||
516 | }; | 516 | }; |
517 | } | 517 | } |
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 | } |