src/hbcore/gui/hbpopup.cpp
changeset 34 ed14f46c0e55
parent 7 923ff622b8b9
equal deleted inserted replaced
31:7516d6d86cf5 34:ed14f46c0e55
    37 #include "hbvgchainedeffect_p.h"
    37 #include "hbvgchainedeffect_p.h"
    38 #include <QTimer>
    38 #include <QTimer>
    39 #include <QGraphicsSceneMouseEvent>
    39 #include <QGraphicsSceneMouseEvent>
    40 #include <QShowEvent>
    40 #include <QShowEvent>
    41 #include <QHideEvent>
    41 #include <QHideEvent>
    42 #include <QEventLoop>
       
    43 #include <QPointer>
    42 #include <QPointer>
    44 #include <QDebug>
    43 #include <QDebug>
    45 #include <QBitmap>
    44 #include <QBitmap>
    46 #include <hbinstance_p.h>
    45 #include <hbinstance_p.h>
       
    46 #include <QGraphicsScene>
    47 #include <QApplication> // krazy:exclude=qclasses
    47 #include <QApplication> // krazy:exclude=qclasses
    48 
    48 
    49 #include <hbwidgetfeedback.h>
    49 #include <hbwidgetfeedback.h>
    50 
    50 
    51 #ifdef HB_EFFECTS
    51 #ifdef HB_EFFECTS
    54 #endif
    54 #endif
    55 /*!
    55 /*!
    56     @beta
    56     @beta
    57     @hbcore
    57     @hbcore
    58     \class HbPopup
    58     \class HbPopup
    59     \brief HbPopup is a base class for different popups in Hb library.
    59     \brief The HbPopup class defines a set of properties that control the behavior of 
    60 
    60     the many dialog and popup classes that derive from it. 
    61     Popup is a widget that is displayed above other widgets in the view.
    61     
    62 
    62     Objects of classes derived from %HbPopup are called \b popups. Typically they
    63     Lastly shown popup is always positioned in Z order on the the top
    63     are displayed above other objects within the view, at the highest z-order. The %HbPopup
    64     of already visible popups.  
    64     class simply defines a frame with a number of properties. If you want to create an
    65 
    65     application dialog with a heading, content and a toolbar, use the HbDialog class (which
    66     A popup can be permanent or automatically dismissed after a
    66     is derived from %HbPopup) or one of its convenience subclasses.
    67     time-out.  Modal popups interrupt any other user interaction
    67     
    68     outside of the popup while they are visible, whereas non-modal
    68     %HbPopup provides properties that you can use to customize the following aspects of a popup:
    69     popups do not.
    69     
    70 
    70     - \b Modality. You can define whether the popup is modal or non-modal. A modal popup stops
    71     \sa HbDialog
    71       the user interacting with anything outside of the popup until it closes. A non-modal 
    72 */
    72       popup does not block the user's interaction with things outside of the popup. You 
    73 
    73       set and get the modality by calling setModal() and isModal(), respectively.  
    74 /*!
    74     
    75     \reimp
    75     - <b>Dismiss policy</b>. You can define which user actions, if any, cause the popup to 
       
    76       close. Possible values are defined by HbPopup::DismissPolicy. You set and get the dismiss 
       
    77       policy by calling setDismissPolicy() and dismissPolicy(), respectively.
       
    78     
       
    79     - <b>Background fade policy</b>. You can set a policy to fade everything behind the 
       
    80       popup. This is useful for modal dialogs, because the user cannot interact with 
       
    81       anything behind the popup. You control this policy by calling setBackgroundFaded() and 
       
    82       get the current policy by calling isBackgroundFaded().
       
    83     
       
    84     - \b Timeout. You can define a timeout that causes the popup to be dismissed automatically
       
    85       after a set a period. You set and get this property by calling setTimeout() and 
       
    86       timeout(), respectively. Call the setTimeout(HbPopup::DefaultTimeout) overload to use the 
       
    87       default value for the popup type, which provides a common look and feel.
       
    88       
       
    89     - <b>Frame background type</b>. You can define the popup's background style. However, 
       
    90       the actual appearance of the popup depends on the theme. You set and get this property by
       
    91       calling setFrameType() and frameType(), respectively.
       
    92       
       
    93     By default, popups are displayed in the center of the screen. Typically you should not override
       
    94     the default position of modal dialogs. However, some popups, such as context menus, need to be 
       
    95     in a specific position. For these, you can use the setPreferredPos() method to set the 
       
    96     preferred position.
       
    97     
       
    98     Popups that contain an editor may be repositioned by the virtual keyboard when it opens. 
       
    99     When the virtual keyboard closes, it attempts to reposition the popup back to its 
       
   100     previous position. However, this is not always possible, particularly when there has also
       
   101     been an orientation switch.
       
   102 
       
   103     \section _usecases_hbpopup Using the HbPopup class
       
   104     
       
   105     Although it is possible to create an instance of the HbPopup class, it is designed as a
       
   106     base class to provide common features to the many popup and dialog classes that are 
       
   107     derived from it (such as HbMenu, HbDialog, HbToolBarExtension, HbZoomSliderPopup). 
       
   108     
       
   109     How you open a popup depends on whether it is modal. It is important to use the 
       
   110     appropriate method, because this ensures the correct touch event handling.
       
   111     
       
   112     <table border="1" style="border-collapse: collapse; border: solid;">
       
   113     <tr><th>To open</TH><TH>Call</th></tr>
       
   114     <tr><td>Modal popups</td><td>open()</td></tr>
       
   115     <tr><td>Non-modal popups</td><td>\link QGraphicsItem::show() show()\endlink</td></tr>
       
   116     </table>
       
   117 
       
   118     \sa HbDialog, HbMenu
       
   119 */
       
   120 
       
   121 /*!
    76     \fn int HbPopup::type() const
   122     \fn int HbPopup::type() const
    77  */
   123  */
    78 
   124 
    79 /*!
   125 /*!
    80     \enum HbPopup::DefaultTimeout
   126     \enum HbPopup::DefaultTimeout
    81 
   127 
    82     This enum defines available default timeout values to be used in method
   128     Identifies default timeout values for various popup types. The timeout defines a time
    83     setTimeout(HbPopup::DefaultTimeout).
   129     period after which the popup is automatically closed. Using these default values 
       
   130     provides a consistent look and feel.
       
   131     \sa setTimeout(HbPopup::DefaultTimeout)
    84  */
   132  */
    85 
   133 
    86 /*!
   134 /*!
    87     \var HbPopup::NoTimeout
   135     \var HbPopup::NoTimeout
    88 
   136     Defines a permanent popup, for which no timeout is defined.
    89     No timeout is defined for automatically closing the popup. i.e. the popup is permanent.
       
    90  */
   137  */
    91 
   138 
    92 /*!
   139 /*!
    93     \var HbPopup::ConfirmationNoteTimeout
   140     \var HbPopup::ConfirmationNoteTimeout
    94 
   141     The default timeout value for confirmation notes.
    95     Timeout value intended to be used by confirmation notes.
       
    96  */
   142  */
    97 
   143 
    98 /*!
   144 /*!
    99     \var HbPopup::StandardTimeout
   145     \var HbPopup::StandardTimeout
   100 
   146     The default timeout value for standard non-permanent popups, such as notes.
   101     The default timeout value intended to be used by most non-permanent popups e.g. by notes.
       
   102  */
   147  */
   103 
   148 
   104 /*!
   149 /*!
   105     \var HbPopup::ContextMenuTimeout
   150     \var HbPopup::ContextMenuTimeout
   106 
   151     The default timeout value for context menus.
   107     The default timeout value intended to be used by context menus.
       
   108  */
   152  */
   109 
   153 
   110 /*!
   154 /*!
   111     \enum HbPopup::DismissPolicy
   155     \enum HbPopup::DismissPolicy
   112 
   156 
   113     This enum defines available dismiss policy values.
   157     Defines the available dismiss policy values. The dismiss policy defines which
   114 
   158     user actions cause the popup to close.
   115     The dismiss policy defines what user actions will cause the popup to be dismissed i.e. closed.
   159     
       
   160     \sa setDismissPolicy(), dismissPolicy()
   116  */
   161  */
   117 
   162 
   118 /*!
   163 /*!
   119     \var HbPopup::NoDismiss
   164     \var HbPopup::NoDismiss
   120 
   165     The popup cannot be closed by the user.
   121     The popup cannot be dismissed automatically by user interaction.
       
   122  */
   166  */
   123 
   167 
   124 /*!
   168 /*!
   125     \var HbPopup::TapInside
   169     \var HbPopup::TapInside
   126 
   170     Closes the popup when the user taps within the popup's bounding rectangle.
   127     The popup is dismissed when user taps within the bounding rectangle of the popup.
       
   128  */
   171  */
   129 
   172 
   130 /*!
   173 /*!
   131     \var HbPopup::TapOutside
   174     \var HbPopup::TapOutside
   132 
   175 
   133     The popup is dismissed when user taps outside of the bounding rectangle of the popup.
   176     Closes the popup when the user taps outside of the popup's bounding rectangle.
   134  */
   177  */
   135 
   178 
   136 /*!
   179 /*!
   137     \var HbPopup::TapAnywhere
   180     \var HbPopup::TapAnywhere
   138 
   181     Closes the popup when the user taps either inside or outside the popup's bounding 
   139     The popup is dismissed when user taps either within or outside
   182     rectangle.
   140     of the bounding rectangle of the popup.
       
   141  */
   183  */
   142 
   184 
   143 /*!
   185 /*!
   144     \enum HbPopup::FrameType
   186     \enum HbPopup::FrameType
   145 
   187 
   146     This enum defines available frame type values.
   188     Identifies the background graphical styles of the popup's frame.
   147 
   189 
   148     The frame types defines what frame item backgrounds will be used
   190     \sa setFrameType(), frameType()
   149     by the popup. Actual appearance is dependent on theme.
       
   150  */
   191  */
   151 
   192 
   152 /*!
   193 /*!
   153     \var HbPopup::Strong
   194     \var HbPopup::Strong
   154 
   195     Use the "strong" frame background style.
   155     The popup is using strong frame.
       
   156  */
   196  */
   157 
   197 
   158 /*!
   198 /*!
   159     \var HbPopup::Weak
   199     \var HbPopup::Weak
   160 
   200     Use the "weak" frame background style.
   161     The popup is using weak frame.
       
   162  */
   201  */
   163 
   202 
   164 /*!
   203 /*!
   165     \fn void HbPopup::aboutToShow();
   204     \fn void HbPopup::aboutToShow();
   166 
   205 
   167     This signal is emitted when the popup is about to be shown i.e. when method show() is called.
   206     This signal is emitted when the popup is about to be shown; that is, when 
       
   207     \link QGraphicsItem::show() show()\endlink is called.
   168  */
   208  */
   169 
   209 
   170 /*!
   210 /*!
   171     \fn void HbPopup::aboutToHide();
   211     \fn void HbPopup::aboutToHide();
   172 
   212 
   173     This signal is emitted when the popup is about to be hidden i.e. when method hide() is called.
   213     This signal is emitted when the popup is about to be hidden; that is, when 
       
   214     \link QGraphicsItem::hide() hide()\endlink is called.
   174  */
   215  */
   175 
   216 
   176 
   217 
   177 /*!
   218 /*!
   178     \fn void HbPopup::aboutToClose();
   219     \fn void HbPopup::aboutToClose();
   179 
   220 
   180     This signal is emitted when the popup is about to be closed i.e. when method close() is called
   221     This signal is emitted when the popup is about to close; that is, when 
   181     or the popup is
   222     \link QGraphicsWidget::close() close()\endlink is called or the popup is dismissed 
   182     dismissed by the user or timeout.
   223     by the user or timeout.
   183  */
   224  */
   184 
   225 
   185 /*!
   226 /*!
   186     \enum HbPopup::Placement
   227     \enum HbPopup::Placement
   187 
   228     Identifies the corners and edges of the popup for use when setting its position
   188     Placement is the corner or edge to which position of the popup refers to.
   229     using setPreferredPos(). 
   189   */
   230   */
   190 
   231   
   191 /*!
   232 /*!
       
   233     \var HbPopup::TopLeftCorner
       
   234     The popup's top left corner.
       
   235  */
       
   236   
       
   237 /*!
       
   238     \var HbPopup::TopRightCorner
       
   239     The popup's top right corner.
       
   240  */
       
   241    
       
   242 /*!
       
   243     \var HbPopup::BottomLeftCorner
       
   244     The popup's bottom left corner.
       
   245  */
       
   246    
       
   247 /*!
       
   248     \var HbPopup::BottomRightCorner
       
   249     The popup's bottom right corner.
       
   250  */
       
   251    
       
   252 /*!
       
   253     \var HbPopup::TopEdgeCenter
       
   254     The center of the popup's top edge.
       
   255  */
       
   256    
       
   257 /*!
       
   258     \var HbPopup::RightEdgeCenter
       
   259     The center of the popup's rightmost edge.
       
   260  */
       
   261     
       
   262 /*!
       
   263     \var HbPopup::BottomEdgeCenter
       
   264     The center of the popup's bottom edge.
       
   265  */
       
   266     
       
   267 /*!
       
   268     \var HbPopup::LeftEdgeCenter
       
   269     The center of the popup's leftmost edge.
       
   270  */
       
   271  
       
   272  /*!
       
   273     \var HbPopup::Center
       
   274     The center of the popup.
       
   275  */
       
   276 
       
   277 namespace {
       
   278     //initial values if not found from hbpopup.css
       
   279     static const int NO_TIMEOUT = 0;
       
   280     static const int CONFIRMATION_NOTE_TIMEOUT = 1500;
       
   281     static const int STANDARD_TIMEOUT = 3000;
       
   282     static const int CONTEXT_MENU_TIMEOUT = 6000;
       
   283 
       
   284     static const QLatin1String NO_TIMEOUT_STRING("no-timeout");
       
   285     static const QLatin1String CONFIRMATION_NOTE_TIMEOUT_STRING("confirmation-note-timeout");
       
   286     static const QLatin1String STANDARD_TIMEOUT_STRING("standard-timeout");
       
   287     static const QLatin1String CONTEXT_MENU_TIMEOUT_STRING("context-menu-timeout");
       
   288 }
       
   289 
       
   290 /*
       
   291    Currently, virtual keyboard must be able to position a popup
       
   292    containing an editor to an arbitrary place. VKB does its best to
       
   293    reposition the popup back to original position when needed. At least in
       
   294    orientation switch the old position naturally is wrong, hence popup
       
   295    must be relayouted.
       
   296 
       
   297    It would be unreasonable to make special checks for popup in vkb
       
   298    side. It also would be unreasonable to do special checks for vkb in
       
   299    popup side. Hence this semi-hidden dynamic property for
       
   300    communicating this special case.
       
   301 
       
   302    WARNING: Do not count on this special behaviour, we might remove it
       
   303    without prior notice. If you do require such a behavior, please
       
   304    raise a feature request and we might make this a proper API.
       
   305  */
       
   306 const char* KPositionManagedByVKB("PositionManagedByVKB");
       
   307 
       
   308 /*
   192     \primitives
   309     \primitives
   193     \primitive{background} HbFrameItem representing the popup background. The background can be weak or strong (different graphical styles) depending on popup type.
   310     \primitive{background} HbFrameItem representing the popup background. The background can be 
       
   311     weak or strong (different graphical styles) depending on popup type.
   194     \primitive{P_Popup_heading_frame} HbFrameItem representing the popup heading text background
   312     \primitive{P_Popup_heading_frame} HbFrameItem representing the popup heading text background
   195   */
   313   */
   196 
       
   197 static const struct { HbPopup::DefaultTimeout timeout; int value; } timeoutValues[] =
       
   198 {
       
   199     {HbPopup::NoTimeout,0},
       
   200     {HbPopup::ConfirmationNoteTimeout,1500},
       
   201     {HbPopup::StandardTimeout,3000},
       
   202     {HbPopup::ContextMenuTimeout,6000},
       
   203 };
       
   204 
       
   205 HbPopupBackGround::HbPopupBackGround(HbPopup * popup, QGraphicsItem *parent) :
   314 HbPopupBackGround::HbPopupBackGround(HbPopup * popup, QGraphicsItem *parent) :
   206         QGraphicsItem(parent),
   315         QGraphicsItem(parent),
   207         popup(popup)
   316         popup(popup)
   208 {
   317 {
   209     // This is needed to be able to block moving the focus to items behind background item by
   318     // This is needed to be able to block moving the focus to items behind background item by
   271     }
   380     }
   272     return QGraphicsItem::sceneEvent(event);
   381     return QGraphicsItem::sceneEvent(event);
   273 }
   382 }
   274 
   383 
   275 HbPopupPrivate::HbPopupPrivate( ) :
   384 HbPopupPrivate::HbPopupPrivate( ) :
   276     eventLoop(0),
       
   277     hasEffects(false),
   385     hasEffects(false),
   278     closed(false),
   386     closed(false),
   279     hidingInProgress(true),
   387     hidingInProgress(true),
       
   388     showingInProgress(false),
   280     delayedHide(false),
   389     delayedHide(false),
   281     deleteOnClose(false),
   390     deleteOnClose(false),
   282     modal(true), // must be in sync QGraphicsItem::ItemIsFocusable of backgroundItem
   391     modal(true), // must be in sync QGraphicsItem::ItemIsFocusable of backgroundItem
   283     fadeBackground(true),
   392     fadeBackground(true),
   284     inDestruction(false),
   393     inDestruction(false),
   285     aboutToShowSignalGuard(false),
   394     aboutToShowSignalGuard(false),
   286     duplicateShowEvent(false),
   395     duplicateShowEvent(false),
   287     timedOut(false),
   396     timedOut(false),
   288     timeout(HbPopupPrivate::timeoutValue(HbPopup::StandardTimeout)),
   397     timeout(-1),
       
   398     timeoutPending(true),
       
   399     pendingTimeout(HbPopup::StandardTimeout),
   289     //    priorityValue(HbPopup::Default),
   400     //    priorityValue(HbPopup::Default),
   290     priorityValue(0),
   401     priorityValue(0),
   291     dismissPolicy(HbPopup::TapOutside),
   402     dismissPolicy(HbPopup::TapOutside),
   292     backgroundItem(0),
   403     backgroundItem(0),
   293     mousePressLocation(None),
   404     mousePressLocation(None),
   294     frameType(HbPopup::Strong),
   405     frameType(HbPopup::Strong),
   295     preferredPosSet(false),
   406     preferredPosSet(false),
   296     mStartEffect(false),
   407     placement(HbPopup::TopLeftCorner),
       
   408     mStartEffect(true),
   297     mScreenMargin(0.0),
   409     mScreenMargin(0.0),
   298     mAutoLayouting(true),
   410     mAutoLayouting(true),
   299     mOriginalAutoLayouting(mAutoLayouting),
   411     mOriginalAutoLayouting(mAutoLayouting),
       
   412     mActivePopup(true),
       
   413     mMaskedItem(0),
       
   414     mPopupMask(0),
   300     mVgMaskEffect(0),
   415     mVgMaskEffect(0),
   301     mOrientationEffectHide(false),
   416     mOrientationEffectHide(false),
       
   417     mGestureOverride(false),
       
   418     mFullScreen(false),
   302     timeoutTimerInstance(0)
   419     timeoutTimerInstance(0)
   303 {
   420 {
   304 }
   421 }
   305 
   422 
   306 HbPopupPrivate::~HbPopupPrivate()
   423 HbPopupPrivate::~HbPopupPrivate()
   307 {
   424 {
   308     stopTimeout();
   425     stopTimeout();
   309     delete timeoutTimerInstance;
   426     delete timeoutTimerInstance;
       
   427     delete mPopupMask;
   310 }
   428 }
   311 
   429 
   312 void HbPopupPrivate::init()
   430 void HbPopupPrivate::init()
   313 {
   431 {
   314     Q_Q(HbPopup);
   432     Q_Q(HbPopup);
   315 
   433 
   316     q->setAttribute(Hb::InsidePopup);
   434     q->setAttribute(Hb::InsidePopup);
   317 
   435 
   318     // By default popups are focusable
   436     // By default popups are focusable
   319     q->setFocusPolicy(Qt::StrongFocus);    
   437     q->setFocusPolicy(Qt::StrongFocus);
   320     setBackgroundItem(HbStyle::P_Popup_background);
   438     q->setBackgroundItem(new HbFrameItem(QLatin1String("qtg_fr_popup"), HbFrameDrawer::NinePieces), -1);
   321     q->updatePrimitives();
   439     q->updatePrimitives();
   322 
   440 
   323 
   441 
   324     // Only for popup without parent
   442     // Only for popup without parent
   325     if (!q->parentItem()) {
   443     if (!q->parentItem()) {
   326         backgroundItem = new HbPopupBackGround(q);
   444         backgroundItem = new HbPopupBackGround(q);
   327         backgroundItem->setVisible(false);
   445         backgroundItem->setVisible(false);
   328 
       
   329         // Popup is invisible by default (explicit show or open call is required)
   446         // Popup is invisible by default (explicit show or open call is required)
   330         q->setVisible(false);
   447         q->setVisible(false);
   331     }
   448     }
   332     hidingInProgress = false; 
   449     hidingInProgress = false; 
   333     QGraphicsItem::GraphicsItemFlags itemFlags = q->flags();
   450     QGraphicsItem::GraphicsItemFlags itemFlags = q->flags();
   334     itemFlags |= QGraphicsItem::ItemClipsToShape;
   451     itemFlags |= QGraphicsItem::ItemClipsToShape;
   335     itemFlags |= QGraphicsItem::ItemClipsChildrenToShape;
   452     itemFlags |= QGraphicsItem::ItemClipsChildrenToShape;
   336     itemFlags |= QGraphicsItem::ItemSendsGeometryChanges;
   453     itemFlags |= QGraphicsItem::ItemSendsGeometryChanges;
   337     //itemFlags |= QGraphicsItem::ItemIsPanel;
   454     itemFlags |= QGraphicsItem::ItemIsPanel;
   338     q->setFlags(itemFlags);  
   455     q->setFlags(itemFlags);
   339 }
   456     q->setActive(false);
       
   457 
       
   458     q->setAcceptTouchEvents(true);
       
   459 
       
   460     defaultTimeouts[HbPopup::NoTimeout] = NO_TIMEOUT;
       
   461     defaultTimeouts[HbPopup::ConfirmationNoteTimeout] = CONFIRMATION_NOTE_TIMEOUT;
       
   462     defaultTimeouts[HbPopup::StandardTimeout] = STANDARD_TIMEOUT;
       
   463     defaultTimeouts[HbPopup::ContextMenuTimeout] = CONTEXT_MENU_TIMEOUT;
       
   464 }
       
   465 
   340 void HbPopupPrivate::_q_appearEffectEnded(HbEffect::EffectStatus status)
   466 void HbPopupPrivate::_q_appearEffectEnded(HbEffect::EffectStatus status)
   341 {
   467 {
   342 	Q_UNUSED(status);
   468     Q_UNUSED(status);
       
   469     Q_Q(HbPopup);
       
   470 
       
   471     showingInProgress = false;
       
   472     q->emit popupReady();
       
   473 }
       
   474 
       
   475 void HbPopupPrivate::_q_maskEffectDestroyed()
       
   476 {
       
   477     mVgMaskEffect = 0;
   343 }
   478 }
   344 
   479 
   345 CSystemToneService* HbPopupPrivate::systemToneService()
   480 CSystemToneService* HbPopupPrivate::systemToneService()
   346 {
   481 {
   347 	return HbInstancePrivate::d_ptr()->systemTone();
   482     return HbInstancePrivate::d_ptr()->systemTone();
   348 }
   483 }
   349 /*
   484 /*
   350  Sets the priority for a popup.
   485  Sets the priority for a popup.
   351  A popup with higher priority is always shown on top of a popup with lower priority.
   486  A popup with higher priority is always shown on top of a popup with lower priority.
   352  In case of popups with same priority the lastly shown will be on top.
   487  In case of popups with same priority the lastly shown will be on top.
   363 
   498 
   364 #ifdef HB_EFFECTS
   499 #ifdef HB_EFFECTS
   365 void HbPopupPrivate::_q_delayedHide(HbEffect::EffectStatus status)
   500 void HbPopupPrivate::_q_delayedHide(HbEffect::EffectStatus status)
   366 {
   501 {
   367     Q_UNUSED(status);
   502     Q_UNUSED(status);
   368 
       
   369     Q_Q(HbPopup);
   503     Q_Q(HbPopup);
   370 
   504 
   371     // Apply forceHide only if the effect started successfully
   505     // Apply forceHide only if the effect started successfully
   372     if (status.reason != Hb::EffectNotStarted) {
   506     if (status.reason != Hb::EffectNotStarted) {
   373         forceHide();
   507         forceHide();
   377 
   511 
   378     if (deleteOnClose) {
   512     if (deleteOnClose) {
   379         q->deleteLater();
   513         q->deleteLater();
   380     }
   514     }
   381     hidingInProgress = false;
   515     hidingInProgress = false;
       
   516     mGestureOverride = false;
   382 }
   517 }
   383 
   518 
   384 void HbPopupPrivate::_q_orientationAboutToChange(Qt::Orientation orient, bool animate)
   519 void HbPopupPrivate::_q_orientationAboutToChange(Qt::Orientation orient, bool animate)
   385 {
   520 {
   386     Q_UNUSED(orient);    
   521     Q_UNUSED(orient);    
   395 
   530 
   396 void HbPopupPrivate::_q_orientationChanged()
   531 void HbPopupPrivate::_q_orientationChanged()
   397 {
   532 {
   398     Q_Q(HbPopup);
   533     Q_Q(HbPopup);
   399     if (q->isVisible()) {
   534     if (q->isVisible()) {
   400         QEvent userEvent(QEvent::ContextMenu);
   535         QEvent userEvent(QEvent::LayoutRequest);
   401         QCoreApplication::sendEvent(q, &userEvent);
   536         QCoreApplication::sendEvent(q, &userEvent);
   402     }
   537     }
       
   538 
       
   539     q->repolish();
   403 #ifdef HB_EFFECTS
   540 #ifdef HB_EFFECTS
   404     if (mOrientationEffectHide) {
   541     if (mOrientationEffectHide) {
       
   542         QRectF extRect(0.0,
       
   543                        -q->boundingRect().height(),
       
   544                        q->boundingRect().width(),
       
   545                        0);
   405         HbEffect::cancel(q);
   546         HbEffect::cancel(q);
   406         HbEffect::start(q, "HB_POPUP", "orient_appear");
   547         HbEffect::start(q, "HB_POPUP", "orient_appear", q, "_q_appearEffectEnded",
       
   548                         QVariant(), extRect);
   407         mOrientationEffectHide = false;
   549         mOrientationEffectHide = false;
       
   550         showingInProgress = true;
   408     }
   551     }
   409 #endif
   552 #endif
   410 }
   553 }
   411 
   554 
   412 void HbPopupPrivate::_q_timeoutFinished()
   555 void HbPopupPrivate::_q_timeoutFinished()
   432 
   575 
   433 void HbPopupPrivate::setTimeout(int msec)
   576 void HbPopupPrivate::setTimeout(int msec)
   434 {
   577 {
   435     Q_Q(HbPopup);
   578     Q_Q(HbPopup);
   436 
   579 
       
   580     timeoutPending = false;
   437     int prevTimeout = timeout;
   581     int prevTimeout = timeout;
   438     timeout = msec;
   582     timeout = msec;
   439     if (msec > 0) {
   583     if (msec > 0) {
   440         timeoutTimer()->setInterval(msec);
   584         timeoutTimer()->setInterval(msec);
   441         // If timeout was 0 and it is now set to something > 0 then start the timer.
   585         // If timeout was 0 and it is now set to something > 0 then start the timer.
   479 
   623 
   480 void HbPopupPrivate::handleBackgroundMousePressEvent()
   624 void HbPopupPrivate::handleBackgroundMousePressEvent()
   481 {
   625 {
   482     Q_Q(HbPopup);
   626     Q_Q(HbPopup);
   483     mousePressLocation = Background;
   627     mousePressLocation = Background;
   484     if (dismissPolicy & HbPopup::TapOutside) {
   628     if (dismissPolicy & HbPopup::TapOutside && !modal) {
   485         q->close();
   629         q->close();
   486     }
   630     }
   487 }
   631 }
   488 
   632 
   489 void HbPopupPrivate::handleBackgroundMouseReleaseEvent(QGraphicsSceneMouseEvent *event)
   633 void HbPopupPrivate::handleBackgroundMouseReleaseEvent(QGraphicsSceneMouseEvent *event)
   507                 // Close popup if mouse press is initiated within popup or TapOutside is set
   651                 // Close popup if mouse press is initiated within popup or TapOutside is set
   508                 if (mousePressLocation == Popup || dismissPolicy & HbPopup::TapOutside) {
   652                 if (mousePressLocation == Popup || dismissPolicy & HbPopup::TapOutside) {
   509                     q->close();
   653                     q->close();
   510                 }
   654                 }
   511             }
   655             }
       
   656         } else if ( mousePressLocation == Background &&
       
   657                     dismissPolicy & HbPopup::TapOutside && modal) {
       
   658             q->close();
   512         }
   659         }
   513     }
   660     }
   514 
   661 
   515     // reset mousePressLocation
   662     // reset mousePressLocation
   516     mousePressLocation = None;
   663     mousePressLocation = None;
   517 }
       
   518 
       
   519 
       
   520 int HbPopupPrivate::timeoutValue(HbPopup::DefaultTimeout timeout)
       
   521 {
       
   522     int count = sizeof(timeoutValues) / sizeof(timeoutValues[0]);
       
   523     if (timeout < 0 || timeout >= count) {
       
   524         return timeoutValues[HbPopup::NoTimeout].value;
       
   525     }
       
   526     return timeoutValues[timeout].value;
       
   527 }
   664 }
   528 
   665 
   529 void HbPopupPrivate::forceHide()
   666 void HbPopupPrivate::forceHide()
   530 {
   667 {
   531     Q_Q(HbPopup);
   668     Q_Q(HbPopup);
   580             backgroundItem->setPanelModality(QGraphicsItem::NonModal);
   717             backgroundItem->setPanelModality(QGraphicsItem::NonModal);
   581         }
   718         }
   582     }
   719     }
   583 }
   720 }
   584 
   721 
       
   722 void HbPopupPrivate::setFullScreen(bool enable)
       
   723 {
       
   724     if (mFullScreen != enable) {
       
   725         Q_Q(HbPopup);
       
   726         mFullScreen = enable;
       
   727         if (enable) {
       
   728             q->setBackgroundItem(new HbFrameItem(QLatin1String("qtg_graf_screen_bg_prt"), HbFrameDrawer::OnePiece), -1);
       
   729         } else {
       
   730             if (frameType == HbPopup::Weak) {
       
   731                 q->setBackgroundItem(new HbFrameItem(QLatin1String("qtg_fr_popup_secondary"), HbFrameDrawer::NinePieces), -1);
       
   732             } else {
       
   733                 q->setBackgroundItem(new HbFrameItem(QLatin1String("qtg_fr_popup"), HbFrameDrawer::NinePieces), -1);
       
   734             }
       
   735         }
       
   736         q->repolish();
       
   737     }
       
   738 }
       
   739 
   585 void HbPopupPrivate::calculateShape()
   740 void HbPopupPrivate::calculateShape()
   586 {
   741 {
   587 #if 0
       
   588     Q_Q(HbPopup);
   742     Q_Q(HbPopup);
       
   743     // Only used for HbMenu currently, this is not fully correct as some dialogs may need masking too.
       
   744     if (q->type() != Hb::ItemType_Menu && q->type() != Hb::ItemType_ColorDialog) {
       
   745         return;
       
   746     }
       
   747     // Cannot set up masking if the background item is not available.
       
   748     if (!q->backgroundItem() || !q->backgroundItem()->boundingRect().isValid()) {
       
   749         return;
       
   750     }
   589     // Contrary to the name, HbVgMaskEffect has a software
   751     // Contrary to the name, HbVgMaskEffect has a software
   590     // implementation too, and we will actually force the usage of
   752     // implementation too, and we will actually force the usage of
   591     // that here, ignoring the pure OpenVG version.
   753     // that here, ignoring the pure OpenVG version.
   592     if (!mVgMaskEffect) {
   754     if (!mVgMaskEffect) {
       
   755         if (!mMaskedItem) {
       
   756             mMaskedItem = q;
       
   757         }
   593         mVgMaskEffect = new HbVgMaskEffect;
   758         mVgMaskEffect = new HbVgMaskEffect;
   594         // Masking does not work reliably on HW.
   759         // Masking does not work reliably on HW.
   595         mVgMaskEffect->setForceSwMode(true);
   760         mVgMaskEffect->setForceSwMode(true);
   596         // There may be children (like the scroll area in menus) that
   761         // There may be children (like the scroll area in menus) that
   597         // would mess up the masking so exclude those.
   762         // would mess up the masking so exclude those.
   598         mVgMaskEffect->setIncludeSourceItemOnly(true);
   763         mVgMaskEffect->setIncludeSourceItemOnly(true);
   599         if (!q->graphicsEffect()) {
   764         if (!mMaskedItem->graphicsEffect()) {
   600             // Attach the effect. Ownership is transferred to q.
   765             // Attach the effect. Ownership is transferred to the chain. The
   601             mVgMaskEffect->install(q);
   766             // ownership of the chain is transferred to q.  The chain is needed
       
   767             // because we must co-exist with FXML-based filter effects.
       
   768             HbVgChainedEffect *c = new HbVgChainedEffect;
       
   769             c->add(mVgMaskEffect);            
       
   770             c->install(mMaskedItem);
   602         } else {
   771         } else {
   603             // Avoid replacing already set effects. Do not mask if
   772             // Avoid replacing already set effects. Do not mask if this is not
   604             // this is not possible, otherwise we would unexpectedly
   773             // possible, otherwise we would unexpectedly delete the previously
   605             // delete the previously set graphics effect.
   774             // set graphics effect. However by being able to add the effect to a
   606             HbVgChainedEffect *c = qobject_cast<HbVgChainedEffect *>(q->graphicsEffect());
   775             // chain makes it possible to co-exist with FXML-based filter
       
   776             // effects. Similar solution is also present in HbEffectGroup.
       
   777             HbVgChainedEffect *c = qobject_cast<HbVgChainedEffect *>(mMaskedItem->graphicsEffect());
   607             if (c) {
   778             if (c) {
   608                 c->add(mVgMaskEffect);
   779                 c->add(mVgMaskEffect);
   609             } else {
   780             } else {
   610                 delete mVgMaskEffect;
   781                 delete mVgMaskEffect;
       
   782                 mVgMaskEffect = 0;
   611             }
   783             }
   612         }
   784         }
   613     }
   785         if (mVgMaskEffect) {
   614     QPixmap image(QSize(static_cast<int>(q->backgroundItem()->boundingRect().width()),
   786             // Make sure that mask effect is reset when destroyed
   615                         static_cast<int>(q->backgroundItem()->boundingRect().height())));
   787             QObject::connect(mVgMaskEffect, SIGNAL(destroyed()), q, SLOT(_q_maskEffectDestroyed()));
       
   788         }
       
   789     }
       
   790     /*if (!mPopupMask) {
       
   791         mPopupMask= new HbFrameItem();
       
   792         mPopupMask->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
   793         mPopupMask->frameDrawer().setFrameGraphicsName(QLatin1String("qtg_fr_popup_mask"));
       
   794     }
       
   795     mPopupMask->setGeometry(q->boundingRect());*/
       
   796 
       
   797     QPixmap image(q->backgroundItem()->boundingRect().size().toSize());
   616     image.fill(Qt::transparent);
   798     image.fill(Qt::transparent);
   617     QPainter imagePainter(&image);
   799     QPainter imagePainter(&image);
       
   800     //mPopupMask->paint(&imagePainter, 0, 0);
   618     q->backgroundItem()->paint(&imagePainter, 0, 0);
   801     q->backgroundItem()->paint(&imagePainter, 0, 0);
   619     imagePainter.end();
   802     imagePainter.end();
   620     mVgMaskEffect->setMask(image);
   803     mVgMaskEffect->setMask(image);
   621 #endif
   804 }
   622 }
   805 
   623 
   806 
   624 /*!
   807 
   625  Constructs a popup with given  \a parent graphics item.\n
   808 /*!
   626  Note: popups with \a parent set as 0 are behaving as real popups.
   809     Constructs a popup with the given \a parent graphics item. For true popup 
   627  This is actually the intended use.
   810     behavior (which means that it opens above other objects, at the highest z-order) 
   628 
   811     set \a parent to 0. This is the primary intended use of this class.
   629  However in some situation could be useful to embedd a popup into a QGraphicsItem.
   812 
   630  In this case a non zero \a parent value must be passed.
   813     However, it may sometimes be useful to embed a popup into a QGraphicsItem. To do 
   631  Popups with parent items behaving just like any other QGraphicsWidget.
   814     this, pass a non-zero \a parent value. HbPopup objects that have a parent are 
   632  The following features are not supported (i.e. ignored) for popup with parents:
   815     not real popups: they behave like any other QGraphicsWidget object and following
   633 
   816     properties are ignored. In addition the aboutToClose() signal is not emitted.
   634        - modality
   817     
   635        - timeout
   818     - \link isModal() modal\endlink property
   636        - unfadedItems
   819     - \link timeout() timeout\endlink  property
   637        - dismissPolicy
   820     - \link isBackgroundFaded() Backgroundfaded\endlink property
   638        - signal aboutToClose
   821     - \link  dismissPolicy() dismissPolicy\endlink property
   639 */
   822 */
   640 HbPopup::HbPopup(QGraphicsItem *parent) :
   823 HbPopup::HbPopup(QGraphicsItem *parent) :
   641     HbWidget(*new HbPopupPrivate,parent)
   824     HbWidget(*new HbPopupPrivate,parent)
   642 {
   825 {
   643     Q_D(HbPopup);
   826     Q_D(HbPopup);
   644     d->q_ptr = this;
   827     d->q_ptr = this;
   645     d->init();    
   828     d->init();
   646 }
   829 }
   647 
   830 
   648 
   831 
   649 /*!
   832 /*!
   650     \internal
   833     \internal
   652 HbPopup::HbPopup(HbPopupPrivate &dd, QGraphicsItem *parent) :
   835 HbPopup::HbPopup(HbPopupPrivate &dd, QGraphicsItem *parent) :
   653     HbWidget(dd, parent)
   836     HbWidget(dd, parent)
   654 {
   837 {
   655     Q_D(HbPopup);
   838     Q_D(HbPopup);
   656     d->q_ptr = this;
   839     d->q_ptr = this;
   657     d->init();    
   840     d->init();
   658 }
   841 }
   659 /*!
   842 /*!
   660  Destroys the popup.
   843     Destructor.
   661 */
   844 */
   662 HbPopup::~HbPopup()
   845 HbPopup::~HbPopup()
   663 {
   846 {
   664     Q_D(HbPopup);
   847     Q_D(HbPopup);
   665     d->inDestruction = true;
   848     d->inDestruction = true;
   669     HbGraphicsScene *hbScene = qobject_cast<HbGraphicsScene *>(scene());
   852     HbGraphicsScene *hbScene = qobject_cast<HbGraphicsScene *>(scene());
   670     if (hbScene) {
   853     if (hbScene) {
   671         hbScene->d_ptr->hidePopup(this);
   854         hbScene->d_ptr->hidePopup(this);
   672     }
   855     }
   673 
   856 
   674     if (d->eventLoop) {
       
   675         d->eventLoop->exit();
       
   676     }
       
   677     if (d->backgroundItem) {
   857     if (d->backgroundItem) {
   678         // Set backgroundItem->popup to 0 to avoid double deletion
   858         // Set backgroundItem->popup to 0 to avoid double deletion
   679         // e.g. when popup is deleted by scene before its backgroundItem
   859         // e.g. when popup is deleted by scene before its backgroundItem
   680         d->backgroundItem->popup = 0;
   860         d->backgroundItem->popup = 0;
   681 
   861 
   686             delete d->backgroundItem;
   866             delete d->backgroundItem;
   687         }
   867         }
   688     }
   868     }
   689 }
   869 }
   690 
   870 
   691 
   871 /*!
   692 /*!
   872     Returns the popup's timeout property in milliseconds. The timeout causes the popup to
   693  Returns the popup timeout property in milliseconds.
   873     be dismissed automatically after the specified time period has elapsed. A value of
   694  If this property is not set the deafult is HbPopup::StandardTimeout.
   874     zero or less than zero, means that the popup is permanent and the user must take 
   695  \sa setTimeout()
   875     some explicit action in order to close the popup. 
       
   876     
       
   877     The default value for this property is HbPopup::StandardTimeout.
       
   878       
       
   879     \sa setTimeout(), setTimeout(HbPopup::DefaultTimeout)
   696 */
   880 */
   697 int HbPopup::timeout() const
   881 int HbPopup::timeout() const
   698 {
   882 {
   699     Q_D(const HbPopup);
   883     Q_D(const HbPopup);
       
   884     if (d->timeoutPending) {
       
   885         HbStyleParameters params;
       
   886         QLatin1String timeoutString("");
       
   887         switch (d->pendingTimeout) {
       
   888             case HbPopup::NoTimeout:
       
   889                 timeoutString = NO_TIMEOUT_STRING;
       
   890                 break;
       
   891             case HbPopup::ContextMenuTimeout:
       
   892                 timeoutString = CONTEXT_MENU_TIMEOUT_STRING;
       
   893                 break;
       
   894             case HbPopup::StandardTimeout:
       
   895                 timeoutString = STANDARD_TIMEOUT_STRING;
       
   896                 break;
       
   897             case HbPopup::ConfirmationNoteTimeout:
       
   898                 timeoutString = CONFIRMATION_NOTE_TIMEOUT_STRING;
       
   899                 break;
       
   900         }
       
   901         params.addParameter(timeoutString);
       
   902 
       
   903         style()->widgetParameters(params, const_cast<HbPopup *>(this));
       
   904 
       
   905         if (!params.value(timeoutString).isNull()) {
       
   906            return params.value(timeoutString).toInt();
       
   907        } else {
       
   908            return d->timeout;
       
   909        }
       
   910     } else {
   700     return d->timeout;
   911     return d->timeout;
   701 }
   912 }
   702 
   913 }
   703 /*!
   914 
   704  Sets the popup timeout property in milliseconds.
   915 /*!
   705  If timeout <= 0 then the popup is permanent and not closed automatically.
   916     Sets the popup's timeout property in milliseconds. A value of zero or less than zero
   706  \sa timeout() setTimeout(HbPopup::DefaultTimeout) QGraphicsWidget::close()
   917     means that the popup is permanent and is not closed automatically.
       
   918     
       
   919     \overload
       
   920     \sa timeout() setTimeout(HbPopup::DefaultTimeout), QGraphicsWidget::close()
   707 */
   921 */
   708 void HbPopup::setTimeout(int timeout)
   922 void HbPopup::setTimeout(int timeout)
   709 {
   923 {
   710     Q_D(HbPopup);
   924     Q_D(HbPopup);    
   711     d->setTimeout(timeout);
   925     d->setTimeout(timeout);
   712     //d->timeout = timeout;
   926 }
   713 }
   927 
   714 
   928 /*!
   715 /*!
   929     Sets the popup's timeout property to the default value for a standard popup type.
   716  It is a convenience overload of \a timeout() for setting HbPopup::DefaultTimeout values
   930     This has the advantage of creating a common look and feel.
   717  to achieve common look & feel.
   931 
   718  \sa enum DefaultTimeout
   932     \overload
   719  \sa timeout() setTimeout(int) QGraphicsWidget::close()
   933     \sa timeout(), setTimeout(int), QGraphicsWidget::close()
   720 */
   934 */
   721 void HbPopup::setTimeout(HbPopup::DefaultTimeout timeout)
   935 void HbPopup::setTimeout(HbPopup::DefaultTimeout timeout)
   722 {
   936 {
   723     setTimeout(HbPopupPrivate::timeoutValue(timeout));
   937     Q_D(HbPopup);
   724 }
   938     if (d->polished) {
   725 
   939         int newTimeout = d->defaultTimeouts.value(timeout);        
   726 /*!
   940         setTimeout(newTimeout);
   727  Returns the popup modality property.
   941     } else {
   728  A modal popup blocks any user initiated events outside of the popup
   942         d->timeoutPending = true;
   729  until it is closed.
   943         d->pendingTimeout = timeout;
   730  \sa setModal()
   944     }
       
   945 }
       
   946 
       
   947 /*!
       
   948     Returns the popup's modality property. A modal popup blocks any user-initiated
       
   949     events outside of the popup until it is closed.
       
   950     \sa setModal()
   731 */
   951 */
   732 bool HbPopup::isModal() const
   952 bool HbPopup::isModal() const
   733 {
   953 {
   734     Q_D(const HbPopup);
   954     Q_D(const HbPopup);
   735     return d->modal;
   955     return d->modal;
   736 }
   956 }
   737 
   957 
   738 /*!
   958 /*!
   739  Sets the popup modality property.
   959     Sets the popup's modality property.
   740  \sa isModal()
   960     
   741 */
   961     To open a modal popup, call open(). To open a non-modal popup, call 
   742 void HbPopup::setModal(bool enabled)
   962     \link QGraphicsItem::show() show()\endlink.
   743 {
   963     \sa isModal()
   744     Q_D(HbPopup);
   964 */
   745     d->modal = enabled;
   965 void HbPopup::setModal(bool modal)
       
   966 {
       
   967     Q_D(HbPopup);
       
   968     d->modal = modal;
   746     d->doSetModal( d->modal );
   969     d->doSetModal( d->modal );
   747 }
   970 }
   748 
   971 
   749 /*!
   972 /*!
   750  Sets the background of popup faded if \a fadeBackground is true otherwise
   973     Sets the popup's background fade policy property. When this is set to true, it causes
   751  the background will not be faded.
   974     everything behind the popup to be faded. 
   752  \sa isBackgroundFaded()
   975     \sa isBackgroundFaded()
   753 */
   976 */
   754 void HbPopup::setBackgroundFaded(bool fadeBackground)
   977 void HbPopup::setBackgroundFaded(bool fadeBackground)
   755 {
   978 {
   756     Q_D(HbPopup);
   979     Q_D(HbPopup);
   757     d->fadeBackground = fadeBackground;
   980     d->fadeBackground = fadeBackground;
   758 }
   981 }
   759 
   982 
   760 /*!
   983 /*!
   761  Returns if the background of the popup is faded or not.
   984     Returns the popup's background fade policy property. This controls whether 
   762  Default: true
   985     everything behind the popup is faded while the popup is on the screen. Typically
   763  \sa isBackgroundFaded()
   986     this property is set to true for modal dialogs only. The default is true.
       
   987     \sa setBackgroundFaded()
   764 */
   988 */
   765 bool HbPopup::isBackgroundFaded() const
   989 bool HbPopup::isBackgroundFaded() const
   766 {
   990 {
   767     Q_D(const HbPopup);
   991     Q_D(const HbPopup);
   768     return d->backgroundItem && d->fadeBackground;
   992     return d->backgroundItem && d->fadeBackground;
   769 }
   993 }
   770 
   994 
   771 /*!
   995 /*!
   772  Returns the dismiss policy of the popup.
   996     Returns the popup's dismiss policy. This defines which user actions (if any) cause 
   773  Default is HbPopup::TapOutside.
   997     the popup to close. The default is HbPopup::TapOutside.
   774  \sa setDismissPolicy()
   998     \sa setDismissPolicy()
   775 */
   999 */
   776 HbPopup::DismissPolicy HbPopup::dismissPolicy() const
  1000 HbPopup::DismissPolicy HbPopup::dismissPolicy() const
   777 {
  1001 {
   778     Q_D(const HbPopup);
  1002     Q_D(const HbPopup);
   779     return d->dismissPolicy;
  1003     return d->dismissPolicy;
   780 }
  1004 }
   781 
  1005 
   782 /*!
  1006 /*!
   783  Sets the dismiss policy property for the the popup.
  1007     Sets the popup's dismiss policy property.
   784 
  1008 
   785  \sa dismissPolicy()
  1009     \sa dismissPolicy()
   786 */
  1010 */
   787 void HbPopup::setDismissPolicy(HbPopup::DismissPolicy dismissPolicy)
  1011 void HbPopup::setDismissPolicy(HbPopup::DismissPolicy dismissPolicy)
   788 {
  1012 {
   789     Q_D(HbPopup);
  1013     Q_D(HbPopup);
   790     d->dismissPolicy = dismissPolicy;
  1014     d->dismissPolicy = dismissPolicy;
   791 }
  1015 }
   792 
  1016 
   793 /*!
  1017 /*!
   794  Returns the frame type of the popup.
  1018     Returns the popup's frame type. This controls the popup's background style. However, 
   795  Default is HbPopup::Strong
  1019     the actual appearance depends on the theme. The default value is HbPopup::Strong.
   796  \sa setFrameType()
  1020     
       
  1021     \sa setFrameType()
   797 */
  1022 */
   798 HbPopup::FrameType HbPopup::frameType() const
  1023 HbPopup::FrameType HbPopup::frameType() const
   799 {
  1024 {
   800     Q_D(const HbPopup);
  1025     Q_D(const HbPopup);
   801     return d->frameType;
  1026     return d->frameType;
   802 }
  1027 }
   803 
  1028 
   804 /*!
  1029 void HbPopupPrivate::doSetFrameType(HbPopup::FrameType newFrameType)
   805  Sets the frame typeproperty for the the popup.
  1030 {
   806 
  1031     Q_Q(HbPopup);
   807  \sa frameType()
  1032     switch( newFrameType ) {
       
  1033     case HbPopup::Weak:
       
  1034         q->setBackgroundItem(new HbFrameItem(QLatin1String("qtg_fr_popup_secondary"), HbFrameDrawer::NinePieces), -1);
       
  1035         break;
       
  1036     case HbPopup::Strong:
       
  1037     default:
       
  1038         q->setBackgroundItem(new HbFrameItem(QLatin1String("qtg_fr_popup"), HbFrameDrawer::NinePieces), -1);
       
  1039         break;
       
  1040     }
       
  1041 }
       
  1042 
       
  1043 /*!
       
  1044     Sets the popup's frame type, which controls the popup's background style.
       
  1045 
       
  1046     \sa frameType()
   808 */
  1047 */
   809 void HbPopup::setFrameType(HbPopup::FrameType frameType)
  1048 void HbPopup::setFrameType(HbPopup::FrameType frameType)
   810 {
  1049 {
   811     Q_D(HbPopup);
  1050     Q_D(HbPopup);
   812     if ( d->frameType != frameType ) {
  1051     if ( d->frameType != frameType ) {
   813         switch( frameType ) {
       
   814         case HbPopup::Weak:
       
   815             d->setBackgroundItem(HbStyle::P_Popup_background_weak);
       
   816             break;
       
   817         case HbPopup::Strong:
       
   818         default:
       
   819             d->setBackgroundItem(HbStyle::P_Popup_background);
       
   820             break;
       
   821         }
       
   822         d->frameType = frameType;
  1052         d->frameType = frameType;
       
  1053         d->doSetFrameType(frameType);
   823         updatePrimitives();
  1054         updatePrimitives();
   824     }
  1055     }
   825 }
  1056 }
   826 
  1057 
   827 
  1058 /*!
   828 /*!
  1059     Returns true if the popup is set to occupy the whole screen, false if not.
   829  Shows the popup as modal popup returning immediately.  
  1060 
   830 
  1061     \sa setFullScreen()
   831  Connects aboutToClose() signal to the slot specified by \a receiver and
  1062 */
   832  \a member. The signal will be disconnected from the slot when the
  1063 bool HbPopup::isFullScreen() const
   833  popup is closed.
  1064 {
   834 
  1065     Q_D(const HbPopup);
   835  For non modal popups, use show().  
  1066     return d->mFullScreen;
       
  1067 }
       
  1068 
       
  1069 /*!
       
  1070     Sets the popup to occupy the whole screen. When the popup is in full screen different
       
  1071     background graphics are used and there are no margins between popup and the main window.
       
  1072 
       
  1073     Inherited classes may have different color and graphics for full screen popups.
       
  1074 
       
  1075     \param enable A Boolean value; true for full screen popup, false for regular popup.
       
  1076 
       
  1077     \sa isFullScreen()
       
  1078 */
       
  1079 void HbPopup::setFullScreen(bool fullScreen)
       
  1080 {
       
  1081     Q_D(HbPopup);
       
  1082     d->setFullScreen(fullScreen);
       
  1083 }
       
  1084 
       
  1085 /*!
       
  1086     Displays the popup on the screen and returns immediately. This function also 
       
  1087     connects the popup's aboutToClose() signal to a specified slot. The signal 
       
  1088     is disconnected from the slot when the popup closes.
       
  1089     
       
  1090     Use this function to open modal popups. To open non-modal popups, call 
       
  1091     \link QGraphicsItem::show() show()\endlink.  
       
  1092 
       
  1093     \param receiver  The object that is to receive the signal.  
       
  1094     \param member  The slot on the receiver to which the signal is to connect. 
       
  1095     
       
  1096     \sa isModal() 
   836 */
  1097 */
   837 void HbPopup::open( QObject *receiver, const char *member )
  1098 void HbPopup::open( QObject *receiver, const char *member )
   838 {
  1099 {
   839     Q_D(HbPopup);
  1100     Q_D(HbPopup);
   840     if (receiver) {
  1101     if (receiver) {
   841         connect(this, SIGNAL(aboutToClose()), receiver, member);
  1102         connect(this, SIGNAL(aboutToClose()), receiver, member);
   842     }
  1103     }
   843     d->receiverToDisconnectOnClose = receiver;
  1104     d->receiverToDisconnectOnClose = receiver;
   844     d->memberToDisconnectOnClose = member;
  1105     d->memberToDisconnectOnClose = member;
   845 
  1106 
       
  1107     d->showingInProgress = true;
   846     show();
  1108     show();
   847 }
  1109 }
   848 
  1110 
   849 /*!
  1111 /*!
   850     \reimp
  1112     
   851  */
  1113  */
   852 QVariant HbPopup::itemChange ( GraphicsItemChange change, const QVariant & value )
  1114 QVariant HbPopup::itemChange ( GraphicsItemChange change, const QVariant & value )
   853 {
  1115 {
   854     Q_D(HbPopup);
  1116     Q_D(HbPopup);
   855 
  1117 
   856     if (change == QGraphicsItem::ItemPositionChange) {
  1118     if (change == QGraphicsItem::ItemPositionChange) {        
       
  1119         // Skipping X-coordinate changes made by VKB since popupmanager handles popup to be in the
       
  1120         // center of the screen
       
  1121         if (property(KPositionManagedByVKB).isValid() && property(KPositionManagedByVKB).toBool() &&
       
  1122             !d->mAutoLayouting && value.isValid() && !value.toPointF().isNull()) {
       
  1123             QPointF newPointF(geometry().x(), value.toPointF().y());
       
  1124             d->mAutoLayouting = false;
       
  1125             return newPointF;
       
  1126         }
   857         d->mAutoLayouting = false;
  1127         d->mAutoLayouting = false;
   858     }
  1128     }
   859     if (change == QGraphicsItem::ItemVisibleHasChanged) {
  1129     if (change == QGraphicsItem::ItemVisibleHasChanged) {
   860         if (value.toBool()) {
  1130         if (value.toBool()) {
   861             if(d->hasEffects && boundingRect().isValid()) {
  1131             if (d->hasEffects && boundingRect().isValid() && d->polished) {
   862 
  1132 
   863 #ifdef HB_EFFECTS
  1133 #ifdef HB_EFFECTS
   864                 QRectF extRect(0.0,
  1134                 QRectF extRect(0.0,
   865                                -boundingRect().height(),
  1135                                -boundingRect().height(),
   866                                boundingRect().width(),
  1136                                boundingRect().width(),
   867                                0);
  1137                                0);
   868                 d->mStartEffect = true;
       
   869                 HbEffect::cancel(this);
  1138                 HbEffect::cancel(this);
   870                 d->mStartEffect = false;
  1139                 d->mStartEffect = false;
   871                 HbEffect::start(this, d->effectType, "appear", this, "_q_appearEffectEnded", QVariant(), extRect);
  1140                 HbEffectInternal::start(this, this, HbEffectInternal::UpdateAtEachStep,
   872 #endif//HB_EFFECTS
  1141                                         d->effectType, "appear", this, "_q_appearEffectEnded",
   873             } else {
  1142                                         QVariant(), extRect);
   874                 d->mStartEffect = true;
  1143                 d->showingInProgress = true;
       
  1144 #endif //HB_EFFECTS
   875             }
  1145             }
   876         }
  1146         }
   877     }
  1147     }
   878 
  1148 
   879     if (change == QGraphicsItem::ItemVisibleChange) {
  1149     if (change == QGraphicsItem::ItemVisibleChange) {
   887                 emit aboutToShow();
  1157                 emit aboutToShow();
   888             }
  1158             }
   889             // Note: when visibility changes to "visible" base class implementation needs
  1159             // Note: when visibility changes to "visible" base class implementation needs
   890             //       to be called otherwise showEvent() is not called.
  1160             //       to be called otherwise showEvent() is not called.
   891         } else {
  1161         } else {
       
  1162             if(isPanel() && isActive() && d->mActivePopup) {
       
  1163                 setActive(false);
       
  1164             }
   892             d->aboutToShowSignalGuard = false;
  1165             d->aboutToShowSignalGuard = false;
   893             if (!d->hidingInProgress) {
  1166             if (!d->hidingInProgress) {
   894                 emit aboutToHide();
  1167                 emit aboutToHide();
   895             }
  1168             }
   896 
       
   897             if (d->delayedHide &&  // about to hide and we wanna delay hiding
  1169             if (d->delayedHide &&  // about to hide and we wanna delay hiding
   898                 d->hasEffects && !parentItem()) { // only for popup without parent
  1170                 d->hasEffects && !parentItem()) { // only for popup without parent
   899                 bool hideDelayed = d->delayedHide;
  1171                 bool hideDelayed = d->delayedHide;
   900                 if (!d->hidingInProgress) { // Prevent reentrance
  1172                 if (!d->hidingInProgress) { // Prevent reentrance
   901                     d->hidingInProgress = true;
  1173                     d->hidingInProgress = true;
   903                     QRectF extRect(0.0,
  1175                     QRectF extRect(0.0,
   904                                    -boundingRect().height(),
  1176                                    -boundingRect().height(),
   905                                    boundingRect().width(),
  1177                                    boundingRect().width(),
   906                                    0);
  1178                                    0);
   907                     HbEffect::cancel(this);
  1179                     HbEffect::cancel(this);
   908                     if (!HbEffect::start(this, d->effectType, "disappear",
  1180                     if (!HbEffectInternal::start(this, this, HbEffectInternal::UpdateAtEachStep,
   909                                          this, "_q_delayedHide",
  1181                                                  d->effectType, "disappear",
   910                                          QVariant(), extRect)) {
  1182                                                  this, "_q_delayedHide",
       
  1183                                                  QVariant(), extRect)) {
   911                         d->delayedHide = false;
  1184                         d->delayedHide = false;
   912                         return HbWidget::itemChange(change, value);
  1185                         return HbWidget::itemChange(change, value);
   913                     }
  1186                     }
       
  1187                     d->mGestureOverride = true;
   914 #endif
  1188 #endif
   915                 }
  1189                 }
   916                 if (hideDelayed) {
  1190                 if (hideDelayed) {
   917                     return true;
  1191                     return true;
   918                 } else {
  1192                 } else {
   936     }
  1210     }
   937     return HbWidget::itemChange(change, value);
  1211     return HbWidget::itemChange(change, value);
   938 }
  1212 }
   939 
  1213 
   940 /*!
  1214 /*!
   941  \deprecated HbPopup::handlePopupPos()
  1215     Reimplemented from QGraphicsItem.
   942          is deprecated. This function should not be used from the application side.
       
   943  Handles the popup position when Orientation changes
       
   944 */
       
   945 void HbPopup::handlePopupPos()
       
   946 {
       
   947     HB_DEPRECATED("HbPopup::handlePopupPos() is deprecated.");
       
   948     QEvent userEvent(QEvent::ContextMenu);
       
   949     QCoreApplication::sendEvent(this, &userEvent);    
       
   950 }
       
   951 
       
   952 /*!
       
   953     \reimp
       
   954  */
  1216  */
   955 void HbPopup::mousePressEvent(QGraphicsSceneMouseEvent *event )
  1217 void HbPopup::mousePressEvent(QGraphicsSceneMouseEvent *event )
   956 {
  1218 {
   957     Q_D(HbPopup);
  1219     Q_D(HbPopup);
   958 
  1220 
   970     // to ignored
  1232     // to ignored
   971     event->accept();
  1233     event->accept();
   972 }
  1234 }
   973 
  1235 
   974 /*!
  1236 /*!
   975     \reimp
  1237     Reimplemented from QGraphicsItem.
   976  */
  1238  */
   977 void HbPopup::mouseReleaseEvent(QGraphicsSceneMouseEvent *event )
  1239 void HbPopup::mouseReleaseEvent(QGraphicsSceneMouseEvent *event )
   978 {
  1240 {
   979     QGraphicsItem::mouseReleaseEvent(event);        
  1241     Q_D(HbPopup);
       
  1242     d->handleBackgroundMouseReleaseEvent(event);
       
  1243 
       
  1244     QGraphicsItem::mouseReleaseEvent(event);
   980     event->accept();
  1245     event->accept();
   981     // Note: Mouse release event is always handled in handleBackgroundMouseReleaseEvent
  1246 }
   982 }
  1247 
   983 
  1248 /*!
   984 /*!
  1249     Reimplemented from QGraphicsWidget. 
   985     \reimp
       
   986  */
  1250  */
   987 //
  1251 //
   988 // Shows the popup with an animation and starts the timer to dismiss the popup,
  1252 // Shows the popup with an animation and starts the timer to dismiss the popup,
   989 // unless it is a permanent popup.
  1253 // unless it is a permanent popup.
   990 //
  1254 //
  1000     //  - can have background item
  1264     //  - can have background item
  1001     //  - timeout
  1265     //  - timeout
  1002     //  - and registered to HbPopupManager
  1266     //  - and registered to HbPopupManager
  1003     //  otherwise popup is treated as normal widget
  1267     //  otherwise popup is treated as normal widget
  1004     if(d->duplicateShowEvent){
  1268     if(d->duplicateShowEvent){
  1005         d->duplicateShowEvent = false;
  1269         d->duplicateShowEvent = false;        
       
  1270         //setting popup as active panel failed in previous showEvent
       
  1271         if (d->mActivePopup) {
       
  1272             setActive(true);
       
  1273         }
  1006         return;
  1274         return;
  1007     }
  1275     }
  1008     if (!parentItem()) {
  1276     if (!parentItem()) {
  1009         //check if popup needs to be added to scene.This can result in duplciate show event,
  1277         //check if popup needs to be added to scene.This can result in duplciate show event,
  1010         // if popup is added to scene here.
  1278         // if popup is added to scene here.
  1011         if(d->addPopupToScene()) {
  1279         if(d->addPopupToScene()) {
  1012               d->duplicateShowEvent = true;
  1280               d->duplicateShowEvent = true;
  1013         }
  1281         }
  1014         //setActive(true);
  1282         if (d->mActivePopup) {
       
  1283             setActive(true);
       
  1284         }
  1015         // Popup clears closed state
  1285         // Popup clears closed state
  1016         d->closed = false;
  1286         d->closed = false;
  1017         if (d->backgroundItem) {
  1287         if (d->backgroundItem) {
  1018             d->backgroundItem->setVisible(true);
  1288             d->backgroundItem->setVisible(true);
  1019             d->backgroundItem->setAcceptHoverEvents(isModal());
       
  1020             if (isModal()) {
  1289             if (isModal()) {
  1021                 d->backgroundItem->setFlag(QGraphicsItem::ItemIsPanel);
  1290                 d->backgroundItem->setFlag(QGraphicsItem::ItemIsPanel);
  1022              }
  1291              }
  1023         }
  1292         }
  1024         if (qobject_cast<HbGraphicsScene *>(scene())) {
  1293         if (qobject_cast<HbGraphicsScene *>(scene())) {
  1041         }
  1310         }
  1042     }
  1311     }
  1043 }
  1312 }
  1044 
  1313 
  1045 /*!
  1314 /*!
  1046     \reimp
  1315     Reimplemented from QGraphicsWidget. 
  1047  */
  1316  */
  1048 void HbPopup::hideEvent(QHideEvent *event)
  1317 void HbPopup::hideEvent(QHideEvent *event)
  1049 {
  1318 {
  1050     Q_D(HbPopup);
  1319     Q_D(HbPopup);
  1051 
  1320 
  1058         }
  1327         }
  1059         qobject_cast<HbGraphicsScene *>(scene())->d_ptr->hidePopup(this);
  1328         qobject_cast<HbGraphicsScene *>(scene())->d_ptr->hidePopup(this);
  1060     }
  1329     }
  1061 
  1330 
  1062     HbWidgetFeedback::triggered(this, Hb::InstantPopupClosed);
  1331     HbWidgetFeedback::triggered(this, Hb::InstantPopupClosed);
  1063     if (d->eventLoop) {
       
  1064         d->eventLoop->exit();
       
  1065     }
       
  1066 
  1332 
  1067     d->doSetModal( d->modal );
  1333     d->doSetModal( d->modal );
  1068 
  1334 }
  1069 }
  1335 
  1070 
  1336 /*!
  1071 /*!
  1337     Reimplemented from QGraphicsWidget. 
  1072     \reimp
       
  1073  */
  1338  */
  1074 void HbPopup::resizeEvent( QGraphicsSceneResizeEvent * event )
  1339 void HbPopup::resizeEvent( QGraphicsSceneResizeEvent * event )
  1075 {    
  1340 {    
  1076     HbWidget::resizeEvent(event);
  1341     HbWidget::resizeEvent(event);
  1077     updatePrimitives();
  1342     updatePrimitives();
  1080         d->calculateShape();
  1345         d->calculateShape();
  1081     }
  1346     }
  1082 }
  1347 }
  1083 
  1348 
  1084 /*!
  1349 /*!
  1085     \reimp
  1350     Reimplemented from QGraphicsWidget. 
  1086  */
  1351  */
  1087 void HbPopup::closeEvent ( QCloseEvent * event )
  1352 void HbPopup::closeEvent ( QCloseEvent * event )
  1088 {
  1353 {
  1089     Q_D(HbPopup);
  1354     Q_D(HbPopup);
  1090     d->stopTimeout();
  1355     d->stopTimeout();
  1109     }
  1374     }
  1110     d->memberToDisconnectOnClose.clear();
  1375     d->memberToDisconnectOnClose.clear();
  1111     HbWidget::closeEvent(event);
  1376     HbWidget::closeEvent(event);
  1112 }
  1377 }
  1113 
  1378 
  1114 
  1379 /*!
  1115 /* Currently, virtual keyboard must be able to position a popup
  1380     Reimplemented from QGraphicsWidget. 
  1116    containing a editor to an arbitrary place. VKB does it's best to
       
  1117    reposition popup back to original position when needed. At least in
       
  1118    orientation switch the old position naturally is wrong, hence popup
       
  1119    must be relayouted.
       
  1120 
       
  1121    It would be unreasonable to make special checks for popup in vkb
       
  1122    side. It also would be unreasonable to do special checks for vkb in
       
  1123    popup side. Hence this semi-hidden dynamic property for
       
  1124    communicating this special case.
       
  1125 
       
  1126    WARNING: Do not count on this special behaviour, we might remove it
       
  1127    without prior notice. If you do require such a behavior, please
       
  1128    raise a feature request and we might make this a proper API.
       
  1129  */
       
  1130 const char* KPositionManagedByVKB("PositionManagedByVKB");
       
  1131 
       
  1132 /*!
       
  1133     \reimp
       
  1134  */
  1381  */
  1135 bool HbPopup::event(QEvent *event)
  1382 bool HbPopup::event(QEvent *event)
  1136 {
  1383 {
  1137     Q_D(HbPopup);
  1384     Q_D(HbPopup);
  1138     if ( event->type() == QEvent::DynamicPropertyChange ) {
  1385     if ( event->type() == QEvent::DynamicPropertyChange ) {
  1152             }
  1399             }
  1153         }
  1400         }
  1154     } else if (event->type() == QEvent::LayoutRequest) {
  1401     } else if (event->type() == QEvent::LayoutRequest) {
  1155         //Workaround when showing first time                           
  1402         //Workaround when showing first time                           
  1156 #ifdef HB_EFFECTS
  1403 #ifdef HB_EFFECTS
  1157         if(d->mStartEffect && boundingRect().isValid()) {
  1404         if (d->mStartEffect && boundingRect().isValid()) {
  1158             d->mStartEffect = false;
  1405             d->mStartEffect = false;
  1159             QCoreApplication::sendPostedEvents(this, QEvent::LayoutRequest);
  1406             QCoreApplication::sendPostedEvents(this, QEvent::LayoutRequest);
  1160             QRectF extRect(0.0,
  1407             QRectF extRect(0.0,
  1161                            -boundingRect().height(),
  1408                            -boundingRect().height(),
  1162                            boundingRect().width(),
  1409                            boundingRect().width(),
  1163                            0);
  1410                            0);
  1164             d->mStartEffect = true;
       
  1165             HbEffect::cancel(this);
  1411             HbEffect::cancel(this);
  1166             d->mStartEffect = false;
  1412             HbEffectInternal::start(this, this, HbEffectInternal::UpdateAtEachStep,
  1167             HbEffect::start(this, d->effectType, "appear", this, "_q_appearEffectEnded", QVariant(), extRect);            
  1413                                     d->effectType, "appear", this, "_q_appearEffectEnded",
  1168         }
  1414                                     QVariant(), extRect);
  1169 #endif//HB_EFFECTS
  1415             d->showingInProgress = true;
  1170         //workaround ends
  1416         } else if (d->mStartEffect) {
  1171     }
  1417         }
       
  1418 #endif //HB_EFFECTS
       
  1419     } else if (event->type() == QEvent::TouchBegin) {
       
  1420         // Accept all touch begin events to get the full Begin..End sequence
       
  1421         event->accept();
       
  1422         return true;
       
  1423     } else if (d->mGestureOverride && event->type() == QEvent::GestureOverride) {
       
  1424         event->accept();
       
  1425         return true;
       
  1426     }
       
  1427 
  1172     return HbWidget::event(event);
  1428     return HbWidget::event(event);
  1173 }
  1429 }
  1174 
  1430 
  1175 /*!
  1431 /*!
  1176   Sets preferred position\a position for popup with \a placement
  1432     Sets the preferred position of the popup. By default, the popup is placed in the middle
  1177   as origin.
  1433     of the screen. If you use this function to set the preferred position, it is your 
  1178 
  1434     responsibility to ensure that this position works correctly on devices with different 
  1179   By default popup is placed in the middle of the screen. If other positions are needed please
  1435     screen sizes.
  1180   ensure that the preferred position is working properly with different screen sizes.
  1436   
  1181 
  1437     Typically you should set the preferred position only for context aware popups, such as 
  1182   \param position is the position at which the popup is shown.
  1438     context menus and slider popups. The position is not relevant for most dialogs and
  1183   \param placement is the corner or edge which \a position refers to
  1439     popups and you should use the default position for these.
  1184 
  1440 
  1185   Example usage:
  1441     \param preferredPos Defines the coordinates of preferred position on the screen where 
  1186   \code
  1442            the popup is to open.
  1187   HbPopup *popup = new HbPopup();
  1443     \param placement The corner or edge of the dialog that is to be placed at \a preferredPos.
  1188   ...
  1444 
  1189   popup->setPreferredPosition( QPointF(x,y), HbPopupBase::BottomEdgeCenter );
  1445     \b Example:
  1190   popup->show();
  1446     \code
  1191   \endcode
  1447     HbPopup *popup = new HbPopup();
       
  1448   
       
  1449     popup->setPreferredPos( QPointF(x,y), HbPopup::BottomEdgeCenter );
       
  1450     popup->show();
       
  1451     \endcode
  1192  */
  1452  */
  1193 void HbPopup::setPreferredPos( const QPointF& preferredPos,
  1453 void HbPopup::setPreferredPos( const QPointF& preferredPos,
  1194                                HbPopup::Placement placement )
  1454                                HbPopup::Placement placement )
  1195 {
  1455 {
  1196     Q_D(HbPopup);
  1456     Q_D(HbPopup);
  1210         QApplication::sendEvent(this, &layoutRequest);
  1470         QApplication::sendEvent(this, &layoutRequest);
  1211     }
  1471     }
  1212 }
  1472 }
  1213 
  1473 
  1214 /*!
  1474 /*!
  1215   \reimp
  1475      Returns the shape of this item as a QPainterPath.
  1216   Returns the shape of this item as a QPainterPath.
  1476  */
  1217   */
       
  1218 QPainterPath HbPopup::shape() const
  1477 QPainterPath HbPopup::shape() const
  1219 {    
  1478 {    
  1220 #if 0
  1479 #if 0
  1221    /*Q_D(const HbPopup);
  1480    /*Q_D(const HbPopup);
  1222     if (backgroundItem() && d->mPath) {
  1481     if (backgroundItem() && d->mPath) {
  1227 #else
  1486 #else
  1228     return HbWidget::shape();
  1487     return HbWidget::shape();
  1229 #endif
  1488 #endif
  1230 }
  1489 }
  1231 
  1490 
       
  1491 /*!
       
  1492     Reimplemented from HbWidget.
       
  1493  */
       
  1494 void HbPopup::polish(HbStyleParameters &params)
       
  1495 {
       
  1496     if (isVisible()) {
       
  1497         Q_D(HbPopup);
       
  1498 
       
  1499         // fetch scrolling parameters from css
       
  1500 
       
  1501         params.addParameter(NO_TIMEOUT_STRING);
       
  1502         params.addParameter(CONFIRMATION_NOTE_TIMEOUT_STRING);
       
  1503         params.addParameter(STANDARD_TIMEOUT_STRING);
       
  1504         params.addParameter(CONTEXT_MENU_TIMEOUT_STRING);
       
  1505 
       
  1506         HbWidget::polish(params);
       
  1507 
       
  1508         if (!params.value(NO_TIMEOUT_STRING).isNull()) {
       
  1509             d->defaultTimeouts[HbPopup::NoTimeout] = params.value(NO_TIMEOUT_STRING).toInt();
       
  1510         }
       
  1511         if (!params.value(CONFIRMATION_NOTE_TIMEOUT_STRING).isNull()) {
       
  1512             d->defaultTimeouts[HbPopup::ConfirmationNoteTimeout] = params.value(CONFIRMATION_NOTE_TIMEOUT_STRING).toInt();
       
  1513         }
       
  1514         if (!params.value(STANDARD_TIMEOUT_STRING).isNull()) {
       
  1515             d->defaultTimeouts[HbPopup::StandardTimeout] = params.value(STANDARD_TIMEOUT_STRING).toInt();
       
  1516         }
       
  1517         if (!params.value(CONTEXT_MENU_TIMEOUT_STRING).isNull()) {
       
  1518             d->defaultTimeouts[HbPopup::ContextMenuTimeout] = params.value(CONTEXT_MENU_TIMEOUT_STRING).toInt();
       
  1519         }
       
  1520         if (d->timeoutPending) {
       
  1521             d->timeout = d->defaultTimeouts[d->pendingTimeout];
       
  1522             if (d->timeout > 0) {
       
  1523                 d->timeoutTimer()->setInterval(d->timeout);
       
  1524                 d->startTimeout();
       
  1525             }
       
  1526             d->timeoutPending = false;
       
  1527         }
       
  1528     } else {
       
  1529         HbWidget::polish(params);
       
  1530     }
       
  1531 }
       
  1532 
  1232 #include "moc_hbpopup.cpp"
  1533 #include "moc_hbpopup.cpp"