author | simon <simon> | 2002-12-02 18:17:40 (UTC) |
---|---|---|
committer | simon <simon> | 2002-12-02 18:17:40 (UTC) |
commit | 2aa2e01cd678012d4b28365c9c765a2076f64a3b (patch) (unidiff) | |
tree | 53fb067b1670b734cd65ce1d2fddd920e059d200 | |
parent | daf5a1cfa07615a3259dce3f7f980d30241fa3d5 (diff) | |
download | opie-2aa2e01cd678012d4b28365c9c765a2076f64a3b.zip opie-2aa2e01cd678012d4b28365c9c765a2076f64a3b.tar.gz opie-2aa2e01cd678012d4b28365c9c765a2076f64a3b.tar.bz2 |
- adapted to the new MediaPlayerState::MediaType
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 15 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.h | 4 |
2 files changed, 10 insertions, 9 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 46d374d..74bc390 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -1,547 +1,546 @@ | |||
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 | extern MediaPlayerState *mediaPlayerState; | 53 | extern MediaPlayerState *mediaPlayerState; |
54 | extern PlayListWidget *playList; | 54 | extern PlayListWidget *playList; |
55 | 55 | ||
56 | static const int xo = -2; // movable x offset | 56 | static const int xo = -2; // movable x offset |
57 | static const int yo = 22; // movable y offset | 57 | static const int yo = 22; // movable y offset |
58 | 58 | ||
59 | struct MediaButton { | 59 | struct MediaButton { |
60 | bool isToggle, isHeld, isDown; | 60 | bool isToggle, isHeld, isDown; |
61 | }; | 61 | }; |
62 | 62 | ||
63 | //Layout information for the audioButtons (and if it is a toggle button or not) | 63 | //Layout information for the audioButtons (and if it is a toggle button or not) |
64 | MediaButton audioButtons[] = { | 64 | MediaButton audioButtons[] = { |
65 | { TRUE, FALSE, FALSE }, // play | 65 | { TRUE, FALSE, FALSE }, // play |
66 | { FALSE, FALSE, FALSE }, // stop | 66 | { FALSE, FALSE, FALSE }, // stop |
67 | { FALSE, FALSE, FALSE }, // next | 67 | { FALSE, FALSE, FALSE }, // next |
68 | { FALSE, FALSE, FALSE }, // previous | 68 | { FALSE, FALSE, FALSE }, // previous |
69 | { FALSE, FALSE, FALSE }, // volume up | 69 | { FALSE, FALSE, FALSE }, // volume up |
70 | { FALSE, FALSE, FALSE }, // volume down | 70 | { FALSE, FALSE, FALSE }, // volume down |
71 | { TRUE, FALSE, FALSE }, // repeat/loop | 71 | { TRUE, FALSE, FALSE }, // repeat/loop |
72 | { FALSE, FALSE, FALSE }, // playlist | 72 | { FALSE, FALSE, FALSE }, // playlist |
73 | { FALSE, FALSE, FALSE }, // forward | 73 | { FALSE, FALSE, FALSE }, // forward |
74 | { FALSE, FALSE, FALSE } // back | 74 | { FALSE, FALSE, FALSE } // back |
75 | }; | 75 | }; |
76 | 76 | ||
77 | const char * const skin_mask_file_names[10] = { | 77 | const char * const skin_mask_file_names[10] = { |
78 | "play", "stop", "next", "prev", "up", | 78 | "play", "stop", "next", "prev", "up", |
79 | "down", "loop", "playlist", "forward", "back" | 79 | "down", "loop", "playlist", "forward", "back" |
80 | }; | 80 | }; |
81 | 81 | ||
82 | 82 | ||
83 | static void changeTextColor( QWidget *w ) { | 83 | static void changeTextColor( QWidget *w ) { |
84 | QPalette p = w->palette(); | 84 | QPalette p = w->palette(); |
85 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); | 85 | p.setBrush( QColorGroup::Background, QColor( 167, 212, 167 ) ); |
86 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); | 86 | p.setBrush( QColorGroup::Base, QColor( 167, 212, 167 ) ); |
87 | w->setPalette( p ); | 87 | w->setPalette( p ); |
88 | } | 88 | } |
89 | 89 | ||
90 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); | 90 | static const int numButtons = (sizeof(audioButtons)/sizeof(MediaButton)); |
91 | 91 | ||
92 | 92 | ||
93 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : | 93 | AudioWidget::AudioWidget(QWidget* parent, const char* name, WFlags f) : |
94 | 94 | ||
95 | QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { | 95 | QWidget( parent, name, f ), songInfo( this ), slider( Qt::Horizontal, this ), time( this ) { |
96 | 96 | ||
97 | setCaption( tr("OpiePlayer") ); | 97 | setCaption( tr("OpiePlayer") ); |
98 | 98 | ||
99 | Config cfg("OpiePlayer"); | 99 | Config cfg("OpiePlayer"); |
100 | cfg.setGroup("Options"); | 100 | cfg.setGroup("Options"); |
101 | skin = cfg.readEntry("Skin","default"); | 101 | skin = cfg.readEntry("Skin","default"); |
102 | //skin = "scaleTest"; | 102 | //skin = "scaleTest"; |
103 | // color of background, frame, degree of transparency | 103 | // color of background, frame, degree of transparency |
104 | 104 | ||
105 | QString skinPath = "opieplayer2/skins/" + skin; | 105 | QString skinPath = "opieplayer2/skins/" + skin; |
106 | pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); | 106 | pixBg = QPixmap( Resource::loadPixmap( QString("%1/background").arg(skinPath) ) ); |
107 | imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); | 107 | imgUp = QImage( Resource::loadImage( QString("%1/skin_up").arg(skinPath) ) ); |
108 | imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); | 108 | imgDn = QImage( Resource::loadImage( QString("%1/skin_down").arg(skinPath) ) ); |
109 | 109 | ||
110 | imgButtonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); | 110 | imgButtonMask = QImage( imgUp.width(), imgUp.height(), 8, 255 ); |
111 | imgButtonMask.fill( 0 ); | 111 | imgButtonMask.fill( 0 ); |
112 | 112 | ||
113 | for ( int i = 0; i < 10; i++ ) { | 113 | for ( int i = 0; i < 10; i++ ) { |
114 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" ); | 114 | QString filename = QString( QPEApplication::qpeDir() + "/pics/" + skinPath + "/skin_mask_" + skin_mask_file_names[i] + ".png" ); |
115 | masks[i] = new QBitmap( filename ); | 115 | masks[i] = new QBitmap( filename ); |
116 | 116 | ||
117 | if ( !masks[i]->isNull() ) { | 117 | if ( !masks[i]->isNull() ) { |
118 | QImage imgMask = masks[i]->convertToImage(); | 118 | QImage imgMask = masks[i]->convertToImage(); |
119 | uchar **dest = imgButtonMask.jumpTable(); | 119 | uchar **dest = imgButtonMask.jumpTable(); |
120 | for ( int y = 0; y < imgUp.height(); y++ ) { | 120 | for ( int y = 0; y < imgUp.height(); y++ ) { |
121 | uchar *line = dest[y]; | 121 | uchar *line = dest[y]; |
122 | for ( int x = 0; x < imgUp.width(); x++ ) | 122 | for ( int x = 0; x < imgUp.width(); x++ ) |
123 | if ( !qRed( imgMask.pixel( x, y ) ) ) | 123 | if ( !qRed( imgMask.pixel( x, y ) ) ) |
124 | line[x] = i + 1; | 124 | line[x] = i + 1; |
125 | } | 125 | } |
126 | } | 126 | } |
127 | 127 | ||
128 | } | 128 | } |
129 | 129 | ||
130 | for ( int i = 0; i < 10; i++ ) { | 130 | for ( int i = 0; i < 10; i++ ) { |
131 | buttonPixUp[i] = 0l; | 131 | buttonPixUp[i] = 0l; |
132 | buttonPixDown[i] = 0l; | 132 | buttonPixDown[i] = 0l; |
133 | } | 133 | } |
134 | 134 | ||
135 | setBackgroundPixmap( pixBg ); | 135 | setBackgroundPixmap( pixBg ); |
136 | 136 | ||
137 | songInfo.setFocusPolicy( QWidget::NoFocus ); | 137 | songInfo.setFocusPolicy( QWidget::NoFocus ); |
138 | // changeTextColor( &songInfo ); | 138 | // changeTextColor( &songInfo ); |
139 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); | 139 | // songInfo.setBackgroundColor( QColor( 167, 212, 167 )); |
140 | // songInfo.setFrameStyle( QFrame::NoFrame); | 140 | // songInfo.setFrameStyle( QFrame::NoFrame); |
141 | songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); | 141 | songInfo.setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); |
142 | // songInfo.setForegroundColor(Qt::white); | 142 | // songInfo.setForegroundColor(Qt::white); |
143 | 143 | ||
144 | slider.setFixedHeight( 20 ); | 144 | slider.setFixedHeight( 20 ); |
145 | slider.setMinValue( 0 ); | 145 | slider.setMinValue( 0 ); |
146 | slider.setMaxValue( 1 ); | 146 | slider.setMaxValue( 1 ); |
147 | slider.setFocusPolicy( QWidget::NoFocus ); | 147 | slider.setFocusPolicy( QWidget::NoFocus ); |
148 | slider.setBackgroundPixmap( pixBg ); | 148 | slider.setBackgroundPixmap( pixBg ); |
149 | 149 | ||
150 | // Config cofg("qpe"); | 150 | // Config cofg("qpe"); |
151 | // cofg.setGroup("Appearance"); | 151 | // cofg.setGroup("Appearance"); |
152 | // QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); | 152 | // QColor backgroundcolor = QColor( cofg.readEntry( "Background", "#E5E1D5" ) ); |
153 | 153 | ||
154 | time.setFocusPolicy( QWidget::NoFocus ); | 154 | time.setFocusPolicy( QWidget::NoFocus ); |
155 | time.setAlignment( Qt::AlignCenter ); | 155 | time.setAlignment( Qt::AlignCenter ); |
156 | 156 | ||
157 | // time.setFrame(FALSE); | 157 | // time.setFrame(FALSE); |
158 | // changeTextColor( &time ); | 158 | // changeTextColor( &time ); |
159 | 159 | ||
160 | resizeEvent( NULL ); | 160 | resizeEvent( NULL ); |
161 | 161 | ||
162 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 162 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
163 | connect( mediaPlayerState, SIGNAL( viewChanged(char) ), this, SLOT( setView(char) ) ); | 163 | connect( mediaPlayerState, SIGNAL( mediaTypeChanged(MediaPlayerState::MediaType) ), this, SLOT( setMediaType(MediaPlayerState::MediaType) ) ); |
164 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); | 164 | connect( mediaPlayerState, SIGNAL( loopingToggled(bool) ), this, SLOT( setLooping(bool) ) ); |
165 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); | 165 | connect( mediaPlayerState, SIGNAL( playingToggled(bool) ), this, SLOT( setPlaying(bool) ) ); |
166 | connect( mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); | 166 | connect( mediaPlayerState, SIGNAL( isSeekableToggled( bool ) ), this, SLOT( setSeekable( bool ) ) ); |
167 | 167 | ||
168 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); | 168 | connect( this, SIGNAL( forwardClicked() ), this, SLOT( skipFor() ) ); |
169 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); | 169 | connect( this, SIGNAL( backClicked() ), this, SLOT( skipBack() ) ); |
170 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); | 170 | connect( this, SIGNAL( forwardReleased() ), this, SLOT( stopSkip() ) ); |
171 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); | 171 | connect( this, SIGNAL( backReleased() ), this, SLOT( stopSkip() ) ); |
172 | 172 | ||
173 | // Intialise state | 173 | // Intialise state |
174 | setLength( mediaPlayerState->length() ); | 174 | setLength( mediaPlayerState->length() ); |
175 | setPosition( mediaPlayerState->position() ); | 175 | setPosition( mediaPlayerState->position() ); |
176 | setLooping( mediaPlayerState->isFullscreen() ); | 176 | setLooping( mediaPlayerState->isFullscreen() ); |
177 | // setPaused( mediaPlayerState->paused() ); | 177 | // setPaused( mediaPlayerState->paused() ); |
178 | setPlaying( mediaPlayerState->isPlaying() ); | 178 | setPlaying( mediaPlayerState->isPlaying() ); |
179 | 179 | ||
180 | } | 180 | } |
181 | 181 | ||
182 | AudioWidget::~AudioWidget() { | 182 | AudioWidget::~AudioWidget() { |
183 | 183 | ||
184 | for ( int i = 0; i < 10; i++ ) { | 184 | for ( int i = 0; i < 10; i++ ) { |
185 | delete buttonPixUp[i]; | 185 | delete buttonPixUp[i]; |
186 | delete buttonPixDown[i]; | 186 | delete buttonPixDown[i]; |
187 | } | 187 | } |
188 | for ( int i = 0; i < 10; i++ ) { | 188 | for ( int i = 0; i < 10; i++ ) { |
189 | delete masks[i]; | 189 | delete masks[i]; |
190 | } | 190 | } |
191 | // mediaPlayerState->setPlaying(false); | 191 | // mediaPlayerState->setPlaying(false); |
192 | } | 192 | } |
193 | 193 | ||
194 | namespace { | 194 | namespace { |
195 | 195 | ||
196 | QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { | 196 | QPixmap combineImageWithBackground( QImage img, QPixmap bg, QPoint offset ) { |
197 | QPixmap pix( img.width(), img.height() ); | 197 | QPixmap pix( img.width(), img.height() ); |
198 | QPainter p( &pix ); | 198 | QPainter p( &pix ); |
199 | p.drawTiledPixmap( pix.rect(), bg, offset ); | 199 | p.drawTiledPixmap( pix.rect(), bg, offset ); |
200 | p.drawImage( 0, 0, img ); | 200 | p.drawImage( 0, 0, img ); |
201 | return pix; | 201 | return pix; |
202 | } | 202 | } |
203 | 203 | ||
204 | 204 | ||
205 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { | 205 | QPixmap *maskPixToMask( QPixmap pix, QBitmap mask ) { |
206 | QPixmap *pixmap = new QPixmap( pix ); | 206 | QPixmap *pixmap = new QPixmap( pix ); |
207 | pixmap->setMask( mask ); | 207 | pixmap->setMask( mask ); |
208 | return pixmap; | 208 | return pixmap; |
209 | } | 209 | } |
210 | 210 | ||
211 | }; | 211 | }; |
212 | 212 | ||
213 | void AudioWidget::resizeEvent( QResizeEvent * ) { | 213 | void AudioWidget::resizeEvent( QResizeEvent * ) { |
214 | int h = height(); | 214 | int h = height(); |
215 | int w = width(); | 215 | int w = width(); |
216 | 216 | ||
217 | songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); | 217 | songInfo.setGeometry( QRect( 2, 2, w - 4, 20 ) ); |
218 | slider.setFixedWidth( w - 110 ); | 218 | slider.setFixedWidth( w - 110 ); |
219 | slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); | 219 | slider.setGeometry( QRect( 15, h - 22, w - 90, 20 ) ); |
220 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); | 220 | slider.setBackgroundOrigin( QWidget::ParentOrigin ); |
221 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); | 221 | time.setGeometry( QRect( w - 85, h - 30, 70, 20 ) ); |
222 | 222 | ||
223 | xoff = ( w - imgUp.width() ) / 2; | 223 | xoff = ( w - imgUp.width() ) / 2; |
224 | yoff = (( h - imgUp.height() ) / 2) - 10; | 224 | yoff = (( h - imgUp.height() ) / 2) - 10; |
225 | QPoint p( xoff, yoff ); | 225 | QPoint p( xoff, yoff ); |
226 | 226 | ||
227 | QPixmap pixUp = combineImageWithBackground( imgUp, pixBg, p ); | 227 | QPixmap pixUp = combineImageWithBackground( imgUp, pixBg, p ); |
228 | QPixmap pixDn = combineImageWithBackground( imgDn, pixBg, p ); | 228 | QPixmap pixDn = combineImageWithBackground( imgDn, pixBg, p ); |
229 | 229 | ||
230 | for ( int i = 0; i < 10; i++ ) { | 230 | for ( int i = 0; i < 10; i++ ) { |
231 | if ( !masks[i]->isNull() ) { | 231 | if ( !masks[i]->isNull() ) { |
232 | delete buttonPixUp[i]; | 232 | delete buttonPixUp[i]; |
233 | delete buttonPixDown[i]; | 233 | delete buttonPixDown[i]; |
234 | buttonPixUp[i] = maskPixToMask( pixUp, *masks[i] ); | 234 | buttonPixUp[i] = maskPixToMask( pixUp, *masks[i] ); |
235 | buttonPixDown[i] = maskPixToMask( pixDn, *masks[i] ); | 235 | buttonPixDown[i] = maskPixToMask( pixDn, *masks[i] ); |
236 | } | 236 | } |
237 | } | 237 | } |
238 | } | 238 | } |
239 | 239 | ||
240 | static bool audioSliderBeingMoved = FALSE; | 240 | static bool audioSliderBeingMoved = FALSE; |
241 | 241 | ||
242 | 242 | ||
243 | void AudioWidget::sliderPressed() { | 243 | void AudioWidget::sliderPressed() { |
244 | audioSliderBeingMoved = TRUE; | 244 | audioSliderBeingMoved = TRUE; |
245 | } | 245 | } |
246 | 246 | ||
247 | 247 | ||
248 | void AudioWidget::sliderReleased() { | 248 | void AudioWidget::sliderReleased() { |
249 | audioSliderBeingMoved = FALSE; | 249 | audioSliderBeingMoved = FALSE; |
250 | if ( slider.width() == 0 ) | 250 | if ( slider.width() == 0 ) |
251 | return; | 251 | return; |
252 | long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); | 252 | long val = long((double)slider.value() * mediaPlayerState->length() / slider.width()); |
253 | mediaPlayerState->setPosition( val ); | 253 | mediaPlayerState->setPosition( val ); |
254 | } | 254 | } |
255 | 255 | ||
256 | void AudioWidget::setPosition( long i ) { | 256 | void AudioWidget::setPosition( long i ) { |
257 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); | 257 | // qDebug("<<<<<<<<<<<<<<<<<<<<<<<<set position %d",i); |
258 | updateSlider( i, mediaPlayerState->length() ); | 258 | updateSlider( i, mediaPlayerState->length() ); |
259 | } | 259 | } |
260 | 260 | ||
261 | 261 | ||
262 | void AudioWidget::setLength( long max ) { | 262 | void AudioWidget::setLength( long max ) { |
263 | updateSlider( mediaPlayerState->position(), max ); | 263 | updateSlider( mediaPlayerState->position(), max ); |
264 | } | 264 | } |
265 | 265 | ||
266 | 266 | ||
267 | void AudioWidget::setView( char view ) { | 267 | void AudioWidget::setMediaType( MediaPlayerState::MediaType mediaType ) { |
268 | 268 | if ( mediaType == MediaPlayerState::Video ) { | |
269 | if ( view == 'a' ) { | ||
270 | // startTimer( 150 ); | ||
271 | showMaximized(); | ||
272 | } else { | ||
273 | killTimers(); | 269 | killTimers(); |
274 | hide(); | 270 | hide(); |
271 | return; | ||
275 | } | 272 | } |
276 | // qApp->processEvents(); | 273 | |
274 | // startTimer( 150 ); | ||
275 | showMaximized(); | ||
277 | } | 276 | } |
278 | 277 | ||
279 | 278 | ||
280 | void AudioWidget::setSeekable( bool isSeekable ) { | 279 | void AudioWidget::setSeekable( bool isSeekable ) { |
281 | 280 | ||
282 | if ( !isSeekable ) { | 281 | if ( !isSeekable ) { |
283 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); | 282 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); |
284 | if( !slider.isHidden()) { | 283 | if( !slider.isHidden()) { |
285 | slider.hide(); | 284 | slider.hide(); |
286 | } | 285 | } |
287 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 286 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
288 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 287 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
289 | disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 288 | disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
290 | disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 289 | disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
291 | } else { | 290 | } else { |
292 | // this stops the slider from being moved, thus | 291 | // this stops the slider from being moved, thus |
293 | // does not stop stream when it reaches the end | 292 | // does not stop stream when it reaches the end |
294 | slider.show(); | 293 | slider.show(); |
295 | qDebug( " CONNECT SET POSTION " ); | 294 | qDebug( " CONNECT SET POSTION " ); |
296 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 295 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
297 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 296 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
298 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 297 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
299 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 298 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
300 | } | 299 | } |
301 | } | 300 | } |
302 | 301 | ||
303 | 302 | ||
304 | static QString timeAsString( long length ) { | 303 | static QString timeAsString( long length ) { |
305 | int minutes = length / 60; | 304 | int minutes = length / 60; |
306 | int seconds = length % 60; | 305 | int seconds = length % 60; |
307 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); | 306 | return QString("%1:%2%3").arg( minutes ).arg( seconds / 10 ).arg( seconds % 10 ); |
308 | } | 307 | } |
309 | 308 | ||
310 | void AudioWidget::updateSlider( long i, long max ) { | 309 | void AudioWidget::updateSlider( long i, long max ) { |
311 | 310 | ||
312 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); | 311 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); |
313 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; | 312 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; |
314 | 313 | ||
315 | if ( max == 0 ) { | 314 | if ( max == 0 ) { |
316 | return; | 315 | return; |
317 | } | 316 | } |
318 | // Will flicker too much if we don't do this | 317 | // Will flicker too much if we don't do this |
319 | // Scale to something reasonable | 318 | // Scale to something reasonable |
320 | int width = slider.width(); | 319 | int width = slider.width(); |
321 | int val = int((double)i * width / max); | 320 | int val = int((double)i * width / max); |
322 | if ( !audioSliderBeingMoved ) { | 321 | if ( !audioSliderBeingMoved ) { |
323 | if ( slider.value() != val ) { | 322 | if ( slider.value() != val ) { |
324 | slider.setValue( val ); | 323 | slider.setValue( val ); |
325 | } | 324 | } |
326 | 325 | ||
327 | if ( slider.maxValue() != width ) { | 326 | if ( slider.maxValue() != width ) { |
328 | slider.setMaxValue( width ); | 327 | slider.setMaxValue( width ); |
329 | } | 328 | } |
330 | } | 329 | } |
331 | } | 330 | } |
332 | 331 | ||
333 | 332 | ||
334 | void AudioWidget::setToggleButton( int i, bool down ) { | 333 | void AudioWidget::setToggleButton( int i, bool down ) { |
335 | qDebug("setToggleButton %d", i); | 334 | qDebug("setToggleButton %d", i); |
336 | if ( down != audioButtons[i].isDown ) { | 335 | if ( down != audioButtons[i].isDown ) { |
337 | toggleButton( i ); | 336 | toggleButton( i ); |
338 | } | 337 | } |
339 | } | 338 | } |
340 | 339 | ||
341 | 340 | ||
342 | void AudioWidget::toggleButton( int i ) { | 341 | void AudioWidget::toggleButton( int i ) { |
343 | audioButtons[i].isDown = !audioButtons[i].isDown; | 342 | audioButtons[i].isDown = !audioButtons[i].isDown; |
344 | QPainter p(this); | 343 | QPainter p(this); |
345 | paintButton ( &p, i ); | 344 | paintButton ( &p, i ); |
346 | } | 345 | } |
347 | 346 | ||
348 | 347 | ||
349 | void AudioWidget::paintButton( QPainter *p, int i ) { | 348 | void AudioWidget::paintButton( QPainter *p, int i ) { |
350 | if ( audioButtons[i].isDown ) { | 349 | if ( audioButtons[i].isDown ) { |
351 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | 350 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); |
352 | } else { | 351 | } else { |
353 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | 352 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); |
354 | } | 353 | } |
355 | } | 354 | } |
356 | 355 | ||
357 | 356 | ||
358 | void AudioWidget::skipFor() { | 357 | void AudioWidget::skipFor() { |
359 | skipDirection = +1; | 358 | skipDirection = +1; |
360 | startTimer( 50 ); | 359 | startTimer( 50 ); |
361 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); | 360 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); |
362 | } | 361 | } |
363 | 362 | ||
364 | void AudioWidget::skipBack() { | 363 | void AudioWidget::skipBack() { |
365 | skipDirection = -1; | 364 | skipDirection = -1; |
366 | startTimer( 50 ); | 365 | startTimer( 50 ); |
367 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); | 366 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); |
368 | } | 367 | } |
369 | 368 | ||
370 | 369 | ||
371 | 370 | ||
372 | void AudioWidget::stopSkip() { | 371 | void AudioWidget::stopSkip() { |
373 | killTimers(); | 372 | killTimers(); |
374 | } | 373 | } |
375 | 374 | ||
376 | 375 | ||
377 | void AudioWidget::timerEvent( QTimerEvent * ) { | 376 | void AudioWidget::timerEvent( QTimerEvent * ) { |
378 | if ( skipDirection == +1 ) { | 377 | if ( skipDirection == +1 ) { |
379 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); | 378 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); |
380 | } else if ( skipDirection == -1 ) { | 379 | } else if ( skipDirection == -1 ) { |
381 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); | 380 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); |
382 | } | 381 | } |
383 | } | 382 | } |
384 | 383 | ||
385 | 384 | ||
386 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | 385 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { |
387 | for ( int i = 0; i < numButtons; i++ ) { | 386 | for ( int i = 0; i < numButtons; i++ ) { |
388 | if ( event->state() == QMouseEvent::LeftButton ) { | 387 | if ( event->state() == QMouseEvent::LeftButton ) { |
389 | // The test to see if the mouse click is inside the button or not | 388 | // The test to see if the mouse click is inside the button or not |
390 | int x = event->pos().x() - xoff; | 389 | int x = event->pos().x() - xoff; |
391 | int y = event->pos().y() - yoff; | 390 | int y = event->pos().y() - yoff; |
392 | 391 | ||
393 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask.width() | 392 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask.width() |
394 | && y < imgButtonMask.height() | 393 | && y < imgButtonMask.height() |
395 | && imgButtonMask.pixelIndex( x, y ) == i + 1 ); | 394 | && imgButtonMask.pixelIndex( x, y ) == i + 1 ); |
396 | 395 | ||
397 | if ( isOnButton && !audioButtons[i].isHeld ) { | 396 | if ( isOnButton && !audioButtons[i].isHeld ) { |
398 | audioButtons[i].isHeld = TRUE; | 397 | audioButtons[i].isHeld = TRUE; |
399 | toggleButton(i); | 398 | toggleButton(i); |
400 | switch (i) { | 399 | switch (i) { |
401 | case AudioVolumeUp: | 400 | case AudioVolumeUp: |
402 | emit moreClicked(); | 401 | emit moreClicked(); |
403 | return; | 402 | return; |
404 | case AudioVolumeDown: | 403 | case AudioVolumeDown: |
405 | emit lessClicked(); | 404 | emit lessClicked(); |
406 | return; | 405 | return; |
407 | case AudioForward: | 406 | case AudioForward: |
408 | emit forwardClicked(); | 407 | emit forwardClicked(); |
409 | return; | 408 | return; |
410 | case AudioBack: | 409 | case AudioBack: |
411 | emit backClicked(); | 410 | emit backClicked(); |
412 | return; | 411 | return; |
413 | } | 412 | } |
414 | } else if ( !isOnButton && audioButtons[i].isHeld ) { | 413 | } else if ( !isOnButton && audioButtons[i].isHeld ) { |
415 | audioButtons[i].isHeld = FALSE; | 414 | audioButtons[i].isHeld = FALSE; |
416 | toggleButton(i); | 415 | toggleButton(i); |
417 | } | 416 | } |
418 | } else { | 417 | } else { |
419 | if ( audioButtons[i].isHeld ) { | 418 | if ( audioButtons[i].isHeld ) { |
420 | audioButtons[i].isHeld = FALSE; | 419 | audioButtons[i].isHeld = FALSE; |
421 | if ( !audioButtons[i].isToggle ) { | 420 | if ( !audioButtons[i].isToggle ) { |
422 | setToggleButton( i, FALSE ); | 421 | setToggleButton( i, FALSE ); |
423 | } | 422 | } |
424 | qDebug("mouseEvent %d", i); | 423 | qDebug("mouseEvent %d", i); |
425 | switch (i) { | 424 | switch (i) { |
426 | case AudioPlay: | 425 | case AudioPlay: |
427 | if( mediaPlayerState->isPaused() ) { | 426 | if( mediaPlayerState->isPaused() ) { |
428 | mediaPlayerState->setPaused( FALSE ); | 427 | mediaPlayerState->setPaused( FALSE ); |
429 | return; | 428 | return; |
430 | } else if( !mediaPlayerState->isPaused() ) { | 429 | } else if( !mediaPlayerState->isPaused() ) { |
431 | mediaPlayerState->setPaused( TRUE ); | 430 | mediaPlayerState->setPaused( TRUE ); |
432 | return; | 431 | return; |
433 | } | 432 | } |
434 | case AudioStop: mediaPlayerState->setPlaying(FALSE); return; | 433 | case AudioStop: mediaPlayerState->setPlaying(FALSE); return; |
435 | case AudioNext: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState->setNext(); return; | 434 | case AudioNext: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState->setNext(); return; |
436 | case AudioPrevious: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState->setPrev(); return; | 435 | case AudioPrevious: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState->setPrev(); return; |
437 | case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; | 436 | case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; |
438 | case AudioVolumeUp: emit moreReleased(); return; | 437 | case AudioVolumeUp: emit moreReleased(); return; |
439 | case AudioVolumeDown: emit lessReleased(); return; | 438 | case AudioVolumeDown: emit lessReleased(); return; |
440 | case AudioPlayList: mediaPlayerState->setList(); return; | 439 | case AudioPlayList: mediaPlayerState->setList(); return; |
441 | case AudioForward: emit forwardReleased(); return; | 440 | case AudioForward: emit forwardReleased(); return; |
442 | case AudioBack: emit backReleased(); return; | 441 | case AudioBack: emit backReleased(); return; |
443 | } | 442 | } |
444 | } | 443 | } |
445 | } | 444 | } |
446 | } | 445 | } |
447 | } | 446 | } |
448 | 447 | ||
449 | 448 | ||
450 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { | 449 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { |
451 | mouseMoveEvent( event ); | 450 | mouseMoveEvent( event ); |
452 | } | 451 | } |
453 | 452 | ||
454 | 453 | ||
455 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { | 454 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { |
456 | mouseMoveEvent( event ); | 455 | mouseMoveEvent( event ); |
457 | } | 456 | } |
458 | 457 | ||
459 | 458 | ||
460 | void AudioWidget::showEvent( QShowEvent* ) { | 459 | void AudioWidget::showEvent( QShowEvent* ) { |
461 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 460 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
462 | mouseMoveEvent( &event ); | 461 | mouseMoveEvent( &event ); |
463 | } | 462 | } |
464 | 463 | ||
465 | 464 | ||
466 | void AudioWidget::closeEvent( QCloseEvent* ) { | 465 | void AudioWidget::closeEvent( QCloseEvent* ) { |
467 | mediaPlayerState->setList(); | 466 | mediaPlayerState->setList(); |
468 | } | 467 | } |
469 | 468 | ||
470 | 469 | ||
471 | void AudioWidget::paintEvent( QPaintEvent * pe ) { | 470 | void AudioWidget::paintEvent( QPaintEvent * pe ) { |
472 | if ( !pe->erased() ) { | 471 | if ( !pe->erased() ) { |
473 | // Combine with background and double buffer | 472 | // Combine with background and double buffer |
474 | QPixmap pix( pe->rect().size() ); | 473 | QPixmap pix( pe->rect().size() ); |
475 | QPainter p( &pix ); | 474 | QPainter p( &pix ); |
476 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 475 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
477 | p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); | 476 | p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); |
478 | for ( int i = 0; i < numButtons; i++ ) | 477 | for ( int i = 0; i < numButtons; i++ ) |
479 | paintButton( &p, i ); | 478 | paintButton( &p, i ); |
480 | QPainter p2( this ); | 479 | QPainter p2( this ); |
481 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 480 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
482 | } else { | 481 | } else { |
483 | QPainter p( this ); | 482 | QPainter p( this ); |
484 | for ( int i = 0; i < numButtons; i++ ) | 483 | for ( int i = 0; i < numButtons; i++ ) |
485 | paintButton( &p, i ); | 484 | paintButton( &p, i ); |
486 | } | 485 | } |
487 | } | 486 | } |
488 | 487 | ||
489 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { | 488 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { |
490 | switch ( e->key() ) { | 489 | switch ( e->key() ) { |
491 | ////////////////////////////// Zaurus keys | 490 | ////////////////////////////// Zaurus keys |
492 | case Key_Home: | 491 | case Key_Home: |
493 | break; | 492 | break; |
494 | case Key_F9: //activity | 493 | case Key_F9: //activity |
495 | hide(); | 494 | hide(); |
496 | // qDebug("Audio F9"); | 495 | // qDebug("Audio F9"); |
497 | break; | 496 | break; |
498 | case Key_F10: //contacts | 497 | case Key_F10: //contacts |
499 | break; | 498 | break; |
500 | case Key_F11: //menu | 499 | case Key_F11: //menu |
501 | mediaPlayerState->toggleBlank(); | 500 | mediaPlayerState->toggleBlank(); |
502 | break; | 501 | break; |
503 | case Key_F12: //home | 502 | case Key_F12: //home |
504 | break; | 503 | break; |
505 | case Key_F13: //mail | 504 | case Key_F13: //mail |
506 | mediaPlayerState->toggleBlank(); | 505 | mediaPlayerState->toggleBlank(); |
507 | break; | 506 | break; |
508 | case Key_Space: { | 507 | case Key_Space: { |
509 | if(mediaPlayerState->isPlaying()) { | 508 | if(mediaPlayerState->isPlaying()) { |
510 | // toggleButton(1); | 509 | // toggleButton(1); |
511 | mediaPlayerState->setPlaying(FALSE); | 510 | mediaPlayerState->setPlaying(FALSE); |
512 | // toggleButton(1); | 511 | // toggleButton(1); |
513 | } else { | 512 | } else { |
514 | // toggleButton(0); | 513 | // toggleButton(0); |
515 | mediaPlayerState->setPlaying(TRUE); | 514 | mediaPlayerState->setPlaying(TRUE); |
516 | // toggleButton(0); | 515 | // toggleButton(0); |
517 | } | 516 | } |
518 | } | 517 | } |
519 | break; | 518 | break; |
520 | case Key_Down: | 519 | case Key_Down: |
521 | // toggleButton(6); | 520 | // toggleButton(6); |
522 | emit lessClicked(); | 521 | emit lessClicked(); |
523 | emit lessReleased(); | 522 | emit lessReleased(); |
524 | // toggleButton(6); | 523 | // toggleButton(6); |
525 | break; | 524 | break; |
526 | case Key_Up: | 525 | case Key_Up: |
527 | // toggleButton(5); | 526 | // toggleButton(5); |
528 | emit moreClicked(); | 527 | emit moreClicked(); |
529 | emit moreReleased(); | 528 | emit moreReleased(); |
530 | // toggleButton(5); | 529 | // toggleButton(5); |
531 | break; | 530 | break; |
532 | case Key_Right: | 531 | case Key_Right: |
533 | // toggleButton(3); | 532 | // toggleButton(3); |
534 | mediaPlayerState->setNext(); | 533 | mediaPlayerState->setNext(); |
535 | // toggleButton(3); | 534 | // toggleButton(3); |
536 | break; | 535 | break; |
537 | case Key_Left: | 536 | case Key_Left: |
538 | // toggleButton(4); | 537 | // toggleButton(4); |
539 | mediaPlayerState->setPrev(); | 538 | mediaPlayerState->setPrev(); |
540 | // toggleButton(4); | 539 | // toggleButton(4); |
541 | break; | 540 | break; |
542 | case Key_Escape: { | 541 | case Key_Escape: { |
543 | } | 542 | } |
544 | break; | 543 | break; |
545 | 544 | ||
546 | }; | 545 | }; |
547 | } | 546 | } |
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h index 54adb36..3f0c059 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.h +++ b/noncore/multimedia/opieplayer2/audiowidget.h | |||
@@ -1,135 +1,137 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; Library General Public License for more | 22 | ..}^=.= = ; Library General Public License for more |
23 | ++= -. .` .: details. | 23 | ++= -. .` .: details. |
24 | : = ...= . :.=- | 24 | : = ...= . :.=- |
25 | -. .:....=;==+<; You should have received a copy of the GNU | 25 | -. .:....=;==+<; You should have received a copy of the GNU |
26 | -_. . . )=. = Library General Public License along with | 26 | -_. . . )=. = Library General Public License along with |
27 | -- :-=` this library; see the file COPYING.LIB. | 27 | -- :-=` this library; see the file COPYING.LIB. |
28 | If not, write to the Free Software Foundation, | 28 | If not, write to the Free Software Foundation, |
29 | Inc., 59 Temple Place - Suite 330, | 29 | Inc., 59 Temple Place - Suite 330, |
30 | Boston, MA 02111-1307, USA. | 30 | Boston, MA 02111-1307, USA. |
31 | 31 | ||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #ifndef AUDIO_WIDGET_H | 34 | #ifndef AUDIO_WIDGET_H |
35 | #define AUDIO_WIDGET_H | 35 | #define AUDIO_WIDGET_H |
36 | 36 | ||
37 | #include <qwidget.h> | 37 | #include <qwidget.h> |
38 | #include <qpainter.h> | 38 | #include <qpainter.h> |
39 | #include <qdrawutil.h> | 39 | #include <qdrawutil.h> |
40 | #include <qpixmap.h> | 40 | #include <qpixmap.h> |
41 | #include <qstring.h> | 41 | #include <qstring.h> |
42 | #include <qslider.h> | 42 | #include <qslider.h> |
43 | #include <qframe.h> | 43 | #include <qframe.h> |
44 | #include <qlineedit.h> | 44 | #include <qlineedit.h> |
45 | #include <qimage.h> | 45 | #include <qimage.h> |
46 | 46 | ||
47 | #include <opie/oticker.h> | 47 | #include <opie/oticker.h> |
48 | 48 | ||
49 | #include "mediaplayerstate.h" | ||
50 | |||
49 | class QPixmap; | 51 | class QPixmap; |
50 | 52 | ||
51 | namespace { | 53 | namespace { |
52 | 54 | ||
53 | enum AudioButtons { | 55 | enum AudioButtons { |
54 | AudioPlay=0, | 56 | AudioPlay=0, |
55 | AudioStop, | 57 | AudioStop, |
56 | AudioNext, | 58 | AudioNext, |
57 | AudioPrevious, | 59 | AudioPrevious, |
58 | AudioVolumeUp, | 60 | AudioVolumeUp, |
59 | AudioVolumeDown, | 61 | AudioVolumeDown, |
60 | AudioLoop, | 62 | AudioLoop, |
61 | AudioPlayList, | 63 | AudioPlayList, |
62 | AudioForward, | 64 | AudioForward, |
63 | AudioBack | 65 | AudioBack |
64 | }; | 66 | }; |
65 | }; | 67 | }; |
66 | 68 | ||
67 | class AudioWidget : public QWidget { | 69 | class AudioWidget : public QWidget { |
68 | Q_OBJECT | 70 | Q_OBJECT |
69 | public: | 71 | public: |
70 | AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); | 72 | AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); |
71 | ~AudioWidget(); | 73 | ~AudioWidget(); |
72 | void setTickerText( const QString &text ) { songInfo.setText( text ); } | 74 | void setTickerText( const QString &text ) { songInfo.setText( text ); } |
73 | public slots: | 75 | public slots: |
74 | void updateSlider( long, long ); | 76 | void updateSlider( long, long ); |
75 | void sliderPressed( ); | 77 | void sliderPressed( ); |
76 | void sliderReleased( ); | 78 | void sliderReleased( ); |
77 | void setLooping( bool b) { setToggleButton( AudioLoop, b ); } | 79 | void setLooping( bool b) { setToggleButton( AudioLoop, b ); } |
78 | void setPlaying( bool b) { setToggleButton( AudioPlay, b ); } | 80 | void setPlaying( bool b) { setToggleButton( AudioPlay, b ); } |
79 | void setPosition( long ); | 81 | void setPosition( long ); |
80 | void setLength( long ); | 82 | void setLength( long ); |
81 | void setSeekable( bool ); | 83 | void setSeekable( bool ); |
82 | void setView( char ); | 84 | void setMediaType( MediaPlayerState::MediaType mediaType ); |
83 | 85 | ||
84 | signals: | 86 | signals: |
85 | void moreClicked(); | 87 | void moreClicked(); |
86 | void lessClicked(); | 88 | void lessClicked(); |
87 | void moreReleased(); | 89 | void moreReleased(); |
88 | void lessReleased(); | 90 | void lessReleased(); |
89 | void forwardClicked(); | 91 | void forwardClicked(); |
90 | void backClicked(); | 92 | void backClicked(); |
91 | void forwardReleased(); | 93 | void forwardReleased(); |
92 | void backReleased(); | 94 | void backReleased(); |
93 | void sliderMoved(long); | 95 | void sliderMoved(long); |
94 | 96 | ||
95 | protected: | 97 | protected: |
96 | void doBlank(); | 98 | void doBlank(); |
97 | void doUnblank(); | 99 | void doUnblank(); |
98 | void paintEvent( QPaintEvent *pe ); | 100 | void paintEvent( QPaintEvent *pe ); |
99 | void showEvent( QShowEvent *se ); | 101 | void showEvent( QShowEvent *se ); |
100 | void resizeEvent( QResizeEvent *re ); | 102 | void resizeEvent( QResizeEvent *re ); |
101 | void mouseMoveEvent( QMouseEvent *event ); | 103 | void mouseMoveEvent( QMouseEvent *event ); |
102 | void mousePressEvent( QMouseEvent *event ); | 104 | void mousePressEvent( QMouseEvent *event ); |
103 | void mouseReleaseEvent( QMouseEvent *event ); | 105 | void mouseReleaseEvent( QMouseEvent *event ); |
104 | void timerEvent( QTimerEvent *event ); | 106 | void timerEvent( QTimerEvent *event ); |
105 | void closeEvent( QCloseEvent *event ); | 107 | void closeEvent( QCloseEvent *event ); |
106 | void keyReleaseEvent( QKeyEvent *e); | 108 | void keyReleaseEvent( QKeyEvent *e); |
107 | private slots: | 109 | private slots: |
108 | void skipFor(); | 110 | void skipFor(); |
109 | void skipBack(); | 111 | void skipBack(); |
110 | void stopSkip(); | 112 | void stopSkip(); |
111 | private: | 113 | private: |
112 | void toggleButton( int ); | 114 | void toggleButton( int ); |
113 | void setToggleButton( int, bool ); | 115 | void setToggleButton( int, bool ); |
114 | void paintButton( QPainter *p, int i ); | 116 | void paintButton( QPainter *p, int i ); |
115 | int skipDirection; | 117 | int skipDirection; |
116 | QString skin; | 118 | QString skin; |
117 | QPixmap pixBg; | 119 | QPixmap pixBg; |
118 | QImage imgUp; | 120 | QImage imgUp; |
119 | QImage imgDn; | 121 | QImage imgDn; |
120 | QImage imgButtonMask; | 122 | QImage imgButtonMask; |
121 | QBitmap *masks[10]; | 123 | QBitmap *masks[10]; |
122 | QPixmap *buttonPixUp[10]; | 124 | QPixmap *buttonPixUp[10]; |
123 | QPixmap *buttonPixDown[10]; | 125 | QPixmap *buttonPixDown[10]; |
124 | 126 | ||
125 | QPixmap *pixmaps[4]; | 127 | QPixmap *pixmaps[4]; |
126 | OTicker songInfo; | 128 | OTicker songInfo; |
127 | QSlider slider; | 129 | QSlider slider; |
128 | QLineEdit time; | 130 | QLineEdit time; |
129 | int xoff, yoff; | 131 | int xoff, yoff; |
130 | bool isStreaming : 1; | 132 | bool isStreaming : 1; |
131 | }; | 133 | }; |
132 | 134 | ||
133 | 135 | ||
134 | #endif // AUDIO_WIDGET_H | 136 | #endif // AUDIO_WIDGET_H |
135 | 137 | ||