43 |
43 |
44 //Location of theme preview and background icons. |
44 //Location of theme preview and background icons. |
45 static const QString KPreviewThumbnailNVG = "/scalable/qtg_graf_theme_preview_thumbnail.nvg"; |
45 static const QString KPreviewThumbnailNVG = "/scalable/qtg_graf_theme_preview_thumbnail.nvg"; |
46 static const QString KPreviewThumbnailSVG = "/scalable/qtg_graf_theme_preview_thumbnail.svg"; |
46 static const QString KPreviewThumbnailSVG = "/scalable/qtg_graf_theme_preview_thumbnail.svg"; |
47 |
47 |
48 static const QString KPreviewPrtNVG = "/scalable/qtg_graf_theme_preview_prt.nvg"; |
|
49 static const QString KPreviewLscNVG = "/scalable/qtg_graf_theme_preview_lsc.nvg"; |
|
50 static const QString KPreviewPrtSVG = "/scalable/qtg_graf_theme_preview_prt.svg"; |
|
51 static const QString KPreviewLscSVG = "/scalable/qtg_graf_theme_preview_lsc.svg"; |
|
52 |
|
53 static const QString KBackgroundPrtNVG = "/scalable/qtg_graf_screen_bg_prt.nvg"; |
48 static const QString KBackgroundPrtNVG = "/scalable/qtg_graf_screen_bg_prt.nvg"; |
54 static const QString KBackgroundLscNVG = "/scalable/qtg_graf_screen_bg_lsc.nvg"; |
49 static const QString KBackgroundLscNVG = "/scalable/qtg_graf_screen_bg_lsc.nvg"; |
55 static const QString KBackgroundPrtSVG = "/scalable/qtg_graf_screen_bg_prt.svg"; |
50 static const QString KBackgroundPrtSVG = "/scalable/qtg_graf_screen_bg_prt.svg"; |
56 static const QString KBackgroundLscSVG = "/scalable/qtg_graf_screen_bg_lsc.svg"; |
51 static const QString KBackgroundLscSVG = "/scalable/qtg_graf_screen_bg_lsc.svg"; |
57 |
52 |
58 static const QString KBackgroundPrtPNG = "/pixmap/qtg_graf_screen_bg_prt.png"; |
|
59 static const QString KBackgroundLscPNG = "/pixmap/qtg_graf_screen_bg_lsc.png"; |
|
60 |
53 |
61 |
54 |
62 |
55 |
63 |
56 |
64 /* |
57 /* |
82 QSettings iniSetting(themePath + "/index.theme", QSettings::IniFormat); |
73 QSettings iniSetting(themePath + "/index.theme", QSettings::IniFormat); |
83 iniSetting.beginGroup("Icon Theme"); |
74 iniSetting.beginGroup("Icon Theme"); |
84 name = iniSetting.value("Name").toString(); |
75 name = iniSetting.value("Name").toString(); |
85 hidden = iniSetting.value("Hidden").toString(); |
76 hidden = iniSetting.value("Hidden").toString(); |
86 iconPath = iniSetting.value("PreviewThumbnailPath").toString(); |
77 iconPath = iniSetting.value("PreviewThumbnailPath").toString(); |
87 previewPathPrt = iniSetting.value("PreviewIconPath_prt").toString(); |
|
88 previewPathLsc = iniSetting.value("PreviewIconPath_lsc").toString(); |
|
89 iniSetting.endGroup(); |
78 iniSetting.endGroup(); |
90 |
79 |
91 } |
80 } |
92 |
81 |
93 if(name.isEmpty() || (hidden == "true") ||( hidden == "")) { |
82 if(name.isEmpty() || (hidden == "true") ||( hidden == "")) { |
103 * 2. Otherwise look for the icon in the theme folder. |
92 * 2. Otherwise look for the icon in the theme folder. |
104 * 2. If preview icon doesn't exist, use background icon. |
93 * 2. If preview icon doesn't exist, use background icon. |
105 * 3. If no icon exist (background or preview),use default theme icon. |
94 * 3. If no icon exist (background or preview),use default theme icon. |
106 */ |
95 */ |
107 if(iconPath.isEmpty() || !QFileInfo(themePath + iconPath).exists()){ |
96 if(iconPath.isEmpty() || !QFileInfo(themePath + iconPath).exists()){ |
108 //Set thumbnail |
97 //Set thumbnail |
109 if(QFileInfo(themePath + KPreviewThumbnailNVG).exists()){ |
98 HbIcon themeIcon = getPreviewIcon(themePath); |
110 themeInfo->setIcon(HbIcon(themePath + KPreviewThumbnailNVG)); |
99 if(themeIcon.isNull()){ |
111 }else if(QFileInfo(themePath + KPreviewThumbnailSVG).exists()){ |
100 QString defaultThemePath = defaultTheme(); |
112 themeInfo->setIcon(HbIcon(themePath + KPreviewThumbnailSVG)); |
101 if(!defaultThemePath.isEmpty()) { |
113 }else if(QFileInfo(themePath + KBackgroundPrtNVG).exists()){ |
102 themeIcon = getPreviewIcon(defaultThemePath); |
114 themeInfo->setIcon(HbIcon(themePath + KBackgroundPrtNVG)); |
103 } |
115 } else if(QFileInfo(themePath + KBackgroundPrtSVG).exists()){ |
104 } |
116 themeInfo->setIcon(HbIcon(themePath + KBackgroundPrtSVG)); |
105 themeInfo->setIcon(themeIcon); |
117 } else if(QFileInfo(themePath + KBackgroundPrtPNG).exists()){ |
|
118 themeInfo->setIcon(HbIcon(themePath + KBackgroundPrtPNG)); |
|
119 }else{ |
|
120 themeInfo->setIcon(HbIcon(defaultTheme()->icon())); |
|
121 } |
|
122 |
|
123 } else { |
106 } else { |
124 themeInfo->setIcon(HbIcon(themePath + iconPath)); |
107 themeInfo->setIcon(HbIcon(themePath + iconPath)); |
125 } |
108 } |
126 |
109 |
127 //Portrait preview |
|
128 |
|
129 if(previewPathPrt.isEmpty() || !QFileInfo(themePath + previewPathPrt).exists()) { |
|
130 |
|
131 if(QFileInfo(themePath + KPreviewPrtNVG).exists()){ |
|
132 themeInfo->setPortraitPreviewIcon(HbIcon(themePath + KPreviewPrtNVG)); |
|
133 }else if(QFileInfo(themePath + KPreviewPrtSVG).exists()){ |
|
134 themeInfo->setPortraitPreviewIcon(HbIcon(themePath + KPreviewPrtSVG)); |
|
135 }else if(QFileInfo(themePath + KBackgroundPrtNVG).exists()){ |
|
136 themeInfo->setPortraitPreviewIcon(HbIcon(themePath + KBackgroundPrtNVG)); |
|
137 } else if(QFileInfo(themePath + KBackgroundPrtSVG).exists()){ |
|
138 themeInfo->setPortraitPreviewIcon(HbIcon(themePath + KBackgroundPrtSVG)); |
|
139 } else if(QFileInfo(themePath + KBackgroundPrtPNG).exists()){ |
|
140 themeInfo->setPortraitPreviewIcon(HbIcon(themePath + KBackgroundPrtPNG)); |
|
141 } else{ |
|
142 themeInfo->setPortraitPreviewIcon(HbIcon(defaultTheme()->icon())); |
|
143 } |
|
144 } |
|
145 else { |
|
146 themeInfo->setPortraitPreviewIcon(HbIcon(themePath + previewPathPrt)); |
|
147 } |
|
148 |
|
149 //Landscape preview |
|
150 |
|
151 if(previewPathLsc.isEmpty() || !QFileInfo(themePath + previewPathLsc).exists()) { |
|
152 if(QFileInfo(themePath + KPreviewLscNVG).exists()){ |
|
153 themeInfo->setLandscapePreviewIcon(HbIcon(themePath + KPreviewLscNVG)); |
|
154 }else if(QFileInfo(themePath + KPreviewLscSVG).exists()){ |
|
155 themeInfo->setLandscapePreviewIcon(HbIcon(themePath + KPreviewLscSVG)); |
|
156 }else if(QFileInfo(themePath + KBackgroundLscNVG).exists()){ |
|
157 themeInfo->setLandscapePreviewIcon(HbIcon(themePath + KBackgroundLscNVG)); |
|
158 } else if(QFileInfo(themePath + KBackgroundLscSVG).exists()){ |
|
159 themeInfo->setLandscapePreviewIcon(HbIcon(themePath + KBackgroundLscSVG)); |
|
160 } else if(QFileInfo(themePath + KBackgroundLscPNG).exists()){ |
|
161 themeInfo->setLandscapePreviewIcon(HbIcon(themePath + KBackgroundLscPNG)); |
|
162 } else{ |
|
163 themeInfo->setLandscapePreviewIcon(HbIcon(defaultTheme()->icon())); |
|
164 } |
|
165 } |
|
166 else { |
|
167 themeInfo->setLandscapePreviewIcon(HbIcon(themePath + previewPathLsc)); |
|
168 } |
|
169 return themeInfo; |
110 return themeInfo; |
170 |
111 |
|
112 } |
|
113 |
|
114 /*! |
|
115 * given a path to the theme, returns the preview icon or just a Null icon |
|
116 * if it doesn't exist. |
|
117 */ |
|
118 HbIcon CpThemeUtil::getPreviewIcon(const QString& themePath) |
|
119 { |
|
120 HbIcon themeIcon; |
|
121 if(QFileInfo(themePath + KPreviewThumbnailNVG).exists()){ |
|
122 themeIcon = HbIcon(themePath + KPreviewThumbnailNVG); |
|
123 }else if(QFileInfo(themePath + KPreviewThumbnailSVG).exists()){ |
|
124 themeIcon = HbIcon(themePath + KPreviewThumbnailSVG); |
|
125 }else if(QFileInfo(themePath + KBackgroundPrtNVG).exists()){ |
|
126 themeIcon = HbIcon(themePath + KBackgroundPrtNVG); |
|
127 }else if(QFileInfo(themePath + KBackgroundPrtSVG).exists()){ |
|
128 themeIcon = HbIcon(themePath + KBackgroundPrtSVG); |
|
129 } |
|
130 return themeIcon; |
|
131 |
171 } |
132 } |
172 |
133 |
173 /*! Creates a list of CpThemeInfo objects representing theme information. |
134 /*! Creates a list of CpThemeInfo objects representing theme information. |
174 * |
135 * |
175 */ |
136 */ |
176 QList<CpThemeInfo> CpThemeUtil::buildThemeList() |
137 QList<CpThemeInfo> CpThemeUtil::buildThemeList() |
177 { |
138 { |
178 QList<CpThemeInfo> themeList; |
139 QList<CpThemeInfo> themeList; |
179 |
140 |
180 QList<QPair<QString, QString> > mThemesPathList = availableThemes(); |
141 QList<QPair<QString, QString> > mThemesPathList = availableThemes(); |
181 QPair<QString, QString>pair; |
142 QPair<QString, QString>pair; |
182 foreach (pair, mThemesPathList) { |
143 foreach (pair, mThemesPathList) { |
183 QDir themeDir; |
144 QDir themeDir; |
184 QString name = pair.first; |
145 QString name = pair.first; |