equal
deleted
inserted
replaced
20 ** |
20 ** |
21 ** If you have questions regarding the use of this file, please contact |
21 ** If you have questions regarding the use of this file, please contact |
22 ** Nokia at developer.feedback@nokia.com. |
22 ** Nokia at developer.feedback@nokia.com. |
23 ** |
23 ** |
24 ****************************************************************************/ |
24 ****************************************************************************/ |
|
25 #include "hbinputvkbhost.h" |
|
26 |
25 #include <QVariant> |
27 #include <QVariant> |
26 |
28 |
27 #include "hbinputvkbhost.h" |
|
28 #include "hbinputmethod.h" |
29 #include "hbinputmethod.h" |
29 |
30 |
30 const char HbVkbHostPropertyName[] = "HbVkbHost"; |
31 const char HbVkbHostPropertyName[] = "HbVkbHost"; |
31 |
32 |
32 /*! |
33 /*! |
45 Virtual keyboard host also knows how to keep the editor cursor visible at all times |
46 Virtual keyboard host also knows how to keep the editor cursor visible at all times |
46 so that the virtual keyboard widget never covers it. Application developer or editor widget |
47 so that the virtual keyboard widget never covers it. Application developer or editor widget |
47 developer doesn't need to care about that. |
48 developer doesn't need to care about that. |
48 |
49 |
49 There can be several vkb hosts in the system because in some situations the keyboard |
50 There can be several vkb hosts in the system because in some situations the keyboard |
50 needs to behave differently than in others. |
51 needs to behave differently than in others. |
51 |
52 |
52 The input framework finds active vkb host by traversing editor widget's parent chain |
53 The input framework finds active vkb host by traversing editor widget's parent chain |
53 to see if there is a host attached to editor widget or any of its parents. If |
54 to see if there is a host attached to editor widget or any of its parents. If |
54 it doesn't find a suitable host, it uses the default host. |
55 it doesn't find a suitable host, it uses the default host. |
55 |
56 |
59 \sa HbVirtualKeyboard |
60 \sa HbVirtualKeyboard |
60 \sa HbEditorInterface |
61 \sa HbEditorInterface |
61 */ |
62 */ |
62 |
63 |
63 /*! |
64 /*! |
64 \fn virtual void HbVkbHost::openKeypad(HbVirtualKeyboard *vkb, bool animationAllowed = true) |
65 \fn virtual void HbVkbHost::openKeypad(HbVirtualKeyboard *vkb, HbInputMethod *owner, bool animationAllowed = true) |
65 Opens given virtual keyboard. If animation is used, emits signal |
66 Opens given virtual keyboard. If animation is used, emits signal |
66 keypadOpened after animation is completed. |
67 keypadOpened after animation is completed. |
67 */ |
68 */ |
68 |
69 |
69 /*! |
70 /*! |
76 Returns true if virtual keypad is open on the screen. |
77 Returns true if virtual keypad is open on the screen. |
77 */ |
78 */ |
78 |
79 |
79 /*! |
80 /*! |
80 \fn virtual QSizeF HbVkbHost::keyboardArea() const |
81 \fn virtual QSizeF HbVkbHost::keyboardArea() const |
81 Returns the size of a rectangular area of the screen where virtual keyboard will be displayed. If |
82 Returns the size of a rectangular area of the screen where virtual keyboard will be displayed. If |
82 virtual keyboard's preferredKeyboardSize method returns larger area than returned by this method, |
83 virtual keyboard's preferredKeyboardSize method returns larger area than returned by this method, |
83 the vkb host will shrink keyboard to fit into this rectangle. |
84 the vkb host will shrink keyboard to fit into this rectangle. |
84 */ |
85 */ |
85 |
86 |
86 /*! |
87 /*! |
87 \fn virtual HbVirtualKeyboard* activeKeypad() const = 0 |
88 \fn virtual HbVirtualKeyboard* activeKeypad() const = 0 |
88 Returns active virtual keyboard. Returns zero if there is no active keyboard. |
89 Returns active virtual keyboard. Returns zero if there is no active keyboard. |
113 */ |
114 */ |
114 |
115 |
115 /*! |
116 /*! |
116 Attaches given host to given object. Deletes previously attached host. |
117 Attaches given host to given object. Deletes previously attached host. |
117 */ |
118 */ |
118 void HbVkbHost::attachHost(HbVkbHost* host, QObject* object) |
119 void HbVkbHost::attachHost(HbVkbHost *host, QObject *object) |
119 { |
120 { |
120 if (object) { |
121 if (object) { |
121 delete getVkbHost(object); // delete previous host. |
122 delete getVkbHost(object); // delete previous host. |
122 QObject *hostObject = host; |
123 QObject *hostObject = host; |
123 QVariant hostData = qVariantFromValue(hostObject); |
124 QVariant hostData = qVariantFromValue(hostObject); |
126 } |
127 } |
127 |
128 |
128 /*! |
129 /*! |
129 Removes (possible) vkb host from given object. |
130 Removes (possible) vkb host from given object. |
130 */ |
131 */ |
131 void HbVkbHost::detachHost(QObject* object) |
132 void HbVkbHost::detachHost(QObject *object) |
132 { |
133 { |
133 if (object) { |
134 if (object) { |
134 QObject *hostObject = 0; |
135 QObject *hostObject = 0; |
135 QVariant hostData = qVariantFromValue(hostObject); |
136 QVariant hostData = qVariantFromValue(hostObject); |
136 object->setProperty(HbVkbHostPropertyName, hostData); |
137 object->setProperty(HbVkbHostPropertyName, hostData); |
144 HbVkbHost *HbVkbHost::getVkbHost(QObject *object) |
145 HbVkbHost *HbVkbHost::getVkbHost(QObject *object) |
145 { |
146 { |
146 if (object) { |
147 if (object) { |
147 QVariant variant = object->property(HbVkbHostPropertyName); |
148 QVariant variant = object->property(HbVkbHostPropertyName); |
148 if (variant.isValid()) { |
149 if (variant.isValid()) { |
149 QObject *hostObject = variant.value<QObject*>(); |
150 QObject *hostObject = variant.value<QObject *>(); |
150 HbVkbHost *host = static_cast<HbVkbHost*>(hostObject); |
151 HbVkbHost *host = static_cast<HbVkbHost *>(hostObject); |
151 return host; |
152 return host; |
152 } |
153 } |
153 } |
154 } |
154 |
155 |
155 return 0; |
156 return 0; |
156 } |
157 } |
157 |
158 |
158 /*! |
159 /*! |
159 Returns active virtual keyboard host if there is one currently available. |
160 Returns active virtual keyboard host if there is one currently available. |
160 */ |
161 */ |
161 HbVkbHost *HbVkbHost::activeVkbHost() |
162 HbVkbHost *HbVkbHost::activeVkbHost() |
162 { |
163 { |
163 HbInputMethod *activeMethod = HbInputMethod::activeInputMethod(); |
164 HbInputMethod *activeMethod = HbInputMethod::activeInputMethod(); |
164 if (activeMethod && activeMethod->focusObject()) { |
165 if (activeMethod && activeMethod->focusObject()) { |