343 /*! |
343 /*! |
344 \internal |
344 \internal |
345 */ |
345 */ |
346 bool HbIconPrivate::addBadge(Qt::Alignment align, |
346 bool HbIconPrivate::addBadge(Qt::Alignment align, |
347 const HbIcon &icon, |
347 const HbIcon &icon, |
348 int z) |
348 int z, |
|
349 const QSizeF &sizeFactor, |
|
350 Qt::AspectRatioMode aspectRatio) |
349 { |
351 { |
350 if (icon.isBadged()) { |
352 if (icon.isBadged()) { |
351 return false; |
353 return false; |
352 } else if (engine) { |
354 } else if (engine) { |
353 engine->addBadge(align, icon, z); |
355 engine->addBadge(align, icon, z, sizeFactor, aspectRatio); |
354 } else { |
356 } else { |
355 if (!badgeInfo) { |
357 if (!badgeInfo) { |
356 badgeInfo = new HbBadgeIcon(); |
358 badgeInfo = new HbBadgeIcon(); |
357 } |
359 } |
358 badgeInfo->addBadge(align, icon, z); |
360 badgeInfo->addBadge(align, icon, z, sizeFactor, aspectRatio); |
359 } |
361 } |
360 return true; |
362 return true; |
361 } |
363 } |
362 |
364 |
363 /*! |
365 /*! |
681 * \sa HbIcon::setSize(), HbIcon::defaultSize() |
683 * \sa HbIcon::setSize(), HbIcon::defaultSize() |
682 */ |
684 */ |
683 QSizeF HbIcon::size() const |
685 QSizeF HbIcon::size() const |
684 { |
686 { |
685 if ((static_cast<int>(flags()) & HbIcon::ResolutionCorrected)) { |
687 if ((static_cast<int>(flags()) & HbIcon::ResolutionCorrected)) { |
|
688 if (d->engine) { |
|
689 d->size = d->engine->size(); |
|
690 } |
686 if (d->size.isValid()) { |
691 if (d->size.isValid()) { |
687 return d->size; |
692 return d->size; |
688 } else { |
693 } else { |
689 QSizeF defSize(defaultSize()); |
694 QSizeF defSize(defaultSize()); |
690 HbIconLoader::global()->applyResolutionCorrection(defSize); |
|
691 return defSize; |
695 return defSize; |
692 } |
696 } |
693 } else if (d->size.isValid()) { |
697 } else if (d->size.isValid()) { |
694 return d->size; |
698 return d->size; |
695 } |
699 } |
906 |
910 |
907 /*! |
911 /*! |
908 * Adds a badge icon to the existing icon. The badge icons |
912 * Adds a badge icon to the existing icon. The badge icons |
909 * are drawn relative to the alignment you specify with the |
913 * are drawn relative to the alignment you specify with the |
910 * z-order you provide. |
914 * z-order you provide. |
|
915 * |
|
916 * By default the badge icon will use its default size. If this is |
|
917 * not suitable (which is typical in case of vector graphics) then |
|
918 * call setSize() explicitly on \a badge before passing it to this |
|
919 * function. |
|
920 * |
|
921 * The aspect ratio for the badge is kept by default, but this can be |
|
922 * changed in the \a aspectRatio argument. |
|
923 * |
|
924 * \sa addProportionalBadge() |
911 */ |
925 */ |
912 bool HbIcon::addBadge(Qt::Alignment alignment, |
926 bool HbIcon::addBadge(Qt::Alignment alignment, |
913 const HbIcon &badge, |
927 const HbIcon &badge, |
914 int z) |
928 int z, |
|
929 Qt::AspectRatioMode aspectRatio) |
915 { |
930 { |
916 d.detach(); |
931 d.detach(); |
917 return d->addBadge(alignment, badge, z); |
932 return d->addBadge(alignment, badge, z, QSizeF(), aspectRatio); |
|
933 } |
|
934 |
|
935 /*! |
|
936 * Adds a badge icon to the existing icon. The badge icons |
|
937 * are drawn relative to the alignment you specify with the |
|
938 * z-order you provide. |
|
939 * |
|
940 * With this function the size of the badge icon will be proportional |
|
941 * to the size of the badged icon. If the size needs to be explicitly |
|
942 * specified then use addBadge() instead. |
|
943 * |
|
944 * \a sizeFactor's x and y values must be between 0 and 1. They |
|
945 * specify how much space the badge takes. For example (0.25, 0.25) |
|
946 * causes both the width and height to be 1/4 of the full icon width |
|
947 * and height. |
|
948 * |
|
949 * The aspect ratio for the badge is kept by default, but this can be |
|
950 * changed in the \a aspectRatio argument. |
|
951 * |
|
952 * \sa addBadge() |
|
953 */ |
|
954 bool HbIcon::addProportionalBadge(Qt::Alignment alignment, |
|
955 const HbIcon &badge, |
|
956 const QSizeF &sizeFactor, |
|
957 int z, |
|
958 Qt::AspectRatioMode aspectRatio) |
|
959 { |
|
960 d.detach(); |
|
961 return d->addBadge(alignment, badge, z, sizeFactor, aspectRatio); |
918 } |
962 } |
919 |
963 |
920 /*! |
964 /*! |
921 * Removes badge icon(s) from the icon. |
965 * Removes badge icon(s) from the icon. |
922 */ |
966 */ |