33 |
33 |
34 #include "hbmemoryutils_p.h" |
34 #include "hbmemoryutils_p.h" |
35 #include "hbmaskableiconimpl_p.h" |
35 #include "hbmaskableiconimpl_p.h" |
36 #include "hbpixmapiconrenderer_p.h" |
36 #include "hbpixmapiconrenderer_p.h" |
37 |
37 |
38 struct HbPixmapMaskedIcon |
38 struct HbPixmapMaskedIcon { |
39 { |
|
40 QPixmap currentPixmap; |
39 QPixmap currentPixmap; |
41 }; |
40 }; |
42 |
41 |
43 HbPixmapIconImpl::HbPixmapIconImpl(HbSharedIconInfo iconData, QString& name, |
42 HbPixmapIconImpl::HbPixmapIconImpl(HbSharedIconInfo iconData, QString &name, |
44 const QSizeF& keySize, |
43 const QSizeF &keySize, |
45 Qt::AspectRatioMode aspectRatioMode, |
44 Qt::AspectRatioMode aspectRatioMode, |
46 QIcon::Mode mode, |
45 QIcon::Mode mode, |
47 bool mirrored, |
46 bool mirrored, |
48 HbRenderingMode renderMode): |
47 HbRenderingMode renderMode): |
49 HbIconImpl(iconData, |
48 HbIconImpl(iconData, |
50 name, |
49 name, |
51 keySize, |
50 keySize, |
52 aspectRatioMode, |
51 aspectRatioMode, |
53 mode, |
52 mode, |
54 mirrored, |
53 mirrored, |
55 renderMode), |
54 renderMode), |
56 pixmapIconRenderer(0) |
55 pixmapIconRenderer(0) |
57 { |
56 { |
58 retrievePixmapData(); |
57 retrievePixmapData(); |
59 pixmapIconRenderer = new HbPixmapIconRenderer(pixmapData, this); |
58 pixmapIconRenderer = new HbPixmapIconRenderer(pixmapData, this); |
60 } |
59 } |
61 |
60 |
62 HbPixmapIconImpl::HbPixmapIconImpl(const QPixmap& pixmap, const QString& name): |
61 HbPixmapIconImpl::HbPixmapIconImpl(const QPixmap &pixmap, const QString &name): |
63 pixmapData(pixmap), |
62 pixmapData(pixmap), |
64 pixmapIconRenderer(0) |
63 pixmapIconRenderer(0) |
65 { |
64 { |
66 pixmapIconRenderer = new HbPixmapIconRenderer(pixmapData, this); |
65 pixmapIconRenderer = new HbPixmapIconRenderer(pixmapData, this); |
67 aspectRatioMode = Qt::KeepAspectRatio; |
66 aspectRatioMode = Qt::KeepAspectRatio; |
68 mode = QIcon::Normal; |
67 mode = QIcon::Normal; |
69 mirrored = false; |
68 mirrored = false; |
93 } |
92 } |
94 |
93 |
95 void HbPixmapIconImpl::retrievePixmapData() |
94 void HbPixmapIconImpl::retrievePixmapData() |
96 { |
95 { |
97 GET_MEMORY_MANAGER(HbMemoryManager::SharedMemory); |
96 GET_MEMORY_MANAGER(HbMemoryManager::SharedMemory); |
98 QImage image((const uchar*) |
97 QImage image((const uchar *) |
99 ((char *)manager->base() + sharedIconData.pixmapData.offset), |
98 ((char *)manager->base() + sharedIconData.pixmapData.offset), |
100 sharedIconData.pixmapData.width, sharedIconData.pixmapData.height, |
99 sharedIconData.pixmapData.width, sharedIconData.pixmapData.height, |
101 sharedIconData.pixmapData.format); |
100 sharedIconData.pixmapData.format); |
102 |
101 |
103 pixmapData = QPixmap::fromImage((image)); |
102 pixmapData = QPixmap::fromImage((image)); |
104 defaultIconSize = |
103 defaultIconSize = |
105 QSize(sharedIconData.pixmapData.defaultWidth, sharedIconData.pixmapData.defaultHeight); |
104 QSize(sharedIconData.pixmapData.defaultWidth, sharedIconData.pixmapData.defaultHeight); |
106 |
105 |
107 } |
106 } |
108 |
107 |
109 void HbPixmapIconImpl::paint(QPainter* painter, |
108 void HbPixmapIconImpl::paint(QPainter *painter, |
110 const QRectF &rect, |
109 const QRectF &rect, |
111 Qt::Alignment alignment, |
110 Qt::Alignment alignment, |
112 const QPainterPath &clipPath, |
111 const QPainterPath &clipPath, |
113 HbMaskableIconImpl * maskIconData) |
112 HbMaskableIconImpl *maskIconData) |
114 { |
113 { |
115 #ifdef HB_ICON_CACHE_DEBUG |
114 #ifdef HB_ICON_CACHE_DEBUG |
116 qDebug() << "HbPixmapIconImpl::paint()-->"<<this->fileName; |
115 qDebug() << "HbPixmapIconImpl::paint()-->" << this->fileName; |
117 #endif |
116 #endif |
118 QPointF topLeft = rect.topLeft(); |
117 QPointF topLeft = rect.topLeft(); |
119 QSizeF pixmapSize = pixmapData.size(); |
118 QSizeF pixmapSize = pixmapData.size(); |
120 |
119 |
121 if (alignment & Qt::AlignRight) { |
120 if (alignment & Qt::AlignRight) { |