summaryrefslogtreecommitdiff
path: root/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
Unidiff
Diffstat (limited to 'noncore/multimedia/opieplayer2/mediaplayerstate.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/mediaplayerstate.cpp39
1 files changed, 26 insertions, 13 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
index 6806adc..901b43f 100644
--- a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
+++ b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp
@@ -51,72 +51,76 @@ 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
59MediaPlayerState::~MediaPlayerState() { 59MediaPlayerState::~MediaPlayerState() {
60} 60}
61 61
62 62
63void MediaPlayerState::readConfig( Config& cfg ) { 63void 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 m_displayType = MediaSelection;
76} 76}
77 77
78 78
79void MediaPlayerState::writeConfig( Config& cfg ) const { 79void 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
88MediaPlayerState::DisplayType MediaPlayerState::displayType() const 88char MediaPlayerState::view() const
89{ 89{
90 char v = view(); 90 switch ( m_displayType ) {
91 switch ( v ) { 91 case Audio: return 'a';
92 case 'a': return MediaPlayerState::Audio; 92 case Video: return 'v';
93 case 'v': return MediaPlayerState::Video; 93 case MediaSelection: return 'l';
94 case 'l': return MediaPlayerState::MediaSelection;
95 default: assert( false ); 94 default: assert( false );
96 } 95 }
97 // never reached 96 // never reached
98 return MediaPlayerState::MediaSelection; 97 return 42;
98}
99
100MediaPlayerState::DisplayType MediaPlayerState::displayType() const
101{
102 return m_displayType;
99} 103}
100 104
101// slots 105// slots
102void MediaPlayerState::setIsStreaming( bool b ) { 106void MediaPlayerState::setIsStreaming( bool b ) {
103 streaming = b; 107 streaming = b;
104} 108}
105 109
106void MediaPlayerState::setIsSeekable( bool b ) { 110void MediaPlayerState::setIsSeekable( bool b ) {
107 seekable = b; 111 seekable = b;
108 emit isSeekableToggled(b); 112 emit isSeekableToggled(b);
109} 113}
110 114
111 115
112void MediaPlayerState::setFullscreen( bool b ) { 116void MediaPlayerState::setFullscreen( bool b ) {
113 if ( fullscreen == b ) { 117 if ( fullscreen == b ) {
114 return; 118 return;
115 } 119 }
116 fullscreen = b; 120 fullscreen = b;
117 emit fullscreenToggled(b); 121 emit fullscreenToggled(b);
118} 122}
119 123
120 124
121void MediaPlayerState::setBlanked( bool b ) { 125void MediaPlayerState::setBlanked( bool b ) {
122 if ( blanked == b ) { 126 if ( blanked == b ) {
@@ -190,54 +194,63 @@ void MediaPlayerState::updatePosition( long p ){
190 if ( curPosition == p ) { 194 if ( curPosition == p ) {
191 return; 195 return;
192 } 196 }
193 curPosition = p; 197 curPosition = p;
194 emit positionUpdated(p); 198 emit positionUpdated(p);
195} 199}
196 200
197void MediaPlayerState::setVideoGamma( int v ){ 201void MediaPlayerState::setVideoGamma( int v ){
198 if ( videoGamma == v ) { 202 if ( videoGamma == v ) {
199 return; 203 return;
200 } 204 }
201 videoGamma = v; 205 videoGamma = v;
202 emit videoGammaChanged( v ); 206 emit videoGammaChanged( v );
203} 207}
204 208
205void MediaPlayerState::setLength( long l ) { 209void MediaPlayerState::setLength( long l ) {
206 if ( curLength == l ) { 210 if ( curLength == l ) {
207 return; 211 return;
208 } 212 }
209 curLength = l; 213 curLength = l;
210 emit lengthChanged(l); 214 emit lengthChanged(l);
211} 215}
212 216
213void MediaPlayerState::setView( char v ) { 217void MediaPlayerState::setView( char v ) {
214 if ( curView == v ) { 218 switch ( v ) {
215 return; 219 case 'a': setDisplayType( Audio ); return;
220 case 'v': setDisplayType( Video ); return;
221 case 'l': setDisplayType( MediaSelection ); return;
222 default: assert( false );
216 } 223 }
217 curView = v; 224}
218 emit viewChanged(v); 225
219 emit displayTypeChanged( displayType() ); 226void MediaPlayerState::setDisplayType( DisplayType displayType )
227{
228 if ( m_displayType == displayType )
229 return;
230
231 m_displayType = displayType;
232 emit displayTypeChanged( m_displayType );
220} 233}
221 234
222void MediaPlayerState::setPrev(){ 235void MediaPlayerState::setPrev(){
223 emit prev(); 236 emit prev();
224} 237}
225 238
226void MediaPlayerState::setNext() { 239void MediaPlayerState::setNext() {
227 emit next(); 240 emit next();
228} 241}
229 242
230void MediaPlayerState::setList() { 243void MediaPlayerState::setList() {
231 setPlaying( FALSE ); 244 setPlaying( FALSE );
232 setView('l'); 245 setView('l');
233} 246}
234 247
235void MediaPlayerState::setVideo() { 248void MediaPlayerState::setVideo() {
236 setView('v'); 249 setView('v');
237} 250}
238 251
239void MediaPlayerState::setAudio() { 252void MediaPlayerState::setAudio() {
240 setView('a'); 253 setView('a');
241} 254}
242 255
243void MediaPlayerState::toggleFullscreen() { 256void MediaPlayerState::toggleFullscreen() {