diff --git a/DSView/pv/dock/dsotriggerdock.cpp b/DSView/pv/dock/dsotriggerdock.cpp index 8ef51545..9eda81cd 100644 --- a/DSView/pv/dock/dsotriggerdock.cpp +++ b/DSView/pv/dock/dsotriggerdock.cpp @@ -73,6 +73,7 @@ DsoTriggerDock::DsoTriggerDock(QWidget *parent, SigSession *session) : _holdoff_spinBox->setButtonSymbols(QAbstractSpinBox::NoButtons); _holdoff_slider = new QSlider(Qt::Horizontal, _widget); _holdoff_slider->setRange(0, 999); + connect(_holdoff_slider, SIGNAL(valueChanged(int)), _holdoff_spinBox, 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))); @@ -83,7 +84,6 @@ DsoTriggerDock::DsoTriggerDock(QWidget *parent, SigSession *session) : _margin_slider->setRange(0, 15); connect(_margin_slider, SIGNAL(valueChanged(int)), this, SLOT(margin_changed(int))); - _tSource_label = new QLabel(_widget); _auto_radioButton = new QRadioButton(_widget); _auto_radioButton->setChecked(true); @@ -91,6 +91,7 @@ DsoTriggerDock::DsoTriggerDock(QWidget *parent, SigSession *session) : _ch1_radioButton = new QRadioButton(_widget); _ch0a1_radioButton = new QRadioButton(_widget); _ch0o1_radioButton = new QRadioButton(_widget); + connect(_auto_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())); @@ -101,6 +102,7 @@ DsoTriggerDock::DsoTriggerDock(QWidget *parent, SigSession *session) : _rising_radioButton = new QRadioButton(_widget); _rising_radioButton->setChecked(true); _falling_radioButton = new QRadioButton(_widget); + connect(_rising_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() -{ +{ _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: ")); _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; // opt.init(this); // QPainter p(this); @@ -240,15 +243,16 @@ void DsoTriggerDock::pos_changed(int pos) } void DsoTriggerDock::hold_changed(int hold) -{ +{ (void)hold; int ret; uint64_t holdoff; - if (_holdoff_comboBox->currentData().toDouble() == 1000000000) { + + if (_holdoff_comboBox->currentData().toDouble() == 1000000000) _holdoff_slider->setRange(0, 10); - } else { + else _holdoff_slider->setRange(0, 999); - } + holdoff = _holdoff_slider->value() * _holdoff_comboBox->currentData().toDouble() / 10; ret = _session->get_device()->set_config(NULL, NULL, 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()) { for(QAbstractButton * btn : _source_group->buttons()) @@ -437,18 +441,20 @@ void DsoTriggerDock::init() if (gvar != NULL) { uint64_t holdoff = g_variant_get_uint64(gvar); g_variant_unref(gvar); + for (int i = _holdoff_comboBox->count()-1; i >= 0; i--) { if (holdoff >= _holdoff_comboBox->itemData(i).toDouble()) { _holdoff_comboBox->setCurrentIndex(i); break; } } - if (_holdoff_comboBox->currentData().toDouble() == 1000000000) { + + if (_holdoff_comboBox->currentData().toDouble() == 1000000000) _holdoff_slider->setRange(0, 10); - } else { + else _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_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(hold_changed(int))); diff --git a/DSView/pv/dock/dsotriggerdock.h b/DSView/pv/dock/dsotriggerdock.h index 847194e5..3454601b 100644 --- a/DSView/pv/dock/dsotriggerdock.h +++ b/DSView/pv/dock/dsotriggerdock.h @@ -47,14 +47,12 @@ class DsoTriggerDock : public QScrollArea public: DsoTriggerDock(QWidget *parent, SigSession *session); ~DsoTriggerDock(); - - void paintEvent(QPaintEvent *); - + void device_change(); - - void init(); + void update_view(); private: + void paintEvent(QPaintEvent *e); void changeEvent(QEvent *event); void retranslateUi(); void reStyle(); diff --git a/DSView/pv/dock/triggerdock.cpp b/DSView/pv/dock/triggerdock.cpp index 0876308b..a9f3e4d8 100644 --- a/DSView/pv/dock/triggerdock.cpp +++ b/DSView/pv/dock/triggerdock.cpp @@ -414,7 +414,7 @@ bool TriggerDock::commit_trigger() } } -void TriggerDock::init() +void TriggerDock::update_view() { // TRIGGERPOS //uint16_t pos = ds_trigger_get_pos(); diff --git a/DSView/pv/dock/triggerdock.h b/DSView/pv/dock/triggerdock.h index c02cad3e..d232a6dc 100644 --- a/DSView/pv/dock/triggerdock.h +++ b/DSView/pv/dock/triggerdock.h @@ -63,7 +63,7 @@ public: void paintEvent(QPaintEvent *); - void init(); + void update_view(); QJsonObject get_session(); void set_session(QJsonObject ses); diff --git a/DSView/pv/mainwindow.cpp b/DSView/pv/mainwindow.cpp index 5b44ea9a..3da4f40e 100644 --- a/DSView/pv/mainwindow.cpp +++ b/DSView/pv/mainwindow.cpp @@ -468,13 +468,13 @@ namespace pv { if (_device_agent->get_work_mode() != DSO) { - _trigger_widget->init(); + _trigger_widget->update_view(); _trigger_dock->setVisible(visible); _dso_trigger_dock->setVisible(false); } else { - _dso_trigger_widget->init(); + _dso_trigger_widget->update_view(); _trigger_dock->setVisible(false); _dso_trigger_dock->setVisible(visible); } @@ -616,7 +616,14 @@ namespace pv QJsonDocument sessionDoc = QJsonDocument::fromJson(sdata.toUtf8()); _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) @@ -1458,10 +1465,10 @@ namespace pv _view->status_clear(); _view->reload(); _view->set_device(); - _trigger_widget->init(); + _trigger_widget->update_view(); _trigger_widget->device_updated(); _trig_bar->reload(); - _dso_trigger_widget->init(); + _dso_trigger_widget->update_view(); _measure_widget->reload(); }