44 #include "hswidgetpositioningonwidgetadd.h" |
44 #include "hswidgetpositioningonwidgetadd.h" |
45 #include "hsconfiguration.h" |
45 #include "hsconfiguration.h" |
46 #include "hstest_global.h" |
46 #include "hstest_global.h" |
47 #include "hswidgetpositioningonwidgetmove.h" |
47 #include "hswidgetpositioningonwidgetmove.h" |
48 |
48 |
49 #ifdef Q_OS_SYMBIAN |
|
50 #include <xqappmgr.h> |
|
51 #include <xqcallinfo.h> |
|
52 #include <logsservices.h> |
|
53 #include <xqrequestinfo.h> |
|
54 #endif // Q_OS_SYMBIAN |
|
55 |
|
56 QTM_USE_NAMESPACE |
49 QTM_USE_NAMESPACE |
57 #define hbApp qobject_cast<HbApplication*>(qApp) |
50 #define hbApp qobject_cast<HbApplication*>(qApp) |
58 |
51 |
59 namespace |
52 namespace |
60 { |
53 { |
85 : QStateMachine(parent), |
78 : QStateMachine(parent), |
86 mContentService(0), |
79 mContentService(0), |
87 mHomeScreenActive(false), |
80 mHomeScreenActive(false), |
88 mIdleStateActive(false), |
81 mIdleStateActive(false), |
89 mEndKeyCaptured(false), |
82 mEndKeyCaptured(false), |
90 mSendKeyCaptured(false), |
|
91 mPublisher(NULL) |
83 mPublisher(NULL) |
92 #ifdef Q_OS_SYMBIAN |
84 #ifdef Q_OS_SYMBIAN |
93 ,keyCapture() |
85 ,keyCapture() |
94 #endif |
86 #endif |
95 { |
87 { |
108 HsConfiguration::setInstance(new HsConfiguration(QCoreApplication::instance())); |
100 HsConfiguration::setInstance(new HsConfiguration(QCoreApplication::instance())); |
109 HsConfiguration::instance()->load(); |
101 HsConfiguration::instance()->load(); |
110 |
102 |
111 HsWidgetPositioningOnOrientationChange::setInstance( |
103 HsWidgetPositioningOnOrientationChange::setInstance( |
112 new HsAdvancedWidgetPositioningOnOrientationChange); |
104 new HsAdvancedWidgetPositioningOnOrientationChange); |
113 #ifdef HSWIDGETORGANIZER_ALGORITHM |
105 |
114 HsWidgetPositioningOnWidgetAdd::setInstance( |
106 HsWidgetPositioningOnWidgetAdd *widgetOrganizer = |
115 new HsWidgetOrganizer); |
107 new HsWidgetOrganizer(HSCONFIGURATION_GET(snapGap), |
116 #else |
108 HSCONFIGURATION_GET(widgetOrganizerSearchSequence)); |
117 HsWidgetPositioningOnWidgetAdd::setInstance( |
109 |
118 new HsAnchorPointInBottomRight); |
110 HsWidgetPositioningOnWidgetAdd::setInstance(widgetOrganizer); |
119 #endif |
111 |
120 |
|
121 HsWidgetPositioningOnWidgetMove::setInstance( |
112 HsWidgetPositioningOnWidgetMove::setInstance( |
122 new HsSnapToLines); |
113 new HsSnapToLines); |
123 |
114 |
124 registerAnimations(); |
115 registerAnimations(); |
125 |
116 |
176 default: |
167 default: |
177 break; |
168 break; |
178 } |
169 } |
179 |
170 |
180 bool result = QStateMachine::eventFilter(watched, event); |
171 bool result = QStateMachine::eventFilter(watched, event); |
181 |
172 |
182 if (event->type() == QEvent::KeyPress ) { |
173 if (event->type() == QEvent::KeyPress ) { |
183 QKeyEvent* ke = static_cast<QKeyEvent *>(event); |
174 QKeyEvent* ke = static_cast<QKeyEvent *>(event); |
184 int key = ke->key(); |
175 result = (ke->key() == Qt::Key_Home); |
185 |
|
186 if (key == Qt::Key_Home ) { |
|
187 result = true; |
|
188 } |
|
189 else if (key == Qt::Key_Yes ) { |
|
190 result = true; |
|
191 if (mSendKeyCaptured == false && mHomeScreenActive == true) { |
|
192 mSendKeyCaptured = true; |
|
193 startDialer(); |
|
194 } |
|
195 } |
|
196 } |
176 } |
197 return result; |
177 return result; |
198 } |
178 } |
199 |
|
200 #ifdef COVERAGE_MEASUREMENT |
|
201 #pragma CTC SKIP |
|
202 #endif //COVERAGE_MEASUREMENT |
|
203 /*! |
|
204 \fn void HsStateMachine::startDialer() |
|
205 Starts Dialer application |
|
206 */ |
|
207 void HsStateMachine::startDialer() |
|
208 { |
|
209 // copy-paste code from dialer widget |
|
210 #ifdef Q_OS_SYMBIAN |
|
211 qDebug("HsStateMachine::startDialer()"); |
|
212 |
|
213 QList<CallInfo> calls; |
|
214 QScopedPointer<XQCallInfo> callInfo(XQCallInfo::create()); |
|
215 callInfo->getCalls(calls); |
|
216 QList<QVariant> args; |
|
217 QString service; |
|
218 QString interface; |
|
219 QString operation; |
|
220 |
|
221 if (0 < calls.count()) { |
|
222 qDebug("HS: call ongoing, bring Telephone to foreground"); |
|
223 service = "phoneui"; |
|
224 interface = "com.nokia.symbian.IStart"; |
|
225 operation = "start(int)"; |
|
226 int openDialer(0); |
|
227 args << openDialer; |
|
228 } else { |
|
229 qDebug("HS: no calls, open Dialer"); |
|
230 service = "logs"; |
|
231 interface = "com.nokia.symbian.ILogsView"; |
|
232 operation = "show(QVariantMap)"; |
|
233 QVariantMap map; |
|
234 map.insert("view_index", QVariant(int(LogsServices::ViewAll))); |
|
235 map.insert("show_dialpad", QVariant(true)); |
|
236 map.insert("dialpad_text", QVariant(QString())); |
|
237 args.append(QVariant(map)); |
|
238 } |
|
239 |
|
240 XQApplicationManager appManager; |
|
241 QScopedPointer<XQAiwRequest> request(appManager.create(service, interface, operation, false)); |
|
242 if (request == NULL) { |
|
243 return; |
|
244 } |
|
245 request->setArguments(args); |
|
246 XQRequestInfo info; |
|
247 info.setForeground(true); |
|
248 request->setInfo(info); |
|
249 bool ret = request->send(); |
|
250 qDebug("HS: request sent successfully:", ret); |
|
251 #endif |
|
252 } |
|
253 |
|
254 #ifdef COVERAGE_MEASUREMENT |
|
255 #pragma CTC ENDSKIP |
|
256 #endif //COVERAGE_MEASUREMENT |
|
257 |
179 |
258 /*! |
180 /*! |
259 Registers framework animations. |
181 Registers framework animations. |
260 */ |
182 */ |
261 void HsStateMachine::registerAnimations() |
183 void HsStateMachine::registerAnimations() |
418 HsMenuEventTransition *idleToCollectionTransition = |
340 HsMenuEventTransition *idleToCollectionTransition = |
419 new HsMenuEventTransition(HsMenuEvent::OpenCollection, |
341 new HsMenuEventTransition(HsMenuEvent::OpenCollection, |
420 idleState, collectionStates[0]); |
342 idleState, collectionStates[0]); |
421 idleState->addTransition(idleToCollectionTransition); |
343 idleState->addTransition(idleToCollectionTransition); |
422 } |
344 } |
|
345 // show after install is opened from applibrary via idlestate |
|
346 if (collectionStates.count()) { |
|
347 HsMenuEventTransition *idleToCollectionTransition = |
|
348 new HsMenuEventTransition(HsMenuEvent::OpenCollectionFromAppLibrary, |
|
349 idleState, collectionStates[0]); |
|
350 idleState->addTransition(idleToCollectionTransition); |
|
351 } |
423 |
352 |
424 guiRootState->setInitialState(loadSceneState); |
353 guiRootState->setInitialState(loadSceneState); |
425 setInitialState(guiRootState); |
354 setInitialState(guiRootState); |
426 |
355 |
427 HSTEST_FUNC_EXIT("HS::HsStateMachine::createStates"); |
356 HSTEST_FUNC_EXIT("HS::HsStateMachine::createStates"); |
497 Activity requested by another client |
425 Activity requested by another client |
498 */ |
426 */ |
499 void HsStateMachine::activityRequested(const QString &name) |
427 void HsStateMachine::activityRequested(const QString &name) |
500 { |
428 { |
501 if (name == Hs::groupAppLibRecentView) { |
429 if (name == Hs::groupAppLibRecentView) { |
502 this->postEvent( |
430 if (mHomeScreenActive) { |
503 HsMenuEventFactory::createOpenCollectionEvent(0, |
431 this->postEvent( |
504 Hs::collectionDownloadedTypeName)); |
432 HsMenuEventFactory::createOpenCollectionEvent(0, |
|
433 Hs::collectionDownloadedTypeName)); |
|
434 } |
|
435 else { |
|
436 this->postEvent( |
|
437 HsMenuEventFactory::createOpenCollectionFromAppLibraryEvent(0, |
|
438 Hs::collectionDownloadedTypeName)); |
|
439 } |
505 } else if (name == Hs::activityHsIdleView) { |
440 } else if (name == Hs::activityHsIdleView) { |
506 emit event_toIdle(); |
441 emit event_toIdle(); |
507 } else if (name == Hs::activityAppLibMainView) { |
442 } else if (name == Hs::activityAppLibMainView) { |
508 emit event_toAppLib(); |
443 emit event_toAppLib(); |
509 } |
444 } |