39 #include <hbinputmethod.h> |
39 #include <hbinputmethod.h> |
40 #include <hbinputsettingproxy.h> |
40 #include <hbinputsettingproxy.h> |
41 #include <hbinputvkbhost.h> |
41 #include <hbinputvkbhost.h> |
42 #include <hbinputregioncollector_p.h> |
42 #include <hbinputregioncollector_p.h> |
43 |
43 |
44 #include "hbdialog_p.h" |
44 #include "hbinputpopupbase_p.h" |
45 |
45 |
46 const QString HbCandidateListBackground("qtg_fr_popup_secondary"); |
46 const QString HbCandidateListBackground("qtg_fr_popup_secondary"); |
47 const int HbCandListDefaultNumRows = 5; |
47 const int HbCandListDefaultNumRows = 5; |
48 const qreal HbCandListMaxWidthMultiplier = 0.8; |
48 const qreal HbCandListMaxWidthMultiplier = 0.8; |
49 const qreal HbCandListMinWidth = 30.0; |
49 const qreal HbCandListMinWidth = 30.0; |
50 const qreal HbAutoComplPopupSideMargin = 15.0; |
50 const qreal HbAutoComplPopupSideMargin = 15.0; |
51 const qreal HbAutoComplPopupMinAllowedHeight = 25.0; |
51 const qreal HbAutoComplPopupMinAllowedHeight = 25.0; |
52 |
52 |
53 /// @cond |
53 /// @cond |
54 |
54 |
55 class HbCandidateListPrivate : public HbDialogPrivate |
55 class HbCandidateListPrivate : public HbInputPopupBasePrivate |
56 { |
56 { |
57 Q_DECLARE_PUBLIC(HbCandidateList) |
57 Q_DECLARE_PUBLIC(HbCandidateList) |
58 |
58 |
59 public: |
59 public: |
60 HbCandidateListPrivate(HbInputMethod *input); |
60 HbCandidateListPrivate(HbInputMethod *input); |
157 Constructor. |
157 Constructor. |
158 @param input The input method that uses this widget. |
158 @param input The input method that uses this widget. |
159 @param parent parent of the widget. |
159 @param parent parent of the widget. |
160 */ |
160 */ |
161 HbCandidateList::HbCandidateList(HbInputMethod *input, QGraphicsItem *parent) |
161 HbCandidateList::HbCandidateList(HbInputMethod *input, QGraphicsItem *parent) |
162 : HbDialog(*new HbCandidateListPrivate(input), parent) |
162 : HbInputPopupBase(*new HbCandidateListPrivate(input), parent) |
163 { |
163 { |
164 Q_D(HbCandidateList); |
164 Q_D(HbCandidateList); |
165 |
165 |
166 HbInputRegionCollector::instance()->attach(this); |
166 HbInputRegionCollector::instance()->attach(this); |
167 |
167 |
168 d->setPriority(HbPopupPrivate::VirtualKeyboard + 1); // Should be shown on top of virtual keyboard. |
|
169 d->setBackground(); |
168 d->setBackground(); |
170 |
169 |
171 d->mList->setParent(this); |
170 d->mList->setParent(this); |
172 |
|
173 // Make sure the preview pane never steals focus. |
|
174 setFlag(QGraphicsItem::ItemIsPanel, true); |
|
175 d->mActivePopup = false; |
|
176 setActive(false); |
|
177 |
171 |
178 setTimeout(NoTimeout); |
172 setTimeout(NoTimeout); |
179 setAttribute(Qt::WA_InputMethodEnabled, false); |
173 setAttribute(Qt::WA_InputMethodEnabled, false); |
180 connect(d->mList, SIGNAL(activated(HbListWidgetItem *)), this, SLOT(itemActivated(HbListWidgetItem *))); |
174 connect(d->mList, SIGNAL(activated(HbListWidgetItem *)), this, SLOT(itemActivated(HbListWidgetItem *))); |
181 connect(d->mList, SIGNAL(longPressed(HbListWidgetItem *, const QPointF &)), this, SLOT(itemActivated(HbListWidgetItem *))); |
175 connect(d->mList, SIGNAL(longPressed(HbListWidgetItem *, const QPointF &)), this, SLOT(itemActivated(HbListWidgetItem *))); |
202 setVisible(true); |
196 setVisible(true); |
203 QEvent event(QEvent::Polish); |
197 QEvent event(QEvent::Polish); |
204 QApplication::sendEvent(this, &event); |
198 QApplication::sendEvent(this, &event); |
205 setContentWidget(d->mList); |
199 setContentWidget(d->mList); |
206 |
200 |
207 d->setPriority(HbPopupPrivate::VirtualKeyboard + 1); // Should be shown on top of virtual keyboard. |
|
208 d->mList->clear(); |
201 d->mList->clear(); |
209 |
202 |
210 int longestwidth = 0; |
203 int longestwidth = 0; |
211 int finalWidth = 250; |
204 int finalWidth = 250; |
212 for (int i = 0; i < candidates.count(); i++) { |
205 for (int i = 0; i < candidates.count(); i++) { |