Exemplo n.º 1
0
bool VCProperties::loadXML(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() == KXMLQLCVCPropertiesSize)
        {
            QSize sz;

            /* Width */
            str = tag.attribute(KXMLQLCVCPropertiesSizeWidth);
            if (str.isEmpty() == false)
                sz.setWidth(str.toInt());

            /* Height */
            str = tag.attribute(KXMLQLCVCPropertiesSizeHeight);
            if (str.isEmpty() == false)
                sz.setHeight(str.toInt());

            /* Set size if both are valid */
            if (sz.isValid() == true)
                setSize(sz);
        }
        else if (tag.tagName() == KXMLQLCVCPropertiesKeyboard)
        {
            /* Tap modifier */
            str = tag.attribute(KXMLQLCVCPropertiesKeyboardTapModifier);
            if (str.isEmpty() == false)
                setTapModifier(Qt::KeyboardModifier(str.toInt()));
        }
        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));

            if (tag.hasAttribute(KXMLQLCVCPropertiesGrandMasterSliderMode))
            {
                str = tag.attribute(KXMLQLCVCPropertiesGrandMasterSliderMode);
                setGrandMasterSliderMode(UniverseArray::stringToGMSliderMode(str));
            }

            /* External input */
            if (loadXMLInput(tag.firstChild().toElement(), &universe, &channel) == true)
                setGrandMasterInputSource(universe, channel);
        }
        else
        {
            qWarning() << Q_FUNC_INFO << "Unknown virtual console property tag:"
                       << tag.tagName();
        }

        /* Next node */
        node = node.nextSibling();
    }

    return true;
}
Exemplo n.º 2
0
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;
}
Exemplo n.º 3
0
bool VirtualConsole::loadPropertiesXML(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();
        /** This is a legacy property, converted into
         *  VCFrame "WindowState" tag */
        if (tag.tagName() == KXMLQLCVCPropertiesSize)
        {
            QSize sz;

            /* Width */
            str = tag.attribute(KXMLQLCVCPropertiesSizeWidth);
            if (str.isEmpty() == false)
                sz.setWidth(str.toInt());

            /* Height */
            str = tag.attribute(KXMLQLCVCPropertiesSizeHeight);
            if (str.isEmpty() == false)
                sz.setHeight(str.toInt());

            /* Set size if both are valid */
            if (sz.isValid() == true)
                m_pages.at(0)->setGeometry(QRect(0, 0, sz.width(), sz.height()));
        }
#if 0
        else if (tag.tagName() == KXMLQLCVCPropertiesGrandMaster)
        {
            quint32 universe = InputOutputMap::invalidUniverse();
            quint32 channel = QLCChannel::invalid();

            str = tag.attribute(KXMLQLCVCPropertiesGrandMasterChannelMode);
            setGrandMasterChannelMode(GrandMaster::stringToChannelMode(str));

            str = tag.attribute(KXMLQLCVCPropertiesGrandMasterValueMode);
            setGrandMasterValueMode(GrandMaster::stringToValueMode(str));

            if (tag.hasAttribute(KXMLQLCVCPropertiesGrandMasterSliderMode))
            {
                str = tag.attribute(KXMLQLCVCPropertiesGrandMasterSliderMode);
                setGrandMasterSliderMode(GrandMaster::stringToSliderMode(str));
            }

            /* External input */
            if (loadXMLInput(tag.firstChild().toElement(), &universe, &channel) == true)
                setGrandMasterInputSource(universe, channel);
        }
#endif
        else
        {
            qWarning() << Q_FUNC_INFO << "Unknown Virtual Console property tag:"
                       << tag.tagName();
        }

        /* Next node */
        node = node.nextSibling();
    }

    return true;
}