From: Soeren Apel Date: Thu, 8 Jun 2017 20:08:19 +0000 (+0200) Subject: Settings: Only show initial pin config UI elements if enabled X-Git-Tag: pulseview-0.4.0~18 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=1cc1c8dec120ed6d98071f939ea435d85ee853bf;p=pulseview.git Settings: Only show initial pin config UI elements if enabled --- diff --git a/pv/dialogs/settings.cpp b/pv/dialogs/settings.cpp index 8a3aef9c..310b80e2 100644 --- a/pv/dialogs/settings.cpp +++ b/pv/dialogs/settings.cpp @@ -179,6 +179,11 @@ QWidget *Settings::get_decoder_settings_form(QWidget *parent) const QFormLayout *decoder_layout = new QFormLayout(); decoder_group->setLayout(decoder_layout); + QCheckBox *initial_state_configurable_cb = new QCheckBox(); + initial_state_configurable_cb->setChecked(settings.value(GlobalSettings::Key_Dec_InitialStateConfigurable).toBool()); + connect(initial_state_configurable_cb, SIGNAL(stateChanged(int)), this, SLOT(on_dec_initialStateConfigurable_changed(int))); + decoder_layout->addRow(tr("Allow configuration of &initial signal state"), initial_state_configurable_cb); + return form; #else (void)parent; @@ -398,5 +403,11 @@ void Settings::on_view_showAnalogMinorGrid_changed(int state) settings.setValue(GlobalSettings::Key_View_ShowAnalogMinorGrid, state ? true : false); } +void Settings::on_dec_initialStateConfigurable_changed(int state) +{ + GlobalSettings settings; + settings.setValue(GlobalSettings::Key_Dec_InitialStateConfigurable, state ? true : false); +} + } // namespace dialogs } // namespace pv diff --git a/pv/dialogs/settings.hpp b/pv/dialogs/settings.hpp index 40b2a56a..bc6542d3 100644 --- a/pv/dialogs/settings.hpp +++ b/pv/dialogs/settings.hpp @@ -53,6 +53,7 @@ private Q_SLOTS: void on_view_stickyScrolling_changed(int state); void on_view_showSamplingPoints_changed(int state); void on_view_showAnalogMinorGrid_changed(int state); + void on_dec_initialStateConfigurable_changed(int state); private: DeviceManager &device_manager_; diff --git a/pv/globalsettings.cpp b/pv/globalsettings.cpp index 925c48e1..0eff1915 100644 --- a/pv/globalsettings.cpp +++ b/pv/globalsettings.cpp @@ -30,6 +30,7 @@ const QString GlobalSettings::Key_View_ColouredBG = "View_ColouredBG"; const QString GlobalSettings::Key_View_StickyScrolling = "View_StickyScrolling"; const QString GlobalSettings::Key_View_ShowSamplingPoints = "View_ShowSamplingPoints"; const QString GlobalSettings::Key_View_ShowAnalogMinorGrid = "View_ShowAnalogMinorGrid"; +const QString GlobalSettings::Key_Dec_InitialStateConfigurable = "Dec_InitialStateConfigurable"; multimap< QString, function > GlobalSettings::callbacks_; bool GlobalSettings::tracking_ = false; diff --git a/pv/globalsettings.hpp b/pv/globalsettings.hpp index 1c07c308..930bb5bb 100644 --- a/pv/globalsettings.hpp +++ b/pv/globalsettings.hpp @@ -43,6 +43,7 @@ public: static const QString Key_View_StickyScrolling; static const QString Key_View_ShowSamplingPoints; static const QString Key_View_ShowAnalogMinorGrid; + static const QString Key_Dec_InitialStateConfigurable; public: GlobalSettings(); diff --git a/pv/view/decodetrace.cpp b/pv/view/decodetrace.cpp index ec441df4..89d335d7 100644 --- a/pv/view/decodetrace.cpp +++ b/pv/view/decodetrace.cpp @@ -40,6 +40,7 @@ extern "C" { #include "decodetrace.hpp" +#include #include #include #include @@ -781,6 +782,7 @@ void DecodeTrace::create_decoder_form(int index, QFormLayout *form) { const GSList *l; + GlobalSettings settings; assert(dec); const srd_decoder *const decoder = dec->decoder(); @@ -825,6 +827,9 @@ void DecodeTrace::create_decoder_form(int index, hlayout->addWidget(combo); hlayout->addWidget(combo_initial_pin); + if (!settings.value(GlobalSettings::Key_Dec_InitialStateConfigurable).toBool()) + combo_initial_pin->hide(); + decoder_form->addRow(tr("%1 (%2) *") .arg(QString::fromUtf8(pdch->name), QString::fromUtf8(pdch->desc)), hlayout); @@ -850,6 +855,9 @@ void DecodeTrace::create_decoder_form(int index, hlayout->addWidget(combo); hlayout->addWidget(combo_initial_pin); + if (!settings.value(GlobalSettings::Key_Dec_InitialStateConfigurable).toBool()) + combo_initial_pin->hide(); + decoder_form->addRow(tr("%1 (%2)") .arg(QString::fromUtf8(pdch->name), QString::fromUtf8(pdch->desc)), hlayout);