-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayerstate.cpp | 39 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayerstate.h | 6 |
2 files changed, 29 insertions, 16 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 | |||
@@ -59,56 +59,60 @@ MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) | |||
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 | m_displayType = MediaSelection; |
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::DisplayType MediaPlayerState::displayType() const | 88 | char 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 | |||
100 | MediaPlayerState::DisplayType MediaPlayerState::displayType() const | ||
101 | { | ||
102 | return m_displayType; | ||
99 | } | 103 | } |
100 | 104 | ||
101 | // slots | 105 | // slots |
102 | void MediaPlayerState::setIsStreaming( bool b ) { | 106 | void MediaPlayerState::setIsStreaming( bool b ) { |
103 | streaming = b; | 107 | streaming = b; |
104 | } | 108 | } |
105 | 109 | ||
106 | void MediaPlayerState::setIsSeekable( bool b ) { | 110 | void MediaPlayerState::setIsSeekable( bool b ) { |
107 | seekable = b; | 111 | seekable = b; |
108 | emit isSeekableToggled(b); | 112 | emit isSeekableToggled(b); |
109 | } | 113 | } |
110 | 114 | ||
111 | 115 | ||
112 | void MediaPlayerState::setFullscreen( bool b ) { | 116 | void MediaPlayerState::setFullscreen( bool b ) { |
113 | if ( fullscreen == b ) { | 117 | if ( fullscreen == b ) { |
114 | return; | 118 | return; |
@@ -198,38 +202,47 @@ void 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 | ||
205 | void MediaPlayerState::setLength( long l ) { | 209 | void 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 | ||
213 | void MediaPlayerState::setView( char v ) { | 217 | void 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() ); | 226 | void 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 | ||
222 | void MediaPlayerState::setPrev(){ | 235 | void MediaPlayerState::setPrev(){ |
223 | emit prev(); | 236 | emit prev(); |
224 | } | 237 | } |
225 | 238 | ||
226 | void MediaPlayerState::setNext() { | 239 | void MediaPlayerState::setNext() { |
227 | emit next(); | 240 | emit next(); |
228 | } | 241 | } |
229 | 242 | ||
230 | void MediaPlayerState::setList() { | 243 | void MediaPlayerState::setList() { |
231 | setPlaying( FALSE ); | 244 | setPlaying( FALSE ); |
232 | setView('l'); | 245 | setView('l'); |
233 | } | 246 | } |
234 | 247 | ||
235 | void MediaPlayerState::setVideo() { | 248 | void MediaPlayerState::setVideo() { |
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.h b/noncore/multimedia/opieplayer2/mediaplayerstate.h index ca531c5..b18780b 100644 --- a/noncore/multimedia/opieplayer2/mediaplayerstate.h +++ b/noncore/multimedia/opieplayer2/mediaplayerstate.h | |||
@@ -50,94 +50,94 @@ public: | |||
50 | enum DisplayType { Audio, Video, MediaSelection }; | 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; |
67 | DisplayType displayType() 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 setDisplayType( MediaPlayerState::DisplayType displayType ); | ||
83 | void setBlanked( bool b ); | 84 | void setBlanked( bool b ); |
84 | void setVideoGamma( int v ); | 85 | void setVideoGamma( int v ); |
85 | 86 | ||
86 | void setPrev(); | 87 | void setPrev(); |
87 | void setNext(); | 88 | void setNext(); |
88 | void setList(); | 89 | void setList(); |
89 | void setVideo(); | 90 | void setVideo(); |
90 | void setAudio(); | 91 | void setAudio(); |
91 | 92 | ||
92 | void toggleFullscreen(); | 93 | void toggleFullscreen(); |
93 | void toggleScaled(); | 94 | void toggleScaled(); |
94 | void toggleLooping(); | 95 | void toggleLooping(); |
95 | void toggleShuffled(); | 96 | void toggleShuffled(); |
96 | void togglePaused(); | 97 | void togglePaused(); |
97 | void togglePlaying(); | 98 | void togglePlaying(); |
98 | void toggleBlank(); | 99 | void toggleBlank(); |
99 | void writeConfig( Config& cfg ) const; | 100 | void writeConfig( Config& cfg ) const; |
100 | 101 | ||
101 | 102 | ||
102 | signals: | 103 | signals: |
103 | void fullscreenToggled( bool ); | 104 | void fullscreenToggled( bool ); |
104 | void scaledToggled( bool ); | 105 | void scaledToggled( bool ); |
105 | void loopingToggled( bool ); | 106 | void loopingToggled( bool ); |
106 | void shuffledToggled( bool ); | 107 | void shuffledToggled( bool ); |
107 | void pausedToggled( bool ); | 108 | void pausedToggled( bool ); |
108 | void playingToggled( bool ); | 109 | void playingToggled( bool ); |
109 | void stopToggled( bool ); | 110 | void stopToggled( bool ); |
110 | void positionChanged( long ); // When the slider is moved | 111 | void positionChanged( long ); // When the slider is moved |
111 | void positionUpdated( long ); // When the media file progresses | 112 | void positionUpdated( long ); // When the media file progresses |
112 | void lengthChanged( long ); | 113 | void lengthChanged( long ); |
113 | void viewChanged( char ); | ||
114 | void displayTypeChanged( MediaPlayerState::DisplayType 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 | DisplayType m_displayType; |
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 | ||