29 #include "hbaction.h" |
29 #include "hbaction.h" |
30 #include "hbstyleoptionpopup.h" |
30 #include "hbstyleoptionpopup.h" |
31 #include "hbdeviceprofile.h" |
31 #include "hbdeviceprofile.h" |
32 #include "hbevent.h" |
32 #include "hbevent.h" |
33 #include "hbtoolbar_p.h" |
33 #include "hbtoolbar_p.h" |
|
34 #include "hbglobal_p.h" |
34 |
35 |
35 #include <QPainter> |
36 #include <QPainter> |
36 #include <QGraphicsSceneMouseEvent> |
37 #include <QGraphicsSceneMouseEvent> |
37 #include <QStyleOptionGraphicsItem> |
38 #include <QStyleOptionGraphicsItem> |
38 #include <QShowEvent> |
39 #include <QShowEvent> |
49 #include "hbeffectinternal_p.h" |
50 #include "hbeffectinternal_p.h" |
50 #define HB_POPUP_ITEM_TYPE "HB_POPUP" |
51 #define HB_POPUP_ITEM_TYPE "HB_POPUP" |
51 #endif |
52 #endif |
52 |
53 |
53 /*! |
54 /*! |
54 @stable |
55 @beta |
55 @hbcore |
56 @hbcore |
56 \class HbDialog |
57 \class HbDialog |
57 \brief HbDialog is a base class for different popup notes in Hb library. |
58 \brief HbDialog is a base class for different popup notes in Hb library. |
58 |
59 |
59 \image html hbpopup.png A popup with a header widget, a list as a content widget, |
60 \image html hbpopup.png A popup with a header widget, a list as a content widget, |
240 HbStyle::setItemName(contentWidget,"content"); |
241 HbStyle::setItemName(contentWidget,"content"); |
241 d->setWidget((d->headingWidget?1:0), d->contentWidget, contentWidget); |
242 d->setWidget((d->headingWidget?1:0), d->contentWidget, contentWidget); |
242 } |
243 } |
243 |
244 |
244 /*! |
245 /*! |
245 * It returns the primary action added to the control area |
246 \deprecated HbDialog::primaryAction() const |
246 * \sa setPrimaryAction() |
247 is deprecated. |
|
248 It returns the primary action added to the control area |
|
249 \sa setPrimaryAction() |
247 */ |
250 */ |
248 HbAction* HbDialog::primaryAction() const |
251 HbAction* HbDialog::primaryAction() const |
249 { |
252 { |
|
253 HB_DEPRECATED("HbAction* HbDialog::primaryAction() is deprecated. Use QGraphicsWidget action api instead"); |
250 Q_D(const HbDialog); |
254 Q_D(const HbDialog); |
251 return d->primaryAction; |
255 return d->primaryAction; |
252 } |
256 } |
253 |
257 |
254 /*! |
258 /*! |
255 * It adds the given action to the control area. |
259 \deprecated HbDialog::setPrimaryAction(HbAction*) |
256 * It is added to the left side of the control area if the layout direction of the application |
260 is deprecated. Please use QGraphicsWidget::addAction() family of functions instead. |
257 * is left-to-right and in the vice-versa if the layout direction of the application |
261 It adds the given action to the control area. |
258 * is right-to-left. |
262 It is added to the left side of the control area if the layout direction of the application |
259 * \sa primaryAction() |
263 is left-to-right and in the vice-versa if the layout direction of the application |
|
264 is right-to-left. |
|
265 \sa primaryAction() |
260 */ |
266 */ |
261 void HbDialog::setPrimaryAction(HbAction *action) |
267 void HbDialog::setPrimaryAction(HbAction *action) |
262 { |
268 { |
|
269 HB_DEPRECATED("HbDialog::setPrimaryAction(HbAction *action) is deprecated. Use QGraphicsWidget action api instead"); |
263 Q_D(HbDialog); |
270 Q_D(HbDialog); |
264 if (d->primaryAction && action != d->primaryAction) { |
271 if (d->primaryAction && action != d->primaryAction) { |
265 removeAction(d->primaryAction); |
272 removeAction(d->primaryAction); |
266 } |
273 } |
267 d->primaryAction = action; |
274 d->primaryAction = action; |
271 } |
278 } |
272 insertAction(before, action); |
279 insertAction(before, action); |
273 } |
280 } |
274 |
281 |
275 /*! |
282 /*! |
276 * It returns the secondary action added to the control area |
283 \deprecated HbDialog::secondaryAction() const |
277 * \sa setSecondaryAction() |
284 is deprecated. |
|
285 It returns the secondary action added to the control area |
|
286 \sa setSecondaryAction() |
278 */ |
287 */ |
279 HbAction* HbDialog::secondaryAction() const |
288 HbAction* HbDialog::secondaryAction() const |
280 { |
289 { |
|
290 HB_DEPRECATED("HbAction* HbDialog::secondaryAction() is deprecated. Use QGraphicsWidget action api instead"); |
281 Q_D(const HbDialog); |
291 Q_D(const HbDialog); |
282 return(d->secondaryAction); |
292 return(d->secondaryAction); |
283 } |
293 } |
284 |
294 |
285 /*! |
295 /*! |
286 * It adds the given action to the control area. |
296 \deprecated HbDialog::setSecondaryAction(HbAction*) |
287 * It is added to the right side of the control area if the layout direction of the application |
297 is deprecated. Please use QGraphicsWidget::addAction() family of functions instead. |
288 * is left-to-right and in the vice-versa if the layout direction of the application |
298 It adds the given action to the control area. |
289 * is right-to-left. |
299 It is added to the right side of the control area if the layout direction of the application |
290 * \sa secondaryAction() |
300 is left-to-right and in the vice-versa if the layout direction of the application |
|
301 is right-to-left. |
|
302 \sa secondaryAction() |
291 */ |
303 */ |
292 void HbDialog::setSecondaryAction(HbAction *action) |
304 void HbDialog::setSecondaryAction(HbAction *action) |
293 { |
305 { |
|
306 HB_DEPRECATED("HbDialog::setSecondaryAction(HbAction *action) is deprecated. Use QGraphicsWidget action api instead"); |
294 Q_D(HbDialog); |
307 Q_D(HbDialog); |
295 if (d->secondaryAction && action != d->secondaryAction) { |
308 if (d->secondaryAction && action != d->secondaryAction) { |
296 removeAction(d->secondaryAction); |
309 removeAction(d->secondaryAction); |
297 } |
310 } |
298 d->secondaryAction = action; |
311 d->secondaryAction = action; |
299 addAction(action); |
312 addAction(action); |
300 } |
313 } |
301 |
314 |
302 /*! |
315 /*! |
303 \deprecated HbDialog::exec() |
316 \deprecated HbDialog::exec() |
304 is deprecated. Please use HbDialog::open( QObject* receiver, const char* member ) instead. |
317 is deprecated. |
305 * |
318 Please use HbDialog::open( QObject* receiver, const char* member ) instead. |
306 * Executes the popup synchronously. |
319 |
307 * Note: when popup is executed syncronously it is always modal. |
320 Executes the popup synchronously. |
|
321 Note: when popup is executed syncronously it is always modal. |
308 */ |
322 */ |
309 HbAction* HbDialog::exec() |
323 HbAction* HbDialog::exec() |
310 { |
324 { |
|
325 HB_DEPRECATED("HbDialog::exec is deprecated. Use HbDialog::show() or HbDialog::open() instead!"); |
311 Q_D(HbDialog); |
326 Q_D(HbDialog); |
312 |
327 |
313 HbAction *action = 0; |
328 HbAction *action = 0; |
314 QPointer<QObject> guard = this; |
329 QPointer<QObject> guard = this; |
315 HbPopup::exec(); |
330 HbPopup::exec(); |
371 d->closingAction = closingAction; |
386 d->closingAction = closingAction; |
372 emit finished( d->closingAction ); |
387 emit finished( d->closingAction ); |
373 } else { |
388 } else { |
374 HbAction* nullAction(0); |
389 HbAction* nullAction(0); |
375 emit finished( nullAction ); |
390 emit finished( nullAction ); |
|
391 } |
|
392 if (d->receiverToDisconnectOnClose) { |
|
393 if (disconnect(this, SIGNAL(finished(HbAction*)), |
|
394 d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose)) { |
|
395 d->receiverToDisconnectOnClose = 0; |
|
396 d->memberToDisconnectOnClose.clear(); |
|
397 } |
376 } |
398 } |
377 |
399 |
378 HbPopup::closeEvent(event); |
400 HbPopup::closeEvent(event); |
379 } |
401 } |
380 |
402 |
455 d->doLayout(); |
477 d->doLayout(); |
456 } |
478 } |
457 return HbPopup::event(event); |
479 return HbPopup::event(event); |
458 } |
480 } |
459 |
481 |
|
482 /*! |
|
483 \reimp |
|
484 */ |
|
485 QSizeF HbDialog::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const |
|
486 { |
|
487 QSizeF hint = HbPopup::sizeHint(which, constraint); |
|
488 |
|
489 if (which == Qt::PreferredSize) { |
|
490 Q_D(const HbDialog); |
|
491 if (d->contentWidget) { |
|
492 QSizePolicy policy = d->contentWidget->sizePolicy(); |
|
493 if (policy.horizontalPolicy() & QSizePolicy::ExpandFlag) { |
|
494 hint.setWidth(QWIDGETSIZE_MAX); |
|
495 } |
|
496 |
|
497 if (policy.verticalPolicy() & QSizePolicy::ExpandFlag) { |
|
498 hint.setHeight(QWIDGETSIZE_MAX); |
|
499 } |
|
500 } |
|
501 } |
|
502 |
|
503 return hint; |
|
504 } |
|
505 |
460 #include "moc_hbdialog.cpp" |
506 #include "moc_hbdialog.cpp" |