3 #include <QCoreApplication>
12 #define LOC QString("TVMenu: ")
15 const QString& DefaultTextActive,
16 const QString& DefaultTextInactive,
17 bool IsMenu,
const QString& TextArg)
const
29 text = (Active || DefaultTextInactive.isEmpty()) ? DefaultTextActive : DefaultTextInactive;
31 if (!TextArg.isEmpty())
32 text = text.arg(TextArg);
53 m_menuName(std::move(
Name)),
55 m_currentContext(Current),
66 m_showContext(Context),
67 m_currentContext(Current),
68 m_action(std::move(
Action)),
69 m_actionText(std::move(ActionText)),
81 m_showContext(Context),
82 m_currentContext(Current),
83 m_action(std::move(
Action)),
135 while (Node.isElement())
137 QDomElement el = Node.toElement();
138 if (el.tagName() !=
"menu")
140 path.prepend(
"NotMenu");
143 path.prepend(el.attribute(
"text"));
144 Node = Node.parentNode();
146 return path.join(
'/');
151 QStringList pathList = path.split(
'/');
152 if (pathList.isEmpty())
156 QDomElement result =
GetRoot();
157 QString name = pathList.takeFirst();
158 if ((result.tagName() !=
"menu") || (result.attribute(
"text") != name))
162 while (!pathList.isEmpty())
165 name = pathList.takeFirst();
166 auto children = result.childNodes();
167 for (
int i = 0 ; i < children.count(); i++)
169 auto child = children.at(i).toElement();
170 if (child.isNull() ||
171 (name == child.attribute(
"text")) ||
172 (name == child.attribute(
"XXXtext")))
190 const char * TranslationContext,
const QString& KeyBindingContext,
200 for (
auto it = searchpath.cbegin(); !result && it != searchpath.cend(); ++it)
202 QString themefile = *it + Filename;
203 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Loading menu %1").arg(themefile));
204 QFile
file(themefile);
205 if (
file.open(QIODevice::ReadOnly))
224 LOG(VB_FILE, LOG_ERR,
LOC +
"No theme file " + themefile);
231 const char * TranslationContext,
const QString& KeyBindingContext,
257 const int maxInclude = 10;
258 for (QDomNode node =
Root.firstChild(); !node.isNull(); node = node.nextSibling())
260 if (node.isElement())
262 QDomElement element = node.toElement();
263 if (element.tagName() ==
"include")
265 QString include = element.attribute(
"file",
"");
266 if (include.isEmpty())
269 if (IncludeLevel >= maxInclude)
271 LOG(VB_GENERAL, LOG_ERR, QString(
"Maximum include depth (%1) exceeded for %2")
272 .arg(maxInclude).arg(include));
280 QDomNode newChild =
menu.GetRoot();
281 newChild =
m_document->importNode(newChild,
true);
282 Root.replaceChild(newChild, node);
286 else if (element.tagName() ==
"menu")
298 bool hasSelected =
false;
299 bool displayed =
false;
300 for (QDomNode node = Node.firstChild(); !node.isNull(); node = node.nextSibling())
302 if (node == Selected)
306 for (QDomNode node = Node.firstChild(); !node.isNull(); node = node.nextSibling())
308 if (node.isElement())
310 QDomElement element = node.toElement();
311 QString text =
Translate(element.attribute(
"text",
""));
312 QString
show = element.attribute(
"show",
"");
314 if (
show ==
"active")
316 else if (
show ==
"inactive")
318 QString
current = element.attribute(
"current",
"");
320 if ((
current ==
"active") && !hasSelected)
325 if (element.tagName() ==
"menu")
327 if (hasSelected && node == Selected)
332 else if (element.tagName() ==
"item")
334 QString
action = element.attribute(
"action",
"");
338 else if (element.tagName() ==
"itemlist")
340 QString actiongroup = element.attribute(
"actiongroup",
"");
355 m_path(std::move(Path))