160 Q_UNUSED(watched); |
155 Q_UNUSED(watched); |
161 |
156 |
162 switch (event->type()) { |
157 switch (event->type()) { |
163 case QEvent::ApplicationActivate: |
158 case QEvent::ApplicationActivate: |
164 qDebug() << "HsStateMachine::eventFilter: QEvent::ApplicationActivate"; |
159 qDebug() << "HsStateMachine::eventFilter: QEvent::ApplicationActivate"; |
165 #ifdef Q_OS_SYMBIAN |
|
166 keyCapture.captureKey(applicationKey); |
|
167 #endif |
|
168 mHomeScreenActive = true; |
160 mHomeScreenActive = true; |
169 updatePSKeys(); |
161 updatePSKeys(); |
170 break; |
162 break; |
171 case QEvent::ApplicationDeactivate: |
163 case QEvent::ApplicationDeactivate: |
172 qDebug() << "HsStateMachine::eventFilter: QEvent::ApplicationDeactivate"; |
164 qDebug() << "HsStateMachine::eventFilter: QEvent::ApplicationDeactivate"; |
173 #ifdef Q_OS_SYMBIAN |
|
174 keyCapture.cancelCaptureKey(applicationKey); |
|
175 #endif |
|
176 mHomeScreenActive = false; |
165 mHomeScreenActive = false; |
177 updatePSKeys(); |
166 updatePSKeys(); |
178 break; |
167 break; |
179 default: |
168 default: |
180 break; |
169 break; |
181 } |
170 } |
182 |
171 |
183 bool result = QStateMachine::eventFilter(watched, event); |
172 bool result = QStateMachine::eventFilter(watched, event); |
184 // temporary hack as we should not register twice for events |
|
185 if (event->type() == QEvent::KeyPress ) { |
173 if (event->type() == QEvent::KeyPress ) { |
186 QKeyEvent* ke = static_cast<QKeyEvent *>(event); |
174 QKeyEvent* ke = static_cast<QKeyEvent *>(event); |
187 // Key_Launch0 should be removed when QT starts to send Key_Menu |
175 result = (ke->key() == Qt::Key_Home); |
188 result = (ke->key() == applicationKey) || ke->key() == Qt::Key_Launch0; |
|
189 } |
176 } |
190 return result; |
177 return result; |
191 } |
178 } |
192 |
179 |
193 |
180 |
312 HsMenuEvent::OpenHomeScreen, appLibraryState, idleState); |
299 HsMenuEvent::OpenHomeScreen, appLibraryState, idleState); |
313 appLibraryState->addTransition(appLibToIdleTransition); |
300 appLibraryState->addTransition(appLibToIdleTransition); |
314 |
301 |
315 HbMainWindow *window = hbInstance->allMainWindows().first(); |
302 HbMainWindow *window = hbInstance->allMainWindows().first(); |
316 |
303 |
|
304 #ifndef Q_OS_SYMBIAN |
317 // key driven transition from idle to menu |
305 // key driven transition from idle to menu |
318 QKeyEventTransition *idleToMenuRootTransition = |
306 QKeyEventTransition *idleToMenuRootTransition = |
319 new QKeyEventTransition( |
307 new QKeyEventTransition( |
320 window, QEvent::KeyPress, applicationKey); |
308 window, QEvent::KeyPress, Qt::Key_Home); |
321 idleToMenuRootTransition->setTargetState(menuRootState); |
309 idleToMenuRootTransition->setTargetState(menuRootState); |
322 idleState->addTransition(idleToMenuRootTransition); |
310 idleState->addTransition(idleToMenuRootTransition); |
323 // key driven transition from menu to idle |
311 // key driven transition from menu to idle |
324 QKeyEventTransition *menuToIdleTransition = |
312 QKeyEventTransition *menuToIdleTransition = |
325 new QKeyEventTransition( |
313 new QKeyEventTransition( |
326 window, QEvent::KeyPress, applicationKey); |
314 window, QEvent::KeyPress, Qt::Key_Home); |
327 menuToIdleTransition->setTargetState(idleState); |
315 menuToIdleTransition->setTargetState(idleState); |
328 menuRootState->addTransition(menuToIdleTransition); |
316 menuRootState->addTransition(menuToIdleTransition); |
329 |
317 #endif |
330 // transition for Key_Launch0 should be removed |
318 // key driven transition from menu to idle |
331 // when OT starts to send Key_Menu (maybe wk14) |
319 QKeyEventTransition *menuToIdleTransitionNoKey = |
332 QKeyEventTransition *idleToMenuRootTransition2 = |
|
333 new QKeyEventTransition( |
320 new QKeyEventTransition( |
334 window, QEvent::KeyPress, Qt::Key_Launch0); |
321 window, QEvent::KeyPress, Qt::Key_No); |
335 idleToMenuRootTransition2->setTargetState(menuRootState); |
322 menuToIdleTransitionNoKey->setTargetState(idleState); |
336 idleState->addTransition(idleToMenuRootTransition2); |
323 menuRootState->addTransition(menuToIdleTransitionNoKey); |
337 // key driven transition from menu to idle |
324 |
338 QKeyEventTransition *menuToIdleTransition2 = |
|
339 new QKeyEventTransition( |
|
340 window, QEvent::KeyPress, Qt::Key_Launch0); |
|
341 menuToIdleTransition2->setTargetState(idleState); |
|
342 menuRootState->addTransition(menuToIdleTransition2); |
|
343 // add transition to switch to idle |
325 // add transition to switch to idle |
344 menuRootState->addTransition( this, SIGNAL(event_toIdle()), idleState); |
326 menuRootState->addTransition( this, SIGNAL(event_toIdle()), idleState); |
|
327 // add transition to switch to applib |
|
328 idleState->addTransition( this, SIGNAL(event_toAppLib()), menuRootState); |
345 |
329 |
346 // transitions to child states |
330 // transitions to child states |
347 // opening shortcut to a colleciton |
331 // opening shortcut to a colleciton |
348 QList<QState *> collectionStates = |
332 QList<QState *> collectionStates = |
349 appLibraryState-> |
333 appLibraryState-> |
381 } |
365 } |
382 else{ |
366 else{ |
383 qDebug() << "HsStateMachine::updatePSKeys: EHomeScreenInactive"; |
367 qDebug() << "HsStateMachine::updatePSKeys: EHomeScreenInactive"; |
384 mPublisher->setValue(HsStatePSKeySubPath, EHomeScreenInactive); |
368 mPublisher->setValue(HsStatePSKeySubPath, EHomeScreenInactive); |
385 } |
369 } |
|
370 |
|
371 if (mHomeScreenActive && !mIdleStateActive) { |
|
372 captureEndKey(true); |
|
373 } else { |
|
374 captureEndKey(false); |
|
375 } |
|
376 } |
|
377 |
|
378 /*! |
|
379 capture End key |
|
380 */ |
|
381 void HsStateMachine::captureEndKey(bool enable) |
|
382 { |
|
383 #ifdef Q_OS_SYMBIAN |
|
384 if (enable && !mEndKeyCaptured) { |
|
385 mEndKeyCaptured = true; |
|
386 keyCapture.captureKey(Qt::Key_No); |
|
387 } else if (mEndKeyCaptured) { |
|
388 mEndKeyCaptured = false; |
|
389 keyCapture.cancelCaptureKey(Qt::Key_No); |
|
390 } |
|
391 #endif |
386 } |
392 } |
387 |
393 |
388 /*! |
394 /*! |
389 Called when state machine is in Idle state. |
395 Called when state machine is in Idle state. |
390 */ |
396 */ |