From: Soeren Apel Date: Wed, 18 Oct 2023 23:19:55 +0000 (+0200) Subject: Trace view: Add setting to keep ruler item selected X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=e3faae50d59e2bc6d530a195c15d8a196bc8baf9;p=pulseview.git Trace view: Add setting to keep ruler item selected --- diff --git a/pv/dialogs/settings.cpp b/pv/dialogs/settings.cpp index 1c8a1611..55b7e826 100644 --- a/pv/dialogs/settings.cpp +++ b/pv/dialogs/settings.cpp @@ -351,6 +351,10 @@ 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); + cb = create_checkbox(GlobalSettings::Key_View_KeepRulerItemSelected, + SLOT(on_view_keepRulerItemSelected_changed(int))); + trace_view_layout->addRow(tr("Keep active item on ruler selected when editing popup is closed"), cb); + QSpinBox *snap_distance_sb = new QSpinBox(); snap_distance_sb->setRange(0, 1000); snap_distance_sb->setSuffix(tr(" pixels")); @@ -765,6 +769,12 @@ void Settings::on_view_showHoverMarker_changed(int state) settings.setValue(GlobalSettings::Key_View_ShowHoverMarker, state ? true : false); } +void Settings::on_view_keepRulerItemSelected_changed(int state) +{ + GlobalSettings settings; + settings.setValue(GlobalSettings::Key_View_KeepRulerItemSelected, state ? true : false); +} + void Settings::on_view_snapDistance_changed(int value) { GlobalSettings settings; diff --git a/pv/dialogs/settings.hpp b/pv/dialogs/settings.hpp index c8ba8162..bd3572ff 100644 --- a/pv/dialogs/settings.hpp +++ b/pv/dialogs/settings.hpp @@ -74,6 +74,7 @@ private Q_SLOTS: void on_view_fillSignalHighAreaColor_changed(QColor color); void on_view_showAnalogMinorGrid_changed(int state); void on_view_showHoverMarker_changed(int state); + void on_view_keepRulerItemSelected_changed(int state); void on_view_snapDistance_changed(int value); void on_view_cursorFillColor_changed(QColor color); void on_view_conversionThresholdDispMode_changed(int state); diff --git a/pv/globalsettings.cpp b/pv/globalsettings.cpp index 62393747..ecca21d5 100644 --- a/pv/globalsettings.cpp +++ b/pv/globalsettings.cpp @@ -67,6 +67,7 @@ const QString GlobalSettings::Key_View_ConversionThresholdDispMode = "View_Conve const QString GlobalSettings::Key_View_DefaultDivHeight = "View_DefaultDivHeight"; const QString GlobalSettings::Key_View_DefaultLogicHeight = "View_DefaultLogicHeight"; const QString GlobalSettings::Key_View_ShowHoverMarker = "View_ShowHoverMarker"; +const QString GlobalSettings::Key_View_KeepRulerItemSelected = "View_KeepRulerItemSelected"; const QString GlobalSettings::Key_View_SnapDistance = "View_SnapDistance"; const QString GlobalSettings::Key_View_CursorFillColor = "View_CursorFillColor"; const QString GlobalSettings::Key_View_CursorShowFrequency = "View_CursorShowFrequency"; @@ -152,6 +153,9 @@ void GlobalSettings::set_defaults_where_needed() if (!contains(Key_View_ShowHoverMarker)) setValue(Key_View_ShowHoverMarker, true); + if (!contains(Key_View_KeepRulerItemSelected)) + setValue(Key_View_KeepRulerItemSelected, false); + if (!contains(Key_View_SnapDistance)) setValue(Key_View_SnapDistance, 15); diff --git a/pv/globalsettings.hpp b/pv/globalsettings.hpp index 67922d7a..f6239a6b 100644 --- a/pv/globalsettings.hpp +++ b/pv/globalsettings.hpp @@ -72,6 +72,7 @@ public: static const QString Key_View_DefaultDivHeight; static const QString Key_View_DefaultLogicHeight; static const QString Key_View_ShowHoverMarker; + static const QString Key_View_KeepRulerItemSelected; static const QString Key_View_SnapDistance; static const QString Key_View_CursorFillColor; static const QString Key_View_CursorShowInterval; diff --git a/pv/views/trace/timemarker.cpp b/pv/views/trace/timemarker.cpp index 063e579a..0f390f52 100644 --- a/pv/views/trace/timemarker.cpp +++ b/pv/views/trace/timemarker.cpp @@ -202,7 +202,9 @@ pv::widgets::Popup* TimeMarker::create_popup(QWidget *parent) void TimeMarker::on_popup_closed() { - select(false); + GlobalSettings settings; + if (!settings.value(GlobalSettings::Key_View_KeepRulerItemSelected).toBool()) + select(false); } void TimeMarker::on_value_changed(const pv::util::Timestamp& value)