Diffstat (limited to 'noncore/multimedia/opieplayer2/mediaplayerstate.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/mediaplayerstate.cpp | 195 |
1 files changed, 185 insertions, 10 deletions
diff --git a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp index d1d30e4..2f24b00 100644 --- a/noncore/multimedia/opieplayer2/mediaplayerstate.cpp +++ b/noncore/multimedia/opieplayer2/mediaplayerstate.cpp | |||
@@ -8,25 +8,25 @@ | |||
8 | #include <qobject.h> | 8 | #include <qobject.h> |
9 | #include <qdir.h> | 9 | #include <qdir.h> |
10 | #include <qpe/mediaplayerplugininterface.h> | 10 | #include <qpe/mediaplayerplugininterface.h> |
11 | #include "mediaplayerstate.h" | 11 | #include "mediaplayerstate.h" |
12 | 12 | ||
13 | 13 | ||
14 | 14 | ||
15 | //#define MediaPlayerDebug(x) qDebug x | 15 | //#define MediaPlayerDebug(x) qDebug x |
16 | #define MediaPlayerDebug(x) | 16 | #define MediaPlayerDebug(x) |
17 | 17 | ||
18 | 18 | ||
19 | MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) | 19 | MediaPlayerState::MediaPlayerState( QObject *parent, const char *name ) |
20 | : QObject( parent, name ), decoder( NULL ) { | 20 | : QObject( parent, name ) { |
21 | Config cfg( "OpiePlayer" ); | 21 | Config cfg( "OpiePlayer" ); |
22 | readConfig( cfg ); | 22 | readConfig( cfg ); |
23 | } | 23 | } |
24 | 24 | ||
25 | 25 | ||
26 | MediaPlayerState::~MediaPlayerState() { | 26 | MediaPlayerState::~MediaPlayerState() { |
27 | Config cfg( "OpiePlayer" ); | 27 | Config cfg( "OpiePlayer" ); |
28 | writeConfig( cfg ); | 28 | writeConfig( cfg ); |
29 | } | 29 | } |
30 | 30 | ||
31 | 31 | ||
32 | void MediaPlayerState::readConfig( Config& cfg ) { | 32 | void MediaPlayerState::readConfig( Config& cfg ) { |
@@ -46,25 +46,200 @@ void MediaPlayerState::readConfig( Config& cfg ) { | |||
46 | 46 | ||
47 | 47 | ||
48 | void MediaPlayerState::writeConfig( Config& cfg ) const { | 48 | void MediaPlayerState::writeConfig( Config& cfg ) const { |
49 | cfg.setGroup("Options"); | 49 | cfg.setGroup("Options"); |
50 | cfg.writeEntry("FullScreen", isFullscreen ); | 50 | cfg.writeEntry("FullScreen", isFullscreen ); |
51 | cfg.writeEntry("Scaling", isScaled ); | 51 | cfg.writeEntry("Scaling", isScaled ); |
52 | cfg.writeEntry("Looping", isLooping ); | 52 | cfg.writeEntry("Looping", isLooping ); |
53 | cfg.writeEntry("Shuffle", isShuffled ); | 53 | cfg.writeEntry("Shuffle", isShuffled ); |
54 | cfg.writeEntry("UsePlayList", usePlaylist ); | 54 | cfg.writeEntry("UsePlayList", usePlaylist ); |
55 | } | 55 | } |
56 | 56 | ||
57 | 57 | ||
58 | struct MediaPlayerPlugin { | ||
59 | #ifndef QT_NO_COMPONENT | ||
60 | QLibrary *library; | ||
61 | #endif | ||
62 | MediaPlayerPluginInterface *iface; | ||
63 | MediaPlayerDecoder *decoder; | ||
64 | MediaPlayerEncoder *encoder; | ||
65 | }; | ||
66 | 58 | ||
67 | 59 | ||
68 | static QValueList<MediaPlayerPlugin> pluginList; | 60 | // public stuff |
61 | bool MediaPlayerState::fullscreen() { | ||
62 | return isFullscreen; | ||
63 | } | ||
64 | |||
65 | bool MediaPlayerState::scaled() { | ||
66 | return isScaled; | ||
67 | } | ||
68 | |||
69 | bool MediaPlayerState::looping() { | ||
70 | return isLooping; | ||
71 | } | ||
72 | |||
73 | bool MediaPlayerState::shuffled() { | ||
74 | return isShuffled; | ||
75 | } | ||
76 | |||
77 | |||
78 | bool MediaPlayerState:: playlist() { | ||
79 | return usePlaylist; | ||
80 | } | ||
81 | |||
82 | bool MediaPlayerState::paused() { | ||
83 | return isPaused; | ||
84 | } | ||
85 | |||
86 | bool MediaPlayerState::playing() { | ||
87 | return isPlaying; | ||
88 | } | ||
89 | |||
90 | long MediaPlayerState::position() { | ||
91 | return curPosition; | ||
92 | } | ||
93 | |||
94 | long MediaPlayerState::length() { | ||
95 | return curLength; | ||
96 | } | ||
97 | |||
98 | char MediaPlayerState::view() { | ||
99 | return curView; | ||
100 | } | ||
101 | |||
102 | // slots | ||
103 | void MediaPlayerState::setFullscreen( bool b ) { | ||
104 | if ( isFullscreen == b ) { | ||
105 | return; | ||
106 | } | ||
107 | isFullscreen = b; | ||
108 | emit fullscreenToggled(b); | ||
109 | } | ||
110 | |||
111 | |||
112 | void MediaPlayerState::setScaled( bool b ) { | ||
113 | if ( isScaled == b ) { | ||
114 | return; | ||
115 | } | ||
116 | isScaled = b; | ||
117 | emit scaledToggled(b); | ||
118 | } | ||
119 | |||
120 | void MediaPlayerState::setLooping( bool b ) { | ||
121 | if ( isLooping == b ) { | ||
122 | return; | ||
123 | } | ||
124 | isLooping = b; | ||
125 | emit loopingToggled(b); | ||
126 | } | ||
127 | |||
128 | void MediaPlayerState::setShuffled( bool b ) { | ||
129 | if ( isShuffled == b ) { | ||
130 | return; | ||
131 | } | ||
132 | isShuffled = b; | ||
133 | emit shuffledToggled(b); | ||
134 | } | ||
135 | |||
136 | void MediaPlayerState::setPlaylist( bool b ) { | ||
137 | if ( usePlaylist == b ) { | ||
138 | return; | ||
139 | } | ||
140 | usePlaylist = b; | ||
141 | emit playlistToggled(b); | ||
142 | } | ||
143 | |||
144 | void MediaPlayerState::setPaused( bool b ) { | ||
145 | if ( isPaused == b ) { | ||
146 | return; | ||
147 | } | ||
148 | isPaused = b; | ||
149 | emit pausedToggled(b); | ||
150 | } | ||
151 | |||
152 | void MediaPlayerState::setPlaying( bool b ) { | ||
153 | if ( isPlaying == b ) { | ||
154 | return; | ||
155 | } | ||
156 | isPlaying = b; | ||
157 | emit playingToggled(b); | ||
158 | } | ||
159 | |||
160 | void MediaPlayerState::setPosition( long p ) { | ||
161 | if ( curPosition == p ) { | ||
162 | return; | ||
163 | } | ||
164 | curPosition = p; | ||
165 | emit positionChanged(p); | ||
166 | } | ||
167 | |||
168 | void MediaPlayerState::updatePosition( long p ){ | ||
169 | if ( curPosition == p ) { | ||
170 | return; | ||
171 | } | ||
172 | curPosition = p; | ||
173 | emit positionUpdated(p); | ||
174 | } | ||
175 | |||
176 | void MediaPlayerState::setLength( long l ) { | ||
177 | if ( curLength == l ) { | ||
178 | return; | ||
179 | } | ||
180 | curLength = l; | ||
181 | emit lengthChanged(l); | ||
182 | } | ||
183 | |||
184 | void MediaPlayerState::setView( char v ) { | ||
185 | if ( curView == v ) { | ||
186 | return; | ||
187 | } | ||
188 | curView = v; | ||
189 | emit viewChanged(v); | ||
190 | } | ||
191 | |||
192 | void MediaPlayerState::setPrev(){ | ||
193 | emit prev(); | ||
194 | } | ||
195 | |||
196 | void MediaPlayerState::setNext() { | ||
197 | emit next(); | ||
198 | } | ||
199 | |||
200 | void MediaPlayerState::setList() { | ||
201 | setPlaying( FALSE ); | ||
202 | setView('l'); | ||
203 | } | ||
204 | |||
205 | void MediaPlayerState::setVideo() { | ||
206 | setView('v'); | ||
207 | } | ||
208 | |||
209 | void MediaPlayerState::setAudio() { | ||
210 | setView('a'); | ||
211 | } | ||
212 | |||
213 | |||
214 | |||
215 | void MediaPlayerState::toggleFullscreen() { | ||
216 | setFullscreen( !isFullscreen ); | ||
217 | } | ||
218 | |||
219 | void MediaPlayerState::toggleScaled() { | ||
220 | setScaled( !isScaled); | ||
221 | } | ||
222 | |||
223 | void MediaPlayerState::toggleLooping() { | ||
224 | setLooping( !isLooping); | ||
225 | } | ||
226 | |||
227 | void MediaPlayerState::toggleShuffled() { | ||
228 | setShuffled( !isShuffled); | ||
229 | } | ||
230 | |||
231 | void MediaPlayerState::togglePlaylist() { | ||
232 | setPlaylist( !usePlaylist); | ||
233 | } | ||
234 | |||
235 | void MediaPlayerState::togglePaused() { | ||
236 | setPaused( !isPaused); | ||
237 | } | ||
238 | |||
239 | void MediaPlayerState::togglePlaying() { | ||
240 | setPlaying( !isPlaying); | ||
241 | } | ||
242 | |||
243 | |||
69 | 244 | ||
70 | 245 | ||