|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (developer.feedback@nokia.com) |
|
6 ** |
|
7 ** This file is part of the HbUtils module of the UI Extensions for Mobile. |
|
8 ** |
|
9 ** GNU Lesser General Public License Usage |
|
10 ** This file may be used under the terms of the GNU Lesser General Public |
|
11 ** License version 2.1 as published by the Free Software Foundation and |
|
12 ** appearing in the file LICENSE.LGPL included in the packaging of this file. |
|
13 ** Please review the following information to ensure the GNU Lesser General |
|
14 ** Public License version 2.1 requirements will be met: |
|
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
16 ** |
|
17 ** In addition, as a special exception, Nokia gives you certain additional |
|
18 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
20 ** |
|
21 ** If you have questions regarding the use of this file, please contact |
|
22 ** Nokia at developer.feedback@nokia.com. |
|
23 ** |
|
24 ****************************************************************************/ |
|
25 |
|
26 |
|
27 |
|
28 /*! |
|
29 @proto |
|
30 @hbutils |
|
31 \class HbThemeServices |
|
32 \brief HbThemeServices class is used to set and get current theme. |
|
33 |
|
34 HbThemeServices class has static functions to change and query current theme. |
|
35 */ |
|
36 |
|
37 #include "hbthemeservices_r.h" |
|
38 #include "hbthemeutils_p.h" |
|
39 |
|
40 #ifdef Q_OS_SYMBIAN |
|
41 #include <e32property.h> |
|
42 #include "hbthemecommon_symbian_p.h" |
|
43 #else |
|
44 #include "hbthemeclient_p.h" |
|
45 #endif |
|
46 |
|
47 /*! |
|
48 Sets the active theme that is used with the Hb applications. HbTheme changed() signal will be emitted if theme change is |
|
49 applied succesfully. In addition to the active theme content loading also the underlying priority themes will be updated |
|
50 during the theme change. |
|
51 |
|
52 Depending on the platform setTheme functionality might by restricted. |
|
53 |
|
54 \param themePath, absolute path to the folder where themes index.theme file is located. |
|
55 */ |
|
56 void HbThemeServices::setTheme(const QString &themePath) |
|
57 { |
|
58 #ifdef Q_OS_SYMBIAN |
|
59 RProperty themeRequestProp; |
|
60 |
|
61 User::LeaveIfError( themeRequestProp.Attach( KServerUid3, KNewThemeForThemeChanger ) ); |
|
62 |
|
63 TBuf<256> newThemenameChangeRequest; |
|
64 _LIT(KThemeRequestFormatter, "%d:%S"); |
|
65 TBuf<256> newThemename(themePath.utf16()); |
|
66 newThemenameChangeRequest.Format(KThemeRequestFormatter, EThemeSelection, &newThemename); |
|
67 themeRequestProp.Set(newThemenameChangeRequest); |
|
68 themeRequestProp.Close(); |
|
69 #else |
|
70 HbThemeClient::global()->setTheme(themePath); |
|
71 #endif |
|
72 } |
|
73 |
|
74 /*! |
|
75 Returns the absolute path to the active theme. |
|
76 |
|
77 \return absolute path to the folder where the index.theme file of the active theme is located. |
|
78 */ |
|
79 const QString HbThemeServices::themePath() |
|
80 { |
|
81 QString path(""); |
|
82 HbThemeIndexInfo info = HbThemeUtils::getThemeIndexInfo(ActiveTheme); |
|
83 if (info.address) { |
|
84 path.append(info.path); |
|
85 path.append("/icons/"); |
|
86 path.append(info.name); |
|
87 } |
|
88 return path; |
|
89 } |