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),
63 QString
Action, QString ActionText,
bool Display)
66 m_showContext(Context),
67 m_currentContext(Current),
68 m_action(std::move(
Action)),
69 m_actionText(std::move(ActionText)),
77 QString
Action,
bool Display)
81 m_showContext(Context),
82 m_currentContext(Current),
83 m_action(std::move(
Action)),
132 const char * TranslationContext,
const QString& KeyBindingContext,
141 for (
auto it = searchpath.cbegin(); !result && it != searchpath.cend(); ++it)
143 QString themefile = *it + Filename;
144 LOG(VB_PLAYBACK, LOG_INFO,
LOC + QString(
"Loading menu %1").
arg(themefile));
145 QFile
file(themefile);
146 if (
file.open(QIODevice::ReadOnly))
165 LOG(VB_FILE, LOG_ERR,
LOC +
"No theme file " + themefile);
172 const char * TranslationContext,
const QString& KeyBindingContext,
197 const int maxInclude = 10;
198 for (QDomNode node =
Root.firstChild(); !node.isNull(); node = node.nextSibling())
200 if (node.isElement())
202 QDomElement element = node.toElement();
203 if (element.tagName() ==
"include")
205 QString include = element.attribute(
"file",
"");
206 if (include.isEmpty())
209 if (IncludeLevel >= maxInclude)
211 LOG(VB_GENERAL, LOG_ERR, QString(
"Maximum include depth (%1) exceeded for %2")
212 .
arg(maxInclude).
arg(include));
220 QDomNode newChild =
menu.GetRoot();
221 newChild =
m_document->importNode(newChild,
true);
222 Root.replaceChild(newChild, node);
226 else if (element.tagName() ==
"menu")
238 bool hasSelected =
false;
239 bool displayed =
false;
240 for (QDomNode node = Node.firstChild(); !node.isNull(); node = node.nextSibling())
242 if (node == Selected)
246 for (QDomNode node = Node.firstChild(); !node.isNull(); node = node.nextSibling())
248 if (node.isElement())
250 QDomElement element = node.toElement();
251 QString text =
Translate(element.attribute(
"text",
""));
252 QString
show = element.attribute(
"show",
"");
256 QString
current = element.attribute(
"current",
"");
258 if ((
current ==
"active") && !hasSelected)
263 if (element.tagName() ==
"menu")
265 if (hasSelected && node == Selected)
270 else if (element.tagName() ==
"item")
272 QString
action = element.attribute(
"action",
"");
276 else if (element.tagName() ==
"itemlist")
278 QString actiongroup = element.attribute(
"actiongroup",
"");
285 if (!Display && displayed)