30 #include <HbApplication> // hbapplication |
30 #include <HbApplication> // hbapplication |
31 #include <HbActivityManager> // activity manager |
31 #include <HbActivityManager> // activity manager |
32 #include <xqsettingsmanager.h> |
32 #include <xqsettingsmanager.h> |
33 #include <xqsettingskey.h> |
33 #include <xqsettingskey.h> |
34 #include <clockdomaincrkeys.h> |
34 #include <clockdomaincrkeys.h> |
|
35 #include <AfActivityStorage.h>//activity |
35 |
36 |
36 // User includes |
37 // User includes |
37 #include "clockmainview.h" |
38 #include "clockmainview.h" |
38 #include "clockdocloader.h" |
39 #include "clockdocloader.h" |
39 #include "clockappcontrollerif.h" |
40 #include "clockappcontrollerif.h" |
116 ClockAppControllerIf &controllerIf, ClockDocLoader *docLoader) |
117 ClockAppControllerIf &controllerIf, ClockDocLoader *docLoader) |
117 { |
118 { |
118 OstTraceFunctionEntry0( CLOCKMAINVIEW_SETUPVIEW_ENTRY ); |
119 OstTraceFunctionEntry0( CLOCKMAINVIEW_SETUPVIEW_ENTRY ); |
119 mDocLoader = docLoader; |
120 mDocLoader = docLoader; |
120 mAppControllerIf = &controllerIf; |
121 mAppControllerIf = &controllerIf; |
121 |
122 //initialize the activity |
|
123 mActivityStorage = new AfActivityStorage(this); |
122 mTimezoneClient = controllerIf.timezoneClient(); |
124 mTimezoneClient = controllerIf.timezoneClient(); |
123 mSettingsUtility = controllerIf.settingsUtility(); |
125 mSettingsUtility = controllerIf.settingsUtility(); |
124 mAlarmClient = controllerIf.alarmClient(); |
126 mAlarmClient = controllerIf.alarmClient(); |
125 |
127 |
126 // Fetch the color group of the labels from the theme. |
128 // Fetch the color group of the labels from the theme. |
210 |
212 |
211 mDayLabel = static_cast<HbLabel *> (mDocLoader->findObject("dateLabel")); |
213 mDayLabel = static_cast<HbLabel *> (mDocLoader->findObject("dateLabel")); |
212 mDayLabel->setTextColor(mLabelColorGroup); |
214 mDayLabel->setTextColor(mLabelColorGroup); |
213 mPlaceLabel = static_cast<HbLabel *> (mDocLoader->findObject("placetext")); |
215 mPlaceLabel = static_cast<HbLabel *> (mDocLoader->findObject("placetext")); |
214 mPlaceLabel->setTextColor(mLabelColorGroup); |
216 mPlaceLabel->setTextColor(mLabelColorGroup); |
|
217 mPlaceLabel->setAlignment(Qt::AlignLeft); |
|
218 mPlaceLabel->setTextWrapping(Hb::TextNoWrap); |
215 mDstIcon = static_cast<HbLabel *> (mDocLoader->findObject("dstIcon")); |
219 mDstIcon = static_cast<HbLabel *> (mDocLoader->findObject("dstIcon")); |
216 mClockWidget = static_cast<ClockWidget*> ( |
220 mClockWidget = static_cast<ClockWidget*> ( |
217 mDocLoader->findObject(CLOCK_WIDGET)); |
221 mDocLoader->findObject(CLOCK_WIDGET)); |
218 |
222 |
219 // Update the date info. |
223 // Update the date info. |
226 // Connect to orientation change and load appropriate section. |
230 // Connect to orientation change and load appropriate section. |
227 connect( |
231 connect( |
228 window, SIGNAL(orientationChanged(Qt::Orientation)), |
232 window, SIGNAL(orientationChanged(Qt::Orientation)), |
229 this, SLOT(checkOrientationAndLoadSection(Qt::Orientation))); |
233 this, SLOT(checkOrientationAndLoadSection(Qt::Orientation))); |
230 |
234 |
231 // Get a pointer to activity Manager |
235 |
232 HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager(); |
|
233 |
236 |
234 // clean up any previous versions of this activity from the activity manager. |
237 // clean up any previous versions of this activity. |
235 // ignore return value as the first boot would always return a false |
238 // ignore return value as the first boot would always return a false |
236 // bool declared on for debugging purpose |
239 // bool declared on for debugging purpose |
237 bool ok = activityManager->removeActivity(clockMainView); |
240 bool ok = removeActivity(); |
238 |
241 |
239 // connect for the aboutToQuit events on application Exit as to call saveActivity |
242 // connect for the aboutToQuit events on application Exit as to call saveActivity |
240 connect(qobject_cast<HbApplication*>(qApp), SIGNAL(aboutToQuit()), this, SLOT(saveActivity())); |
243 connect(qobject_cast<HbApplication*>(qApp), SIGNAL(aboutToQuit()), this, SLOT(saveActivity())); |
241 |
244 |
242 OstTraceFunctionExit0( CLOCKMAINVIEW_SETUPVIEW_EXIT ); |
245 OstTraceFunctionExit0( CLOCKMAINVIEW_SETUPVIEW_EXIT ); |
540 updatePlaceLabel(mTimezoneClient->timeUpdateOn()); |
543 updatePlaceLabel(mTimezoneClient->timeUpdateOn()); |
541 // Update date label. |
544 // Update date label. |
542 updateDateLabel(); |
545 updateDateLabel(); |
543 // Update clock widget. |
546 // Update clock widget. |
544 updateClockWidget(); |
547 updateClockWidget(); |
|
548 captureScreenShot(false); |
545 OstTraceFunctionExit0( CLOCKMAINVIEW_UPDATEVIEW_EXIT ); |
549 OstTraceFunctionExit0( CLOCKMAINVIEW_UPDATEVIEW_EXIT ); |
546 } |
550 } |
547 |
551 |
548 /*! |
552 /*! |
549 Slot which gets called for value change in auto time update in cenrep. |
553 Slot which gets called for value change in auto time update in cenrep. |
835 saveActivity saves main view as an activity |
839 saveActivity saves main view as an activity |
836 */ |
840 */ |
837 void ClockMainView::saveActivity() |
841 void ClockMainView::saveActivity() |
838 { |
842 { |
839 OstTraceFunctionEntry0( CLOCKMAINVIEW_SAVEACTIVITY_ENTRY ); |
843 OstTraceFunctionEntry0( CLOCKMAINVIEW_SAVEACTIVITY_ENTRY ); |
840 // Get a pointer to activity Manager |
|
841 HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager(); |
|
842 // check if a valid screenshot is already captured |
844 // check if a valid screenshot is already captured |
843 if (!mIsScreenShotCapruted) { |
845 if (!mIsScreenShotCapruted) { |
844 mScreenShot.clear(); |
846 mScreenShot.clear(); |
845 mScreenShot.insert("screenshot", QPixmap::grabWidget(mainWindow(), mainWindow()->rect())); |
847 mScreenShot.insert("screenshot", QPixmap::grabWidget(mainWindow(), mainWindow()->rect())); |
846 } |
848 } |
849 QByteArray serializedActivity; |
851 QByteArray serializedActivity; |
850 QDataStream stream(&serializedActivity, QIODevice::WriteOnly | QIODevice::Append); |
852 QDataStream stream(&serializedActivity, QIODevice::WriteOnly | QIODevice::Append); |
851 stream << MainView; |
853 stream << MainView; |
852 |
854 |
853 // add the activity to the activity manager |
855 // add the activity to the activity manager |
854 bool ok = activityManager->addActivity(clockMainView, serializedActivity, mScreenShot); |
856 bool ok = mActivityStorage->saveActivity(clockMainView, serializedActivity, mScreenShot); |
855 if ( !ok ) { |
857 if ( !ok ) { |
856 qFatal("Add failed" ); |
858 qFatal("Add failed" ); |
857 } |
859 } |
858 OstTraceFunctionExit0( CLOCKMAINVIEW_SAVEACTIVITY_EXIT ); |
860 OstTraceFunctionExit0( CLOCKMAINVIEW_SAVEACTIVITY_EXIT ); |
859 } |
861 } |
|
862 |
|
863 /*! |
|
864 Function to remove the activity |
|
865 */ |
|
866 bool ClockMainView::removeActivity() |
|
867 { |
|
868 OstTraceFunctionEntry0( CLOCKMAINVIEW_REMOVEACTIVITY_ENTRY ); |
|
869 OstTraceFunctionExit0( CLOCKMAINVIEW_REMOVEACTIVITY_EXIT ); |
|
870 return mActivityStorage->removeActivity(clockMainView); |
|
871 } |
860 // End of file --Don't remove. |
872 // End of file --Don't remove. |