231 QStringList list; |
229 QStringList list; |
232 QString frameGraphicsFooter; |
230 QString frameGraphicsFooter; |
233 // data->state already set by abstractbutton's data init |
231 // data->state already set by abstractbutton's data init |
234 QIcon::Mode mode = HbStylePrivate::iconMode(data->state); |
232 QIcon::Mode mode = HbStylePrivate::iconMode(data->state); |
235 QIcon::State state = HbStylePrivate::iconState(data->state); |
233 QIcon::State state = HbStylePrivate::iconState(data->state); |
236 |
234 |
237 // custom background |
235 // custom background |
238 if (!q->background().isNull()) { |
236 if (!q->background().isNull()) { |
239 data->frameGraphicsName = customBackground.iconName(mode, state); |
237 data->frameGraphicsName = customBackground.iconName(mode, state); |
240 return; |
238 return; |
241 } |
239 } |
242 |
240 |
243 // in toolbar extension |
241 // in toolbar extension |
244 if(isToolBarExtension()) { |
242 if(isToolBarExtension()) { |
245 if (mode == QIcon::Normal && state == QIcon::On) { |
243 if (mode == QIcon::Normal && state == QIcon::On) { |
246 if(!q->isCheckable()){ |
244 if(!q->isCheckable()){ |
247 data->frameGraphicsName = QLatin1String("qtg_fr_popup_grid_pressed"); |
245 data->frameGraphicsName = QLatin1String("qtg_fr_popup_grid_pressed"); |
248 } else { |
246 } else { |
249 data->frameGraphicsName = QLatin1String("qtg_fr_tb_ext"); |
247 data->frameGraphicsName = QLatin1String("qtg_fr_tb_ext"); |
250 } |
248 } |
251 } else { |
249 } else { |
252 data->frameGraphicsName = QLatin1String(""); |
250 data->frameGraphicsName = QLatin1String(""); |
253 } |
251 } |
254 data->frameType = HbFrameDrawer::NinePieces; |
252 data->frameType = HbFrameDrawer::NinePieces; |
255 return; |
253 return; |
256 } |
254 } |
257 |
255 |
258 if (!toolBarPosition) { |
256 if (!toolBarPosition) { |
259 if (mode == QIcon::Disabled && state == QIcon::Off) { |
257 if (mode == QIcon::Disabled && state == QIcon::Off) { |
260 data->frameGraphicsName = QLatin1String("qtg_fr_btn_disabled"); |
258 data->frameGraphicsName = QLatin1String("qtg_fr_btn_disabled"); |
270 data->frameGraphicsName = QLatin1String("qtg_fr_btn_normal"); |
268 data->frameGraphicsName = QLatin1String("qtg_fr_btn_normal"); |
271 } |
269 } |
272 data->frameType = HbFrameDrawer::NinePieces; |
270 data->frameType = HbFrameDrawer::NinePieces; |
273 return; |
271 return; |
274 } |
272 } |
275 // For toolbar: |
273 // For toolbar: |
276 |
274 |
277 QString frameGraphicsHeader; |
275 QString frameGraphicsHeader; |
278 if (!mDialogToolBar){ |
276 if (!mDialogToolBar){ |
279 if (useTransparentGraphics()) { |
277 if (useTransparentGraphics()) { |
280 frameGraphicsHeader = orientation == Qt::Vertical ? |
278 frameGraphicsHeader = orientation == Qt::Vertical ? |
281 QLatin1String("qtg_fr_tb_trans_h_"): |
279 QLatin1String("qtg_fr_tb_trans_h_"): |
282 QLatin1String("qtg_fr_tb_trans_v_"); |
280 QLatin1String("qtg_fr_tb_trans_v_"); |
283 } else { |
281 } else { |
284 frameGraphicsHeader = orientation == Qt::Vertical ? |
282 frameGraphicsHeader = orientation == Qt::Vertical ? |
285 QLatin1String("qtg_fr_tb_h_"): |
283 QLatin1String("qtg_fr_tb_h_"): |
286 QLatin1String("qtg_fr_tb_v_"); |
284 QLatin1String("qtg_fr_tb_v_"); |
287 } |
285 } |
288 }else { |
286 } else { |
289 frameGraphicsHeader = QLatin1String("qtg_fr_popup_sk_"); |
287 frameGraphicsHeader = QLatin1String("qtg_fr_popup_sk_"); |
290 data->mirroringMode = HbIcon::LayoutDirection; |
288 data->mirroringMode = HbIcon::LayoutDirection; |
291 } |
289 } |
292 |
290 |
293 switch (toolBarPosition) { |
291 switch (toolBarPosition) { |
294 case TB_OnlyOne: |
292 case TB_OnlyOne: |
295 if (orientation == Qt::Vertical) { |
293 if (orientation == Qt::Vertical) { |
296 list << QLatin1String("_l") << QLatin1String("_c") << QLatin1String("_r"); |
294 list << QLatin1String("_l") << QLatin1String("_c") << QLatin1String("_r"); |
297 } else { |
295 } else { |
298 list << QLatin1String("_t") << QLatin1String("_c") << QLatin1String("_b"); |
296 list << QLatin1String("_t") << QLatin1String("_c") << QLatin1String("_b"); |
299 } |
297 } |
300 break; |
298 break; |
301 case TB_Beginning: |
299 case TB_Beginning: |
302 if (orientation== Qt::Vertical) { |
300 if (orientation== Qt::Vertical) { |
303 list << QLatin1String("_l") << QLatin1String("_c") << QLatin1String("_cr"); |
301 list << QLatin1String("_l") << QLatin1String("_c") << QLatin1String("_cr"); |
304 } else { |
302 } else { |
305 list << QLatin1String("_t") << QLatin1String("_c") << QLatin1String("_cb"); |
303 list << QLatin1String("_t") << QLatin1String("_c") << QLatin1String("_cb"); |
306 } |
304 } |
307 break; |
305 break; |
308 case TB_Middle: |
306 case TB_Middle: |
309 if (orientation == Qt::Vertical) { |
307 if (orientation == Qt::Vertical) { |
310 list << QLatin1String("_cl") << QLatin1String("_c") << QLatin1String("_cr"); |
308 list << QLatin1String("_cl") << QLatin1String("_c") << QLatin1String("_cr"); |
311 } else { |
309 } else { |
312 list << QLatin1String("_ct") << QLatin1String("_c") << QLatin1String("_cb"); |
310 list << QLatin1String("_ct") << QLatin1String("_c") << QLatin1String("_cb"); |
313 } |
311 } |
314 break; |
312 break; |
315 case TB_End: |
313 case TB_End: |
316 if (orientation== Qt::Vertical) { |
314 if (orientation== Qt::Vertical) { |
317 list << QLatin1String("_cl") << QLatin1String("_c") << QLatin1String("_r"); |
315 list << QLatin1String("_cl") << QLatin1String("_c") << QLatin1String("_r"); |
318 } else { |
316 } else { |
319 list << QLatin1String("_ct") << QLatin1String("_c") << QLatin1String("_b"); |
317 list << QLatin1String("_ct") << QLatin1String("_c") << QLatin1String("_b"); |
320 } |
318 } |
321 break; |
319 break; |
322 |
320 |
323 default: |
321 default: |
324 case TB_None: |
322 case TB_None: |
325 break; |
323 break; |
326 }; // switch case end |
324 } // switch case end |
327 |
325 |
328 |
326 data->fileNameSuffixList = list; |
329 |
327 if (mode == QIcon::Disabled && state == QIcon::Off) { |
330 data->fileNameSuffixList = list; |
328 frameGraphicsFooter = QLatin1String("disabled"); |
331 if (mode == QIcon::Disabled && state == QIcon::Off) { |
329 } else if (mode == QIcon::Normal && state == QIcon::On) { |
332 frameGraphicsFooter = QLatin1String("disabled"); |
330 if(!q->isCheckable()) { |
333 } else if (mode == QIcon::Normal && state == QIcon::On) { |
331 frameGraphicsFooter = QLatin1String("pressed"); |
334 if(!q->isCheckable()) { |
332 } else { |
335 frameGraphicsFooter = QLatin1String("pressed"); |
333 frameGraphicsFooter = QLatin1String("latched"); |
336 } else { |
334 } |
337 frameGraphicsFooter = QLatin1String("latched"); |
335 } else if (mode == QIcon::Selected && state == QIcon::Off) { |
338 } |
336 frameGraphicsFooter = QLatin1String("highlight"); |
339 } else if (mode == QIcon::Selected && state == QIcon::Off) { |
337 } else { |
340 frameGraphicsFooter = QLatin1String("highlight"); |
338 frameGraphicsFooter = QLatin1String("normal"); |
341 } else { |
339 } |
342 frameGraphicsFooter = QLatin1String("normal"); |
340 data->frameGraphicsName = QString ("%0%1").arg(frameGraphicsHeader).arg(frameGraphicsFooter); |
343 } |
341 data->mirroringMode = HbIcon::LayoutDirection; |
344 data->frameGraphicsName = QString ("%0%1").arg(frameGraphicsHeader).arg(frameGraphicsFooter); |
342 } |
345 data->mirroringMode = HbIcon::LayoutDirection; |
343 |
346 return; |
|
347 |
|
348 } |
|
349 void HbToolButtonPrivate::iconPrimitiveData(HbStyleIconPrimitiveData *data) |
344 void HbToolButtonPrivate::iconPrimitiveData(HbStyleIconPrimitiveData *data) |
350 { |
345 { |
351 Q_Q(HbToolButton); |
346 Q_Q(HbToolButton); |
352 if (q->action()) { |
347 if (q->action()) { |
353 data->icon = q->action()->icon(); |
348 data->icon = q->action()->icon(); |
354 } else if(action){ |
349 } else if(action){ |
355 data->icon = action->icon(); |
350 data->icon = action->icon(); |
|
351 } else { |
|
352 data->icon = HbIcon(); |
356 } |
353 } |
357 data->iconMode = HbStylePrivate::iconMode(data->state); |
354 data->iconMode = HbStylePrivate::iconMode(data->state); |
358 data->iconState = HbStylePrivate::iconState(data->state); |
355 data->iconState = HbStylePrivate::iconState(data->state); |
359 return; |
356 return; |
360 } |
357 } |
361 void HbToolButtonPrivate::textPrimitiveData(HbStyleTextPrimitiveData *data) |
358 void HbToolButtonPrivate::textPrimitiveData(HbStyleTextPrimitiveData *data) |
362 { |
359 { |
363 if(action) { |
360 if(action) { |
364 data->text = action->text(); |
361 data->text = action->text(); |
|
362 } else { |
|
363 data->text = QString(); |
365 } |
364 } |
366 } |
365 } |
367 |
366 |
368 QSizeF HbToolButtonPrivate::getMinimumSize() |
367 QSizeF HbToolButtonPrivate::getMinimumSize() |
369 { |
368 { |
558 HbStyleTextPrimitiveData data; |
557 HbStyleTextPrimitiveData data; |
559 initPrimitiveData(&data, d->textItem); |
558 initPrimitiveData(&data, d->textItem); |
560 bool itemHasNoContents = false; |
559 bool itemHasNoContents = false; |
561 if (data.text.isSet()) { |
560 if (data.text.isSet()) { |
562 if ( data.text.value().isEmpty() || data.text.value().isNull() || |
561 if ( data.text.value().isEmpty() || data.text.value().isNull() || |
563 (property(BUTTONSTYLE).toInt() == HbToolButtonPrivate::ToolButtonIcon)) { |
562 (property(BUTTONSTYLE).toInt() == HbToolButtonPrivate::ToolButtonIcon)) { |
564 itemHasNoContents = true; |
563 itemHasNoContents = true; |
565 } |
564 } |
566 } |
565 } |
567 d->textItem->setFlag(QGraphicsItem::ItemHasNoContents, itemHasNoContents); |
566 d->textItem->setFlag(QGraphicsItem::ItemHasNoContents, itemHasNoContents); |
568 if(!itemHasNoContents) { |
567 if(!itemHasNoContents) { |
569 |
568 |
570 style()->updatePrimitive(d->textItem, &data, this); |
569 style()->updatePrimitive(d->textItem, &data, this); |
|
570 /* HbDialog::setPrimaryAction deprecation action coloring - begin */ |
|
571 if (d->action && d->action->property("invalid_addition").isValid() ) { |
|
572 HbTextItem *textItem = qgraphicsitem_cast<HbTextItem*>(d->textItem); |
|
573 textItem->setTextColor(QColor("magenta")); |
|
574 } |
|
575 /* HbDialog::setPrimaryAction deprecation action coloring - end */ |
571 d->textItem->update(); |
576 d->textItem->update(); |
572 } |
577 } |
573 } |
578 } |
574 if (d->iconItem) { |
579 if (d->iconItem) { |
575 HbStyleIconPrimitiveData data; |
580 HbStyleIconPrimitiveData data; |
578 bool itemHasNoContents = false; |
583 bool itemHasNoContents = false; |
579 if (data.icon.isSet()) { |
584 if (data.icon.isSet()) { |
580 if (data.icon.value().isNull() || (property(BUTTONSTYLE).toInt() == HbToolButtonPrivate::ToolButtonText)) { |
585 if (data.icon.value().isNull() || (property(BUTTONSTYLE).toInt() == HbToolButtonPrivate::ToolButtonText)) { |
581 itemHasNoContents = true; |
586 itemHasNoContents = true; |
582 } else { |
587 } else { |
583 style()->updatePrimitive(d->iconItem, &data, this); |
588 style()->updatePrimitive(d->iconItem, &data, this); |
584 d->iconItem->update(); |
589 /* HbDialog::setPrimaryAction deprecation action coloring - begin */ |
|
590 if (d->action && d->action->property("invalid_addition").isValid() ) { |
|
591 HbIconItem *iconItem = qgraphicsitem_cast<HbIconItem*>(d->iconItem); |
|
592 iconItem->setColor(QColor("magenta")); |
|
593 } |
|
594 /* HbDialog::setPrimaryAction deprecation action coloring - end */ |
|
595 d->iconItem->update(); |
585 } |
596 } |
586 } |
597 } |
587 d->iconItem->setFlag(QGraphicsItem::ItemHasNoContents, itemHasNoContents); |
598 d->iconItem->setFlag(QGraphicsItem::ItemHasNoContents, itemHasNoContents); |
588 } |
599 } |
589 |
|
590 } |
600 } |
591 |
601 |
592 |
602 |
593 /*! |
603 /*! |
594 \internal |
604 \internal |