30 |
30 |
31 /*! |
31 /*! |
32 \class HbCssThemeInterface |
32 \class HbCssThemeInterface |
33 \brief HbCssThemeInterface is an internal class. |
33 \brief HbCssThemeInterface is an internal class. |
34 * |
34 * |
35 */ |
35 */ |
36 |
|
37 |
36 |
38 /*! |
37 /*! |
39 * \fn HbCssThemeInterface::initialise(const QStringList& list,bool loadAllFiles,bool enableBinarySupport =false) |
38 * \fn HbCssThemeInterface::initialise(const QStringList& list,bool loadAllFiles,bool enableBinarySupport =false) |
40 * Function to populate the interface with css files |
39 * Function to populate the interface with css files |
41 * \a list list of css files, priority wise |
40 * \a list list of css files, priority wise |
42 * \a loadAllFiles ,On application launch all files are loaded and on theme change unchanged files are not loaded. |
41 * \a loadAllFiles ,On application launch all files are loaded and on theme change unchanged files are not loaded. |
43 * \a enableBinarySupport optional flag for using the binary functionality |
42 * \a enableBinarySupport optional flag for using the binary functionality |
44 */ |
43 */ |
45 void HbCssThemeInterface::initialise(const QMap<int,QString> & list,bool loadAllFiles, |
44 void HbCssThemeInterface::initialise(const QMap<int, QString> &list, bool loadAllFiles, |
46 bool enableBinarySupport) |
45 bool enableBinarySupport) |
47 { |
46 { |
48 int handle; |
47 int handle; |
49 flushVariableCache(); |
48 flushVariableCache(); |
50 HbLayeredStyleLoader *loader = HbLayeredStyleLoader::getStack(HbLayeredStyleLoader::Concern_Colors); |
49 HbLayeredStyleLoader *loader = |
|
50 HbLayeredStyleLoader::getStack(HbLayeredStyleLoader::Concern_Colors); |
51 |
51 |
52 //first unload the layers, for which the contents are different after theme change |
52 //first unload the layers, for which the contents are different after theme change |
53 if (handles.size() != 0) { |
53 if (handles.size() != 0) { |
54 QMap<int,HbLayeredStyleLoader::LayerPriority>::const_iterator itr; |
54 QMap<int,HbLayeredStyleLoader::LayerPriority>::const_iterator itr; |
55 for (itr = handles.constBegin(); itr != handles.constEnd(); ++itr){ |
55 for (itr = handles.constBegin(); itr != handles.constEnd(); ++itr){ |
56 loader->unload(itr.key(),itr.value()); |
56 loader->unload(itr.key(), itr.value()); |
57 } |
57 } |
58 handles.clear(); |
58 handles.clear(); |
59 } |
59 } |
60 |
60 |
61 QMap<int,QString>::const_iterator i; |
61 QMap<int, QString>::const_iterator i; |
62 for (i = list.constBegin(); i != list.constEnd(); ++i){ |
62 for (i = list.constBegin(); i != list.constEnd(); ++i){ |
|
63 HbLayeredStyleLoader::LayerPriority layerPriority = |
|
64 static_cast<HbLayeredStyleLoader::LayerPriority>(i.key()); |
63 if(loadAllFiles) { |
65 if(loadAllFiles) { |
64 handle =loader->load(i.value(),(HbLayeredStyleLoader::LayerPriority) i.key(),enableBinarySupport); |
66 handle = loader->load(i.value(), layerPriority, enableBinarySupport); |
65 if (((HbLayeredStyleLoader::LayerPriority) i.key() != HbLayeredStyleLoader::Priority_Core) && ((HbLayeredStyleLoader::LayerPriority) i.key() != HbLayeredStyleLoader::Priority_Operator )) { |
67 if (layerPriority != HbLayeredStyleLoader::Priority_Core |
66 handles.insertMulti(handle, (HbLayeredStyleLoader::LayerPriority) i.key()); |
68 && layerPriority != HbLayeredStyleLoader::Priority_Operator) { |
|
69 handles.insertMulti(handle, layerPriority); |
67 } |
70 } |
68 |
71 } else if (layerPriority != HbLayeredStyleLoader::Priority_Core |
|
72 && layerPriority != HbLayeredStyleLoader::Priority_Operator) { |
|
73 handle = loader->load(i.value(), layerPriority, enableBinarySupport); |
|
74 handles.insertMulti(handle, layerPriority); |
69 } |
75 } |
70 else{ |
|
71 if (((HbLayeredStyleLoader::LayerPriority) i.key() != HbLayeredStyleLoader::Priority_Core) && ((HbLayeredStyleLoader::LayerPriority) i.key() != HbLayeredStyleLoader::Priority_Operator )) { |
|
72 handle = loader->load(i.value(),(HbLayeredStyleLoader::LayerPriority) i.key(),enableBinarySupport); |
|
73 handles.insertMulti(handle, (HbLayeredStyleLoader::LayerPriority) i.key()); |
|
74 } |
|
75 |
|
76 } |
|
77 |
|
78 } |
76 } |
79 } |
77 } |
80 |
78 |
81 /*! |
79 /*! |
82 * \fn HbCssThemeInterface::flush() |
80 * \fn HbCssThemeInterface::flush() |
83 * |
81 * |
84 */ |
82 */ |
85 void HbCssThemeInterface::flush() |
83 void HbCssThemeInterface::flush() |
86 { |
84 { |
87 HbLayeredStyleLoader *loader = HbLayeredStyleLoader::getStack(HbLayeredStyleLoader::Concern_Colors); |
85 HbLayeredStyleLoader *loader = |
|
86 HbLayeredStyleLoader::getStack(HbLayeredStyleLoader::Concern_Colors); |
88 loader->clear(); |
87 loader->clear(); |
89 flushVariableCache(); |
88 flushVariableCache(); |
90 } |
89 } |
91 |
90 |
92 void HbCssThemeInterface::flushVariableCache() |
91 void HbCssThemeInterface::flushVariableCache() |
107 { |
106 { |
108 StyleSelector::NodePtr n; |
107 StyleSelector::NodePtr n; |
109 n.ptr = (void *)w; |
108 n.ptr = (void *)w; |
110 HbCss::Value value; |
109 HbCss::Value value; |
111 |
110 |
112 HbLayeredStyleLoader *loader = HbLayeredStyleLoader::getStack(HbLayeredStyleLoader::Concern_Colors); |
111 HbLayeredStyleLoader *loader = |
|
112 HbLayeredStyleLoader::getStack(HbLayeredStyleLoader::Concern_Colors); |
113 HbDeviceProfile profile(HbDeviceProfile::profile(w)); |
113 HbDeviceProfile profile(HbDeviceProfile::profile(w)); |
114 HbCss::ValueExtractor valueExtractor(loader->declarationsForNode(n, profile.orientation()), true); |
114 HbCss::ValueExtractor valueExtractor( |
|
115 loader->declarationsForNode(n, profile.orientation()), true); |
115 valueExtractor.extractValue(attribute, value); |
116 valueExtractor.extractValue(attribute, value); |
116 |
117 |
117 if ( value.type == Value::Variable) { |
118 if ( value.type == Value::Variable) { |
118 value = findVariable ( value.variant.toString ()); |
119 value = findVariable ( value.variant.toString ()); |
119 } |
120 } |