|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Prompt Dialog implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <HbLabel> |
|
19 #include "eapquerydialog.h" |
|
20 #include "OstTraceDefinitions.h" |
|
21 #ifdef OST_TRACE_COMPILER_IN_USE |
|
22 #endif |
|
23 |
|
24 // The index numbers of the button of the dialog |
|
25 const int okButtonIndex = 1; |
|
26 |
|
27 /** |
|
28 * The constructor |
|
29 */ |
|
30 EapQueryDialog::EapQueryDialog(const QVariantMap ¶meters) |
|
31 :mActionOk(NULL), |
|
32 mTranslator(new HbTranslator("eapprompts")) |
|
33 { |
|
34 OstTraceFunctionEntry0( EAPQUERYDIALOG_EAPQUERYDIALOG_ENTRY ); |
|
35 qDebug("EapQueryDialog::EapQueryDialog ENTER"); |
|
36 |
|
37 createDialog( parameters ); |
|
38 |
|
39 mOkActionPressed = false; |
|
40 |
|
41 OstTraceFunctionExit0( EAPQUERYDIALOG_EAPQUERYDIALOG_EXIT ); |
|
42 qDebug("EapQueryDialog::EapQueryDialog EXIT"); |
|
43 } |
|
44 |
|
45 |
|
46 /** |
|
47 * The construction of the dialog |
|
48 */ |
|
49 void EapQueryDialog::createDialog(const QVariantMap ¶meters ) |
|
50 { |
|
51 OstTraceFunctionEntry0( EAPQUERYDIALOG_CREATEDIALOG_ENTRY ); |
|
52 qDebug("EapQueryDialog::createDialog ENTER"); |
|
53 |
|
54 QString message = QString(""); ; |
|
55 QString keyauthmethod = QString("authmethod"); |
|
56 QString keymessage = QString("messagetxt"); |
|
57 QString authMethodstr = QString("FOO"); |
|
58 |
|
59 if ( parameters.empty() == false ) { |
|
60 |
|
61 if ( parameters.contains(keyauthmethod) ) { |
|
62 QVariant variant1 = parameters.value(keyauthmethod); |
|
63 authMethodstr = variant1.toString(); |
|
64 } |
|
65 if ( parameters.contains(keymessage) ) { |
|
66 QVariant variant2 = parameters.value(keymessage); |
|
67 message = variant2.toString(); |
|
68 } |
|
69 } |
|
70 |
|
71 QString labelText1 = QString(hbTrId("txt_occ_title_1_message").arg(authMethodstr)); |
|
72 QString labelText2 = message; |
|
73 |
|
74 //Set the dialog to be on the screen until user reacts |
|
75 //by pressing any of the Action buttons |
|
76 this->setModal(true); |
|
77 this->setTimeout(HbPopup::NoTimeout); |
|
78 this->setDismissPolicy(HbPopup::NoDismiss); |
|
79 |
|
80 HbLabel* label1 = new HbLabel; |
|
81 Q_ASSERT(label1 != NULL); |
|
82 label1->setPlainText(labelText1); |
|
83 label1->setFontSpec(HbFontSpec(HbFontSpec::Primary)); |
|
84 label1->setTextWrapping(Hb::TextWrapAnywhere); |
|
85 |
|
86 this->setHeadingWidget(label1); |
|
87 this->setText(labelText2); |
|
88 this->setIconVisible(false); |
|
89 |
|
90 QList<QAction*> action_list = this->actions(); |
|
91 |
|
92 for ( int i = 0; i < action_list.count(); i++ ) { |
|
93 this->removeAction(action_list.at(i)); |
|
94 } |
|
95 |
|
96 mActionOk = new HbAction(tr("Ok"),this); |
|
97 this->addAction(mActionOk); |
|
98 |
|
99 disconnect(mActionOk, SIGNAL(triggered()),this, SLOT(close())); |
|
100 bool connected = connect(mActionOk, SIGNAL(triggered()), this, SLOT(okPressed())); |
|
101 Q_ASSERT(connected == true); |
|
102 |
|
103 // Connect the about to close and hide signals, so that we are able to inform |
|
104 // the caller that the dialog was closed |
|
105 connected = connect(this, SIGNAL(aboutToClose()), this, SLOT(closingDialog())); |
|
106 Q_ASSERT(connected == true); |
|
107 connected = connect(this, SIGNAL(aboutToHide()), this, SLOT(closingDialog())); |
|
108 Q_ASSERT(connected == true); |
|
109 |
|
110 OstTraceFunctionExit0( DUP1_EAPQUERYDIALOG_CREATEDIALOG_EXIT ); |
|
111 qDebug("EapQueryDialog::createDialog EXIT"); |
|
112 } |
|
113 |
|
114 /** |
|
115 * Destructor |
|
116 */ |
|
117 EapQueryDialog::~EapQueryDialog() |
|
118 { |
|
119 OstTraceFunctionEntry0( EAPQUERYDIALOG_DEAPQUERYDIALOG_ENTRY ); |
|
120 |
|
121 // The dialog widgets are deleted as the dialog is deleted |
|
122 |
|
123 OstTraceFunctionExit0( EAPQUERYDIALOG_DEAPQUERYDIALOG_EXIT ); |
|
124 } |
|
125 |
|
126 /** |
|
127 * Function is called when the Ok Action button is pressed |
|
128 */ |
|
129 void EapQueryDialog::okPressed() |
|
130 { |
|
131 OstTraceFunctionEntry0( EAPQUERYDIALOG_OKPRESSED_ENTRY ); |
|
132 qDebug("EapQueryDialog::okPressed ENTER"); |
|
133 |
|
134 if ( mOkActionPressed == false ) { |
|
135 |
|
136 mOkActionPressed = true; |
|
137 |
|
138 QVariantMap data; |
|
139 QVariant variant(okButtonIndex); |
|
140 data.insert("okbutton", variant); |
|
141 // emit the data of the selected button and close the dialog |
|
142 qDebug("EapQueryDialog::okPressed: emit deviceDialogData"); |
|
143 emit deviceDialogData(data); |
|
144 |
|
145 closeDeviceDialog(true); |
|
146 } |
|
147 OstTraceFunctionExit0( EAPQUERYDIALOG_OKPRESSED_EXIT ); |
|
148 qDebug("EapQueryDialog::okPressed EXIT"); |
|
149 } |
|
150 |
|
151 /** |
|
152 * Function is called when the dialog is about to close |
|
153 * |
|
154 */ |
|
155 void EapQueryDialog::closingDialog() |
|
156 { |
|
157 OstTraceFunctionEntry0( EAPQUERYDIALOG_CLOSINGDIALOG_ENTRY ); |
|
158 qDebug("EapQueryDialog::closingDialog ENTER"); |
|
159 |
|
160 closeDeviceDialog(false); |
|
161 |
|
162 qDebug("EapQueryDialog::closingDialog EXIT"); |
|
163 OstTraceFunctionExit0( EAPQUERYDIALOG_CLOSINGDIALOG_EXIT ); |
|
164 } |
|
165 |
|
166 /** |
|
167 * Updating the dialog during its showing is not allowed. |
|
168 */ |
|
169 bool EapQueryDialog::setDeviceDialogParameters |
|
170 (const QVariantMap ¶meters) |
|
171 { |
|
172 OstTraceFunctionEntry0( EAPQUERYDIALOG_SETDEVICEDIALOGPARAMETERS_ENTRY ); |
|
173 |
|
174 Q_UNUSED(parameters) |
|
175 // changing the dialog after presenting it is not supported. |
|
176 |
|
177 OstTraceFunctionExit0( EAPQUERYDIALOG_SETDEVICEDIALOGPARAMETERS_EXIT ); |
|
178 return true; |
|
179 } |
|
180 |
|
181 /** |
|
182 * Not supported, 0 always returned |
|
183 */ |
|
184 int EapQueryDialog::deviceDialogError() const |
|
185 { |
|
186 OstTraceFunctionEntry0( EAPQUERYDIALOG_DEVICEDIALOGERROR_ENTRY ); |
|
187 OstTraceFunctionExit0( EAPQUERYDIALOG_DEVICEDIALOGERROR_EXIT); |
|
188 return 0; |
|
189 } |
|
190 |
|
191 /** |
|
192 * Dialog is closed and the signal about closing is emitted |
|
193 */ |
|
194 void EapQueryDialog::closeDeviceDialog(bool byClient) |
|
195 { |
|
196 OstTraceFunctionEntry0( EAPQUERYDIALOG_CLOSEDEVICEDIALOG_ENTRY ); |
|
197 qDebug("EapQueryDialog::closeDeviceDialog ENTER"); |
|
198 |
|
199 //If the user closes the dialog, then the deviceDialogClosed is emitted |
|
200 if ( byClient == true ) { |
|
201 emit deviceDialogClosed(); |
|
202 } |
|
203 |
|
204 qDebug("EapQueryDialog::closeDeviceDialog EXIT"); |
|
205 OstTraceFunctionExit0( EAPQUERYDIALOG_CLOSEDEVICEDIALOG_EXIT ); |
|
206 } |
|
207 |
|
208 /** |
|
209 * This dialog widget is returned to the caller |
|
210 */ |
|
211 HbPopup *EapQueryDialog::deviceDialogWidget() const |
|
212 { |
|
213 OstTraceFunctionEntry0( EAPQUERYDIALOG_DEVICEDIALOGWIDGET_ENTRY ); |
|
214 qDebug("EapQueryDialog::deviceDialogWidget ENTER"); |
|
215 |
|
216 qDebug("EapQueryDialog::deviceDialogWidget EXIT"); |
|
217 OstTraceFunctionExit0( EAPQUERYDIALOG_DEVICEDIALOGWIDGET_EXIT ); |
|
218 |
|
219 return const_cast<EapQueryDialog*>(this); |
|
220 } |
|
221 |