diff -r 627c4a0fd0e7 -r c3690ec91ef8 src/hbcore/gui/hbtoolbutton.cpp --- a/src/hbcore/gui/hbtoolbutton.cpp Fri Jun 11 13:58:22 2010 +0300 +++ b/src/hbcore/gui/hbtoolbutton.cpp Wed Jun 23 18:33:25 2010 +0300 @@ -42,6 +42,7 @@ #include #include +#include /*! @stable @@ -120,6 +121,13 @@ \fn int HbToolButton::type() const */ +/*! + \primitives + \primitive{background} HbFrameItem representing the background frame of the button. + \primitive{icon} HbIconItem representing the icon of the button. + \primitive{text} HbTextItem representing button text. + */ + HbToolButtonPrivate::HbToolButtonPrivate() : action(0), textItem(0), @@ -246,13 +254,18 @@ void HbToolButtonPrivate::_q_actionTriggered() { Q_Q(HbToolButton); - emit q->triggered(action); + // Only emit triggered signal for HbActions, not QActions. + // triggered(QAction*) requires an API change we don't want to do right now. + HbAction *hbAction = qobject_cast(action); + if (hbAction) + emit q->triggered(hbAction); } void HbToolButtonPrivate::_q_actionChanged() { Q_Q(HbToolButton); - if (!action->icon().isNull()) { + HbAction *hbAction = qobject_cast(action); + if ((hbAction && !hbAction->icon().isNull()) || !action->icon().isNull()) { if (orientation == Qt::Horizontal) { buttonStyle = HbToolButton::ToolButtonIcon; } else if (!action->text().isEmpty()) { @@ -265,7 +278,8 @@ } // action text/icon may have changed, if (polished) { - q->repolish(); + q->repolish(); + QCoreApplication::sendPostedEvents(q, QEvent::Polish); } } @@ -314,7 +328,7 @@ HbAction *HbToolButton::action() const { Q_D(const HbToolButton); - return d->action; + return qobject_cast(d->action); } /*! @@ -336,7 +350,7 @@ disconnect(d->action, SIGNAL(changed()), this, SLOT(_q_actionChanged())); } - HbAction *oldAction = d->action; + QAction *oldAction = d->action; d->action = action; if (d->action) { connect(action, SIGNAL(triggered()), this, SLOT(_q_actionTriggered())); @@ -480,14 +494,16 @@ } if (d->iconItem) { style()->updatePrimitive(d->iconItem, HbStyle::P_ToolButton_icon, &option); - if (d->action && d->action->icon().flags() & HbIcon::Colorized) { - static_cast(d->iconItem)->setFlags(HbIcon::Colorized); + HbAction *hbAction = qobject_cast(d->action); + if (hbAction) { + if (hbAction->icon().flags() & HbIcon::Colorized) { + static_cast(d->iconItem)->setFlags(HbIcon::Colorized); + } + if (hbAction->icon().mirroringMode() != HbIcon::Default) { + HbIconItem *iconItem = static_cast(d->iconItem); + iconItem->setMirroringMode( hbAction->icon().mirroringMode() ); + } } - if (d->action && d->action->icon().mirroringMode() != HbIcon::Default) { - HbIconItem *iconItem = static_cast(d->iconItem); - iconItem->setMirroringMode( d->action->icon().mirroringMode() ); - } - } } @@ -518,7 +534,12 @@ if (d->action) { option->text = d->action->text(); - option->icon = d->action->icon(); + HbAction *hbAction = qobject_cast(d->action); + if (hbAction) + option->icon = hbAction->icon(); + else + option->icon = d->action->icon(); + option->isToolBarExtension = d->toolbarExtensionFrame; } } @@ -541,8 +562,9 @@ if (event->newSize() != event->oldSize() && d->polished && isVisible()) { updatePrimitives(); } - if (action() && action()->toolBarExtension()) { - HbToolBarExtensionPrivate::d_ptr(action()->toolBarExtension())->placeToolBarExtension(); + HbAction *hbAction = qobject_cast(d->action); + if ( hbAction && hbAction->toolBarExtension()) { + HbToolBarExtensionPrivate::d_ptr(hbAction->toolBarExtension())->placeToolBarExtension(); } } @@ -556,9 +578,10 @@ if (!d->action) { return; } - if ( d->action->toolBarExtension() ) { - HbToolBarExtensionPrivate::d_ptr(d->action->toolBarExtension())->mExtendedButton = this; - d->action->toolBarExtension()->show(); + HbAction *hbAction = qobject_cast(d->action); + if ( hbAction && hbAction->toolBarExtension() ) { + HbToolBarExtensionPrivate::d_ptr(hbAction->toolBarExtension())->mExtendedButton = this; + hbAction->toolBarExtension()->show(); } d->action->trigger();