src/hbcore/image/hbicon.cpp
changeset 30 80e4d18b72f5
parent 23 e6ad4ef83b23
equal deleted inserted replaced
28:b7da29130b0e 30:80e4d18b72f5
   411     d = shared_null;
   411     d = shared_null;
   412 }
   412 }
   413 
   413 
   414 /*! Constructs a new icon with the icon name \a iconName.
   414 /*! Constructs a new icon with the icon name \a iconName.
   415 */
   415 */
   416 HbIcon::HbIcon(const QString &iconName)
   416 HbIcon::HbIcon(const QString &iconName) : d( new HbIconPrivate(iconName) )
   417 {
   417 {
   418     d = new HbIconPrivate(iconName);
       
   419 }
   418 }
   420 
   419 
   421 /*!
   420 /*!
   422  * Constructs a new icon to be a copy of the given QIcon.  Due to the
   421  * Constructs a new icon to be a copy of the given QIcon.  Due to the
   423  * limitations listed below, this constructor should be used only for
   422  * limitations listed below, this constructor should be used only for
   435  * This method should only be used if absolute necessary, as this is not ideal
   434  * This method should only be used if absolute necessary, as this is not ideal
   436  * for hardware accelerated environment and there may be huge differences in
   435  * for hardware accelerated environment and there may be huge differences in
   437  * painting performance when compared to a native HbIcon.  Some advanced resource
   436  * painting performance when compared to a native HbIcon.  Some advanced resource
   438  * management features are not available for such icons either.
   437  * management features are not available for such icons either.
   439  */
   438  */
   440 HbIcon::HbIcon(const QIcon &icon)
   439 HbIcon::HbIcon(const QIcon &icon) : d( new HbIconPrivate(icon) )
   441 {
   440 {
   442     d = new HbIconPrivate(icon);
       
   443 }
   441 }
   444 
   442 
   445 /*!
   443 /*!
   446 * Copy constructs a new icon using the \a other icon.
   444 * Copy constructs a new icon using the \a other icon.
   447 * Copy-on-write semantics is used, so this only does a shallow copy.
   445 * Copy-on-write semantics is used, so this only does a shallow copy.
   670 
   668 
   671             QPixmap pixmap = d->qicon.pixmap(size.toSize(), mode, state);
   669             QPixmap pixmap = d->qicon.pixmap(size.toSize(), mode, state);
   672             QSizeF pixmapSize = pixmap.size();
   670             QSizeF pixmapSize = pixmap.size();
   673 
   671 
   674             // QIcon::pixmap() will not do upscaling.
   672             // QIcon::pixmap() will not do upscaling.
   675             if (pixmapSize.width() < size.width() || pixmapSize.height() < size.height()) {
   673             if (!pixmap.isNull() && (pixmapSize.width() < size.width() || pixmapSize.height() < size.height())) {
   676                 // Native HbIcons are scaled using SmoothTransformation so use the same.
   674                 // Native HbIcons are scaled using SmoothTransformation so use the same.
   677                 pixmap = pixmap.scaled(size.toSize(), aspectRatioMode, Qt::SmoothTransformation);
   675                 pixmap = pixmap.scaled(size.toSize(), aspectRatioMode, Qt::SmoothTransformation);
   678                 pixmapSize = pixmap.size();
   676                 pixmapSize = pixmap.size();
   679             }
   677             }
   680 
   678 
   934 
   932 
   935 /*!
   933 /*!
   936  * Adds a badge icon to the existing icon. The badge icons
   934  * Adds a badge icon to the existing icon. The badge icons
   937  * are drawn relative to the alignment you specify with the
   935  * are drawn relative to the alignment you specify with the
   938  * z-order you provide.
   936  * z-order you provide.
   939  * 
   937  *
   940  * By default the badge icon will use its default size.  If this is
   938  * By default the badge icon will use its default size.  If this is
   941  * not suitable (which is typical in case of vector graphics) then
   939  * not suitable (which is typical in case of vector graphics) then
   942  * call setSize() explicitly on \a badge before passing it to this
   940  * call setSize() explicitly on \a badge before passing it to this
   943  * function.
   941  * function.
   944  *
   942  *