62
|
1 |
/*
|
86
|
2 |
* Copyright (c) 2009 - 2010 Nokia Corporation and/or its subsidiary(-ies).
|
62
|
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 |
/*!
|
69
|
111 |
\fn void Screensaver::unlockRequested()
|
|
112 |
|
|
113 |
This signal is emitted if screensaver wants the device to be unlocked.
|
|
114 |
*/
|
|
115 |
|
|
116 |
/*!
|
86
|
117 |
\fn void Screensaver::activeAreaMoved()
|
69
|
118 |
|
86
|
119 |
This signal is emitted when active area of power-save mode screensaver has moved.
|
69
|
120 |
*/
|
|
121 |
|
|
122 |
/*!
|
62
|
123 |
Returns the state that the Screensaver is currently in.
|
|
124 |
\return The current state.
|
|
125 |
*/
|
|
126 |
ScreensaverState Screensaver::currentState()
|
|
127 |
{
|
|
128 |
return m_d->currentState();
|
|
129 |
}
|
|
130 |
|
|
131 |
/*!
|
86
|
132 |
\fn virtual Screensaver::ScreenPowerMode currentPowerMode() = 0
|
|
133 |
|
|
134 |
Inherited screensavers must implement this function to return the
|
|
135 |
display power mode to be used in the current state.
|
|
136 |
*/
|
|
137 |
|
|
138 |
/*!
|
69
|
139 |
\fn virtual void getActiveScreenRows(int *firstActiveRow, int *lastActiveRow) = 0
|
|
140 |
|
|
141 |
Inherited screensavers must implement this function to return the rows where
|
|
142 |
the screensaver wants to draw graphics. This is called when screen is set to the
|
|
143 |
power save mode. The values returned do not matter in case the screensaver doesn't
|
|
144 |
ask for power save mode.
|
|
145 |
Note that the returned rows should reflect the rows in the natural orientation
|
|
146 |
of the screen device. That is, if default orientation of the screen is portrait,
|
|
147 |
then the return value in landscape mode must reflect the columns between which
|
|
148 |
the graphics are drawn.
|
|
149 |
*/
|
|
150 |
|
|
151 |
/*!
|
|
152 |
\fn virtual void updateLayout() = 0
|
|
153 |
|
|
154 |
Inherited screensavers must implement this function to reload the screen layout
|
|
155 |
for the current screen orientation.
|
|
156 |
*/
|
|
157 |
|
|
158 |
/*!
|
62
|
159 |
Initializes the Screensaver
|
|
160 |
*/
|
|
161 |
void Screensaver::initialize()
|
|
162 |
{
|
|
163 |
m_d->initialize();
|
|
164 |
}
|
|
165 |
|
|
166 |
/*!
|
|
167 |
Called when the application is in foreground.
|
|
168 |
*/
|
|
169 |
void Screensaver::foreground()
|
|
170 |
{
|
|
171 |
m_d->foreground();
|
|
172 |
}
|
|
173 |
|
|
174 |
/*!
|
|
175 |
Called when the application gains limited foreground as with OLED display cases.
|
|
176 |
*/
|
|
177 |
void Screensaver::partialForeground()
|
|
178 |
{
|
|
179 |
m_d->partialForeground();
|
|
180 |
}
|
|
181 |
|
|
182 |
/*!
|
|
183 |
Called when the application goes to background.
|
|
184 |
*/
|
|
185 |
void Screensaver::background()
|
|
186 |
{
|
|
187 |
m_d->background();
|
|
188 |
}
|
|
189 |
|
|
190 |
/*!
|
|
191 |
Called when device enters power save mode.
|
|
192 |
*/
|
|
193 |
void Screensaver::powerSave()
|
|
194 |
{
|
|
195 |
m_d->powerSave();
|
|
196 |
}
|
|
197 |
|
|
198 |
/*!
|
|
199 |
Stops Screensaver's processing.
|
|
200 |
*/
|
|
201 |
void Screensaver::close()
|
|
202 |
{
|
|
203 |
m_d->close();
|
|
204 |
}
|
|
205 |
|
|
206 |
/*!
|
|
207 |
If there is any active universal indicator when screensaver
|
|
208 |
is launched, then this method is called.
|
|
209 |
Note that indicators are implemented only for Symbian/S60 OS.
|
|
210 |
\param activeIndicators List of currently active indicators in
|
|
211 |
the chronological order according to their arrival time.
|
|
212 |
*/
|
|
213 |
void Screensaver::handleActiveIndicators(
|
|
214 |
const QList<HbIndicatorInterface*> &activeIndicators)
|
|
215 |
{
|
|
216 |
// TODO: need to go through private class?
|
|
217 |
m_d->handleActiveIndicators(activeIndicators);
|
|
218 |
}
|
|
219 |
|
|
220 |
/*!
|
|
221 |
Called when some universal indicator is activated.
|
|
222 |
\param activatedIndicator Activated indicator. Ownership is not transferred.
|
|
223 |
*/
|
|
224 |
void Screensaver::handleActivatedIndicator(
|
|
225 |
HbIndicatorInterface* activatedIndicator)
|
|
226 |
{
|
|
227 |
m_d->handleActivatedIndicator(activatedIndicator);
|
|
228 |
}
|
|
229 |
|
|
230 |
/*!
|
|
231 |
Called when some universal indicator is deactivated.
|
|
232 |
\param activatedIndicator Deactivated indicator. Ownership is not transferred.
|
|
233 |
*/
|
|
234 |
void Screensaver::handleDeactivatedIndicator(
|
|
235 |
HbIndicatorInterface* deactivatedIndicator)
|
|
236 |
{
|
|
237 |
m_d->handleDeactivatedIndicator(deactivatedIndicator);
|
|
238 |
}
|
|
239 |
|
|
240 |
|
|
241 |
/*!
|
|
242 |
\fn virtual bool Screensaver::onForeground() = 0
|
|
243 |
|
|
244 |
After a call the Screensaver should emit the foreground state visualization.
|
|
245 |
Returns true if the operation secceeded, otherwise false - in this case
|
|
246 |
the faulted() signal will be emitted by the base class.
|
|
247 |
\return Indicates if the operation succeeded.
|
|
248 |
*/
|
|
249 |
|
|
250 |
/*!
|
|
251 |
\fn virtual bool Screensaver::onPartialForeground() = 0
|
|
252 |
|
|
253 |
After a call the Screensaver should emit the partial foreground state visualization.
|
|
254 |
This is valid for OLED display cases when the screensaver is displayed at all times
|
|
255 |
with limited functionality.
|
|
256 |
Returns true if the operation secceeded, otherwise false - in this case
|
|
257 |
the faulted() signal will be emitted by the base class.
|
|
258 |
\return Indicates if the operation succeeded.
|
|
259 |
*/
|
|
260 |
|
|
261 |
/*!
|
|
262 |
\fn virtual bool Screensaver::onBackground() = 0
|
|
263 |
|
|
264 |
After a call the Screensaver should limit its processing.
|
|
265 |
Returns true if the operation secceeded, otherwise false - in this case
|
|
266 |
the faulted() signal will be emitted by the base class.
|
|
267 |
\return Indicates if the operation succeeded.
|
|
268 |
*/
|
|
269 |
|
|
270 |
/*!
|
|
271 |
\fn virtual bool Screensaver::onPowerSave() = 0
|
|
272 |
|
|
273 |
After a call the Screensaver should limit its processing as much as possible.
|
|
274 |
Returns true if the operation secceeded, otherwise false - in this case
|
|
275 |
the faulted() signal will be emitted by the base class.
|
|
276 |
\return Indicates if the operation succeeded.
|
|
277 |
*/
|
|
278 |
|
|
279 |
/*!
|
|
280 |
After a call it should initialize the Screensaver.
|
|
281 |
Returns true if the operation secceeded, otherwise false - in this case
|
|
282 |
the faulted() signal will be emitted by the base class.
|
|
283 |
The default implementation does nothing and always returns true.
|
|
284 |
\return Indicates if the operation succeeded.
|
|
285 |
*/
|
|
286 |
bool Screensaver::onInitialize()
|
|
287 |
{
|
|
288 |
return true;
|
|
289 |
}
|
|
290 |
|
|
291 |
/*!
|
|
292 |
After a call it should close the Screensaver.
|
|
293 |
The Screensaver should also free all resources.
|
|
294 |
Returns true if the operation secceeded, otherwise false - in this case
|
|
295 |
the faulted() signal will be emitted by the base class.
|
|
296 |
The default implementation does nothing and always returns true.
|
|
297 |
\return Indicates if the operation succeeded.
|
|
298 |
*/
|
|
299 |
bool Screensaver::onClose()
|
|
300 |
{
|
|
301 |
return true;
|
|
302 |
}
|
|
303 |
|
|
304 |
/*!
|
|
305 |
The default implementation is empty.
|
|
306 |
*/
|
|
307 |
void Screensaver::onHandleActiveIndicators(
|
|
308 |
const QList<HbIndicatorInterface*> &activeIndicators)
|
|
309 |
{
|
|
310 |
Q_UNUSED(activeIndicators);
|
|
311 |
}
|
|
312 |
|
|
313 |
/*!
|
|
314 |
The default implementation is empty.
|
|
315 |
*/
|
|
316 |
void Screensaver::onHandleActivatedIndicator(
|
|
317 |
HbIndicatorInterface *activatedIndicator)
|
|
318 |
{
|
|
319 |
Q_UNUSED(activatedIndicator);
|
|
320 |
}
|
|
321 |
|
|
322 |
/*!
|
|
323 |
The default implementation is empty.
|
|
324 |
*/
|
|
325 |
void Screensaver::onHandleDeactivatedIndicator(
|
|
326 |
HbIndicatorInterface *deactivatedIndicator)
|
|
327 |
{
|
|
328 |
Q_UNUSED(deactivatedIndicator);
|
|
329 |
}
|
|
330 |
|