102 /*! |
96 /*! |
103 Creates the layout of the mini touch keypad for hardware qwerty. |
97 Creates the layout of the mini touch keypad for hardware qwerty. |
104 */ |
98 */ |
105 void HbHwToolCluster::createLayout() |
99 void HbHwToolCluster::createLayout() |
106 { |
100 { |
107 setupToolCluster(); |
|
108 |
|
109 Q_D(HbHwToolCluster); |
|
110 // The layout is already created. So just return. |
|
111 if ( d->mButtonLayout ) { |
|
112 return; |
|
113 } |
|
114 |
|
115 d->mButtonLayout = new QGraphicsGridLayout(); |
|
116 setContentsMargins(0.0, 0.0, 0.0, 0.0); |
|
117 d->mButtonLayout->setContentsMargins(0.0, 0.0, 0.0, 0.0); |
|
118 d->mButtonLayout->setHorizontalSpacing(HorizontalSpacing); |
|
119 d->mButtonLayout->setVerticalSpacing(VerticalSpacing); |
|
120 d->mButtonLayout->addItem(d->mSettingsButton, 0, 0); // Settings key |
|
121 d->mButtonLayout->addItem(d->mLanguageButton, 0, 1); // language selection |
|
122 d->mButtonLayout->addItem(d->mPredictionIndicatorButton, 0, 2); // prediction indicator |
|
123 d->mButtonLayout->addItem(d->mInputMethodButton, 0, 3); //input method selection key |
|
124 d->mButtonLayout->addItem(d->mApplicationButton, 0, 4); // Application specific key |
|
125 |
|
126 d->mSettingsButton->setObjectName( HbCustomButtonObjName + QString::number(1)); |
|
127 d->mApplicationButton->setObjectName( HbCustomButtonObjName + QString::number(2)); |
|
128 d->mLanguageButton->setObjectName( HbCustomButtonObjName + QString::number(3)); |
|
129 d->mInputMethodButton->setObjectName( HbCustomButtonObjName + QString::number(4)); |
|
130 d->mPredictionIndicatorButton->setObjectName( HbCustomButtonObjName + QString::number(5)); |
|
131 |
|
132 connect(d->mInputMethodButton, SIGNAL(clicked()), this, SLOT(showMethodDialog())); |
|
133 connect(d->mLanguageButton, SIGNAL(clicked()), this, SLOT(showLanguageDialog())); |
|
134 connect(d->mPredictionIndicatorButton, SIGNAL(clicked()), HbInputSettingProxy::instance(), SLOT(togglePrediction())); |
|
135 } |
101 } |
136 |
102 |
137 |
103 |
138 /*! |
104 /*! |
139 Creates the tools cluster for mini VKB layout. |
105 Creates the tools cluster for mini VKB layout. |
140 */ |
106 */ |
141 void HbHwToolCluster::setupToolCluster() |
107 void HbHwToolCluster::setupToolCluster() |
142 { |
108 { |
143 Q_D(HbHwToolCluster); |
|
144 if(!d->mOwner || !d->mOwner->focusObject()) { |
|
145 return; |
|
146 } |
|
147 |
|
148 // Create buttons if they do not exist |
|
149 if (!d->mSettingsButton) { |
|
150 d->mSettingsButton = new HbTouchKeypadButton(this, QString("")); |
|
151 d->mSettingsButton->setIcon(HbIcon(settingsIcon)); |
|
152 d->mSettingsButton->setButtonType(HbTouchKeypadButton::HbTouchButtonFunction); |
|
153 d->mSettingsButton->setBackgroundAttributes(HbTouchKeypadButton::HbTouchButtonReleased); |
|
154 |
|
155 connect(d->mSettingsButton, SIGNAL(clicked()), this, SLOT(showSettingList())); |
|
156 } |
|
157 if(!d->mLanguageButton) { |
|
158 d->mLanguageButton = new HbTouchKeypadButton(this, QString("")); |
|
159 d->mLanguageButton->setButtonType(HbTouchKeypadButton::HbTouchButtonFunction); |
|
160 d->mLanguageButton->setBackgroundAttributes(HbTouchKeypadButton::HbTouchButtonReleased); |
|
161 } |
|
162 |
|
163 if(!d->mInputMethodButton) { |
|
164 d->mInputMethodButton = new HbTouchKeypadButton(this, QString("")); |
|
165 d->mInputMethodButton->setIcon(HbIcon(inputMethodIcon)); |
|
166 d->mInputMethodButton->setButtonType(HbTouchKeypadButton::HbTouchButtonFunction); |
|
167 d->mInputMethodButton->setBackgroundAttributes(HbTouchKeypadButton::HbTouchButtonReleased); |
|
168 } |
|
169 |
|
170 if(!d->mPredictionIndicatorButton) { |
|
171 d->mPredictionIndicatorButton = new HbTouchKeypadButton(this, QString("")); |
|
172 d->mPredictionIndicatorButton->setButtonType(HbTouchKeypadButton::HbTouchButtonFunction); |
|
173 d->mPredictionIndicatorButton->setBackgroundAttributes(HbTouchKeypadButton::HbTouchButtonReleased); |
|
174 d->mInputModeIndicator = new HbInputModeIndicator(*d->mPredictionIndicatorButton, this); |
|
175 } else { |
|
176 d->mInputModeIndicator->updateIndicator(); |
|
177 } |
|
178 |
|
179 if(d->mLanguageButton) { |
|
180 // update language button text |
|
181 QString langName = HbInputSettingProxy::instance()->globalInputLanguage().localisedName(); |
|
182 langName.truncate(3); |
|
183 d->mLanguageButton->setText(langName); |
|
184 } |
|
185 |
|
186 // update prediction button status |
|
187 if (HbInputSettingProxy::instance()->predictiveInputStatusForActiveKeyboard()) { |
|
188 d->mPredictionIndicatorButton->setIcon(HbIcon(predictionOffIcon)); |
|
189 } else { |
|
190 d->mPredictionIndicatorButton->setIcon(HbIcon(predictionOnIcon)); |
|
191 } |
|
192 |
|
193 // If there's a application specific button defined, create new button with the properties |
|
194 // or update the existing one. Otherwise create an empty button or clean the properties of an existing one. |
|
195 if (!d->mOwner->focusObject()->editorInterface().actions().isEmpty()) { |
|
196 QList<HbAction*> actions = d->mOwner->focusObject()->editorInterface().actions(); |
|
197 if (d->mApplicationButton) { |
|
198 d->mApplicationButton->setText(actions.first()->text()); |
|
199 d->mApplicationButton->disconnect(SIGNAL(clicked())); |
|
200 } else { |
|
201 d->mApplicationButton = new HbTouchKeypadButton(this, actions.first()->text()); |
|
202 d->mApplicationButton->setButtonType(HbTouchKeypadButton::HbTouchButtonFunction); |
|
203 d->mApplicationButton->setBackgroundAttributes(HbTouchKeypadButton::HbTouchButtonReleased); |
|
204 } |
|
205 connect(d->mApplicationButton, SIGNAL(clicked()), actions.first(), SLOT(trigger())); |
|
206 d->mApplicationButton->setIcon(actions.first()->icon()); |
|
207 d->mApplicationButton->setToolTip(actions.first()->toolTip()); |
|
208 } else { |
|
209 if (d->mApplicationButton) { |
|
210 d->mApplicationButton->disconnect(SIGNAL(clicked())); |
|
211 d->mApplicationButton->setText(QString()); |
|
212 d->mApplicationButton->setIcon(HbIcon()); |
|
213 d->mApplicationButton->setToolTip(QString()); |
|
214 } else { |
|
215 d->mApplicationButton = new HbTouchKeypadButton(this, QString()); |
|
216 d->mApplicationButton->setButtonType(HbTouchKeypadButton::HbTouchButtonFunction); |
|
217 d->mApplicationButton->setBackgroundAttributes(HbTouchKeypadButton::HbTouchButtonReleased); |
|
218 } |
|
219 } |
|
220 } |
109 } |
221 |
110 |
222 /*! |
111 /*! |
223 Returns keyboard type. |
112 Returns keyboard type. |
224 */ |
113 */ |