27 #endif |
27 #endif |
28 // cfbsbitmap |
28 // cfbsbitmap |
29 #include <apgicnfl.h> |
29 #include <apgicnfl.h> |
30 |
30 |
31 #include <HbIcon> |
31 #include <HbIcon> |
|
32 |
32 #include "camenuiconutility.h" |
33 #include "camenuiconutility.h" |
33 #include "camenuiconmifutility.h" |
|
34 #include "cabitmapadapter.h" |
34 #include "cabitmapadapter.h" |
35 #include "caentry.h" |
35 #include "caentry.h" |
36 #include "caquery.h" |
36 #include "caquery.h" |
37 #include "caservice.h" |
37 #include "caservice.h" |
38 #include "cadef.h" |
38 #include "cadef.h" |
39 |
39 |
40 const QString appUidAttributeName("application:uid"); |
40 const char appUidAttributeName[] = "application:uid"; |
41 |
41 |
42 /*! |
42 /*! |
43 Get icon from entry. |
43 Get icon from entry. |
44 \param entry const reference to CaEntry. |
44 \param entry const reference to CaEntry. |
45 \retval icon. |
45 \retval icon. |
46 */ |
46 */ |
47 LOCAL_C HbIcon getIconFromEntry(const CaEntry& entry) |
47 LOCAL_C HbIcon getIconFromEntry(const CaEntry& entry, const QSizeF &size) |
48 { |
48 { |
49 HbIcon icon; |
49 HbIcon icon; |
50 QString skinId(entry.iconDescription().skinId()); |
50 QString skinId(entry.iconDescription().skinId()); |
51 if (!skinId.isEmpty()) { |
51 if (!skinId.isEmpty()) { |
52 icon = HbIcon(skinId); |
52 icon = HbIcon(skinId); |
54 |
54 |
55 if (icon.isNull() || !(icon.size().isValid())) { |
55 if (icon.isNull() || !(icon.size().isValid())) { |
56 QString fileName(entry.iconDescription().filename()); |
56 QString fileName(entry.iconDescription().filename()); |
57 if (!fileName.isEmpty()) { |
57 if (!fileName.isEmpty()) { |
58 icon = HbIcon(fileName); |
58 icon = HbIcon(fileName); |
|
59 if (fileName.contains(QChar('.')) |
|
60 && !icon.isNull() && icon.size().isValid()) { |
|
61 icon.setSize(size); |
|
62 icon = HbIcon(QIcon(icon.pixmap())); |
|
63 } |
59 } |
64 } |
60 } |
65 } |
61 return icon; |
66 return icon; |
62 } |
67 } |
63 |
68 |
65 Get icon from apparc. |
70 Get icon from apparc. |
66 \param entry const reference to CaEntry. |
71 \param entry const reference to CaEntry. |
67 \param sie const reference to icon size. |
72 \param sie const reference to icon size. |
68 \retval icon. |
73 \retval icon. |
69 */ |
74 */ |
70 LOCAL_C HbIcon getIconFromApparcL(int uidValue, const QSize &size) |
75 LOCAL_C HbIcon getIconFromApparcL(int uidValue, const QSizeF &size) |
71 { |
76 { |
72 HbIcon icon; |
77 HbIcon icon; |
73 |
78 |
74 RApaLsSession apaLsSession; |
79 RApaLsSession apaLsSession; |
75 CleanupClosePushL(apaLsSession); |
80 CleanupClosePushL(apaLsSession); |
101 QPixmap pixmap; |
106 QPixmap pixmap; |
102 if ((err == KErrNone) && (iconsCount > 0)) { |
107 if ((err == KErrNone) && (iconsCount > 0)) { |
103 CaBitmapAdapter::fromBitmapAndMaskToPixmapL(apaMaskedBitmap, |
108 CaBitmapAdapter::fromBitmapAndMaskToPixmapL(apaMaskedBitmap, |
104 apaMaskedBitmap->Mask(), pixmap); |
109 apaMaskedBitmap->Mask(), pixmap); |
105 |
110 |
106 pixmap = pixmap.scaled(size, Qt::KeepAspectRatioByExpanding); |
111 pixmap = pixmap.scaled(size.toSize(), |
|
112 Qt::KeepAspectRatioByExpanding); |
107 icon = HbIcon(QIcon(pixmap)); |
113 icon = HbIcon(QIcon(pixmap)); |
108 } else { |
114 } else { |
109 HBufC* fileNameFromApparc = NULL; |
115 HBufC* fileNameFromApparc = NULL; |
110 TInt err2 = apaLsSession.GetAppIcon(uid,fileNameFromApparc); |
116 TInt err2 = apaLsSession.GetAppIcon(uid,fileNameFromApparc); |
111 CleanupStack::PushL(fileNameFromApparc); |
117 CleanupStack::PushL(fileNameFromApparc); |
112 if (err2 == KErrNone) { |
118 if (err2 == KErrNone) { |
113 QString fileName = XQConversions::s60DescToQString( |
119 QString fileName = XQConversions::s60DescToQString( |
114 fileNameFromApparc->Des()); |
120 fileNameFromApparc->Des()); |
115 if (fileName.contains(QString(".mif")) || fileName.contains(QString(".mbm"))) { |
121 if (fileName.endsWith(QLatin1String(".mif"), |
116 |
122 Qt::CaseInsensitive) || |
117 TPtr ptr(fileNameFromApparc->Des()); |
123 fileName.endsWith(QLatin1String(".mbm"), |
118 CaMenuIconMifUtility::GetPixmapByFilenameL(ptr,size,pixmap); |
124 Qt::CaseInsensitive)) { |
119 icon = HbIcon(QIcon(pixmap)); |
125 icon = HbIcon(QIcon(fileName)); |
|
126 // Icon should be valid. |
|
127 icon.setSize(QSizeF(0.0, 0.0)); |
120 } else { |
128 } else { |
121 icon = HbIcon(fileName); |
129 icon = HbIcon(fileName); |
122 } |
130 } |
123 } |
131 } |
124 CleanupStack::PopAndDestroy(fileNameFromApparc); |
132 CleanupStack::PopAndDestroy(fileNameFromApparc); |
187 \param entry const reference to CaEntry. |
195 \param entry const reference to CaEntry. |
188 \param sie const reference to icon size. |
196 \param sie const reference to icon size. |
189 \retval icon. |
197 \retval icon. |
190 */ |
198 */ |
191 HbIcon CaMenuIconUtility::getApplicationIcon(int uid, |
199 HbIcon CaMenuIconUtility::getApplicationIcon(int uid, |
192 const QSize &size) |
200 const QSizeF &size) |
193 { |
201 { |
194 HbIcon icon; |
202 HbIcon icon; |
195 CaEntry entry; |
203 CaEntry entry; |
196 entry = getEntryByUid(uid); |
204 entry = getEntryByUid(uid); |
197 icon = getEntryIcon(entry, size); |
205 icon = getEntryIcon(entry, size); |
203 \param entry const reference to CaEntry. |
211 \param entry const reference to CaEntry. |
204 \param sie const reference to icon size. |
212 \param sie const reference to icon size. |
205 \retval icon. |
213 \retval icon. |
206 */ |
214 */ |
207 HbIcon CaMenuIconUtility::getEntryIcon(const CaEntry& entry, |
215 HbIcon CaMenuIconUtility::getEntryIcon(const CaEntry& entry, |
208 const QSize &size) |
216 const QSizeF &size) |
209 { |
217 { |
210 HbIcon icon; |
218 HbIcon icon; |
211 icon = getIconFromEntry(entry); |
219 icon = getIconFromEntry(entry, size); |
212 |
220 |
213 if (icon.isNull() || !(icon.size().isValid())) { |
221 if (icon.isNull() || !(icon.size().isValid())) { |
214 QString uidString(entry.attribute(appUidAttributeName)); |
222 QString uidString(entry.attribute(appUidAttributeName)); |
215 bool uidOk(false); |
223 bool uidOk(false); |
216 int uidValue = uidString.toInt(&uidOk); |
224 int uidValue = uidString.toInt(&uidOk); |