/** * \brief Copy this widgets state from another. */ void MythUIType::CopyFrom(MythUIType *base) { m_Visible = base->m_Visible; m_Enabled = base->m_Enabled; m_CanHaveFocus = base->m_CanHaveFocus; m_focusOrder = base->m_focusOrder; SetArea(base->m_Area); m_MinArea = base->m_MinArea; m_MinSize = base->m_MinSize; m_Alpha = base->m_Alpha; m_AlphaChangeMode = base->m_AlphaChangeMode; m_AlphaChange = base->m_AlphaChange; m_AlphaMin = base->m_AlphaMin; m_AlphaMax = base->m_AlphaMax; m_Moving = base->m_Moving; m_XYDestination = base->m_XYDestination; m_XYSpeed = base->m_XYSpeed; m_deferload = base->m_deferload; QList<MythUIType *>::Iterator it; for (it = base->m_ChildrenList.begin(); it != base->m_ChildrenList.end(); ++it) { MythUIType *child = GetChild((*it)->objectName()); if (child) child->CopyFrom(*it); else (*it)->CreateCopy(this); } }
MythUIType *XMLParseBase::ParseUIType( const QString &filename, QDomElement &element, const QString &type, MythUIType *parent, MythScreenType *screen, bool showWarnings) { QString name = element.attribute("name", ""); if (name.isEmpty()) { VERBOSE_XML(VB_IMPORTANT, filename, element, LOC_ERR + "This element requires a name"); return NULL; } MythUIType *olduitype = NULL; // check for name in immediate parent as siblings cannot share names if (parent && parent->GetChild(name)) { // if we're the global object store, assume it's just a theme overriding // the defaults.. if (parent == GetGlobalObjectStore()) return NULL; // Reuse the existing child and reparse olduitype = parent->GetChild(name); } MythUIType *uitype = NULL; MythUIType *base = NULL; QString inherits = element.attribute("from", ""); if (!inherits.isEmpty()) { if (parent) base = parent->GetChild(inherits); // might remove this if (screen && !base) base = screen->GetChild(inherits); if (!base) base = GetGlobalObjectStore()->GetChild(inherits); if (!base) { VERBOSE_XML(VB_IMPORTANT, filename, element, LOC_ERR + QString( "Couldn't find object '%1' to inherit '%2' from") .arg(inherits).arg(name)); return NULL; } } if (type == "imagetype") uitype = new MythUIImage(parent, name); else if (type == "textarea") uitype = new MythUIText(parent, name); else if (type == "group") uitype = new MythUIGroup(parent, name); else if (type == "textedit") uitype = new MythUITextEdit(parent, name); else if (type == "button") uitype = new MythUIButton(parent, name); else if (type == "buttonlist2" || type == "buttonlist") uitype = new MythUIButtonList(parent, name); else if (type == "buttontree") uitype = new MythUIButtonTree(parent, name); else if (type == "spinbox") uitype = new MythUISpinBox(parent, name); else if (type == "checkbox") uitype = new MythUICheckBox(parent, name); else if (type == "statetype") uitype = new MythUIStateType(parent, name); else if (type == "clock") uitype = new MythUIClock(parent, name); else if (type == "progressbar") uitype = new MythUIProgressBar(parent, name); else if (type == "webbrowser") uitype = new MythUIWebBrowser(parent, name); else if (type == "guidegrid") uitype = new MythUIGuideGrid(parent, name); else if (type == "shape") uitype = new MythUIShape(parent, name); else if (type == "editbar") uitype = new MythUIEditBar(parent, name); else if (type == "video") uitype = new MythUIVideo(parent, name); else if (type == "window" && parent == GetGlobalObjectStore()) uitype = new MythScreenType(parent, name); else { VERBOSE_XML(VB_IMPORTANT, filename, element, LOC_ERR + "Unknown widget type."); return NULL; } if (!uitype) { VERBOSE_XML(VB_IMPORTANT, filename, element, LOC_ERR + "Failed to instantiate widget type."); return NULL; } if (olduitype) { if (typeid(*olduitype) != typeid(*uitype)) { VERBOSE_XML(VB_IMPORTANT, filename, element, LOC_ERR + QString("Duplicate name: '%1' in parent '%2'") .arg(name).arg(parent->objectName())); parent->DeleteChild(olduitype); } else { parent->DeleteChild(uitype); uitype = olduitype; } } if (base) { if (typeid(*base) != typeid(*uitype)) { VERBOSE_XML(VB_IMPORTANT, filename, element, LOC_ERR + QString("Type of new widget '%1' doesn't " "match old '%2'") .arg(name).arg(inherits)); parent->DeleteChild(uitype); return NULL; } else uitype->CopyFrom(base); } for (QDomNode child = element.firstChild(); !child.isNull(); child = child.nextSibling()) { QDomElement info = child.toElement(); if (!info.isNull()) { if (uitype->ParseElement(filename, info, showWarnings)) { } else if (info.tagName() == "font" || info.tagName() == "fontdef") { bool global = (GetGlobalObjectStore() == parent); MythFontProperties *font = MythFontProperties::ParseFromXml( filename, info, parent, global, showWarnings); if (!global && font) { QString name = info.attribute("name"); uitype->AddFont(name, font); } delete font; } else if (info.tagName() == "imagetype" || info.tagName() == "textarea" || info.tagName() == "group" || info.tagName() == "textedit" || info.tagName() == "button" || info.tagName() == "buttonlist" || info.tagName() == "buttonlist2" || info.tagName() == "buttontree" || info.tagName() == "spinbox" || info.tagName() == "checkbox" || info.tagName() == "statetype" || info.tagName() == "clock" || info.tagName() == "progressbar" || info.tagName() == "webbrowser" || info.tagName() == "guidegrid" || info.tagName() == "shape" || info.tagName() == "editbar" || info.tagName() == "video") { ParseUIType(filename, info, info.tagName(), uitype, screen, showWarnings); } else { VERBOSE_XML(VB_IMPORTANT, filename, info, LOC_ERR + "Unknown widget type."); } } } uitype->Finalize(); return uitype; }