-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.cpp | 14 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/audiowidget.h | 2 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayerstate.cpp | 16 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayerstate.h | 6 |
4 files changed, 23 insertions, 15 deletions
diff --git a/noncore/multimedia/opieplayer2/audiowidget.cpp b/noncore/multimedia/opieplayer2/audiowidget.cpp index 74bc390..1600320 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.cpp +++ b/noncore/multimedia/opieplayer2/audiowidget.cpp | |||
@@ -1,546 +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( mediaTypeChanged(MediaPlayerState::MediaType) ), this, SLOT( setMediaType(MediaPlayerState::MediaType) ) ); | 163 | connect( mediaPlayerState, SIGNAL( displayTypeChanged(MediaPlayerState::DisplayType) ), this, SLOT( setDisplayType(MediaPlayerState::DisplayType) ) ); |
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::setMediaType( MediaPlayerState::MediaType mediaType ) { | 267 | void AudioWidget::setDisplayType( MediaPlayerState::DisplayType mediaType ) { |
268 | if ( mediaType == MediaPlayerState::Video ) { | 268 | if ( mediaType == MediaPlayerState::Audio ) { |
269 | killTimers(); | 269 | // startTimer( 150 ); |
270 | hide(); | 270 | showMaximized(); |
271 | return; | 271 | return; |
272 | } | 272 | } |
273 | 273 | ||
274 | // startTimer( 150 ); | 274 | killTimers(); |
275 | showMaximized(); | 275 | hide(); |
276 | } | 276 | } |
277 | 277 | ||
278 | 278 | ||
279 | void AudioWidget::setSeekable( bool isSeekable ) { | 279 | void AudioWidget::setSeekable( bool isSeekable ) { |
280 | 280 | ||
281 | if ( !isSeekable ) { | 281 | if ( !isSeekable ) { |
282 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); | 282 | qDebug("<<<<<<<<<<<<<<file is STREAMING>>>>>>>>>>>>>>>>>>>"); |
283 | if( !slider.isHidden()) { | 283 | if( !slider.isHidden()) { |
284 | slider.hide(); | 284 | slider.hide(); |
285 | } | 285 | } |
286 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 286 | disconnect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
287 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 287 | disconnect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
288 | disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 288 | disconnect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
289 | disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 289 | disconnect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
290 | } else { | 290 | } else { |
291 | // this stops the slider from being moved, thus | 291 | // this stops the slider from being moved, thus |
292 | // does not stop stream when it reaches the end | 292 | // does not stop stream when it reaches the end |
293 | slider.show(); | 293 | slider.show(); |
294 | qDebug( " CONNECT SET POSTION " ); | 294 | qDebug( " CONNECT SET POSTION " ); |
295 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 295 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
296 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); | 296 | connect( mediaPlayerState, SIGNAL( positionUpdated(long) ),this, SLOT( setPosition(long) ) ); |
297 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 297 | connect( &slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
298 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 298 | connect( &slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
299 | } | 299 | } |
300 | } | 300 | } |
301 | 301 | ||
302 | 302 | ||
303 | static QString timeAsString( long length ) { | 303 | static QString timeAsString( long length ) { |
304 | int minutes = length / 60; | 304 | int minutes = length / 60; |
305 | int seconds = length % 60; | 305 | int seconds = length % 60; |
306 | 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 ); |
307 | } | 307 | } |
308 | 308 | ||
309 | void AudioWidget::updateSlider( long i, long max ) { | 309 | void AudioWidget::updateSlider( long i, long max ) { |
310 | 310 | ||
311 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); | 311 | time.setText( timeAsString( i ) + " / " + timeAsString( max ) ); |
312 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; | 312 | // qDebug( timeAsString( i ) + " / " + timeAsString( max ) ) ; |
313 | 313 | ||
314 | if ( max == 0 ) { | 314 | if ( max == 0 ) { |
315 | return; | 315 | return; |
316 | } | 316 | } |
317 | // Will flicker too much if we don't do this | 317 | // Will flicker too much if we don't do this |
318 | // Scale to something reasonable | 318 | // Scale to something reasonable |
319 | int width = slider.width(); | 319 | int width = slider.width(); |
320 | int val = int((double)i * width / max); | 320 | int val = int((double)i * width / max); |
321 | if ( !audioSliderBeingMoved ) { | 321 | if ( !audioSliderBeingMoved ) { |
322 | if ( slider.value() != val ) { | 322 | if ( slider.value() != val ) { |
323 | slider.setValue( val ); | 323 | slider.setValue( val ); |
324 | } | 324 | } |
325 | 325 | ||
326 | if ( slider.maxValue() != width ) { | 326 | if ( slider.maxValue() != width ) { |
327 | slider.setMaxValue( width ); | 327 | slider.setMaxValue( width ); |
328 | } | 328 | } |
329 | } | 329 | } |
330 | } | 330 | } |
331 | 331 | ||
332 | 332 | ||
333 | void AudioWidget::setToggleButton( int i, bool down ) { | 333 | void AudioWidget::setToggleButton( int i, bool down ) { |
334 | qDebug("setToggleButton %d", i); | 334 | qDebug("setToggleButton %d", i); |
335 | if ( down != audioButtons[i].isDown ) { | 335 | if ( down != audioButtons[i].isDown ) { |
336 | toggleButton( i ); | 336 | toggleButton( i ); |
337 | } | 337 | } |
338 | } | 338 | } |
339 | 339 | ||
340 | 340 | ||
341 | void AudioWidget::toggleButton( int i ) { | 341 | void AudioWidget::toggleButton( int i ) { |
342 | audioButtons[i].isDown = !audioButtons[i].isDown; | 342 | audioButtons[i].isDown = !audioButtons[i].isDown; |
343 | QPainter p(this); | 343 | QPainter p(this); |
344 | paintButton ( &p, i ); | 344 | paintButton ( &p, i ); |
345 | } | 345 | } |
346 | 346 | ||
347 | 347 | ||
348 | void AudioWidget::paintButton( QPainter *p, int i ) { | 348 | void AudioWidget::paintButton( QPainter *p, int i ) { |
349 | if ( audioButtons[i].isDown ) { | 349 | if ( audioButtons[i].isDown ) { |
350 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); | 350 | p->drawPixmap( xoff, yoff, *buttonPixDown[i] ); |
351 | } else { | 351 | } else { |
352 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); | 352 | p->drawPixmap( xoff, yoff, *buttonPixUp[i] ); |
353 | } | 353 | } |
354 | } | 354 | } |
355 | 355 | ||
356 | 356 | ||
357 | void AudioWidget::skipFor() { | 357 | void AudioWidget::skipFor() { |
358 | skipDirection = +1; | 358 | skipDirection = +1; |
359 | startTimer( 50 ); | 359 | startTimer( 50 ); |
360 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); | 360 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); |
361 | } | 361 | } |
362 | 362 | ||
363 | void AudioWidget::skipBack() { | 363 | void AudioWidget::skipBack() { |
364 | skipDirection = -1; | 364 | skipDirection = -1; |
365 | startTimer( 50 ); | 365 | startTimer( 50 ); |
366 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); | 366 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); |
367 | } | 367 | } |
368 | 368 | ||
369 | 369 | ||
370 | 370 | ||
371 | void AudioWidget::stopSkip() { | 371 | void AudioWidget::stopSkip() { |
372 | killTimers(); | 372 | killTimers(); |
373 | } | 373 | } |
374 | 374 | ||
375 | 375 | ||
376 | void AudioWidget::timerEvent( QTimerEvent * ) { | 376 | void AudioWidget::timerEvent( QTimerEvent * ) { |
377 | if ( skipDirection == +1 ) { | 377 | if ( skipDirection == +1 ) { |
378 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); | 378 | mediaPlayerState->setPosition( mediaPlayerState->position() + 2 ); |
379 | } else if ( skipDirection == -1 ) { | 379 | } else if ( skipDirection == -1 ) { |
380 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); | 380 | mediaPlayerState->setPosition( mediaPlayerState->position() - 2 ); |
381 | } | 381 | } |
382 | } | 382 | } |
383 | 383 | ||
384 | 384 | ||
385 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { | 385 | void AudioWidget::mouseMoveEvent( QMouseEvent *event ) { |
386 | for ( int i = 0; i < numButtons; i++ ) { | 386 | for ( int i = 0; i < numButtons; i++ ) { |
387 | if ( event->state() == QMouseEvent::LeftButton ) { | 387 | if ( event->state() == QMouseEvent::LeftButton ) { |
388 | // 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 |
389 | int x = event->pos().x() - xoff; | 389 | int x = event->pos().x() - xoff; |
390 | int y = event->pos().y() - yoff; | 390 | int y = event->pos().y() - yoff; |
391 | 391 | ||
392 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask.width() | 392 | bool isOnButton = ( x > 0 && y > 0 && x < imgButtonMask.width() |
393 | && y < imgButtonMask.height() | 393 | && y < imgButtonMask.height() |
394 | && imgButtonMask.pixelIndex( x, y ) == i + 1 ); | 394 | && imgButtonMask.pixelIndex( x, y ) == i + 1 ); |
395 | 395 | ||
396 | if ( isOnButton && !audioButtons[i].isHeld ) { | 396 | if ( isOnButton && !audioButtons[i].isHeld ) { |
397 | audioButtons[i].isHeld = TRUE; | 397 | audioButtons[i].isHeld = TRUE; |
398 | toggleButton(i); | 398 | toggleButton(i); |
399 | switch (i) { | 399 | switch (i) { |
400 | case AudioVolumeUp: | 400 | case AudioVolumeUp: |
401 | emit moreClicked(); | 401 | emit moreClicked(); |
402 | return; | 402 | return; |
403 | case AudioVolumeDown: | 403 | case AudioVolumeDown: |
404 | emit lessClicked(); | 404 | emit lessClicked(); |
405 | return; | 405 | return; |
406 | case AudioForward: | 406 | case AudioForward: |
407 | emit forwardClicked(); | 407 | emit forwardClicked(); |
408 | return; | 408 | return; |
409 | case AudioBack: | 409 | case AudioBack: |
410 | emit backClicked(); | 410 | emit backClicked(); |
411 | return; | 411 | return; |
412 | } | 412 | } |
413 | } else if ( !isOnButton && audioButtons[i].isHeld ) { | 413 | } else if ( !isOnButton && audioButtons[i].isHeld ) { |
414 | audioButtons[i].isHeld = FALSE; | 414 | audioButtons[i].isHeld = FALSE; |
415 | toggleButton(i); | 415 | toggleButton(i); |
416 | } | 416 | } |
417 | } else { | 417 | } else { |
418 | if ( audioButtons[i].isHeld ) { | 418 | if ( audioButtons[i].isHeld ) { |
419 | audioButtons[i].isHeld = FALSE; | 419 | audioButtons[i].isHeld = FALSE; |
420 | if ( !audioButtons[i].isToggle ) { | 420 | if ( !audioButtons[i].isToggle ) { |
421 | setToggleButton( i, FALSE ); | 421 | setToggleButton( i, FALSE ); |
422 | } | 422 | } |
423 | qDebug("mouseEvent %d", i); | 423 | qDebug("mouseEvent %d", i); |
424 | switch (i) { | 424 | switch (i) { |
425 | case AudioPlay: | 425 | case AudioPlay: |
426 | if( mediaPlayerState->isPaused() ) { | 426 | if( mediaPlayerState->isPaused() ) { |
427 | mediaPlayerState->setPaused( FALSE ); | 427 | mediaPlayerState->setPaused( FALSE ); |
428 | return; | 428 | return; |
429 | } else if( !mediaPlayerState->isPaused() ) { | 429 | } else if( !mediaPlayerState->isPaused() ) { |
430 | mediaPlayerState->setPaused( TRUE ); | 430 | mediaPlayerState->setPaused( TRUE ); |
431 | return; | 431 | return; |
432 | } | 432 | } |
433 | case AudioStop: mediaPlayerState->setPlaying(FALSE); return; | 433 | case AudioStop: mediaPlayerState->setPlaying(FALSE); return; |
434 | case AudioNext: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState->setNext(); return; | 434 | case AudioNext: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState->setNext(); return; |
435 | case AudioPrevious: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState->setPrev(); return; | 435 | case AudioPrevious: if( playList->currentTab() == PlayListWidget::CurrentPlayList ) mediaPlayerState->setPrev(); return; |
436 | case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; | 436 | case AudioLoop: mediaPlayerState->setLooping(audioButtons[i].isDown); return; |
437 | case AudioVolumeUp: emit moreReleased(); return; | 437 | case AudioVolumeUp: emit moreReleased(); return; |
438 | case AudioVolumeDown: emit lessReleased(); return; | 438 | case AudioVolumeDown: emit lessReleased(); return; |
439 | case AudioPlayList: mediaPlayerState->setList(); return; | 439 | case AudioPlayList: mediaPlayerState->setList(); return; |
440 | case AudioForward: emit forwardReleased(); return; | 440 | case AudioForward: emit forwardReleased(); return; |
441 | case AudioBack: emit backReleased(); return; | 441 | case AudioBack: emit backReleased(); return; |
442 | } | 442 | } |
443 | } | 443 | } |
444 | } | 444 | } |
445 | } | 445 | } |
446 | } | 446 | } |
447 | 447 | ||
448 | 448 | ||
449 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { | 449 | void AudioWidget::mousePressEvent( QMouseEvent *event ) { |
450 | mouseMoveEvent( event ); | 450 | mouseMoveEvent( event ); |
451 | } | 451 | } |
452 | 452 | ||
453 | 453 | ||
454 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { | 454 | void AudioWidget::mouseReleaseEvent( QMouseEvent *event ) { |
455 | mouseMoveEvent( event ); | 455 | mouseMoveEvent( event ); |
456 | } | 456 | } |
457 | 457 | ||
458 | 458 | ||
459 | void AudioWidget::showEvent( QShowEvent* ) { | 459 | void AudioWidget::showEvent( QShowEvent* ) { |
460 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); | 460 | QMouseEvent event( QEvent::MouseMove, QPoint( 0, 0 ), 0, 0 ); |
461 | mouseMoveEvent( &event ); | 461 | mouseMoveEvent( &event ); |
462 | } | 462 | } |
463 | 463 | ||
464 | 464 | ||
465 | void AudioWidget::closeEvent( QCloseEvent* ) { | 465 | void AudioWidget::closeEvent( QCloseEvent* ) { |
466 | mediaPlayerState->setList(); | 466 | mediaPlayerState->setList(); |
467 | } | 467 | } |
468 | 468 | ||
469 | 469 | ||
470 | void AudioWidget::paintEvent( QPaintEvent * pe ) { | 470 | void AudioWidget::paintEvent( QPaintEvent * pe ) { |
471 | if ( !pe->erased() ) { | 471 | if ( !pe->erased() ) { |
472 | // Combine with background and double buffer | 472 | // Combine with background and double buffer |
473 | QPixmap pix( pe->rect().size() ); | 473 | QPixmap pix( pe->rect().size() ); |
474 | QPainter p( &pix ); | 474 | QPainter p( &pix ); |
475 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); | 475 | p.translate( -pe->rect().topLeft().x(), -pe->rect().topLeft().y() ); |
476 | p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); | 476 | p.drawTiledPixmap( pe->rect(), pixBg, pe->rect().topLeft() ); |
477 | for ( int i = 0; i < numButtons; i++ ) | 477 | for ( int i = 0; i < numButtons; i++ ) |
478 | paintButton( &p, i ); | 478 | paintButton( &p, i ); |
479 | QPainter p2( this ); | 479 | QPainter p2( this ); |
480 | p2.drawPixmap( pe->rect().topLeft(), pix ); | 480 | p2.drawPixmap( pe->rect().topLeft(), pix ); |
481 | } else { | 481 | } else { |
482 | QPainter p( this ); | 482 | QPainter p( this ); |
483 | for ( int i = 0; i < numButtons; i++ ) | 483 | for ( int i = 0; i < numButtons; i++ ) |
484 | paintButton( &p, i ); | 484 | paintButton( &p, i ); |
485 | } | 485 | } |
486 | } | 486 | } |
487 | 487 | ||
488 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { | 488 | void AudioWidget::keyReleaseEvent( QKeyEvent *e) { |
489 | switch ( e->key() ) { | 489 | switch ( e->key() ) { |
490 | ////////////////////////////// Zaurus keys | 490 | ////////////////////////////// Zaurus keys |
491 | case Key_Home: | 491 | case Key_Home: |
492 | break; | 492 | break; |
493 | case Key_F9: //activity | 493 | case Key_F9: //activity |
494 | hide(); | 494 | hide(); |
495 | // qDebug("Audio F9"); | 495 | // qDebug("Audio F9"); |
496 | break; | 496 | break; |
497 | case Key_F10: //contacts | 497 | case Key_F10: //contacts |
498 | break; | 498 | break; |
499 | case Key_F11: //menu | 499 | case Key_F11: //menu |
500 | mediaPlayerState->toggleBlank(); | 500 | mediaPlayerState->toggleBlank(); |
501 | break; | 501 | break; |
502 | case Key_F12: //home | 502 | case Key_F12: //home |
503 | break; | 503 | break; |
504 | case Key_F13: //mail | 504 | case Key_F13: //mail |
505 | mediaPlayerState->toggleBlank(); | 505 | mediaPlayerState->toggleBlank(); |
506 | break; | 506 | break; |
507 | case Key_Space: { | 507 | case Key_Space: { |
508 | if(mediaPlayerState->isPlaying()) { | 508 | if(mediaPlayerState->isPlaying()) { |
509 | // toggleButton(1); | 509 | // toggleButton(1); |
510 | mediaPlayerState->setPlaying(FALSE); | 510 | mediaPlayerState->setPlaying(FALSE); |
511 | // toggleButton(1); | 511 | // toggleButton(1); |
512 | } else { | 512 | } else { |
513 | // toggleButton(0); | 513 | // toggleButton(0); |
514 | mediaPlayerState->setPlaying(TRUE); | 514 | mediaPlayerState->setPlaying(TRUE); |
515 | // toggleButton(0); | 515 | // toggleButton(0); |
516 | } | 516 | } |
517 | } | 517 | } |
518 | break; | 518 | break; |
519 | case Key_Down: | 519 | case Key_Down: |
520 | // toggleButton(6); | 520 | // toggleButton(6); |
521 | emit lessClicked(); | 521 | emit lessClicked(); |
522 | emit lessReleased(); | 522 | emit lessReleased(); |
523 | // toggleButton(6); | 523 | // toggleButton(6); |
524 | break; | 524 | break; |
525 | case Key_Up: | 525 | case Key_Up: |
526 | // toggleButton(5); | 526 | // toggleButton(5); |
527 | emit moreClicked(); | 527 | emit moreClicked(); |
528 | emit moreReleased(); | 528 | emit moreReleased(); |
529 | // toggleButton(5); | 529 | // toggleButton(5); |
530 | break; | 530 | break; |
531 | case Key_Right: | 531 | case Key_Right: |
532 | // toggleButton(3); | 532 | // toggleButton(3); |
533 | mediaPlayerState->setNext(); | 533 | mediaPlayerState->setNext(); |
534 | // toggleButton(3); | 534 | // toggleButton(3); |
535 | break; | 535 | break; |
536 | case Key_Left: | 536 | case Key_Left: |
537 | // toggleButton(4); | 537 | // toggleButton(4); |
538 | mediaPlayerState->setPrev(); | 538 | mediaPlayerState->setPrev(); |
539 | // toggleButton(4); | 539 | // toggleButton(4); |
540 | break; | 540 | break; |
541 | case Key_Escape: { | 541 | case Key_Escape: { |
542 | } | 542 | } |
543 | break; | 543 | break; |
544 | 544 | ||
545 | }; | 545 | }; |
546 | } | 546 | } |
diff --git a/noncore/multimedia/opieplayer2/audiowidget.h b/noncore/multimedia/opieplayer2/audiowidget.h index 3f0c059..91fcbc5 100644 --- a/noncore/multimedia/opieplayer2/audiowidget.h +++ b/noncore/multimedia/opieplayer2/audiowidget.h | |||
@@ -1,137 +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" | 49 | #include "mediaplayerstate.h" |
50 | 50 | ||
51 | class QPixmap; | 51 | class QPixmap; |
52 | 52 | ||
53 | namespace { | 53 | namespace { |
54 | 54 | ||
55 | enum AudioButtons { | 55 | enum AudioButtons { |
56 | AudioPlay=0, | 56 | AudioPlay=0, |
57 | AudioStop, | 57 | AudioStop, |
58 | AudioNext, | 58 | AudioNext, |
59 | AudioPrevious, | 59 | AudioPrevious, |
60 | AudioVolumeUp, | 60 | AudioVolumeUp, |
61 | AudioVolumeDown, | 61 | AudioVolumeDown, |
62 | AudioLoop, | 62 | AudioLoop, |
63 | AudioPlayList, | 63 | AudioPlayList, |
64 | AudioForward, | 64 | AudioForward, |
65 | AudioBack | 65 | AudioBack |
66 | }; | 66 | }; |
67 | }; | 67 | }; |
68 | 68 | ||
69 | class AudioWidget : public QWidget { | 69 | class AudioWidget : public QWidget { |
70 | Q_OBJECT | 70 | Q_OBJECT |
71 | public: | 71 | public: |
72 | AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); | 72 | AudioWidget( QWidget* parent=0, const char* name=0, WFlags f=0 ); |
73 | ~AudioWidget(); | 73 | ~AudioWidget(); |
74 | void setTickerText( const QString &text ) { songInfo.setText( text ); } | 74 | void setTickerText( const QString &text ) { songInfo.setText( text ); } |
75 | public slots: | 75 | public slots: |
76 | void updateSlider( long, long ); | 76 | void updateSlider( long, long ); |
77 | void sliderPressed( ); | 77 | void sliderPressed( ); |
78 | void sliderReleased( ); | 78 | void sliderReleased( ); |
79 | void setLooping( bool b) { setToggleButton( AudioLoop, b ); } | 79 | void setLooping( bool b) { setToggleButton( AudioLoop, b ); } |
80 | void setPlaying( bool b) { setToggleButton( AudioPlay, b ); } | 80 | void setPlaying( bool b) { setToggleButton( AudioPlay, b ); } |
81 | void setPosition( long ); | 81 | void setPosition( long ); |
82 | void setLength( long ); | 82 | void setLength( long ); |
83 | void setSeekable( bool ); | 83 | void setSeekable( bool ); |
84 | void setMediaType( MediaPlayerState::MediaType mediaType ); | 84 | void setDisplayType( MediaPlayerState::DisplayType displayType ); |
85 | 85 | ||
86 | signals: | 86 | signals: |
87 | void moreClicked(); | 87 | void moreClicked(); |
88 | void lessClicked(); | 88 | void lessClicked(); |
89 | void moreReleased(); | 89 | void moreReleased(); |
90 | void lessReleased(); | 90 | void lessReleased(); |
91 | void forwardClicked(); | 91 | void forwardClicked(); |
92 | void backClicked(); | 92 | void backClicked(); |
93 | void forwardReleased(); | 93 | void forwardReleased(); |
94 | void backReleased(); | 94 | void backReleased(); |
95 | void sliderMoved(long); | 95 | void sliderMoved(long); |
96 | 96 | ||
97 | protected: | 97 | protected: |
98 | void doBlank(); | 98 | void doBlank(); |
99 | void doUnblank(); | 99 | void doUnblank(); |
100 | void paintEvent( QPaintEvent *pe ); | 100 | void paintEvent( QPaintEvent *pe ); |
101 | void showEvent( QShowEvent *se ); | 101 | void showEvent( QShowEvent *se ); |
102 | void resizeEvent( QResizeEvent *re ); | 102 | void resizeEvent( QResizeEvent *re ); |
103 | void mouseMoveEvent( QMouseEvent *event ); | 103 | void mouseMoveEvent( QMouseEvent *event ); |
104 | void mousePressEvent( QMouseEvent *event ); | 104 | void mousePressEvent( QMouseEvent *event ); |
105 | void mouseReleaseEvent( QMouseEvent *event ); | 105 | void mouseReleaseEvent( QMouseEvent *event ); |
106 | void timerEvent( QTimerEvent *event ); | 106 | void timerEvent( QTimerEvent *event ); |
107 | void closeEvent( QCloseEvent *event ); | 107 | void closeEvent( QCloseEvent *event ); |
108 | void keyReleaseEvent( QKeyEvent *e); | 108 | void keyReleaseEvent( QKeyEvent *e); |
109 | private slots: | 109 | private slots: |
110 | void skipFor(); | 110 | void skipFor(); |
111 | void skipBack(); | 111 | void skipBack(); |
112 | void stopSkip(); | 112 | void stopSkip(); |
113 | private: | 113 | private: |
114 | void toggleButton( int ); | 114 | void toggleButton( int ); |
115 | void setToggleButton( int, bool ); | 115 | void setToggleButton( int, bool ); |
116 | void paintButton( QPainter *p, int i ); | 116 | void paintButton( QPainter *p, int i ); |
117 | int skipDirection; | 117 | int skipDirection; |
118 | QString skin; | 118 | QString skin; |
119 | QPixmap pixBg; | 119 | QPixmap pixBg; |
120 | QImage imgUp; | 120 | QImage imgUp; |
121 | QImage imgDn; | 121 | QImage imgDn; |
122 | QImage imgButtonMask; | 122 | QImage imgButtonMask; |
123 | QBitmap *masks[10]; | 123 | QBitmap *masks[10]; |
124 | QPixmap *buttonPixUp[10]; | 124 | QPixmap *buttonPixUp[10]; |
125 | QPixmap *buttonPixDown[10]; | 125 | QPixmap *buttonPixDown[10]; |
126 | 126 | ||
127 | QPixmap *pixmaps[4]; | 127 | QPixmap *pixmaps[4]; |
128 | OTicker songInfo; | 128 | OTicker songInfo; |
129 | QSlider slider; | 129 | QSlider slider; |
130 | QLineEdit time; | 130 | QLineEdit time; |
131 | int xoff, yoff; | 131 | int xoff, yoff; |
132 | bool isStreaming : 1; | 132 | bool isStreaming : 1; |
133 | }; | 133 | }; |
134 | 134 | ||
135 | 135 | ||
136 | #endif // AUDIO_WIDGET_H | 136 | #endif // AUDIO_WIDGET_H |
137 | 137 | ||
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp index 22451b7..6806adc 100644 --- a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp | |||
@@ -1,264 +1,272 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> |
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | 5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> |
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
7 | =. | 7 | =. |
8 | .=l. | 8 | .=l. |
9 | .>+-= | 9 | .>+-= |
10 | _;:, .> :=|. This program is free software; you can | 10 | _;:, .> :=|. This program is free software; you can |
11 | .> <`_, > . <= redistribute it and/or modify it under | 11 | .> <`_, > . <= redistribute it and/or modify it under |
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
13 | .="- .-=="i, .._ License as published by the Free Software | 13 | .="- .-=="i, .._ License as published by the Free Software |
14 | - . .-<_> .<> Foundation; either version 2 of the License, | 14 | - . .-<_> .<> Foundation; either version 2 of the License, |
15 | ._= =} : or (at your option) any later version. | 15 | ._= =} : or (at your option) any later version. |
16 | .%`+i> _;_. | 16 | .%`+i> _;_. |
17 | .i_,=:_. -<s. This program is distributed in the hope that | 17 | .i_,=:_. -<s. This program is distributed in the hope that |
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
19 | : .. .:, . . . without even the implied warranty of | 19 | : .. .:, . . . without even the implied warranty of |
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
22 | ..}^=.= = ; General Public License for more | 22 | ..}^=.= = ; 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 | -_. . . )=. = General Public License along with | 26 | -_. . . )=. = 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 | // this file is based on work by trolltech | 34 | // this file is based on work by trolltech |
35 | 35 | ||
36 | #include <qpe/qpeapplication.h> | 36 | #include <qpe/qpeapplication.h> |
37 | #include <qpe/qlibrary.h> | 37 | #include <qpe/qlibrary.h> |
38 | #include <qpe/config.h> | 38 | #include <qpe/config.h> |
39 | #include <qvaluelist.h> | 39 | #include <qvaluelist.h> |
40 | #include <qobject.h> | 40 | #include <qobject.h> |
41 | #include <qdir.h> | 41 | #include <qdir.h> |
42 | #include "mediaplayerstate.h" | 42 | #include "mediaplayerstate.h" |
43 | 43 | ||
44 | 44 | #include <assert.h> | |
45 | 45 | ||
46 | //#define MediaPlayerDebug(x) qDebug x | 46 | //#define MediaPlayerDebug(x) qDebug x |
47 | #define MediaPlayerDebug(x) | 47 | #define MediaPlayerDebug(x) |
48 | 48 | ||
49 | 49 | ||
50 | MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) | 50 | MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) |
51 | : QObject( parent, name ) { | 51 | : QObject( parent, name ) { |
52 | Config cfg( "OpiePlayer" ); | 52 | Config cfg( "OpiePlayer" ); |
53 | readConfig( cfg ); | 53 | readConfig( cfg ); |
54 | streaming = false; | 54 | streaming = false; |
55 | seekable = true; | 55 | seekable = true; |
56 | } | 56 | } |
57 | 57 | ||
58 | 58 | ||
59 | MediaPlayerState::~MediaPlayerState() { | 59 | MediaPlayerState::~MediaPlayerState() { |
60 | } | 60 | } |
61 | 61 | ||
62 | 62 | ||
63 | void MediaPlayerState::readConfig( Config& cfg ) { | 63 | void MediaPlayerState::readConfig( Config& cfg ) { |
64 | cfg.setGroup("Options"); | 64 | cfg.setGroup("Options"); |
65 | fullscreen = cfg.readBoolEntry( "FullScreen" ); | 65 | fullscreen = cfg.readBoolEntry( "FullScreen" ); |
66 | scaled = cfg.readBoolEntry( "Scaling" ); | 66 | scaled = cfg.readBoolEntry( "Scaling" ); |
67 | looping = cfg.readBoolEntry( "Looping" ); | 67 | looping = cfg.readBoolEntry( "Looping" ); |
68 | shuffled = cfg.readBoolEntry( "Shuffle" ); | 68 | shuffled = cfg.readBoolEntry( "Shuffle" ); |
69 | videoGamma = cfg.readNumEntry( "VideoGamma" ); | 69 | videoGamma = cfg.readNumEntry( "VideoGamma" ); |
70 | playing = FALSE; | 70 | playing = FALSE; |
71 | streaming = FALSE; | 71 | streaming = FALSE; |
72 | paused = FALSE; | 72 | paused = FALSE; |
73 | curPosition = 0; | 73 | curPosition = 0; |
74 | curLength = 0; | 74 | curLength = 0; |
75 | curView = 'l'; | 75 | curView = 'l'; |
76 | } | 76 | } |
77 | 77 | ||
78 | 78 | ||
79 | void MediaPlayerState::writeConfig( Config& cfg ) const { | 79 | void MediaPlayerState::writeConfig( Config& cfg ) const { |
80 | cfg.setGroup( "Options" ); | 80 | cfg.setGroup( "Options" ); |
81 | cfg.writeEntry( "FullScreen", fullscreen ); | 81 | cfg.writeEntry( "FullScreen", fullscreen ); |
82 | cfg.writeEntry( "Scaling", scaled ); | 82 | cfg.writeEntry( "Scaling", scaled ); |
83 | cfg.writeEntry( "Looping", looping ); | 83 | cfg.writeEntry( "Looping", looping ); |
84 | cfg.writeEntry( "Shuffle", shuffled ); | 84 | cfg.writeEntry( "Shuffle", shuffled ); |
85 | cfg.writeEntry( "VideoGamma", videoGamma ); | 85 | cfg.writeEntry( "VideoGamma", videoGamma ); |
86 | } | 86 | } |
87 | 87 | ||
88 | MediaPlayerState::MediaType MediaPlayerState::mediaType() const | 88 | MediaPlayerState::DisplayType MediaPlayerState::displayType() const |
89 | { | 89 | { |
90 | return view() == 'a' ? MediaPlayerState::Audio : MediaPlayerState::Video; | 90 | char v = view(); |
91 | switch ( v ) { | ||
92 | case 'a': return MediaPlayerState::Audio; | ||
93 | case 'v': return MediaPlayerState::Video; | ||
94 | case 'l': return MediaPlayerState::MediaSelection; | ||
95 | default: assert( false ); | ||
96 | } | ||
97 | // never reached | ||
98 | return MediaPlayerState::MediaSelection; | ||
91 | } | 99 | } |
92 | 100 | ||
93 | // slots | 101 | // slots |
94 | void MediaPlayerState::setIsStreaming( bool b ) { | 102 | void MediaPlayerState::setIsStreaming( bool b ) { |
95 | streaming = b; | 103 | streaming = b; |
96 | } | 104 | } |
97 | 105 | ||
98 | void MediaPlayerState::setIsSeekable( bool b ) { | 106 | void MediaPlayerState::setIsSeekable( bool b ) { |
99 | seekable = b; | 107 | seekable = b; |
100 | emit isSeekableToggled(b); | 108 | emit isSeekableToggled(b); |
101 | } | 109 | } |
102 | 110 | ||
103 | 111 | ||
104 | void MediaPlayerState::setFullscreen( bool b ) { | 112 | void MediaPlayerState::setFullscreen( bool b ) { |
105 | if ( fullscreen == b ) { | 113 | if ( fullscreen == b ) { |
106 | return; | 114 | return; |
107 | } | 115 | } |
108 | fullscreen = b; | 116 | fullscreen = b; |
109 | emit fullscreenToggled(b); | 117 | emit fullscreenToggled(b); |
110 | } | 118 | } |
111 | 119 | ||
112 | 120 | ||
113 | void MediaPlayerState::setBlanked( bool b ) { | 121 | void MediaPlayerState::setBlanked( bool b ) { |
114 | if ( blanked == b ) { | 122 | if ( blanked == b ) { |
115 | return; | 123 | return; |
116 | } | 124 | } |
117 | blanked = b; | 125 | blanked = b; |
118 | emit blankToggled(b); | 126 | emit blankToggled(b); |
119 | } | 127 | } |
120 | 128 | ||
121 | 129 | ||
122 | void MediaPlayerState::setScaled( bool b ) { | 130 | void MediaPlayerState::setScaled( bool b ) { |
123 | if ( scaled == b ) { | 131 | if ( scaled == b ) { |
124 | return; | 132 | return; |
125 | } | 133 | } |
126 | scaled = b; | 134 | scaled = b; |
127 | emit scaledToggled(b); | 135 | emit scaledToggled(b); |
128 | } | 136 | } |
129 | 137 | ||
130 | void MediaPlayerState::setLooping( bool b ) { | 138 | void MediaPlayerState::setLooping( bool b ) { |
131 | if ( looping == b ) { | 139 | if ( looping == b ) { |
132 | return; | 140 | return; |
133 | } | 141 | } |
134 | looping = b; | 142 | looping = b; |
135 | emit loopingToggled(b); | 143 | emit loopingToggled(b); |
136 | } | 144 | } |
137 | 145 | ||
138 | void MediaPlayerState::setShuffled( bool b ) { | 146 | void MediaPlayerState::setShuffled( bool b ) { |
139 | if ( shuffled == b ) { | 147 | if ( shuffled == b ) { |
140 | return; | 148 | return; |
141 | } | 149 | } |
142 | shuffled = b; | 150 | shuffled = b; |
143 | emit shuffledToggled(b); | 151 | emit shuffledToggled(b); |
144 | } | 152 | } |
145 | 153 | ||
146 | void MediaPlayerState::setPaused( bool b ) { | 154 | void MediaPlayerState::setPaused( bool b ) { |
147 | if ( paused == b ) { | 155 | if ( paused == b ) { |
148 | paused = FALSE; | 156 | paused = FALSE; |
149 | emit pausedToggled(FALSE); | 157 | emit pausedToggled(FALSE); |
150 | return; | 158 | return; |
151 | } | 159 | } |
152 | paused = b; | 160 | paused = b; |
153 | emit pausedToggled(b); | 161 | emit pausedToggled(b); |
154 | } | 162 | } |
155 | 163 | ||
156 | void MediaPlayerState::setPlaying( bool b ) { | 164 | void MediaPlayerState::setPlaying( bool b ) { |
157 | if ( playing == b ) { | 165 | if ( playing == b ) { |
158 | return; | 166 | return; |
159 | } | 167 | } |
160 | playing = b; | 168 | playing = b; |
161 | stopped = !b; | 169 | stopped = !b; |
162 | emit playingToggled(b); | 170 | emit playingToggled(b); |
163 | } | 171 | } |
164 | 172 | ||
165 | void MediaPlayerState::setStopped( bool b ) { | 173 | void MediaPlayerState::setStopped( bool b ) { |
166 | if ( stopped == b ) { | 174 | if ( stopped == b ) { |
167 | return; | 175 | return; |
168 | } | 176 | } |
169 | stopped = b; | 177 | stopped = b; |
170 | emit stopToggled(b); | 178 | emit stopToggled(b); |
171 | } | 179 | } |
172 | 180 | ||
173 | void MediaPlayerState::setPosition( long p ) { | 181 | void MediaPlayerState::setPosition( long p ) { |
174 | if ( curPosition == p ) { | 182 | if ( curPosition == p ) { |
175 | return; | 183 | return; |
176 | } | 184 | } |
177 | curPosition = p; | 185 | curPosition = p; |
178 | emit positionChanged(p); | 186 | emit positionChanged(p); |
179 | } | 187 | } |
180 | 188 | ||
181 | void MediaPlayerState::updatePosition( long p ){ | 189 | void MediaPlayerState::updatePosition( long p ){ |
182 | if ( curPosition == p ) { | 190 | if ( curPosition == p ) { |
183 | return; | 191 | return; |
184 | } | 192 | } |
185 | curPosition = p; | 193 | curPosition = p; |
186 | emit positionUpdated(p); | 194 | emit positionUpdated(p); |
187 | } | 195 | } |
188 | 196 | ||
189 | void MediaPlayerState::setVideoGamma( int v ){ | 197 | void MediaPlayerState::setVideoGamma( int v ){ |
190 | if ( videoGamma == v ) { | 198 | if ( videoGamma == v ) { |
191 | return; | 199 | return; |
192 | } | 200 | } |
193 | videoGamma = v; | 201 | videoGamma = v; |
194 | emit videoGammaChanged( v ); | 202 | emit videoGammaChanged( v ); |
195 | } | 203 | } |
196 | 204 | ||
197 | void MediaPlayerState::setLength( long l ) { | 205 | void MediaPlayerState::setLength( long l ) { |
198 | if ( curLength == l ) { | 206 | if ( curLength == l ) { |
199 | return; | 207 | return; |
200 | } | 208 | } |
201 | curLength = l; | 209 | curLength = l; |
202 | emit lengthChanged(l); | 210 | emit lengthChanged(l); |
203 | } | 211 | } |
204 | 212 | ||
205 | void MediaPlayerState::setView( char v ) { | 213 | void MediaPlayerState::setView( char v ) { |
206 | if ( curView == v ) { | 214 | if ( curView == v ) { |
207 | return; | 215 | return; |
208 | } | 216 | } |
209 | curView = v; | 217 | curView = v; |
210 | emit viewChanged(v); | 218 | emit viewChanged(v); |
211 | emit mediaTypeChanged( mediaType() ); | 219 | emit displayTypeChanged( displayType() ); |
212 | } | 220 | } |
213 | 221 | ||
214 | void MediaPlayerState::setPrev(){ | 222 | void MediaPlayerState::setPrev(){ |
215 | emit prev(); | 223 | emit prev(); |
216 | } | 224 | } |
217 | 225 | ||
218 | void MediaPlayerState::setNext() { | 226 | void MediaPlayerState::setNext() { |
219 | emit next(); | 227 | emit next(); |
220 | } | 228 | } |
221 | 229 | ||
222 | void MediaPlayerState::setList() { | 230 | void MediaPlayerState::setList() { |
223 | setPlaying( FALSE ); | 231 | setPlaying( FALSE ); |
224 | setView('l'); | 232 | setView('l'); |
225 | } | 233 | } |
226 | 234 | ||
227 | void MediaPlayerState::setVideo() { | 235 | void MediaPlayerState::setVideo() { |
228 | setView('v'); | 236 | setView('v'); |
229 | } | 237 | } |
230 | 238 | ||
231 | void MediaPlayerState::setAudio() { | 239 | void MediaPlayerState::setAudio() { |
232 | setView('a'); | 240 | setView('a'); |
233 | } | 241 | } |
234 | 242 | ||
235 | void MediaPlayerState::toggleFullscreen() { | 243 | void MediaPlayerState::toggleFullscreen() { |
236 | setFullscreen( !fullscreen ); | 244 | setFullscreen( !fullscreen ); |
237 | } | 245 | } |
238 | 246 | ||
239 | void MediaPlayerState::toggleScaled() { | 247 | void MediaPlayerState::toggleScaled() { |
240 | setScaled( !scaled); | 248 | setScaled( !scaled); |
241 | } | 249 | } |
242 | 250 | ||
243 | void MediaPlayerState::toggleLooping() { | 251 | void MediaPlayerState::toggleLooping() { |
244 | setLooping( !looping); | 252 | setLooping( !looping); |
245 | } | 253 | } |
246 | 254 | ||
247 | void MediaPlayerState::toggleShuffled() { | 255 | void MediaPlayerState::toggleShuffled() { |
248 | setShuffled( !shuffled); | 256 | setShuffled( !shuffled); |
249 | } | 257 | } |
250 | 258 | ||
251 | void MediaPlayerState::togglePaused() { | 259 | void MediaPlayerState::togglePaused() { |
252 | setPaused( !paused); | 260 | setPaused( !paused); |
253 | } | 261 | } |
254 | 262 | ||
255 | void MediaPlayerState::togglePlaying() { | 263 | void MediaPlayerState::togglePlaying() { |
256 | setPlaying( !playing); | 264 | setPlaying( !playing); |
257 | } | 265 | } |
258 | 266 | ||
259 | void MediaPlayerState::toggleBlank() { | 267 | void MediaPlayerState::toggleBlank() { |
260 | setBlanked( !blanked); | 268 | setBlanked( !blanked); |
261 | } | 269 | } |
262 | 270 | ||
263 | 271 | ||
264 | 272 | ||
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.h b/noncore/multimedia/opieplayer2/mediaplayerstate.h index 05264cf..ca531c5 100644 --- a/noncore/multimedia/opieplayer2/mediaplayerstate.h +++ b/noncore/multimedia/opieplayer2/mediaplayerstate.h | |||
@@ -1,143 +1,143 @@ | |||
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 | ..}^=.= = ; General Public License for more | 22 | ..}^=.= = ; 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 | -_. . . )=. = General Public License along with | 26 | -_. . . )=. = 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 | // this file is based on work by trolltech | 34 | // this file is based on work by trolltech |
35 | 35 | ||
36 | #ifndef MEDIA_PLAYER_STATE_H | 36 | #ifndef MEDIA_PLAYER_STATE_H |
37 | #define MEDIA_PLAYER_STATE_H | 37 | #define MEDIA_PLAYER_STATE_H |
38 | 38 | ||
39 | 39 | ||
40 | #include <qobject.h> | 40 | #include <qobject.h> |
41 | 41 | ||
42 | 42 | ||
43 | class MediaPlayerDecoder; | 43 | class MediaPlayerDecoder; |
44 | class Config; | 44 | class Config; |
45 | 45 | ||
46 | 46 | ||
47 | class MediaPlayerState : public QObject { | 47 | class MediaPlayerState : public QObject { |
48 | Q_OBJECT | 48 | Q_OBJECT |
49 | public: | 49 | public: |
50 | enum MediaType { Audio, Video }; | 50 | enum DisplayType { Audio, Video, MediaSelection }; |
51 | 51 | ||
52 | MediaPlayerState( QObject *parent, const char *name ); | 52 | MediaPlayerState( QObject *parent, const char *name ); |
53 | ~MediaPlayerState(); | 53 | ~MediaPlayerState(); |
54 | 54 | ||
55 | bool isStreaming() const { return streaming; } | 55 | bool isStreaming() const { return streaming; } |
56 | bool isSeekable() const { return seekable; } | 56 | bool isSeekable() const { return seekable; } |
57 | bool isFullscreen() const { return fullscreen; } | 57 | bool isFullscreen() const { return fullscreen; } |
58 | bool isScaled() const { return scaled; } | 58 | bool isScaled() const { return scaled; } |
59 | bool isLooping() const { return looping; } | 59 | bool isLooping() const { return looping; } |
60 | bool isShuffled() const { return shuffled; } | 60 | bool isShuffled() const { return shuffled; } |
61 | bool isPaused() const { return paused; } | 61 | bool isPaused() const { return paused; } |
62 | bool isPlaying() const { return playing; } | 62 | bool isPlaying() const { return playing; } |
63 | bool isStopped() const { return stopped; } | 63 | bool isStopped() const { return stopped; } |
64 | long position() const { return curPosition; } | 64 | long position() const { return curPosition; } |
65 | long length() const { return curLength; } | 65 | long length() const { return curLength; } |
66 | char view() const { return curView; } | 66 | char view() const { return curView; } |
67 | MediaType mediaType() const; | 67 | DisplayType displayType() const; |
68 | 68 | ||
69 | public slots: | 69 | public slots: |
70 | void setIsStreaming( bool b ); | 70 | void setIsStreaming( bool b ); |
71 | void setIsSeekable( bool b ); | 71 | void setIsSeekable( bool b ); |
72 | void setFullscreen( bool b ); | 72 | void setFullscreen( bool b ); |
73 | void setScaled( bool b ); | 73 | void setScaled( bool b ); |
74 | void setLooping( bool b ); | 74 | void setLooping( bool b ); |
75 | void setShuffled( bool b ); | 75 | void setShuffled( bool b ); |
76 | void setPaused( bool b ); | 76 | void setPaused( bool b ); |
77 | void setPlaying( bool b ); | 77 | void setPlaying( bool b ); |
78 | void setStopped( bool b ); | 78 | void setStopped( bool b ); |
79 | void setPosition( long p ); | 79 | void setPosition( long p ); |
80 | void updatePosition( long p ); | 80 | void updatePosition( long p ); |
81 | void setLength( long l ); | 81 | void setLength( long l ); |
82 | void setView( char v ); | 82 | void setView( char v ); |
83 | void setBlanked( bool b ); | 83 | void setBlanked( bool b ); |
84 | void setVideoGamma( int v ); | 84 | void setVideoGamma( int v ); |
85 | 85 | ||
86 | void setPrev(); | 86 | void setPrev(); |
87 | void setNext(); | 87 | void setNext(); |
88 | void setList(); | 88 | void setList(); |
89 | void setVideo(); | 89 | void setVideo(); |
90 | void setAudio(); | 90 | void setAudio(); |
91 | 91 | ||
92 | void toggleFullscreen(); | 92 | void toggleFullscreen(); |
93 | void toggleScaled(); | 93 | void toggleScaled(); |
94 | void toggleLooping(); | 94 | void toggleLooping(); |
95 | void toggleShuffled(); | 95 | void toggleShuffled(); |
96 | void togglePaused(); | 96 | void togglePaused(); |
97 | void togglePlaying(); | 97 | void togglePlaying(); |
98 | void toggleBlank(); | 98 | void toggleBlank(); |
99 | void writeConfig( Config& cfg ) const; | 99 | void writeConfig( Config& cfg ) const; |
100 | 100 | ||
101 | 101 | ||
102 | signals: | 102 | signals: |
103 | void fullscreenToggled( bool ); | 103 | void fullscreenToggled( bool ); |
104 | void scaledToggled( bool ); | 104 | void scaledToggled( bool ); |
105 | void loopingToggled( bool ); | 105 | void loopingToggled( bool ); |
106 | void shuffledToggled( bool ); | 106 | void shuffledToggled( bool ); |
107 | void pausedToggled( bool ); | 107 | void pausedToggled( bool ); |
108 | void playingToggled( bool ); | 108 | void playingToggled( bool ); |
109 | void stopToggled( bool ); | 109 | void stopToggled( bool ); |
110 | void positionChanged( long ); // When the slider is moved | 110 | void positionChanged( long ); // When the slider is moved |
111 | void positionUpdated( long ); // When the media file progresses | 111 | void positionUpdated( long ); // When the media file progresses |
112 | void lengthChanged( long ); | 112 | void lengthChanged( long ); |
113 | void viewChanged( char ); | 113 | void viewChanged( char ); |
114 | void mediaTypeChanged( MediaPlayerState::MediaType type ); | 114 | void displayTypeChanged( MediaPlayerState::DisplayType type ); |
115 | void isSeekableToggled( bool ); | 115 | void isSeekableToggled( bool ); |
116 | void blankToggled( bool ); | 116 | void blankToggled( bool ); |
117 | void videoGammaChanged( int ); | 117 | void videoGammaChanged( int ); |
118 | void prev(); | 118 | void prev(); |
119 | void next(); | 119 | void next(); |
120 | 120 | ||
121 | private: | 121 | private: |
122 | bool streaming : 1; | 122 | bool streaming : 1; |
123 | bool seekable : 1; | 123 | bool seekable : 1; |
124 | bool fullscreen: 1; | 124 | bool fullscreen: 1; |
125 | bool scaled : 1; | 125 | bool scaled : 1; |
126 | bool blanked : 1; | 126 | bool blanked : 1; |
127 | bool looping : 1; | 127 | bool looping : 1; |
128 | bool shuffled : 1; | 128 | bool shuffled : 1; |
129 | bool usePlaylist : 1; | 129 | bool usePlaylist : 1; |
130 | bool paused : 1; | 130 | bool paused : 1; |
131 | bool playing : 1; | 131 | bool playing : 1; |
132 | bool stopped : 1; | 132 | bool stopped : 1; |
133 | long curPosition; | 133 | long curPosition; |
134 | long curLength; | 134 | long curLength; |
135 | char curView; | 135 | char curView; |
136 | int videoGamma; | 136 | int videoGamma; |
137 | void readConfig( Config& cfg ); | 137 | void readConfig( Config& cfg ); |
138 | 138 | ||
139 | }; | 139 | }; |
140 | 140 | ||
141 | 141 | ||
142 | #endif // MEDIA_PLAYER_STATE_H | 142 | #endif // MEDIA_PLAYER_STATE_H |
143 | 143 | ||