|
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 HbPlugins 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 <hbdeviceprofile.h> |
|
27 |
|
28 #include <hbinputmethod.h> |
|
29 #include <hbinputkeymap.h> |
|
30 #include <hbinputsettingproxy.h> |
|
31 |
|
32 #include "hbinputqwerty11x4touchkeyboard.h" |
|
33 #include "hbinputqwerty11x4touchkeyboard_p.h" |
|
34 #include "hbinputvkbwidget_p.h" |
|
35 #include "hbinputbuttongroup.h" |
|
36 #include "hbinputbutton.h" |
|
37 #include "hbinputmodeindicator.h" |
|
38 |
|
39 const qreal HbKeyboardHeightInUnits = 34.6; |
|
40 const qreal HbKeyboardWidthInUnits = 95.5; |
|
41 |
|
42 const int HbVirtualQwertyNumberOfRows = 4; |
|
43 const int HbVirtualQwertyNumberOfColumns = 11; |
|
44 const int HbButtonKeyCodeTable[HbVirtualQwertyNumberOfRows * HbVirtualQwertyNumberOfColumns - 1] = |
|
45 { |
|
46 HbInputButton::ButtonKeyCodeCharacter, |
|
47 HbInputButton::ButtonKeyCodeCharacter, |
|
48 HbInputButton::ButtonKeyCodeCharacter, |
|
49 HbInputButton::ButtonKeyCodeCharacter, |
|
50 HbInputButton::ButtonKeyCodeCharacter, |
|
51 HbInputButton::ButtonKeyCodeCharacter, |
|
52 HbInputButton::ButtonKeyCodeCharacter, |
|
53 HbInputButton::ButtonKeyCodeCharacter, |
|
54 HbInputButton::ButtonKeyCodeCharacter, |
|
55 HbInputButton::ButtonKeyCodeCharacter, |
|
56 HbInputButton::ButtonKeyCodeCharacter, |
|
57 HbInputButton::ButtonKeyCodeCharacter, |
|
58 HbInputButton::ButtonKeyCodeCharacter, |
|
59 HbInputButton::ButtonKeyCodeCharacter, |
|
60 HbInputButton::ButtonKeyCodeCharacter, |
|
61 HbInputButton::ButtonKeyCodeCharacter, |
|
62 HbInputButton::ButtonKeyCodeCharacter, |
|
63 HbInputButton::ButtonKeyCodeCharacter, |
|
64 HbInputButton::ButtonKeyCodeCharacter, |
|
65 HbInputButton::ButtonKeyCodeCharacter, |
|
66 HbInputButton::ButtonKeyCodeCharacter, |
|
67 HbInputButton::ButtonKeyCodeDelete, |
|
68 HbInputButton::ButtonKeyCodeCharacter, |
|
69 HbInputButton::ButtonKeyCodeCharacter, |
|
70 HbInputButton::ButtonKeyCodeCharacter, |
|
71 HbInputButton::ButtonKeyCodeCharacter, |
|
72 HbInputButton::ButtonKeyCodeCharacter, |
|
73 HbInputButton::ButtonKeyCodeCharacter, |
|
74 HbInputButton::ButtonKeyCodeCharacter, |
|
75 HbInputButton::ButtonKeyCodeCharacter, |
|
76 HbInputButton::ButtonKeyCodeCharacter, |
|
77 HbInputButton::ButtonKeyCodeCharacter, |
|
78 HbInputButton::ButtonKeyCodeEnter, |
|
79 HbInputButton::ButtonKeyCodeShift, |
|
80 HbInputButton::ButtonKeyCodeSymbol, |
|
81 HbInputButton::ButtonKeyCodeCharacter, |
|
82 HbInputButton::ButtonKeyCodeCharacter, |
|
83 HbInputButton::ButtonKeyCodeSpace, |
|
84 HbInputButton::ButtonKeyCodeCharacter, |
|
85 HbInputButton::ButtonKeyCodeCharacter, |
|
86 HbInputButton::ButtonKeyCodeCharacter, |
|
87 HbInputButton::ButtonKeyCodeSettings, |
|
88 HbInputButton::ButtonKeyCodeCustom |
|
89 }; |
|
90 |
|
91 HbQwerty11x4KeyboardPrivate::HbQwerty11x4KeyboardPrivate() |
|
92 { |
|
93 } |
|
94 |
|
95 HbQwerty11x4KeyboardPrivate::~HbQwerty11x4KeyboardPrivate() |
|
96 { |
|
97 } |
|
98 |
|
99 void HbQwerty11x4KeyboardPrivate::init() |
|
100 { |
|
101 Q_Q(HbQwerty11x4Keyboard); |
|
102 |
|
103 HbInputVkbWidgetPrivate::init(); |
|
104 |
|
105 HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup*>(q->contentItem()); |
|
106 if (buttonGroup) { |
|
107 buttonGroup->setGridSize(QSize(HbVirtualQwertyNumberOfColumns, HbVirtualQwertyNumberOfRows)); |
|
108 |
|
109 int key = 0; |
|
110 QList<HbInputButton*> buttons; |
|
111 for (int i = 0; i < HbVirtualQwertyNumberOfColumns * HbVirtualQwertyNumberOfRows - 1; ++i) { |
|
112 HbInputButton *item = new HbInputButton(HbButtonKeyCodeTable[i], QPoint(key % HbVirtualQwertyNumberOfColumns, key / HbVirtualQwertyNumberOfColumns)); |
|
113 buttons.append(item); |
|
114 |
|
115 if (HbButtonKeyCodeTable[i] == HbInputButton::ButtonKeyCodeSettings) { |
|
116 mInputModeIndicator = new HbInputModeIndicator(item, q); |
|
117 } else if (HbButtonKeyCodeTable[i] == HbInputButton::ButtonKeyCodeSpace) { |
|
118 item->setSize(QSize(2, 1)); |
|
119 ++key; |
|
120 } |
|
121 ++key; |
|
122 } |
|
123 buttonGroup->setButtons(buttons); |
|
124 buttonGroup->setButtonPreviewEnabled(HbInputSettingProxy::instance()->isCharacterPreviewForQwertyEnabled()); |
|
125 buttonGroup->setCharacterSelectionPreviewEnabled(true); |
|
126 |
|
127 QObject::connect(buttonGroup, SIGNAL(buttonPressed(const QKeyEvent&)), q, SLOT(sendKeyPressEvent(const QKeyEvent&))); |
|
128 QObject::connect(buttonGroup, SIGNAL(buttonDoublePressed(const QKeyEvent&)), q, SLOT(sendKeyDoublePressEvent(const QKeyEvent&))); |
|
129 QObject::connect(buttonGroup, SIGNAL(buttonReleased(const QKeyEvent&)), q, SLOT(sendKeyReleaseEvent(const QKeyEvent&))); |
|
130 QObject::connect(buttonGroup, SIGNAL(buttonLongPressed(const QKeyEvent&)), q, SLOT(sendLongPressEvent(const QKeyEvent&))); |
|
131 QObject::connect(buttonGroup, SIGNAL(pressedButtonChanged(const QKeyEvent&, const QKeyEvent&)), q, SLOT(sendKeyChangeEvent(const QKeyEvent&, const QKeyEvent&))); |
|
132 } |
|
133 |
|
134 QObject::connect(q, SIGNAL(flickEvent(HbInputVkbWidget::HbFlickDirection)), buttonGroup, SLOT(cancelButtonPress())); |
|
135 } |
|
136 |
|
137 int HbQwerty11x4KeyboardPrivate::keyCode(int buttonId) |
|
138 { |
|
139 return HbButtonKeyCodeTable[buttonId]; |
|
140 } |
|
141 |
|
142 void HbQwerty11x4KeyboardPrivate::setRockerPosition() |
|
143 { |
|
144 Q_Q(HbQwerty11x4Keyboard); |
|
145 |
|
146 HbInputVkbWidgetPrivate::setRockerPosition(); |
|
147 |
|
148 HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup*>(q->contentItem()); |
|
149 if (buttonGroup) { |
|
150 QPointF position = mRocker->pos(); |
|
151 position.setX(position.x() + 0.5 * buttonGroup->size().width() / HbVirtualQwertyNumberOfColumns); |
|
152 |
|
153 mRocker->setPos(position); |
|
154 } |
|
155 } |
|
156 |
|
157 /*! |
|
158 Constructs the object. owner is the owning input method implementation. Keymap |
|
159 is key mapping data to be used to display button texts. Key mapping data can be |
|
160 changed later (for example when the input language changes) by calling |
|
161 setKeymap. |
|
162 */ |
|
163 HbQwerty11x4Keyboard::HbQwerty11x4Keyboard(HbInputMethod *owner, const HbKeymap *keymap, QGraphicsItem *parent) |
|
164 : HbQwerty10x4Keyboard(*new HbQwerty11x4KeyboardPrivate, owner, keymap, parent) |
|
165 { |
|
166 Q_D(HbQwerty11x4Keyboard); |
|
167 d->mOwner = owner; |
|
168 setKeymap(keymap); |
|
169 |
|
170 QObject::connect(HbInputSettingProxy::instance(), SIGNAL(characterPreviewStateForQwertyChanged(bool)), this, SLOT(updateButtonPreviewStatus(bool))); |
|
171 } |
|
172 |
|
173 /*! |
|
174 Constructs the object. owner is the owning input method implementation. Keymap |
|
175 is key mapping data to be used to display button texts. Key mapping data can be |
|
176 changed later (for example when the input language changes) by calling |
|
177 setKeymap. |
|
178 */ |
|
179 HbQwerty11x4Keyboard::HbQwerty11x4Keyboard(HbQwerty11x4KeyboardPrivate &dd, HbInputMethod *owner, |
|
180 const HbKeymap *keymap, QGraphicsItem *parent) |
|
181 : HbQwerty10x4Keyboard(dd, owner, keymap, parent) |
|
182 { |
|
183 Q_D(HbQwerty11x4Keyboard); |
|
184 d->mOwner = owner; |
|
185 setKeymap(keymap); |
|
186 |
|
187 QObject::connect(HbInputSettingProxy::instance(), SIGNAL(characterPreviewStateForQwertyChanged(bool)), this, SLOT(updateButtonPreviewStatus(bool))); |
|
188 } |
|
189 |
|
190 /*! |
|
191 Destructs the object. |
|
192 */ |
|
193 HbQwerty11x4Keyboard::~HbQwerty11x4Keyboard() |
|
194 { |
|
195 } |
|
196 |
|
197 // End of file |