212 updateEditor(); |
213 updateEditor(); |
213 mCanContinuePrediction = true; |
214 mCanContinuePrediction = true; |
214 } |
215 } |
215 } |
216 } |
216 |
217 |
217 void HbInputPrediction12KeyHandlerPrivate::_q_timeout() |
218 bool HbInputPrediction12KeyHandlerPrivate::buttonPressed(const QKeyEvent *keyEvent) |
218 { |
219 { |
219 qDebug("HbInputPrediction12KeyHandlerPrivate::_q_timeout()"); |
|
220 Q_Q(HbInputPrediction12KeyHandler); |
220 Q_Q(HbInputPrediction12KeyHandler); |
221 |
221 mLongPressHappened = false; |
222 // let's stop the timer first. |
222 HbInputFocusObject *focusObject = 0; |
223 mTimer->stop(); |
223 focusObject = mInputMethod->focusObject(); |
224 |
224 if (!focusObject) { |
225 //Long key press number key is applicable to all keys |
225 return false; |
226 if (mButtonDown) { |
226 } |
227 if (mLastKey == Qt::Key_Asterisk) { |
227 |
228 //Remove the "?" mark if present |
228 int buttonId = keyEvent->key(); |
229 chopQMarkAndUpdateEditor(); |
229 |
230 mInputMethod->switchMode(mLastKey); |
230 if (keyEvent->isAutoRepeat() && mLastKey == buttonId) { |
231 } else if (mLastKey == Qt::Key_Shift) { |
231 if (buttonId == HbInputButton::ButtonKeyCodeAsterisk) { |
232 mInputMethod->switchMode(Qt::Key_Shift); |
232 if (!mCanContinuePrediction) { |
|
233 mInputMethod->switchMode(buttonId); |
|
234 } else { |
|
235 //Remove the "?" mark if present |
|
236 chopQMarkAndUpdateEditor(); |
|
237 mInputMethod->selectSpecialCharacterTableMode(); |
|
238 } |
233 mLongPressHappened = true; |
239 mLongPressHappened = true; |
234 } else if (mLastKey == Qt::Key_Control) { |
240 } else if (buttonId == HbInputButton::ButtonKeyCodeShift) { |
|
241 mInputMethod->switchMode(HbInputButton::ButtonKeyCodeShift); |
|
242 mLongPressHappened = true; |
|
243 } else if (buttonId == HbInputButton::ButtonKeyCodeSymbol) { |
235 //Remove the "?" mark if present |
244 //Remove the "?" mark if present |
236 chopQMarkAndUpdateEditor(); |
245 chopQMarkAndUpdateEditor(); |
237 mInputMethod->selectSpecialCharacterTableMode(); |
246 mInputMethod->selectSpecialCharacterTableMode(); |
|
247 mLongPressHappened = true; |
238 } else { |
248 } else { |
239 //With a long key press of a key, numbers are supposed to be entered. |
249 //With a long key press of a key, numbers are supposed to be entered. |
240 //When the existing input (along with the short key press input of the |
250 //When the existing input (along with the short key press input of the |
241 //existing key) results in tail (i.e. autocompletion), we need to accept |
251 //existing key) results in tail (i.e. autocompletion), we need to accept |
242 //the short key press as well as the tail. In case of ? delete the questionmark and add the number value. |
252 //the short key press as well as the tail. In case of ? delete the questionmark and add the number value. |
243 //mTailShowing = false; |
253 //mTailShowing = false; |
244 // Delete "?" entered |
254 // Delete "?" entered |
245 if (!mCanContinuePrediction) { |
255 if (!mCanContinuePrediction) { |
246 deleteOneCharacter(); |
256 deleteOneCharacter(); |
247 } |
257 mLongPressHappened = true; |
248 if (mLastKey != Qt::Key_Delete) { |
258 } |
249 q->commitFirstMappedNumber(mLastKey); |
259 if (buttonId != HbInputButton::ButtonKeyCodeDelete) { |
|
260 q->commitFirstMappedNumber(buttonId, mInputMethod->currentKeyboardType()); |
|
261 mLongPressHappened = true; |
250 } |
262 } |
251 mLongPressHappened = true; |
263 } |
252 } |
264 |
253 } |
265 if (mLongPressHappened) { |
254 } |
266 mLastKey = 0; |
255 |
267 return true; |
256 bool HbInputPrediction12KeyHandlerPrivate::buttonPressed(const QKeyEvent *keyEvent) |
268 } |
257 { |
269 } |
258 mLongPressHappened = false; |
270 |
259 HbInputFocusObject *focusObject = 0; |
271 if (buttonId == HbInputButton::ButtonKeyCodeShift) { |
260 focusObject = mInputMethod->focusObject(); |
272 // if we get a second consequtive shift key press, |
261 if (!focusObject) { |
273 // we want to handle it in buttonRelease |
262 return false; |
|
263 } |
|
264 |
|
265 int buttonId = keyEvent->key(); |
|
266 |
|
267 |
|
268 if (buttonId == Qt::Key_Control) { |
|
269 mLastKey = buttonId; |
|
270 mButtonDown = true; |
|
271 mTimer->start(HbLongPressTimerTimeout); |
|
272 return true; |
|
273 } else if (buttonId == Qt::Key_Shift) { |
|
274 // if we get a second consequtive shift key press, |
|
275 // we want to handle it in buttonRelease |
|
276 if (mTimer->isActive() && (mLastKey == buttonId)){ |
274 if (mTimer->isActive() && (mLastKey == buttonId)){ |
277 mShiftKeyDoubleTap = true; |
275 mShiftKeyDoubleTap = true; |
278 } |
276 } |
279 if (!mTimer->isActive()) { |
|
280 mTimer->start(HbLongPressTimerTimeout); |
|
281 } |
|
282 mLastKey = buttonId; |
|
283 mButtonDown = true; |
|
284 return true; |
|
285 } |
277 } |
286 |
278 |
287 mLastKey = buttonId; |
279 mLastKey = buttonId; |
288 mButtonDown = true; |
280 mButtonDown = true; |
289 |
281 |
290 // custom button should not start timer. |
|
291 if ((buttonId & CUSTOM_INPUT_MASK) != CUSTOM_INPUT_MASK) { |
|
292 mTimer->start(HbLongPressTimerTimeout); |
|
293 } |
|
294 return false; |
282 return false; |
295 } |
283 } |
296 |
284 |
297 /*! |
285 /*! |
298 Handles the key release events from the VKB. Launches the SCT with key release event of |
286 Handles the key release events from the VKB. Launches the SCT with key release event of |
307 } |
295 } |
308 |
296 |
309 // since button is released we can set buttonDown back to false. |
297 // since button is released we can set buttonDown back to false. |
310 mButtonDown = false; |
298 mButtonDown = false; |
311 int buttonId = keyEvent->key(); |
299 int buttonId = keyEvent->key(); |
312 // it was a long press on sct swith button. so just return form here. |
|
313 if (!mTimer->isActive() && buttonId == Qt::Key_Control) { |
|
314 return true; |
|
315 } |
|
316 |
300 |
317 // Sym key is handled in this class it self, so not passing it to |
301 // Sym key is handled in this class it self, so not passing it to |
318 // the base mode handlers. |
302 // the base mode handlers. |
319 if ( buttonId == Qt::Key_Control) { |
303 if (buttonId == HbInputButton::ButtonKeyCodeSymbol || |
|
304 buttonId == HbInputButton::ButtonKeyCodeAlphabet) { |
320 //Remove the "?" mark if present |
305 //Remove the "?" mark if present |
321 chopQMarkAndUpdateEditor(); |
306 chopQMarkAndUpdateEditor(); |
322 mInputMethod->switchMode(buttonId); |
307 mInputMethod->switchMode(buttonId); |
323 return true; |
308 return true; |
324 } |
309 } |
426 //any meaningful word for the input sequence. |
417 //any meaningful word for the input sequence. |
427 if(!d->mCanContinuePrediction) { |
418 if(!d->mCanContinuePrediction) { |
428 int eventKey = event->key(); |
419 int eventKey = event->key(); |
429 switch(eventKey) { |
420 switch(eventKey) { |
430 case Qt::Key_0: |
421 case Qt::Key_0: |
431 case Qt::Key_Space: { |
422 case HbInputButton::ButtonKeyCodeSpace: { |
432 if(d->mCandidates->size() && focusObject) { |
423 if(d->mCandidates->size() && focusObject) { |
433 //Remove the "?" mark |
424 //Remove the "?" mark |
434 (*d->mCandidates)[d->mBestGuessLocation].chop(1); |
425 (*d->mCandidates)[d->mBestGuessLocation].chop(1); |
435 d->updateEditor(); |
426 d->updateEditor(); |
436 d->mCanContinuePrediction = true; |
427 d->mCanContinuePrediction = true; |
437 } |
428 } |
438 } |
429 } |
439 break; |
430 break; |
440 case Qt::Key_Shift: { |
431 case HbInputButton::ButtonKeyCodeShift: { |
441 if(event->type() == QEvent::KeyRelease && d->mShiftKeyDoubleTap) { |
432 if(event->type() == QEvent::KeyRelease && d->mShiftKeyDoubleTap) { |
442 //Remove the "?" mark |
433 //Remove the "?" mark |
443 deleteOneCharacter(); |
434 deleteOneCharacter(); |
444 } |
435 } |
445 } |
436 } |
446 //For the following set of keys, it does not matter. |
437 //For the following set of keys, it does not matter. |
447 case Qt::Key_Backspace: |
438 case Qt::Key_Backspace: |
448 case Qt::Key_Delete: |
439 case HbInputButton::ButtonKeyCodeDelete: |
449 case Qt::Key_Return: |
440 case HbInputButton::ButtonKeyCodeEnter: |
450 case Qt::Key_Enter: |
441 case HbInputButton::ButtonKeyCodeAsterisk: |
451 case Qt::Key_Asterisk: |
442 case HbInputButton::ButtonKeyCodeControl: |
452 case Qt::Key_Control: |
|
453 break; |
443 break; |
454 /* Behavior for other keys i.e. from key1 to key9 - |
444 /* Behavior for other keys i.e. from key1 to key9 - |
455 To start the long press timer as we need to handle long press functionality i.e Enter corresponding number mapped to a key */ |
445 To start the long press timer as we need to handle long press functionality i.e Enter corresponding number mapped to a key */ |
456 case Qt::Key_1: |
446 case Qt::Key_1: |
457 case Qt::Key_2: |
447 case Qt::Key_2: |