183 ++mCharacterButtons; |
185 ++mCharacterButtons; |
184 } else if (keyCode(i) == HbInputButton::ButtonKeyCodeSpace) { |
186 } else if (keyCode(i) == HbInputButton::ButtonKeyCodeSpace) { |
185 item->setSize(QSize(2, 1)); |
187 item->setSize(QSize(2, 1)); |
186 ++key; |
188 ++key; |
187 } else if (keyCode(i) == HbInputButton::ButtonKeyCodeDelete && |
189 } else if (keyCode(i) == HbInputButton::ButtonKeyCodeDelete && |
188 mType == HbKeyboardSctPortrait) { |
190 (mType == HbKeyboardSctPortrait || mType == HbKeyboardSctEmail || mType == HbKeyboardSctUrl )) { |
189 // Portrait SCT has different delete icon from the default one |
191 // Portrait SCT has different delete icon from the default one |
190 item->setIcon(HbIcon(HbInputButtonIconDelete2), HbInputButton::ButtonIconIndexPrimary); |
192 item->setIcon(HbIcon(HbInputButtonIconDelete2), HbInputButton::ButtonIconIndexPrimary); |
191 } else if (keyCode(i) == HbInputButton::ButtonKeyCodeAlphabet) { |
193 } else if (keyCode(i) == HbInputButton::ButtonKeyCodeAlphabet) { |
192 // Button that is used to return to normal keypad should be shown as latched |
194 // Button that is used to return to normal keypad should be shown as latched |
193 item->setState(HbInputButton::ButtonStateLatched); |
195 item->setState(HbInputButton::ButtonStateLatched); |
194 if (mType == HbKeyboardSctPortrait) { |
196 if (mType == HbKeyboardSctPortrait || mType == HbKeyboardSctEmail || mType == HbKeyboardSctUrl ) { |
195 // Portrait SCT has different symbol icon from the default one |
197 // Portrait SCT has different symbol icon from the default one |
196 item->setIcon(HbIcon(HbInputButtonIconSymbol2), HbInputButton::ButtonIconIndexPrimary); |
198 item->setIcon(HbIcon(HbInputButtonIconSymbol2), HbInputButton::ButtonIconIndexPrimary); |
197 } |
199 } |
198 } |
200 } |
199 ++key; |
201 ++key; |
210 QObject::connect(q, SIGNAL(flickEvent(HbInputVkbWidget::HbFlickDirection)), buttonGroup, SLOT(cancelButtonPress())); |
212 QObject::connect(q, SIGNAL(flickEvent(HbInputVkbWidget::HbFlickDirection)), buttonGroup, SLOT(cancelButtonPress())); |
211 } |
213 } |
212 |
214 |
213 int HbSctKeyboardPrivate::keyCode(int buttonId) |
215 int HbSctKeyboardPrivate::keyCode(int buttonId) |
214 { |
216 { |
215 if (mType == HbKeyboardSctPortrait) { |
217 if (mType == HbKeyboardSctLandscape) { |
216 return HbPortraitButtonKeyCodeTable[buttonId]; |
218 return HbLandscapeButtonKeyCodeTable[buttonId]; |
217 } else { |
219 } else { |
218 return HbLandscapeButtonKeyCodeTable[buttonId]; |
220 return HbPortraitButtonKeyCodeTable[buttonId]; |
219 } |
221 } |
220 } |
222 } |
|
223 |
221 |
224 |
222 void HbSctKeyboardPrivate::applyEditorConstraints() |
225 void HbSctKeyboardPrivate::applyEditorConstraints() |
223 { |
226 { |
224 Q_Q(HbSctKeyboard); |
227 Q_Q(HbSctKeyboard); |
225 |
|
226 HbInputFocusObject *focusedObject = mOwner->focusObject(); |
228 HbInputFocusObject *focusedObject = mOwner->focusObject(); |
|
229 HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup *>(q->contentItem()); |
|
230 applyEditorConstraints(focusedObject, buttonGroup); |
|
231 } |
|
232 |
|
233 void HbSctKeyboardPrivate::applyEditorConstraints(HbInputFocusObject *focusedObject, HbInputButtonGroup *buttonGroup) |
|
234 { |
227 if (!focusedObject) { |
235 if (!focusedObject) { |
228 return; |
236 return; |
229 } |
237 } |
230 |
|
231 HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup *>(q->contentItem()); |
|
232 if (buttonGroup) { |
238 if (buttonGroup) { |
233 QList<HbInputButton *> buttons = buttonGroup->buttons(); |
239 QList<HbInputButton*> buttons = buttonGroup->buttons(); |
234 for (int i = 0; i < buttons.count(); ++i) { |
240 for (int i = 0; i < buttons.count(); ++i) { |
235 HbInputButton *item = buttons.at(i); |
241 HbInputButton *item = buttons.at(i); |
236 |
|
237 HbInputButton::HbInputButtonState state = item->state(); |
242 HbInputButton::HbInputButtonState state = item->state(); |
238 if (keyCode(i) == HbInputButton::ButtonKeyCodeCharacter) { |
243 if (keyCode(i) == HbInputButton::ButtonKeyCodeCharacter) { |
239 QString data = item->text(HbInputButton::ButtonTextIndexPrimary); |
244 QString data = item->text(HbInputButton::ButtonTextIndexPrimary); |
240 if (data.isEmpty() || !focusedObject->characterAllowedInEditor(data.at(0))) { |
245 if (data.isEmpty() || !focusedObject->characterAllowedInEditor(data.at(0))) { |
241 state = HbInputButton::ButtonStateDisabled; |
246 state = HbInputButton::ButtonStateDisabled; |
260 state = HbInputButton::ButtonStateReleased; |
265 state = HbInputButton::ButtonStateReleased; |
261 } |
266 } |
262 } |
267 } |
263 item->setState(state); |
268 item->setState(state); |
264 } |
269 } |
|
270 |
265 buttonGroup->setButtons(buttons); |
271 buttonGroup->setButtons(buttons); |
266 } |
272 } |
267 } |
273 } |
268 |
274 |
269 void HbSctKeyboardPrivate::updateKeyCodes() |
275 void HbSctKeyboardPrivate::updateKeyCodes() |
270 { |
276 { |
271 Q_Q(HbSctKeyboard); |
277 Q_Q(HbSctKeyboard); |
272 |
278 HbInputFocusObject *focusedObject = mOwner->focusObject(); |
|
279 if (!focusedObject) { |
|
280 return; |
|
281 } |
|
282 |
|
283 if (HbInputSettingProxy::instance()->activeKeyboard() & HbQwertyKeyboardMask){ |
|
284 mType = HbKeyboardSctLandscape; |
|
285 } else if (focusedObject && focusedObject->editorInterface().editorClass() == HbInputEditorClassEmail) { |
|
286 mType = HbKeyboardSctEmail; |
|
287 } else if (focusedObject && focusedObject->editorInterface().editorClass() == HbInputEditorClassUrl) { |
|
288 mType = HbKeyboardSctUrl; |
|
289 } else { |
|
290 mType = HbKeyboardSctPortrait; |
|
291 } |
|
292 |
273 mPages = 0; |
293 mPages = 0; |
274 const HbKeyboardMap *keyboardMap = mKeymap->keyboard(q->keyboardType()); |
294 const HbKeyboardMap *keyboardMap = mKeymap->keyboard(q->keyboardType()); |
275 if (keyboardMap) { |
295 if (keyboardMap) { |
276 mPages = (int)ceil((float)(keyboardMap->keys.count() / mCharacterButtons)); |
296 mPages = (int)ceil((float)countActiveKeys() / mCharacterButtons); |
277 } |
297 } |
278 |
298 |
279 if (mPages > 1) { |
299 mFlickAnimation = mPages > 1; |
280 mFlickAnimation = true; |
300 |
281 } |
|
282 |
|
283 HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup *>(q->contentItem()); |
301 HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup *>(q->contentItem()); |
284 if (buttonGroup) { |
302 if (buttonGroup) { |
285 int key = mActivePage * mCharacterButtons; |
303 int key = keyAtIndex(mActivePage * mCharacterButtons); |
286 QList<HbInputButton *> buttons = buttonGroup->buttons(); |
304 QList<HbInputButton *> buttons = buttonGroup->buttons(); |
287 for (int i = 0; i < buttons.count(); ++i) { |
305 for (int i = 0; i < buttons.count(); ++i) { |
288 if (keyCode(i) == HbInputButton::ButtonKeyCodeCharacter) { |
306 if (keyCode(i) == HbInputButton::ButtonKeyCodeCharacter) { |
289 HbInputButton *item = buttons.at(i); |
307 HbInputButton *item = buttons.at(i); |
290 |
308 |
291 if (keyboardMap && key < keyboardMap->keys.count()) { |
309 if (keyboardMap && key < keyboardMap->keys.count()) { |
292 // Replace space and enter markers with correct keycodes |
310 // Replace space and enter markers with correct keycodes |
293 if (keyboardMap->keys.at(key)->keycode.unicode() == HbSctSpaceMarker) { |
311 if (focusedObject->characterAllowedInEditor(keyboardMap->keys.at(key)->characters(HbModifierNone).at(0)) || mType == HbKeyboardSctLandscape){ |
294 item->setKeyCode(HbInputButton::ButtonKeyCodeSpace); |
312 if (keyboardMap->keys.at(key)->keycode.unicode() == HbSctSpaceMarker) { |
295 } else if (keyboardMap->keys.at(key)->keycode.unicode() == HbSctEnterMarker) { |
313 item->setKeyCode(HbInputButton::ButtonKeyCodeSpace); |
296 item->setKeyCode(HbInputButton::ButtonKeyCodeEnter); |
314 } else if (keyboardMap->keys.at(key)->keycode.unicode() == HbSctEnterMarker) { |
|
315 item->setKeyCode(HbInputButton::ButtonKeyCodeEnter); |
|
316 } else { |
|
317 item->setKeyCode(keyboardMap->keys.at(key)->keycode.unicode()); |
|
318 } |
297 } else { |
319 } else { |
298 item->setKeyCode(keyboardMap->keys.at(key)->keycode.unicode()); |
320 i--; |
299 } |
321 } |
300 } else { |
322 } else { |
301 item->setKeyCode(-1); |
323 item->setKeyCode(-1); |
302 } |
324 } |
303 ++key; |
325 ++key; |
304 } |
326 } |
305 } |
327 } |
306 } |
328 } |
|
329 applyEditorConstraints(); |
307 } |
330 } |
308 |
331 |
309 void HbSctKeyboardPrivate::updateButtons() |
332 void HbSctKeyboardPrivate::updateButtons() |
310 { |
333 { |
311 Q_Q(HbSctKeyboard); |
334 Q_Q(HbSctKeyboard); |
|
335 |
|
336 HbInputFocusObject *focusedObject = mOwner->focusObject(); |
|
337 if (!focusedObject) { |
|
338 return; |
|
339 } |
312 |
340 |
313 HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup *>(q->contentItem()); |
341 HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup *>(q->contentItem()); |
314 if (buttonGroup) { |
342 if (buttonGroup) { |
315 int key = mActivePage * mCharacterButtons; |
343 int key = keyAtIndex(mActivePage * mCharacterButtons); |
316 QList<HbInputButton *> buttons = buttonGroup->buttons(); |
344 QList<HbInputButton *> buttons = buttonGroup->buttons(); |
317 for (int i = 0; i < buttons.count(); ++i) { |
345 for (int i = 0; i < buttons.count(); ++i) { |
318 if (keyCode(i) == HbInputButton::ButtonKeyCodeCharacter) { |
346 if (keyCode(i) == HbInputButton::ButtonKeyCodeCharacter) { |
319 HbInputButton *item = buttons.at(i); |
347 HbInputButton *item = buttons.at(i); |
320 |
|
321 const HbKeyboardMap *keyboardMap = mKeymap->keyboard(q->keyboardType()); |
348 const HbKeyboardMap *keyboardMap = mKeymap->keyboard(q->keyboardType()); |
322 if (keyboardMap && key < keyboardMap->keys.count() && keyboardMap->keys.at(key)->characters(HbModifierNone) != QString("")) { |
349 if (keyboardMap && key < keyboardMap->keys.count() && keyboardMap->keys.at(key)->characters(HbModifierNone) != QString("")) { |
323 QString keydata = keyboardMap->keys.at(key)->characters(HbModifierNone); |
350 if (focusedObject->characterAllowedInEditor(keyboardMap->keys.at(key)->characters(HbModifierNone).at(0)) || mType == HbKeyboardSctLandscape){ |
324 // Replace space and enter markers with correct glyphs. |
351 QString keydata = keyboardMap->keys.at(key)->characters(HbModifierNone); |
325 // These only exist in symbian fonts, so if we are not using symbian, use blank. |
352 // Replace space and enter markers with correct glyphs. |
326 if (keydata.at(0) == HbSctSpaceMarker) { |
353 // These only exist in symbian fonts, so if we are not using symbian, use blank. |
327 item->setText(HbSctSpaceGlyph, HbInputButton::ButtonTextIndexPrimary); |
354 if (keydata.at(0) == HbSctSpaceMarker) { |
328 } else if (keydata.at(0) == HbSctEnterMarker) { |
355 item->setText(HbSctSpaceGlyph, HbInputButton::ButtonTextIndexPrimary); |
329 item->setText(HbSctEnterGlyph, HbInputButton::ButtonTextIndexPrimary); |
356 } else if (keydata.at(0) == HbSctEnterMarker) { |
|
357 item->setText(HbSctEnterGlyph, HbInputButton::ButtonTextIndexPrimary); |
|
358 } else { |
|
359 item->setText(keydata.at(0), HbInputButton::ButtonTextIndexPrimary); |
|
360 } |
330 } else { |
361 } else { |
331 item->setText(keydata.at(0), HbInputButton::ButtonTextIndexPrimary); |
362 i--; |
332 } |
363 } |
333 } else { |
364 } else { |
334 item->setText("", HbInputButton::ButtonTextIndexPrimary); |
365 item->setText("", HbInputButton::ButtonTextIndexPrimary); |
335 } |
366 } |
336 |
367 |
342 } |
373 } |
343 buttonGroup->setButtons(buttons); |
374 buttonGroup->setButtons(buttons); |
344 } |
375 } |
345 } |
376 } |
346 |
377 |
|
378 int HbSctKeyboardPrivate::keyAtIndex(int index) |
|
379 { |
|
380 Q_Q(HbSctKeyboard); |
|
381 |
|
382 const HbKeyboardMap *keyboardMap = mKeymap->keyboard(q->keyboardType()); |
|
383 if (mType == HbKeyboardSctLandscape){ |
|
384 return index; |
|
385 } |
|
386 int totalKeys=0; |
|
387 HbInputFocusObject *focusedObject = mOwner->focusObject(); |
|
388 HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup*>(q->contentItem()); |
|
389 if (buttonGroup) { |
|
390 if (keyboardMap && totalKeys < keyboardMap->keys.count()) { |
|
391 while (index){ |
|
392 if (focusedObject->characterAllowedInEditor(keyboardMap->keys.at(totalKeys)->characters(HbModifierNone).at(0))){ |
|
393 index--; |
|
394 } |
|
395 totalKeys++; |
|
396 } |
|
397 } |
|
398 } |
|
399 return totalKeys; |
|
400 } |
|
401 |
|
402 int HbSctKeyboardPrivate::countActiveKeys() |
|
403 { |
|
404 Q_Q(HbSctKeyboard); |
|
405 |
|
406 const HbKeyboardMap *keyboardMap = mKeymap->keyboard(q->keyboardType()); |
|
407 if (mType == HbKeyboardSctLandscape){ |
|
408 return keyboardMap->keys.count(); |
|
409 } |
|
410 |
|
411 int totalKeys=0; |
|
412 HbInputFocusObject *focusedObject = mOwner->focusObject(); |
|
413 HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup*>(q->contentItem()); |
|
414 if (buttonGroup) { |
|
415 if (keyboardMap && totalKeys < keyboardMap->keys.count()) { |
|
416 foreach(HbMappedKey *key, keyboardMap->keys){ |
|
417 if (focusedObject->characterAllowedInEditor(key->characters(HbModifierNone).at(0))){ |
|
418 totalKeys++; |
|
419 } |
|
420 } |
|
421 } |
|
422 } |
|
423 return totalKeys; |
|
424 } |
|
425 |
347 /*! |
426 /*! |
348 Constructs the object. owner is the owning input method implementation. Keymap |
427 Constructs the object. owner is the owning input method implementation. Keymap |
349 is key mapping data to be used to display button texts. Key mapping data can be |
428 is key mapping data to be used to display button texts. Key mapping data can be |
350 changed later (for example when the input language changes) by calling |
429 changed later (for example when the input language changes) by calling |
351 setKeymap. |
430 setKeymap. |