2
0
forked from Ivasoft/DSView

fix: the 'Hold Off Time' can't resotre from file

This commit is contained in:
dreamsourcelabTAI
2023-03-15 16:16:23 +08:00
parent 1fc5df21ed
commit ebd5526d15
5 changed files with 35 additions and 24 deletions

View File

@@ -73,6 +73,7 @@ DsoTriggerDock::DsoTriggerDock(QWidget *parent, SigSession *session) :
_holdoff_spinBox->setButtonSymbols(QAbstractSpinBox::NoButtons); _holdoff_spinBox->setButtonSymbols(QAbstractSpinBox::NoButtons);
_holdoff_slider = new QSlider(Qt::Horizontal, _widget); _holdoff_slider = new QSlider(Qt::Horizontal, _widget);
_holdoff_slider->setRange(0, 999); _holdoff_slider->setRange(0, 999);
connect(_holdoff_slider, SIGNAL(valueChanged(int)), _holdoff_spinBox, SLOT(setValue(int))); connect(_holdoff_slider, SIGNAL(valueChanged(int)), _holdoff_spinBox, SLOT(setValue(int)));
connect(_holdoff_spinBox, SIGNAL(valueChanged(int)), _holdoff_slider, SLOT(setValue(int))); connect(_holdoff_spinBox, SIGNAL(valueChanged(int)), _holdoff_slider, SLOT(setValue(int)));
connect(_holdoff_slider, SIGNAL(valueChanged(int)), this, SLOT(hold_changed(int))); connect(_holdoff_slider, SIGNAL(valueChanged(int)), this, SLOT(hold_changed(int)));
@@ -83,7 +84,6 @@ DsoTriggerDock::DsoTriggerDock(QWidget *parent, SigSession *session) :
_margin_slider->setRange(0, 15); _margin_slider->setRange(0, 15);
connect(_margin_slider, SIGNAL(valueChanged(int)), this, SLOT(margin_changed(int))); connect(_margin_slider, SIGNAL(valueChanged(int)), this, SLOT(margin_changed(int)));
_tSource_label = new QLabel(_widget); _tSource_label = new QLabel(_widget);
_auto_radioButton = new QRadioButton(_widget); _auto_radioButton = new QRadioButton(_widget);
_auto_radioButton->setChecked(true); _auto_radioButton->setChecked(true);
@@ -91,6 +91,7 @@ DsoTriggerDock::DsoTriggerDock(QWidget *parent, SigSession *session) :
_ch1_radioButton = new QRadioButton(_widget); _ch1_radioButton = new QRadioButton(_widget);
_ch0a1_radioButton = new QRadioButton(_widget); _ch0a1_radioButton = new QRadioButton(_widget);
_ch0o1_radioButton = new QRadioButton(_widget); _ch0o1_radioButton = new QRadioButton(_widget);
connect(_auto_radioButton, SIGNAL(clicked()), this, SLOT(source_changed())); connect(_auto_radioButton, SIGNAL(clicked()), this, SLOT(source_changed()));
connect(_ch0_radioButton, SIGNAL(clicked()), this, SLOT(source_changed())); connect(_ch0_radioButton, SIGNAL(clicked()), this, SLOT(source_changed()));
connect(_ch1_radioButton, SIGNAL(clicked()), this, SLOT(source_changed())); connect(_ch1_radioButton, SIGNAL(clicked()), this, SLOT(source_changed()));
@@ -101,6 +102,7 @@ DsoTriggerDock::DsoTriggerDock(QWidget *parent, SigSession *session) :
_rising_radioButton = new QRadioButton(_widget); _rising_radioButton = new QRadioButton(_widget);
_rising_radioButton->setChecked(true); _rising_radioButton->setChecked(true);
_falling_radioButton = new QRadioButton(_widget); _falling_radioButton = new QRadioButton(_widget);
connect(_rising_radioButton, SIGNAL(clicked()), this, SLOT(type_changed())); connect(_rising_radioButton, SIGNAL(clicked()), this, SLOT(type_changed()));
connect(_falling_radioButton, SIGNAL(clicked()), this, SLOT(type_changed())); connect(_falling_radioButton, SIGNAL(clicked()), this, SLOT(type_changed()));
@@ -184,7 +186,7 @@ void DsoTriggerDock::changeEvent(QEvent *event)
} }
void DsoTriggerDock::retranslateUi() void DsoTriggerDock::retranslateUi()
{ {
_position_label->setText(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_TRIGGER_POSITION), "Trigger Position: ")); _position_label->setText(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_TRIGGER_POSITION), "Trigger Position: "));
_holdoff_label->setText(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_HOLD_OFF_TIME), "Hold Off Time: ")); _holdoff_label->setText(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_HOLD_OFF_TIME), "Hold Off Time: "));
_margin_label->setText(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_NOISE_SENSITIVITY), "Noise Sensitivity: ")); _margin_label->setText(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_NOISE_SENSITIVITY), "Noise Sensitivity: "));
@@ -205,8 +207,9 @@ void DsoTriggerDock::reStyle()
} }
void DsoTriggerDock::paintEvent(QPaintEvent *) void DsoTriggerDock::paintEvent(QPaintEvent *e)
{ {
(void*)e;
// QStyleOption opt; // QStyleOption opt;
// opt.init(this); // opt.init(this);
// QPainter p(this); // QPainter p(this);
@@ -240,15 +243,16 @@ void DsoTriggerDock::pos_changed(int pos)
} }
void DsoTriggerDock::hold_changed(int hold) void DsoTriggerDock::hold_changed(int hold)
{ {
(void)hold; (void)hold;
int ret; int ret;
uint64_t holdoff; uint64_t holdoff;
if (_holdoff_comboBox->currentData().toDouble() == 1000000000) {
if (_holdoff_comboBox->currentData().toDouble() == 1000000000)
_holdoff_slider->setRange(0, 10); _holdoff_slider->setRange(0, 10);
} else { else
_holdoff_slider->setRange(0, 999); _holdoff_slider->setRange(0, 999);
}
holdoff = _holdoff_slider->value() * _holdoff_comboBox->currentData().toDouble() / 10; holdoff = _holdoff_slider->value() * _holdoff_comboBox->currentData().toDouble() / 10;
ret = _session->get_device()->set_config(NULL, NULL, ret = _session->get_device()->set_config(NULL, NULL,
SR_CONF_TRIGGER_HOLDOFF, SR_CONF_TRIGGER_HOLDOFF,
@@ -351,7 +355,7 @@ void DsoTriggerDock::device_change()
} }
} }
void DsoTriggerDock::init() void DsoTriggerDock::update_view()
{ {
if (_session->get_device()->is_virtual()) { if (_session->get_device()->is_virtual()) {
for(QAbstractButton * btn : _source_group->buttons()) for(QAbstractButton * btn : _source_group->buttons())
@@ -437,18 +441,20 @@ void DsoTriggerDock::init()
if (gvar != NULL) { if (gvar != NULL) {
uint64_t holdoff = g_variant_get_uint64(gvar); uint64_t holdoff = g_variant_get_uint64(gvar);
g_variant_unref(gvar); g_variant_unref(gvar);
for (int i = _holdoff_comboBox->count()-1; i >= 0; i--) { for (int i = _holdoff_comboBox->count()-1; i >= 0; i--) {
if (holdoff >= _holdoff_comboBox->itemData(i).toDouble()) { if (holdoff >= _holdoff_comboBox->itemData(i).toDouble()) {
_holdoff_comboBox->setCurrentIndex(i); _holdoff_comboBox->setCurrentIndex(i);
break; break;
} }
} }
if (_holdoff_comboBox->currentData().toDouble() == 1000000000) {
if (_holdoff_comboBox->currentData().toDouble() == 1000000000)
_holdoff_slider->setRange(0, 10); _holdoff_slider->setRange(0, 10);
} else { else
_holdoff_slider->setRange(0, 999); _holdoff_slider->setRange(0, 999);
}
_holdoff_spinBox->setValue(holdoff * 10.0/_holdoff_comboBox->currentData().toDouble()); _holdoff_spinBox->setValue(holdoff * 10.0 / _holdoff_comboBox->currentData().toDouble());
} }
connect(_holdoff_slider, SIGNAL(valueChanged(int)), this, SLOT(hold_changed(int))); connect(_holdoff_slider, SIGNAL(valueChanged(int)), this, SLOT(hold_changed(int)));
connect(_holdoff_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(hold_changed(int))); connect(_holdoff_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(hold_changed(int)));

View File

@@ -47,14 +47,12 @@ class DsoTriggerDock : public QScrollArea
public: public:
DsoTriggerDock(QWidget *parent, SigSession *session); DsoTriggerDock(QWidget *parent, SigSession *session);
~DsoTriggerDock(); ~DsoTriggerDock();
void paintEvent(QPaintEvent *);
void device_change(); void device_change();
void update_view();
void init();
private: private:
void paintEvent(QPaintEvent *e);
void changeEvent(QEvent *event); void changeEvent(QEvent *event);
void retranslateUi(); void retranslateUi();
void reStyle(); void reStyle();

View File

@@ -414,7 +414,7 @@ bool TriggerDock::commit_trigger()
} }
} }
void TriggerDock::init() void TriggerDock::update_view()
{ {
// TRIGGERPOS // TRIGGERPOS
//uint16_t pos = ds_trigger_get_pos(); //uint16_t pos = ds_trigger_get_pos();

View File

@@ -63,7 +63,7 @@ public:
void paintEvent(QPaintEvent *); void paintEvent(QPaintEvent *);
void init(); void update_view();
QJsonObject get_session(); QJsonObject get_session();
void set_session(QJsonObject ses); void set_session(QJsonObject ses);

View File

@@ -468,13 +468,13 @@ namespace pv
{ {
if (_device_agent->get_work_mode() != DSO) if (_device_agent->get_work_mode() != DSO)
{ {
_trigger_widget->init(); _trigger_widget->update_view();
_trigger_dock->setVisible(visible); _trigger_dock->setVisible(visible);
_dso_trigger_dock->setVisible(false); _dso_trigger_dock->setVisible(false);
} }
else else
{ {
_dso_trigger_widget->init(); _dso_trigger_widget->update_view();
_trigger_dock->setVisible(false); _trigger_dock->setVisible(false);
_dso_trigger_dock->setVisible(visible); _dso_trigger_dock->setVisible(visible);
} }
@@ -616,7 +616,14 @@ namespace pv
QJsonDocument sessionDoc = QJsonDocument::fromJson(sdata.toUtf8()); QJsonDocument sessionDoc = QJsonDocument::fromJson(sdata.toUtf8());
_protocol_widget->del_all_protocol(); _protocol_widget->del_all_protocol();
return load_session_json(sessionDoc, bDone); int ret = load_session_json(sessionDoc, bDone);
if (ret && _device_agent->get_work_mode() == DSO)
{
_dso_trigger_widget->update_view();
}
return ret;
} }
bool MainWindow::gen_session_json(QJsonObject &sessionVar) bool MainWindow::gen_session_json(QJsonObject &sessionVar)
@@ -1458,10 +1465,10 @@ namespace pv
_view->status_clear(); _view->status_clear();
_view->reload(); _view->reload();
_view->set_device(); _view->set_device();
_trigger_widget->init(); _trigger_widget->update_view();
_trigger_widget->device_updated(); _trigger_widget->device_updated();
_trig_bar->reload(); _trig_bar->reload();
_dso_trigger_widget->init(); _dso_trigger_widget->update_view();
_measure_widget->reload(); _measure_widget->reload();
} }