Avoid wrapping driver names etc in about box.
[pulseview.git] / pv / dialogs / settings.cpp
index 068d99b3108ead8c35a5c2dce0e1884a096f6d9d..0104b7c9e32f3de4c146c52ab6326e7fb8b68b9d 100644 (file)
@@ -40,6 +40,8 @@
 #include <libsigrokdecode/libsigrokdecode.h>
 #endif
 
 #include <libsigrokdecode/libsigrokdecode.h>
 #endif
 
+using std::shared_ptr;
+
 namespace pv {
 namespace dialogs {
 
 namespace pv {
 namespace dialogs {
 
@@ -55,7 +57,7 @@ Settings::Settings(DeviceManager &device_manager, QWidget *parent) :
        page_list->setViewMode(QListView::IconMode);
        page_list->setIconSize(QSize(icon_size, icon_size));
        page_list->setMovement(QListView::Static);
        page_list->setViewMode(QListView::IconMode);
        page_list->setIconSize(QSize(icon_size, icon_size));
        page_list->setMovement(QListView::Static);
-       page_list->setMaximumWidth(icon_size + icon_size/2);
+       page_list->setMaximumWidth(icon_size + (icon_size / 2));
        page_list->setSpacing(12);
 
        pages = new QStackedWidget;
        page_list->setSpacing(12);
 
        pages = new QStackedWidget;
@@ -138,9 +140,25 @@ QWidget *Settings::get_view_settings_form(QWidget *parent) const
        connect(show_sampling_points_cb, SIGNAL(stateChanged(int)), this, SLOT(on_view_showSamplingPoints_changed(int)));
        trace_view_layout->addRow(tr("Show data &sampling points"), show_sampling_points_cb);
 
        connect(show_sampling_points_cb, SIGNAL(stateChanged(int)), this, SLOT(on_view_showSamplingPoints_changed(int)));
        trace_view_layout->addRow(tr("Show data &sampling points"), show_sampling_points_cb);
 
+       QCheckBox *show_analog_minor_grid_cb = new QCheckBox();
+       show_analog_minor_grid_cb->setChecked(settings.value(GlobalSettings::Key_View_ShowAnalogMinorGrid).toBool());
+       connect(show_analog_minor_grid_cb, SIGNAL(stateChanged(int)), this, SLOT(on_view_showAnalogMinorGrid_changed(int)));
+       trace_view_layout->addRow(tr("Show analog minor grid in addition to vdiv grid"), show_analog_minor_grid_cb);
+
        return form;
 }
 
        return form;
 }
 
+#ifdef ENABLE_DECODE
+static gint sort_pds(gconstpointer a, gconstpointer b)
+{
+       const struct srd_decoder *sda, *sdb;
+
+       sda = (const struct srd_decoder *)a;
+       sdb = (const struct srd_decoder *)b;
+       return strcmp(sda->id, sdb->id);
+}
+#endif
+
 QWidget *Settings::get_about_page(QWidget *parent) const
 {
 #ifdef ENABLE_DECODE
 QWidget *Settings::get_about_page(QWidget *parent) const
 {
 #ifdef ENABLE_DECODE
@@ -159,49 +177,63 @@ QWidget *Settings::get_about_page(QWidget *parent) const
                QApplication::organizationDomain()));
        version_info->setOpenExternalLinks(true);
 
                QApplication::organizationDomain()));
        version_info->setOpenExternalLinks(true);
 
-       std::shared_ptr<sigrok::Context> context = device_manager_.context();
+       shared_ptr<sigrok::Context> context = device_manager_.context();
 
        QString s;
 
        QString s;
+
+       s.append("<style type=\"text/css\"> tr .id { white-space: pre; padding-right: 5px; } </style>");
+
        s.append("<table>");
 
        s.append("<table>");
 
