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 <hbinputsettingproxy.h> |
32 |
33 |
33 /*! |
34 /*! |
34 @alpha |
35 @alpha |
35 @hbcore |
36 @hbcore |
36 \class HbInputContextProxy |
37 \class HbInputContextProxy |
91 \internal |
92 \internal |
92 Sets input framework focus to given widget if it is valid. |
93 Sets input framework focus to given widget if it is valid. |
93 */ |
94 */ |
94 void HbInputContextProxy::setInputFrameworkFocus(QObject *widget) |
95 void HbInputContextProxy::setInputFrameworkFocus(QObject *widget) |
95 { |
96 { |
96 if(mTarget) { |
97 if (mTarget) { |
97 if(!widget) { |
98 if (!widget) { |
98 mTarget->setFocusObject(0); |
99 mTarget->setFocusObject(0); |
99 } else if (HbInputFocusObject::isEditor(widget) && !HbInputFocusObject::isReadOnlyWidget(widget)) { |
100 } else if (HbInputFocusObject::isEditor(widget) && !HbInputFocusObject::isReadOnlyWidget(widget)) { |
100 mTarget->setFocusObject(new HbInputFocusObject(widget)); |
101 mTarget->setFocusObject(new HbInputFocusObject(widget)); |
101 } |
102 } |
102 } |
103 } |
103 } |
104 } |
104 |
105 |
105 /*! |
106 /*! |
106 \internal |
107 \internal |
107 \reimp |
108 \reimp |
108 */ |
109 */ |
109 bool HbInputContextProxy::filterEvent(const QEvent* event) |
110 bool HbInputContextProxy::filterEvent(const QEvent *event) |
110 { |
111 { |
111 if (mTarget) { |
112 if (mTarget) { |
112 #if QT_VERSION >= 0x040600 |
113 #if QT_VERSION >= 0x040600 |
113 if (event->type() == QEvent::CloseSoftwareInputPanel) { |
114 bool orientationCompleted = HbInputSettingProxy::instance()->orientationChangeCompleted(); |
|
115 if (event->type() == QEvent::CloseSoftwareInputPanel && orientationCompleted) { |
114 setInputFrameworkFocus(0); |
116 setInputFrameworkFocus(0); |
115 return true; |
117 return true; |
116 } else if (event->type() == QEvent::RequestSoftwareInputPanel) { |
118 } else if (event->type() == QEvent::RequestSoftwareInputPanel && orientationCompleted) { |
117 if(QWidget * focusedWidget = qApp->focusWidget()) { |
119 if (QWidget *focusedWidget = qApp->focusWidget()) { |
118 // see if the focused widget is graphics view, if so get the focused graphics item in the view |
120 // see if the focused widget is graphics view, if so get the focused graphics item in the view |
119 // and acivate inputmethod for the focused graphics item |
121 // and acivate inputmethod for the focused graphics item |
120 if (QGraphicsView * graphicsView = qobject_cast<QGraphicsView*>(focusedWidget)) { |
122 if (QGraphicsView *graphicsView = qobject_cast<QGraphicsView *>(focusedWidget)) { |
121 if (QGraphicsScene * scene = graphicsView->scene()) { |
123 if (QGraphicsScene *scene = graphicsView->scene()) { |
122 if (QGraphicsItem * fItem = scene->focusItem()) { |
124 if (QGraphicsItem *fItem = scene->focusItem()) { |
123 QGraphicsProxyWidget *proxy = qgraphicsitem_cast<QGraphicsProxyWidget *>(fItem); |
125 QGraphicsProxyWidget *proxy = qgraphicsitem_cast<QGraphicsProxyWidget *>(fItem); |
124 if (proxy) { |
126 if (proxy) { |
125 setInputFrameworkFocus(proxy->widget()->focusWidget()); |
127 setInputFrameworkFocus(proxy->widget()->focusWidget()); |
126 } else { |
128 } else { |
127 setInputFrameworkFocus(static_cast<QGraphicsWidget*>(fItem)); |
129 setInputFrameworkFocus(static_cast<QGraphicsWidget *>(fItem)); |
128 } |
130 } |
129 } |
131 } |
130 } |
132 } |
131 } else { |
133 } else { |
132 // focused wiget is not graphics view, let see if it is native qt editor |
134 // focused wiget is not graphics view, let see if it is native qt editor |
140 |
142 |
141 #ifdef Q_OS_SYMBIAN |
143 #ifdef Q_OS_SYMBIAN |
142 const quint32 HbInputContextProxyExternalKeyboardModifier = 0x00200000; |
144 const quint32 HbInputContextProxyExternalKeyboardModifier = 0x00200000; |
143 |
145 |
144 if (event->type() == QEvent::QEvent::KeyPress || event->type() == QEvent::KeyRelease) { |
146 if (event->type() == QEvent::QEvent::KeyPress || event->type() == QEvent::KeyRelease) { |
145 const QKeyEvent *keyEvent = static_cast<const QKeyEvent*>(event); |
147 const QKeyEvent *keyEvent = static_cast<const QKeyEvent *>(event); |
146 if (keyEvent->nativeModifiers() & HbInputContextProxyExternalKeyboardModifier) { |
148 if (keyEvent->nativeModifiers() & HbInputContextProxyExternalKeyboardModifier) { |
147 // Operating system indicates that the event originated from an external keyboard. |
149 // Operating system indicates that the event originated from an external keyboard. |
148 // We let it pass here untouched. |
150 // We let it pass here untouched. |
149 if (mTarget) { |
151 if (mTarget) { |
150 mTarget->reset(); |
152 mTarget->reset(); |
151 } |
153 } |
152 return false; |
154 return false; |
153 } |
155 } |
154 } |
156 } |
155 #endif |
157 #endif |
156 if(event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) { |
158 if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) { |
157 const QKeyEvent *keyEvent = static_cast<const QKeyEvent *>(event); |
159 const QKeyEvent *keyEvent = static_cast<const QKeyEvent *>(event); |
158 if (Qt::Key_unknown == keyEvent->key()) { |
160 if (Qt::Key_unknown == keyEvent->key()) { |
159 return false; |
161 return false; |
160 } |
162 } |
161 } |
163 } |
162 return mTarget->filterEvent(event); |
164 return mTarget->filterEvent(event); |
163 } |
165 } |
164 |
166 |
165 return false; |
167 return false; |
166 } |
168 } |
167 |
169 |
168 /*! |
170 /*! |
169 \internal |
171 \internal |
170 \reimp |
172 \reimp |