Пример #1
0
void WVuMeter::setup(QDomNode node, const SkinContext& context) {
    // Set pixmaps
    bool bHorizontal = context.hasNode(node, "Horizontal") &&
            context.selectString(node, "Horizontal") == "true";

    // Set background pixmap if available
    if (context.hasNode(node, "PathBack")) {
        setPixmapBackground(context.getSkinPath(context.selectString(node, "PathBack")));
    }

    setPixmaps(context.getSkinPath(context.selectString(node, "PathVu")), bHorizontal);

    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;
}
Пример #2
0
WaveformMarkProperties::WaveformMarkProperties(const QDomNode& node,
                                               const SkinContext& context,
                                               const WaveformSignalColors& signalColors) {
    m_color = context.selectString(node, "Color");
    if (!m_color.isValid()) {
        // As a fallback, grab the color from the parent's AxesColor
        m_color = signalColors.getAxesColor();
        qDebug() << "Didn't get mark <Color>, using parent's <AxesColor>:" << m_color;
    } else {
        m_color = WSkinColor::getCorrectColor(m_color);
    }

    m_textColor = context.selectString(node, "TextColor");
    if (!m_textColor.isValid()) {
        // Read the text color, otherwise use the parent's BgColor.
        m_textColor = signalColors.getBgColor();
        qDebug() << "Didn't get mark <TextColor>, using parent's <BgColor>:" << m_textColor;
    }

    QString markAlign = context.selectString(node, "Align");
    m_align = decodeAlignmentFlags(markAlign, Qt::AlignBottom | Qt::AlignHCenter);

    m_text = context.selectString(node, "Text");
    m_pixmapPath = context.selectString(node, "Pixmap");
    if (!m_pixmapPath.isEmpty()) {
        m_pixmapPath = context.getSkinPath(m_pixmapPath);
    }
}
Пример #3
0
void WTime::setTimeFormat(QDomNode node, const SkinContext& context) {
    // if a custom format is defined, all other formatting flags are ignored
    if (!context.hasNode(node, "CustomFormat")) {
        // check if seconds should be shown
        QString secondsFormat = context.selectString(node, "ShowSeconds");
        if(secondsFormat == "true" || secondsFormat == "yes") {
            m_sTimeFormat = "h:mm:ss";
            m_iInterval = s_iSecondInterval;
        } else {
            m_sTimeFormat = "h:mm";
            m_iInterval = s_iMinuteInterval;
        }
        // check if 24 hour format or 12 hour format is selected
        QString clockFormat = context.selectString(node, "ClockFormat");
        if (clockFormat == "24" || clockFormat == "24hrs") {
        } else if (clockFormat == "12" ||
                   clockFormat == "12hrs" ||
                   clockFormat == "12ap") {
            m_sTimeFormat += " ap";
        } else if (clockFormat == "12AP") {
            m_sTimeFormat += " AP";
        } else {
            qDebug() << "WTime: Unknown clock format: " << clockFormat;
        }
    } else {
        // set the time format to the custom format
        m_sTimeFormat = context.selectString(node, "CustomFormat");
    }
}
Пример #4
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();
        }
    }
}
Пример #5
0
void WOverview::setup(QDomNode node, const SkinContext& context) {
    m_signalColors.setup(node, context);

    m_qColorBackground = m_signalColors.getBgColor();

    // Clear the background pixmap, if it exists.
    m_backgroundPixmap = QPixmap();
    m_backgroundPixmapPath = context.selectString(node, "BgPixmap");
    if (m_backgroundPixmapPath != "") {
        m_backgroundPixmap = QPixmap(context.getSkinPath(m_backgroundPixmapPath));
    }

    m_endOfTrackColor = QColor(200, 25, 20);
    const QString endOfTrackColorName = context.selectString(node, "EndOfTrackColor");
    if (!endOfTrackColorName.isNull()) {
        m_endOfTrackColor.setNamedColor(endOfTrackColorName);
        m_endOfTrackColor = WSkinColor::getCorrectColor(m_endOfTrackColor);
    }

    QPalette palette; //Qt4 update according to http://doc.trolltech.com/4.4/qwidget-qt3.html#setBackgroundColor (this could probably be cleaner maybe?)
    palette.setColor(this->backgroundRole(), m_qColorBackground);
    setPalette(palette);

    //setup hotcues and cue and loop(s)
    m_marks.setup(m_group, node, context, m_signalColors);

    for (int i = 0; i < m_marks.size(); ++i) {
        WaveformMark& mark = m_marks[i];
        if (mark.m_pointControl) {
            connect(mark.m_pointControl, SIGNAL(valueChanged(double)),
                    this, SLOT(onMarkChanged(double)));
        }
    }
Пример #6
0
void WaveformMarkRange::setup(const QString& group, const QDomNode& node,
                              const SkinContext& context,
                              const WaveformSignalColors& signalColors) {
    m_activeColor = context.selectString(node, "Color");
    if (m_activeColor == "") {
        //vRince kind of legacy fallback ...
        // As a fallback, grab the mark color from the parent's MarkerColor
        m_activeColor = signalColors.getAxesColor();
        qDebug() << "Didn't get mark Color, using parent's <AxesColor>:" << m_activeColor;
    } else {
        m_activeColor = WSkinColor::getCorrectColor(m_activeColor);
    }

    m_disabledColor = context.selectString(node, "DisabledColor");
    if (m_disabledColor == "") {
        //vRince kind of legacy fallback ...
        // Read the text color, otherwise use the parent's SignalColor.
        m_disabledColor = signalColors.getSignalColor();
        qDebug() << "Didn't get mark TextColor, using parent's <SignalColor>:" << m_disabledColor;
    }

    m_markStartPointControl = new ControlObjectThread(
            group, context.selectString(node, "StartControl"));
    m_markEndPointControl = new ControlObjectThread(
            group, context.selectString(node, "EndControl"));
    m_markEnabledControl = new ControlObjectThread(
            group, context.selectString(node, "EnabledControl"));
}
Пример #7
0
void WDisplay::setup(QDomNode node, const SkinContext& context) {
    // Set background pixmap if available
    if (context.hasNode(node, "BackPath")) {
        setPixmapBackground(context.getSkinPath(
            context.selectString(node, "BackPath")));
    }

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


    // Load knob pixmaps
    QString path = context.selectString(node, "Path");
    for (int i = 0; i < m_pixmaps.size(); ++i) {
        setPixmap(&m_pixmaps, i, context.getSkinPath(path.arg(i)));
    }

    // See if disabled images is defined, and load them...
    if (context.hasNode(node, "DisabledPath")) {
        QString disabledPath = context.selectString(node, "DisabledPath");
        for (int i = 0; i < m_disabledPixmaps.size(); ++i) {
            setPixmap(&m_disabledPixmaps, i,
                      context.getSkinPath(disabledPath.arg(i)));
        }
        m_bDisabledLoaded = true;
    }
}
Пример #8
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);
            }
        }
    }
}
Пример #9
0
void WWidgetGroup::setup(QDomNode node, const SkinContext& context) {
    setContentsMargins(0, 0, 0, 0);

    // Set background pixmap if available
    if (context.hasNode(node, "BackPath")) {
        setPixmapBackground(context.getSkinPath(context.selectString(node, "BackPath")));
    }

    QLayout* pLayout = NULL;
    if (context.hasNode(node, "Layout")) {
        QString layout = context.selectString(node, "Layout");
        if (layout == "vertical") {
            pLayout = new QVBoxLayout();
            pLayout->setSpacing(0);
            pLayout->setContentsMargins(0, 0, 0, 0);
            pLayout->setAlignment(Qt::AlignCenter);
        } else if (layout == "horizontal") {
            pLayout = new QHBoxLayout();
            pLayout->setSpacing(0);
            pLayout->setContentsMargins(0, 0, 0, 0);
            pLayout->setAlignment(Qt::AlignCenter);
        }
    }

    if (pLayout && context.hasNode(node, "SizeConstraint")) {
        QMap<QString, QLayout::SizeConstraint> constraints;
        constraints["SetDefaultConstraint"] = QLayout::SetDefaultConstraint;
        constraints["SetFixedSize"] = QLayout::SetFixedSize;
        constraints["SetMinimumSize"] = QLayout::SetMinimumSize;
        constraints["SetMaximumSize"] = QLayout::SetMaximumSize;
        constraints["SetMinAndMaxSize"] = QLayout::SetMinAndMaxSize;
        constraints["SetNoConstraint"] = QLayout::SetNoConstraint;

        QString sizeConstraintStr = context.selectString(node, "SizeConstraint");
        if (constraints.contains(sizeConstraintStr)) {
            pLayout->setSizeConstraint(constraints[sizeConstraintStr]);
        } else {
            qDebug() << "Could not parse SizeConstraint:" << sizeConstraintStr;
        }
    }

    if (pLayout) {
        setLayout(pLayout);
    }
}
Пример #10
0
void WLabel::setup(QDomNode node, const SkinContext& context) {
    // Colors
    QPalette pal = palette(); //we have to copy out the palette to edit it since it's const (probably for threadsafety)
    if (context.hasNode(node, "BgColor")) {
        m_qBgColor.setNamedColor(context.selectString(node, "BgColor"));
        pal.setColor(this->backgroundRole(), WSkinColor::getCorrectColor(m_qBgColor));
        setAutoFillBackground(true);
    }
    m_qFgColor.setNamedColor(context.selectString(node, "FgColor"));
    pal.setColor(this->foregroundRole(), WSkinColor::getCorrectColor(m_qFgColor));
    setPalette(pal);

    // Text
    if (context.hasNode(node, "Text"))
        m_qsText = context.selectString(node, "Text");
    setText(m_qsText);

    // Font size
    if (context.hasNode(node, "FontSize")) {
        int fontsize = 9;
        fontsize = context.selectString(node, "FontSize").toInt();
        setFont( QFont("Helvetica",fontsize,QFont::Normal) );
    }

    // Alignment
    if (context.hasNode(node, "Alignment")) {
        if (context.selectString(node, "Alignment") == "right") {
            setAlignment(Qt::AlignRight | Qt::AlignVCenter);
        } else if (context.selectString(node, "Alignment") == "center") {
            setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
        } else if (context.selectString(node, "Alignment") == "left") {
            setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
        }
    }
}
Пример #11
0
void WaveformRendererEndOfTrack::setup(const QDomNode& node, const SkinContext& context) {
    m_color = QColor(200, 25, 20);
    const QString endOfTrackColorName = context.selectString(node, "EndOfTrackColor");
    if (!endOfTrackColorName.isNull()) {
        m_color.setNamedColor(endOfTrackColorName);
        m_color = WSkinColor::getCorrectColor(m_color);
    }
    m_pen = QPen(QBrush(m_color), 2.5);
}
Пример #12
0
WaveformMarkRange::WaveformMarkRange(
        const QString& group,
        const QDomNode& node,
        const SkinContext& context,
        const WaveformSignalColors& signalColors)
        : m_activeColor(context.selectString(node, "Color")),
          m_disabledColor(context.selectString(node, "DisabledColor")),
          m_durationTextColor(context.selectString(node, "DurationTextColor")) {
    if (!m_activeColor.isValid()) {
        //vRince kind of legacy fallback ...
        // As a fallback, grab the mark color from the parent's MarkerColor
        m_activeColor = signalColors.getAxesColor();
        qDebug() << "Didn't get mark Color, using parent's <AxesColor>:" << m_activeColor;
    } else {
        m_activeColor = WSkinColor::getCorrectColor(m_activeColor);
    }

    if (!m_disabledColor.isValid()) {
        //vRince kind of legacy fallback ...
        // Read the text color, otherwise use the parent's SignalColor.
        m_disabledColor = signalColors.getSignalColor();
        qDebug() << "Didn't get mark TextColor, using parent's <SignalColor>:" << m_disabledColor;
    }

    QString startControl = context.selectString(node, "StartControl");
    if (!startControl.isEmpty()) {
        DEBUG_ASSERT(!m_markStartPointControl); // has not been created yet
        m_markStartPointControl = std::make_unique<ControlProxy>(group, startControl);
    }
    QString endControl = context.selectString(node, "EndControl");
    if (!endControl.isEmpty()) {
        DEBUG_ASSERT(!m_markEndPointControl); // has not been created yet
        m_markEndPointControl = std::make_unique<ControlProxy>(group, endControl);
    }
    QString enabledControl = context.selectString(node, "EnabledControl");
    if (!enabledControl.isEmpty()) {
        DEBUG_ASSERT(!m_markEnabledControl); // has not been created yet
        m_markEnabledControl = std::make_unique<ControlProxy>(group, enabledControl);
    }
    QString visibilityControl = context.selectString(node, "VisibilityControl");
    if (!visibilityControl.isEmpty()) {
        DEBUG_ASSERT(!m_markVisibleControl); // has not been created yet
        ConfigKey key = ConfigKey::parseCommaSeparated(visibilityControl);
        m_markVisibleControl = std::make_unique<ControlProxy>(key);
    }

    QString durationTextLocation = context.selectString(node, "DurationTextLocation");
    if (durationTextLocation == "before") {
        m_durationTextLocation = DurationTextLocation::Before;
    } else {
        m_durationTextLocation = DurationTextLocation::After;
    }
}
Пример #13
0
void WSearchLineEdit::setup(QDomNode node, const SkinContext& context) {
    // Background color
    QColor bgc(255,255,255);
    if (context.hasNode(node, "BgColor")) {
        bgc.setNamedColor(context.selectString(node, "BgColor"));
        setAutoFillBackground(true);
    }
    QPalette pal = palette();
    pal.setBrush(backgroundRole(), WSkinColor::getCorrectColor(bgc));

    // Foreground color
    m_fgc = QColor(0,0,0);
    if (context.hasNode(node, "FgColor")) {
        m_fgc.setNamedColor(context.selectString(node, "FgColor"));
    }
    bgc = WSkinColor::getCorrectColor(bgc);
    m_fgc = QColor(255 - bgc.red(), 255 - bgc.green(), 255 - bgc.blue());
    pal.setBrush(foregroundRole(), m_fgc);
    setPalette(pal);
}
Пример #14
0
void WSplitter::setup(QDomNode node, const SkinContext& context) {
    // Default orientation is horizontal.
    if (context.hasNode(node, "Orientation")) {
        QString layout = context.selectString(node, "Orientation");
        if (layout == "vertical") {
            setOrientation(Qt::Vertical);
        } else if (layout == "horizontal") {
            setOrientation(Qt::Horizontal);
        }
    }
}
Пример #15
0
void WTime::setTimeFormat(QDomNode node, const SkinContext& context) {
    // if a custom format is defined, all other formatting flags are ignored
    if (!context.hasNode(node, "CustomFormat")) {
        // check if seconds should be shown
        QString secondsFormat = context.selectString(node, "ShowSeconds");
        // long format is equivalent to showing seconds
        QLocale::FormatType format;
        if(secondsFormat == "true" || secondsFormat == "yes") {
            format = QLocale::LongFormat;
            m_iInterval = s_iSecondInterval;
        } else {
            format = QLocale::ShortFormat;
            m_iInterval = s_iMinuteInterval;
        }
        m_sTimeFormat = QLocale().timeFormat(format);
    } else {
        // set the time format to the custom format
        m_sTimeFormat = context.selectString(node, "CustomFormat");
    }
}
Пример #16
0
void WKnobComposed::setup(QDomNode node, const SkinContext& context) {
    clear();

    // Set background pixmap if available
    if (context.hasNode(node, "BackPath")) {
        setPixmapBackground(context.getSkinPath(context.selectString(node, "BackPath")));
    }

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

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

    if (context.hasNode(node, "MaxAngle")) {
        m_dMaxAngle = context.selectDouble(node, "MaxAngle");
    }
}
Пример #17
0
void WaveformRendererRGB::setup(const QDomNode& node,
                                       const SkinContext& context) {
    WaveformRendererSignalBase::setup(node, context);

    m_lowColor.setNamedColor(context.selectString(node, "SignalLowColor"));
    if (!m_lowColor.isValid()) {
        m_lowColor.setRgb(255,0,0);
    }
    m_lowColor  = WSkinColor::getCorrectColor(m_lowColor);

    m_midColor.setNamedColor(context.selectString(node, "SignalMidColor"));
    if (!m_midColor.isValid()) {
        m_midColor.setRgb(0,255,0);
    }
    m_midColor  = WSkinColor::getCorrectColor(m_midColor);

    m_highColor.setNamedColor(context.selectString(node, "SignalHighColor"));
    if (!m_highColor.isValid()) {
        m_highColor.setRgb(0,0,255);
    }
    m_highColor = WSkinColor::getCorrectColor(m_highColor);
}
Пример #18
0
bool WaveformSignalColors::setup(const QDomNode &node, const SkinContext& context)
{
/*
    QString string;
    QTextStream textStr(&string);
    node.save(textStr,4);
    qDebug() << string;
*/

    m_signalColor.setNamedColor(context.selectString(node, "SignalColor"));
    m_signalColor = WSkinColor::getCorrectColor(m_signalColor);

    m_lowColor.setNamedColor(context.selectString(node, "SignalLowColor"));
    m_lowColor = WSkinColor::getCorrectColor(m_lowColor);

    m_midColor.setNamedColor(context.selectString(node, "SignalMidColor"));
    m_midColor = WSkinColor::getCorrectColor(m_midColor);

    m_highColor.setNamedColor(context.selectString(node, "SignalHighColor"));
    m_highColor = WSkinColor::getCorrectColor(m_highColor);

    m_axesColor.setNamedColor(context.selectString(node, "AxesColor"));
    if (!m_axesColor.isValid()) {
        m_axesColor = QColor(245,245,245);
    }
    m_axesColor = WSkinColor::getCorrectColor(m_axesColor);

    m_playPosColor.setNamedColor(context.selectString(node, "PlayPosColor"));
    m_playPosColor = WSkinColor::getCorrectColor(m_playPosColor);
    if (!m_playPosColor.isValid()) {
        m_playPosColor = m_axesColor;
    }

    m_bgColor.setNamedColor(context.selectString(node, "BgColor"));
    if (!m_bgColor.isValid()) {
        m_bgColor = QColor(0, 0, 0);
    }
    m_bgColor = WSkinColor::getCorrectColor(m_bgColor);

    bool filteredColorValid = m_lowColor.isValid() && m_midColor.isValid() && m_highColor.isValid();

    if (m_signalColor.isValid() && filteredColorValid) {
        return true; //default
    }

    if (m_signalColor.isValid() && !filteredColorValid) {
        fallBackFromSignalColor(); //pre waveform-2.0 skins
        return false;
    }

    fallBackDefaultColor();
    return false;
}
Пример #19
0
WaveformMark::WaveformMark( const QString& group,
                            const QDomNode& node,
                            const SkinContext& context,
                            const WaveformSignalColors& signalColors,
                            int hotCue,
                            QString item)
    : m_iHotCue(hotCue) {
    if(item.isEmpty())
        item = context.selectString(node, "Control");
    if (!item.isEmpty()) {
        m_pPointCos = std::make_unique<ControlProxy>(group, item);
    }
    m_properties = WaveformMarkProperties(node, context, signalColors);
}
Пример #20
0
WaveformMark::WaveformMark(const QString& group,
                           const QDomNode& node,
                           const SkinContext& context,
                           const WaveformSignalColors& signalColors)
        : m_iHotCue(kNoHotCue) {
    QString item = context.selectString(node, "Control");
    if (!item.isEmpty()) {
        m_pPointCos = std::make_unique<ControlProxy>(group, item);
        if (item.startsWith("hotcue_") && item.endsWith("_position")) {
            m_iHotCue = item.mid(7, item.count() - 16).toInt() - 1;
        }
    }
    m_properties = WaveformMarkProperties(node, context, signalColors, m_iHotCue);
}
Пример #21
0
void WNumber::setup(QDomNode node, const SkinContext& context) {
    WLabel::setup(node, context);

    // Number of digits
    // TODO(rryan): This has been unused for a long time yet our skins specify
    // this value all over the place.
    m_iNoDigits = context.selectInt(node, "NumberOfDigits");

    // Constant factor
    if (context.hasNode(node, "ConstFactor")) {
        m_dConstFactor = context.selectString(node, "ConstFactor").toDouble();
    }

    setValue(0.);
}
Пример #22
0
void WaveformRendererSignalBase::setup(const QDomNode& node,
                                       const SkinContext& context) {
    QString alignString = context.selectString(node, "Align").toLower();
    if (alignString == "bottom") {
        m_alignment = Qt::AlignBottom;
    } else if (alignString == "top") {
        m_alignment = Qt::AlignTop;
    } else {
        m_alignment = Qt::AlignCenter;
    }

    m_pColors = m_waveformRenderer->getWaveformSignalColors();
    m_axesColor = m_pColors->getAxesColor();

    onSetup(node);
}
Пример #23
0
void WComboBox::setup(const QDomNode& node, const SkinContext& context) {
    // Load pixmaps for associated states
    QDomNode state = context.selectNode(node, "State");
    while (!state.isNull()) {
        if (state.isElement() && state.nodeName() == "State") {
            int iState;
            if (!context.hasNodeSelectInt(state, "Number", &iState)) {
                SKIN_WARNING(state, context)
                        << "WComboBox ignoring <State> without <Number> node.";
                continue;
            }
            QString text = context.selectString(state, "Text");
            QString icon = context.selectString(state, "Icon");
            addItem(QIcon(icon), text, QVariant(iState));
        }
        state = state.nextSibling();
    }
}
Пример #24
0
void WVuMeter::setup(QDomNode node, const SkinContext& context) {
    // Set pixmaps
    bool bHorizontal = context.hasNode(node, "Horizontal") &&
    context.selectString(node, "Horizontal") == "true";

    // Set background pixmap if available
    if (context.hasNode(node, "PathBack")) {
        QDomElement backPathNode = context.selectElement(node, "PathBack");
        // 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;
}
Пример #25
0
void WTrackProperty::setup(QDomNode node, const SkinContext& context) {
    WLabel::setup(node, context);

    m_property = context.selectString(node, "Property");
}
Пример #26
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();
    }
}
Пример #27
0
void WLabel::setup(const QDomNode& node, const SkinContext& context) {
    // Colors
    QPalette pal = palette(); //we have to copy out the palette to edit it since it's const (probably for threadsafety)


    QDomElement bgColor = context.selectElement(node, "BgColor");
    if (!bgColor.isNull()) {
        m_qBgColor.setNamedColor(context.nodeToString(bgColor));
        pal.setColor(this->backgroundRole(), WSkinColor::getCorrectColor(m_qBgColor));
        setAutoFillBackground(true);
    }

    m_qFgColor.setNamedColor(context.selectString(node, "FgColor"));
    pal.setColor(this->foregroundRole(), WSkinColor::getCorrectColor(m_qFgColor));
    setPalette(pal);

    // Text
    if (context.hasNodeSelectString(node, "Text", &m_skinText)) {
        setText(m_skinText);
    }

    // Font size
    QString strFontSize;
    if (context.hasNodeSelectString(node, "FontSize", &strFontSize)) {
        int fontsize = strFontSize.toInt();
        // TODO(XXX) "Helvetica" should retrain the Qt default font matching, verify that.
        setFont(QFont("Helvetica", fontsize, QFont::Normal));
    }

    // Alignment
    QString alignment;
    if (context.hasNodeSelectString(node, "Alignment", &alignment)) {
        alignment = alignment.toLower();
        if (alignment == "right") {
            setAlignment(Qt::AlignRight | Qt::AlignVCenter);
        } else if (alignment == "center") {
            setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
        } else if (alignment == "left") {
            setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
        } else {
            qDebug() << "WLabel::setup(): Alignment =" << alignment <<
                    " unknown, use right, center or left";
        }
    }

    // Adds an ellipsis to truncated text
    QString elide;
    if (context.hasNodeSelectString(node, "Elide", &elide)) {
        elide = elide.toLower();
        if (elide == "right") {
            m_elideMode = Qt::ElideRight;
        } else if (elide == "middle") {
            m_elideMode = Qt::ElideMiddle;
        } else if (elide == "left") {
            m_elideMode = Qt::ElideLeft;
        } else if (elide == "none") {
            m_elideMode = Qt::ElideNone;
        } else {
            qDebug() << "WLabel::setup(): Alide =" << elide <<
                    "unknown, use right, middle, left or none.";
        }
    }
}
Пример #28
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);
        }
    }
}
Пример #29
0
bool WaveformSignalColors::setup(const QDomNode &node, const SkinContext& context) {
    // NOTE(rryan): It is critical that every color is converted to RGB with
    // toRgb(). Otherwise Mixxx will waste 3% of its CPU time while rendering
    // the filtered waveform doing RGB color space conversions!

    m_signalColor.setNamedColor(context.selectString(node, "SignalColor"));
    m_signalColor = WSkinColor::getCorrectColor(m_signalColor).toRgb();

    m_lowColor.setNamedColor(context.selectString(node, "SignalLowColor"));
    m_lowColor = WSkinColor::getCorrectColor(m_lowColor).toRgb();

    m_midColor.setNamedColor(context.selectString(node, "SignalMidColor"));
    m_midColor = WSkinColor::getCorrectColor(m_midColor).toRgb();

    m_highColor.setNamedColor(context.selectString(node, "SignalHighColor"));
    m_highColor = WSkinColor::getCorrectColor(m_highColor).toRgb();

    m_rgbLowColor.setNamedColor(context.selectString(node, "SignalRGBLowColor"));
    if (!m_rgbLowColor.isValid()) {
        m_rgbLowColor = Qt::red;
    }
    m_rgbLowColor = WSkinColor::getCorrectColor(m_rgbLowColor).toRgb();

    m_rgbMidColor.setNamedColor(context.selectString(node, "SignalRGBMidColor"));
    if (!m_rgbMidColor.isValid()) {
        m_rgbMidColor = Qt::green;
    }
    m_rgbMidColor = WSkinColor::getCorrectColor(m_rgbMidColor).toRgb();

    m_rgbHighColor.setNamedColor(context.selectString(node, "SignalRGBHighColor"));
    if (!m_rgbHighColor.isValid()) {
        m_rgbHighColor = Qt::blue;
    }
    m_rgbHighColor = WSkinColor::getCorrectColor(m_rgbHighColor).toRgb();

    m_axesColor.setNamedColor(context.selectString(node, "AxesColor"));
    if (!m_axesColor.isValid()) {
        m_axesColor = QColor(245,245,245);
    }
    m_axesColor = WSkinColor::getCorrectColor(m_axesColor).toRgb();

    m_playPosColor.setNamedColor(context.selectString(node, "PlayPosColor"));
    m_playPosColor = WSkinColor::getCorrectColor(m_playPosColor).toRgb();
    if (!m_playPosColor.isValid()) {
        m_playPosColor = m_axesColor;
    }

    m_bgColor.setNamedColor(context.selectString(node, "BgColor"));
    if (!m_bgColor.isValid()) {
        m_bgColor = QColor(0, 0, 0);
    }
    m_bgColor = WSkinColor::getCorrectColor(m_bgColor).toRgb();

    bool filteredColorValid = m_lowColor.isValid() && m_midColor.isValid() && m_highColor.isValid();

    if (m_signalColor.isValid() && filteredColorValid) {
        return true; //default
    }

    if (m_signalColor.isValid() && !filteredColorValid) {
        fallBackFromSignalColor(); //pre waveform-2.0 skins
        return false;
    }

    fallBackDefaultColor();
    return false;
}
Пример #30
0
void WaveformRendererPreroll::setup(const QDomNode& node, const SkinContext& context) {
    m_color.setNamedColor(context.selectString(node, "SignalColor"));
    m_color = WSkinColor::getCorrectColor(m_color);
}