homescreenapp/stateplugins/hsapplibrarystateplugin/src/hsapplibrarystate.cpp
changeset 71 1db7cc813a4e
parent 63 52b0f64eeb51
child 81 7dd137878ff8
equal deleted inserted replaced
69:87476091b3f5 71:1db7cc813a4e
   116 
   116 
   117     mAllAppsState = new HsAllAppsState(mMenuViewBuilder, mMenuMode, mMainWindow, this);
   117     mAllAppsState = new HsAllAppsState(mMenuViewBuilder, mMenuMode, mMainWindow, this);
   118 
   118 
   119     mAllCollectionsState = new HsAllCollectionsState(mMenuViewBuilder, mMenuMode,
   119     mAllCollectionsState = new HsAllCollectionsState(mMenuViewBuilder, mMenuMode,
   120             mMainWindow, this);
   120             mMainWindow, this);
   121             
   121 
   122     QState *initialState = new QState(this);
   122     QState *initialState = new QState(this);
   123     setInitialState(initialState);
   123     setInitialState(initialState);
   124 
   124 
   125     mHistoryTransaction =  new HsMenuModeTransition(
   125     mHistoryTransaction =  new HsMenuModeTransition(
   126         mMenuMode, NormalHsMenuMode, mAllAppsState);
   126         mMenuMode, NormalHsMenuMode, mAllAppsState);
   133             mMenuMode,
   133             mMenuMode,
   134             mMainWindow,
   134             mMainWindow,
   135             this);
   135             this);
   136 
   136 
   137     connect(mCollectionState, SIGNAL(entered()),SLOT(clearToolbarLatch()));
   137     connect(mCollectionState, SIGNAL(entered()),SLOT(clearToolbarLatch()));
   138     
   138 
   139     HsMenuEventTransition *openCollectionFromAppLibTransition =
   139     HsMenuEventTransition *openCollectionFromAppLibTransition =
   140         new HsMenuEventTransition(HsMenuEvent::OpenCollectionFromAppLibrary,
   140         new HsMenuEventTransition(HsMenuEvent::OpenCollectionFromAppLibrary,
   141                                   this, mCollectionState);
   141                                   this, mCollectionState);
   142     this->addTransition(openCollectionFromAppLibTransition);
   142     this->addTransition(openCollectionFromAppLibTransition);
   143     
   143 
   144     //It is called from: HsDefaultRuntime::activityRequested(const QString &name)
   144     //It is called from: HsDefaultRuntime::activityRequested(const QString &name)
   145     HsMenuEventTransition *openCollectionAfterActivityRequest =
   145     HsMenuEventTransition *openCollectionAfterActivityRequest =
   146             new HsMenuEventTransition(HsMenuEvent::OpenCollection,
   146             new HsMenuEventTransition(HsMenuEvent::OpenCollection,
   147                                       this, mCollectionState);
   147                                       this, mCollectionState);
   148     this->addTransition(openCollectionAfterActivityRequest);
   148     this->addTransition(openCollectionAfterActivityRequest);
   181     connect(mAllCollectionsState, SIGNAL(toAppLibraryState()),
   181     connect(mAllCollectionsState, SIGNAL(toAppLibraryState()),
   182             this, SIGNAL(toHomescreenState()));
   182             this, SIGNAL(toHomescreenState()));
   183 
   183 
   184     connect(mAllCollectionsState, SIGNAL(entered()),
   184     connect(mAllCollectionsState, SIGNAL(entered()),
   185             this, SLOT(allCollectionsStateEntered()));
   185             this, SLOT(allCollectionsStateEntered()));
   186   
   186 
   187     HSMENUTEST_FUNC_EXIT("HsAppLibraryState::construct");
   187     HSMENUTEST_FUNC_EXIT("HsAppLibraryState::construct");
   188 }
   188 }
   189 
   189 
   190 /*!
   190 /*!
   191  Sets entry event.
   191  Sets entry event.
   195 {
   195 {
   196     qDebug("HsCollectionState::onEntry()");
   196     qDebug("HsCollectionState::onEntry()");
   197     HSMENUTEST_FUNC_ENTRY("HsAppLibraryState::onEntry");
   197     HSMENUTEST_FUNC_ENTRY("HsAppLibraryState::onEntry");
   198     QState::onEntry(event);
   198     QState::onEntry(event);
   199 
   199 
   200     if (static_cast<HsMenuEvent *>(event)->operation() != 
   200     if (static_cast<HsMenuEvent *>(event)->operation() !=
   201             HsMenuEvent::OpenCollectionFromAppLibrary)
   201             HsMenuEvent::OpenCollectionFromAppLibrary)
   202         {
   202         {
   203     // we are back from HS, scroll those views to top
   203     // we are back from HS, scroll those views to top
   204         mAllAppsState->scrollToBeginning();
   204         mAllAppsState->scrollToBeginning();
   205         mAllCollectionsState->scrollToBeginning();        
   205         mAllCollectionsState->scrollToBeginning();
   206         }
   206         }
   207     
   207 
   208     if (event->type() == HsMenuEvent::eventType()) {
   208     if (event->type() == HsMenuEvent::eventType()) {
   209         HsMenuEvent *menuEvent = static_cast<HsMenuEvent *>(event);
   209         HsMenuEvent *menuEvent = static_cast<HsMenuEvent *>(event);
   210         QVariantMap data = menuEvent->data();
   210         QVariantMap data = menuEvent->data();
   211         mMenuMode.setHsMenuMode(
   211         mMenuMode.setHsMenuMode(
   212             static_cast<HsMenuMode>(data.value(menuModeType()).toInt()), 
   212             static_cast<HsMenuMode>(data.value(menuModeType()).toInt()),
   213             data.value(HOMESCREENDATA));
   213             data.value(HOMESCREENDATA));
   214     } else {
   214     } else {
   215         mMenuMode.setHsMenuMode(NormalHsMenuMode);
   215         mMenuMode.setHsMenuMode(NormalHsMenuMode);
   216     }
   216     }
   217 
   217 
   228     connect(mMenuViewBuilder.oviStoreAction(), SIGNAL(triggered()),
   228     connect(mMenuViewBuilder.oviStoreAction(), SIGNAL(triggered()),
   229             this, SLOT(oviStoreAction()));
   229             this, SLOT(oviStoreAction()));
   230 
   230 
   231     HsOperatorHandler *const operatorHandler = new HsOperatorHandler(this);
   231     HsOperatorHandler *const operatorHandler = new HsOperatorHandler(this);
   232 
   232 
   233     const bool operatorActionAvailable = !operatorHandler->icon().isNull();
   233     if (operatorHandler->oviStorePresent()
   234 
   234             && operatorHandler->operatorStorePresent()) {
   235     if (operatorActionAvailable) {
       
   236 
   235 
   237         //TODO HbToolBarExtension is not supported in docml currently
   236         //TODO HbToolBarExtension is not supported in docml currently
   238         //should be changed in future
   237         //should be changed in future
   239         bool loaded = HbStyleLoader::registerFilePath(
   238         bool loaded = HbStyleLoader::registerFilePath(
   240                      ":/css/hsapplibrarystateplugin.css");
   239                      ":/css/hsapplibrarystateplugin.css");
   241         Q_ASSERT(loaded);
   240         Q_ASSERT(loaded);
   242         HbAction *const operatorAction(mMenuViewBuilder.operatorAction());
       
   243 
   241 
   244         HbToolBarExtension *const extension(
   242         HbToolBarExtension *const extension(
   245             mMenuViewBuilder.toolBarExtension());
   243             mMenuViewBuilder.toolBarExtension());
   246         HbAction *const extensionAction(
   244         HbAction *const extensionAction(
   247             mMenuViewBuilder.toolBar()->addExtension(extension));
   245             mMenuViewBuilder.toolBar()->addExtension(extension));
   248 
   246 
   249         extensionAction->setIcon(HbIcon("qtg_mono_store"));
   247         extensionAction->setIcon(HbIcon("qtg_mono_store"));
   250 
   248 
   251         operatorAction->setIcon(operatorHandler->icon());
   249         HbAction *const operatorAction(
       
   250                 operatorHandler->prepareOperatorStoreAction(
       
   251                         mMenuViewBuilder.operatorAction()));
   252         operatorAction->setText(hbTrId(operatorHandler->text().toLatin1()));
   252         operatorAction->setText(hbTrId(operatorHandler->text().toLatin1()));
   253 
   253 
   254         //TODO: no locstring for ovi store currently
   254         //TODO: no locstring for ovi store currently
   255         mMenuViewBuilder.oviStoreAction()->setText("Ovi Store");
   255         mMenuViewBuilder.oviStoreAction()->setText("Ovi Store");
   256 
   256         if (operatorHandler->operatorStoreFirst()) {
   257         connect(mMenuViewBuilder.operatorAction(), SIGNAL(triggered()),
   257             extension->addAction(operatorAction);
   258                 operatorHandler, SLOT(action()));
   258             extension->addAction(mMenuViewBuilder.oviStoreAction());
   259 
   259         } else {
   260         extension->addAction(mMenuViewBuilder.oviStoreAction());
   260             extension->addAction(mMenuViewBuilder.oviStoreAction());
   261         extension->addAction(operatorAction);
   261             extension->addAction(operatorAction);
   262 
   262         }
   263     } else {
   263     } else if (operatorHandler->oviStorePresent()) {
   264         mMenuViewBuilder.toolBar()->addAction(
   264         mMenuViewBuilder.toolBar()->addAction(
   265             mMenuViewBuilder.oviStoreAction());
   265             mMenuViewBuilder.oviStoreAction());
   266     }
   266     } else if (operatorHandler->operatorStorePresent()) {
   267 
   267         mMenuViewBuilder.toolBar()->addAction(
   268 
   268             operatorHandler->prepareOperatorStoreAction(
   269     HbAction *const allCollectionsAction(mMenuViewBuilder.allCollectionsAction());
   269                     mMenuViewBuilder.operatorAction()));
       
   270     }
       
   271 
       
   272     HbAction *const allCollectionsAction(
       
   273             mMenuViewBuilder.allCollectionsAction());
   270 
   274 
   271     mAllAppsState->addTransition(
   275     mAllAppsState->addTransition(
   272         allCollectionsAction, SIGNAL(triggered()), mAllCollectionsState);
   276         allCollectionsAction, SIGNAL(triggered()), mAllCollectionsState);
   273     mCollectionState->addTransition(
   277     mCollectionState->addTransition(
   274         allCollectionsAction, SIGNAL(triggered()), mAllCollectionsState);
   278         allCollectionsAction, SIGNAL(triggered()), mAllCollectionsState);
   306  Ovi Store Action slot
   310  Ovi Store Action slot
   307 */
   311 */
   308 int HsAppLibraryState::oviStoreAction()
   312 int HsAppLibraryState::oviStoreAction()
   309 {
   313 {
   310     HSMENUTEST_FUNC_ENTRY("HsAppLibraryState::oviStoreAction");
   314     HSMENUTEST_FUNC_ENTRY("HsAppLibraryState::oviStoreAction");
   311     
   315 
   312     CaEntry oviEntry;
   316     CaEntry oviEntry;
   313     oviEntry.setEntryTypeName(applicationTypeName());
   317     oviEntry.setEntryTypeName(applicationTypeName());
   314     oviEntry.setAttribute( applicationUidEntryKey(), 
   318     oviEntry.setAttribute( applicationUidEntryKey(),
   315                     QString::number(oviLauncherApplicationUid));
   319                     QString::number(oviLauncherApplicationUid));
   316     
   320 
   317     int result = CaService::instance()->executeCommand(oviEntry);
   321     int result = CaService::instance()->executeCommand(oviEntry);
   318     if (result) {
   322     if (result) {
   319         oviEntry.setEntryTypeName(urlTypeName());
   323         oviEntry.setEntryTypeName(urlTypeName());
   320         oviEntry.setAttribute(urlEntryKey(),
   324         oviEntry.setAttribute(urlEntryKey(),
   321                           QString("https://store.ovi.com/applications/"));
   325                           QString("https://store.ovi.com/applications/"));
   322         result = CaService::instance()->executeCommand(oviEntry);
   326         result = CaService::instance()->executeCommand(oviEntry);
   323     }
   327     }
   324     
   328 
   325     HSMENUTEST_FUNC_EXIT("HsAppLibraryState::oviStoreAction");
   329     HSMENUTEST_FUNC_EXIT("HsAppLibraryState::oviStoreAction");
   326     return result;
   330     return result;
   327 }
   331 }
   328 
   332 
   329 /*!
   333 /*!