|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Base class for all screensavers. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "screensaver.h" |
|
19 #include "screensaver_p.h" |
|
20 |
|
21 /*! |
|
22 \enum ScreensaverState |
|
23 Lists states that the Screensaver can be in. |
|
24 */ |
|
25 |
|
26 /* |
|
27 \var ScreensaverState ScreensaverStateConstructed |
|
28 Screensaver is in this state right after construction. |
|
29 */ |
|
30 |
|
31 /* |
|
32 \var ScreensaverState ScreensaverStateInitialized |
|
33 |
|
34 All Screensaver resources are initialized. |
|
35 Screensaver is set to Initialized state after a call to initialize |
|
36 (if previously Constructed or Closed) method. |
|
37 */ |
|
38 |
|
39 /* |
|
40 \var Screensaver ScreensaverStateBackground |
|
41 Screensaver is in background, its operations are suspended. |
|
42 Screensaver is set to Background after a call to background method. |
|
43 */ |
|
44 |
|
45 /* |
|
46 \var Screensaver ScreensaverStateForeground |
|
47 Screensaver is in foreground and fully operational, showing the main visualization. |
|
48 Screensaver is set to Foreground after a call to foreground method. |
|
49 */ |
|
50 |
|
51 /* |
|
52 \var Screensaver ScreensaverStatePartialForeground |
|
53 Screensaver has limited foreground (in OLED display cases). |
|
54 Screensaver is set to PartialForeground after a call to partialForeground method. |
|
55 */ |
|
56 |
|
57 /* |
|
58 \var Screensaver ScreensaverStatePowerSave |
|
59 Device is in power save mode. Screensaver should limit all processing. |
|
60 Screensaver is set to PowerSave after a call to powerSave method. |
|
61 */ |
|
62 |
|
63 /* |
|
64 \var Screensaver ScreensaverStateClosed |
|
65 Screensaver is closed. All resources should be frees. |
|
66 Screensaver is set to Closed after a call to close method. |
|
67 */ |
|
68 |
|
69 /*! |
|
70 \class Screensaver |
|
71 \brief Base class for all screensavers. |
|
72 |
|
73 Screensaver plug-ins provide the visualizations for different screensaver application states. |
|
74 A Screensaver is notified about state changes and in consequence it should emit a signal |
|
75 viewChanged() carrying a QGraphicsWidget which will be set as the current view. |
|
76 The application takse care about tracing device status so the Screensaver should be only |
|
77 concerned about the GUI. |
|
78 */ |
|
79 |
|
80 /*! |
|
81 Constructs a new Screensaver with \a parent. |
|
82 */ |
|
83 Screensaver::Screensaver(QObject *parent) : |
|
84 QObject(parent), m_d(new ScreensaverPrivate(this)) |
|
85 { |
|
86 } |
|
87 |
|
88 /*! |
|
89 Destructs the class. |
|
90 */ |
|
91 Screensaver::~Screensaver() |
|
92 { |
|
93 delete m_d; |
|
94 } |
|
95 |
|
96 /*! |
|
97 \fn void Screensaver::faulted() |
|
98 |
|
99 This signal is emitted if a fault occurs when changing Screensaver's state. |
|
100 */ |
|
101 |
|
102 /*! |
|
103 \fn void Screensaver::viewChanged(QGraphicsWidget *widget) |
|
104 |
|
105 This signal should be emitted when the Screensaver needs to change its visualization |
|
106 after a state change. |
|
107 \param widget The graphics widget container holding the current visualization. |
|
108 */ |
|
109 |
|
110 /*! |
|
111 \fn void Screensaver::unlockRequested() |
|
112 |
|
113 This signal is emitted if screensaver wants the device to be unlocked. |
|
114 */ |
|
115 |
|
116 /*! |
|
117 \fn void Screensaver::screenPowerModeRequested(ScreenPowerMode mode) |
|
118 |
|
119 This signal is emitted when screensaver wants to switch the power |
|
120 mode of the screen, or update the visible area in power save mode. |
|
121 */ |
|
122 |
|
123 /*! |
|
124 Returns the state that the Screensaver is currently in. |
|
125 \return The current state. |
|
126 */ |
|
127 ScreensaverState Screensaver::currentState() |
|
128 { |
|
129 return m_d->currentState(); |
|
130 } |
|
131 |
|
132 /*! |
|
133 \fn virtual void getActiveScreenRows(int *firstActiveRow, int *lastActiveRow) = 0 |
|
134 |
|
135 Inherited screensavers must implement this function to return the rows where |
|
136 the screensaver wants to draw graphics. This is called when screen is set to the |
|
137 power save mode. The values returned do not matter in case the screensaver doesn't |
|
138 ask for power save mode. |
|
139 Note that the returned rows should reflect the rows in the natural orientation |
|
140 of the screen device. That is, if default orientation of the screen is portrait, |
|
141 then the return value in landscape mode must reflect the columns between which |
|
142 the graphics are drawn. |
|
143 */ |
|
144 |
|
145 /*! |
|
146 \fn virtual void updateLayout() = 0 |
|
147 |
|
148 Inherited screensavers must implement this function to reload the screen layout |
|
149 for the current screen orientation. |
|
150 */ |
|
151 |
|
152 /*! |
|
153 Initializes the Screensaver |
|
154 */ |
|
155 void Screensaver::initialize() |
|
156 { |
|
157 m_d->initialize(); |
|
158 } |
|
159 |
|
160 /*! |
|
161 Called when the application is in foreground. |
|
162 */ |
|
163 void Screensaver::foreground() |
|
164 { |
|
165 m_d->foreground(); |
|
166 } |
|
167 |
|
168 /*! |
|
169 Called when the application gains limited foreground as with OLED display cases. |
|
170 */ |
|
171 void Screensaver::partialForeground() |
|
172 { |
|
173 m_d->partialForeground(); |
|
174 } |
|
175 |
|
176 /*! |
|
177 Called when the application goes to background. |
|
178 */ |
|
179 void Screensaver::background() |
|
180 { |
|
181 m_d->background(); |
|
182 } |
|
183 |
|
184 /*! |
|
185 Called when device enters power save mode. |
|
186 */ |
|
187 void Screensaver::powerSave() |
|
188 { |
|
189 m_d->powerSave(); |
|
190 } |
|
191 |
|
192 /*! |
|
193 Stops Screensaver's processing. |
|
194 */ |
|
195 void Screensaver::close() |
|
196 { |
|
197 m_d->close(); |
|
198 } |
|
199 |
|
200 /*! |
|
201 If there is any active universal indicator when screensaver |
|
202 is launched, then this method is called. |
|
203 Note that indicators are implemented only for Symbian/S60 OS. |
|
204 \param activeIndicators List of currently active indicators in |
|
205 the chronological order according to their arrival time. |
|
206 */ |
|
207 void Screensaver::handleActiveIndicators( |
|
208 const QList<HbIndicatorInterface*> &activeIndicators) |
|
209 { |
|
210 // TODO: need to go through private class? |
|
211 m_d->handleActiveIndicators(activeIndicators); |
|
212 } |
|
213 |
|
214 /*! |
|
215 Called when some universal indicator is activated. |
|
216 \param activatedIndicator Activated indicator. Ownership is not transferred. |
|
217 */ |
|
218 void Screensaver::handleActivatedIndicator( |
|
219 HbIndicatorInterface* activatedIndicator) |
|
220 { |
|
221 m_d->handleActivatedIndicator(activatedIndicator); |
|
222 } |
|
223 |
|
224 /*! |
|
225 Called when some universal indicator is deactivated. |
|
226 \param activatedIndicator Deactivated indicator. Ownership is not transferred. |
|
227 */ |
|
228 void Screensaver::handleDeactivatedIndicator( |
|
229 HbIndicatorInterface* deactivatedIndicator) |
|
230 { |
|
231 m_d->handleDeactivatedIndicator(deactivatedIndicator); |
|
232 } |
|
233 |
|
234 |
|
235 /*! |
|
236 \fn virtual bool Screensaver::onForeground() = 0 |
|
237 |
|
238 After a call the Screensaver should emit the foreground state visualization. |
|
239 Returns true if the operation secceeded, otherwise false - in this case |
|
240 the faulted() signal will be emitted by the base class. |
|
241 \return Indicates if the operation succeeded. |
|
242 */ |
|
243 |
|
244 /*! |
|
245 \fn virtual bool Screensaver::onPartialForeground() = 0 |
|
246 |
|
247 After a call the Screensaver should emit the partial foreground state visualization. |
|
248 This is valid for OLED display cases when the screensaver is displayed at all times |
|
249 with limited functionality. |
|
250 Returns true if the operation secceeded, otherwise false - in this case |
|
251 the faulted() signal will be emitted by the base class. |
|
252 \return Indicates if the operation succeeded. |
|
253 */ |
|
254 |
|
255 /*! |
|
256 \fn virtual bool Screensaver::onBackground() = 0 |
|
257 |
|
258 After a call the Screensaver should limit its processing. |
|
259 Returns true if the operation secceeded, otherwise false - in this case |
|
260 the faulted() signal will be emitted by the base class. |
|
261 \return Indicates if the operation succeeded. |
|
262 */ |
|
263 |
|
264 /*! |
|
265 \fn virtual bool Screensaver::onPowerSave() = 0 |
|
266 |
|
267 After a call the Screensaver should limit its processing as much as possible. |
|
268 Returns true if the operation secceeded, otherwise false - in this case |
|
269 the faulted() signal will be emitted by the base class. |
|
270 \return Indicates if the operation succeeded. |
|
271 */ |
|
272 |
|
273 /*! |
|
274 After a call it should initialize the Screensaver. |
|
275 Returns true if the operation secceeded, otherwise false - in this case |
|
276 the faulted() signal will be emitted by the base class. |
|
277 The default implementation does nothing and always returns true. |
|
278 \return Indicates if the operation succeeded. |
|
279 */ |
|
280 bool Screensaver::onInitialize() |
|
281 { |
|
282 return true; |
|
283 } |
|
284 |
|
285 /*! |
|
286 After a call it should close the Screensaver. |
|
287 The Screensaver should also free all resources. |
|
288 Returns true if the operation secceeded, otherwise false - in this case |
|
289 the faulted() signal will be emitted by the base class. |
|
290 The default implementation does nothing and always returns true. |
|
291 \return Indicates if the operation succeeded. |
|
292 */ |
|
293 bool Screensaver::onClose() |
|
294 { |
|
295 return true; |
|
296 } |
|
297 |
|
298 /*! |
|
299 The default implementation is empty. |
|
300 */ |
|
301 void Screensaver::onHandleActiveIndicators( |
|
302 const QList<HbIndicatorInterface*> &activeIndicators) |
|
303 { |
|
304 Q_UNUSED(activeIndicators); |
|
305 } |
|
306 |
|
307 /*! |
|
308 The default implementation is empty. |
|
309 */ |
|
310 void Screensaver::onHandleActivatedIndicator( |
|
311 HbIndicatorInterface *activatedIndicator) |
|
312 { |
|
313 Q_UNUSED(activatedIndicator); |
|
314 } |
|
315 |
|
316 /*! |
|
317 The default implementation is empty. |
|
318 */ |
|
319 void Screensaver::onHandleDeactivatedIndicator( |
|
320 HbIndicatorInterface *deactivatedIndicator) |
|
321 { |
|
322 Q_UNUSED(deactivatedIndicator); |
|
323 } |
|
324 |