Add setting for the snap-to-edge distance
[pulseview.git] / pv / dialogs / settings.cpp
index 4c0715a8b936ae67a61abf2faf08c716c0f3de2c..f0752c0704ef63312ba9114f0649d8b7f954a6c3 100644 (file)
@@ -237,6 +237,15 @@ QWidget *Settings::get_view_settings_form(QWidget *parent) const
                SLOT(on_view_showHoverMarker_changed(int)));
        trace_view_layout->addRow(tr("Highlight mouse cursor using a vertical marker line"), cb);
 
+       QSpinBox *snap_distance_sb = new QSpinBox();
+       snap_distance_sb->setRange(0, 1000);
+       snap_distance_sb->setSuffix(tr(" pixels"));
+       snap_distance_sb->setValue(
+               settings.value(GlobalSettings::Key_View_SnapDistance).toInt());
+       connect(snap_distance_sb, SIGNAL(valueChanged(int)), this,
+               SLOT(on_view_snapDistance_changed(int)));
+       trace_view_layout->addRow(tr("Maximum distance from edges before cursors snap to them"), snap_distance_sb);
+
        QComboBox *thr_disp_mode_cb = new QComboBox();
        thr_disp_mode_cb->addItem(tr("None"), GlobalSettings::ConvThrDispMode_None);
        thr_disp_mode_cb->addItem(tr("Background"), GlobalSettings::ConvThrDispMode_Background);
@@ -268,9 +277,10 @@ QWidget *Settings::get_view_settings_form(QWidget *parent) const
        return form;
 }
 
-QWidget *Settings::get_decoder_settings_form(QWidget *parent) const
+QWidget *Settings::get_decoder_settings_form(QWidget *parent)
 {
 #ifdef ENABLE_DECODE
+       GlobalSettings settings;
        QCheckBox *cb;
 
        QWidget *form = new QWidget(parent);
@@ -287,6 +297,20 @@ QWidget *Settings::get_decoder_settings_form(QWidget *parent) const
                SLOT(on_dec_initialStateConfigurable_changed(int)));
        decoder_layout->addRow(tr("Allow configuration of &initial signal state"), cb);
 
+       // Annotation export settings
+       ann_export_format_ = new QLineEdit();
+       ann_export_format_->setText(
+               settings.value(GlobalSettings::Key_Dec_ExportFormat).toString());
+       connect(ann_export_format_, SIGNAL(textChanged(const QString&)),
+               this, SLOT(on_dec_exportFormat_changed(const QString&)));
+       decoder_layout->addRow(tr("Annotation export format"), ann_export_format_);
+       QLabel *description_1 = new QLabel(tr("%s = sample range; %d: decoder name; %c: row name; %q: use quotations marks"));
+       description_1->setAlignment(Qt::AlignRight);
+       decoder_layout->addRow(description_1);
+       QLabel *description_2 = new QLabel(tr("%1: longest annotation text; %a: all annotation texts"));
+       description_2->setAlignment(Qt::AlignRight);
+       decoder_layout->addRow(description_2);
+
        return form;
 #else
        (void)parent;
@@ -611,6 +635,12 @@ void Settings::on_view_showHoverMarker_changed(int state)
        settings.setValue(GlobalSettings::Key_View_ShowHoverMarker, state ? true : false);
 }
 
+void Settings::on_view_snapDistance_changed(int value)
+{
+       GlobalSettings settings;
+       settings.setValue(GlobalSettings::Key_View_SnapDistance, value);
+}
+
 void Settings::on_view_conversionThresholdDispMode_changed(int state)
 {
        GlobalSettings settings;
@@ -629,12 +659,20 @@ void Settings::on_view_defaultLogicHeight_changed(int value)
        settings.setValue(GlobalSettings::Key_View_DefaultLogicHeight, value);
 }
 
+#ifdef ENABLE_DECODE
 void Settings::on_dec_initialStateConfigurable_changed(int state)
 {
        GlobalSettings settings;
        settings.setValue(GlobalSettings::Key_Dec_InitialStateConfigurable, state ? true : false);
 }
 
+void Settings::on_dec_exportFormat_changed(const QString &text)
+{
+       GlobalSettings settings;
+       settings.setValue(GlobalSettings::Key_Dec_ExportFormat, text);
+}
+#endif
+
 void Settings::on_log_logLevel_changed(int value)
 {
        logging.set_log_level(value);