Skip to content

Commit

Permalink
Trace view: Add setting to keep ruler item selected
Browse files Browse the repository at this point in the history
  • Loading branch information
abraxa committed Oct 18, 2023
1 parent 5f0ea35 commit e3faae5
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
10 changes: 10 additions & 0 deletions pv/dialogs/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions pv/dialogs/settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions pv/globalsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions pv/globalsettings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class GlobalSettings : public QSettings
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;
Expand Down
4 changes: 3 additions & 1 deletion pv/views/trace/timemarker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e3faae5

Please sign in to comment.