233 QSizeF HbToolButtonPrivate::getMinimumSize() |
241 QSizeF HbToolButtonPrivate::getMinimumSize() |
234 { |
242 { |
235 Q_Q(HbToolButton); |
243 Q_Q(HbToolButton); |
236 mRepolishRequested = true; |
244 mRepolishRequested = true; |
237 polishPending = false; |
245 polishPending = false; |
238 q->updateGeometry(); |
|
239 QSizeF size = q->minimumSize(); |
|
240 //Workaround (causing extra polish) |
246 //Workaround (causing extra polish) |
241 mSizeHintPolish = false; |
247 mSizeHintPolish = false; |
242 //workaround ends |
248 //workaround ends |
|
249 q->updateGeometry(); |
|
250 QCoreApplication::sendPostedEvents(q, QEvent::LayoutRequest); |
|
251 QSizeF size = q->minimumSize(); |
243 return size; |
252 return size; |
244 } |
253 } |
245 |
254 |
246 void HbToolButtonPrivate::_q_actionTriggered() |
255 void HbToolButtonPrivate::_q_actionTriggered() |
247 { |
256 { |
248 Q_Q(HbToolButton); |
257 Q_Q(HbToolButton); |
249 emit q->triggered(action); |
258 // Only emit triggered signal for HbActions, not QActions. |
|
259 // triggered(QAction*) requires an API change we don't want to do right now. |
|
260 HbAction *hbAction = qobject_cast<HbAction *>(action); |
|
261 if (hbAction) |
|
262 emit q->triggered(hbAction); |
250 } |
263 } |
251 |
264 |
252 void HbToolButtonPrivate::_q_actionChanged() |
265 void HbToolButtonPrivate::_q_actionChanged() |
253 { |
266 { |
254 Q_Q(HbToolButton); |
267 Q_Q(HbToolButton); |
255 if (!action->icon().isNull()) { |
268 HbAction *hbAction = qobject_cast<HbAction *>(action); |
|
269 if ((hbAction && !hbAction->icon().isNull()) || !action->icon().isNull()) { |
256 if (orientation == Qt::Horizontal) { |
270 if (orientation == Qt::Horizontal) { |
257 buttonStyle = HbToolButton::ToolButtonIcon; |
271 buttonStyle = HbToolButton::ToolButtonIcon; |
258 } else if (!action->text().isEmpty()) { |
272 } else if (!action->text().isEmpty()) { |
259 buttonStyle = HbToolButton::ToolButtonTextAndIcon; |
273 buttonStyle = HbToolButton::ToolButtonTextAndIcon; |
260 } else { |
274 } else { |
334 if (d->action) { |
349 if (d->action) { |
335 disconnect(d->action, SIGNAL(triggered()), this, SLOT(_q_actionTriggered())); |
350 disconnect(d->action, SIGNAL(triggered()), this, SLOT(_q_actionTriggered())); |
336 disconnect(d->action, SIGNAL(changed()), this, SLOT(_q_actionChanged())); |
351 disconnect(d->action, SIGNAL(changed()), this, SLOT(_q_actionChanged())); |
337 } |
352 } |
338 |
353 |
339 HbAction *oldAction = d->action; |
354 QAction *oldAction = d->action; |
340 d->action = action; |
355 d->action = action; |
341 if (d->action) { |
356 if (d->action) { |
342 connect(action, SIGNAL(triggered()), this, SLOT(_q_actionTriggered())); |
357 connect(action, SIGNAL(triggered()), this, SLOT(_q_actionTriggered())); |
343 connect(action, SIGNAL(changed()), this, SLOT(_q_actionChanged())); |
358 connect(action, SIGNAL(changed()), this, SLOT(_q_actionChanged())); |
344 } |
359 } |
478 if (d->textItem) { |
493 if (d->textItem) { |
479 style()->updatePrimitive(d->textItem, HbStyle::P_ToolButton_text, &option); |
494 style()->updatePrimitive(d->textItem, HbStyle::P_ToolButton_text, &option); |
480 } |
495 } |
481 if (d->iconItem) { |
496 if (d->iconItem) { |
482 style()->updatePrimitive(d->iconItem, HbStyle::P_ToolButton_icon, &option); |
497 style()->updatePrimitive(d->iconItem, HbStyle::P_ToolButton_icon, &option); |
483 if (d->action && d->action->icon().flags() & HbIcon::Colorized) { |
498 HbAction *hbAction = qobject_cast<HbAction *>(d->action); |
484 static_cast<HbIconItem *>(d->iconItem)->setFlags(HbIcon::Colorized); |
499 if (hbAction) { |
485 } |
500 if (hbAction->icon().flags() & HbIcon::Colorized) { |
486 if (d->action && d->action->icon().mirroringMode() != HbIcon::Default) { |
501 static_cast<HbIconItem *>(d->iconItem)->setFlags(HbIcon::Colorized); |
487 HbIconItem *iconItem = static_cast<HbIconItem *>(d->iconItem); |
502 } |
488 iconItem->setMirroringMode( d->action->icon().mirroringMode() ); |
503 if (hbAction->icon().mirroringMode() != HbIcon::Default) { |
489 } |
504 HbIconItem *iconItem = static_cast<HbIconItem *>(d->iconItem); |
490 |
505 iconItem->setMirroringMode( hbAction->icon().mirroringMode() ); |
|
506 } |
|
507 } |
491 |
508 |
492 } |
509 } |
493 } |
510 } |
494 |
511 |
495 /*! |
512 /*! |
539 Q_D(HbToolButton); |
561 Q_D(HbToolButton); |
540 QGraphicsWidget::resizeEvent(event); |
562 QGraphicsWidget::resizeEvent(event); |
541 if (event->newSize() != event->oldSize() && d->polished && isVisible()) { |
563 if (event->newSize() != event->oldSize() && d->polished && isVisible()) { |
542 updatePrimitives(); |
564 updatePrimitives(); |
543 } |
565 } |
544 if (action() && action()->toolBarExtension()) { |
566 HbAction *hbAction = qobject_cast<HbAction *>(d->action); |
545 HbToolBarExtensionPrivate::d_ptr(action()->toolBarExtension())->placeToolBarExtension(); |
567 if ( hbAction && hbAction->toolBarExtension()) { |
|
568 HbToolBarExtensionPrivate::d_ptr(hbAction->toolBarExtension())->placeToolBarExtension(); |
546 } |
569 } |
547 } |
570 } |
548 |
571 |
549 /*! |
572 /*! |
550 \reimp |
573 \reimp |
554 Q_D(HbToolButton); |
577 Q_D(HbToolButton); |
555 HbAbstractButton::nextCheckState(); |
578 HbAbstractButton::nextCheckState(); |
556 if (!d->action) { |
579 if (!d->action) { |
557 return; |
580 return; |
558 } |
581 } |
559 if ( d->action->toolBarExtension() ) { |
582 HbAction *hbAction = qobject_cast<HbAction *>(d->action); |
560 HbToolBarExtensionPrivate::d_ptr(d->action->toolBarExtension())->mExtendedButton = this; |
583 if ( hbAction && hbAction->toolBarExtension() ) { |
561 d->action->toolBarExtension()->show(); |
584 HbToolBarExtensionPrivate::d_ptr(hbAction->toolBarExtension())->mExtendedButton = this; |
|
585 hbAction->toolBarExtension()->show(); |
562 } |
586 } |
563 |
587 |
564 d->action->trigger(); |
588 d->action->trigger(); |
565 } |
589 } |
566 |
590 |