39 #include "hspage.h" |
39 #include "hspage.h" |
40 |
40 |
41 #include "canotifier.h" |
41 #include "canotifier.h" |
42 #include "canotifierfilter.h" |
42 #include "canotifierfilter.h" |
43 #include "caservice.h" |
43 #include "caservice.h" |
44 |
|
45 #include "hsdomainmodel_global.h" |
44 #include "hsdomainmodel_global.h" |
46 #include <hscontentservice.h> |
45 #include <hscontentservice.h> |
47 |
|
48 |
46 |
49 const char HS_PREVIEW_HS_WIDGET_STATE[] = "HsPreviewHSWidgetState"; |
47 const char HS_PREVIEW_HS_WIDGET_STATE[] = "HsPreviewHSWidgetState"; |
50 |
48 |
51 /*! |
49 /*! |
52 \class HsPreviewHSWidgetState |
50 \class HsPreviewHSWidgetState |
145 mScrollArea->horizontalScrollBar()->setInteractive(true); |
143 mScrollArea->horizontalScrollBar()->setInteractive(true); |
146 mWidget = widget.take(); // ownership transfered |
144 mWidget = widget.take(); // ownership transfered |
147 mScrollArea->setContentWidget(mWidget); // ownership transferred |
145 mScrollArea->setContentWidget(mWidget); // ownership transferred |
148 |
146 |
149 subscribeForMemoryCardRemove(); |
147 subscribeForMemoryCardRemove(); |
150 mWidget->initializeWidget(); |
148 mWidget->startWidget(); |
151 mWidget->showWidget(); |
|
152 // Launch popup asyncronously |
149 // Launch popup asyncronously |
153 mPopupDialog->open(this, SLOT(previewDialogFinished(HbAction*))); |
150 mPopupDialog->open(this, SLOT(previewDialogFinished(HbAction*))); |
154 } |
151 } |
155 |
152 |
156 } else { |
153 } else { |
|
154 subscribeForMemoryCardRemove(); |
157 showMessageWidgetCorrupted(); |
155 showMessageWidgetCorrupted(); |
158 } |
156 } |
159 |
157 |
160 HSMENUTEST_FUNC_EXIT("HsPreviewHSWidgetState::onEntry"); |
158 HSMENUTEST_FUNC_EXIT("HsPreviewHSWidgetState::onEntry"); |
161 } |
159 } |
167 Slot launched after state has exited and in destructor. |
165 Slot launched after state has exited and in destructor. |
168 \retval void |
166 \retval void |
169 */ |
167 */ |
170 void HsPreviewHSWidgetState::cleanUp() |
168 void HsPreviewHSWidgetState::cleanUp() |
171 { |
169 { |
172 // Close popups if App key was pressed |
170 // Close popups if App key was pressed or memory card removed |
173 if (mPopupDialog) { |
171 if (mPopupDialog) { |
|
172 disconnect(mPopupDialog, SIGNAL(finished(HbAction*)), this, SLOT(previewDialogFinished(HbAction*))); |
174 mPopupDialog->close(); |
173 mPopupDialog->close(); |
|
174 mPopupDialog = NULL; |
175 } |
175 } |
176 |
176 |
177 if (mCorruptedMessage) { |
177 if (mCorruptedMessage) { |
|
178 disconnect(mCorruptedMessage, SIGNAL(finished(HbAction*)), this, SLOT(messageWidgetCorruptedFinished(HbAction*))); |
178 mCorruptedMessage->close(); |
179 mCorruptedMessage->close(); |
179 } |
180 mCorruptedMessage = NULL; |
180 |
181 } |
181 mPopupDialog = NULL; |
182 |
182 mScrollArea = NULL; |
183 mScrollArea = NULL; |
183 mWidget = NULL; |
184 mWidget = NULL; |
184 mCorruptedMessage = NULL; |
|
185 |
185 |
186 disconnect(mNotifier, |
186 disconnect(mNotifier, |
187 SIGNAL(entryChanged(CaEntry,ChangeType)), |
187 SIGNAL(entryChanged(CaEntry,ChangeType)), |
188 this, SLOT(memoryCardRemoved())); |
188 this, SIGNAL(exit())); |
189 |
189 |
190 delete mNotifier; |
190 delete mNotifier; |
191 mNotifier = NULL; |
191 mNotifier = NULL; |
192 } |
192 } |
193 |
193 |
194 /*! |
194 /*! |
195 Memory card with instaled widget was removed. |
|
196 \retval void |
|
197 */ |
|
198 void HsPreviewHSWidgetState::memoryCardRemoved() |
|
199 { |
|
200 if (mPopupDialog) { |
|
201 mPopupDialog->close(); |
|
202 } |
|
203 // exit not needed, it is called after dialog closed |
|
204 |
|
205 } |
|
206 |
|
207 /*! |
|
208 Slot launched on dismissing the preview dialog |
195 Slot launched on dismissing the preview dialog |
209 \retval void |
196 \retval void |
210 */ |
197 */ |
211 void HsPreviewHSWidgetState::previewDialogFinished(HbAction* finishedAction) |
198 void HsPreviewHSWidgetState::previewDialogFinished(HbAction* finishedAction) |
212 { |
199 { |
213 if (mPopupDialog != NULL) { |
200 if (finishedAction == mPopupDialog->actions().value(0)) { |
214 // (work-around for crash if more then one action is selected in HbDialog) |
201 mWidget->hideWidget(); |
215 if (finishedAction == mPopupDialog->actions().value(0)) { |
202 mScrollArea->takeContentWidget(); |
216 mWidget->hideWidget(); |
203 HsScene::instance()->activePage()->addNewWidget( |
|
204 mWidget); // ownership transferred |
|
205 HbNotificationDialog *notificationDialog = new HbNotificationDialog(); |
|
206 notificationDialog->setAttribute(Qt::WA_DeleteOnClose); |
|
207 notificationDialog->setTitle(hbTrId( |
|
208 "txt_applib_dpophead_added_to_homescreen") ); |
|
209 notificationDialog->show(); |
|
210 } else { |
217 mScrollArea->takeContentWidget(); |
211 mScrollArea->takeContentWidget(); |
218 HsScene::instance()->activePage()->addNewWidget( |
212 mWidget->remove(); |
219 mWidget); // ownership transferred |
213 mWidget = NULL; |
220 HbNotificationDialog *notificationDialog = new HbNotificationDialog(); |
214 } |
221 notificationDialog->setAttribute(Qt::WA_DeleteOnClose); |
215 emit exit(); |
222 notificationDialog->setTitle(hbTrId( |
216 } |
223 "txt_applib_dpophead_added_to_homescreen") ); |
|
224 notificationDialog->show(); |
|
225 } else { |
|
226 mWidget->uninitializeWidget(); |
|
227 mWidget->deleteFromDatabase(); |
|
228 } |
|
229 mPopupDialog = NULL; |
|
230 emit exit(); |
|
231 } else { |
|
232 // (work-around for crash if more then one action is selected in HbDialog) |
|
233 qWarning("Another signal finished was emited."); |
|
234 } |
|
235 } |
|
236 |
|
237 |
|
238 |
217 |
239 /*! |
218 /*! |
240 Subscribe for memory card remove. |
219 Subscribe for memory card remove. |
241 \retval void |
220 \retval void |
242 */ |
221 */ |
269 mCorruptedMessage->setAttribute(Qt::WA_DeleteOnClose); |
247 mCorruptedMessage->setAttribute(Qt::WA_DeleteOnClose); |
270 |
248 |
271 QString message(hbTrId("txt_applib_dialog_file_corrupted_unable_to_use_wi")); |
249 QString message(hbTrId("txt_applib_dialog_file_corrupted_unable_to_use_wi")); |
272 mCorruptedMessage->setText(message); |
250 mCorruptedMessage->setText(message); |
273 |
251 |
274 mCorruptedMessage->clearActions(); |
252 mCorruptedMessage->clearActions(); |
275 HbAction *primaryAction = new HbAction(hbTrId("txt_common_button_ok"), mCorruptedMessage); |
253 HbAction *primaryAction = new HbAction(hbTrId("txt_common_button_ok"), mCorruptedMessage); |
276 mCorruptedMessage->addAction(primaryAction); |
254 mCorruptedMessage->addAction(primaryAction); |
277 |
255 |
278 HbAction *secondaryAction = new HbAction(hbTrId("txt_common_button_cancel"), mCorruptedMessage); |
256 HbAction *secondaryAction = new HbAction(hbTrId("txt_common_button_cancel"), mCorruptedMessage); |
279 mCorruptedMessage->addAction(secondaryAction); |
257 mCorruptedMessage->addAction(secondaryAction); |
280 |
258 |
281 mCorruptedMessage->open(this, SLOT(messageWidgetCorruptedFinished(HbAction*))); |
259 mCorruptedMessage->open(this, SLOT(messageWidgetCorruptedFinished(HbAction*))); |
289 Slot launched on dismissing the corrupted widget error note |
267 Slot launched on dismissing the corrupted widget error note |
290 \retval void |
268 \retval void |
291 */ |
269 */ |
292 void HsPreviewHSWidgetState::messageWidgetCorruptedFinished(HbAction* finishedAction) |
270 void HsPreviewHSWidgetState::messageWidgetCorruptedFinished(HbAction* finishedAction) |
293 { |
271 { |
294 if (mCorruptedMessage) { |
272 if (finishedAction == mCorruptedMessage->actions().value(0)) { |
295 if (finishedAction == mCorruptedMessage->actions().value(0)) { |
273 HsMenuService::executeAction(mEntryId, removeActionIdentifier()); |
296 HsMenuService::executeAction(mEntryId, removeActionIdentifier()); |
274 } |
297 } |
275 emit exit(); |
298 mCorruptedMessage = NULL; |
276 } |
299 emit exit(); |
|
300 } else { |
|
301 // (work-around for crash if more then one action is selected in HbDialog) |
|
302 qWarning("Another signal finished was emited."); |
|
303 } |
|
304 } |
|