6 #include <QCoreApplication>
15 #define LOC QString("ThemeInfo: ")
20 QString themeNoTrailingSlash = theme;
21 if (themeNoTrailingSlash.endsWith(
'/'))
23 themeNoTrailingSlash.chop(1);
25 m_theme = QFileInfo(themeNoTrailingSlash);
45 LOG(VB_GENERAL, LOG_ERR,
LOC +
46 QString(
"The theme (%1) is missing a themeinfo.xml file.")
63 "/themeinfo.xml", &data);
67 if (!doc.setContent(data))
69 LOG(VB_GENERAL, LOG_ERR,
LOC +
70 QString(
"Unable to parse themeinfo.xml for %1")
79 if (!f.open(QIODevice::ReadOnly))
81 LOG(VB_GENERAL, LOG_WARNING,
LOC +
82 QString(
"Unable to open themeinfo.xml for %1")
87 if (!doc.setContent(&f))
89 LOG(VB_GENERAL, LOG_ERR,
LOC +
90 QString(
"Unable to parse themeinfo.xml for %1")
99 QDomElement docElem = doc.documentElement();
101 for (QDomNode n = docElem.firstChild(); !n.isNull();
104 QDomElement e = n.toElement();
107 if (e.tagName() ==
"name")
111 else if (e.tagName() ==
"basetheme")
115 else if (e.tagName() ==
"aspect")
119 else if (e.tagName() ==
"baseres")
122 m_baseres = QSize(size.section(
'x', 0, 0).toInt(),
123 size.section(
'x', 1, 1).toInt());
125 else if (e.tagName() ==
"types")
127 for (QDomNode child = e.firstChild(); !child.isNull();
128 child = child.nextSibling())
130 QDomElement ce = child.toElement();
133 if (ce.tagName() ==
"type")
141 else if (
type ==
"OSD")
145 else if (
type ==
"Menu")
153 "Invalid theme type");
159 else if (e.tagName() ==
"version")
161 for (QDomNode child = e.firstChild(); !child.isNull();
162 child = child.nextSibling())
164 QDomElement ce = child.toElement();
167 if (ce.tagName() ==
"major")
171 else if (ce.tagName() ==
"minor")
178 else if (e.tagName() ==
"author")
180 for (QDomNode child = e.firstChild(); !child.isNull();
181 child = child.nextSibling())
183 QDomElement ce = child.toElement();
186 if (ce.tagName() ==
"name")
190 else if (ce.tagName() ==
"email")
197 else if (e.tagName() ==
"detail")
199 for (QDomNode child = e.firstChild(); !child.isNull();
200 child = child.nextSibling())
202 QDomElement ce = child.toElement();
205 if (ce.tagName() ==
"thumbnail")
207 if (ce.attribute(
"name") ==
"preview")
213 else if (ce.tagName() ==
"description")
218 else if (ce.tagName() ==
"errata")
220 m_errata = QCoreApplication::translate(
"ThemeUI",
226 else if (e.tagName() ==
"downloadinfo")
228 for (QDomNode child = e.firstChild(); !child.isNull();
229 child = child.nextSibling())
231 QDomElement ce = child.toElement();
234 if (ce.tagName() ==
"url")
255 return m_theme.fileName().remove(
"assets:/");
267 infoMap[
"resolution"] = QString(
"%1x%2").arg(
m_baseres.width())
270 infoMap[
"majorversion"] = QString::number(
m_majorver);
271 infoMap[
"minorversion"] = QString::number(
m_minorver);