24 #include <HbMenu> |
24 #include <HbMenu> |
25 #include <HbAction> |
25 #include <HbAction> |
26 #include <HbListView> |
26 #include <HbListView> |
27 #include <HbNotificationDialog> |
27 #include <HbNotificationDialog> |
28 #include <HbStyleLoader> |
28 #include <HbStyleLoader> |
|
29 #include <hbapplication> // hbapplication |
|
30 #include <hbactivitymanager> // activity manager |
29 |
31 |
30 // User includes |
32 // User includes |
31 #include "clockmainview.h" |
33 #include "clockmainview.h" |
32 #include "clockdocloader.h" |
34 #include "clockdocloader.h" |
33 #include "clockappcontrollerif.h" |
35 #include "clockappcontrollerif.h" |
191 |
194 |
192 // Connect to orientation change and load appropriate section. |
195 // Connect to orientation change and load appropriate section. |
193 connect( |
196 connect( |
194 window, SIGNAL(orientationChanged(Qt::Orientation)), |
197 window, SIGNAL(orientationChanged(Qt::Orientation)), |
195 this, SLOT(checkOrientationAndLoadSection(Qt::Orientation))); |
198 this, SLOT(checkOrientationAndLoadSection(Qt::Orientation))); |
|
199 |
|
200 // Get a pointer to activity Manager |
|
201 HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager(); |
|
202 |
|
203 // clean up any previous versions of this activity from the activity manager. |
|
204 // ignore return value as the first boot would always return a false |
|
205 // bool declared on for debugging purpose |
|
206 bool ok = activityManager->removeActivity(clockMainView); |
|
207 |
|
208 // connect for the aboutToQuit events on application Exit as to call saveActivity |
|
209 connect(qobject_cast<HbApplication*>(qApp), SIGNAL(aboutToQuit()), this, SLOT(saveActivity())); |
|
210 |
196 } |
211 } |
197 |
212 |
198 /*! |
213 /*! |
199 To defer the connects and initialization. To be done after the view is drawn. |
214 To defer the connects and initialization. To be done after the view is drawn. |
200 Should be called in the slot of view ready. |
215 Should be called in the slot of view ready. |
309 toolbar. This is responsible for launching the world clock. |
324 toolbar. This is responsible for launching the world clock. |
310 */ |
325 */ |
311 void ClockMainView::displayWorldClockView() |
326 void ClockMainView::displayWorldClockView() |
312 { |
327 { |
313 mAppControllerIf->switchToView(WorldClock); |
328 mAppControllerIf->switchToView(WorldClock); |
|
329 // no need to capture the screenshot here as it's done in ClockViewManager::showView |
314 |
330 |
315 } |
331 } |
316 |
332 |
317 /*! |
333 /*! |
318 Slot which gets called when `New alarm' action is triggered from the view |
334 Slot which gets called when `New alarm' action is triggered from the view |
320 */ |
336 */ |
321 void ClockMainView::addNewAlarm() |
337 void ClockMainView::addNewAlarm() |
322 { |
338 { |
323 ClockAlarmEditor *alarmEditor = new ClockAlarmEditor(*mAlarmClient); |
339 ClockAlarmEditor *alarmEditor = new ClockAlarmEditor(*mAlarmClient); |
324 alarmEditor->showAlarmEditor(); |
340 alarmEditor->showAlarmEditor(); |
|
341 // capture screenshot for future use, if application |
|
342 // is exited/Quit from alarmEditor |
|
343 captureScreenShot(true); |
325 } |
344 } |
326 |
345 |
327 /*! |
346 /*! |
328 Slot which gets called when `Settings' action is triggered from the view |
347 Slot which gets called when `Settings' action is triggered from the view |
329 menu. This is responsible for launching the settings view. |
348 menu. This is responsible for launching the settings view. |
331 void ClockMainView::openSettings() |
350 void ClockMainView::openSettings() |
332 { |
351 { |
333 // Create the settings view. |
352 // Create the settings view. |
334 ClockSettingsView *settingsView = new ClockSettingsView(this); |
353 ClockSettingsView *settingsView = new ClockSettingsView(this); |
335 settingsView->loadSettingsView(); |
354 settingsView->loadSettingsView(); |
|
355 // capture screenshot for future use, if application |
|
356 // is exited/Quit from alarmEditor |
|
357 captureScreenShot(true); |
336 } |
358 } |
337 |
359 |
338 /*! |
360 /*! |
339 This slot handles the 'activated' signal of the alarm list. Opens the |
361 This slot handles the 'activated' signal of the alarm list. Opens the |
340 alarm editor to edit the alarm. |
362 alarm editor to edit the alarm. |
351 |
373 |
352 // Construct the alarm editor. |
374 // Construct the alarm editor. |
353 ClockAlarmEditor *alarmEditor = new ClockAlarmEditor( |
375 ClockAlarmEditor *alarmEditor = new ClockAlarmEditor( |
354 *mAlarmClient, alarmId); |
376 *mAlarmClient, alarmId); |
355 alarmEditor->showAlarmEditor(); |
377 alarmEditor->showAlarmEditor(); |
|
378 // capture screenshot for future use, if application |
|
379 // is exited/Quit from alarmEditor |
|
380 captureScreenShot(true); |
356 } |
381 } |
357 } |
382 } |
358 |
383 |
359 /*! |
384 /*! |
360 This slot handles the 'longpressed' signal of the alarm list. Opens the |
385 This slot handles the 'longpressed' signal of the alarm list. Opens the |
391 hbTrId("txt_clk_main_view_menu_delete_alarm")); |
416 hbTrId("txt_clk_main_view_menu_delete_alarm")); |
392 |
417 |
393 // Show the menu. |
418 // Show the menu. |
394 itemContextMenu->open(this, SLOT(selectedMenuAction(HbAction*))); |
419 itemContextMenu->open(this, SLOT(selectedMenuAction(HbAction*))); |
395 itemContextMenu->setPreferredPos(coords); |
420 itemContextMenu->setPreferredPos(coords); |
|
421 itemContextMenu->setAttribute(Qt::WA_DeleteOnClose, true ); |
|
422 |
396 } |
423 } |
397 |
424 |
398 /*! |
425 /*! |
399 This slot handles the deletion of the alarm from the server. |
426 This slot handles the deletion of the alarm from the server. |
400 |
427 |
514 /*! |
541 /*! |
515 Slot to either hide or show the alarmlist. |
542 Slot to either hide or show the alarmlist. |
516 */ |
543 */ |
517 void ClockMainView::handleAlarmListDisplay() |
544 void ClockMainView::handleAlarmListDisplay() |
518 { |
545 { |
|
546 // alarmEditor closed reset the captured screenshot, current view is main view now |
|
547 captureScreenShot(false); |
519 // Get the list of pending clock alarms from server. |
548 // Get the list of pending clock alarms from server. |
520 QList<AlarmInfo> alarmInfoList; |
549 QList<AlarmInfo> alarmInfoList; |
521 QList<AlarmInfo> displayInfoList; |
550 QList<AlarmInfo> displayInfoList; |
522 AlarmInfo alarmInfo; |
551 AlarmInfo alarmInfo; |
523 mAlarmClient->getAlarmList(alarmInfoList); |
552 mAlarmClient->getAlarmList(alarmInfoList); |
659 void ClockMainView::updateClockWidget() |
688 void ClockMainView::updateClockWidget() |
660 { |
689 { |
661 mClockWidget->updateTime(); |
690 mClockWidget->updateTime(); |
662 } |
691 } |
663 |
692 |
|
693 /*! |
|
694 CaptureScreenShot captures screen shot |
|
695 \param captureScreenShot bool to indicate if screenshot needs to be captured |
|
696 */ |
|
697 void ClockMainView::captureScreenShot(bool captureScreenShot) |
|
698 { |
|
699 // check if screen shot needs to be captured |
|
700 if (captureScreenShot) { |
|
701 mScreenShot.clear(); |
|
702 mScreenShot.insert("screenshot", QPixmap::grabWidget(mainWindow(), mainWindow()->rect())); |
|
703 } |
|
704 mIsScreenShotCapruted = captureScreenShot; // set mIsScreenShotCapruted set validity of screenshot |
|
705 } |
|
706 |
|
707 /*! |
|
708 saveActivity saves main view as an activity |
|
709 */ |
|
710 void ClockMainView::saveActivity() |
|
711 { |
|
712 // Get a pointer to activity Manager |
|
713 HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager(); |
|
714 // check if a valid screenshot is already captured |
|
715 if (!mIsScreenShotCapruted) { |
|
716 mScreenShot.clear(); |
|
717 mScreenShot.insert("screenshot", QPixmap::grabWidget(mainWindow(), mainWindow()->rect())); |
|
718 } |
|
719 |
|
720 // save any data necessary to save the state |
|
721 QByteArray serializedActivity; |
|
722 QDataStream stream(&serializedActivity, QIODevice::WriteOnly | QIODevice::Append); |
|
723 stream << MainView; |
|
724 |
|
725 // add the activity to the activity manager |
|
726 bool ok = activityManager->addActivity(clockMainView, serializedActivity, mScreenShot); |
|
727 if ( !ok ) { |
|
728 qFatal("Add failed" ); |
|
729 } |
|
730 } |
664 // End of file --Don't remove. |
731 // End of file --Don't remove. |