32 #include <hbframeitem.h> |
32 #include <hbframeitem.h> |
33 #include <hbframedrawer.h> |
33 #include <hbframedrawer.h> |
34 |
34 |
35 #include <hbdeviceprofile.h> |
35 #include <hbdeviceprofile.h> |
36 |
36 |
|
37 #include <HbFrameDrawer> |
|
38 #include <hbframedrawerpool_p.h> |
37 #include <hbinputmethod.h> |
39 #include <hbinputmethod.h> |
38 #include <hbinputsettingproxy.h> |
40 #include <hbinputsettingproxy.h> |
39 #include <hbinputvkbhost.h> |
41 #include <hbinputvkbhost.h> |
40 #include <hbinputregioncollector_p.h> |
42 #include <hbinputregioncollector_p.h> |
41 |
43 |
42 #include "hbdialog_p.h" |
44 #include "hbdialog_p.h" |
43 |
45 |
|
46 const QString HbCandidateListBackground("qtg_fr_popup_secondary"); |
44 const int HbCandListDefaultNumRows = 5; |
47 const int HbCandListDefaultNumRows = 5; |
45 const qreal HbCandListMaxWidthMultiplier = 0.8; |
48 const qreal HbCandListMaxWidthMultiplier = 0.8; |
46 const qreal HbCandListMinWidth = 30.0; |
49 const qreal HbCandListMinWidth = 30.0; |
47 const qreal HbAutoComplPopupSideMargin = 15.0; |
50 const qreal HbAutoComplPopupSideMargin = 15.0; |
48 const qreal HbAutoComplPopupVerticalMargin = 15.0; |
|
49 const qreal HbAutoComplPopupMinAllowedHeight = 25.0; |
51 const qreal HbAutoComplPopupMinAllowedHeight = 25.0; |
50 |
52 |
51 /// @cond |
53 /// @cond |
52 |
54 |
53 class HbCandidateListPrivate : public HbDialogPrivate |
55 class HbCandidateListPrivate : public HbDialogPrivate |
56 |
58 |
57 public: |
59 public: |
58 HbCandidateListPrivate(HbInputMethod *input); |
60 HbCandidateListPrivate(HbInputMethod *input); |
59 ~HbCandidateListPrivate(); |
61 ~HbCandidateListPrivate(); |
60 void calculateAndSetSize(qreal maxWidth); |
62 void calculateAndSetSize(qreal maxWidth); |
61 void initFrameIcon(); |
63 void setBackground(); |
62 |
64 |
63 public: |
65 public: |
64 HbListWidget *mList; |
66 HbListWidget *mList; |
65 HbInputMethod *mInput; |
67 HbInputMethod *mInput; |
66 int numRows; |
68 int numRows; |
67 int numCandidates; |
69 int numCandidates; |
68 int longestStringWidth; |
70 int longestStringWidth; |
69 HbFrameItem *mFrameBackground; |
|
70 HbListWidgetItem *mSpellQueryItem; |
71 HbListWidgetItem *mSpellQueryItem; |
71 bool mCandidateCommitted; |
72 bool mCandidateCommitted; |
72 bool mSpellQueryOpenIsPending; |
73 bool mSpellQueryOpenIsPending; |
73 }; |
74 }; |
74 |
75 |
75 HbCandidateListPrivate::HbCandidateListPrivate(HbInputMethod *input) |
76 HbCandidateListPrivate::HbCandidateListPrivate(HbInputMethod *input) |
76 : mInput(input), |
77 : mInput(input), |
77 numRows(HbCandListDefaultNumRows), |
78 numRows(HbCandListDefaultNumRows), |
78 numCandidates(0), |
79 numCandidates(0), |
79 longestStringWidth(0), |
80 longestStringWidth(0), |
80 mFrameBackground(0), |
|
81 mSpellQueryItem(0), |
81 mSpellQueryItem(0), |
82 mCandidateCommitted(false), |
82 mCandidateCommitted(false), |
83 mSpellQueryOpenIsPending(false) |
83 mSpellQueryOpenIsPending(false) |
84 { |
84 { |
85 mList = new HbListWidget(); |
85 mList = new HbListWidget(); |
88 |
88 |
89 HbCandidateListPrivate::~HbCandidateListPrivate() |
89 HbCandidateListPrivate::~HbCandidateListPrivate() |
90 { |
90 { |
91 } |
91 } |
92 |
92 |
93 void HbCandidateListPrivate::initFrameIcon() |
93 void HbCandidateListPrivate::setBackground() |
94 { |
94 { |
95 Q_Q(HbCandidateList); |
95 Q_Q(HbCandidateList); |
96 |
96 HbFrameDrawer *drawer = HbFrameDrawerPool::get(HbCandidateListBackground, HbFrameDrawer::NinePieces, QSizeF(q->boundingRect().width(), q->boundingRect().height())); |
97 mFrameBackground = static_cast<HbFrameItem *>(q->primitive((HbStyle::Primitive)HbStylePrivate::P_Popup_background)); |
97 if (drawer) { |
98 |
98 drawer->setFillWholeRect(true); |
99 if (mFrameBackground == 0) { |
99 q->setBackgroundItem(new HbFrameItem(drawer)); |
100 mFrameBackground = static_cast<HbFrameItem *>(HbStylePrivate::createPrimitive(HbStylePrivate::P_Popup_background, q)); |
100 } |
101 } |
|
102 } |
101 } |
103 |
102 |
104 |
103 |
105 void HbCandidateListPrivate::calculateAndSetSize(qreal maxWidth) |
104 void HbCandidateListPrivate::calculateAndSetSize(qreal maxWidth) |
106 { |
105 { |
165 Q_D(HbCandidateList); |
164 Q_D(HbCandidateList); |
166 |
165 |
167 HbInputRegionCollector::instance()->attach(this); |
166 HbInputRegionCollector::instance()->attach(this); |
168 |
167 |
169 d->setPriority(HbPopupPrivate::VirtualKeyboard + 1); // Should be shown on top of virtual keyboard. |
168 d->setPriority(HbPopupPrivate::VirtualKeyboard + 1); // Should be shown on top of virtual keyboard. |
170 d->initFrameIcon(); |
169 d->setBackground(); |
171 |
170 |
172 d->mList->setParent(this); |
171 d->mList->setParent(this); |
173 |
172 |
174 // Make sure the preview pane never steals focus. |
173 // Make sure the preview pane never steals focus. |
175 setFlag(QGraphicsItem::ItemIsPanel, true); |
174 setFlag(QGraphicsItem::ItemIsPanel, true); |
176 d->mActivePopup = false; |
175 d->mActivePopup = false; |
332 d->mSpellQueryOpenIsPending = false; |
331 d->mSpellQueryOpenIsPending = false; |
333 emit launchSpellQueryDialog(); |
332 emit launchSpellQueryDialog(); |
334 } |
333 } |
335 } |
334 } |
336 |
335 |
337 void HbCandidateList::updatePrimitives() |
|
338 { |
|
339 Q_D(HbCandidateList); |
|
340 |
|
341 d->mFrameBackground->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); |
|
342 d->mFrameBackground->frameDrawer().setFrameGraphicsName("qtg_fr_popup_secondary"); |
|
343 d->mFrameBackground->setGeometry(boundingRect()); |
|
344 } |
|
345 |
336 |
346 /*! |
337 /*! |
347 Finds correct size and position for auto-completion popup. It checks if there is enough space to display candidate popup, |
338 Finds correct size and position for auto-completion popup. It checks if there is enough space to display candidate popup, |
348 finds out whether it is display above or below the editor and sets correct width. |
339 finds out whether it is display above or below the editor and sets correct width. |
349 Returns true if suitable position was found and set. |
340 Returns true if suitable position was found and set. |