37 #include "hbinputmodeindicator.h" |
37 #include "hbinputmodeindicator.h" |
38 |
38 |
39 const qreal HbKeyboardHeightInUnits = 37.8; |
39 const qreal HbKeyboardHeightInUnits = 37.8; |
40 const qreal HbKeyboardWidthInUnits = 53.8; |
40 const qreal HbKeyboardWidthInUnits = 53.8; |
41 |
41 |
|
42 const int HbFirstRowIndex = 0; |
|
43 const int HbSecondRowIndex = 2; |
42 const int HbVirtual12KeyNumberOfRows = 4; |
44 const int HbVirtual12KeyNumberOfRows = 4; |
43 const int HbVirtual12KeyNumberOfColumns = 4; |
45 const int HbVirtual12KeyNumberOfColumns = 4; |
44 const int HbButtonKeyCodeTable[HbVirtual12KeyNumberOfRows * HbVirtual12KeyNumberOfColumns] = |
46 const int HbButtonKeyCodeTable[HbVirtual12KeyNumberOfRows * HbVirtual12KeyNumberOfColumns] = |
45 { |
47 { |
46 HbInputButton::ButtonKeyCodeCharacter, |
48 HbInputButton::ButtonKeyCodeCharacter, |
191 HbInputButton *item = buttons.at(i); |
193 HbInputButton *item = buttons.at(i); |
192 if (keyCode(i) == HbInputButton::ButtonKeyCodeCharacter) { |
194 if (keyCode(i) == HbInputButton::ButtonKeyCodeCharacter) { |
193 |
195 |
194 if (mMode == EModeNumeric) { |
196 if (mMode == EModeNumeric) { |
195 QChar numChr; |
197 QChar numChr; |
196 const HbKeyboardMap *keyboardMap = mKeymap->keyboard(HbKeyboardVirtual12Key); |
198 const HbKeyboardMap *labelMap = mKeymap->keyboard(HbKeyboardVirtual12KeyLabels); |
197 if (keyboardMap && key < keyboardMap->keys.count()) { |
199 const HbKeyboardMap *keyMap = mKeymap->keyboard(HbKeyboardVirtual12Key); |
|
200 if (labelMap && key < labelMap->keys.count()) { |
|
201 numChr = labelMap->keys.at(key)->keycode; |
|
202 } |
|
203 |
|
204 // Fallback to normal keymappings if key labels are not present |
|
205 if (keyMap && key < keyMap->keys.count() && numChr.isNull()) { |
198 numChr = numberCharacterBoundToKey(key); |
206 numChr = numberCharacterBoundToKey(key); |
199 } |
207 } |
200 |
208 |
201 if (numChr > 0) { |
209 item->setText(numChr, HbInputButton::ButtonTextIndexPrimary); |
202 item->setText(numChr, HbInputButton::ButtonTextIndexPrimary); |
|
203 } else { |
|
204 item->setText(QString(), HbInputButton::ButtonTextIndexPrimary); |
|
205 } |
|
206 item->setText(QString(), HbInputButton::ButtonTextIndexSecondaryFirstRow); |
210 item->setText(QString(), HbInputButton::ButtonTextIndexSecondaryFirstRow); |
207 item->setText(QString(), HbInputButton::ButtonTextIndexSecondarySecondRow); |
211 item->setText(QString(), HbInputButton::ButtonTextIndexSecondarySecondRow); |
208 item->setIcon(HbIcon(), HbInputButton::ButtonIconIndexPrimary); |
212 item->setIcon(HbIcon(), HbInputButton::ButtonIconIndexPrimary); |
209 item->setIcon(HbIcon(), HbInputButton::ButtonIconIndexSecondaryFirstRow); |
213 item->setIcon(HbIcon(), HbInputButton::ButtonIconIndexSecondaryFirstRow); |
210 item->setIcon(HbIcon(), HbInputButton::ButtonIconIndexSecondarySecondRow); |
214 item->setIcon(HbIcon(), HbInputButton::ButtonIconIndexSecondarySecondRow); |
211 } else if (mMode == EModeAbc) { |
215 } else if (mMode == EModeAbc) { |
212 QString keydata; |
216 QString firstRow; |
|
217 QString secondRow; |
213 QChar numChr; |
218 QChar numChr; |
214 const HbKeyboardMap *keyboardMap = mKeymap->keyboard(HbKeyboardVirtual12Key); |
219 const HbKeyboardMap *labelMap = mKeymap->keyboard(HbKeyboardVirtual12KeyLabels); |
215 if (keyboardMap && key < keyboardMap->keys.count()) { |
220 const HbKeyboardMap *keyMap = mKeymap->keyboard(HbKeyboardVirtual12Key); |
216 keydata = keyboardMap->keys.at(key)->characters(mModifiers); |
221 if (labelMap && key < labelMap->keys.count()) { |
217 numChr = numberCharacterBoundToKey(key); |
222 firstRow = keyLabel(labelMap->keys.at(key)->chars, HbFirstRowIndex | mModifiers); |
218 } |
223 secondRow = keyLabel(labelMap->keys.at(key)->chars, HbSecondRowIndex | mModifiers); |
219 |
224 numChr = labelMap->keys.at(key)->keycode; |
220 QString title(""); |
225 } |
221 if (mOwner->focusObject()) { |
226 |
222 QString allowedData; |
227 // Fallback to normal keymappings if key labels are not present |
223 mOwner->focusObject()->filterStringWithEditorFilter(keydata, allowedData); |
228 if (keyMap && key < keyMap->keys.count()) { |
224 title.append(allowedData.left(numberOfCharactersToShow(key))); |
229 if (firstRow.isEmpty()) { |
225 } else { |
230 firstRow = keyMap->keys.at(key)->characters(mModifiers); |
226 title.append(keydata.left(numberOfCharactersToShow(key))); |
231 if (mOwner->focusObject()) { |
227 } |
232 QString allowedData; |
228 |
233 mOwner->focusObject()->filterStringWithEditorFilter(firstRow, allowedData); |
229 if (key == 9 && numChr == numberCharacterBoundToKey(key)) { |
234 firstRow = allowedData.left(3); |
|
235 } else { |
|
236 firstRow = firstRow.left(3); |
|
237 } |
|
238 } |
|
239 if (numChr.isNull()) { |
|
240 numChr = numberCharacterBoundToKey(key); |
|
241 } |
|
242 } |
|
243 |
|
244 if (key == 9) { |
230 item->setText(numChr, HbInputButton::ButtonTextIndexPrimary); |
245 item->setText(numChr, HbInputButton::ButtonTextIndexPrimary); |
231 item->setIcon(HbIcon(HbInputButtonIconSpace2), HbInputButton::ButtonIconIndexSecondaryFirstRow); |
246 item->setIcon(HbIcon(HbInputButtonIconSpace2), HbInputButton::ButtonIconIndexSecondaryFirstRow); |
232 // Set space as secondaty text so that the layout is correct if icon is not found. This can be removed when |
|
233 // new space graphics are included in the main line. |
|
234 item->setText(QString(" "), HbInputButton::ButtonTextIndexSecondaryFirstRow); |
|
235 } else { |
247 } else { |
236 item->setText(title, HbInputButton::ButtonTextIndexSecondaryFirstRow); |
248 item->setText(firstRow, HbInputButton::ButtonTextIndexSecondaryFirstRow); |
|
249 item->setText(secondRow, HbInputButton::ButtonTextIndexSecondarySecondRow); |
237 item->setText(numChr, HbInputButton::ButtonTextIndexPrimary); |
250 item->setText(numChr, HbInputButton::ButtonTextIndexPrimary); |
238 } |
251 } |
239 } |
252 } |
240 |
253 |
241 ++key; |
254 ++key; |
249 } |
262 } |
250 buttonGroup->setButtons(buttons); |
263 buttonGroup->setButtons(buttons); |
251 } |
264 } |
252 } |
265 } |
253 |
266 |
254 int Hb12KeyTouchKeyboardPrivate::numberOfCharactersToShow(int key) |
267 QString Hb12KeyTouchKeyboardPrivate::keyLabel(const QStringList &labels, int index) |
255 { |
268 { |
256 QChar keyCode; |
269 if (index == HbFirstRowIndex && labels.count() >= 2) { |
257 const HbKeyboardMap *keyboardMap = mKeymap->keyboard(HbKeyboardVirtual12Key); |
270 return labels.at(1); |
258 if (keyboardMap && key < keyboardMap->keys.count()) { |
271 } else if (index == (HbFirstRowIndex | HbModifierShiftPressed) && labels.count() >= 3) { |
259 keyCode = keyboardMap->keys.at(key)->keycode; |
272 return labels.at(2); |
260 } |
273 } else if (index == HbSecondRowIndex && labels.count() >= 4) { |
261 |
274 return labels.at(3); |
262 if (keyCode == QChar('7') || keyCode == QChar('9')) { |
275 } else if (index == (HbSecondRowIndex | HbModifierShiftPressed) && labels.count() >= 5) { |
263 return 4; |
276 return labels.at(4); |
264 } else { |
277 } |
265 return 3; |
278 return QString(); |
266 } |
|
267 } |
279 } |
268 |
280 |
269 /*! |
281 /*! |
270 Constructs the object. owner is the owning input method implementation. Keymap |
282 Constructs the object. owner is the owning input method implementation. Keymap |
271 is key mapping data to be used to display button texts. Key mapping data can be |
283 is key mapping data to be used to display button texts. Key mapping data can be |