+       /* Library info */
+       s.append("<tr><td colspan=\"2\"><b>" +
+               tr("Used libraries:") + "</b></td></tr>");
+       s.append(QString("<tr><td><i>%1</i></td><td>%2</td></tr>")
+               .arg(QString("Qt"), qVersion()));
+       s.append(QString("<tr><td><i>%1</i></td><td>%2 (lib version %3)</td></tr>")
+               .arg(QString("libsigrok"), sr_package_version_string_get(), sr_lib_version_string_get()));
+#ifdef ENABLE_DECODE
+       s.append(QString("<tr><td><i>%1</i></td><td>%2 (lib version %3)</td></tr>")
+               .arg(QString("libsigrokdecode"), srd_package_version_string_get(), srd_lib_version_string_get()));
+#endif
+
        /* Set up the supported field */
        s.append("<tr><td colspan=\"2\"><b>" +
        /* Set up the supported field */
        s.append("<tr><td colspan=\"2\"><b>" +
-               tr("Supported hardware drivers:") +
-               "</b></td></tr>");
+               tr("Supported hardware drivers:") + "</b></td></tr>");
        for (auto entry : context->drivers()) {
        for (auto entry : context->drivers()) {
-               s.append(QString("<tr><td><i>%1</i></td><td>%2</td></tr>")
+               s.append(QString("<tr><td class=\"id\"><i>%1</i></td><td>%2</td></tr>")
                        .arg(QString::fromUtf8(entry.first.c_str()),
                                QString::fromUtf8(entry.second->long_name().c_str())));
        }
 
        s.append("<tr><td colspan=\"2\"><b>" +
                        .arg(QString::fromUtf8(entry.first.c_str()),
                                QString::fromUtf8(entry.second->long_name().c_str())));
        }
 
        s.append("<tr><td colspan=\"2\"><b>" +
-               tr("Supported input formats:") +
-               "</b></td></tr>");
+               tr("Supported input formats:") + "</b></td></tr>");
        for (auto entry : context->input_formats()) {
        for (auto entry : context->input_formats()) {
-               s.append(QString("<tr><td><i>%1</i></td><td>%2</td></tr>")
+               s.append(QString("<tr><td class=\"id\"><i>%1</i></td><td>%2</td></tr>")
                        .arg(QString::fromUtf8(entry.first.c_str()),
                                QString::fromUtf8(entry.second->description().c_str())));
        }
 
        s.append("<tr><td colspan=\"2\"><b>" +
                        .arg(QString::fromUtf8(entry.first.c_str()),
                                QString::fromUtf8(entry.second->description().c_str())));
        }
 
        s.append("<tr><td colspan=\"2\"><b>" +
-               tr("Supported output formats:") +
-               "</b></td></tr>");
+               tr("Supported output formats:") + "</b></td></tr>");
        for (auto entry : context->output_formats()) {
        for (auto entry : context->output_formats()) {
-               s.append(QString("<tr><td><i>%1</i></td><td>%2</td></tr>")
+               s.append(QString("<tr><td class=\"id\"><i>%1</i></td><td>%2</td></tr>")
                        .arg(QString::fromUtf8(entry.first.c_str()),
                                QString::fromUtf8(entry.second->description().c_str())));
        }
 
 #ifdef ENABLE_DECODE
        s.append("<tr><td colspan=\"2\"><b>" +
                        .arg(QString::fromUtf8(entry.first.c_str()),
                                QString::fromUtf8(entry.second->description().c_str())));
        }
 
 #ifdef ENABLE_DECODE
        s.append("<tr><td colspan=\"2\"><b>" +
-               tr("Supported protocol decoders:") +
-               "</b></td></tr>");
-       for (const GSList *l = srd_decoder_list(); l; l = l->next) {
+               tr("Supported protocol decoders:") + "</b></td></tr>");
+       GSList *sl = g_slist_copy((GSList *)srd_decoder_list());
+       sl = g_slist_sort(sl, sort_pds);
+       for (const GSList *l = sl; l; l = l->next) {
                dec = (struct srd_decoder *)l->data;
                dec = (struct srd_decoder *)l->data;
-               s.append(QString("<tr><td><i>%1</i></td><td>%2</td></tr>")
+               s.append(QString("<tr><td class=\"id\"><i>%1</i></td><td>%2</td></tr>")
                        .arg(QString::fromUtf8(dec->id),
                                QString::fromUtf8(dec->longname)));
        }
                        .arg(QString::fromUtf8(dec->id),
                                QString::fromUtf8(dec->longname)));
        }
+       g_slist_free(sl);
 #endif
 
        s.append("</table>");
 #endif
 
        s.append("</table>");
@@ -271,5 +303,11 @@ void Settings::on_view_showSamplingPoints_changed(int state)
        settings.setValue(GlobalSettings::Key_View_ShowSamplingPoints, state ? true : false);
 }
 
        settings.setValue(GlobalSettings::Key_View_ShowSamplingPoints, state ? true : false);
 }
 
+void Settings::on_view_showAnalogMinorGrid_changed(int state)
+{
+       GlobalSettings settings;
+       settings.setValue(GlobalSettings::Key_View_ShowAnalogMinorGrid, state ? true : false);
+}
+
 } // namespace dialogs
 } // namespace pv
 } // namespace dialogs
 } // namespace pv