22 #endif // Q_OS_SYMBIAN |
22 #endif // Q_OS_SYMBIAN |
23 |
23 |
24 #include <QDebug> |
24 #include <QDebug> |
25 #include <QTime> |
25 #include <QTime> |
26 #include <QTimer> |
26 #include <QTimer> |
27 |
27 #include <XQSettingsManager> |
28 #include <hbinstance.h> |
28 #include <HbInstance> |
29 #include <hbmainwindow.h> |
29 #include <HbMainWindow> |
30 |
30 |
|
31 #include <screensaverdomaincrkeys.h> |
31 #include "snsranalogclockcontainer.h" |
32 #include "snsranalogclockcontainer.h" |
32 #include "snsrdigitalclockcontainer.h" |
33 #include "snsrdigitalclockcontainer.h" |
33 #include "snsroledanalogclockcontainer.h" |
34 #include "snsroledanalogclockcontainer.h" |
34 #include "snsroleddigitalclockcontainer.h" |
35 #include "snsroleddigitalclockcontainer.h" |
|
36 #include "snsrblankcontainer.h" |
35 #include "snsrindicatormodel.h" |
37 #include "snsrindicatormodel.h" |
36 |
38 |
37 /*! |
39 /*! |
38 \class SnsrBigClockScreensaver |
40 \class SnsrBigClockScreensaver |
39 \ingroup group_snsrbigclockscreensaverplugin |
41 \ingroup group_snsrbigclockscreensaverplugin |
40 \brief Screensaver with big digital clock. |
42 \brief Screensaver with big digital clock. |
41 */ |
43 */ |
42 |
44 |
43 const int gTimeInterval(100); |
|
44 |
|
45 /*! |
45 /*! |
46 Constructs a new SnsrBigClockScreensaver. |
46 Constructs a new SnsrBigClockScreensaver. |
47 */ |
47 */ |
48 SnsrBigClockScreensaver::SnsrBigClockScreensaver() : |
48 SnsrBigClockScreensaver::SnsrBigClockScreensaver() : |
49 mMainWindow(0), |
49 mMainWindow(0), |
50 mCurrentContainer(0), |
50 mCurrentContainer(0), |
51 mIndicatorModel(0) |
51 mIndicatorModel(0), |
|
52 m_setManager(0) |
52 { |
53 { |
53 mMainWindow = HbInstance::instance()->allMainWindows().at(0); |
54 mMainWindow = HbInstance::instance()->allMainWindows().at(0); |
54 // for nice looking clock hand transformations |
55 // for nice looking clock hand transformations |
55 mMainWindow->setRenderHint(QPainter::SmoothPixmapTransform); |
56 mMainWindow->setRenderHint(QPainter::SmoothPixmapTransform); |
56 |
57 |
84 SCREENSAVER_TEST_FUNC_ENTRY("SnsrBigClockScreensaver::onForeground") |
86 SCREENSAVER_TEST_FUNC_ENTRY("SnsrBigClockScreensaver::onForeground") |
85 qDebug() << "SnsrBigClockScreensaver::onForeground()"; |
87 qDebug() << "SnsrBigClockScreensaver::onForeground()"; |
86 |
88 |
87 removeCurrentContainer(); |
89 removeCurrentContainer(); |
88 |
90 |
|
91 emit screenPowerModeRequested( Screensaver::ScreenModeFullPower ); |
|
92 |
89 SnsrBigClockContainer* newContainer( 0 ); |
93 SnsrBigClockContainer* newContainer( 0 ); |
90 if (clockFormat() == ClockFormatAnalog) { |
94 if (clockFormat() == ClockFormatAnalog) { |
91 newContainer = new SnsrAnalogClockContainer(); |
95 newContainer = new SnsrAnalogClockContainer(); |
92 } |
96 } |
93 else { |
97 else { |
94 newContainer = new SnsrDigitalClockContainer(); |
98 newContainer = new SnsrDigitalClockContainer(); |
95 } |
99 } |
96 |
100 |
97 setCurrentContainer( newContainer ); |
101 setCurrentContainer( newContainer ); |
98 |
102 |
99 SCREENSAVER_TEST_FUNC_EXIT("SnsrBigClockScreensaver::onForeground") |
103 SCREENSAVER_TEST_FUNC_EXIT("SnsrBigClockScreensaver::onForeground") |
100 return true; |
104 return true; |
101 } |
105 } |
102 |
106 |
103 /*! |
107 /*! |
109 qDebug() << "SnsrBigClockScreensaver::onPartialForeground()"; |
113 qDebug() << "SnsrBigClockScreensaver::onPartialForeground()"; |
110 |
114 |
111 removeCurrentContainer(); |
115 removeCurrentContainer(); |
112 |
116 |
113 SnsrBigClockContainer* newContainer( 0 ); |
117 SnsrBigClockContainer* newContainer( 0 ); |
114 if (clockFormat() == ClockFormatAnalog) { |
118 |
115 newContainer = new SnsrOledAnalogClockContainer(); |
119 // Check ScreensaverStatus from repository |
|
120 XQSettingsManager::Error error; |
|
121 int screensaverOn = 1; |
|
122 XQCentralRepositorySettingsKey settingsKey( |
|
123 KCRUidScreensaverSettings.iUid, KScreensaverStatus ); // TUid as same repository used in control panel via Symbian APIs |
|
124 m_setManager = new XQSettingsManager(this); |
|
125 if (m_setManager) { |
|
126 screensaverOn = m_setManager->readItemValue(settingsKey, XQSettingsManager::TypeInt).toInt(); |
|
127 error = m_setManager->error(); |
|
128 if (error != XQSettingsManager::NoError) { |
|
129 qDebug("Error reading value from XQSettingsManager.. error = %d", error); |
|
130 } |
|
131 delete m_setManager; |
|
132 } |
|
133 |
|
134 if (screensaverOn) { |
|
135 if (clockFormat() == ClockFormatAnalog) { |
|
136 newContainer = new SnsrOledAnalogClockContainer(); |
|
137 } |
|
138 else { |
|
139 newContainer = new SnsrOledDigitalClockContainer(); |
|
140 } |
116 } |
141 } |
117 else { |
142 else { |
118 newContainer = new SnsrOledDigitalClockContainer(); |
143 newContainer = new SnsrBlankContainer(); |
119 } |
144 } |
120 |
145 |
121 setCurrentContainer( newContainer ); |
146 setCurrentContainer( newContainer ); |
122 |
147 |
123 SCREENSAVER_TEST_FUNC_EXIT("SnsrBigClockScreensaver::onPartialForeground") |
148 SCREENSAVER_TEST_FUNC_EXIT("SnsrBigClockScreensaver::onPartialForeground") |
124 return true; |
149 return true; |
125 } |
150 } |
194 HbIndicatorInterface *deactivatedIndicator) |
219 HbIndicatorInterface *deactivatedIndicator) |
195 { |
220 { |
196 mIndicatorModel->handleDeactivatedIndicator(deactivatedIndicator); |
221 mIndicatorModel->handleDeactivatedIndicator(deactivatedIndicator); |
197 } |
222 } |
198 |
223 |
|
224 /*! |
|
225 @copydoc Screensaver::getActiveScreenRows |
|
226 */ |
|
227 void SnsrBigClockScreensaver::getActiveScreenRows(int *firstActiveRow, int *lastActiveRow) |
|
228 { |
|
229 if ( mCurrentContainer ) { |
|
230 mCurrentContainer->getActiveScreenRows( firstActiveRow, lastActiveRow ); |
|
231 } |
|
232 else { |
|
233 qWarning() << "No current container when active rows queried."; |
|
234 } |
|
235 } |
|
236 |
|
237 /*! |
|
238 @copydoc Screensaver::updateLayout |
|
239 */ |
|
240 void SnsrBigClockScreensaver::updateLayout() |
|
241 { |
|
242 if ( mCurrentContainer ) { |
|
243 if ( mCurrentContainer->isOrientationLocked() ) { |
|
244 mMainWindow->setOrientation( mMainWindow->orientation(), /*animate*/false ); |
|
245 } |
|
246 else { |
|
247 mMainWindow->unsetOrientation( /*animate*/false ); |
|
248 } |
|
249 mCurrentContainer->changeLayout( mMainWindow->orientation() ); |
|
250 } |
|
251 else { |
|
252 qWarning() << "No current container when updateLayout called."; |
|
253 } |
|
254 } |
|
255 |
|
256 /*! |
|
257 Update the area visible in the power save screen mode. Power save mode gets |
|
258 also activated on call if not already active. |
|
259 */ |
|
260 void SnsrBigClockScreensaver::updateActiveAreaForLowPower() |
|
261 { |
|
262 emit screenPowerModeRequested( Screensaver::ScreenModeLowPower ); |
|
263 } |
199 |
264 |
200 /*! |
265 /*! |
201 Determines the curent clock format settings. |
266 Determines the curent clock format settings. |
202 \retval ClockFormat. |
267 \retval ClockFormat. |
203 */ |
268 */ |
220 } |
285 } |
221 |
286 |
222 void SnsrBigClockScreensaver::removeCurrentContainer() |
287 void SnsrBigClockScreensaver::removeCurrentContainer() |
223 { |
288 { |
224 if ( mCurrentContainer ) { |
289 if ( mCurrentContainer ) { |
225 disconnect( |
|
226 mMainWindow, SIGNAL(orientationChanged(Qt::Orientation)), |
|
227 mCurrentContainer, SLOT(changeLayout(Qt::Orientation)) |
|
228 ); |
|
229 disconnect( |
290 disconnect( |
230 &mTimer, SIGNAL(timeout()), |
291 &mTimer, SIGNAL(timeout()), |
231 mCurrentContainer, SLOT(update()) |
292 mCurrentContainer, SLOT(update()) |
232 ); |
293 ); |
233 disconnect( |
294 disconnect( |
234 mCurrentContainer, SIGNAL(unlockRequested()), |
295 mCurrentContainer, SIGNAL(unlockRequested()), |
235 this, SIGNAL(unlockRequested()) ); |
296 this, SIGNAL(unlockRequested()) ); |
236 mTimer.stop(); |
297 if (mTimer.timerId()!= -1) { |
|
298 mTimer.stop(); |
|
299 } |
237 emit viewChanged(0); |
300 emit viewChanged(0); |
238 |
301 |
239 delete mCurrentContainer; |
302 delete mCurrentContainer; |
240 mCurrentContainer = 0; |
303 mCurrentContainer = 0; |
241 } |
304 } |
|
305 |
|
306 mMainWindow->unsetOrientation( /*animate*/false ); |
242 } |
307 } |
243 |
308 |
244 void SnsrBigClockScreensaver::setCurrentContainer( SnsrBigClockContainer* newContainer ) |
309 void SnsrBigClockScreensaver::setCurrentContainer( SnsrBigClockContainer* newContainer ) |
245 { |
310 { |
246 mCurrentContainer = newContainer; |
311 mCurrentContainer = newContainer; |
247 connect( |
312 mCurrentContainer->setParent(this); |
248 mMainWindow, SIGNAL(orientationChanged(Qt::Orientation)), |
|
249 mCurrentContainer, SLOT(changeLayout(Qt::Orientation)) |
|
250 ); |
|
251 connect( &mTimer, SIGNAL(timeout()), mCurrentContainer, SLOT(update()) ); |
313 connect( &mTimer, SIGNAL(timeout()), mCurrentContainer, SLOT(update()) ); |
252 connect( mCurrentContainer, SIGNAL(unlockRequested()), SIGNAL(unlockRequested()) ); |
314 connect( mCurrentContainer, SIGNAL(unlockRequested()), SIGNAL(unlockRequested()) ); |
253 |
315 connect( mCurrentContainer, SIGNAL(activeAreaMoved()), SLOT(updateActiveAreaForLowPower()) ); |
254 mCurrentContainer->initIndicators(*mIndicatorModel); |
316 |
255 |
317 mCurrentContainer->setIndicatorModel(*mIndicatorModel); |
256 mCurrentContainer->changeLayout(mMainWindow->orientation()); |
318 |
257 mTimer.start( mCurrentContainer->updateIntervalInMilliseconds() ); |
319 int updateInterval = mCurrentContainer->updateIntervalInMilliseconds(); |
|
320 // blankcontainer is empty one, don't start timer with -1 return value |
|
321 if ( updateInterval != -1) { |
|
322 mTimer.start(updateInterval); |
|
323 } |
|
324 |
|
325 |
258 emit viewChanged(mCurrentContainer); |
326 emit viewChanged(mCurrentContainer); |
259 } |
327 } |
260 |
328 |