Diffstat (limited to 'noncore/multimedia/opieplayer2/mediaplayerstate.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayerstate.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
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 | |||
@@ -20,95 +20,103 @@ | |||
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 ) { |
@@ -187,49 +195,49 @@ void MediaPlayerState::updatePosition( long 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() { |