1 /* |
1 /* |
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0"" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Private implementation of the theme changer. |
|
15 * |
8 * |
16 */ |
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
17 |
17 |
18 #include "cpthemechanger.h" |
18 #include "cpthemechanger.h" |
19 #include "cpthemechanger_p.h" |
19 #include "cpthemechanger_p.h" |
20 #include <QStringList> |
20 #include <QStringList> |
21 #include <QSettings> |
21 #include <QSettings> |
22 #include <QFileSystemWatcher> |
22 #include <QFileSystemWatcher> |
|
23 #include <QPixmap> |
23 #include <QSizeF> |
24 #include <QSizeF> |
24 #include <hbicon.h> |
25 #include <hbicon.h> |
25 #include <hbinstance.h> |
26 #include <hbinstance.h> |
26 #include "cpthemeclient_p.h" |
27 #include "cpthemeclient_p.h" |
27 #include "cpthemecommon_p.h" |
28 #include "cpthemecommon_p.h" |
152 (iconThemePath.exists("scalable") || iconThemePath.exists("pixmap") )) { |
155 (iconThemePath.exists("scalable") || iconThemePath.exists("pixmap") )) { |
153 QSettings iniSetting(iconThemePath.path()+"/index.theme",QSettings::IniFormat); |
156 QSettings iniSetting(iconThemePath.path()+"/index.theme",QSettings::IniFormat); |
154 iniSetting.beginGroup("Icon Theme"); |
157 iniSetting.beginGroup("Icon Theme"); |
155 QString hidden = iniSetting.value("Hidden").toString(); |
158 QString hidden = iniSetting.value("Hidden").toString(); |
156 QString name = iniSetting.value("Name").toString(); |
159 QString name = iniSetting.value("Name").toString(); |
157 QString iconPath = iniSetting.value("PreviewIconPath").toString(); |
160 QString iconPath = iniSetting.value("PreviewThumbnailPath").toString(); |
|
161 QString previewPathPrt = iniSetting.value("PreviewIconPath_prt").toString(); |
|
162 QString previewPathLsc = iniSetting.value("PreviewIconPath_lsc").toString(); |
158 if (name.isEmpty()) { |
163 if (name.isEmpty()) { |
159 continue; |
164 continue; |
160 } |
165 } |
161 if (!KDefaultPreviewAvailable && iconPath.isEmpty()) |
166 |
162 { |
|
163 continue; |
|
164 } |
|
165 QString fullPathToIcon(iconThemePath.path() + iconPath); |
167 QString fullPathToIcon(iconThemePath.path() + iconPath); |
166 // Don't treat this as a theme unless it's got a preview. |
168 |
167 if (!QFileInfo(fullPathToIcon).exists() && !KDefaultPreviewAvailable) { |
169 if(iconPath.isEmpty()|| !QFileInfo(fullPathToIcon).exists()){ |
168 continue; |
|
169 } |
|
170 if(iconPath.isEmpty()){ |
|
171 |
170 |
172 //if no preview graphics path specified,look for the background graphic. |
|
173 //first look in /scalable folder. if not there, look in pixmap folder. |
|
174 |
|
175 //Set thumbnail |
171 //Set thumbnail |
176 if(QFileInfo(fullPathToIcon + "/scalable/qtg_graf_theme_preview_thumbnail.svg").exists()){ |
172 if(QFileInfo(fullPathToIcon + "/scalable/qtg_graf_theme_preview_thumbnail.svg").exists()){ |
177 nameIconPair.icon = HbIcon(fullPathToIcon + "/scalable/qtg_graf_theme_preview_thumbnail.svg"); |
173 nameIconPair.icon = HbIcon(fullPathToIcon + "/scalable/qtg_graf_theme_preview_thumbnail.svg"); |
178 }else if(QFileInfo(fullPathToIcon + "/scalable/qtg_graf_screen_bg_prt.svg").exists()){ |
174 }else if(QFileInfo(fullPathToIcon + "/scalable/qtg_graf_screen_bg_prt.svg").exists()){ |
179 nameIconPair.icon = HbIcon(fullPathToIcon + "/scalable/qtg_graf_screen_bg_prt.svg"); |
175 QPixmap px(fullPathToIcon + "/scalable/qtg_graf_screen_bg_prt.svg"); |
180 qreal width = nameIconPair.icon.width(); |
176 QIcon scaledIcon(px.scaled(QSize(64, 64))); |
181 nameIconPair.icon.setHeight(width); |
177 nameIconPair.icon = HbIcon(scaledIcon); |
|
178 nameIconPair.icon.setIconName(fullPathToIcon + "/scalable/qtg_graf_screen_bg_prt.svg"); |
|
179 |
182 } else if(QFileInfo(fullPathToIcon + "/pixmap/qtg_graf_screen_bg_prt.png").exists()){ |
180 } else if(QFileInfo(fullPathToIcon + "/pixmap/qtg_graf_screen_bg_prt.png").exists()){ |
183 nameIconPair.icon = HbIcon(fullPathToIcon + "/pixmap/qtg_graf_screen_bg_prt.png"); |
181 QPixmap px(fullPathToIcon + "/pixmap/qtg_graf_screen_bg_prt.png"); |
184 qreal width = nameIconPair.icon.width(); |
182 QIcon scaledIcon(px.scaled(QSize(64, 64))); |
185 nameIconPair.icon.setHeight(width); |
183 nameIconPair.icon = HbIcon(scaledIcon); |
|
184 nameIconPair.icon.setIconName(fullPathToIcon + "/scalable/qtg_graf_screen_bg_prt.png"); |
|
185 |
186 } else{ |
186 } else{ |
187 nameIconPair.icon = HbIcon(":/image/themePreview.svg"); |
187 nameIconPair.icon = HbIcon(":/image/themePreview.svg"); |
188 } |
188 } |
189 } else { |
189 } else { |
190 nameIconPair.icon = HbIcon(fullPathToIcon); |
190 nameIconPair.icon = HbIcon(fullPathToIcon); |
191 } |
191 } |
192 |
192 |
193 //set portrait preview |
193 //Portrait preview |
194 if(QFileInfo(fullPathToIcon + "/scalable/qtg_graf_theme_preview_prt.svg").exists()){ |
194 QString fullPathToPreviewPrt = (iconThemePath.path() + previewPathPrt ); |
195 nameIconPair.portraitPreviewIcon = HbIcon(fullPathToIcon + "/scalable/qtg_graf_theme_preview_prt.svg"); |
195 |
196 }else if(QFileInfo(fullPathToIcon + "/scalable/qtg_graf_screen_bg_prt.svg").exists()){ |
196 if(previewPathPrt.isEmpty() || !QFileInfo(fullPathToPreviewPrt).exists()) { |
197 nameIconPair.portraitPreviewIcon = HbIcon(fullPathToIcon + "/scalable/qtg_graf_screen_bg_prt.svg"); |
197 |
198 } else if(QFileInfo(fullPathToIcon + "/pixmap/qtg_graf_screen_bg_prt.png").exists()){ |
198 if(QFileInfo(fullPathToPreviewPrt + "/scalable/qtg_graf_theme_preview_prt.svg").exists()){ |
199 nameIconPair.portraitPreviewIcon = HbIcon(fullPathToIcon + "/pixmap/qtg_graf_screen_bg_prt.png"); |
199 nameIconPair.portraitPreviewIcon = HbIcon(fullPathToPreviewPrt + "/scalable/qtg_graf_theme_preview_prt.svg"); |
200 } else{ |
200 }else if(QFileInfo(fullPathToPreviewPrt + "/scalable/qtg_graf_screen_bg_prt.svg").exists()){ |
201 nameIconPair.portraitPreviewIcon = HbIcon(":/image/themePreview.svg"); |
201 nameIconPair.portraitPreviewIcon = HbIcon(fullPathToPreviewPrt + "/scalable/qtg_graf_screen_bg_prt.svg"); |
202 } |
202 } else if(QFileInfo(fullPathToPreviewPrt + "/pixmap/qtg_graf_screen_bg_prt.png").exists()){ |
203 |
203 nameIconPair.portraitPreviewIcon = HbIcon(fullPathToPreviewPrt + "/pixmap/qtg_graf_screen_bg_prt.png"); |
204 //set landscape preview |
204 } else{ |
205 if(QFileInfo(fullPathToIcon + "/scalable/qtg_graf_theme_preview_lsc.svg").exists()){ |
205 nameIconPair.portraitPreviewIcon = HbIcon(":/image/themePreview.svg"); |
206 nameIconPair.landscapePreviewIcon = HbIcon(fullPathToIcon + "/scalable/qtg_graf_theme_preview_lsc.svg"); |
206 } |
207 }else if(QFileInfo(fullPathToIcon + "/scalable/qtg_graf_screen_bg_lsc.svg").exists()){ |
207 } |
208 nameIconPair.landscapePreviewIcon = HbIcon(fullPathToIcon + "/scalable/qtg_graf_screen_bg_lsc.svg"); |
208 else { |
209 } else if(QFileInfo(fullPathToIcon + "/pixmap/qtg_graf_screen_bg_lsc.png").exists()){ |
209 nameIconPair.portraitPreviewIcon = HbIcon(fullPathToPreviewPrt); |
210 nameIconPair.landscapePreviewIcon = HbIcon(fullPathToIcon + "/pixmap/qtg_graf_screen_bg_lsc.png"); |
210 } |
211 } else{ |
211 |
212 nameIconPair.landscapePreviewIcon = HbIcon(":/image/themePreview.svg"); |
212 //Landscape preview |
|
213 QString fullPathToPreviewLsc = (iconThemePath.path() + previewPathLsc ); |
|
214 |
|
215 if(previewPathLsc.isEmpty() || !QFileInfo(fullPathToPreviewLsc).exists()) { |
|
216 |
|
217 if(QFileInfo(fullPathToPreviewLsc + "/scalable/qtg_graf_theme_preview_lsc.svg").exists()){ |
|
218 nameIconPair.landscapePreviewIcon = HbIcon(fullPathToPreviewLsc + "/scalable/qtg_graf_theme_preview_lsc.svg"); |
|
219 }else if(QFileInfo(fullPathToPreviewLsc + "/scalable/qtg_graf_screen_bg_lsc.svg").exists()){ |
|
220 nameIconPair.landscapePreviewIcon = HbIcon(fullPathToPreviewLsc + "/scalable/qtg_graf_screen_bg_lsc.svg"); |
|
221 } else if(QFileInfo(fullPathToPreviewLsc + "/pixmap/qtg_graf_screen_bg_lsc.png").exists()){ |
|
222 nameIconPair.landscapePreviewIcon = HbIcon(fullPathToPreviewLsc + "/pixmap/qtg_graf_screen_bg_lsc.png"); |
|
223 } else{ |
|
224 nameIconPair.landscapePreviewIcon = HbIcon(":/image/themePreview.svg"); |
|
225 } |
|
226 } |
|
227 else { |
|
228 nameIconPair.landscapePreviewIcon = HbIcon(fullPathToPreviewLsc); |
213 } |
229 } |
214 |
230 |
215 nameIconPair.name = name; |
231 nameIconPair.name = name; |
216 |
232 |
217 themeList.append(nameIconPair); |
233 themeList.append(nameIconPair); |