1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (developer.feedback@nokia.com) |
|
6 ** |
|
7 ** This file is part of the HbInput module of the UI Extensions for Mobile. |
|
8 ** |
|
9 ** GNU Lesser General Public License Usage |
|
10 ** This file may be used under the terms of the GNU Lesser General Public |
|
11 ** License version 2.1 as published by the Free Software Foundation and |
|
12 ** appearing in the file LICENSE.LGPL included in the packaging of this file. |
|
13 ** Please review the following information to ensure the GNU Lesser General |
|
14 ** Public License version 2.1 requirements will be met: |
|
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
16 ** |
|
17 ** In addition, as a special exception, Nokia gives you certain additional |
|
18 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
20 ** |
|
21 ** If you have questions regarding the use of this file, please contact |
|
22 ** Nokia at developer.feedback@nokia.com. |
|
23 ** |
|
24 ****************************************************************************/ |
|
25 |
|
26 #include <QGraphicsGridLayout> |
|
27 #include <hbinputmethod.h> |
|
28 #include <hbinputkeymap.h> |
|
29 #include <hbinputsettingproxy.h> |
|
30 #include <hbstyleoptionlabel.h> |
|
31 #include <hbaction.h> |
|
32 #include <hbtextitem.h> |
|
33 #include <hbframeitem.h> |
|
34 #include <hbcolorscheme.h> |
|
35 |
|
36 #include "hbinputcharpreviewpane.h" |
|
37 #include "hbinputtouchkeypadbutton.h" |
|
38 #include "hbinputqwertytouchkeyboard.h" |
|
39 #include "hbinputqwertytouchkeyboard_p.h" |
|
40 #include "hbinputvkbwidget_p.h" |
|
41 |
|
42 const int HbVirtualQwertyNumberOfColumns = 10; |
|
43 const int HbVirtualQwertyNumberOfRows = 4; |
|
44 const int HbVirtualQwerty4x10MaxKeysCount = 32; |
|
45 const int HbVirtualQwerty4x11MaxKeysCount = 36; |
|
46 const int HbVirtualQwertyFunctionButtonCount = 5; |
|
47 const int HbVirtualQwertyNumericKeypadButtonCount = 18; |
|
48 const qreal HbVirtualQwertyButtonPreferredHeight = 58.0; |
|
49 const QSizeF HbVirtualQwerty4x10LayoutDimensions(64.0, HbVirtualQwertyButtonPreferredHeight); |
|
50 const QSizeF HbVirtualQwerty4x11LayoutDimensions(58.18, HbVirtualQwertyButtonPreferredHeight); |
|
51 const int HbVirtualQwertyNumberOfRowsNumberMode = 2; |
|
52 |
|
53 const QString HbButtonObjName = "qwerty "; |
|
54 const QString HbCustomButtonObjName = "qwerty custom button "; |
|
55 const QString HbEnterObjName = "qwerty enter"; |
|
56 const QString HbShiftObjName = "qwerty shift"; |
|
57 const QString HbControlObjName = "qwerty control"; |
|
58 const QString HbBackspaceObjName = "qwerty backspace"; |
|
59 const QString HbSpaceObjName = "qwerty space"; |
|
60 |
|
61 const QString HbQwertyButtonTextLayout = "_hb_qwerty_button_text_layout"; |
|
62 const QString HbQwertyButtonIconLayout = "_hb_qwerty_button_icon_layout"; |
|
63 |
|
64 /*! |
|
65 \deprecated class HbQwertyKeyboard |
|
66 */ |
|
67 |
|
68 HbQwertyKeyboardPrivate::HbQwertyKeyboardPrivate() |
|
69 :mCtrlBtnIndex(-1), |
|
70 mPressedButtonIndex(-1), |
|
71 mPreviewPane(0), |
|
72 mInStickyRegion(false), |
|
73 mLongKeyPressCharsShown(false), |
|
74 mKeypadCreated(false), |
|
75 mKeymapChanged(false), |
|
76 mKeyboardSize(HbQwerty4x10), |
|
77 mSize(QSizeF()) |
|
78 { |
|
79 } |
|
80 |
|
81 void HbQwertyKeyboardPrivate::constructKeypad() |
|
82 { |
|
83 Q_Q(HbQwertyKeyboard); |
|
84 |
|
85 if (mMode == EModeAbc) { |
|
86 const HbKeyboardMap *keyboardmap = mKeymap->keyboard(HbKeyboardVirtualQwerty); |
|
87 for (int i = 0; i < HbVirtualQwerty4x11MaxKeysCount; i++) { |
|
88 HbTouchKeypadButton *button = new HbTouchKeypadButton(q, textForKey(i), q); |
|
89 if (keyboardmap && (i < keyboardmap->keys.count())) { |
|
90 button->setKeyCode(keyboardmap->keys.at(i)->keycode.unicode()); |
|
91 } |
|
92 button->setProperty(HbStyleRulesCacheId::hbStyleRulesForNodeCache, HbQwertyButtonTextLayout); |
|
93 button->setAsStickyButton(true); |
|
94 q->connect(button, SIGNAL(pressed()), mPressMapper, SLOT(map())); |
|
95 q->connect(button, SIGNAL(released()), mReleaseMapper, SLOT(map())); |
|
96 q->connect(button, SIGNAL(enteredInNonStickyRegion()), q, SLOT(enteredInNonStickyRegion())); |
|
97 if (i >= HbVirtualQwerty4x10MaxKeysCount) { |
|
98 button->hide(); |
|
99 } |
|
100 mButtons.append(button); |
|
101 } |
|
102 //Create the function buttons |
|
103 for (int i = 0; i < HbVirtualQwertyFunctionButtonCount; ++i) { |
|
104 HbTouchKeypadButton *button = 0; |
|
105 switch ( i ) { |
|
106 case 0: { |
|
107 HbIcon icon("qtg_mono_backspace1"); |
|
108 button = new HbTouchKeypadButton(q, icon, QString(), q); |
|
109 button->setAutoRepeatDelay(HbRepeatTimeout); |
|
110 button->setAutoRepeatInterval(HbRepeatTimeoutShort); |
|
111 button->setAutoRepeat(true); |
|
112 button->setProperty(HbStyleRulesCacheId::hbStyleRulesForNodeCache, HbQwertyButtonIconLayout); |
|
113 break; |
|
114 } |
|
115 case 1: { |
|
116 HbIcon icon("qtg_mono_enter"); |
|
117 button = new HbTouchKeypadButton(q, icon, QString(), q); |
|
118 button->setProperty(HbStyleRulesCacheId::hbStyleRulesForNodeCache, HbQwertyButtonIconLayout); |
|
119 break; |
|
120 } |
|
121 case 2: { |
|
122 HbIcon icon("qtg_mono_shift"); |
|
123 button = new HbTouchKeypadButton(q, icon, QString(), q); |
|
124 button->setProperty(HbStyleRulesCacheId::hbStyleRulesForNodeCache, HbQwertyButtonIconLayout); |
|
125 break; |
|
126 } |
|
127 case 3: { |
|
128 HbIcon icon("qtg_mono_sym_qwerty"); |
|
129 button = new HbTouchKeypadButton(q, icon, QString(), q); |
|
130 button->setProperty(HbStyleRulesCacheId::hbStyleRulesForNodeCache, HbQwertyButtonIconLayout); |
|
131 mCtrlBtnIndex = mButtons.count()-1; |
|
132 break; |
|
133 } |
|
134 case 4: { |
|
135 button = new HbTouchKeypadButton(q, QString(), q); |
|
136 button->setFrameIcon("qtg_mono_space"); |
|
137 button->setAutoRepeatDelay(HbRepeatTimeout); |
|
138 button->setAutoRepeatInterval(HbRepeatTimeoutShort); |
|
139 button->setAutoRepeat(true); |
|
140 break; |
|
141 } |
|
142 default: |
|
143 break; |
|
144 } |
|
145 button->setButtonType(HbTouchKeypadButton::HbTouchButtonFunction); |
|
146 button->setBackgroundAttributes(HbTouchKeypadButton::HbTouchButtonReleased); |
|
147 button->setAsStickyButton(false); |
|
148 q->connect(button, SIGNAL(pressed()), mPressMapper, SLOT(map())); |
|
149 q->connect(button, SIGNAL(released()), mReleaseMapper, SLOT(map())); |
|
150 q->connect(button, SIGNAL(enteredInNonStickyRegion()), q, SLOT(enteredInNonStickyRegion())); |
|
151 mButtons.append(button); |
|
152 } |
|
153 } else { |
|
154 QString allowedSctCharacters; |
|
155 getAllowedSctCharcters(allowedSctCharacters); |
|
156 int sctIndex = 1; |
|
157 // Construct Numeric Keypad |
|
158 for(int jj = 0; jj < HbVirtualQwertyNumericKeypadButtonCount ; jj++) { |
|
159 HbTouchKeypadButton *button = 0; |
|
160 if (jj < 10) { |
|
161 button = new HbTouchKeypadButton(q, QString::number((jj+1)%10), q); |
|
162 button->setAsStickyButton(true); |
|
163 setButtonObjectName(*button, 0, jj, Qt::Key_unknown); |
|
164 } else if(jj>= 12 && jj<=16) { |
|
165 // One todo is what if their are more than 5 sct characters that are allowed |
|
166 // in to the editor. UI Concept is not clear for this. Need to revisit this. |
|
167 // But as of now, there are not numeric editors which have more than 5 sct |
|
168 // characters allowed in to them. |
|
169 QString buttonText; |
|
170 if(allowedSctCharacters.length() >= sctIndex) { |
|
171 buttonText = allowedSctCharacters[sctIndex-1]; |
|
172 } |
|
173 button = new HbTouchKeypadButton(q, buttonText, q); |
|
174 button->setAsStickyButton(true); |
|
175 setButtonObjectName(*button, 1, jj%10 , Qt::Key_unknown); |
|
176 sctIndex++; |
|
177 } else { |
|
178 //construct the function button in numeric keypad |
|
179 switch(jj) { |
|
180 case 10: { |
|
181 HbIcon icon("qtg_mono_shift"); |
|
182 button = new HbTouchKeypadButton(q, icon, QString(), q); |
|
183 setButtonObjectName(*button, 1, 0, Qt::Key_Shift); |
|
184 button->setButtonType(HbTouchKeypadButton::HbTouchButtonFunction); |
|
185 button->setBackgroundAttributes(HbTouchKeypadButton::HbTouchButtonReleased); |
|
186 button->setAsStickyButton(false); |
|
187 button->setEnabled(false); |
|
188 } |
|
189 break; |
|
190 case 11: { |
|
191 HbIcon icon("qtg_mono_sym_qwerty"); |
|
192 button = new HbTouchKeypadButton(q, icon, QString(), q); |
|
193 setButtonObjectName(*button, 1, 1, Qt::Key_Control); |
|
194 button->setButtonType(HbTouchKeypadButton::HbTouchButtonFunction); |
|
195 button->setBackgroundAttributes(HbTouchKeypadButton::HbTouchButtonReleased); |
|
196 button->setAsStickyButton(false); |
|
197 button->setEnabled(false); |
|
198 } |
|
199 break; |
|
200 case 17: { |
|
201 HbIcon icon("qtg_mono_backspace1"); |
|
202 button = new HbTouchKeypadButton(q, icon, QString(), q); |
|
203 setButtonObjectName(*button, 1, 7, Qt::Key_Backspace); |
|
204 button->setButtonType(HbTouchKeypadButton::HbTouchButtonFunction); |
|
205 button->setBackgroundAttributes(HbTouchKeypadButton::HbTouchButtonReleased); |
|
206 button->setAsStickyButton(false); |
|
207 button->setAutoRepeatDelay(HbRepeatTimeout); |
|
208 button->setAutoRepeatInterval(HbRepeatTimeoutShort); |
|
209 button->setAutoRepeat(true); |
|
210 } |
|
211 break; |
|
212 default: |
|
213 break; |
|
214 } |
|
215 } |
|
216 |
|
217 q->connect(button, SIGNAL(pressed()), mPressMapper, SLOT(map())); |
|
218 q->connect(button, SIGNAL(released()), mReleaseMapper, SLOT(map())); |
|
219 q->connect(button, SIGNAL(enteredInNonStickyRegion()), q, SLOT(enteredInNonStickyRegion())); |
|
220 mButtons.append(button); |
|
221 } |
|
222 } |
|
223 |
|
224 |
|
225 // intercepting signal before passing to mOwner |
|
226 q->connect(mPressMapper, SIGNAL(mapped(int)), q, SLOT(mappedKeyPress(int))); |
|
227 q->connect(mReleaseMapper, SIGNAL(mapped(int)), q, SLOT(mappedKeyRelease(int))); |
|
228 } |
|
229 |
|
230 void HbQwertyKeyboardPrivate::getAllowedSctCharcters(QString & allowedSctCharacters) |
|
231 { |
|
232 QString sctCharacters; |
|
233 if (mKeymap) { |
|
234 const HbKeyboardMap* keymap = mKeymap->keyboard(HbKeyboardSctLandscape); |
|
235 if (keymap == 0) { |
|
236 return; |
|
237 } |
|
238 foreach (const HbMappedKey* mappedKey, keymap->keys) { |
|
239 sctCharacters.append(mappedKey->characters(HbModifierNone)); |
|
240 } |
|
241 } |
|
242 |
|
243 HbInputFocusObject *focusedObject = mOwner->focusObject(); |
|
244 QString tempAllowedSctCharacters; |
|
245 if(focusedObject) { |
|
246 focusedObject->filterStringWithEditorFilter(sctCharacters,tempAllowedSctCharacters); |
|
247 } |
|
248 |
|
249 // Remove digits from it ( digits always come in the first row ) |
|
250 allowedSctCharacters.clear(); |
|
251 for(int i=0; i<tempAllowedSctCharacters.length() ;i++) { |
|
252 if(!(tempAllowedSctCharacters[i]>='0' && tempAllowedSctCharacters[i] <= '9' )) { |
|
253 // dont add duplicates to the list |
|
254 if(!allowedSctCharacters.contains(tempAllowedSctCharacters[i])) { |
|
255 allowedSctCharacters.append(tempAllowedSctCharacters[i]); |
|
256 } |
|
257 } |
|
258 } |
|
259 } |
|
260 |
|
261 void HbQwertyKeyboardPrivate::updateButtonsTextAndMappers() |
|
262 { |
|
263 if (mMode == EModeNumeric) { |
|
264 QString allowedSctCharacters; |
|
265 getAllowedSctCharcters(allowedSctCharacters); |
|
266 int sctIndex = 1; |
|
267 for (int jj = 0; jj < HbVirtualQwertyNumericKeypadButtonCount ; jj++) { |
|
268 if (jj>=12 && jj<=16) { |
|
269 QString buttonText; |
|
270 if (allowedSctCharacters.length() >= sctIndex) { |
|
271 buttonText = allowedSctCharacters[sctIndex-1]; |
|
272 } |
|
273 mButtons[jj]->setText(buttonText); |
|
274 // Update press and release mapper. |
|
275 mReleaseMapper->removeMappings(mButtons.at(jj)); |
|
276 mPressMapper->removeMappings(mButtons.at(jj)); |
|
277 if(!mButtons.at(jj)->text().isEmpty()) { |
|
278 mReleaseMapper->setMapping(mButtons.at(jj), mButtons.at(jj)->text().at(0).unicode()); |
|
279 mPressMapper->setMapping(mButtons.at(jj), mButtons.at(jj)->text().at(0).unicode()); |
|
280 } |
|
281 sctIndex++; |
|
282 } |
|
283 } |
|
284 } else { // mMode == EModeAbc |
|
285 const HbKeyboardMap* keymap = mKeymap->keyboard(HbKeyboardVirtualQwerty); |
|
286 if (keymap == 0) { |
|
287 return; |
|
288 } |
|
289 int keymapCount = keymap->keys.count(); |
|
290 |
|
291 for (int i = 0; i < mButtons.count(); i++) { |
|
292 if (i < keymapCount) { |
|
293 mButtons.at(i)->setText(textForKey(i)); |
|
294 mButtons.at(i)->setKeyCode(keymap->keys.at(i)->keycode.unicode()); |
|
295 if (mKeymapChanged) { |
|
296 HbTouchKeypadButton *button = mButtons.at(i); |
|
297 mReleaseMapper->removeMappings(button); |
|
298 mPressMapper->removeMappings(button); |
|
299 mReleaseMapper->setMapping(button, keymap->keys.at(i)->keycode.unicode()); |
|
300 mPressMapper->setMapping(button, keymap->keys.at(i)->keycode.unicode()); |
|
301 } |
|
302 } |
|
303 } |
|
304 } |
|
305 } |
|
306 |
|
307 HbQwertyKeyboardPrivate::~HbQwertyKeyboardPrivate() |
|
308 { |
|
309 delete mPreviewPane; |
|
310 mPreviewPane = 0; |
|
311 |
|
312 while (!mKeypadButtonOption.isEmpty()) { |
|
313 delete mKeypadButtonOption.takeFirst(); |
|
314 } |
|
315 } |
|
316 |
|
317 void HbQwertyKeyboardPrivate::launchPreviewPane(const QStringList& list) |
|
318 { |
|
319 if (mPressedButtonIndex > -1 && mPressedButtonIndex < mButtons.size()) { |
|
320 mPreviewPane->showCharacters(list, mButtons.at(mPressedButtonIndex)->sceneBoundingRect()); |
|
321 } |
|
322 } |
|
323 |
|
324 int HbQwertyKeyboardPrivate::indexForKeycode(int keycode) |
|
325 { |
|
326 int index = -1; |
|
327 if (mMode == EModeNumeric) { |
|
328 switch(keycode) { |
|
329 case Qt::Key_Control: |
|
330 index = 10; // First key of second row |
|
331 break; |
|
332 case Qt::Key_Shift: |
|
333 index = 11; |
|
334 break; |
|
335 case Qt::Key_Backspace: |
|
336 index = 17; |
|
337 break; |
|
338 case '0': |
|
339 index = 9; |
|
340 break; |
|
341 default: |
|
342 if (keycode >= '1' && keycode <= '9') { |
|
343 index = keycode - '1'; |
|
344 } else { |
|
345 QString sctChars; |
|
346 getAllowedSctCharcters(sctChars); |
|
347 sctChars.truncate(5); |
|
348 if (sctChars.contains(QChar(keycode))) { |
|
349 index = sctChars.indexOf(QChar(keycode)) + 12; |
|
350 } |
|
351 } |
|
352 break; |
|
353 } |
|
354 } else { |
|
355 const HbKeyboardMap* keymap = mKeymap->keyboard(HbKeyboardVirtualQwerty); |
|
356 for (int i = 0; i < keymap->keys.count(); ++i) { |
|
357 if (keymap->keys.at(i)->keycode == keycode) { |
|
358 index = i; |
|
359 break; |
|
360 } |
|
361 } |
|
362 } |
|
363 return index; |
|
364 } |
|
365 |
|
366 int HbQwertyKeyboardPrivate::keyCode(int buttonId) |
|
367 { |
|
368 return buttonId; |
|
369 } |
|
370 |
|
371 int HbQwertyKeyboardPrivate::keyCode(HbTouchKeypadButton *button) |
|
372 { |
|
373 int code = -1; |
|
374 if(button) { |
|
375 code = button->keyCode(); |
|
376 } |
|
377 return code; |
|
378 } |
|
379 |
|
380 void HbQwertyKeyboardPrivate::handleStandardButtonPress(int buttonId) |
|
381 { |
|
382 HbInputVkbWidgetPrivate::handleStandardButtonPress(buttonId); |
|
383 |
|
384 // A new button is pressed so we should close |
|
385 // preview pane on the previous button. |
|
386 if (mPreviewPane->isVisible()) { |
|
387 mPreviewPane->hide(); |
|
388 } |
|
389 // a new button is pressed so we should reset the state of the |
|
390 // long press character preview pane. |
|
391 mLongKeyPressCharsShown = false; |
|
392 |
|
393 if (buttonId < 0) { |
|
394 return; |
|
395 } |
|
396 |
|
397 mPressedButtonIndex = indexForKeycode(buttonId); |
|
398 |
|
399 if (!(buttonId & 0xffff0000) && showPreview(buttonId)) { |
|
400 mInStickyRegion = false; |
|
401 // Show character preview only incase of setting proxy allows us to do. |
|
402 if (HbInputSettingProxy::instance()->isCharacterPreviewForQwertyEnabled()) { |
|
403 if (mPressedButtonIndex >= 0 && mPressedButtonIndex < mButtons.count()) { |
|
404 if(mButtons.at(mPressedButtonIndex)->isFaded()) { |
|
405 return; // if the button is inactive, dont show character preview popup. |
|
406 } |
|
407 const QString &text = mButtons.at(mPressedButtonIndex)->text(); |
|
408 if (text.size()) { |
|
409 QStringList list; |
|
410 list.append(text); |
|
411 // let's show the character preview. |
|
412 launchPreviewPane(list); |
|
413 return; |
|
414 } |
|
415 } |
|
416 } |
|
417 } |
|
418 } |
|
419 |
|
420 void HbQwertyKeyboardPrivate::handleStandardButtonRelease(int buttonId) |
|
421 { |
|
422 // mLongKeyPressCharsShown will be true in case there is a long key press |
|
423 // detected and preview pane is showing some character(s) to be selected |
|
424 // by user. so when mLongKeyPressCharsShown is true we should not close |
|
425 // the preview pane. |
|
426 if (!mLongKeyPressCharsShown) { |
|
427 if (mPreviewPane->isVisible()) { |
|
428 mPreviewPane->hide(); |
|
429 } |
|
430 |
|
431 /* Release Event is handled in Button Release as we do not get Click event from |
|
432 pushButton on longpress of the button |
|
433 */ |
|
434 |
|
435 // handle keypress only if there was no flick |
|
436 if (mFlickDirection==HbInputVkbWidget::HbFlickDirectionNone && buttonId >= 0){ |
|
437 QKeyEvent releaseEvent(QEvent::KeyRelease, buttonId, Qt::NoModifier); |
|
438 if (mOwner) { |
|
439 mOwner->filterEvent(&releaseEvent); |
|
440 } |
|
441 } |
|
442 } |
|
443 } |
|
444 |
|
445 void HbQwertyKeyboardPrivate::setLayoutDimensions(QSizeF dimensions) |
|
446 { |
|
447 // only update the dimensions if they are not previously set and buttons have been created |
|
448 if (mSize == dimensions || !mButtons.count()) { |
|
449 return; |
|
450 } |
|
451 mSize = dimensions; |
|
452 |
|
453 mButtonLayout->setContentsMargins(0.0, 0.0, 0.0, 0.0); |
|
454 int numberOfRows = HbVirtualQwertyNumberOfRows; |
|
455 |
|
456 foreach (HbTouchKeypadButton* button, mButtons) { |
|
457 button->setInitialSize(dimensions); |
|
458 } |
|
459 if (mSettingsButton && mApplicationButton) { |
|
460 mSettingsButton->setInitialSize(dimensions); |
|
461 mApplicationButton->setInitialSize(dimensions); |
|
462 } |
|
463 |
|
464 if ( EModeNumeric == mMode ) { |
|
465 numberOfRows = HbVirtualQwertyNumberOfRowsNumberMode; |
|
466 } |
|
467 if (mKeyboardSize == HbQwerty4x10) { |
|
468 for (int jj = 0; jj < HbVirtualQwertyNumberOfColumns; jj++) { |
|
469 mButtonLayout->setColumnFixedWidth(jj, dimensions.width() - HorizontalSpacing); |
|
470 } |
|
471 } else { |
|
472 for (int jj = 0; jj < HbVirtualQwertyNumberOfColumns + 1; jj++) { |
|
473 mButtonLayout->setColumnFixedWidth(jj, dimensions.width() - HorizontalSpacing); |
|
474 } |
|
475 } |
|
476 for (int jj = 0; jj < numberOfRows; jj++) { |
|
477 mButtonLayout->setRowFixedHeight(jj, dimensions.height() - VerticalSpacing); |
|
478 } |
|
479 |
|
480 mButtonLayout->setHorizontalSpacing(HorizontalSpacing); |
|
481 mButtonLayout->setVerticalSpacing(VerticalSpacing); |
|
482 } |
|
483 |
|
484 QSizeF HbQwertyKeyboardPrivate::calculateDimensions(QSizeF size) |
|
485 { |
|
486 QSizeF dimensions; |
|
487 if (mKeyboardSize == HbQwertyKeyboardPrivate::HbQwerty4x10) { |
|
488 dimensions.setWidth(size.width() / (qreal)HbVirtualQwertyNumberOfColumns); |
|
489 } else { |
|
490 dimensions.setWidth(size.width() / (qreal)(HbVirtualQwertyNumberOfColumns + 1)); |
|
491 } |
|
492 if (mMode == EModeNumeric) { |
|
493 dimensions.setHeight(size.height() / (qreal)HbVirtualQwertyNumberOfRowsNumberMode); |
|
494 } else { |
|
495 dimensions.setHeight(size.height() / (qreal)HbVirtualQwertyNumberOfRows); |
|
496 } |
|
497 return dimensions; |
|
498 } |
|
499 |
|
500 QString HbQwertyKeyboardPrivate::textForKey(int key) |
|
501 { |
|
502 QString keydata; |
|
503 if (mKeymap->keyboard(HbKeyboardVirtualQwerty)->keys.count() <= key) { |
|
504 return QString(); |
|
505 } |
|
506 if (mModifiers & HbModifierShiftPressed) { |
|
507 keydata = mKeymap->keyboard(HbKeyboardVirtualQwerty)->keys.at(key)->characters(HbModifierShiftPressed); |
|
508 } else { |
|
509 keydata = mKeymap->keyboard(HbKeyboardVirtualQwerty)->keys.at(key)->characters(HbModifierNone); |
|
510 } |
|
511 return keydata.left(1); |
|
512 } |
|
513 |
|
514 void HbQwertyKeyboardPrivate::initializeNumericKeyboard() |
|
515 { |
|
516 Q_Q(HbQwertyKeyboard); |
|
517 removeExistingSignalMappings(); |
|
518 const HbKeyboardMap* keymap = mKeymap->keyboard(HbKeyboardVirtualQwerty); |
|
519 if (keymap == 0) { |
|
520 return; |
|
521 } |
|
522 for (int i = 0; i < HbVirtualQwertyNumericKeypadButtonCount; ++i) { |
|
523 if (i <= 9) { |
|
524 mButtonLayout->addItem(mButtons.at(i), 0, i); |
|
525 mReleaseMapper->setMapping(mButtons.at(i), mButtons.at(i)->text().at(0).unicode()); |
|
526 mPressMapper->setMapping(mButtons.at(i), mButtons.at(i)->text().at(0).unicode()); |
|
527 } else if(i>=12 && i<= 16) { |
|
528 mButtonLayout->addItem(mButtons.at(i), 1, i%10); |
|
529 if(!mButtons.at(i)->text().isEmpty()) { |
|
530 mReleaseMapper->setMapping(mButtons.at(i), mButtons.at(i)->text().at(0).unicode()); |
|
531 mPressMapper->setMapping(mButtons.at(i), mButtons.at(i)->text().at(0).unicode()); |
|
532 } |
|
533 } else { |
|
534 switch(i) { |
|
535 case 10: { |
|
536 mButtonLayout->addItem(mButtons.at(i), 1, 0); |
|
537 mReleaseMapper->setMapping(mButtons.at(i), Qt::Key_Shift); |
|
538 mPressMapper->setMapping(mButtons.at(i), Qt::Key_Shift); |
|
539 } |
|
540 break; |
|
541 case 11: { |
|
542 mButtonLayout->addItem(mButtons.at(i), 1, 1); |
|
543 mReleaseMapper->setMapping(mButtons.at(i), Qt::Key_Control); |
|
544 mPressMapper->setMapping(mButtons.at(i), Qt::Key_Control); |
|
545 } |
|
546 break; |
|
547 case 17: { |
|
548 mButtonLayout->addItem(mButtons.at(i), 1, 7); |
|
549 mReleaseMapper->setMapping(mButtons.at(i), Qt::Key_Backspace); |
|
550 mPressMapper->setMapping(mButtons.at(i), Qt::Key_Backspace); |
|
551 } |
|
552 break; |
|
553 default: |
|
554 break; |
|
555 } |
|
556 } |
|
557 } |
|
558 |
|
559 q->setupToolCluster(); |
|
560 if (mSettingsButton) { |
|
561 mSettingsButton->setObjectName(HbCustomButtonObjName + QString::number(2)); |
|
562 mButtonLayout->addItem(mSettingsButton, 1, 8); |
|
563 } |
|
564 if (mApplicationButton) { |
|
565 mApplicationButton->setObjectName(HbCustomButtonObjName + QString::number(3)); |
|
566 mButtonLayout->addItem(mApplicationButton, 1, 9); |
|
567 } |
|
568 |
|
569 setLayoutDimensions(calculateDimensions(q->keypadButtonAreaSize())); |
|
570 mKeypadCreated = true; |
|
571 } |
|
572 |
|
573 void HbQwertyKeyboardPrivate::initializeKeyboard(bool refreshButtonText) |
|
574 { |
|
575 const HbKeyboardMap* keymap = mKeymap->keyboard(HbKeyboardVirtualQwerty); |
|
576 if (mKeymap == 0) { |
|
577 return; |
|
578 } |
|
579 |
|
580 int keymapCount = keymap->keys.count(); |
|
581 if (mMode == EModeNumeric) { |
|
582 initializeNumericKeyboard(); |
|
583 } else if (keymapCount <= HbVirtualQwerty4x10MaxKeysCount) { |
|
584 initialize4x10Keypad(refreshButtonText); |
|
585 } else { |
|
586 initialize4x11Keypad(refreshButtonText); |
|
587 } |
|
588 mKeypadCreated = true; |
|
589 } |
|
590 |
|
591 void HbQwertyKeyboardPrivate::setRockerPosition() |
|
592 { |
|
593 Q_Q(HbQwertyKeyboard); |
|
594 |
|
595 // Set rocker position. |
|
596 QSizeF padArea = q->keypadButtonAreaSize(); |
|
597 QPointF point((padArea.width() * 0.5) - (mRocker->size().width() * 0.5), |
|
598 (padArea.height() * 0.5) - (mRocker->size().height() * 0.5)); |
|
599 point.setY(point.y() + HbCloseHandleHeight); |
|
600 |
|
601 if (q->keypadLayout() && q->keypadLayout()->geometry().height()) { |
|
602 if(mKeyboardSize == HbQwerty4x10) { |
|
603 point.setX((padArea.width() * 0.5) - (mRocker->size().width() * 0.5)); |
|
604 point.setY((q->keypadLayout()->geometry().height() * 0.5) - (mRocker->size().height() * 0.5) + HbCloseHandleHeight); |
|
605 } else { |
|
606 point.setX(((padArea.width() * 0.5) - (mRocker->size().width() * 0.5)) + HbVirtualQwerty4x11LayoutDimensions.width()/2); |
|
607 point.setY((q->keypadLayout()->geometry().height() * 0.5) - (mRocker->size().height() * 0.5) + HbCloseHandleHeight); |
|
608 } |
|
609 } |
|
610 mRocker->setPos(point); |
|
611 } |
|
612 |
|
613 void HbQwertyKeyboardPrivate::removeExistingSignalMappings() |
|
614 { |
|
615 // removes all mappings except settings button and application button |
|
616 if (mButtonLayout) { |
|
617 int count = mButtonLayout->count(); |
|
618 for (int jj=0; jj < count-2 ; jj++) { |
|
619 HbTouchKeypadButton * button = mButtons.at(jj); |
|
620 mReleaseMapper->removeMappings(button); |
|
621 mPressMapper->removeMappings(button); |
|
622 } |
|
623 for (int i = mButtonLayout->count() - 1; i >= 0; i--) { |
|
624 mButtonLayout->removeAt(i); |
|
625 } |
|
626 } |
|
627 } |
|
628 |
|
629 void HbQwertyKeyboardPrivate::initialize4x10Keypad(bool refreshButtonText) |
|
630 { |
|
631 removeExistingSignalMappings(); |
|
632 mKeyboardSize = HbQwerty4x10; |
|
633 Q_Q(HbQwertyKeyboard); |
|
634 const HbKeyboardMap* keymap = mKeymap->keyboard(HbKeyboardVirtualQwerty); |
|
635 if (keymap == 0) { |
|
636 return; |
|
637 } |
|
638 |
|
639 for (int i = 0; i < keymap->keys.count() && i < HbVirtualQwerty4x11MaxKeysCount; ++i) { |
|
640 if (refreshButtonText) { |
|
641 mButtons[i]->setText(textForKey(i)); |
|
642 mButtons[i]->setKeyCode(keymap->keys.at(i)->keycode.unicode()); |
|
643 } |
|
644 mReleaseMapper->setMapping(mButtons.at(i), keymap->keys.at(i)->keycode.unicode()); |
|
645 mPressMapper->setMapping(mButtons.at(i), keymap->keys.at(i)->keycode.unicode()); |
|
646 int row = 0; |
|
647 int column = 0; |
|
648 if (i < 10) { |
|
649 row = 0; |
|
650 column = i; |
|
651 } else if (i < 19) { |
|
652 row = 1; |
|
653 column = i-10; |
|
654 } else if (i < 28) { |
|
655 row = 2; |
|
656 column = i-19; |
|
657 } else { |
|
658 row = 3; |
|
659 column = i-28; |
|
660 if (column == 0) { |
|
661 column = 2; |
|
662 } else if (column == 1) { |
|
663 column = 3; |
|
664 } else if (column == 2) { |
|
665 column = 6; |
|
666 } else if (column == 3) { |
|
667 column = 7; |
|
668 } |
|
669 } |
|
670 mButtonLayout->addItem(mButtons.at(i), row, column); |
|
671 setButtonObjectName(*mButtons.at(i), row, column, Qt::Key_unknown); |
|
672 } |
|
673 |
|
674 for (int i = HbVirtualQwerty4x10MaxKeysCount; i < HbVirtualQwerty4x11MaxKeysCount; ++i) { |
|
675 mButtons[i]->hide(); |
|
676 } |
|
677 |
|
678 for (int i = 0; i < 5; ++i) { |
|
679 switch ( i ) { |
|
680 case 0: { |
|
681 mButtonLayout->addItem(mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), 1, 9); |
|
682 setButtonObjectName(*mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), 1, 9, Qt::Key_Backspace); |
|
683 mReleaseMapper->setMapping(mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), Qt::Key_Backspace); |
|
684 mPressMapper->setMapping(mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), Qt::Key_Backspace); |
|
685 break; |
|
686 } |
|
687 case 1: { |
|
688 mButtonLayout->addItem(mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), 2, 9); |
|
689 setButtonObjectName(*mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), 2, 9, Qt::Key_Enter); |
|
690 mReleaseMapper->setMapping(mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), Qt::Key_Enter); |
|
691 mPressMapper->setMapping(mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), Qt::Key_Enter); |
|
692 break; |
|
693 } |
|
694 case 2: { |
|
695 mButtonLayout->addItem(mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), 3, 0); |
|
696 setButtonObjectName(*mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), 3, 0, Qt::Key_Shift); |
|
697 mReleaseMapper->setMapping(mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), Qt::Key_Shift); |
|
698 mPressMapper->setMapping(mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), Qt::Key_Shift); |
|
699 break; |
|
700 } |
|
701 case 3: { |
|
702 mButtonLayout->addItem(mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), 3, 1); |
|
703 setButtonObjectName(*mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), 3, 1, Qt::Key_Control); |
|
704 mReleaseMapper->setMapping(mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), Qt::Key_Control); |
|
705 mPressMapper->setMapping(mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), Qt::Key_Control); |
|
706 break; |
|
707 } |
|
708 case 4: { |
|
709 mButtonLayout->addItem(mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), 3, 4, 1, 2); |
|
710 setButtonObjectName(*mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), 3, 4, Qt::Key_Space); |
|
711 mReleaseMapper->setMapping(mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), Qt::Key_Space); |
|
712 mPressMapper->setMapping(mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), Qt::Key_Space); |
|
713 break; |
|
714 } |
|
715 default: |
|
716 break; |
|
717 } |
|
718 } |
|
719 q->setupToolCluster(); |
|
720 if (mSettingsButton) { |
|
721 mSettingsButton->setObjectName(HbCustomButtonObjName + QString::number(2)); |
|
722 mButtonLayout->addItem(mSettingsButton, 3, 8); |
|
723 } |
|
724 if (mApplicationButton) { |
|
725 mApplicationButton->setObjectName(HbCustomButtonObjName + QString::number(3)); |
|
726 mButtonLayout->addItem(mApplicationButton, 3, 9); |
|
727 } |
|
728 |
|
729 setLayoutDimensions(calculateDimensions(q->keypadButtonAreaSize())); |
|
730 } |
|
731 |
|
732 void HbQwertyKeyboardPrivate::initialize4x11Keypad(bool refreshButtonText) |
|
733 { |
|
734 removeExistingSignalMappings(); |
|
735 mKeyboardSize = HbQwerty4x11; |
|
736 Q_Q(HbQwertyKeyboard); |
|
737 const HbKeyboardMap* keymap = mKeymap->keyboard(HbKeyboardVirtualQwerty); |
|
738 if (keymap == 0) { |
|
739 return; |
|
740 } |
|
741 |
|
742 for (int i = 0; i < keymap->keys.count() && i <= HbVirtualQwerty4x11MaxKeysCount; ++i) { |
|
743 if (refreshButtonText) { |
|
744 mButtons[i]->setText(textForKey(i)); |
|
745 mButtons[i]->setKeyCode(keymap->keys.at(i)->keycode.unicode()); |
|
746 } |
|
747 mReleaseMapper->setMapping(mButtons.at(i), keymap->keys.at(i)->keycode.unicode()); |
|
748 mPressMapper->setMapping(mButtons.at(i), keymap->keys.at(i)->keycode.unicode()); |
|
749 int row = 0; |
|
750 int column = 0; |
|
751 if (i < 11) { |
|
752 row = 0; |
|
753 column = i; |
|
754 } else if (i < 21) { |
|
755 row = 1; |
|
756 column = i-11; |
|
757 } else if (i < 31) { |
|
758 row = 2; |
|
759 column = i-21; |
|
760 } else { |
|
761 row = 3; |
|
762 column = i-31; |
|
763 if (column == 0) { |
|
764 column = 2; |
|
765 } else if (column == 1) { |
|
766 column = 3; |
|
767 } else if (column == 2) { |
|
768 column = 6; |
|
769 } else if (column == 3) { |
|
770 column = 7; |
|
771 } else if (column == 4) { |
|
772 column = 8; |
|
773 } |
|
774 } |
|
775 mButtonLayout->addItem(mButtons.at(i), row, column); |
|
776 setButtonObjectName(*mButtons.at(i), row, column, Qt::Key_unknown); |
|
777 if (i >= HbVirtualQwerty4x10MaxKeysCount) { |
|
778 mButtons[i]->show(); |
|
779 } |
|
780 } |
|
781 |
|
782 for (int i = 0; i < 5; ++i) { |
|
783 switch ( i ) { |
|
784 case 0: { |
|
785 mButtonLayout->addItem(mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), 1, 10); |
|
786 setButtonObjectName(*mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), 1, 10, Qt::Key_Backspace); |
|
787 mReleaseMapper->setMapping(mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), Qt::Key_Backspace); |
|
788 mPressMapper->setMapping(mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), Qt::Key_Backspace); |
|
789 break; |
|
790 } |
|
791 case 1: { |
|
792 mButtonLayout->addItem(mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), 2, 10); |
|
793 setButtonObjectName(*mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), 2, 10, Qt::Key_Enter); |
|
794 mReleaseMapper->setMapping(mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), Qt::Key_Enter); |
|
795 mPressMapper->setMapping(mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), Qt::Key_Enter); |
|
796 break; |
|
797 } |
|
798 case 2: { |
|
799 mButtonLayout->addItem(mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), 3, 0); |
|
800 setButtonObjectName(*mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), 3, 0, Qt::Key_Shift); |
|
801 mReleaseMapper->setMapping(mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), Qt::Key_Shift); |
|
802 mPressMapper->setMapping(mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), Qt::Key_Shift); |
|
803 break; |
|
804 } |
|
805 case 3: { |
|
806 mButtonLayout->addItem(mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), 3, 1); |
|
807 setButtonObjectName(*mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), 3, 1, Qt::Key_Control); |
|
808 mReleaseMapper->setMapping(mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), Qt::Key_Control); |
|
809 mPressMapper->setMapping(mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), Qt::Key_Control); |
|
810 break; |
|
811 } |
|
812 case 4: { |
|
813 mButtonLayout->addItem(mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), 3, 4, 1, 2); |
|
814 setButtonObjectName(*mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), 3, 4, Qt::Key_Space); |
|
815 mReleaseMapper->setMapping(mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), Qt::Key_Space); |
|
816 mPressMapper->setMapping(mButtons.at(HbVirtualQwerty4x11MaxKeysCount+i), Qt::Key_Space); |
|
817 break; |
|
818 } |
|
819 default: |
|
820 break; |
|
821 } |
|
822 } |
|
823 |
|
824 q->setupToolCluster(); |
|
825 if (mSettingsButton) { |
|
826 mSettingsButton->setObjectName(HbCustomButtonObjName + QString::number(2)); |
|
827 mButtonLayout->addItem(mSettingsButton, 3, 9); |
|
828 } |
|
829 if (mApplicationButton) { |
|
830 mApplicationButton->setObjectName(HbCustomButtonObjName + QString::number(3)); |
|
831 mButtonLayout->addItem(mApplicationButton, 3, 10); |
|
832 } |
|
833 |
|
834 setLayoutDimensions(calculateDimensions(q->keypadButtonAreaSize())); |
|
835 } |
|
836 |
|
837 bool HbQwertyKeyboardPrivate::showPreview(int keycode) |
|
838 { |
|
839 if (keycode == Qt::Key_Enter || |
|
840 keycode == Qt::Key_Shift || |
|
841 keycode == Qt::Key_Control || |
|
842 keycode == Qt::Key_Backspace || |
|
843 keycode == Qt::Key_Space) { |
|
844 return false; |
|
845 } |
|
846 return true; |
|
847 } |
|
848 |
|
849 void HbQwertyKeyboardPrivate::setButtonObjectName(HbTouchKeypadButton& button, int row, int column, Qt::Key specialKey) |
|
850 { |
|
851 // bs, enter, more, pred, .com, space, 123sym, shift |
|
852 QString objName; |
|
853 switch(specialKey) { |
|
854 case Qt::Key_Enter: |
|
855 objName = HbEnterObjName; |
|
856 break; |
|
857 case Qt::Key_Shift: |
|
858 objName = HbShiftObjName; |
|
859 break; |
|
860 case Qt::Key_Control: |
|
861 objName = HbControlObjName; |
|
862 break; |
|
863 case Qt::Key_Backspace: |
|
864 objName = HbBackspaceObjName; |
|
865 break; |
|
866 case Qt::Key_Space: |
|
867 objName = HbSpaceObjName; |
|
868 break; |
|
869 default: |
|
870 objName = (HbButtonObjName + QString::number(row+1) + "," + QString::number(column+1) ); |
|
871 break; |
|
872 } |
|
873 button.setObjectName(objName); |
|
874 } |
|
875 |
|
876 /*! |
|
877 Apply editor constraints to the vkb |
|
878 */ |
|
879 void HbQwertyKeyboardPrivate::applyEditorConstraints() |
|
880 { |
|
881 HbInputFocusObject *focusedObject = 0; |
|
882 if (mOwner) { |
|
883 focusedObject = mOwner->focusObject(); |
|
884 } |
|
885 |
|
886 if(!focusedObject || isKeyboardDimmed()) { |
|
887 // dont need to apply constraints when keypad is dimmed. |
|
888 // applyEditorConstraints will be called from setKeyboardDimmed(false) |
|
889 return; |
|
890 } |
|
891 |
|
892 for (int i = 0; i < mButtons.count(); i++) { |
|
893 if(Hb::ItemType_InputCharacterButton == mButtons.at(i)->type()) { |
|
894 QString buttonText = mButtons.at(i)->text(); |
|
895 if (buttonText.isEmpty() || !focusedObject->characterAllowedInEditor(buttonText[0])) { |
|
896 mButtons.at(i)->setFade(true); |
|
897 } else { |
|
898 mButtons.at(i)->setFade(false); |
|
899 } |
|
900 } |
|
901 } |
|
902 } |
|
903 |
|
904 // |
|
905 // HbQwertyKeyboard |
|
906 // |
|
907 |
|
908 /*! |
|
909 \deprecated HbQwertyKeyboard::HbQwertyKeyboard(HbInputMethod*, const HbKeymap*, QGraphicsItem*, HbKeypadMode) |
|
910 is deprecated. |
|
911 */ |
|
912 HbQwertyKeyboard::HbQwertyKeyboard(HbInputMethod* owner, |
|
913 const HbKeymap* keymap, |
|
914 QGraphicsItem* aParent, HbKeypadMode mode) |
|
915 : HbInputVkbWidget(*new HbQwertyKeyboardPrivate, aParent) |
|
916 { |
|
917 Q_D(HbQwertyKeyboard); |
|
918 d->mKeymap = keymap; |
|
919 d->mClickMapper = new QSignalMapper(this); |
|
920 d->q_ptr = this; |
|
921 d->mOwner = owner; |
|
922 |
|
923 d->mButtonLayout = new QGraphicsGridLayout(); |
|
924 |
|
925 // character preview pane |
|
926 d->mPreviewPane = new HbCharPreviewPane(); |
|
927 connect(d->mPreviewPane, SIGNAL(charFromPreviewSelected(QString)), this, SIGNAL(charFromPreviewSelected(QString))); |
|
928 // A QGraphicsItem bydefault is shown so we need to hide it. |
|
929 d->mPreviewPane->hide(); |
|
930 |
|
931 d->mMode = mode; |
|
932 } |
|
933 |
|
934 /*! |
|
935 \deprecated HbQwertyKeyboard::HbQwertyKeyboard(HbQwertyKeyboardPrivate&, QGraphicsItem*) |
|
936 is deprecated. |
|
937 */ |
|
938 HbQwertyKeyboard::HbQwertyKeyboard(HbQwertyKeyboardPrivate &dd, QGraphicsItem* parent) |
|
939 : HbInputVkbWidget(dd, parent) |
|
940 { |
|
941 } |
|
942 |
|
943 /*! |
|
944 \deprecated HbQwertyKeyboard::~HbQwertyKeyboard() |
|
945 is deprecated. |
|
946 */ |
|
947 HbQwertyKeyboard::~HbQwertyKeyboard() |
|
948 { |
|
949 } |
|
950 |
|
951 /*! |
|
952 \reimp |
|
953 \deprecated HbQwertyKeyboard::keyboardType() const |
|
954 is deprecated. |
|
955 */ |
|
956 HbKeyboardType HbQwertyKeyboard::keyboardType() const |
|
957 { |
|
958 return HbKeyboardVirtualQwerty; |
|
959 } |
|
960 |
|
961 /*! |
|
962 \reimp |
|
963 \deprecated HbQwertyKeyboard::setMode(HbKeypadMode, QFlags<HbModifier>) |
|
964 is deprecated. |
|
965 */ |
|
966 void HbQwertyKeyboard::setMode(HbKeypadMode mode, HbModifiers modifiers) |
|
967 { |
|
968 Q_D(HbQwertyKeyboard); |
|
969 |
|
970 if(d->mMode == EModeNumeric && d->mKeypadCreated) { |
|
971 // for numeric edito we need to update sct character button everytime |
|
972 // we move between editors. ( dialer editor, digits only, formatted editor ect) |
|
973 d->updateButtonsTextAndMappers(); |
|
974 } |
|
975 |
|
976 setupToolCluster(); |
|
977 if (d->mMode == mode && d->mModifiers == modifiers && d->mKeypadCreated && !d->mKeymapChanged) { |
|
978 d->applyEditorConstraints(); |
|
979 return; |
|
980 } |
|
981 |
|
982 d->mMode = mode; |
|
983 d->mModifiers = modifiers; |
|
984 |
|
985 const HbKeyboardMap* keymap = d->mKeymap->keyboard(HbKeyboardVirtualQwerty); |
|
986 if (keymap == 0) { |
|
987 return; |
|
988 } |
|
989 |
|
990 int keymapCount = keymap->keys.count(); |
|
991 |
|
992 if (!d->mKeypadCreated |
|
993 || (keymapCount == HbVirtualQwerty4x10MaxKeysCount && d->mKeyboardSize == HbQwertyKeyboardPrivate::HbQwerty4x11) |
|
994 || (keymapCount == HbVirtualQwerty4x11MaxKeysCount && d->mKeyboardSize == HbQwertyKeyboardPrivate::HbQwerty4x10)) { |
|
995 if (!d->mKeypadCreated) { |
|
996 d->constructKeypad(); |
|
997 d->initializeKeyboard(false); |
|
998 } else { |
|
999 d->initializeKeyboard(true); |
|
1000 } |
|
1001 d->applyEditorConstraints(); |
|
1002 d->setRockerPosition(); |
|
1003 return; |
|
1004 } |
|
1005 if (d->mMode == EModeNumeric) { |
|
1006 // Numeric keyboard does not change mode |
|
1007 return; |
|
1008 } |
|
1009 d->updateButtonsTextAndMappers(); |
|
1010 d->applyEditorConstraints(); |
|
1011 } |
|
1012 |
|
1013 /*! |
|
1014 \reimp |
|
1015 \deprecated HbQwertyKeyboard::setKeymap(const HbKeymap*) |
|
1016 is deprecated. |
|
1017 */ |
|
1018 void HbQwertyKeyboard::setKeymap(const HbKeymap* keymap) |
|
1019 { |
|
1020 Q_D(HbQwertyKeyboard); |
|
1021 if (keymap) { |
|
1022 d->mKeymap = keymap; |
|
1023 d->mKeymapChanged = true; |
|
1024 // let's change the button text depending on the new keymapping. |
|
1025 HbInputState newState = d->mOwner->inputState(); |
|
1026 if (newState.textCase() == HbTextCaseUpper || newState.textCase() == HbTextCaseAutomatic) { |
|
1027 setMode(d->mMode, HbModifierShiftPressed); |
|
1028 } else { |
|
1029 setMode(d->mMode, HbModifierNone); |
|
1030 } |
|
1031 d->mKeymapChanged = false; |
|
1032 } |
|
1033 } |
|
1034 |
|
1035 /*! |
|
1036 \reimp |
|
1037 \deprecated HbQwertyKeyboard::aboutToOpen(HbVkbHost*) |
|
1038 */ |
|
1039 void HbQwertyKeyboard::aboutToOpen(HbVkbHost *host) |
|
1040 { |
|
1041 Q_D(HbQwertyKeyboard); |
|
1042 |
|
1043 HbInputVkbWidget::aboutToOpen(host); |
|
1044 |
|
1045 d->setLayoutDimensions(d->calculateDimensions(keypadButtonAreaSize())); |
|
1046 } |
|
1047 |
|
1048 /*! |
|
1049 \reimp |
|
1050 \deprecated HbQwertyKeyboard::preferredKeyboardSize() |
|
1051 */ |
|
1052 QSizeF HbQwertyKeyboard::preferredKeyboardSize() |
|
1053 { |
|
1054 Q_D(HbQwertyKeyboard); |
|
1055 |
|
1056 QSizeF result = HbInputVkbWidget::preferredKeyboardSize(); |
|
1057 |
|
1058 if (d->mMode == EModeNumeric) { |
|
1059 //We need to subtract the height of the close handle from prefered size of keypad |
|
1060 //before calculating the height of each row. |
|
1061 qreal height = (result.height() - HbCloseHandleHeight) / (qreal)HbVirtualQwertyNumberOfRows; |
|
1062 result.setHeight(HbVirtualQwertyNumberOfRowsNumberMode * height + HbCloseHandleHeight); |
|
1063 } |
|
1064 |
|
1065 return QSizeF(result); |
|
1066 } |
|
1067 |
|
1068 /*! |
|
1069 \deprecated HbQwertyKeyboard::previewCharacters(const QStringList&) |
|
1070 is deprecated. |
|
1071 */ |
|
1072 bool HbQwertyKeyboard::previewCharacters(const QStringList& characters) |
|
1073 { |
|
1074 Q_D(HbQwertyKeyboard); |
|
1075 |
|
1076 // Don't do anything if the current button index is not in the range. |
|
1077 if (d->mPressedButtonIndex < 0 || d->mPressedButtonIndex > d->mButtons.size()) { |
|
1078 return false; |
|
1079 } |
|
1080 |
|
1081 // let's set mLongKeyPressCharsShown. Since if the long press preview pane is On |
|
1082 // we should not close the preview pane when the button is released. |
|
1083 if (!d->mInStickyRegion) { |
|
1084 if (characters.count()) { |
|
1085 // we should not show the long press preview pane if the character size is 1 and matches with |
|
1086 // the the button text. |
|
1087 if (characters.count() == 1 |
|
1088 && (d->mButtons.at(d->mPressedButtonIndex)->text().compare(characters.at(0)) == 0)) { |
|
1089 d->mLongKeyPressCharsShown = false; |
|
1090 } else { |
|
1091 d->launchPreviewPane(characters); |
|
1092 d->mLongKeyPressCharsShown = true; |
|
1093 } |
|
1094 } else { |
|
1095 d->mLongKeyPressCharsShown = false; |
|
1096 } |
|
1097 } else { |
|
1098 // This situation is not likely to happen as we might have closed |
|
1099 // the preview pane in enteredInNonStickyRegion function. |
|
1100 if (d->mPreviewPane->isVisible()) { |
|
1101 d->mPreviewPane->hide(); |
|
1102 } |
|
1103 d->mLongKeyPressCharsShown = false; |
|
1104 } |
|
1105 |
|
1106 // let's inform the caller that there preview is not possible with the |
|
1107 // character set sent. |
|
1108 return d->mLongKeyPressCharsShown; |
|
1109 } |
|
1110 |
|
1111 /*! |
|
1112 \reimp |
|
1113 \deprecated HbQwertyKeyboard::aboutToClose(HbVkbHost*) |
|
1114 */ |
|
1115 void HbQwertyKeyboard::aboutToClose(HbVkbHost *host) |
|
1116 { |
|
1117 Q_UNUSED(host); |
|
1118 Q_D(HbQwertyKeyboard); |
|
1119 // Let's hide the preview pane. |
|
1120 if (d->mPreviewPane->isVisible()) { |
|
1121 d->mPreviewPane->hide(); |
|
1122 } |
|
1123 // reset the states as the keypad is closing |
|
1124 d->mLongKeyPressCharsShown = false; |
|
1125 d->mInStickyRegion = true; |
|
1126 |
|
1127 HbInputVkbWidget::aboutToClose(host); |
|
1128 } |
|
1129 |
|
1130 /*! |
|
1131 \deprecated HbQwertyKeyboard::initSctModeList() |
|
1132 is deprecated. Sct mode list is not supported anymore. |
|
1133 */ |
|
1134 void HbQwertyKeyboard::initSctModeList() |
|
1135 { |
|
1136 } |
|
1137 |
|
1138 /*! |
|
1139 \deprecated HbQwertyKeyboard::sctModeListClosed() |
|
1140 is deprecated. Sct mode list is not supported anymore. |
|
1141 */ |
|
1142 void HbQwertyKeyboard::sctModeListClosed() |
|
1143 { |
|
1144 } |
|
1145 |
|
1146 /*! |
|
1147 \deprecated HbQwertyKeyboard::enteredInNonStickyRegion() |
|
1148 is deprecated. |
|
1149 */ |
|
1150 void HbQwertyKeyboard::enteredInNonStickyRegion() |
|
1151 { |
|
1152 Q_D(HbQwertyKeyboard); |
|
1153 if (d->mPreviewPane->isVisible()) { |
|
1154 d->mPreviewPane->hide(); |
|
1155 } |
|
1156 d->mInStickyRegion = true; |
|
1157 d->mLongKeyPressCharsShown = false; |
|
1158 } |
|
1159 |
|
1160 /*! |
|
1161 \deprecated HbQwertyKeyboard::mappedKeyClick(int) |
|
1162 is deprecated and will be removed. |
|
1163 */ |
|
1164 void HbQwertyKeyboard::mappedKeyClick(int buttonid) |
|
1165 { |
|
1166 Q_UNUSED(buttonid); |
|
1167 } |
|
1168 // End of file |
|