diff -r b7da29130b0e -r 80e4d18b72f5 src/hbcore/gui/hbtoolbutton.cpp --- a/src/hbcore/gui/hbtoolbutton.cpp Fri Sep 17 08:32:10 2010 +0300 +++ b/src/hbcore/gui/hbtoolbutton.cpp Mon Oct 04 00:38:12 2010 +0300 @@ -35,6 +35,8 @@ #include "hbiconitem.h" #include "hbview.h" #include "hbmainwindow.h" +#include "hbframeitem.h" +#include "hbevent.h" #include "hbglobal_p.h" // remove when removing HB_DEPRECATED @@ -212,16 +214,12 @@ return (action != 0 && toolbarExtensionFrame); } - - - void HbToolButtonPrivate::framePrimitiveData(HbStyleFramePrimitiveData *data) { - Q_Q(HbToolButton); data->fillWholeRect = true; - + if (orientation == Qt::Vertical) { data->frameType = HbFrameDrawer::ThreePiecesHorizontal; } else { @@ -233,7 +231,7 @@ // data->state already set by abstractbutton's data init QIcon::Mode mode = HbStylePrivate::iconMode(data->state); QIcon::State state = HbStylePrivate::iconState(data->state); - + // custom background if (!q->background().isNull()) { data->frameGraphicsName = customBackground.iconName(mode, state); @@ -242,8 +240,8 @@ // in toolbar extension if(isToolBarExtension()) { - if (mode == QIcon::Normal && state == QIcon::On) { - if(!q->isCheckable()){ + if (mode == QIcon::Normal && state == QIcon::On) { + if(!q->isCheckable()){ data->frameGraphicsName = QLatin1String("qtg_fr_popup_grid_pressed"); } else { data->frameGraphicsName = QLatin1String("qtg_fr_tb_ext"); @@ -251,8 +249,8 @@ } else { data->frameGraphicsName = QLatin1String(""); } - data->frameType = HbFrameDrawer::NinePieces; - return; + data->frameType = HbFrameDrawer::NinePieces; + return; } if (!toolBarPosition) { @@ -272,80 +270,77 @@ data->frameType = HbFrameDrawer::NinePieces; return; } -// For toolbar: + // For toolbar: - QString frameGraphicsHeader; - if (!mDialogToolBar){ - if (useTransparentGraphics()) { - frameGraphicsHeader = orientation == Qt::Vertical ? - QLatin1String("qtg_fr_tb_trans_h_"): - QLatin1String("qtg_fr_tb_trans_v_"); - } else { - frameGraphicsHeader = orientation == Qt::Vertical ? - QLatin1String("qtg_fr_tb_h_"): - QLatin1String("qtg_fr_tb_v_"); - } - }else { - frameGraphicsHeader = QLatin1String("qtg_fr_popup_sk_"); - data->mirroringMode = HbIcon::LayoutDirection; - } + QString frameGraphicsHeader; + if (!mDialogToolBar){ + if (useTransparentGraphics()) { + frameGraphicsHeader = orientation == Qt::Vertical ? + QLatin1String("qtg_fr_tb_trans_h_"): + QLatin1String("qtg_fr_tb_trans_v_"); + } else { + frameGraphicsHeader = orientation == Qt::Vertical ? + QLatin1String("qtg_fr_tb_h_"): + QLatin1String("qtg_fr_tb_v_"); + } + } else { + frameGraphicsHeader = QLatin1String("qtg_fr_popup_sk_"); + data->mirroringMode = HbIcon::LayoutDirection; + } - switch (toolBarPosition) { - case TB_OnlyOne: - if (orientation == Qt::Vertical) { - list << QLatin1String("_l") << QLatin1String("_c") << QLatin1String("_r"); - } else { - list << QLatin1String("_t") << QLatin1String("_c") << QLatin1String("_b"); - } - break; - case TB_Beginning: - if (orientation== Qt::Vertical) { - list << QLatin1String("_l") << QLatin1String("_c") << QLatin1String("_cr"); - } else { - list << QLatin1String("_t") << QLatin1String("_c") << QLatin1String("_cb"); - } - break; - case TB_Middle: - if (orientation == Qt::Vertical) { - list << QLatin1String("_cl") << QLatin1String("_c") << QLatin1String("_cr"); - } else { - list << QLatin1String("_ct") << QLatin1String("_c") << QLatin1String("_cb"); - } - break; - case TB_End: - if (orientation== Qt::Vertical) { - list << QLatin1String("_cl") << QLatin1String("_c") << QLatin1String("_r"); - } else { - list << QLatin1String("_ct") << QLatin1String("_c") << QLatin1String("_b"); - } - break; + switch (toolBarPosition) { + case TB_OnlyOne: + if (orientation == Qt::Vertical) { + list << QLatin1String("_l") << QLatin1String("_c") << QLatin1String("_r"); + } else { + list << QLatin1String("_t") << QLatin1String("_c") << QLatin1String("_b"); + } + break; + case TB_Beginning: + if (orientation== Qt::Vertical) { + list << QLatin1String("_l") << QLatin1String("_c") << QLatin1String("_cr"); + } else { + list << QLatin1String("_t") << QLatin1String("_c") << QLatin1String("_cb"); + } + break; + case TB_Middle: + if (orientation == Qt::Vertical) { + list << QLatin1String("_cl") << QLatin1String("_c") << QLatin1String("_cr"); + } else { + list << QLatin1String("_ct") << QLatin1String("_c") << QLatin1String("_cb"); + } + break; + case TB_End: + if (orientation== Qt::Vertical) { + list << QLatin1String("_cl") << QLatin1String("_c") << QLatin1String("_r"); + } else { + list << QLatin1String("_ct") << QLatin1String("_c") << QLatin1String("_b"); + } + break; - default: - case TB_None: - break; - }; // switch case end - - + default: + case TB_None: + break; + } // switch case end - data->fileNameSuffixList = list; - if (mode == QIcon::Disabled && state == QIcon::Off) { - frameGraphicsFooter = QLatin1String("disabled"); - } else if (mode == QIcon::Normal && state == QIcon::On) { - if(!q->isCheckable()) { - frameGraphicsFooter = QLatin1String("pressed"); - } else { - frameGraphicsFooter = QLatin1String("latched"); - } - } else if (mode == QIcon::Selected && state == QIcon::Off) { - frameGraphicsFooter = QLatin1String("highlight"); - } else { - frameGraphicsFooter = QLatin1String("normal"); - } - data->frameGraphicsName = QString ("%0%1").arg(frameGraphicsHeader).arg(frameGraphicsFooter); - data->mirroringMode = HbIcon::LayoutDirection; - return; + data->fileNameSuffixList = list; + if (mode == QIcon::Disabled && state == QIcon::Off) { + frameGraphicsFooter = QLatin1String("disabled"); + } else if (mode == QIcon::Normal && state == QIcon::On) { + if(!q->isCheckable()) { + frameGraphicsFooter = QLatin1String("pressed"); + } else { + frameGraphicsFooter = QLatin1String("latched"); + } + } else if (mode == QIcon::Selected && state == QIcon::Off) { + frameGraphicsFooter = QLatin1String("highlight"); + } else { + frameGraphicsFooter = QLatin1String("normal"); + } + data->frameGraphicsName = QString ("%0%1").arg(frameGraphicsHeader).arg(frameGraphicsFooter); + data->mirroringMode = HbIcon::LayoutDirection; +} -} void HbToolButtonPrivate::iconPrimitiveData(HbStyleIconPrimitiveData *data) { Q_Q(HbToolButton); @@ -353,6 +348,8 @@ data->icon = q->action()->icon(); } else if(action){ data->icon = action->icon(); + } else { + data->icon = HbIcon(); } data->iconMode = HbStylePrivate::iconMode(data->state); data->iconState = HbStylePrivate::iconState(data->state); @@ -362,6 +359,8 @@ { if(action) { data->text = action->text(); + } else { + data->text = QString(); } } @@ -560,7 +559,7 @@ bool itemHasNoContents = false; if (data.text.isSet()) { if ( data.text.value().isEmpty() || data.text.value().isNull() || - (property(BUTTONSTYLE).toInt() == HbToolButtonPrivate::ToolButtonIcon)) { + (property(BUTTONSTYLE).toInt() == HbToolButtonPrivate::ToolButtonIcon)) { itemHasNoContents = true; } } @@ -568,6 +567,12 @@ if(!itemHasNoContents) { style()->updatePrimitive(d->textItem, &data, this); + /* HbDialog::setPrimaryAction deprecation action coloring - begin */ + if (d->action && d->action->property("invalid_addition").isValid() ) { + HbTextItem *textItem = qgraphicsitem_cast(d->textItem); + textItem->setTextColor(QColor("magenta")); + } + /* HbDialog::setPrimaryAction deprecation action coloring - end */ d->textItem->update(); } } @@ -580,13 +585,18 @@ if (data.icon.value().isNull() || (property(BUTTONSTYLE).toInt() == HbToolButtonPrivate::ToolButtonText)) { itemHasNoContents = true; } else { - style()->updatePrimitive(d->iconItem, &data, this); - d->iconItem->update(); + style()->updatePrimitive(d->iconItem, &data, this); + /* HbDialog::setPrimaryAction deprecation action coloring - begin */ + if (d->action && d->action->property("invalid_addition").isValid() ) { + HbIconItem *iconItem = qgraphicsitem_cast(d->iconItem); + iconItem->setColor(QColor("magenta")); + } + /* HbDialog::setPrimaryAction deprecation action coloring - end */ + d->iconItem->update(); } } d->iconItem->setFlag(QGraphicsItem::ItemHasNoContents, itemHasNoContents); } - } @@ -687,6 +697,13 @@ if (event->type() == QEvent::GraphicsSceneMouseRelease) { mouseReleaseEvent(static_cast(event)); return true; + } else if(event->type() == HbEvent::ThemeChanged) { + Q_D(HbToolButton); + changeEvent(event); + if (d->frameItem) { + HbFrameItem *item = static_cast(d->frameItem); + item->frameDrawer().themeChanged(); + } } return HbAbstractButton::event(event);