bool MythThemedMenu::findDepends(const QString &fileList) { QStringList files = fileList.split(" "); QString filename; for (QStringList::Iterator it = files.begin(); it != files.end(); ++it ) { QString filename = findMenuFile(*it); if (!filename.isEmpty() && filename.endsWith(".xml")) return true; QString newname = FindPluginName(*it); QFile checkFile(newname); if (checkFile.exists()) return true; } return false; }
bool MythThemedMenu::findDepends(const QString &fileList) { QStringList files = fileList.split(" "); QString filename; MythPluginManager *pluginManager = gCoreContext->GetPluginManager(); for (QStringList::Iterator it = files.begin(); it != files.end(); ++it ) { QString filename = findMenuFile(*it); if (!filename.isEmpty() && filename.endsWith(".xml")) return true; // Has plugin by this name been successfully loaded MythPlugin *plugin = pluginManager->GetPlugin(*it); if (plugin) return true; } return false; }
/** \brief Parse the themebuttons to be added based on the name of * the menu file provided. * * If the menu to be parsed is the main menu and this fails to find the * XML file this will simply return false. Otherwise if it fails to * find the menu it will pop up an error dialog and then return false. * * The idea behind this is that if we can't parse the main menu we * have to exit from the frontend entirely. But in all other cases * we can simply return to the main menu and hope that it is a * non-essential portion of MythTV which the theme does not support. * */ bool MythThemedMenu::parseMenu(const QString &menuname) { QString filename = findMenuFile(menuname); QDomDocument doc; QFile f(filename); if (!f.exists() || !f.open(QIODevice::ReadOnly)) { LOG(VB_GENERAL, LOG_ERR, QString("MythThemedMenu: Couldn't read " "menu file %1").arg(menuname)); if (menuname != "mainmenu.xml") ShowOkPopup(QObject::tr("MythTV could not locate the menu file %1") .arg(menuname)); return false; } QString errorMsg; int errorLine = 0; int errorColumn = 0; if (!doc.setContent(&f, false, &errorMsg, &errorLine, &errorColumn)) { LOG(VB_GENERAL, LOG_ERR, QString("Error parsing: %1\nat line: %2 column: %3 msg: %4"). arg(filename).arg(errorLine).arg(errorColumn).arg(errorMsg)); f.close(); if (menuname != "mainmenu.xml") ShowOkPopup(QObject::tr("The menu file %1 is incomplete.") .arg(menuname)); return false; } f.close(); LOG(VB_GUI, LOG_INFO, QString("Loading menu theme from %1").arg(filename)); QDomElement docElem = doc.documentElement(); m_menumode = docElem.attribute("name", "MAIN"); QDomNode n = docElem.firstChild(); while (!n.isNull()) { QDomElement e = n.toElement(); if (!e.isNull()) { if (e.tagName() == "button") { parseThemeButton(e); } else { LOG(VB_GENERAL, LOG_ERR, QString("MythThemedMenu: Unknown element %1") .arg(e.tagName())); return false; } } n = n.nextSibling(); } if (m_buttonList->GetCount() == 0) { LOG(VB_GENERAL, LOG_ERR, QString("MythThemedMenu: No buttons for menu %1").arg(menuname)); return false; } m_buttonList->SetLCDTitles("MYTH-" + m_menumode); if (m_titleState) { m_titleState->EnsureStateLoaded(m_menumode); m_titleState->DisplayState(m_menumode); } m_selection.clear(); return true; }