示例#1
0
void WSliderComposed::setup(QDomNode node, const SkinContext& context) {
    // Setup pixmaps
    unsetPixmaps();

    if (context.hasNode(node, "Slider")) {
        PixmapSource sourceSlider = context.getPixmapSource(context.selectNode(node, "Slider"));
        setSliderPixmap(sourceSlider);
    }

    PixmapSource sourceHandle = context.getPixmapSource(context.selectNode(node, "Handle"));
    bool h = context.selectBool(node, "Horizontal", false);
    setHandlePixmap(h, sourceHandle);

    if (context.hasNode(node, "EventWhileDrag")) {
        if (context.selectString(node, "EventWhileDrag").contains("no")) {
            m_bEventWhileDrag = false;
        }
    }
    if (!m_connections.isEmpty()) {
        ControlParameterWidgetConnection* defaultConnection = m_connections.at(0);
        if (defaultConnection) {
            if (defaultConnection->getEmitOption() &
                    ControlParameterWidgetConnection::EMIT_DEFAULT) {
                // ON_PRESS means here value change on mouse move during press
                defaultConnection->setEmitOption(
                        ControlParameterWidgetConnection::EMIT_ON_PRESS_AND_RELEASE);
            }
        }
    }
}
示例#2
0
void WBattery::setup(const QDomNode& node, const SkinContext& context) {
    QDomElement backPath = context.selectElement(node, "BackPath");
    if (!backPath.isNull()) {
        setPixmap(&m_pPixmapBack,
                  context.getPixmapSource(backPath),
                  context.selectScaleMode(backPath, Paintable::TILE));
    }

    QDomElement unknownPath = context.selectElement(node, "PixmapUnknown");
    if (!unknownPath.isNull()) {
        setPixmap(&m_pPixmapUnknown,
                  context.getPixmapSource(unknownPath),
                  context.selectScaleMode(unknownPath, Paintable::TILE));
    }

    QDomElement chargedPath = context.selectElement(node, "PixmapCharged");
    if (!chargedPath.isNull()) {
        setPixmap(&m_pPixmapCharged,
                  context.getPixmapSource(chargedPath),
                  context.selectScaleMode(chargedPath, Paintable::TILE));
    }

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

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

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

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

    if (m_pBattery) {
        m_pBattery->update();
    }
}
示例#3
0
void WVuMeter::setup(const QDomNode& node, const SkinContext& context) {
    // Set pixmaps
    bool bHorizontal = false;
    (void)context.hasNodeSelectBool(node, "Horizontal", &bHorizontal);

    // Set background pixmap if available
    QDomElement backPathNode = context.selectElement(node, "PathBack");
    if (!backPathNode.isNull()) {
        // The implicit default in <1.12.0 was FIXED so we keep it for backwards
        // compatibility.
        setPixmapBackground(context.getPixmapSource(backPathNode),
                            context.selectScaleMode(backPathNode, Paintable::FIXED));
    }

    QDomElement vuNode = context.selectElement(node, "PathVu");
    // The implicit default in <1.12.0 was FIXED so we keep it for backwards
    // compatibility.
    setPixmaps(context.getPixmapSource(vuNode), bHorizontal,
               context.selectScaleMode(vuNode, Paintable::FIXED));

    m_iPeakHoldSize = context.selectInt(node, "PeakHoldSize");
    if (m_iPeakHoldSize < 0 || m_iPeakHoldSize > 100) {
        m_iPeakHoldSize = DEFAULT_HOLDSIZE;
    }

    m_iPeakFallStep = context.selectInt(node, "PeakFallStep");
    if (m_iPeakFallStep < 1 || m_iPeakFallStep > 1000) {
        m_iPeakFallStep = DEFAULT_FALLSTEP;
    }

    m_iPeakHoldTime = context.selectInt(node, "PeakHoldTime");
    if (m_iPeakHoldTime < 1 || m_iPeakHoldTime > 3000) {
        m_iPeakHoldTime = DEFAULT_HOLDTIME;
    }

    m_iPeakFallTime = context.selectInt(node, "PeakFallTime");
    if (m_iPeakFallTime < 1 || m_iPeakFallTime > 1000) {
        m_iPeakFallTime = DEFAULT_FALLTIME;
    }
}
示例#4
0
void WStatusLight::setup(const 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);

        QDomElement statusLightNode;
        if (context.hasNodeSelectElement(node, nodeName, &statusLightNode) ||
                (i == 0 && context.hasNodeSelectElement(node, "PathBack", &statusLightNode)) ||
                (i == 1 && context.hasNodeSelectElement(node, "PathStatusLight", &statusLightNode))) {
            setPixmap(i, context.getPixmapSource(statusLightNode),
                      context.selectScaleMode(statusLightNode, Paintable::FIXED));
        } else {
            m_pixmaps[i].clear();
        }
    }
}
示例#5
0
void WDisplay::setup(const QDomNode& node, const SkinContext& context) {
    // Set background pixmap if available

    QDomElement backPathNode = context.selectElement(node, "BackPath");
    if (!backPathNode.isNull()) {
        setPixmapBackground(context.getPixmapSource(backPathNode),
                            context.selectScaleMode(backPathNode, Paintable::TILE));
    }

    // Number of states
    setPositions(context.selectInt(node, "NumberStates"));

    // Load knob pixmaps
    QDomElement pathNode = context.selectElement(node, "Path");
    QString path = context.nodeToString(pathNode);
    // The implicit default in <1.12.0 was FIXED so we keep it for
    // backwards compatibility.
    Paintable::DrawMode pathMode =
            context.selectScaleMode(pathNode, Paintable::FIXED);
    for (int i = 0; i < m_pixmaps.size(); ++i) {
        setPixmap(&m_pixmaps, i, context.getSkinPath(path.arg(i)), pathMode);
    }

    // See if disabled images is defined, and load them...
    QDomElement disabledNode = context.selectElement(node, "DisabledPath");
    if (!disabledNode.isNull()) {
        QString disabledPath = context.nodeToString(disabledNode);
        // The implicit default in <1.12.0 was FIXED so we keep it for
        // backwards compatibility.
        Paintable::DrawMode disabledMode =
            context.selectScaleMode(disabledNode, Paintable::FIXED);
        for (int i = 0; i < m_disabledPixmaps.size(); ++i) {
            setPixmap(&m_disabledPixmaps, i,
                      context.getSkinPath(disabledPath.arg(i)), disabledMode);
        }
        m_bDisabledLoaded = true;
    }
}
示例#6
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();
    }
}