40 #include "hscontentservice.h" |
40 #include "hscontentservice.h" |
41 #include "hsshortcutservice.h" |
41 #include "hsshortcutservice.h" |
42 #include "hsmenueventtransition.h" |
42 #include "hsmenueventtransition.h" |
43 #include "hswidgetpositioningonorientationchange.h" |
43 #include "hswidgetpositioningonorientationchange.h" |
44 #include "hswidgetpositioningonwidgetadd.h" |
44 #include "hswidgetpositioningonwidgetadd.h" |
|
45 #include "hsconfiguration.h" |
45 #include "hstest_global.h" |
46 #include "hstest_global.h" |
46 #include "hsconfiguration.h" |
47 #include "hswidgetpositioningonwidgetmove.h" |
47 |
48 |
48 QTM_USE_NAMESPACE |
49 QTM_USE_NAMESPACE |
49 #define hbApp qobject_cast<HbApplication*>(qApp) |
50 #define hbApp qobject_cast<HbApplication*>(qApp) |
50 |
51 |
51 #ifdef Q_OS_SYMBIAN |
52 #ifdef Q_OS_SYMBIAN |
80 Constructs runtime with \a parent as the parent object. |
81 Constructs runtime with \a parent as the parent object. |
81 */ |
82 */ |
82 HsDefaultRuntime::HsDefaultRuntime(QObject *parent) |
83 HsDefaultRuntime::HsDefaultRuntime(QObject *parent) |
83 : QStateMachine(parent), |
84 : QStateMachine(parent), |
84 mContentService(0), |
85 mContentService(0), |
85 mHomeScreenActive(false), |
86 mHomeScreenActive(false), |
86 mIdleStateActive(false), |
87 mIdleStateActive(false), |
87 mPublisher(NULL) |
88 mPublisher(NULL) |
88 #ifdef Q_OS_SYMBIAN |
89 #ifdef Q_OS_SYMBIAN |
89 ,keyCapture() |
90 ,keyCapture() |
90 #endif |
91 #endif |
91 { |
92 { |
92 HSTEST_FUNC_ENTRY("HS::HsDefaultRuntime::HsDefaultRuntime"); |
93 HSTEST_FUNC_ENTRY("HS::HsDefaultRuntime::HsDefaultRuntime"); |
99 db->setDatabaseName("private/20022f35/homescreen.db"); |
100 db->setDatabaseName("private/20022f35/homescreen.db"); |
100 #endif |
101 #endif |
101 db->open(); |
102 db->open(); |
102 HsDatabase::setInstance(db); |
103 HsDatabase::setInstance(db); |
103 |
104 |
104 HsConfiguration::loadConfiguration(); |
105 HsConfiguration::setInstance(new HsConfiguration); |
105 |
106 HsConfiguration::instance()->load(); |
|
107 |
106 HsWidgetPositioningOnOrientationChange::setInstance( |
108 HsWidgetPositioningOnOrientationChange::setInstance( |
107 new HsAdvancedWidgetPositioningOnOrientationChange); |
109 new HsAdvancedWidgetPositioningOnOrientationChange); |
108 |
110 |
109 HsWidgetPositioningOnWidgetAdd::setInstance( |
111 HsWidgetPositioningOnWidgetAdd::setInstance( |
110 new HsAnchorPointInBottomRight); |
112 new HsAnchorPointInBottomRight); |
|
113 |
|
114 HsWidgetPositioningOnWidgetMove::setInstance( |
|
115 new HsSnapToLines); |
|
116 |
|
117 registerAnimations(); |
111 |
118 |
112 createStatePublisher(); |
119 createStatePublisher(); |
113 createContentServiceParts(); |
120 createContentServiceParts(); |
114 createStates(); |
121 createStates(); |
115 assignServices(); |
122 assignServices(); |
116 |
123 |
117 QCoreApplication::instance()->installEventFilter(this); |
124 // create the instance so that singleton is accessible from elsewhere |
|
125 HsShortcutService::instance(this); |
|
126 |
|
127 QCoreApplication::instance()->installEventFilter(this); |
118 |
128 |
119 if (hbApp) { // Qt test framework uses QApplication. |
129 if (hbApp) { // Qt test framework uses QApplication. |
120 connect(hbApp->activityManager(), SIGNAL(activityRequested(QString)), |
130 connect(hbApp->activityManager(), SIGNAL(activityRequested(QString)), |
121 this, SLOT(activityRequested(QString))); |
131 this, SLOT(activityRequested(QString))); |
122 } |
132 } |
123 HSTEST_FUNC_EXIT("HS::HsDefaultRuntime::HsDefaultRuntime"); |
133 HSTEST_FUNC_EXIT("HS::HsDefaultRuntime::HsDefaultRuntime"); |
124 } |
134 } |
125 |
135 |
126 /*! |
136 /*! |
127 Destructor. |
137 Destructor. |
128 */ |
138 */ |
129 HsDefaultRuntime::~HsDefaultRuntime() |
139 HsDefaultRuntime::~HsDefaultRuntime() |
130 { |
140 { |
131 HsWidgetPositioningOnOrientationChange::setInstance(0); |
141 HsWidgetPositioningOnOrientationChange::setInstance(0); |
132 delete mPublisher; |
142 delete mPublisher; |
133 } |
143 } |
134 |
144 |
135 /*! |
145 /*! |
136 \fn void HsDefaultRuntime::stopStateMachine() |
146 \fn void HsDefaultRuntime::stopStateMachine() |
137 Emission of this signal initiates a transition to the final state. |
147 Emission of this signal initiates a transition to the final state. |
143 bool HsDefaultRuntime::eventFilter(QObject *watched, QEvent *event) |
153 bool HsDefaultRuntime::eventFilter(QObject *watched, QEvent *event) |
144 { |
154 { |
145 Q_UNUSED(watched); |
155 Q_UNUSED(watched); |
146 |
156 |
147 switch (event->type()) { |
157 switch (event->type()) { |
148 case QEvent::ApplicationActivate: |
158 case QEvent::ApplicationActivate: |
149 qDebug() << "HsDefaultRuntime::eventFilter: QEvent::ApplicationActivate"; |
159 qDebug() << "HsDefaultRuntime::eventFilter: QEvent::ApplicationActivate"; |
150 #ifdef Q_OS_SYMBIAN |
160 #ifdef Q_OS_SYMBIAN |
151 keyCapture.captureKey(applicationKey); |
161 keyCapture.captureKey(applicationKey); |
152 #endif |
162 #endif |
153 mHomeScreenActive = true; |
163 mHomeScreenActive = true; |
154 updatePSKeys(); |
164 updatePSKeys(); |
155 break; |
165 break; |
156 case QEvent::ApplicationDeactivate: |
166 case QEvent::ApplicationDeactivate: |
157 qDebug() << "HsDefaultRuntime::eventFilter: QEvent::ApplicationDeactivate"; |
167 qDebug() << "HsDefaultRuntime::eventFilter: QEvent::ApplicationDeactivate"; |
158 #ifdef Q_OS_SYMBIAN |
168 #ifdef Q_OS_SYMBIAN |
159 keyCapture.cancelCaptureKey(applicationKey); |
169 keyCapture.cancelCaptureKey(applicationKey); |
160 #endif |
170 #endif |
161 mHomeScreenActive = false; |
171 mHomeScreenActive = false; |
162 updatePSKeys(); |
172 updatePSKeys(); |
163 break; |
173 break; |
164 default: |
174 default: |
165 break; |
175 break; |
166 } |
176 } |
167 |
177 |
168 bool result = QStateMachine::eventFilter(watched, event); |
178 bool result = QStateMachine::eventFilter(watched, event); |
169 // temporary hack as we should not register twice for events |
179 // temporary hack as we should not register twice for events |
170 if (event->type() == QEvent::KeyPress ) { |
180 if (event->type() == QEvent::KeyPress ) { |
171 QKeyEvent* ke = static_cast<QKeyEvent *>(event); |
181 QKeyEvent* ke = static_cast<QKeyEvent *>(event); |
172 // Key_Launch0 should be removed when QT starts to send Key_Menu |
182 // Key_Launch0 should be removed when QT starts to send Key_Menu |
173 result = (ke->key() == applicationKey) || ke->key() == Qt::Key_Launch0; |
183 result = (ke->key() == applicationKey) || ke->key() == Qt::Key_Launch0; |
174 } |
184 } |
175 return result; |
185 return result; |
|
186 } |
|
187 |
|
188 |
|
189 /*! |
|
190 Registers framework animations. |
|
191 */ |
|
192 void HsDefaultRuntime::registerAnimations() |
|
193 { |
|
194 HbIconAnimationManager *manager = HbIconAnimationManager::global(); |
|
195 manager->addDefinitionFile(QLatin1String("qtg_anim_loading.axml")); |
176 } |
196 } |
177 |
197 |
178 /*! |
198 /*! |
179 Creates Home screen state publisher. |
199 Creates Home screen state publisher. |
180 */ |
200 */ |
257 |
277 |
258 QObject *menuWorkerStateObj = manager.loadInterface(KHsMenuWorkerStateInterface); |
278 QObject *menuWorkerStateObj = manager.loadInterface(KHsMenuWorkerStateInterface); |
259 QState *menuWorkerState = qobject_cast<QState *>(menuWorkerStateObj); |
279 QState *menuWorkerState = qobject_cast<QState *>(menuWorkerStateObj); |
260 menuWorkerState->setParent(menuParallelState); |
280 menuWorkerState->setParent(menuParallelState); |
261 menuWorkerState->setObjectName(KHsMenuWorkerStateInterface); |
281 menuWorkerState->setObjectName(KHsMenuWorkerStateInterface); |
|
282 |
262 connect(appLibraryState, SIGNAL(collectionEntered()), |
283 connect(appLibraryState, SIGNAL(collectionEntered()), |
263 menuWorkerState, SIGNAL(reset())); |
284 menuWorkerState, SIGNAL(reset())); |
|
285 connect(appLibraryState, SIGNAL(allAppsStateEntered ()), |
|
286 menuWorkerState, SIGNAL(reset())); |
|
287 connect(appLibraryState, SIGNAL(allCollectionsStateEntered ()), |
|
288 menuWorkerState, SIGNAL(reset())); |
|
289 |
264 //Backup/Restore state |
290 //Backup/Restore state |
265 QObject *backupRestoreStateObj = manager.loadInterface(KHsBacupRestoreStateInterface); |
291 QObject *backupRestoreStateObj = manager.loadInterface(KHsBacupRestoreStateInterface); |
266 QState *backupRestoreState = qobject_cast<QState *>(backupRestoreStateObj); |
292 QState *backupRestoreState = qobject_cast<QState *>(backupRestoreStateObj); |
267 backupRestoreState->setParent(guiRootState); |
293 backupRestoreState->setParent(guiRootState); |
268 backupRestoreState->setObjectName(KHsBacupRestoreStateInterface); |
294 backupRestoreState->setObjectName(KHsBacupRestoreStateInterface); |
311 QKeyEventTransition *menuToIdleTransition2 = |
337 QKeyEventTransition *menuToIdleTransition2 = |
312 new QKeyEventTransition( |
338 new QKeyEventTransition( |
313 window, QEvent::KeyPress, Qt::Key_Launch0); |
339 window, QEvent::KeyPress, Qt::Key_Launch0); |
314 menuToIdleTransition2->setTargetState(idleState); |
340 menuToIdleTransition2->setTargetState(idleState); |
315 menuRootState->addTransition(menuToIdleTransition2); |
341 menuRootState->addTransition(menuToIdleTransition2); |
316 |
342 // add transition to switch to idle |
|
343 menuRootState->addTransition( this, SIGNAL(event_toIdle()), idleState); |
|
344 |
317 // transitions to child states |
345 // transitions to child states |
318 // opening shortcut to a colleciton |
346 // opening shortcut to a colleciton |
319 QList<QState *> collectionStates = |
347 QList<QState *> collectionStates = |
320 appLibraryState-> |
348 appLibraryState-> |
321 findChildren<QState *> |
349 findChildren<QState *> |
403 /*! |
431 /*! |
404 Activity requested by another client |
432 Activity requested by another client |
405 */ |
433 */ |
406 void HsDefaultRuntime::activityRequested(const QString &name) |
434 void HsDefaultRuntime::activityRequested(const QString &name) |
407 { |
435 { |
408 if (name == groupAppLibRecentView()){ |
436 if (name == appLibActivity()) { |
409 this->postEvent(HsMenuEventFactory::createOpenCollectionEvent(0, |
437 this->postEvent( |
410 collectionDownloadedTypeName())); |
438 HsMenuEventFactory::createOpenAppLibraryEvent(NormalHsMenuMode)); |
411 } |
439 } |
412 } |
440 else if (name == groupAppLibRecentView()) { |
|
441 this->postEvent( |
|
442 HsMenuEventFactory::createOpenCollectionEvent(0, |
|
443 collectionDownloadedTypeName())); |
|
444 } else if (name == activityHsIdleView()) { |
|
445 emit event_toIdle(); |
|
446 } |
|
447 } |