Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix time error in ruler popup menu commands #78

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions pv/views/trace/ruler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ void Ruler::contextMenuEvent(QContextMenuEvent *event)
if (event->isAccepted())
return;

// Save the place of the click in the popup menu
// so that it can be used when a popup menu action is selected
// and needs to know the mouse position in the ruler
context_menu_x_pos_ = event->pos().x();

QMenu *const menu = new QMenu(this);
Expand Down Expand Up @@ -399,12 +402,12 @@ void Ruler::invalidate_tick_position_cache()

void Ruler::on_createMarker()
{
hover_item_ = view_.add_flag(get_absolute_time_from_x_pos(mouse_down_point_.x()));
hover_item_ = view_.add_flag(get_absolute_time_from_x_pos(context_menu_x_pos_));
}

void Ruler::on_setZeroPosition()
{
view_.set_zero_position(get_absolute_time_from_x_pos(mouse_down_point_.x()));
view_.set_zero_position(get_absolute_time_from_x_pos(context_menu_x_pos_));
}

void Ruler::on_resetZeroPosition()
Expand Down
3 changes: 3 additions & 0 deletions pv/views/trace/ruler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ private Q_SLOTS:

shared_ptr<TimeItem> hover_item_;

/**
* @brief Save the place (x only) where the user has clicked to open the popup menu
*/
uint32_t context_menu_x_pos_;
};

Expand Down