示例#1
0
void ParamWidget::AddDouble(const QString& name,
    double min, double max, double step, double initial_value,
    DisplayHint display_hint) {
  ExpectNameNotFound(name);

  if (display_hint == DisplayHint::kSpinBox) {
    QDoubleSpinBox* spinbox = new QDoubleSpinBox(this);
    spinbox->setRange(min, max);
    spinbox->setSingleStep(step);
    spinbox->setValue(initial_value);
    spinbox->setProperty("param_widget_type", kParamDouble);
    widgets_[name] = spinbox;
    AddLabeledRow(name, spinbox);
    connect(spinbox,
        static_cast<void(QDoubleSpinBox::*)(double)>(
          &QDoubleSpinBox::valueChanged),
        [this, name](double value) {
          emit ParamChanged(name);
        });
  } else if (display_hint == DisplayHint::kSlider) {
    QWidget* row_widget = new QWidget(this);
    QHBoxLayout* row_hbox = new QHBoxLayout(row_widget);
    QSlider* slider = new QSlider(Qt::Horizontal, this);
    const int num_steps = static_cast<int>((max - min) / step);
    const int initial_value_int =
      static_cast<int>((initial_value - min) / step);
    slider->setRange(0, num_steps);
    slider->setSingleStep(1);
    slider->setValue(initial_value_int);
    slider->setProperty("min", min);
    slider->setProperty("max", max);
    slider->setProperty("step", step);
    slider->setProperty("param_widget_type", kParamDouble);
    QLabel* label = new QLabel(this);
    label->setText(QString::number((initial_value_int - min) * step));
    row_hbox->addWidget(new QLabel(name, this));
    row_hbox->addWidget(slider);
    row_hbox->addWidget(label);
    widgets_[name] = slider;
    layout_->addWidget(row_widget);
    slider->setProperty("param_widget_label", QVariant::fromValue(label));
    label->setProperty("format_str", "");
    connect(slider, &QSlider::valueChanged,
        [this, name, label, min, step](int position) {
          const double value = min + step * position;
          const QString format_str = label->property("format_str").toString();
          if (format_str == "") {
            label->setText(QString::number(value));
            label->setMinimumWidth(std::max(label->width(), label->minimumWidth()));
          } else {
            QString text;
            text.sprintf(format_str.toStdString().c_str(), value);
            label->setText(text);
          }
          emit ParamChanged(name);
        });
  } else {
    throw std::invalid_argument("Invalid display hint");
  }
}
示例#2
0
void ParamWidget::AddEnum(const QString& name,
    const EnumVector& items,
    int initial_value,
    DisplayHint display_hint) {
  ExpectNameNotFound(name);

  if (display_hint != DisplayHint::kComboBox) {
    throw std::invalid_argument("Invalid display hint");
  }

  QComboBox* combobox = new QComboBox(this);
  combobox->setProperty("param_widget_type", kParamEnum);
  bool found_initial_value = false;
  for (size_t i = 0; i < items.size(); ++i) {
    const EnumItem& item = items[i];
    combobox->addItem(item.first, item.second);
    if (item.second == initial_value) {
      found_initial_value = true;
      combobox->setCurrentIndex(i);
    }
  }
  if (!found_initial_value) {
    throw std::invalid_argument("Invalid initial value");
  }
  widgets_[name] = combobox;
  AddLabeledRow(name, combobox);
  connect(combobox,
      static_cast<void(QComboBox::*)(int)>(&QComboBox::activated),
      [this, name](int val) {
        emit ParamChanged(name);
      });
}
示例#3
0
void ParamWidget::AddInt(const QString& name,
    int min, int max, int step, int initial_value,
    DisplayHint display_hint) {
  ExpectNameNotFound(name);

  if (display_hint == DisplayHint::kSpinBox) {
    QSpinBox* spinbox = new QSpinBox(this);
    spinbox->setRange(min, max);
    spinbox->setSingleStep(step);
    spinbox->setValue(initial_value);
    spinbox->setProperty("param_widget_type", kParamInt);
    widgets_[name] = spinbox;
    AddLabeledRow(name, spinbox);
    connect(spinbox,
        static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged),
        [this, name](int val) {
          emit ParamChanged(name);
        });
  } else if (display_hint == DisplayHint::kSlider) {
    QWidget* row_widget = new QWidget(this);
    QHBoxLayout* row_hbox = new QHBoxLayout(row_widget);
    QSlider* slider = new QSlider(Qt::Horizontal, this);
    slider->setRange(min, max);
    slider->setSingleStep(step);
    slider->setValue(initial_value);
    slider->setProperty("param_widget_type", kParamInt);
    QLabel* label = new QLabel(this);
    label->setText(QString::number(initial_value));
    row_hbox->addWidget(new QLabel(name, this));
    row_hbox->addWidget(slider);
    row_hbox->addWidget(label);
    widgets_[name] = slider;
    layout_->addWidget(row_widget);
    connect(slider, &QSlider::valueChanged,
        [this, name, label](int value) {
          label->setText(QString::number(value));
          emit ParamChanged(name);
        });
  } else {
    throw std::invalid_argument("Invalid display hint");
  }
}
示例#4
0
void ParamWidget::AddString(const QString& name, const QString& initial_value) {
  QWidget* row_widget = new QWidget(this);
  QHBoxLayout* row_hbox = new QHBoxLayout(row_widget);
  row_hbox->addWidget(new QLabel(name, this));
  QLineEdit* ledit = new QLineEdit(initial_value, this);
  row_hbox->addWidget(ledit);
  widgets_[name] = ledit;
  layout_->addWidget(row_widget);
  connect(ledit, &QLineEdit::editingFinished,
          [this, name]() { emit ParamChanged(name); });
}
示例#5
0
void ImgColorBalancePage::OnReset()
{
	{
		Block update(in_update_);
		preserve_lum_ = 1;
		CheckDlgButton(IDC_PRESERVE_LUM, preserve_lum_);
	}
	// clear all ranges
	for (int i= 0; i < array_count(shift_); ++i)
		std::fill(shift_[i].val, shift_[i].val + array_count(shift_[i].val), 0);
	SetRangeValues();
	ParamChanged(this, true);
}
示例#6
0
void ParamWidget::AddPushButtons(const std::vector<QString>& names) {
  QWidget* row_widget = new QWidget(this);
  QHBoxLayout* hbox = new QHBoxLayout(row_widget);
  for (const QString& name : names) {
    QPushButton* button =
      new QPushButton(name, this);
    button->setProperty("param_widget_type", kParamButton);
    hbox->addWidget(button);
    connect(button, &QPushButton::clicked,
        [this, name](bool ignored) { emit ParamChanged(name); });
    widgets_[name] = button;
  }
  layout_->addWidget(row_widget);
}
示例#7
0
//--------------------------------------------------------------------------------------
//! Defines the work for constructor
//--------------------------------------------------------------------------------------
void tHVDisplayConfigDialog::AddConfigInfo()
{
    m_pDefaultsPushButton->hide();

    // White Backlight
    m_pBacklightColorCheckBox = new tCheckBox(false, this);
    m_pBacklightColorLabel = new QLabel( tr("White backlight", "White backlight color on a remote display") , this);

    // Backlight colour is not selectable on 40/40 displays
    if(m_pDevice->ProductCode() == N2K_B_AND_G_HV_DISPLAY_40_40_ID)
    {
        m_pBacklightColorCheckBox->hide();
        m_pBacklightColorLabel->hide();
    }

    // Display Group
    m_pDisplayGroupComboBox = new tComboBox(this);
    QStringList groupsList;
    groupsList << tDataUiConfig::Instance()->DefaultNetworkGroupTerm() << "1" << "2" << "3" << "4" << "5" << "6";
    m_pDisplayGroupComboBox->addItems(groupsList);

    m_pDisplayGroupLabel = new QLabel( tr("Display group", "Display group for a remote display"), this);

    // Data
    m_pSelectDataButton = new tPushButton(this);
    m_pSelectDataButton->setText(tr("Select Data"));

    // setting the tab order to be sequential
    setTabOrder(m_pBacklightColorCheckBox, m_pDisplayGroupComboBox);
    setTabOrder(m_pDisplayGroupComboBox, m_pSelectDataButton);
    setTabOrder(m_pSelectDataButton, m_pInstanceEdit);
    
    m_pConfigLayout->addWidget(m_pBacklightColorLabel, 1, 0, 1, 1);
    m_pConfigLayout->addWidget(m_pBacklightColorCheckBox, 1, 1, 1, 1);
    m_pConfigLayout->addWidget(m_pDisplayGroupLabel, 2, 0, 1, 1);
    m_pConfigLayout->addWidget(m_pDisplayGroupComboBox, 2, 1, 1, 1);
    m_pConfigLayout->addWidget(m_pSelectDataButton, 3, 1, 1, 1);

    Connect( m_pProxy, 
             SIGNAL( ParamChanged(eNDP2kParamId, quint8, QVariant) ),
             this, 
             SLOT( OnParamChanged(eNDP2kParamId, quint8, QVariant) ) );

    Connect(m_pBacklightColorCheckBox, SIGNAL(stateChanged(int)), this, SLOT(OnBacklightColorChange(int)), Qt::QueuedConnection );
    Connect(m_pDisplayGroupComboBox, SIGNAL( currentIndexChanged(int) ), this, SLOT( OnDisplayGroupChange(int)), Qt::QueuedConnection);
    Connect(m_pSelectDataButton, SIGNAL(clicked()), this, SLOT(OnSelectData()));

    m_pProxy->SetFlashingDisplay(true);
}
示例#8
0
void ImgColorBalancePage::OnHScroll(UINT sb_code, UINT pos, CScrollBar* scroll_bar)
{
	if (scroll_bar == 0 || in_update_)
		return;

	for (int i= 0; i < 3; ++i)
		if (scroll_bar->m_hWnd == slider_wnd_[i].m_hWnd)
		{
			Block update(in_update_);
			int val= slider_wnd_[i].GetPos();
			SetDlgItemInt(IDC_EDIT_1 + i, val);
			shift_[range_].val[i] = val;

			ParamChanged(this);

			break;
		}
}
示例#9
0
void ImgColorBalancePage::OnNumChanged(UINT id)
{
	if (in_update_)
		return;

	int index= -1;

	switch (id)
	{
	case IDC_EDIT_1:
		index = 0;
		break;

	case IDC_EDIT_2:
		index = 1;
		break;

	case IDC_EDIT_3:
		index = 2;
		break;
	}

	if (index < 0)
		return;

	int val= GetDlgItemInt(id);
	if (val < MIN_VAL)
		val = MIN_VAL;
	if (val > MAX_VAL)
		val = MAX_VAL;

	Block update(in_update_);
	slider_wnd_[index].SetPos(val);
	shift_[range_].val[index] = val;

	ParamChanged(this);
}
示例#10
0
void ImgColorBalancePage::OnPreserveLuminosity()
{
	balance_.PreserveLuminosity(IsDlgButtonChecked(IDC_PRESERVE_LUM) != 0);

	ParamChanged(this);
}
示例#11
-5
void ParamWidget::AddBooleans(const std::vector<BoolItem>& to_add,
    DisplayHint display_hint) {
  if (display_hint != kCheckBox) {
    throw std::invalid_argument("Invalid display hint");
  }

  QWidget* row_widget = new QWidget(this);
  QHBoxLayout* hbox = new QHBoxLayout(row_widget);
  for (const BoolItem& item : to_add) {
    ExpectNameNotFound(item.name);

    QCheckBox* checkbox =
      new QCheckBox(item.name, this);

    if (item.initially_checked) {
      checkbox->setCheckState(Qt::Checked);
    } else {
     checkbox->setCheckState(Qt::Unchecked);
    }
    checkbox->setProperty("param_widget_type", kParamBool);

    widgets_[item.name] = checkbox;
    hbox->addWidget(checkbox);

    connect(checkbox, &QCheckBox::stateChanged,
        [this, item](int val) { emit ParamChanged(item.name); });
  }

  layout_->addWidget(row_widget);
}