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