SLOT(on_scroll_to_end_shortcut_triggered()), nullptr, Qt::WidgetWithChildrenShortcut);
end_shortcut_->setAutoRepeat(false);
+ grab_ruler_left_shortcut_ = new QShortcut(QKeySequence(Qt::Key_1), this);
+ connect(grab_ruler_left_shortcut_, &QShortcut::activated,
+ this, [=]{on_grab_ruler(1);});
+ grab_ruler_left_shortcut_->setAutoRepeat(false);
+
+ grab_ruler_right_shortcut_ = new QShortcut(QKeySequence(Qt::Key_2), this);
+ connect(grab_ruler_right_shortcut_, &QShortcut::activated,
+ this, [=]{on_grab_ruler(2);});
+ grab_ruler_right_shortcut_->setAutoRepeat(false);
+
+ cancel_grab_shortcut_ = new QShortcut(QKeySequence(Qt::Key_Escape), this);
+ connect(cancel_grab_shortcut_, &QShortcut::activated,
+ this, [=]{grabbed_widget_ = nullptr;});
+ cancel_grab_shortcut_->setAutoRepeat(false);
+
// Trigger the initial event manually. The default device has signals
// which were created before this object came into being
signals_changed();
next_flag_text_ = 'A';
trigger_markers_.clear();
hover_widget_ = nullptr;
+ grabbed_widget_ = nullptr;
hover_point_ = QPoint(-1, -1);
scroll_needs_defaults_ = true;
saved_v_offset_ = 0;
update_hover_point();
+ if (grabbed_widget_) {
+ int64_t nearest = get_nearest_level_change(hover_point_);
+ pv::util::Timestamp mouse_time = offset_ + hover_point_.x() * scale_;
+
+ if (nearest == -1) {
+ grabbed_widget_->set_time(mouse_time);
+ } else {
+ grabbed_widget_->set_time(nearest / get_signal_under_mouse_cursor()->base()->get_samplerate());
+ }
+ }
+
} else if (type == QEvent::MouseButtonPress) {
+ grabbed_widget_ = nullptr;
+
const QMouseEvent *const mouse_event = (QMouseEvent*)event;
if ((object == viewport_) && (mouse_event->button() & Qt::LeftButton)) {
// Send event to all trace tree items
viewport_->update();
}
+void View::on_grab_ruler(int ruler_id)
+{
+ if (cursors_shown()) {
+ // Release the grabbed widget if its trigger hotkey was pressed twice
+ if (ruler_id == 1)
+ grabbed_widget_ = (grabbed_widget_ == cursors_->first().get()) ?
+ nullptr : cursors_->first().get();
+ else
+ grabbed_widget_ = (grabbed_widget_ == cursors_->second().get()) ?
+ nullptr : cursors_->second().get();
+
+ if (grabbed_widget_)
+ grabbed_widget_->set_time(offset_ + mapFromGlobal(QCursor::pos()).x() * scale_);
+ }
+}
+
void View::signals_changed()
{
using sigrok::Channel;
void h_scroll_value_changed(int value);
void v_scroll_value_changed();
+ void on_grab_ruler(int ruler_id);
+
void signals_changed();
void capture_state_updated(int state);
QShortcut *zoom_in_shortcut_, *zoom_in_shortcut_2_;
QShortcut *zoom_out_shortcut_, *zoom_out_shortcut_2_;
QShortcut *home_shortcut_, *end_shortcut_;
+ QShortcut *grab_ruler_left_shortcut_, *grab_ruler_right_shortcut_;
+ QShortcut *cancel_grab_shortcut_;
unordered_set< shared_ptr<Signal> > signals_;
vector< shared_ptr<TriggerMarker> > trigger_markers_;
QWidget* hover_widget_;
+ TimeMarker* grabbed_widget_;
QPoint hover_point_;
shared_ptr<Signal> signal_under_mouse_cursor_;
uint16_t snap_distance_;