]> sigrok.org Git - pulseview.git/blobdiff - pv/dialogs/settings.cpp
Settings: Only show initial pin config UI elements if enabled
[pulseview.git] / pv / dialogs / settings.cpp
index 5e2be818c34c60f3634c976f503a12c635728764..310b80e2147d6835ded84b10589daa4dbb89a6b8 100644 (file)
@@ -101,6 +101,17 @@ void Settings::create_pages()
        viewButton->setTextAlignment(Qt::AlignHCenter);
        viewButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
 
+#ifdef ENABLE_DECODE
+       // Decoder page
+       pages->addWidget(get_decoder_settings_form(pages));
+
+       QListWidgetItem *decoderButton = new QListWidgetItem(page_list);
+       decoderButton->setIcon(QIcon(":/icons/add-decoder.svg"));
+       decoderButton->setText(tr("Decoders"));
+       decoderButton->setTextAlignment(Qt::AlignHCenter);
+       decoderButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+#endif
+
        // About page
        pages->addWidget(get_about_page(pages));
 
@@ -153,6 +164,32 @@ QWidget *Settings::get_view_settings_form(QWidget *parent) const
        return form;
 }
 
+QWidget *Settings::get_decoder_settings_form(QWidget *parent) const
+{
+#ifdef ENABLE_DECODE
+       GlobalSettings settings;
+
+       QWidget *form = new QWidget(parent);
+       QVBoxLayout *form_layout = new QVBoxLayout(form);
+
+       // Decoder settings
+       QGroupBox *decoder_group = new QGroupBox(tr("Decoders"));
+       form_layout->addWidget(decoder_group);
+
+       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;
+#endif
+}
+
 #ifdef ENABLE_DECODE
 static gint sort_pds(gconstpointer a, gconstpointer b)
 {
@@ -251,6 +288,7 @@ QWidget *Settings::get_about_page(QWidget *parent) const
 #endif
 
        /* Set up the supported field */
+       s.append("<tr><td colspan=\"2\"></td></tr>");
        s.append("<tr><td colspan=\"2\"><b>" +
                tr("Supported hardware drivers:") + "</b></td></tr>");
        for (auto entry : context->drivers()) {
@@ -259,6 +297,7 @@ QWidget *Settings::get_about_page(QWidget *parent) const
                                QString::fromUtf8(entry.second->long_name().c_str())));
        }
 
+       s.append("<tr><td colspan=\"2\"></td></tr>");
        s.append("<tr><td colspan=\"2\"><b>" +
                tr("Supported input formats:") + "</b></td></tr>");
        for (auto entry : context->input_formats()) {
@@ -267,6 +306,7 @@ QWidget *Settings::get_about_page(QWidget *parent) const
                                QString::fromUtf8(entry.second->description().c_str())));
        }
 
+       s.append("<tr><td colspan=\"2\"></td></tr>");
        s.append("<tr><td colspan=\"2\"><b>" +
                tr("Supported output formats:") + "</b></td></tr>");
        for (auto entry : context->output_formats()) {
@@ -276,6 +316,7 @@ QWidget *Settings::get_about_page(QWidget *parent) const
        }
 
 #ifdef ENABLE_DECODE
+       s.append("<tr><td colspan=\"2\"></td></tr>");
        s.append("<tr><td colspan=\"2\"><b>" +
                tr("Supported protocol decoders:") + "</b></td></tr>");
        GSList *sl = g_slist_copy((GSList *)srd_decoder_list());
@@ -362,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