homescreenapp/stateplugins/hshomescreenstateplugin/src/hsidlestate.cpp
changeset 101 ba1b7e218624
parent 98 e6f74eb7f69f
equal deleted inserted replaced
98:e6f74eb7f69f 101:ba1b7e218624
    76     const char hsLocTextId_OptionsMenu_HsToOnline[] = "txt_homescreen_opt_home_screen_to_online";
    76     const char hsLocTextId_OptionsMenu_HsToOnline[] = "txt_homescreen_opt_home_screen_to_online";
    77 
    77 
    78     //Sends request to all widgets to disable data connections
    78     //Sends request to all widgets to disable data connections
    79     const char hsLocTextId_OptionsMenu_HsToOffline[] = "txt_homescreen_opt_home_screen_to_offline";
    79     const char hsLocTextId_OptionsMenu_HsToOffline[] = "txt_homescreen_opt_home_screen_to_offline";
    80 
    80 
       
    81     //Home screen options menu item for opening Task switcher
       
    82     const char hsLocTextId_OptionsMenu_TaskSwitcher[] = "txt_homescreen_opt_task_switcher";
       
    83 
       
    84     //Home screen options menu item for opening Application library
       
    85     const char hsLocTextId_OptionsMenu_AddContent[] = "txt_homescreen_opt_add_content";
       
    86 
       
    87     //Home screen canvas menu item for opening Application library
       
    88     const char hsLocTextId_ContextMenu_AddContent[] = "txt_homescreen_list_add_content";
       
    89 
    81     //Home screen canvas menu item for opening picture gallery
    90     //Home screen canvas menu item for opening picture gallery
    82     const char hsLocTextId_ContextMenu_ChangeWallpaper[] = "txt_homescreen_list_change_wallpaper";
    91     const char hsLocTextId_ContextMenu_ChangeWallpaper[] = "txt_homescreen_list_change_wallpaper";
    83 
       
    84     //Home screen canvas menu item for opening Application library
       
    85     const char hsLocTextId_ContextMenu_AddContent[] = "txt_homescreen_opt_add_content";
       
    86 
       
    87     //Home screen options menu item for opening Task switcher
       
    88     const char hsLocTextId_OptionsMenu_TaskSwitcher[] = "txt_homescreen_opt_task_switcher";
       
    89 
    92 
    90     //Heading text in confirmation dialog while removing page with content
    93     //Heading text in confirmation dialog while removing page with content
    91     const char hsLocTextId_Title_RemovePage[] = "txt_homescreen_title_remove_page";
    94     const char hsLocTextId_Title_RemovePage[] = "txt_homescreen_title_remove_page";
    92 
    95 
    93     //Text in confirmation dialog while removing page with content
    96     //Text in confirmation dialog while removing page with content
   141     //mContinuousFeedback->setContinuousEffect(HbFeedback::ContinuousSmooth);
   144     //mContinuousFeedback->setContinuousEffect(HbFeedback::ContinuousSmooth);
   142     //mContinuousFeedback->setIntensity(HbFeedback::IntensityFull );
   145     //mContinuousFeedback->setIntensity(HbFeedback::IntensityFull );
   143 
   146 
   144     mVerticalSnapLineTimer.setSingleShot(true);
   147     mVerticalSnapLineTimer.setSingleShot(true);
   145     mHorizontalSnapLineTimer.setSingleShot(true);
   148     mHorizontalSnapLineTimer.setSingleShot(true);
       
   149     qRegisterMetaType<HsWidgetHost *>("HsWidgetHost *");
   146 }
   150 }
   147 
   151 
   148 /*!
   152 /*!
   149     Destroys this idle state.
   153     Destroys this idle state.
   150 */
   154 */
   326     
   330     
   327     ENTRY_ACTION(state_preRemovePage, action_preRemovePage_showQuery)
   331     ENTRY_ACTION(state_preRemovePage, action_preRemovePage_showQuery)
   328     EXIT_ACTION(state_preRemovePage, action_preRemovePage_exit);
   332     EXIT_ACTION(state_preRemovePage, action_preRemovePage_exit);
   329 
   333 
   330     ENTRY_ACTION(state_removePage, action_removePage_startRemovePageAnimation)
   334     ENTRY_ACTION(state_removePage, action_removePage_startRemovePageAnimation)
       
   335     ENTRY_ACTION(state_removePage, action_removePage_connectAboutToChangeOrientationEventHandler)
   331     EXIT_ACTION(state_removePage, action_removePage_removePage)
   336     EXIT_ACTION(state_removePage, action_removePage_removePage)
       
   337     EXIT_ACTION(state_removePage, action_removePage_disconnectAboutToChangeOrientationEventHandler)
   332 
   338 
   333     ENTRY_ACTION(state_toggleConnection, action_toggleConnection_toggleConnection)
   339     ENTRY_ACTION(state_toggleConnection, action_toggleConnection_toggleConnection)
   334 }
   340 }
   335 
   341 
   336 /*!
   342 /*!
   634 
   640 
   635 void HsIdleState::onWidgetTapStarted(QPointF point, HsWidgetHost *widget)
   641 void HsIdleState::onWidgetTapStarted(QPointF point, HsWidgetHost *widget)
   636 {
   642 {
   637     HsScene *scene = HsScene::instance();
   643     HsScene *scene = HsScene::instance();
   638     HsPage *page = scene->activePage();
   644     HsPage *page = scene->activePage();
   639     QMetaObject::invokeMethod(page, "updateZValues", Qt::QueuedConnection);
   645     // If z-values are changed in this event handler flow, then active widget will be
       
   646     // one benieth this one
       
   647     QMetaObject::invokeMethod(page, "updateZValues", Qt::QueuedConnection, Q_ARG(HsWidgetHost *,widget));
       
   648     
   640     HbVkbHost::HbVkbStatus status = HbVkbHostBridge::instance()->keypadStatus();
   649     HbVkbHost::HbVkbStatus status = HbVkbHostBridge::instance()->keypadStatus();
   641     if ( status == HbVkbHost::HbVkbStatusOpened && !isEditor(point, widget) ) {
   650     if ( status == HbVkbHost::HbVkbStatusOpened && !isEditor(point, widget) ) {
   642         closeVirtualKeyboard();
   651         closeVirtualKeyboard();
   643     }
   652     }
   644 }
   653 }
   879     // Task switcher
   888     // Task switcher
   880     menu->addAction(hbTrId(hsLocTextId_OptionsMenu_TaskSwitcher),
   889     menu->addAction(hbTrId(hsLocTextId_OptionsMenu_TaskSwitcher),
   881         this, SLOT(openTaskSwitcher()));
   890         this, SLOT(openTaskSwitcher()));
   882     
   891     
   883     // Add content
   892     // Add content
   884     menu->addAction(hbTrId(hsLocTextId_ContextMenu_AddContent),
   893     menu->addAction(hbTrId(hsLocTextId_OptionsMenu_AddContent),
   885         this, SLOT(onAddContentFromOptionsMenuActionTriggered()));
   894         this, SLOT(onAddContentFromOptionsMenuActionTriggered()));
   886     // Add page
   895     // Add page
   887     if (scene->pages().count() < HSCONFIGURATION_GET(maximumPageCount)) {
   896     if (scene->pages().count() < HSCONFIGURATION_GET(maximumPageCount)) {
   888         menu->addAction(hbTrId(hsLocTextId_OptionsMenu_AddPage),
   897         menu->addAction(hbTrId(hsLocTextId_OptionsMenu_AddPage),
   889             this, SIGNAL(event_addPage()));
   898             this, SIGNAL(event_addPage()));
  1105 
  1114 
  1106         QPointF adjustedWidgetPosition = page->adjustedWidgetPosition(widgetRect);
  1115         QPointF adjustedWidgetPosition = page->adjustedWidgetPosition(widgetRect);
  1107         widget->visual()->setPos(adjustedWidgetPosition);
  1116         widget->visual()->setPos(adjustedWidgetPosition);
  1108 
  1117 
  1109         widget->savePresentation();
  1118         widget->savePresentation();
  1110         page->updateZValues();
  1119         page->updateZValues(widget);
  1111 
  1120 
  1112         widget->visual()->setParentItem(HsScene::instance()->activePage()->visual());
  1121         widget->visual()->setParentItem(HsScene::instance()->activePage()->visual());
  1113     }
  1122     }
  1114     HsGui::instance()->idleWidget()->showPageIndicator();
  1123     HsGui::instance()->idleWidget()->showPageIndicator();
  1115     
  1124     
  1330     HsPropertyAnimationWrapper *animation = HsGui::instance()->pageChangeAnimation();
  1339     HsPropertyAnimationWrapper *animation = HsGui::instance()->pageChangeAnimation();
  1331     if (animation->isRunning()) {
  1340     if (animation->isRunning()) {
  1332         animation->stop();
  1341         animation->stop();
  1333     }
  1342     }
  1334     animation->disconnect(this);
  1343     animation->disconnect(this);
       
  1344 
  1335     connect(animation,
  1345     connect(animation,
  1336             SIGNAL(finished()),
  1346             SIGNAL(finished()),
  1337             SIGNAL(event_waitInput()), 
  1347             SIGNAL(event_waitInput()), 
  1338             Qt::UniqueConnection);
  1348             Qt::UniqueConnection);
       
  1349 
  1339     animation->setEndValue(pageLayerXPos(nextPageIndex));
  1350     animation->setEndValue(pageLayerXPos(nextPageIndex));
  1340     animation->setDuration(HSCONFIGURATION_GET(pageRemovedAnimationDuration));
  1351     animation->setDuration(HSCONFIGURATION_GET(pageRemovedAnimationDuration));
  1341    
  1352    
  1342     animation->start();
  1353     animation->start();
  1343     
  1354     
  1344     HbInstantFeedback::play(HSCONFIGURATION_GET(pageChangeFeedbackEffect));
  1355     HbInstantFeedback::play(HSCONFIGURATION_GET(pageChangeFeedbackEffect));
  1345     
  1356 }
       
  1357 
       
  1358 /*!
       
  1359     Connects the SIGNAL for about to change the orientation for removePage state 
       
  1360     to go back to waitInput state
       
  1361 */
       
  1362 void HsIdleState::action_removePage_connectAboutToChangeOrientationEventHandler()
       
  1363 {
       
  1364     connect(HsGui::instance(),
       
  1365         SIGNAL(aboutToChangeOrientation()),
       
  1366         SIGNAL(event_waitInput()));
  1346 }
  1367 }
  1347 
  1368 
  1348 /*!
  1369 /*!
  1349     Removes an existing page from the scene.
  1370     Removes an existing page from the scene.
  1350 */
  1371 */
  1366     // Take new active page (previous was removed) and move scene to right position
  1387     // Take new active page (previous was removed) and move scene to right position
  1367     qreal x = pageLayerXPos(scene->activePageIndex());
  1388     qreal x = pageLayerXPos(scene->activePageIndex());
  1368     idleWidget->setSceneX(x);
  1389     idleWidget->setSceneX(x);
  1369     // delete it   
  1390     // delete it   
  1370     pageToRemove->deleteLater();
  1391     pageToRemove->deleteLater();
  1371    
  1392 }
  1372 }
  1393 
       
  1394 /*!
       
  1395     Disconnects the SIGNAL for about to change the orientation for removePage state 
       
  1396     to go back to waitInput state
       
  1397 
       
  1398 */
       
  1399 void HsIdleState::action_removePage_disconnectAboutToChangeOrientationEventHandler()
       
  1400 {
       
  1401     disconnect(HsGui::instance(),
       
  1402         SIGNAL(aboutToChangeOrientation()),
       
  1403         this, SIGNAL(event_waitInput()));
       
  1404 }
       
  1405 
  1373 /*!
  1406 /*!
  1374     Toggles the homescreen online/offline state.
  1407     Toggles the homescreen online/offline state.
  1375 */
  1408 */
  1376 void HsIdleState::action_toggleConnection_toggleConnection()
  1409 void HsIdleState::action_toggleConnection_toggleConnection()
  1377 {
  1410 {