Пример #1
0
void WStatusLight::setup(QDomNode node, const SkinContext& context) {
    // Number of states. Add one to account for the background.
    setNoPos(context.selectInt(node, "NumberPos") + 1);

    // Set pixmaps
    for (int i = 0; i < m_pixmaps.size(); ++i) {
        // Accept either PathStatusLight or PathStatusLight1 for value 1,
        QString nodeName = QString("PathStatusLight%1").arg(i);
        if (context.hasNode(node, nodeName)) {
            QString mode = context.selectAttributeString(
                context.selectElement(node, nodeName), "sizemode", "FIXED");
            setPixmap(i, context.getSkinPath(context.selectString(node, nodeName)),
                                             SizeModeFromString(mode));
        } else if (i == 0 && context.hasNode(node, "PathBack")) {
            QString mode = context.selectAttributeString(
                context.selectElement(node, "PathBack"), "sizemode", "FIXED");
            setPixmap(i, context.getSkinPath(context.selectString(node, "PathBack")),
                                             SizeModeFromString(mode));
        } else if (i == 1 && context.hasNode(node, "PathStatusLight")) {
            QString mode = context.selectAttributeString(
                context.selectElement(node, "PathStatusLight"), "sizemode", "FIXED");
            setPixmap(i, context.getSkinPath(context.selectString(node, "PathStatusLight")),
                                             SizeModeFromString(mode));
        } else {
            m_pixmaps[i].clear();
        }
    }
}
Пример #2
0
void WKnobComposed::setup(QDomNode node, const SkinContext& context) {
    clear();

    // Set background pixmap if available
    if (context.hasNode(node, "BackPath")) {
        QString mode_str = context.selectAttributeString(
                context.selectElement(node, "BackPath"), "scalemode", "TILE");
        setPixmapBackground(context.getPixmapPath(context.selectNode(node, "BackPath")),
                            Paintable::DrawModeFromString(mode_str));
    }

    // Set background pixmap if available
    if (context.hasNode(node, "Knob")) {
        setPixmapKnob(context.getPixmapPath(context.selectNode(node, "Knob")));
    }

    if (context.hasNode(node, "MinAngle")) {
        m_dMinAngle = context.selectDouble(node, "MinAngle");
    }

    if (context.hasNode(node, "MaxAngle")) {
        m_dMaxAngle = context.selectDouble(node, "MaxAngle");
    }
}
Пример #3
0
void WPushButton::setup(QDomNode node, const SkinContext& context) {
    // Number of states
    int iNumStates = context.selectInt(node, "NumberStates");
    setStates(iNumStates);

    // Set background pixmap if available
    if (context.hasNode(node, "BackPath")) {
        QString mode_str = context.selectAttributeString(
                context.selectElement(node, "BackPath"), "scalemode", "TILE");
        setPixmapBackground(context.getSkinPath(context.selectString(node, "BackPath")),
                            Paintable::DrawModeFromString(mode_str));
    }

    // Load pixmaps for associated states
    QDomNode state = context.selectNode(node, "State");
    while (!state.isNull()) {
        if (state.isElement() && state.nodeName() == "State") {
            int iState = context.selectInt(state, "Number");
            if (iState < m_iNoStates) {
                if (context.hasNode(state, "Pressed")) {
                    setPixmap(iState, true,
                              context.getSkinPath(context.selectString(state, "Pressed")));
                }
                if (context.hasNode(state, "Unpressed")) {
                    setPixmap(iState, false,
                              context.getSkinPath(context.selectString(state, "Unpressed")));
                }
                m_text.replace(iState, context.selectString(state, "Text"));
            }
        }
        state = state.nextSibling();
    }

    ControlParameterWidgetConnection* leftConnection = NULL;
    if (m_leftConnections.isEmpty()) {
        if (!m_connections.isEmpty()) {
            // If no left connection is set, the this is the left connection
            leftConnection = m_connections.at(0);
        }
    } else {
        leftConnection = m_leftConnections.at(0);
    }

    if (leftConnection) {
        bool leftClickForcePush = context.selectBool(node, "LeftClickIsPushButton", false);
        m_leftButtonMode = ControlPushButton::PUSH;
        if (!leftClickForcePush) {
            const ConfigKey& configKey = leftConnection->getKey();
            ControlPushButton* p = dynamic_cast<ControlPushButton*>(
                    ControlObject::getControl(configKey));
            if (p) {
                m_leftButtonMode = p->getButtonMode();
            }
        }
        if (leftConnection->getEmitOption() &
                ControlParameterWidgetConnection::EMIT_DEFAULT) {
            switch (m_leftButtonMode) {
                case ControlPushButton::PUSH:
                case ControlPushButton::LONGPRESSLATCHING:
                case ControlPushButton::POWERWINDOW:
                    leftConnection->setEmitOption(
                            ControlParameterWidgetConnection::EMIT_ON_PRESS_AND_RELEASE);
                    break;
                default:
                    leftConnection->setEmitOption(
                            ControlParameterWidgetConnection::EMIT_ON_PRESS);
                    break;
            }
        }
        if (leftConnection->getDirectionOption() &
                        ControlParameterWidgetConnection::DIR_DEFAULT) {
            if (m_pDisplayConnection == leftConnection) {
                leftConnection->setDirectionOption(ControlParameterWidgetConnection::DIR_FROM_AND_TO_WIDGET);
            } else {
                leftConnection->setDirectionOption(ControlParameterWidgetConnection::DIR_FROM_WIDGET);
                if (m_pDisplayConnection->getDirectionOption() &
                        ControlParameterWidgetConnection::DIR_DEFAULT) {
                    m_pDisplayConnection->setDirectionOption(ControlParameterWidgetConnection::DIR_TO_WIDGET);
                }
            }
        }
    }

    if (!m_rightConnections.isEmpty()) {
        ControlParameterWidgetConnection* rightConnection = m_rightConnections.at(0);
        bool rightClickForcePush = context.selectBool(node, "RightClickIsPushButton", false);
        m_rightButtonMode = ControlPushButton::PUSH;
        if (!rightClickForcePush) {
            const ConfigKey configKey = rightConnection->getKey();
            ControlPushButton* p = dynamic_cast<ControlPushButton*>(
                    ControlObject::getControl(configKey));
            if (p) {
                m_rightButtonMode = p->getButtonMode();
                if (m_rightButtonMode != ControlPushButton::PUSH) {
                    qWarning()
                            << "WPushButton::setup: Connecting a Pushbutton not in PUSH mode is not implemented\n"
                            << "Please set <RightClickIsPushButton>true</RightClickIsPushButton>";
                }
            }
        }
        if (rightConnection->getEmitOption() &
                ControlParameterWidgetConnection::EMIT_DEFAULT) {
            switch (m_rightButtonMode) {
                case ControlPushButton::PUSH:
                case ControlPushButton::LONGPRESSLATCHING:
                case ControlPushButton::POWERWINDOW:
                    leftConnection->setEmitOption(
                            ControlParameterWidgetConnection::EMIT_ON_PRESS_AND_RELEASE);
                    break;
                default:
                    leftConnection->setEmitOption(
                            ControlParameterWidgetConnection::EMIT_ON_PRESS);
                    break;
            }
        }
        if (rightConnection->getDirectionOption() &
                        ControlParameterWidgetConnection::DIR_DEFAULT) {
            rightConnection->setDirectionOption(ControlParameterWidgetConnection::DIR_FROM_WIDGET);
        }
    }
}
Пример #4
0
void WBattery::setup(QDomNode node, const SkinContext& context) {
    if (context.hasNode(node, "BackPath")) {
        QString mode_str = context.selectAttributeString(
                context.selectElement(node, "BackPath"), "scalemode", "TILE");
        setPixmap(&m_pPixmapBack,
                  context.getPixmapSource(context.selectNode(node, "BackPath")),
                  Paintable::DrawModeFromString(mode_str));
    }

    if (context.hasNode(node, "PixmapUnknown")) {
        QString mode_str = context.selectAttributeString(
                context.selectElement(node, "PixmapUnknown"), "scalemode", "TILE");
        setPixmap(&m_pPixmapUnknown,
                  context.getPixmapSource(context.selectNode(node, "PixmapUnknown")),
                  Paintable::DrawModeFromString(mode_str));
    }

    if (context.hasNode(node, "PixmapCharged")) {
        QString mode_str = context.selectAttributeString(
                context.selectElement(node, "PixmapCharged"), "scalemode", "TILE");
        setPixmap(&m_pPixmapCharged,
                  context.getPixmapSource(context.selectNode(node, "PixmapCharged")),
                  Paintable::DrawModeFromString(mode_str));
    }

    int numberStates = context.selectInt(node, "NumberStates");
    if (numberStates < 0) {
        numberStates = 0;
    }

    m_chargingPixmaps.resize(numberStates);
    m_dischargingPixmaps.resize(numberStates);

    if (context.hasNode(node, "PixmapsCharging")) {
        // TODO(XXX) inline SVG support via context.getPixmapSource.
        QString chargingPath = context.selectString(node, "PixmapsCharging");
        Paintable::DrawMode mode = Paintable::DrawModeFromString(
                context.selectAttributeString(
                        context.selectElement(node, "PixmapsCharging"),
                        "scalemode", "TILE"));
        for (int i = 0; i < m_chargingPixmaps.size(); ++i) {
            PixmapSource source(chargingPath.arg(i));
            setPixmap(&m_chargingPixmaps[i], source, mode);
        }
    }

    if (context.hasNode(node, "PixmapsDischarging")) {
        // TODO(XXX) inline SVG support via context.getPixmapSource.
        QString dischargingPath = context.selectString(node, "PixmapsDischarging");
        Paintable::DrawMode mode = Paintable::DrawModeFromString(
                context.selectAttributeString(
                        context.selectElement(node, "PixmapsDischarging"),
                        "scalemode", "TILE"));
        for (int i = 0; i < m_dischargingPixmaps.size(); ++i) {
            PixmapSource source(dischargingPath.arg(i));
            setPixmap(&m_dischargingPixmaps[i], source, mode);
        }
    }

    if (m_pBattery) {
        m_pBattery->update();
    }
}