Skip to content

Commit

Permalink
Merge pull request #5 from ferranpujolcamins/Fix-SetVariable-in-Color…
Browse files Browse the repository at this point in the history
…Schemes

Fix set variable in color schemes
  • Loading branch information
ronso0 authored Jan 15, 2019
2 parents b40f73f + 939f95a commit e1a63f1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 30 deletions.
9 changes: 0 additions & 9 deletions res/skins/Tango/skin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,6 @@
<SetVariable name="PotiMinAngle">-130</SetVariable>
<SetVariable name="PotiMaxAngle">130</SetVariable>

<SetVariable name="SignalColor_1">#5EBAFF</SetVariable>
<SetVariable name="SignalColor_2">#5EBAFF</SetVariable>
<SetVariable name="SignalColor_3">#DF4DF0</SetVariable>
<SetVariable name="SignalColor_4">#DF4DF0</SetVariable>

<SetVariable name="SignalRGBLowColor">#ff2a00</SetVariable>
<SetVariable name="SignalRGBMidColor">#33f600</SetVariable>
<SetVariable name="SignalRGBHighColor">#332acc</SetVariable>

<SetVariable name="PlayedOverlayColor">#99000000</SetVariable>

<!--################################################################
Expand Down
38 changes: 19 additions & 19 deletions src/skin/colorschemeparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,47 +16,47 @@
void ColorSchemeParser::setupLegacyColorSchemes(QDomElement docElem,
UserSettingsPointer pConfig,
QString* pStyle,
const SkinContext& context) {
QDomNode colsch = docElem.namedItem("Schemes");
SkinContext& context) {
QDomNode schemesNode = docElem.namedItem("Schemes");

bool found = false;
bool bSelectedColorSchemeFound = false;

if (!colsch.isNull() && colsch.isElement()) {
QString schname = pConfig->getValueString(ConfigKey("[Config]","Scheme"));
QDomNode sch = colsch.firstChild();
if (!schemesNode.isNull() && schemesNode.isElement()) {
QString selectedSchemeName = pConfig->getValueString(ConfigKey("[Config]","Scheme"));
QDomNode schemeNode = schemesNode.firstChild();

if (schname.isEmpty()) {
// If no scheme stored, accept the first one in the file
found = true;
if (selectedSchemeName.isEmpty()) {
// If no scheme selected, accept the first one in the file
bSelectedColorSchemeFound = true;
}

while (!sch.isNull() && !found) {
QString thisname = XmlParse::selectNodeQString(sch, "Name");
if (thisname == schname) {
found = true;
while (!schemeNode.isNull() && !bSelectedColorSchemeFound) {
QString schemeName = XmlParse::selectNodeQString(schemeNode, "Name");
if (schemeName == selectedSchemeName) {
bSelectedColorSchemeFound = true;
} else {
sch = sch.nextSibling();
schemeNode = schemeNode.nextSibling();
}
}

if (found) {
if (bSelectedColorSchemeFound) {
QSharedPointer<ImgSource> imsrc =
QSharedPointer<ImgSource>(parseFilters(sch.namedItem("Filters")));
QSharedPointer<ImgSource>(parseFilters(schemeNode.namedItem("Filters")));
WPixmapStore::setLoader(imsrc);
WImageStore::setLoader(imsrc);
WSkinColor::setLoader(imsrc);

// ronso0 :: find <SetVariable> nodes, update them.
// This calls SkinContext::updateVariables in skincontext.cpp which
// iterates over all <SetVariable> nodes
m_pContext->updateVariables(context);
context.updateVariables(schemeNode);

if (pStyle) {
*pStyle = LegacySkinParser::getStyleFromNode(sch);
*pStyle = LegacySkinParser::getStyleFromNode(schemeNode);
}
}
}
if (!found) {
if (!bSelectedColorSchemeFound) {
QSharedPointer<ImgSource> imsrc =
QSharedPointer<ImgSource>(new ImgLoader());
WPixmapStore::setLoader(imsrc);
Expand Down
3 changes: 1 addition & 2 deletions src/skin/colorschemeparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ class ColorSchemeParser {
QDomElement docElem,
UserSettingsPointer pConfig,
QString* pStyle,
const SkinContext& context);
SkinContext& context);
private:
static ImgSource* parseFilters(QDomNode filter);
ColorSchemeParser() { }
~ColorSchemeParser() { }
SkinContext* m_pContext;
};

#endif /* COLORSCHEMEPARSER_H */

0 comments on commit e1a63f1

Please sign in to comment.