Exemplo n.º 1
0
double ParamWidget::GetDouble(const QString& name) {
  QWidget* widget = GetWidget(name);
  QDoubleSpinBox* spinbox = dynamic_cast<QDoubleSpinBox*>(widget);
  if (spinbox) {
    return spinbox->value();
  }
  QSlider* slider = dynamic_cast<QSlider*>(widget);
  if (slider) {
    const double min = slider->property("min").toDouble();
    const double step = slider->property("step").toDouble();
    return min + step * slider->value();
  }
  throw std::runtime_error("Unable to determine widget type for param " +
      name.toStdString());
}
Exemplo n.º 2
0
void ParamWidget::SetDouble(const QString& name, double val) {
  QWidget* widget = GetWidget(name);
  QDoubleSpinBox* spinbox = dynamic_cast<QDoubleSpinBox*>(widget);
  if (spinbox) {
    spinbox->setValue(val);
    return;
  }
  QSlider* slider = dynamic_cast<QSlider*>(widget);
  if (slider) {
    const double min = slider->property("min").toDouble();
    const double step = slider->property("step").toDouble();
    const int position = static_cast<int>(round((val - min) / step));
    slider->setValue(position);
    return;
  }
  throw std::runtime_error("Unable to determine widget type for param " +
      name.toStdString());
}
Exemplo n.º 3
0
void EQWidget::target_changed(int)
{
    QSlider *th = (QSlider *)sender();
    DBG(th->value());
    int h=th->property("index").toInt();
    if(h>0)
        plugin->setBand(h-1,pow(10,(GAIN_HALF-th->value())/-20.0) );
    else
        plugin->setPreamp(pow(10,(GAIN_HALF-th->value())/-20.0));

}
Exemplo n.º 4
0
void ParamWidget::SetPrecision(const QString& name, int digits, int decimal_places)
{
  QWidget* widget = GetWidget(name);
  QSlider* slider = dynamic_cast<QSlider*>(widget);
  if (slider) {
    QLabel* label = slider->property("param_widget_label").value<QLabel*>();
    if (label) {
      const QFont& font = label->font();
      QFontMetrics font_metrics(font);
      QString sample_text;
      for (int i = 0; i < digits; ++i) {
        sample_text.append('9');
      }
      if (decimal_places) {
        sample_text.append('.');
      }
      const int width = font_metrics.width(sample_text);
      QString format_str;
      format_str.sprintf("%%%d.%df", digits, decimal_places);
      label->setProperty("format_str", format_str);
      label->setFixedWidth(width);
    }
  }
}