35 |
35 |
36 #include "hbinputmethod.h" |
36 #include "hbinputmethod.h" |
37 #include "hbinputeditorinterface.h" |
37 #include "hbinputeditorinterface.h" |
38 #include "hbinputvkbhost.h" |
38 #include "hbinputvkbhost.h" |
39 #include "hbinputstandardfilters.h" |
39 #include "hbinputstandardfilters.h" |
|
40 #include "hbdeviceprofile.h" |
40 #include "hbinpututils.h" |
41 #include "hbinpututils.h" |
41 #include "hbnamespace_p.h" |
42 #include "hbnamespace_p.h" |
|
43 #include "hbmainwindow.h" |
42 #include "hbevent.h" |
44 #include "hbevent.h" |
|
45 #include "hbwidget.h" |
|
46 #include "hbinputmainwindow_p.h" |
|
47 |
43 /*! |
48 /*! |
44 @alpha |
49 @alpha |
45 @hbcore |
50 @hbcore |
46 \class HbInputFocusObject |
51 \class HbInputFocusObject |
47 \brief A helper class for accessing editor widget in abstract way. |
52 \brief A helper class for accessing editor widget in abstract way. |
73 textEdit->ensureCursorVisible(); |
78 textEdit->ensureCursorVisible(); |
74 } |
79 } |
75 } |
80 } |
76 } |
81 } |
77 |
82 |
78 |
|
79 class HbInputFocusObjectPrivate |
83 class HbInputFocusObjectPrivate |
80 { |
84 { |
|
85 Q_DECLARE_PUBLIC(HbInputFocusObject) |
|
86 |
81 public: |
87 public: |
82 HbInputFocusObjectPrivate(QObject *focusedObject) |
88 HbInputFocusObjectPrivate(QObject *focusedObject) |
83 : mFocusedObject(focusedObject), |
89 : mFocusedObject(focusedObject), |
84 mEditorInterface(focusedObject) |
90 mEditorInterface(focusedObject) |
85 {} |
91 {} |
86 |
92 |
|
93 HbMainWindow *mainWindow() const; |
|
94 |
87 public: |
95 public: |
|
96 HbInputFocusObject *q_ptr; |
88 QPointer<QObject> mFocusedObject; |
97 QPointer<QObject> mFocusedObject; |
89 HbEditorInterface mEditorInterface; |
98 HbEditorInterface mEditorInterface; |
90 QString mPreEditString; |
99 QString mPreEditString; |
91 }; |
100 }; |
92 |
101 |
|
102 HbMainWindow *HbInputFocusObjectPrivate::mainWindow() const |
|
103 { |
|
104 QWidget *qWidgetObject = qobject_cast<QWidget *>(mFocusedObject); |
|
105 QGraphicsObject *graphicsObject = 0; |
|
106 |
|
107 // check for graphics view related widgets. |
|
108 if (qWidgetObject) { |
|
109 if (qWidgetObject->graphicsProxyWidget()) { |
|
110 graphicsObject = qWidgetObject->graphicsProxyWidget(); |
|
111 } else { |
|
112 return HbInputMainWindow::instance(); |
|
113 } |
|
114 } else { |
|
115 graphicsObject = qobject_cast<QGraphicsObject *>(mFocusedObject); |
|
116 } |
|
117 |
|
118 if (graphicsObject) { |
|
119 if (graphicsObject->scene()) { |
|
120 QList<QGraphicsView*> views = graphicsObject->scene()->views(); |
|
121 foreach (QGraphicsView *view, views) { |
|
122 HbMainWindow *mainWindow = qobject_cast<HbMainWindow*>(view); |
|
123 if (mainWindow) { |
|
124 return mainWindow; |
|
125 } |
|
126 } |
|
127 // not a HbMainWindow. |
|
128 return HbInputMainWindow::instance(); |
|
129 } |
|
130 } |
|
131 |
|
132 return 0; |
|
133 } |
93 |
134 |
94 /// @endcond |
135 /// @endcond |
95 |
136 |
96 HbInputFocusObject::HbInputFocusObject(QObject *focusedObject) |
137 HbInputFocusObject::HbInputFocusObject(QObject *focusedObject) |
97 : d_ptr(new HbInputFocusObjectPrivate(focusedObject)) |
138 : d_ptr(new HbInputFocusObjectPrivate(focusedObject)) |
98 { |
139 { |
|
140 Q_D(HbInputFocusObject); |
|
141 d->q_ptr = this; |
|
142 |
99 if (focusedObject) { |
143 if (focusedObject) { |
100 HbEvent *event = new HbEvent(HbEvent::InputMethodFocusIn); |
144 HbEvent *event = new HbEvent(HbEvent::InputMethodFocusIn); |
101 QCoreApplication::sendEvent(focusedObject, event); |
145 QCoreApplication::sendEvent(focusedObject, event); |
102 delete event; |
146 delete event; |
103 } |
147 |
104 } |
148 HbMainWindow *mainWindow = d->mainWindow(); |
105 |
149 if (mainWindow) { |
|
150 connect(mainWindow, SIGNAL(aboutToChangeOrientation()), this, SIGNAL(aboutToChangeOrientation())); |
|
151 connect(mainWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SIGNAL(orientationChanged())); |
|
152 } |
|
153 } |
|
154 } |
106 |
155 |
107 HbInputFocusObject::~HbInputFocusObject() |
156 HbInputFocusObject::~HbInputFocusObject() |
108 { |
157 { |
109 Q_D(HbInputFocusObject); |
158 Q_D(HbInputFocusObject); |
110 |
159 |