const shared_ptr<sigrok::Device> sr_dev = device->device();
+ try {
+ auto gvar = sr_dev->config_get(ConfigKey::EXTERNAL_CLOCK);
+ if (gvar.gobj()) {
+ bool value = Glib::VariantBase::cast_dynamic<Glib::Variant<bool>>(
+ gvar).get();
+ sample_rate_.allow_user_entered_values(value);
+ }
+ } catch (Error& error) {
+ // Do nothing
+ }
+
if (sr_dev->config_check(ConfigKey::SAMPLERATE, Capability::LIST)) {
try {
gvar_dict = sr_dev->config_list(ConfigKey::SAMPLERATE);
void MainBar::on_config_changed()
{
+ // We want to also call update_sample_rate_selector() here in case
+ // the user changed the SR_CONF_EXTERNAL_CLOCK option. However,
+ // commit_sample_rate() does this already, so we don't call it here
+
commit_sample_count();
commit_sample_rate();
}
connect(conv_threshold_cb_, SIGNAL(currentIndexChanged(int)),
this, SLOT(on_conv_threshold_changed(int)));
- connect(conv_threshold_cb_, SIGNAL(editTextChanged(const QString)),
+ connect(conv_threshold_cb_, SIGNAL(editTextChanged(const QString&)),
this, SLOT(on_conv_threshold_changed())); // index will be -1
// Add the display type dropdown
connect(&list_, SIGNAL(currentIndexChanged(int)),
this, SIGNAL(value_changed()));
+ connect(&list_, SIGNAL(editTextChanged(const QString&)),
+ this, SIGNAL(value_changed()));
+
connect(&value_, SIGNAL(editingFinished()),
this, SIGNAL(value_changed()));
show_none();
}
+void SweepTimingWidget::allow_user_entered_values(bool value)
+{
+ list_.setEditable(value);
+}
+
void SweepTimingWidget::show_none()
{
value_type_ = None;
return (uint64_t)value_.value();
case List:
{
+ if (list_.isEditable()) {
+ uint64_t value;
+ sr_parse_sizestring(list_.currentText().toUtf8().data(), &value);
+ return value;
+ }
+
const int index = list_.currentIndex();
- return (index >= 0) ? list_.itemData(
- index).value<uint64_t>() : 0;
+ return (index >= 0) ? list_.itemData(index).value<uint64_t>() : 0;
}
default:
// Unexpected value type
{
value_.setValue(value);
- int best_match = list_.count() - 1;
- int64_t best_variance = INT64_MAX;
-
- for (int i = 0; i < list_.count(); i++) {
- const int64_t this_variance = abs(
- (int64_t)value - list_.itemData(i).value<int64_t>());
- if (this_variance < best_variance) {
- best_variance = this_variance;
- best_match = i;
+ if (list_.isEditable()) {
+ char *const s = sr_si_string_u64(value, suffix_);
+ list_.lineEdit()->setText(QString::fromUtf8(s));
+ g_free(s);
+ } else {
+ int best_match = list_.count() - 1;
+ int64_t best_variance = INT64_MAX;
+
+ for (int i = 0; i < list_.count(); i++) {
+ const int64_t this_variance = abs(
+ (int64_t)value - list_.itemData(i).value<int64_t>());
+ if (this_variance < best_variance) {
+ best_variance = this_variance;
+ best_match = i;
+ }
}
- }
- list_.setCurrentIndex(best_match);
+ list_.setCurrentIndex(best_match);
+ }
}
} // namespace widgets