139 params[Hs::homescreenData] = mToken; |
137 params[Hs::homescreenData] = mToken; |
140 bool success = contentService.createWidget(params); |
138 bool success = contentService.createWidget(params); |
141 if (!success) { |
139 if (!success) { |
142 showMessageWidgetCorrupted(); |
140 showMessageWidgetCorrupted(); |
143 } else { |
141 } else { |
144 emit exit(); |
142 openHomeScreen(); |
145 if (mMenuMode == Hs::AddHsMenuMode) { |
|
146 machine()->postEvent( |
|
147 HsMenuEventFactory::createOpenHomeScreenEvent()); |
|
148 } |
|
149 } |
143 } |
150 logActionResult("Adding widget", mEntryId, success); |
144 logActionResult("Adding widget", mEntryId, success); |
151 HSMENUTEST_FUNC_EXIT("HsAddToHomeScreenState::addWidget"); |
145 HSMENUTEST_FUNC_EXIT("HsAddToHomeScreenState::addWidget"); |
152 return success; |
146 return success; |
153 } |
147 } |
154 |
148 |
155 /*! |
149 /*! |
156 Shows message about corrupted widget library. Deletes widget eventually |
150 Shows message about corrupted widget library. Deletes widget eventually. |
157 \param itemId entryId of widget (needed to delete it) |
151 \param itemId entryId of widget (needed to delete it) |
158 \retval void |
152 \retval void |
159 */ |
153 */ |
160 void HsAddToHomeScreenState::showMessageWidgetCorrupted() |
154 void HsAddToHomeScreenState::showMessageWidgetCorrupted() |
161 { |
155 { |
162 HSMENUTEST_FUNC_ENTRY("HsCollectionState::showMessageWidgetCorrupted"); |
156 HSMENUTEST_FUNC_ENTRY("HsCollectionState::showMessageWidgetCorrupted"); |
163 |
157 |
164 mCorruptedMessage = HsMenuDialogFactory().create( |
158 QScopedPointer<HsDialogController> dialogController( |
165 hbTrId("txt_applib_dialog_file_corrupted_unable_to_use_wi")); |
159 new HsDialogController( |
166 mConfirmAction = mCorruptedMessage->actions().value(0); |
160 hbTrId( |
167 |
161 "txt_applib_dialog_file_corrupted_unable_to_use_wi"))); |
168 QScopedPointer<HsMenuEntryRemovedHandler> entryObserver( |
162 |
169 new HsMenuEntryRemovedHandler(mEntryId, |
163 connect(dialogController.data(), |
170 mCorruptedMessage, SLOT(close()))); |
164 SIGNAL(acceptActionTriggered(QAction*)), |
171 |
165 this, |
172 entryObserver.take()->setParent(mCorruptedMessage); |
166 SLOT(removeWidget())); |
173 |
167 |
174 mCorruptedMessage->open(this, SLOT(messageWidgetCorruptedFinished(HbAction*))); |
168 connect(dialogController.data(), |
175 |
169 SIGNAL(dialogCompleted()), |
|
170 this, |
|
171 SLOT(openHomeScreen())); |
|
172 |
|
173 // ensure dialog is dismissed on app key pressed |
|
174 connect(this, SIGNAL(exited()), |
|
175 dialogController.data(), |
|
176 SLOT(dismissDialog())); |
|
177 |
|
178 dialogController.take()->openDialog( |
|
179 mEntryId |
|
180 ); |
|
181 |
176 HSMENUTEST_FUNC_EXIT("HsCollectionState::showMessageWidgetCorrupted"); |
182 HSMENUTEST_FUNC_EXIT("HsCollectionState::showMessageWidgetCorrupted"); |
177 } |
183 } |
178 |
184 |
179 /*! |
185 /*! |
180 Slot launched on dismissing the corrupted widget error note |
186 Exits the state. When in Add Mode sends event requesting back step to |
181 \retval void |
187 Home Screen. |
182 */ |
188 \retval void |
183 void HsAddToHomeScreenState::messageWidgetCorruptedFinished |
189 */ |
184 (HbAction* finishedAction) |
190 void HsAddToHomeScreenState::openHomeScreen() |
185 { |
191 { |
186 if (static_cast<QAction*>(finishedAction) == mConfirmAction) { |
|
187 HsMenuService::executeAction(mEntryId, Hs::removeActionIdentifier); |
|
188 } |
|
189 emit exit(); |
192 emit exit(); |
190 if (mMenuMode == Hs::AddHsMenuMode) { |
193 if (mMenuMode == Hs::AddHsMenuMode) { |
191 machine()->postEvent( |
194 machine()->postEvent( |
192 HsMenuEventFactory::createOpenHomeScreenEvent()); |
195 HsMenuEventFactory::createOpenHomeScreenEvent()); |
193 } |
196 } |
194 mConfirmAction = NULL; |
197 } |
195 } |
198 |
196 |
199 |
|
200 /*! |
|
201 Slot. Removes entry requested that was subject of |
|
202 current 'add to homescreen' action. |
|
203 \retval void |
|
204 */ |
|
205 #ifdef COVERAGE_MEASUREMENT |
|
206 #pragma CTC SKIP |
|
207 #endif //COVERAGE_MEASUREMENT |
|
208 void HsAddToHomeScreenState::removeWidget() |
|
209 { |
|
210 HsMenuService::executeAction(mEntryId, Hs::removeActionIdentifier); |
|
211 } |
|
212 #ifdef COVERAGE_MEASUREMENT |
|
213 #pragma CTC ENDSKIP |
|
214 #endif //COVERAGE_MEASUREMENT |
197 |
215 |
198 /*! |
216 /*! |
199 Slot launched after state has exited and in destructor. |
217 Slot launched after state has exited and in destructor. |
200 \retval void |
218 \retval void |
201 */ |
219 */ |
202 void HsAddToHomeScreenState::cleanUp() |
220 void HsAddToHomeScreenState::cleanUp() |
203 { |
221 { |
204 // Close popups if App key was pressed |
|
205 if (mCorruptedMessage != NULL) { |
|
206 mCorruptedMessage->close(); |
|
207 mCorruptedMessage = NULL; |
|
208 } |
|
209 |
|
210 mToken = NULL; |
222 mToken = NULL; |
211 } |
223 } |
212 |
224 |
213 |
225 |
214 /*! |
226 /*! |
215 Adds a shortcut to active page of home screen |
227 Adds a shortcut to active page of home screen |
216 \param shortcutService: service for adding shortcuts |
228 \param contentService service for adding shortcuts. |
217 \param entryId: menu entry id |
229 \retval true if successful. |
218 \param activePage: active page of home screen |
|
219 \retval true if successful |
|
220 */ |
230 */ |
221 bool HsAddToHomeScreenState::addShortcut(HsContentService &contentService) |
231 bool HsAddToHomeScreenState::addShortcut(HsContentService &contentService) |
222 { |
232 { |
223 HSMENUTEST_FUNC_ENTRY("HsAddToHomeScreenState::addShortcut"); |
233 HSMENUTEST_FUNC_ENTRY("HsAddToHomeScreenState::addShortcut"); |
224 QVariantHash params; |
234 QVariantHash params; |