src/hbcore/gui/hbtoolbarextension.cpp
changeset 28 b7da29130b0e
parent 23 e6ad4ef83b23
equal deleted inserted replaced
23:e6ad4ef83b23 28:b7da29130b0e
   151     mLayout(0),
   151     mLayout(0),
   152     extensionAction(0),
   152     extensionAction(0),
   153     mAlignment(Qt::AlignTop),
   153     mAlignment(Qt::AlignTop),
   154     mDefaultContentWidget(false),
   154     mDefaultContentWidget(false),
   155     // default values, in case CSS parsing fails
   155     // default values, in case CSS parsing fails
   156     mMargins(0),
       
   157     mRowsPortrait(4),
   156     mRowsPortrait(4),
   158     mRowsLandscape(3),
   157     mRowsLandscape(3),
   159     mColsPortrait(3),
   158     mColsPortrait(3),
   160     mColsLandscape(4),
   159     mColsLandscape(4),
   161     lazyInitDone(false),
   160     lazyInitDone(false),
   162     orientationConnectDone(false),
   161     orientationConnectDone(false),
   163     //
       
   164     mExtendedButton(0),
   162     mExtendedButton(0),
   165     mToolBar(0)
   163     mToolBar(0)
   166 {
   164 {
   167 }
   165 }
   168 
   166 
   229     foreach (HbToolButton* button, mToolButtons) {
   227     foreach (HbToolButton* button, mToolButtons) {
   230         button->setVisible(HbToolButtonPrivate::d_ptr(button)->action->isVisible());
   228         button->setVisible(HbToolButtonPrivate::d_ptr(button)->action->isVisible());
   231     }
   229     }
   232 
   230 
   233     mLayout = new QGraphicsGridLayout();
   231     mLayout = new QGraphicsGridLayout();
   234     mLayout->setContentsMargins( mMargins, mMargins, mMargins, mMargins );
   232     mLayout->setContentsMargins(0, 0, 0, 0);
   235     mLayout->setSpacing(0.0);  // if non zero spacing needed, add to css
   233     mLayout->setSpacing(0.0);  // if non zero spacing needed, add to css
   236     for ( int i(0), j(0), ie(mToolButtons.count()); i < ie; ++i ) {
   234     for ( int i(0), j(0), ie(mToolButtons.count()); i < ie; ++i ) {
   237         HbToolButton *button = mToolButtons.at(i);
   235         HbToolButton *button = mToolButtons.at(i);
   238         if ( HbToolButtonPrivate::d_ptr(button)->action->isVisible() ) {
   236         if ( HbToolButtonPrivate::d_ptr(button)->action->isVisible() ) {
   239             // Calculate the row and column indices
   237             // Calculate the row and column indices
   374                    && q->layoutDirection() == Qt::LeftToRight) {
   372                    && q->layoutDirection() == Qt::LeftToRight) {
   375             HbToolBarExtensionPrivate::d_ptr(q)->setAlignment(Qt::AlignLeft);
   373             HbToolBarExtensionPrivate::d_ptr(q)->setAlignment(Qt::AlignLeft);
   376         } else {
   374         } else {
   377             HbToolBarExtensionPrivate::d_ptr(q)->setAlignment(Qt::AlignRight);
   375             HbToolBarExtensionPrivate::d_ptr(q)->setAlignment(Qt::AlignRight);
   378         }
   376         }
       
   377         q->close();
   379     }
   378     }
   380     q->repolish();
   379     q->repolish();
   381     doLayout();
       
   382 }
   380 }
   383 
   381 
   384 void HbToolBarExtensionPrivate::_q_animateButtonClicked()
   382 void HbToolBarExtensionPrivate::_q_animateButtonClicked()
   385 {
   383 {
   386 #ifdef HB_EFFECTS
   384 #ifdef HB_EFFECTS
   536     Q_D( HbToolBarExtension );    
   534     Q_D( HbToolBarExtension );    
   537     if ( event->type() == QEvent::ActionAdded ) {
   535     if ( event->type() == QEvent::ActionAdded ) {
   538         d->actionAdded( static_cast<QActionEvent *>(event) );
   536         d->actionAdded( static_cast<QActionEvent *>(event) );
   539         return true;
   537         return true;
   540     } else if ( event->type() == QEvent::ActionRemoved ) {
   538     } else if ( event->type() == QEvent::ActionRemoved ) {
   541         d->actionRemoved( static_cast<QActionEvent *>(event) );    
   539         d->actionRemoved( static_cast<QActionEvent *>(event) );
   542         return true;
   540         return true;
   543     } else if (event->type() == QEvent::ActionChanged ) {
   541     } else if (event->type() == QEvent::ActionChanged ) {
   544         d->actionChanged();
   542         d->actionChanged();
   545         return true;
   543         return true;
   546     } else if ( event->type() == QEvent::GraphicsSceneResize ) {
   544     } else if ( event->type() == QEvent::GraphicsSceneResize ) {
   556 void HbToolBarExtension::polish( HbStyleParameters &params )
   554 void HbToolBarExtension::polish( HbStyleParameters &params )
   557 {
   555 {
   558     if (isVisible()) {
   556     if (isVisible()) {
   559         Q_D(HbToolBarExtension);
   557         Q_D(HbToolBarExtension);
   560         d->doLazyInit();
   558         d->doLazyInit();
   561         const QLatin1String Margins("content-margins");
       
   562         const QLatin1String RowsPortrait("max-rows-portrait");
   559         const QLatin1String RowsPortrait("max-rows-portrait");
   563         const QLatin1String RowsLandscape("max-rows-landscape");
   560         const QLatin1String RowsLandscape("max-rows-landscape");
   564         const QLatin1String ColsPortrait("max-columns-portrait");
   561         const QLatin1String ColsPortrait("max-columns-portrait");
   565         const QLatin1String ColsLandscape("max-columns-landscape");
   562         const QLatin1String ColsLandscape("max-columns-landscape");
   566 
   563 
   567         params.addParameter( Margins );
       
   568         params.addParameter( RowsPortrait );
   564         params.addParameter( RowsPortrait );
   569         params.addParameter( RowsLandscape );
   565         params.addParameter( RowsLandscape );
   570         params.addParameter( ColsPortrait );
   566         params.addParameter( ColsPortrait );
   571         params.addParameter( ColsLandscape );
   567         params.addParameter( ColsLandscape );
   572         d->initialiseContent();
   568         d->initialiseContent();
   573         if (d->mDefaultContentWidget) {
   569         if (d->mDefaultContentWidget) {
   574             HbDialog::polish(params);
   570             HbDialog::polish(params);
   575             if ( params.value( Margins ).isValid()
   571             if ( params.value( RowsPortrait ).isValid()
   576                 && params.value( RowsPortrait ).isValid()
       
   577                 && params.value( RowsLandscape ).isValid()
   572                 && params.value( RowsLandscape ).isValid()
   578                 && params.value( ColsPortrait ).isValid()
   573                 && params.value( ColsPortrait ).isValid()
   579                 && params.value( ColsLandscape ).isValid() ) {
   574                 && params.value( ColsLandscape ).isValid() ) {
   580                 d->mMargins = params.value( Margins ).toReal();
       
   581                 d->mRowsPortrait  = params.value( RowsPortrait ).toInt();
   575                 d->mRowsPortrait  = params.value( RowsPortrait ).toInt();
   582                 d->mRowsLandscape = params.value( RowsLandscape ).toInt();
   576                 d->mRowsLandscape = params.value( RowsLandscape ).toInt();
   583                 d->mColsPortrait  = params.value( ColsPortrait ).toInt();
   577                 d->mColsPortrait  = params.value( ColsPortrait ).toInt();
   584                 d->mColsLandscape = params.value( ColsLandscape ).toInt();
   578                 d->mColsLandscape = params.value( ColsLandscape ).toInt();
   585                 d->doLayout();
   579                 d->doLayout();
   596     Q_D(HbToolBarExtension);
   590     Q_D(HbToolBarExtension);
   597     if (change == QGraphicsItem::ItemVisibleHasChanged) {
   591     if (change == QGraphicsItem::ItemVisibleHasChanged) {
   598         if (value.toBool()) {
   592         if (value.toBool()) {
   599             HbMainWindow* w(mainWindow());
   593             HbMainWindow* w(mainWindow());
   600             if(w && !d->orientationConnectDone) {
   594             if(w && !d->orientationConnectDone) {
   601                 QObject::connect(w,SIGNAL(orientationChanged(Qt::Orientation)),
   595                 QObject::disconnect( w , SIGNAL(aboutToChangeOrientation()), this, SLOT(_q_orientationChanged()));
   602                                  this, SLOT(_q_orientationChanged()));
   596                 QObject::connect( w , SIGNAL(aboutToChangeOrientation()), this, SLOT(_q_orientationChanged()));
   603                 d->orientationConnectDone = true;
   597                 d->orientationConnectDone = true;
   604             }
   598             }
   605             d->placeToolBarExtension();
   599             d->placeToolBarExtension();
   606         }
   600         }
   607     }
   601     }