27 #include <hbgraphicsscene.h> |
27 #include <hbgraphicsscene.h> |
28 #include <hbinputfocusobject.h> |
28 #include <hbinputfocusobject.h> |
29 #include <QGraphicsProxyWidget> |
29 #include <QGraphicsProxyWidget> |
30 #include <QGraphicsView> |
30 #include <QGraphicsView> |
31 #include <hbinputmethod.h> |
31 #include <hbinputmethod.h> |
|
32 #include <hbinputmethod_p.h> |
32 #include <hbinputsettingproxy.h> |
33 #include <hbinputsettingproxy.h> |
33 |
34 #include <hbinputmethodnull_p.h> |
34 /*! |
35 |
35 @alpha |
36 /*! |
|
37 @stable |
36 @hbcore |
38 @hbcore |
37 \class HbInputContextProxy |
39 \class HbInputContextProxy |
38 \brief A proxy class forwarding calls from QInputContext to HbInputMethod |
40 \brief A proxy class forwarding calls from QInputContext to HbInputMethod |
39 |
41 |
40 This class is needed because Qt's input context system assumes the ownership |
42 This class is needed because Qt's input context system assumes the ownership |
100 } else if (HbInputFocusObject::isEditor(widget) && !HbInputFocusObject::isReadOnlyWidget(widget)) { |
102 } else if (HbInputFocusObject::isEditor(widget) && !HbInputFocusObject::isReadOnlyWidget(widget)) { |
101 if (mTarget->focusObject() && mTarget->focusObject()->object() == widget) { |
103 if (mTarget->focusObject() && mTarget->focusObject()->object() == widget) { |
102 // Already focused to given widget. |
104 // Already focused to given widget. |
103 return; |
105 return; |
104 } |
106 } |
105 mTarget->setFocusObject(new HbInputFocusObject(widget)); |
107 mTarget->setFocusObject(mTarget->d_func()->createAndSetupFocusObject(widget)); |
106 } |
108 } |
107 } |
109 } |
108 } |
110 } |
109 |
111 |
110 /*! |
112 /*! |
111 \internal |
113 \internal |
112 \reimp |
114 \reimp |
113 */ |
115 */ |
114 bool HbInputContextProxy::filterEvent(const QEvent *event) |
116 bool HbInputContextProxy::filterEvent(const QEvent *event) |
115 { |
117 { |
116 if (mTarget) { |
118 if (mTarget) { |
117 bool orientationCompleted = HbInputSettingProxy::instance()->orientationChangeCompleted(); |
119 bool focusLocked = mTarget->d_func()->mFocusLocked; |
118 if (event->type() == QEvent::CloseSoftwareInputPanel && orientationCompleted) { |
120 if (event->type() == QEvent::CloseSoftwareInputPanel && !focusLocked) { |
119 setInputFrameworkFocus(0); |
121 setInputFrameworkFocus(0); |
120 return true; |
122 return true; |
121 } else if (event->type() == QEvent::RequestSoftwareInputPanel && orientationCompleted) { |
123 } else if (event->type() == QEvent::RequestSoftwareInputPanel && !focusLocked) { |
122 if (QWidget *focusedWidget = qApp->focusWidget()) { |
124 if (QWidget *focusedWidget = qApp->focusWidget()) { |
123 // see if the focused widget is graphics view, if so get the focused graphics item in the view |
125 // see if the focused widget is graphics view, if so get the focused graphics item in the view |
124 // and acivate inputmethod for the focused graphics item |
126 // and acivate inputmethod for the focused graphics item |
125 if (QGraphicsView *graphicsView = qobject_cast<QGraphicsView *>(focusedWidget)) { |
127 if (QGraphicsView *graphicsView = qobject_cast<QGraphicsView *>(focusedWidget)) { |
126 if (QGraphicsScene *scene = graphicsView->scene()) { |
128 if (QGraphicsScene *scene = graphicsView->scene()) { |
162 if (Qt::Key_unknown == keyEvent->key()) { |
164 if (Qt::Key_unknown == keyEvent->key()) { |
163 return false; |
165 return false; |
164 } |
166 } |
165 } |
167 } |
166 return mTarget->filterEvent(event); |
168 return mTarget->filterEvent(event); |
|
169 } else { |
|
170 if (event->type() == QEvent::RequestSoftwareInputPanel) { |
|
171 // There is no mTarget. It means that someone is displaying something before |
|
172 // the input framework was initialized. Acknowledge the situation so that |
|
173 // the initializer knows to resend it. See HbApplication::initialize() |
|
174 // method. The empty proxy is installed there. |
|
175 HbInputMethodNull::Instance()->setDelayedPanelRequest(true); |
|
176 return true; |
|
177 } |
167 } |
178 } |
168 |
179 |
169 return false; |
180 return false; |
170 } |
181 } |
171 |
182 |
282 */ |
293 */ |
283 void HbInputContextProxy::setFocusWidget(QWidget *widget) |
294 void HbInputContextProxy::setFocusWidget(QWidget *widget) |
284 { |
295 { |
285 if (mTarget) { |
296 if (mTarget) { |
286 mTarget->setFocusWidget(widget); |
297 mTarget->setFocusWidget(widget); |
|
298 } else { |
|
299 // There is no mTarget. It means that someone is focusing something before |
|
300 // the input framework was initialized. Acknowledge the situation so that |
|
301 // the focus wont get lost. See HbApplication::initialize() |
|
302 // method. The empty proxy is installed there. |
|
303 HbInputMethodNull::Instance()->setFocusWidget(widget); |
287 } |
304 } |
288 } |
305 } |
289 |
306 |
290 // End of file |
307 // End of file |