예제 #1
0
void DlgPrefVinyl::VinylGainSlotApply()
{
    qDebug() << "in VinylGainSlotApply()" << "with gain:" << VinylGain->value();
    //Update the config key...
    config->set(ConfigKey(VINYL_PREF_KEY,"gain"), ConfigValue(VinylGain->value()));

    //Update the ControlObject...
    ControlObject* pControlObjectVinylControlGain = ControlObject::getControl(ConfigKey(VINYL_PREF_KEY, "gain"));
    pControlObjectVinylControlGain->set(VinylGain->value());
}
예제 #2
0
TEST_F(ControllerEngineTest, scriptSetValue) {
    ScopedTemporaryFile script(makeTemporaryFile(
        "setValue = function() { engine.setValue('[Channel1]', 'co', 1.0); }\n"));

    cEngine->evaluate(script->fileName());
    EXPECT_FALSE(cEngine->hasErrors(script->fileName()));

    ControlObject *co = new ControlObject(ConfigKey("[Channel1]", "co"));
    co->set(0.0);
    execute("setValue");
    EXPECT_DOUBLE_EQ(co->get(), 1.0);

    delete co;
}
예제 #3
0
LADSPAPresetSlot::LADSPAPresetSlot(QWidget *parent, QDomElement element, int slot, LADSPAPresetManager *presetManager, QPalette palette) : QWidget(parent)
{
    m_pPresetManager = presetManager;
    m_qPalette = palette;
    m_iSlotNumber = slot;

    setAcceptDrops(true);

    m_pScrollArea = new QScrollArea(this);
    m_pScrollWidget = new QWidget(m_pScrollArea);
    m_pScrollArea->setWidget(m_pScrollWidget);
    //m_pScrollArea->setWidgetResizable(true);
    m_pScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

    QDomElement posElement = element.firstChildElement("Pos");
    QString pos = posElement.text();
    int x = pos.left(pos.indexOf(",")).toInt();
    int y = pos.mid(pos.indexOf(",") + 1).toInt();
    if (x < 0)
    {
        x = parent->width() + x;
    }
    if (y < 0)
    {
	    y = parent->height() + y;
    }
    QDomElement spacingElement = element.firstChildElement("Spacing");
    QString spacing = spacingElement.text();
    int spacingWidth = spacing.left(spacing.indexOf(",")).toInt();
    int spacingHeight = spacing.mid(spacing.indexOf(",") + 1).toInt();    

    QDomElement sizeElement = element.firstChildElement("Size");
    QString size = sizeElement.text();
    int width = size.left(size.indexOf(",")).toInt();
    int height = size.mid(size.indexOf(",") + 1).toInt();
    if (width <= 0)
    {
	width = parent->width() + width;
    }
    if (height <= 0)
    {
	height = parent->height() + height;
    }
    move(x + slot * spacingWidth, y + slot * (height + spacingHeight));
    resize(width, height);
    m_pScrollArea->resize(width, height);
    m_pScrollWidget->resize(width - 5, height - 5);
    m_iBaseWidth = width;

    QString slotString;
    slotString.setNum(slot);
    
    QDomNodeList buttonNodeList = element.elementsByTagName("PushButton");
    for (int i = 0; i < buttonNodeList.count(); i++)
    {
	QDomElement buttonElement = buttonNodeList.item(i).toElement();
	QString configKey = buttonElement.firstChildElement("Connection").firstChildElement("ConfigKey").text();
	if (configKey.startsWith("[LADSPA],RemoveEffect"))
	{
	    QString keyString = QString("RemoveEffect") + slotString;
	    ConfigKey *key = new ConfigKey("[LADSPA]", keyString);
	    ControlPushButton *control = new ControlPushButton(*key, false);
	    m_pRemoveButton = new WPushButton(m_pScrollWidget);
	    buttonElement.firstChildElement("Connection").firstChildElement("ConfigKey").firstChild().setNodeValue("[LADSPA]," + keyString);
	    m_pRemoveButton->setup(buttonElement);
	    m_pRemoveButton->setVisible(false);
	}
	else if (configKey.startsWith("[LADSPA],EnableEffect"))
	{
        qDebug() << "Setting up LADSPA EnableEffect" << slotString;
	    QString keyString = QString("EnableEffect") + slotString;
	    ConfigKey *key = new ConfigKey("[LADSPA]", keyString);
        qDebug() << "Key string:" << keyString;
	    ControlObject *control = new ControlPushButton(*key, false);
        control->set(1.0f);
	    m_pEnableButton = new WPushButton(m_pScrollWidget);
	    buttonElement.firstChildElement("Connection").firstChildElement("ConfigKey").firstChild().setNodeValue("[LADSPA]," + keyString);
	    m_pEnableButton->setup(buttonElement);
	}
	else
	{
	    qDebug() << "LADSPA: Invalid skin (unknown button: " << configKey << ")";
	}
    }

    QDomElement labelElement = element.firstChildElement("Label");
    m_pLabel = new QLabel(m_pScrollWidget);
    m_pLabel->setText(tr("Drag a preset from the list & drop it here"));

    posElement = labelElement.firstChildElement("Pos");
    pos = posElement.text();
    x = pos.left(pos.indexOf(",")).toInt();
    y = pos.mid(pos.indexOf(",") + 1).toInt();
    if (x < 0)
    {
        x = this->width() + x;
    }
    if (y < 0)
    {
	    y = this->height() + y;
    }
    m_pLabel->move(x, y);

    QDomElement widthElement = labelElement.firstChildElement("Width");
    if (!(widthElement.isNull()))
    {
	    width = widthElement.text().toInt();
	    m_pLabel->setMaximumWidth(width);
    }

    m_pLabel->setPalette(palette);

    m_qKnobElement = element.firstChildElement("Knob");
    m_pPresetInstance = NULL;

    
    ConfigKey *key = new ConfigKey("[LADSPA]", "DryWet" + slotString);
    ControlPotmeter *control = new ControlPotmeter(*key, 0.0, 1.0);
    m_pDryWetKnob = new WKnob(m_pScrollWidget);
    QString keyString = QString("[LADSPA],DryWet") + slotString;
    m_qKnobElement.firstChildElement(QString("Connection")).firstChildElement(QString("ConfigKey")).firstChild().setNodeValue(keyString);
    m_qKnobElement.firstChildElement(QString("Tooltip")).firstChild().setNodeValue("Dry/wet");
    m_pDryWetKnob->setup(m_qKnobElement);
    m_pDryWetKnob->show();

    posElement = m_qKnobElement.firstChildElement("Pos");
    pos = posElement.text();
    x = pos.left(pos.indexOf(",")).toInt();
    y = pos.mid(pos.indexOf(",") + 1).toInt();
    if (x < 0)
    {
        x = this->width() + x;
    }
    if (y < 0)
    {
	y = this->height() + y;
    }
    m_pDryWetKnob->move(x, y);

    spacingElement = m_qKnobElement.firstChildElement("Spacing");
    spacing = spacingElement.text();
    spacingWidth = spacing.left(spacing.indexOf(",")).toInt();

    m_pDryWetLabel = new QLabel("Dry/wet", m_pScrollWidget);
    m_pDryWetLabel->setMaximumWidth(spacingWidth + m_pDryWetKnob->width() - 4);
    m_pDryWetLabel->show();
    x += m_pDryWetKnob->width() / 2 - m_pDryWetLabel->width() / 2;
    m_pDryWetLabel->move(x, y + m_pDryWetKnob->height() + 1);
    m_pDryWetLabel->setPalette(m_qPalette);

    connect(m_pRemoveButton, SIGNAL(valueChangedLeftUp(double)), this, SLOT(slotRemove()));
}