36 #include <hbinputsettingproxy.h> |
36 #include <hbinputsettingproxy.h> |
37 |
37 |
38 #include "hbinputbuttongroup.h" |
38 #include "hbinputbuttongroup.h" |
39 #include "hbinputbutton.h" |
39 #include "hbinputbutton.h" |
40 |
40 |
41 const qreal HbPortraitKeyboardHeightInUnits = 46.8; |
41 const qreal HbPortraitKeyboardHeightInUnits = 45.9; |
42 const qreal HbPortraitKeyboardWidthInUnits = 53.8; |
42 const qreal HbPortraitKeyboardWidthInUnits = 53.8; |
43 const qreal HbLandscapeKeyboardHeightInUnits = 34.6; |
43 const qreal HbLandscapeKeyboardHeightInUnits = 33.7; |
44 const qreal HbLandscapeKeyboardWidthInUnits = 95.5; |
44 const qreal HbLandscapeKeyboardWidthInUnits = 95.5; |
45 |
45 |
46 const int HbSctPortraitNumberOfRows = 5; |
46 const int HbSctPortraitNumberOfRows = 5; |
47 const int HbSctPortraitNumberOfColumns = 5; |
47 const int HbSctPortraitNumberOfColumns = 5; |
48 const int HbPortraitButtonKeyCodeTable[HbSctPortraitNumberOfRows *HbSctPortraitNumberOfColumns] = { |
48 const int HbPortraitButtonKeyCodeTable[HbSctPortraitNumberOfRows *HbSctPortraitNumberOfColumns] = { |
114 HbInputButton::ButtonKeyCodeCharacter, |
114 HbInputButton::ButtonKeyCodeCharacter, |
115 HbInputButton::ButtonKeyCodeCharacter, |
115 HbInputButton::ButtonKeyCodeCharacter, |
116 HbInputButton::ButtonKeyCodeCharacter, |
116 HbInputButton::ButtonKeyCodeCharacter, |
117 HbInputButton::ButtonKeyCodeCustom |
117 HbInputButton::ButtonKeyCodeCustom |
118 }; |
118 }; |
|
119 |
|
120 const int HbSctSpaceMarker = 0xE118; |
|
121 const int HbSctEnterMarker = 0xE125; |
|
122 |
|
123 #if defined(Q_OS_SYMBIAN) |
|
124 const QChar HbSctSpaceGlyph = 0xF800; |
|
125 const QChar HbSctEnterGlyph = 0xF801; |
|
126 #else |
|
127 const QChar HbSctSpaceGlyph = ' '; |
|
128 const QChar HbSctEnterGlyph = ' '; |
|
129 #endif |
119 |
130 |
120 /*! |
131 /*! |
121 @proto |
132 @proto |
122 @hbinput |
133 @hbinput |
123 \class HbSctKeyboard |
134 \class HbSctKeyboard |
173 } else if (keyCode(i) == HbInputButton::ButtonKeyCodeSpace) { |
184 } else if (keyCode(i) == HbInputButton::ButtonKeyCodeSpace) { |
174 item->setSize(QSize(2, 1)); |
185 item->setSize(QSize(2, 1)); |
175 ++key; |
186 ++key; |
176 } else if (keyCode(i) == HbInputButton::ButtonKeyCodeDelete && |
187 } else if (keyCode(i) == HbInputButton::ButtonKeyCodeDelete && |
177 mType == HbKeyboardSctPortrait) { |
188 mType == HbKeyboardSctPortrait) { |
|
189 // Portrait SCT has different delete icon from the default one |
178 item->setIcon(HbIcon(HbInputButtonIconDelete2), HbInputButton::ButtonIconIndexPrimary); |
190 item->setIcon(HbIcon(HbInputButtonIconDelete2), HbInputButton::ButtonIconIndexPrimary); |
179 } else if (keyCode(i) == HbInputButton::ButtonKeyCodePageChange && |
191 } else if (keyCode(i) == HbInputButton::ButtonKeyCodeAlphabet) { |
180 mType == HbKeyboardSctPortrait) { |
192 // Button that is used to return to normal keypad should be shown as latched |
181 item->setIcon(HbIcon(HbInputButtonIconPageChange2), HbInputButton::ButtonIconIndexPrimary); |
193 item->setState(HbInputButton::ButtonStateLatched); |
|
194 if (mType == HbKeyboardSctPortrait) { |
|
195 // Portrait SCT has different symbol icon from the default one |
|
196 item->setIcon(HbIcon(HbInputButtonIconSymbol2), HbInputButton::ButtonIconIndexPrimary); |
|
197 } |
182 } |
198 } |
183 ++key; |
199 ++key; |
184 } |
200 } |
185 buttonGroup->setButtons(buttons); |
201 buttonGroup->setButtons(buttons); |
186 |
202 |
232 !isSmileysEnabled()) { |
248 !isSmileysEnabled()) { |
233 state = HbInputButton::ButtonStateDisabled; |
249 state = HbInputButton::ButtonStateDisabled; |
234 } else if (item->state() == HbInputButton::ButtonStateDisabled) { |
250 } else if (item->state() == HbInputButton::ButtonStateDisabled) { |
235 state = HbInputButton::ButtonStateReleased; |
251 state = HbInputButton::ButtonStateReleased; |
236 } |
252 } |
|
253 } else if (keyCode(i) == HbInputButton::ButtonKeyCodeAlphabet) { |
|
254 state = HbInputButton::ButtonStateLatched; |
|
255 } else if (keyCode(i) == HbInputButton::ButtonKeyCodeSpace) { |
|
256 bool allowed = focusedObject->characterAllowedInEditor(QChar(' ')); |
|
257 if (!allowed) { |
|
258 state = HbInputButton::ButtonStateDisabled; |
|
259 } else if (item->state() == HbInputButton::ButtonStateDisabled) { |
|
260 state = HbInputButton::ButtonStateReleased; |
|
261 } |
237 } |
262 } |
238 item->setState(state); |
263 item->setState(state); |
239 } |
264 } |
240 buttonGroup->setButtons(buttons); |
265 buttonGroup->setButtons(buttons); |
241 } |
266 } |
262 for (int i = 0; i < buttons.count(); ++i) { |
287 for (int i = 0; i < buttons.count(); ++i) { |
263 if (keyCode(i) == HbInputButton::ButtonKeyCodeCharacter) { |
288 if (keyCode(i) == HbInputButton::ButtonKeyCodeCharacter) { |
264 HbInputButton *item = buttons.at(i); |
289 HbInputButton *item = buttons.at(i); |
265 |
290 |
266 if (keyboardMap && key < keyboardMap->keys.count()) { |
291 if (keyboardMap && key < keyboardMap->keys.count()) { |
267 item->setKeyCode(keyboardMap->keys.at(key)->keycode.unicode()); |
292 // Replace space and enter markers with correct keycodes |
|
293 if (keyboardMap->keys.at(key)->keycode.unicode() == HbSctSpaceMarker) { |
|
294 item->setKeyCode(HbInputButton::ButtonKeyCodeSpace); |
|
295 } else if (keyboardMap->keys.at(key)->keycode.unicode() == HbSctEnterMarker) { |
|
296 item->setKeyCode(HbInputButton::ButtonKeyCodeEnter); |
|
297 } else { |
|
298 item->setKeyCode(keyboardMap->keys.at(key)->keycode.unicode()); |
|
299 } |
268 } else { |
300 } else { |
269 item->setKeyCode(-1); |
301 item->setKeyCode(-1); |
270 } |
302 } |
271 ++key; |
303 ++key; |
272 } |
304 } |
287 HbInputButton *item = buttons.at(i); |
319 HbInputButton *item = buttons.at(i); |
288 |
320 |
289 const HbKeyboardMap *keyboardMap = mKeymap->keyboard(q->keyboardType()); |
321 const HbKeyboardMap *keyboardMap = mKeymap->keyboard(q->keyboardType()); |
290 if (keyboardMap && key < keyboardMap->keys.count() && keyboardMap->keys.at(key)->characters(HbModifierNone) != QString("")) { |
322 if (keyboardMap && key < keyboardMap->keys.count() && keyboardMap->keys.at(key)->characters(HbModifierNone) != QString("")) { |
291 QString keydata = keyboardMap->keys.at(key)->characters(HbModifierNone); |
323 QString keydata = keyboardMap->keys.at(key)->characters(HbModifierNone); |
292 item->setText(keydata.at(0), HbInputButton::ButtonTextIndexPrimary); |
324 // Replace space and enter markers with correct glyphs. |
|
325 // These only exist in symbian fonts, so if we are not using symbian, use blank. |
|
326 if (keydata.at(0) == HbSctSpaceMarker) { |
|
327 item->setText(HbSctSpaceGlyph, HbInputButton::ButtonTextIndexPrimary); |
|
328 } else if (keydata.at(0) == HbSctEnterMarker) { |
|
329 item->setText(HbSctEnterGlyph, HbInputButton::ButtonTextIndexPrimary); |
|
330 } else { |
|
331 item->setText(keydata.at(0), HbInputButton::ButtonTextIndexPrimary); |
|
332 } |
293 } else { |
333 } else { |
294 item->setText("", HbInputButton::ButtonTextIndexPrimary); |
334 item->setText("", HbInputButton::ButtonTextIndexPrimary); |
295 } |
335 } |
296 |
336 |
297 ++key; |
337 ++key; |
|
338 } else if (keyCode(i) == HbInputButton::ButtonKeyCodePageChange) { |
|
339 HbInputButton *item = buttons.at(i); |
|
340 item->setText(QString::number(mActivePage+1) + '/' + QString::number(mPages), HbInputButton::ButtonTextIndexSecondaryFirstRow); |
298 } |
341 } |
299 } |
342 } |
300 buttonGroup->setButtons(buttons); |
343 buttonGroup->setButtons(buttons); |
301 } |
344 } |
302 } |
345 } |
433 { |
476 { |
434 Q_D(HbSctKeyboard); |
477 Q_D(HbSctKeyboard); |
435 |
478 |
436 if (flickDirection == HbInputVkbWidget::HbFlickDirectionRight || |
479 if (flickDirection == HbInputVkbWidget::HbFlickDirectionRight || |
437 flickDirection == HbInputVkbWidget::HbFlickDirectionLeft) { |
480 flickDirection == HbInputVkbWidget::HbFlickDirectionLeft) { |
438 int direction = -1; |
481 int direction = 1; |
439 if (flickDirection == HbInputVkbWidget::HbFlickDirectionRight) { |
482 if (flickDirection == HbInputVkbWidget::HbFlickDirectionRight) { |
440 direction = 1; |
483 direction = -1; |
441 } |
484 } |
442 |
485 |
443 d->mActivePage = (d->mActivePage + direction) % d->mPages; |
486 d->mActivePage = (d->mActivePage + direction) % d->mPages; |
444 if (d->mActivePage < 0) { |
487 if (d->mActivePage < 0) { |
445 d->mActivePage = d->mPages - 1; |
488 d->mActivePage = d->mPages - 1; |
464 /*! |
507 /*! |
465 Sends key event to owning input method. |
508 Sends key event to owning input method. |
466 */ |
509 */ |
467 void HbSctKeyboard::sendKeyReleaseEvent(const QKeyEvent &event) |
510 void HbSctKeyboard::sendKeyReleaseEvent(const QKeyEvent &event) |
468 { |
511 { |
469 Q_D(HbSctKeyboard); |
|
470 |
|
471 if (event.key() == HbInputButton::ButtonKeyCodePageChange) { |
512 if (event.key() == HbInputButton::ButtonKeyCodePageChange) { |
472 changePage(HbInputVkbWidget::HbFlickDirectionRight); |
513 changePage(HbInputVkbWidget::HbFlickDirectionLeft); |
473 } else if (event.key() == HbInputButton::ButtonKeyCodeSmiley) { |
514 } else if (event.key() == HbInputButton::ButtonKeyCodeSmiley) { |
474 showSmileyPicker(d->mRows, d->mColumns); |
515 showSmileyPicker(); |
475 } else { |
516 } else { |
476 HbInputVkbWidget::sendKeyReleaseEvent(event); |
517 HbInputVkbWidget::sendKeyReleaseEvent(event); |
477 } |
518 } |
478 } |
519 } |
479 |
520 |