Exemplo n.º 1
0
void QtDoubleSpinBoxFactory::slotPropertyChanged(QtProperty *property, double value)
{
    QList<QDoubleSpinBox *> editors = m_createdEditors[property];
    QListIterator<QDoubleSpinBox *> itEditor(m_createdEditors[property]);
    while (itEditor.hasNext()) {
        QDoubleSpinBox *editor = itEditor.next();
        if (editor->value() != value) {
            editor->blockSignals(true);
            editor->setValue(value);
            editor->blockSignals(false);
        }
    }
}
Exemplo n.º 2
0
void QtDoubleSpinBoxFactory::slotSingleStepChanged(QtProperty *property, double step)
{
    if (!m_createdEditors.contains(property))
        return;

    QtDoublePropertyManager *manager = this->propertyManager(property);
    if (!manager)
        return;

    QList<QDoubleSpinBox *> editors = m_createdEditors[property];
    QListIterator<QDoubleSpinBox *> itEditor(editors);
    while (itEditor.hasNext()) {
        QDoubleSpinBox *editor = itEditor.next();
        editor->blockSignals(true);
        editor->setSingleStep(step);
        editor->blockSignals(false);
    }
}
Exemplo n.º 3
0
void QtDoubleSpinBoxFactory::slotDecimalsChanged(QtProperty *property, int prec)
{
    if (!m_createdEditors.contains(property))
        return;

    QtDoublePropertyManager *manager = this->propertyManager(property);
    if (!manager)
        return;

    QList<QDoubleSpinBox *> editors = m_createdEditors[property];
    QListIterator<QDoubleSpinBox *> itEditor(editors);
    while (itEditor.hasNext()) {
        QDoubleSpinBox *editor = itEditor.next();
        editor->blockSignals(true);
        editor->setDecimals(prec);
        editor->setValue(manager->value(property));
        editor->blockSignals(false);
    }
}
Exemplo n.º 4
0
WidgetParameterDouble::WidgetParameterDouble(std::shared_ptr<Parameter<double>> parameter)
: WidgetParameter<double>(parameter)
{
	QDoubleSpinBox* spinBox = new QDoubleSpinBox(this);
	spinBox->setMaximumWidth(100);
	spinBox->setRange(parameter->hardMin(), parameter->hardMax());
	spinBox->setDecimals(6);
	spinBox->setSingleStep(qMin(1.,(parameter->softMax() - parameter->softMin())/100.));
	spinBox->move(0,0);
	
	ParameterValueContainer valueContainer = parameter->toContainer();
	double* value = nullptr;
	value = boost::get<double>(&valueContainer);
	assert(value);
	if (value)
	{
		spinBox->setValue(*value);
	}
	
	// param -> widget
	mParameter->addNewInternalValueCallback([this, spinBox](double value) {
		spinBox->blockSignals(true);
		Q_EMIT newInternalValue(value);
		spinBox->blockSignals(false);
	});
	bool success = connect(this, SIGNAL(newInternalValue(double)), spinBox, SLOT(setValue(double)));
	assert(success);
	
	// widget -> param
	success = connect(spinBox, SELECT<double>::OVERLOAD_OF(&QDoubleSpinBox::valueChanged), [this](double value) {
		mParameter->set(value);
	});
	assert(success);
	
	mWidget = spinBox;
}
Exemplo n.º 5
0
void EncTtsCfgGui::updateWidget()
{
    // get sender setting
    EncTtsSetting* setting = qobject_cast<EncTtsSetting*>(QObject::sender());
    if(setting == NULL) return;
    // get corresponding widget
    QWidget* widget = m_settingsWidgetsMap.value(setting);

    // update Widget based on setting type
    switch(setting->type())
    {
        case EncTtsSetting::eDOUBLE:
        {
            QDoubleSpinBox* spinbox = (QDoubleSpinBox*) widget;
            spinbox->setMinimum(setting->min().toDouble());
            spinbox->setMaximum(setting->max().toDouble());
            spinbox->blockSignals(true);
            spinbox->setValue(setting->current().toDouble());
            spinbox->blockSignals(false);
            break;
        }
        case EncTtsSetting::eINT:
        {
            QSpinBox* spinbox = (QSpinBox*) widget;
            spinbox->setMinimum(setting->min().toInt());
            spinbox->setMaximum(setting->max().toInt());
            spinbox->blockSignals(true);
            spinbox->setValue(setting->current().toInt());
            spinbox->blockSignals(false);
            break;
        }
        case EncTtsSetting::eSTRING:
        {
            QLineEdit* lineedit = (QLineEdit*) widget;

            lineedit->blockSignals(true);
            lineedit->setText(setting->current().toString());
            lineedit->blockSignals(false);
            break;
        }
        case EncTtsSetting::eREADONLYSTRING:
        {
            QLabel* label = (QLabel*) widget;

            label->blockSignals(true);
            label->setText(setting->current().toString());
            label->blockSignals(false);
            break;
        }
        case EncTtsSetting::eSTRINGLIST:
        {
            QComboBox* combobox = (QComboBox*) widget;

            combobox->blockSignals(true);
            combobox->clear();
            combobox->addItems(setting->list());
            int index = combobox->findText(setting->current().toString());
            combobox->setCurrentIndex(index);
            combobox->blockSignals(false);

            break;
        }
        case EncTtsSetting::eBOOL:
        {
            QCheckBox* checkbox = (QCheckBox*) widget;

            checkbox->blockSignals(true);
            checkbox->setCheckState(setting->current().toBool() == true ? Qt::Checked : Qt::Unchecked);
            checkbox->blockSignals(false);
            break;
        }
        default:
        {
            LOG_WARNING() << "unknown EncTTsSetting";
            break;
        }
    }
}
Exemplo n.º 6
0
void protoObject::propertyUpdated(QString propertyName){
    QObject *receiver = mapper->mapping(propertyName);
    QWidget *widget;

    if (receiver) return; //if not binding, just leave

    widget = qobject_cast<QLabel*>(receiver);
    if (widget) {
        QLabel* edit = qobject_cast<QLabel*>(receiver);
        QString value = this->property(propertyName.toLatin1()).toString();
        edit->blockSignals(true);
        edit->setText(edit->text().arg(value));
        edit->blockSignals(false);
    };

    widget = qobject_cast<QLineEdit*>(receiver);
    if (widget) {
        QLineEdit* edit = qobject_cast<QLineEdit*>(receiver);
        QString value = this->property(propertyName.toLatin1()).toString();
        edit->blockSignals(true);
        edit->setText(value);
        edit->blockSignals(false);
    };

    widget = qobject_cast<QComboBox*>(receiver);
    if (widget) {
        QComboBox* edit = qobject_cast<QComboBox*>(receiver);
        edit->blockSignals(true);
        edit->setCurrentIndex(edit->findData(this->property(propertyName.toLatin1()), Qt::UserRole));
        edit->blockSignals(false);
    };

    widget = qobject_cast<QRadioButton*>(receiver);
    if (widget) {
        QRadioButton* edit = qobject_cast<QRadioButton*>(receiver);
        bool value = this->property(propertyName.toLatin1()).toBool();
        edit->blockSignals(true);
        edit->setChecked(value);
        edit->blockSignals(false);
    };

    widget = qobject_cast<QCheckBox*>(receiver);
    if (widget) {
        QCheckBox* edit = qobject_cast<QCheckBox*>(receiver);
        bool value = this->property(propertyName.toLatin1()).toBool();
        edit->blockSignals(true);
        edit->setChecked(value);
        edit->blockSignals(false);
    };

    widget = qobject_cast<QPlainTextEdit*>(receiver);
    if (widget) {
        QPlainTextEdit* edit = qobject_cast<QPlainTextEdit*>(receiver);
        QString value = this->property(propertyName.toLatin1()).toString();
        edit->blockSignals(true);
        edit->setPlainText(value);
        edit->blockSignals(false);
    };

    widget = qobject_cast<QSpinBox*>(receiver);
    if (widget) {
        QSpinBox* edit = qobject_cast<QSpinBox*>(receiver);
        int value = this->property(propertyName.toLatin1()).toInt();
        edit->blockSignals(true);
        edit->setValue(value);
        edit->blockSignals(false);
    };

    widget = qobject_cast<QDoubleSpinBox*>(receiver);
    if (widget) {
        QDoubleSpinBox* edit = qobject_cast<QDoubleSpinBox*>(receiver);
        double value = this->property(propertyName.toLatin1()).toDouble();
        edit->blockSignals(true);
        edit->setValue(value);
        edit->blockSignals(false);
    };

    widget = qobject_cast<QDateTimeEdit*>(receiver);
    if (widget) {
        QDateTimeEdit* edit = qobject_cast<QDateTimeEdit*>(receiver);
        QDateTime value = this->property(propertyName.toLatin1()).toDateTime();
        edit->blockSignals(true);
        edit->setDateTime(value);
        edit->blockSignals(false);
    };
}