53 |
53 |
54 /*! |
54 /*! |
55 @beta |
55 @beta |
56 @hbcore |
56 @hbcore |
57 \class HbDialog |
57 \class HbDialog |
58 \brief HbDialog is a base class for different popup notes in Hb library. |
58 \brief HbDialog is a base class for different dialogs in Hb library. |
59 |
59 |
60 \image html hbpopup.png A popup with a header widget, a list as a content widget, |
60 \image html hbpopup.png "A dialog with a header widget, a list as a content widget, and two action buttons." |
61 and two action buttons. |
61 |
62 |
62 HbDialog is a concrete class. The content for a custom dialog is |
63 HbDialog is a concrete class. The content for a custom popup is implemented in |
63 implemented in a separate widget, which is set to the dialog with |
64 a separate widget, which is set to the popup with method setContentWidget(). |
64 method setContentWidget(). |
65 |
65 |
66 Lastly shown popup is always positioned in Z order on the the top of already visible popups. |
66 |
67 A popup can be permanent or automatically dismissed after a time-out. |
67 An example of how to create a simple modal dialog and show it. |
68 Modal popups interrupt any other user interaction outside of the popup while they are visible, |
|
69 whereas non-modal popups do not. |
|
70 |
|
71 An example of how to create a simple modal popup and show it. |
|
72 \snippet{ultimatecodesnippet/ultimatecodesnippet.cpp,13} |
68 \snippet{ultimatecodesnippet/ultimatecodesnippet.cpp,13} |
73 |
69 |
74 An example of how to create a non-modal popup and show it. |
70 An example of how to handle dialog signals from previous example. |
|
71 \snippet{ultimatecodesnippet/ultimatecodesnippet.cpp,53} |
|
72 |
|
73 An example of how to create a non-modal dialog and show it. |
75 \snippet{ultimatecodesnippet/ultimatecodesnippet.cpp,26} |
74 \snippet{ultimatecodesnippet/ultimatecodesnippet.cpp,26} |
|
75 |
76 */ |
76 */ |
77 |
77 |
78 /*! |
78 /*! |
79 \reimp |
79 \reimp |
80 \fn int HbDialog::type() const |
80 \fn int HbDialog::type() const |
150 q->updateGeometry(); |
150 q->updateGeometry(); |
151 } |
151 } |
152 |
152 |
153 |
153 |
154 /*! |
154 /*! |
155 * Constructs a popup with given \a parent graphics item.\n |
155 Constructs a dialog with given \a parent graphics item.\n |
156 * Note: popups with \a parent set as 0 are behaving as real popups. |
156 Note: dialogs with \a parent set as 0 are behaving as real popups. |
157 * This is actually the intended use. |
157 This is actually the intended use. \sa HbPopup::HbPopup |
158 * |
|
159 * However in some situation could be useful to embedd a popup into a QGraphicsItem. |
|
160 * In this case a non zero \a parent value must be passed. |
|
161 * Popups with parent items behaving just like any other QGraphicsWidget. |
|
162 * The following features are not supported (i.e. ignored) for popup with parents: |
|
163 * |
|
164 * - modality |
|
165 * - timeout |
|
166 * - unfadedItems |
|
167 * - dismissPolicy |
|
168 * - signal aboutToClose |
|
169 */ |
158 */ |
170 HbDialog::HbDialog(QGraphicsItem *parent) : |
159 HbDialog::HbDialog(QGraphicsItem *parent) : |
171 HbPopup(*new HbDialogPrivate, parent) |
160 HbPopup(*new HbDialogPrivate, parent) |
172 { |
161 { |
173 Q_D(HbDialog); |
162 Q_D(HbDialog); |
185 d->q_ptr = this; |
174 d->q_ptr = this; |
186 d->init(); |
175 d->init(); |
187 } |
176 } |
188 |
177 |
189 /*! |
178 /*! |
190 * Destroys the popup. |
179 Destroys the popup. |
191 */ |
180 */ |
192 HbDialog::~HbDialog() |
181 HbDialog::~HbDialog() |
193 { |
182 { |
194 } |
183 } |
195 |
184 |
196 /*! |
185 /*! |
197 @beta |
186 Returns the widget which is being added to the heading area |
198 * It returns the widget which is being added to the heading area |
187 \sa setHeadingWidget() |
199 * \sa setHeadingWidget() |
|
200 */ |
188 */ |
201 QGraphicsWidget * HbDialog::headingWidget() const |
189 QGraphicsWidget * HbDialog::headingWidget() const |
202 { |
190 { |
203 Q_D(const HbDialog); |
191 Q_D(const HbDialog); |
204 return (d->headingWidget); |
192 return (d->headingWidget); |
205 } |
193 } |
206 |
194 |
207 /*! |
195 /*! |
208 @beta |
196 Adds \a widget to the heading area. Ownership of the widget is transferred |
209 * Adds \a widget to the heading area. Ownership of the widget is transferred |
197 to popup. If \a headingWidget is 0 the heading widget is removed. |
210 * to popup. If \a headingWidget is 0 the heading widget is removed. |
198 \sa headingWidget() |
211 * \sa headingWidget() |
|
212 */ |
199 */ |
213 void HbDialog::setHeadingWidget(QGraphicsWidget *headingWidget) |
200 void HbDialog::setHeadingWidget(QGraphicsWidget *headingWidget) |
214 { |
201 { |
215 Q_D(HbDialog); |
202 Q_D(HbDialog); |
216 HbStyle::setItemName(headingWidget,"heading"); |
203 HbStyle::setItemName(headingWidget,"heading"); |
217 d->setWidget(0, d->headingWidget, headingWidget); |
204 d->setWidget(0, d->headingWidget, headingWidget); |
218 } |
205 } |
219 |
206 |
220 /*! |
207 /*! |
221 * Returns the content widget property of the popup. |
208 Returns the content widget property of the popup. |
222 * HbDialog only draws a bordered rect, the rest is drawn by the content widget. |
209 HbDialog only draws a bordered rect, the rest is drawn by the content widget. |
223 * \sa setContentWidget() |
210 \sa setContentWidget() |
224 */ |
211 */ |
225 QGraphicsWidget *HbDialog::contentWidget() const |
212 QGraphicsWidget *HbDialog::contentWidget() const |
226 { |
213 { |
227 Q_D(const HbDialog); |
214 Q_D(const HbDialog); |
228 return d->contentWidget; |
215 return d->contentWidget; |
229 } |
216 } |
230 |
217 |
231 /*! |
218 /*! |
232 * Sets the content widget property of the popup. |
219 Sets the content widget property of the popup. |
233 * HbDialog only draws a bordered rect, the rest is drawn by the content widget. |
220 HbDialog only draws a bordered rect, the rest is drawn by the content widget. |
234 * Ownership of the widget is transferred |
221 Ownership of the widget is transferred |
235 * to popup. If \a contentWidget is 0 the content widget is removed. |
222 to popup. If \a contentWidget is 0 the content widget is removed. |
236 * \sa contentWidget() |
223 \sa contentWidget() |
237 */ |
224 */ |
238 void HbDialog::setContentWidget(QGraphicsWidget *contentWidget) |
225 void HbDialog::setContentWidget(QGraphicsWidget *contentWidget) |
239 { |
226 { |
240 Q_D(HbDialog); |
227 Q_D(HbDialog); |
241 HbStyle::setItemName(contentWidget,"content"); |
228 HbStyle::setItemName(contentWidget,"content"); |
242 d->setWidget((d->headingWidget?1:0), d->contentWidget, contentWidget); |
229 d->setWidget((d->headingWidget?1:0), d->contentWidget, contentWidget); |
243 } |
230 } |
244 |
231 |
245 /*! |
232 /*! |
246 \deprecated HbDialog::primaryAction() const |
233 \deprecated HbDialog::primaryAction() const |
247 is deprecated. |
234 is deprecated. |
248 It returns the primary action added to the control area |
235 It returns the primary action added to the control area |
249 \sa setPrimaryAction() |
236 \sa setPrimaryAction() |
250 */ |
237 */ |
251 HbAction* HbDialog::primaryAction() const |
238 HbAction* HbDialog::primaryAction() const |
254 Q_D(const HbDialog); |
241 Q_D(const HbDialog); |
255 return d->primaryAction; |
242 return d->primaryAction; |
256 } |
243 } |
257 |
244 |
258 /*! |
245 /*! |
259 \deprecated HbDialog::setPrimaryAction(HbAction*) |
246 \deprecated HbDialog::setPrimaryAction(HbAction*) |
260 is deprecated. Please use QGraphicsWidget::addAction() family of functions instead. |
247 is deprecated. Please use QGraphicsWidget::addAction() family of functions instead. |
261 It adds the given action to the control area. |
248 It adds the given action to the control area. |
262 It is added to the left side of the control area if the layout direction of the application |
249 It is added to the left side of the control area if the layout direction of the application |
263 is left-to-right and in the vice-versa if the layout direction of the application |
250 is left-to-right and in the vice-versa if the layout direction of the application |
264 is right-to-left. |
251 is right-to-left. |
291 Q_D(const HbDialog); |
278 Q_D(const HbDialog); |
292 return(d->secondaryAction); |
279 return(d->secondaryAction); |
293 } |
280 } |
294 |
281 |
295 /*! |
282 /*! |
296 \deprecated HbDialog::setSecondaryAction(HbAction*) |
283 \deprecated HbDialog::setSecondaryAction(HbAction*) |
297 is deprecated. Please use QGraphicsWidget::addAction() family of functions instead. |
284 is deprecated. Please use QGraphicsWidget::addAction() family of functions instead. |
298 It adds the given action to the control area. |
285 It adds the given action to the control area. |
299 It is added to the right side of the control area if the layout direction of the application |
286 It is added to the right side of the control area if the layout direction of the application |
300 is left-to-right and in the vice-versa if the layout direction of the application |
287 is left-to-right and in the vice-versa if the layout direction of the application |
301 is right-to-left. |
288 is right-to-left. |
311 d->secondaryAction = action; |
298 d->secondaryAction = action; |
312 addAction(action); |
299 addAction(action); |
313 } |
300 } |
314 |
301 |
315 /*! |
302 /*! |
316 \deprecated HbDialog::exec() |
303 |
317 is deprecated. |
304 Shows the dialog as modal dialog returning immediately. |
318 Please use HbDialog::open( QObject* receiver, const char* member ) instead. |
305 |
319 |
306 Connects finished(HbAction*) signal to the slot specified by \a receiver and |
320 Executes the popup synchronously. |
307 \a member. The signal will be disconnected from the slot when the |
321 Note: when popup is executed syncronously it is always modal. |
308 popup is closed. |
322 */ |
309 |
323 HbAction* HbDialog::exec() |
310 For non modal popups, use show(). |
324 { |
|
325 HB_DEPRECATED("HbDialog::exec is deprecated. Use HbDialog::show() or HbDialog::open() instead!"); |
|
326 Q_D(HbDialog); |
|
327 |
|
328 HbAction *action = 0; |
|
329 QPointer<QObject> guard = this; |
|
330 HbPopup::exec(); |
|
331 if (!guard.isNull()) { |
|
332 action = d->closingAction; |
|
333 d->closingAction = 0; |
|
334 } |
|
335 return action; |
|
336 } |
|
337 |
|
338 /*! @alpha |
|
339 * |
|
340 * Shows the dialog as modal dialog returning immediately. |
|
341 |
|
342 * Connects finished(HbAction*) signal to the slot specified by \a receiver and |
|
343 * \a member. The signal will be disconnected from the slot when the |
|
344 * popup is closed. |
|
345 * |
|
346 * For non modal popups, use show(). |
|
347 */ |
311 */ |
348 |
312 |
349 void HbDialog::open( QObject* receiver, const char* member ) |
313 void HbDialog::open( QObject* receiver, const char* member ) |
350 { |
314 { |
351 Q_D(HbDialog); |
315 Q_D(HbDialog); |