103 // mValidatorUsername, mValidatorPassword |
109 // mValidatorUsername, mValidatorPassword |
104 // mConfigIf: scoped pointer deleted automatically |
110 // mConfigIf: scoped pointer deleted automatically |
105 } |
111 } |
106 |
112 |
107 /*! |
113 /*! |
108 * Initializes the password-username ui and initializes objects based on configuration |
114 * Creates username-password UI and initilizes settings read via |
109 * read from the database. |
115 * EapQtConfigInterface |
110 */ |
116 */ |
111 void CpEapUserPasswordUi::initializeUserPasswordUi() |
117 void CpEapUserPasswordUi::createUi() |
112 { |
118 { |
113 qDebug("CpEapUserPasswordUi::initializeUserPasswordUi"); |
119 qDebug("CpEapUserPasswordUi::createUi"); |
114 |
|
115 CpItemDataHelper itemDataHelper; |
|
116 |
120 |
117 // Read Configurations |
121 // Read Configurations |
118 EapQtConfig eapConfig; |
|
119 bool configurationRead = mConfigIf->readConfiguration(mOuterHandle, mPluginInfo.pluginHandle(), |
122 bool configurationRead = mConfigIf->readConfiguration(mOuterHandle, mPluginInfo.pluginHandle(), |
120 eapConfig); |
123 mEapConfig); |
121 if (!configurationRead) { |
124 if (!configurationRead) { |
122 qDebug("CpEapUserPasswordUi::initializeUserPasswordUi - read configuration failed."); |
125 qDebug("CpEapUserPasswordUi::initializeUserPasswordUi - read configuration failed."); |
123 } |
126 } |
124 |
127 |
125 // Create UI objects and group |
128 // Construct username-password UI |
126 mForm = new HbDataForm(); |
129 mForm = new HbDataForm(); |
127 this->setWidget(mForm); |
130 this->setWidget(mForm); |
128 |
131 mModel = new HbDataFormModel(mForm); |
129 mModel = new HbDataFormModel; |
132 |
130 |
133 // Create settings group |
131 HbDataFormModelItem *groupItem = new HbDataFormModelItem(HbDataFormModelItem::GroupItem, |
134 mGroupItem = new HbDataFormModelItem(HbDataFormModelItem::GroupItem, |
132 hbTrId("txt_occ_subhead_eap_module_settings").arg(mPluginInfo.localizationId())); |
135 HbParameterLengthLimiter( |
133 mModel->appendDataFormItem(groupItem); |
136 hbTrId("txt_occ_subhead_eap_module_settings")).arg( |
134 |
137 mPluginInfo.localizationId())); |
|
138 mModel->appendDataFormItem(mGroupItem); |
|
139 |
|
140 // The parameter given as 0 is a HbDataForm pointer, not parent |
|
141 mItemDataHelper = new CpItemDataHelper(0); |
|
142 mItemDataHelper->setParent(this); |
|
143 |
|
144 // Create UI components |
|
145 createUsername(); |
|
146 createPassword(); |
|
147 |
|
148 mItemDataHelper->bindToForm(mForm); |
|
149 mForm->setModel(mModel); |
|
150 |
135 // Connect signal to add validators when items get activated (visualization created). |
151 // Connect signal to add validators when items get activated (visualization created). |
136 bool connected = connect(mForm, SIGNAL( itemShown(const QModelIndex&) ), this, |
152 bool connected = connect(mForm, SIGNAL( itemShown(const QModelIndex&) ), this, |
137 SLOT( setValidator(const QModelIndex) )); |
153 SLOT( setValidator(const QModelIndex) )); |
138 Q_ASSERT(connected); |
154 Q_ASSERT(connected); |
139 |
155 |
|
156 // Expand username-password settings group |
|
157 mForm->setExpanded(mModel->indexFromItem(mGroupItem), true); |
|
158 } |
|
159 |
|
160 /*! |
|
161 * Creates Username lineEdit |
|
162 */ |
|
163 void CpEapUserPasswordUi::createUsername() |
|
164 { |
|
165 qDebug("CpEapUserPasswordUi::createUsername()"); |
140 // Username |
166 // Username |
141 mUsername = new CpSettingFormItemData(HbDataFormModelItem::TextItem, hbTrId( |
167 mUsername = new CpSettingFormItemData(HbDataFormModelItem::TextItem, hbTrId( |
142 "txt_occ_setlabel_username")); |
168 "txt_occ_setlabel_user_name")); |
143 // Initialize the value from EapQtConfig |
169 // Initialize the value from EapQtConfig |
144 mUsername->setContentWidgetData("text", eapConfig.value(EapQtConfig::Username)); |
170 mUsername->setContentWidgetData("text", mEapConfig.value(EapQtConfig::Username)); |
145 groupItem->appendChild(mUsername); |
171 mGroupItem->appendChild(mUsername); |
146 |
172 } |
|
173 |
|
174 /*! |
|
175 * Creates Password group: |
|
176 * Prompt checkBox and password lineEdit |
|
177 */ |
|
178 void CpEapUserPasswordUi::createPassword() |
|
179 { |
|
180 qDebug("CpEapUserPasswordUi::createPassword()"); |
147 // Password prompting |
181 // Password prompting |
148 mPasswordPrompt = new CpSettingFormItemData(HbDataFormModelItem::CheckBoxItem, hbTrId( |
182 mPasswordPrompt = new CpSettingFormItemData(HbDataFormModelItem::CheckBoxItem, hbTrId( |
149 "txt_occ_setlabel_password")); |
183 "txt_occ_setlabel_password")); |
150 mPasswordPrompt->setContentWidgetData("text", hbTrId("txt_occ_setlabel_password_val_prompt")); |
184 mPasswordPrompt->setContentWidgetData("text", hbTrId("txt_occ_setlabel_password_val_prompt")); |
151 mPasswordPrompt->setContentWidgetData("checkState", boolToCheckState(eapConfig.value( |
185 mPasswordPrompt->setContentWidgetData("checkState", boolToCheckState(mEapConfig.value( |
152 EapQtConfig::PasswordPrompt).toBool())); |
186 EapQtConfig::PasswordPrompt).toBool())); |
153 // Connect signal to disable/enable password when passwordPrompt changed |
187 // Connect signal to disable/enable password when passwordPrompt changed |
154 mForm->addConnection(mPasswordPrompt, SIGNAL(stateChanged(int)), this, |
188 mForm->addConnection(mPasswordPrompt, SIGNAL(stateChanged(int)), this, |
155 SLOT(passwordPromptChanged(int))); |
189 SLOT(passwordPromptChanged(int))); |
156 groupItem->appendChild(mPasswordPrompt); |
190 mGroupItem->appendChild(mPasswordPrompt); |
157 |
191 |
158 // Password |
192 // Password |
159 mPassword = new CpSettingFormItemData(HbDataFormModelItem::TextItem, hbTrId( |
193 mPassword = new CpSettingFormItemData(HbDataFormModelItem::TextItem, hbTrId( |
160 "txt_occ_setlabel_password")); |
194 "txt_occ_setlabel_password")); |
161 mPasswordStored = eapConfig.value(EapQtConfig::PasswordStored).toBool(); |
195 mPasswordStored = mEapConfig.value(EapQtConfig::PasswordStored).toBool(); |
162 // If password has already been stored into the databse |
196 // If password has already been stored into the databse |
163 // fixed number of asterisks are shown in UI |
197 // fixed number of asterisks are shown in UI |
164 if (mPasswordStored) { |
198 if (mPasswordStored) { |
165 mPassword->setContentWidgetData("text", passwordExistString); |
199 mPassword->setContentWidgetData("text", passwordExistString); |
166 } |
200 } |
167 // Set password echo mode |
201 // Set password echo mode |
168 mPassword->setContentWidgetData("echoMode", HbLineEdit::Password); |
202 mPassword->setContentWidgetData("echoMode", HbLineEdit::Password); |
169 // Dimmed password if passwordPrompt is selected |
203 // Dim password if passwordPrompt is selected |
170 passwordPromptChanged(mPasswordPrompt->contentWidgetData("checkState") == Qt::Checked); |
204 passwordPromptChanged(mPasswordPrompt->contentWidgetData("checkState") == Qt::Checked); |
171 // Connect signal to get info that user has changed the password |
205 // Connect signal to get info that user has changed the password |
172 mForm->addConnection(mPassword, SIGNAL(editingFinished()), this, SLOT(passwordChanged())); |
206 mForm->addConnection(mPassword, SIGNAL(editingFinished()), this, SLOT(passwordChanged())); |
173 groupItem->appendChild(mPassword); |
207 mGroupItem->appendChild(mPassword); |
174 |
|
175 // Set the model |
|
176 mForm->setModel(mModel); |
|
177 itemDataHelper.bindToForm(mForm); |
|
178 |
|
179 // Expand userpasswordui settings group |
|
180 mForm->setExpanded(mModel->indexFromItem(groupItem), TRUE); |
|
181 } |
208 } |
182 |
209 |
183 /*! |
210 /*! |
184 * Adds validators and connects focusIn event to the Password. |
211 * Adds validators and connects focusIn event to the Password. |
185 * |
212 * |
219 * |
246 * |
220 */ |
247 */ |
221 void CpEapUserPasswordUi::close() |
248 void CpEapUserPasswordUi::close() |
222 { |
249 { |
223 qDebug("CpEapUserPasswordUi::close"); |
250 qDebug("CpEapUserPasswordUi::close"); |
|
251 |
|
252 // Validate configuration |
224 if (validate()) { |
253 if (validate()) { |
225 qDebug("CpEapUserPasswordUi::close - Store settings"); |
254 qDebug("CpEapUserPasswordUi::close - Validation OK"); |
226 storeSettings(); |
255 |
227 qDebug("CpEapUserPasswordUi::close - Settings stored, exit"); |
256 // Store settings |
228 CpBaseSettingView::close(); |
257 if (storeSettings()){ |
|
258 qDebug("CpEapUserPasswordUi::close - Settings stored, close view"); |
|
259 // Close view |
|
260 CpBaseSettingView::close(); |
|
261 } |
|
262 else { |
|
263 qDebug("CpEapUserPasswordUi::close - Store settings failed, prompt warning"); |
|
264 // Store failed. Show error note to user |
|
265 QScopedPointer<HbMessageBox> infoBox; |
|
266 infoBox.reset(new HbMessageBox( |
|
267 HbMessageBox::MessageTypeWarning)); |
|
268 infoBox->setAttribute(Qt::WA_DeleteOnClose); |
|
269 infoBox->setText(hbTrId("txt_occ_info_unable_to_save_setting")); |
|
270 infoBox->clearActions(); |
|
271 // Connect 'OK'-button to CpBaseSettingView 'aboutToClose'-signal |
|
272 HbAction *okAction = new HbAction(hbTrId("txt_common_button_ok")); |
|
273 infoBox->addAction(okAction); |
|
274 bool connected = connect( |
|
275 okAction, |
|
276 SIGNAL(triggered()), |
|
277 this, |
|
278 SIGNAL(aboutToClose())); |
|
279 Q_ASSERT(connected); |
|
280 infoBox->open(); |
|
281 infoBox.take(); |
|
282 } |
229 } |
283 } |
230 else { |
284 else { |
231 qDebug("CpEapUserPasswordUi::close - validation failed. Prompt question."); |
285 qDebug("CpEapUserPasswordUi::close - validation failed. Prompt question."); |
232 HbMessageBox *note = new HbMessageBox(HbMessageBox::MessageTypeQuestion); |
286 |
233 note->setAttribute(Qt::WA_DeleteOnClose); |
287 // Validate failed. Request user to exit anyway |
234 note->setText(hbTrId("txt_occ_info_incomplete_details_return_without_sa")); |
288 QScopedPointer<HbMessageBox> messageBox; |
235 note->clearActions(); |
289 messageBox.reset(new HbMessageBox( |
|
290 HbMessageBox::MessageTypeQuestion)); |
|
291 messageBox->setAttribute(Qt::WA_DeleteOnClose); |
|
292 messageBox->setText(hbTrId("txt_occ_info_incomplete_details_return_without_sa")); |
|
293 messageBox->clearActions(); |
236 // Connect 'YES'-button to CpBaseSettingView 'aboutToClose'-signal |
294 // Connect 'YES'-button to CpBaseSettingView 'aboutToClose'-signal |
237 HbAction *okAction = new HbAction(hbTrId("txt_common_button_yes")); |
295 HbAction *okAction = new HbAction(hbTrId("txt_common_button_yes")); |
238 note->addAction(okAction); |
296 messageBox->addAction(okAction); |
239 bool connected = connect( |
297 bool connected = connect( |
240 okAction, |
298 okAction, |
241 SIGNAL(triggered()), |
299 SIGNAL(triggered()), |
242 this, |
300 this, |
243 SIGNAL(aboutToClose())); |
301 SIGNAL(aboutToClose())); |
244 Q_ASSERT(connected); |
302 Q_ASSERT(connected); |
245 // Clicking 'NO'-button does nothing |
303 // Clicking 'NO'-button does nothing |
246 HbAction *cancelAction = new HbAction(hbTrId("txt_common_button_no")); |
304 HbAction *cancelAction = new HbAction(hbTrId("txt_common_button_no")); |
247 note->addAction(cancelAction); |
305 messageBox->addAction(cancelAction); |
248 note->setTimeout(HbPopup::NoTimeout); |
306 messageBox->setTimeout(HbPopup::NoTimeout); |
249 note->open(); |
307 messageBox->open(); |
|
308 messageBox.take(); |
250 } |
309 } |
251 } |
310 } |
252 |
311 |
253 /*! |
312 /*! |
254 * Converts check box state to boolean. |
313 * Converts check box state to boolean. |