src/hbcore/gui/hbtoolbar.cpp
branchGCC_SURGE
changeset 15 f378acbc9cfb
parent 6 c3690ec91ef8
child 21 4633027730f5
child 34 ed14f46c0e55
equal deleted inserted replaced
9:730c025d4b77 15:f378acbc9cfb
    55     @beta
    55     @beta
    56     @hbcore
    56     @hbcore
    57     \class HbToolBar
    57     \class HbToolBar
    58     \brief HbToolBar is a toolbar decorator.
    58     \brief HbToolBar is a toolbar decorator.
    59 
    59 
    60     The HbToolBar class represents an HbView toolbar. It provides the interface for adding actions
    60     The HbToolBar class represents an HbView toolbar. It provides the
    61     to the toolbar.
    61     interface for adding actions to the toolbar.
       
    62 
    62     Toolbar actions are added using one of the addAction() methods.
    63     Toolbar actions are added using one of the addAction() methods.
    63     Calling addAction() adds an HbToolButton to the toolbar and triggers the action when the button
    64     Calling addAction() adds an HbToolButton to the toolbar and
    64     is pressed. The image and text specified with the action are applied to the toolbar button.
    65     triggers the action when the button is pressed. The image and text
    65 
    66     specified with the action are applied to the toolbar button.
    66     HbToolBar also provides methods for adding pop-up toolbar extensions, represented by
    67 
    67     HbToolBarExtension objects.
    68     HbToolBar also provides methods for adding pop-up toolbar
       
    69     extensions, represented by HbToolBarExtension objects.
    68 
    70 
    69     Example usage:
    71     Example usage:
    70     \dontinclude ultimatecodesnippet/ultimatecodesnippet.cpp
    72     \dontinclude ultimatecodesnippet/ultimatecodesnippet.cpp
    71     \skip Start of snippet 1
    73     \skip Start of snippet 1
    72     \until End of snippet 1
    74     \until End of snippet 1
    73 
    75 
       
    76     Note: calling hide() or setVisible(bool) on toolbar is not
       
    77     recommended.  Instead, use \a HbView::setItemVisible(), as in 
       
    78     this example:
       
    79     \dontinclude ultimatecodesnippet/ultimatecodesnippet.cpp
       
    80     \skip Start of snippet 59
       
    81     \until End of snippet 59
       
    82 
       
    83    
    74 */
    84 */
    75 
    85 
    76 /*!
    86 /*!
    77     \reimp
    87     \reimp
    78     \fn int HbToolBar::type() const
    88     \fn int HbToolBar::type() const
   269                 }
   279                 }
   270                 d->mSuppressNextAppearEffect = false;
   280                 d->mSuppressNextAppearEffect = false;
   271                 d->delayedHide = d->hasEffects;
   281                 d->delayedHide = d->hasEffects;
   272             }
   282             }
   273         } else {
   283         } else {
   274             if (d->mVisibleToolButtons.count()){
       
   275                 d->emitVisibilityChangeSignal = true;
       
   276                 QMetaObject::invokeMethod(&d->core, "visibilityChanged", Qt::QueuedConnection);
       
   277              }
       
   278             if(d->moreExtension && d->moreExtension->isVisible()){
   284             if(d->moreExtension && d->moreExtension->isVisible()){
   279                d->moreExtension->setVisible(false);
   285                d->moreExtension->setVisible(false);
   280             }
   286             }
       
   287             bool hideDelayed = d->delayedHide;
   281             if (d->delayedHide && d->hasEffects) { // about to hide and we wanna delay hiding
   288             if (d->delayedHide && d->hasEffects) { // about to hide and we wanna delay hiding
   282                 if (!d->hidingInProgress) { // Prevent reentrance
   289                 // This check solves the situation where toolbar is hidden by its parent.
   283                     d->hidingInProgress = true;
   290                 // Delayed hide changes explicit bit in qgraphicsitem which makes
   284                     d->startDisappearEffect();
   291                 // toolbar to stay hidden when parent becomes visible again.
       
   292                 // There is a small misbehaviour when parentItem is hidden and hide was explicitely
       
   293                 // called for toolbar. In this case toolbar hides without the effect.
       
   294                 if ((!parentItem() || (parentItem() && parentItem()->isVisible()))) {
       
   295                     if (!d->hidingInProgress) { // Prevent reentrance
       
   296                         d->hidingInProgress = true;
       
   297                         d->startDisappearEffect();
       
   298                         d->delayedHide = false;
       
   299                     }
       
   300                 } else {
       
   301                     d->delayedHide = false;
   285                 }
   302                 }
   286             }
   303             }
   287             if (d->delayedHide) {
   304             if (hideDelayed) {
   288                 return true;
   305                 return true;
   289             } else {
   306             } else {
   290                 d->delayedHide = d->hasEffects;
   307                 d->delayedHide = d->hasEffects;
   291                 d->hidingInProgress = false;
   308                 d->hidingInProgress = false;
   292 #ifdef HB_EFFECTS
   309 #ifdef HB_EFFECTS
   293                         HbEffect::cancel(this, QString(), true);
   310                 HbEffect::cancel(this, QString(), true);
   294 #endif
   311 #endif
       
   312             }
       
   313             if (d->mVisibleToolButtons.count()){
       
   314                 d->emitVisibilityChangeSignal = true;
       
   315                 QMetaObject::invokeMethod(&d->core, "visibilityChanged", Qt::QueuedConnection);
   295             }
   316             }
   296         }
   317         }
   297     break;
   318     break;
   298         default:
   319         default:
   299             break;
   320             break;
   330 /*!
   351 /*!
   331     \reimp
   352     \reimp
   332  */
   353  */
   333 void HbToolBar::hideEvent(QHideEvent *event)
   354 void HbToolBar::hideEvent(QHideEvent *event)
   334 {
   355 {
   335     Q_D(HbToolBar);
       
   336     if (d->mPressedDownButton && d->mPressedDownButton->isDown()) {
       
   337         d->mPressedDownButton->setDown(false);
       
   338         d->mPressedDownButton = 0;
       
   339         d->mPreviouslyPressedDownButton = d->mPressedDownButton;
       
   340     }
       
   341     HbWidget::hideEvent(event);
   356     HbWidget::hideEvent(event);
   342 }
   357 }
   343 
   358 
       
   359 /*!
       
   360   \reimp
       
   361   */
   344 /*!
   362 /*!
   345     \reimp
   363     \reimp
   346  */
   364  */
   347 bool HbToolBar::event(QEvent *event)
   365 bool HbToolBar::event(QEvent *event)
   348 {
   366 {
   385     if (d->moreExtensionButton) {
   403     if (d->moreExtensionButton) {
   386         d->moreExtensionButton->updatePrimitives();
   404         d->moreExtensionButton->updatePrimitives();
   387     }
   405     }
   388 }
   406 }
   389 
   407 
       
   408 /*!
       
   409   \reimp
       
   410   */
       
   411 void HbToolBar::polish(HbStyleParameters &params)
       
   412 {
       
   413     Q_D(HbToolBar);
       
   414     HbWidget::polish(params);
       
   415     if (d->mDoLayoutPending) {
       
   416         d->doLayout();
       
   417     }
       
   418 }
       
   419 
   390 #include "moc_hbtoolbar.cpp"
   420 #include "moc_hbtoolbar.cpp"