85
|
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 |
Returns the state that the Screensaver is currently in.
|
|
112 |
\return The current state.
|
|
113 |
*/
|
|
114 |
ScreensaverState Screensaver::currentState()
|
|
115 |
{
|
|
116 |
return m_d->currentState();
|
|
117 |
}
|
|
118 |
|
|
119 |
/*!
|
|
120 |
Initializes the Screensaver
|
|
121 |
*/
|
|
122 |
void Screensaver::initialize()
|
|
123 |
{
|
|
124 |
m_d->initialize();
|
|
125 |
}
|
|
126 |
|
|
127 |
/*!
|
|
128 |
Called when the application is in foreground.
|
|
129 |
*/
|
|
130 |
void Screensaver::foreground()
|
|
131 |
{
|
|
132 |
m_d->foreground();
|
|
133 |
}
|
|
134 |
|
|
135 |
/*!
|
|
136 |
Called when the application gains limited foreground as with OLED display cases.
|
|
137 |
*/
|
|
138 |
void Screensaver::partialForeground()
|
|
139 |
{
|
|
140 |
m_d->partialForeground();
|
|
141 |
}
|
|
142 |
|
|
143 |
/*!
|
|
144 |
Called when the application goes to background.
|
|
145 |
*/
|
|
146 |
void Screensaver::background()
|
|
147 |
{
|
|
148 |
m_d->background();
|
|
149 |
}
|
|
150 |
|
|
151 |
/*!
|
|
152 |
Called when device enters power save mode.
|
|
153 |
*/
|
|
154 |
void Screensaver::powerSave()
|
|
155 |
{
|
|
156 |
m_d->powerSave();
|
|
157 |
}
|
|
158 |
|
|
159 |
/*!
|
|
160 |
Stops Screensaver's processing.
|
|
161 |
*/
|
|
162 |
void Screensaver::close()
|
|
163 |
{
|
|
164 |
m_d->close();
|
|
165 |
}
|
|
166 |
|
|
167 |
/*!
|
|
168 |
\fn virtual bool Screensaver::onForeground() = 0
|
|
169 |
|
|
170 |
After a call the Screensaver should emit the foreground state visualization.
|
|
171 |
Returns true if the operation secceeded, otherwise false - in this case
|
|
172 |
the faulted() signal will be emitted by the base class.
|
|
173 |
\return Indicates if the operation succeeded.
|
|
174 |
*/
|
|
175 |
|
|
176 |
/*!
|
|
177 |
\fn virtual bool Screensaver::onPartialForeground() = 0
|
|
178 |
|
|
179 |
After a call the Screensaver should emit the partial foreground state visualization.
|
|
180 |
This is valid for OLED display cases when the screensaver is displayed at all times
|
|
181 |
with limited functionality.
|
|
182 |
Returns true if the operation secceeded, otherwise false - in this case
|
|
183 |
the faulted() signal will be emitted by the base class.
|
|
184 |
\return Indicates if the operation succeeded.
|
|
185 |
*/
|
|
186 |
|
|
187 |
/*!
|
|
188 |
\fn virtual bool Screensaver::onBackground() = 0
|
|
189 |
|
|
190 |
After a call the Screensaver should limit its processing.
|
|
191 |
Returns true if the operation secceeded, otherwise false - in this case
|
|
192 |
the faulted() signal will be emitted by the base class.
|
|
193 |
\return Indicates if the operation succeeded.
|
|
194 |
*/
|
|
195 |
|
|
196 |
/*!
|
|
197 |
\fn virtual bool Screensaver::onPowerSave() = 0
|
|
198 |
|
|
199 |
After a call the Screensaver should limit its processing as much as possible.
|
|
200 |
Returns true if the operation secceeded, otherwise false - in this case
|
|
201 |
the faulted() signal will be emitted by the base class.
|
|
202 |
\return Indicates if the operation succeeded.
|
|
203 |
*/
|
|
204 |
|
|
205 |
/*!
|
|
206 |
After a call it should initialize the Screensaver.
|
|
207 |
Returns true if the operation secceeded, otherwise false - in this case
|
|
208 |
the faulted() signal will be emitted by the base class.
|
|
209 |
The default implementation does nothing and always returns true.
|
|
210 |
\return Indicates if the operation succeeded.
|
|
211 |
*/
|
|
212 |
bool Screensaver::onInitialize()
|
|
213 |
{
|
|
214 |
return true;
|
|
215 |
}
|
|
216 |
|
|
217 |
/*!
|
|
218 |
After a call it should close the Screensaver.
|
|
219 |
The Screensaver should also free all resources.
|
|
220 |
Returns true if the operation secceeded, otherwise false - in this case
|
|
221 |
the faulted() signal will be emitted by the base class.
|
|
222 |
The default implementation does nothing and always returns true.
|
|
223 |
\return Indicates if the operation succeeded.
|
|
224 |
*/
|
|
225 |
bool Screensaver::onClose()
|
|
226 |
{
|
|
227 |
return true;
|
|
228 |
}
|