bool VCProperties::loadProperties(const QDomElement& root) { if (root.tagName() != KXMLQLCVCProperties) { qWarning() << Q_FUNC_INFO << "Virtual console properties node not found"; return false; } QString str; QDomNode node = root.firstChild(); while (node.isNull() == false) { QDomElement tag = node.toElement(); if (tag.tagName() == KXMLQLCVCPropertiesGrid) { /* Grid X resolution */ str = tag.attribute(KXMLQLCVCPropertiesGridXResolution); setGridX(str.toInt()); /* Grid Y resolution */ str = tag.attribute(KXMLQLCVCPropertiesGridYResolution); setGridY(str.toInt()); /* Grid enabled */ str = tag.attribute(KXMLQLCVCPropertiesGridEnabled); if (str == KXMLQLCTrue) setGridEnabled(true); else setGridEnabled(false); } else if (tag.tagName() == KXMLQLCVCPropertiesKeyboard) { /* Keyboard grab */ str = tag.attribute(KXMLQLCVCPropertiesKeyboardGrab); if (str == KXMLQLCTrue) setGrabKeyboard(true); else setGrabKeyboard(false); /* Key repeat */ str = tag.attribute(KXMLQLCVCPropertiesKeyboardRepeatOff); if (str == KXMLQLCTrue) setKeyRepeatOff(true); else setKeyRepeatOff(false); } else if (tag.tagName() == KXMLQLCVCPropertiesDefaultSlider) { quint32 low = 0; quint32 high = 10; quint32 universe = InputMap::invalidUniverse(); quint32 channel = InputMap::invalidChannel(); QDomElement subtag; /* Bus low limit */ str = tag.attribute(KXMLQLCVCPropertiesLowLimit); if (str.isEmpty() == false) low = quint32(str.toUInt()); /* Bus high limit */ str = tag.attribute(KXMLQLCVCPropertiesHighLimit); if (str.isEmpty() == false) high = quint32(str.toUInt()); /* Sliders' visibility (on by default) */ str = tag.attribute(KXMLQLCVCPropertiesDefaultSliderVisible); if (str.isEmpty() == false) { if (str == KXMLQLCTrue) setSlidersVisible(true); else setSlidersVisible(false); } /* External input */ bool ok = loadXMLInput(tag.firstChild().toElement(), &universe, &channel); if (tag.attribute(KXMLQLCBusRole) == KXMLQLCBusFade) { setFadeLimits(low, high); if (ok == true) setFadeInputSource(universe, channel); } else { setHoldLimits(low, high); if (ok == true) setHoldInputSource(universe, channel); } } else if (tag.tagName() == KXMLQLCVCPropertiesGrandMaster) { quint32 universe = InputMap::invalidUniverse(); quint32 channel = InputMap::invalidChannel(); str = tag.attribute(KXMLQLCVCPropertiesGrandMasterChannelMode); setGrandMasterChannelMode(UniverseArray::stringToGMChannelMode(str)); str = tag.attribute(KXMLQLCVCPropertiesGrandMasterValueMode); setGrandMasterValueMode(UniverseArray::stringToGMValueMode(str)); /* External input */ if (loadXMLInput(tag.firstChild().toElement(), &universe, &channel) == true) setGrandMasterInputSource(universe, channel); } else if (tag.tagName() == KXMLQLCVCPropertiesBlackout) { /* External input */ quint32 universe = InputMap::invalidUniverse(); quint32 channel = InputMap::invalidChannel(); if (loadXMLInput(tag.firstChild().toElement(), &universe, &channel) == true) setBlackoutInputSource(universe, channel); } else if (tag.tagName() == KXMLQLCWidgetProperties) { VCWidgetProperties::loadXML(tag); } else { qWarning() << Q_FUNC_INFO << "Unknown virtual console property tag:" << tag.tagName(); } /* Next node */ node = node.nextSibling(); } return true; }
bool VCProperties::loadProperties(const QDomElement* root) { QDomElement tag; QDomNode node; QString str; Q_ASSERT(root != NULL); if (root->tagName() != KXMLQLCVCProperties) { qDebug() << "Virtual console properties node not found!"; return false; } node = root->firstChild(); while (node.isNull() == false) { tag = node.toElement(); if (tag.tagName() == KXMLQLCVCPropertiesGrid) { /* Grid X resolution */ str = tag.attribute(KXMLQLCVCPropertiesGridXResolution); setGridX(str.toInt()); /* Grid Y resolution */ str = tag.attribute(KXMLQLCVCPropertiesGridYResolution); setGridY(str.toInt()); /* Grid enabled */ str = tag.attribute(KXMLQLCVCPropertiesGridEnabled); if (str == KXMLQLCTrue) setGridEnabled(true); else setGridEnabled(false); } else if (tag.tagName() == KXMLQLCVCPropertiesKeyboard) { /* Keyboard grab */ str = tag.attribute(KXMLQLCVCPropertiesKeyboardGrab); if (str == KXMLQLCTrue) setGrabKeyboard(true); else setGrabKeyboard(false); /* Key repeat */ str = tag.attribute(KXMLQLCVCPropertiesKeyboardRepeatOff); if (str == KXMLQLCTrue) setKeyRepeatOff(true); else setKeyRepeatOff(false); } else if (tag.tagName() == KXMLQLCVCPropertiesDefaultSlider) { quint32 low = 0; quint32 high = 10; t_input_universe universe = KInputUniverseInvalid; t_input_channel channel = KInputChannelInvalid; QDomElement subtag; /* Bus low limit */ str = tag.attribute(KXMLQLCVCPropertiesLowLimit); if (str.isNull() == false) low = quint32(str.toUInt()); /* Bus high limit */ str = tag.attribute(KXMLQLCVCPropertiesHighLimit); if (str.isNull() == false) high = quint32(str.toUInt()); /* Sliders' visibility (on by default) */ str = tag.attribute(KXMLQLCVCPropertiesDefaultSliderVisible); if (str == KXMLQLCFalse) setSlidersVisible(false); else setSlidersVisible(true); /* External input */ subtag = tag.firstChild().toElement(); if (subtag.isNull() == false && subtag.tagName() == KXMLQLCVCPropertiesInput) { /* Universe */ str = subtag.attribute(KXMLQLCVCPropertiesInputUniverse); if (str.isNull() == false) universe = str.toInt(); /* Channel */ str = subtag.attribute(KXMLQLCVCPropertiesInputChannel); if (str.isNull() == false) channel = str.toInt(); } /* Set the gathered properties to the correct slider */ if (tag.attribute(KXMLQLCBusRole) == KXMLQLCBusFade) { setFadeLimits(low, high); setFadeInputSource(universe, channel); } else { setHoldLimits(low, high); setHoldInputSource(universe, channel); } } else if (tag.tagName() == KXMLQLCWidgetProperties) { QLCWidgetProperties::loadXML(&tag); } else { qDebug() << "Unknown virtual console property tag:" << tag.tagName(); } /* Next node */ node = node.nextSibling(); } return true; }