# HG changeset patch # User John Donoghue # Date 1427915772 14400 # Node ID f2dea119369e426769e531948ead4c2d3d02fabf # Parent bd97c41cce068030b270e5fcc42e0d883343b3ec Qt Canvas: set selection type to 'open' on double click (Bug #44669) * libgui/graphics/Canvas.cc (canvasMouseDoubleClickEvent): move autoscale if left mouse and zoom,pan.rotate mode call to canvasMousePressEvent and call canvasMousePressEvent on double click. (canvasMousePressEvent) set isdlbclick flag if even type was MouseDlbClickEvent, pass doubleclick to figureSelectionType calls, and if double click on left mouse occured in zoom,rotate,pan mode, then autoscale. diff -r bd97c41cce06 -r f2dea119369e libgui/graphics/Canvas.cc --- a/libgui/graphics/Canvas.cc Wed Apr 01 11:52:16 2015 -0700 +++ b/libgui/graphics/Canvas.cc Wed Apr 01 15:16:12 2015 -0400 @@ -414,60 +414,8 @@ void Canvas::canvasMouseDoubleClickEvent (QMouseEvent* event) { - if (event->buttons () != Qt::LeftButton) - return; - - gh_manager::auto_lock lock; - graphics_object obj = gh_manager::get_object (m_handle); - - if (obj.valid_object ()) - { - graphics_object axesObj; - - Matrix children = obj.get_properties ().get_children (); - octave_idx_type num_children = children.numel (); - - for (int i = 0; i < num_children; i++) - { - graphics_object childObj (gh_manager::get_object (children(i))); - - if (childObj.isa ("axes")) - { - graphics_object go = selectFromAxes (childObj, event->pos ()); - - if (go) - { - axesObj = childObj; - break; - } - } - } - - bool redrawFigure = true; - - if (axesObj) - { - graphics_object figObj (obj.get_ancestor ("figure")); - - if (axesObj.get_properties ().handlevisibility_is ("on")) - { - Utils::properties
(figObj) - .set_currentaxes (axesObj.get_handle ().as_octave_value ()); - - if (pan_enabled (figObj) || rotate_enabled (figObj) - || zoom_enabled (figObj)) - { - axes::properties& ap = - Utils::properties (axesObj); - - autoscale_axes (ap); - } - } - - if (redrawFigure) - redraw (false); - } - } + // same processing as nornal click, but event type is MouseButtonDblClick + canvasMousePressEvent (event); } static double @@ -502,6 +450,8 @@ gh_manager::auto_lock lock; graphics_object obj = gh_manager::get_object (m_handle); + bool isdblclick = (event->type () == QEvent::MouseButtonDblClick); + if (obj.valid_object ()) { graphics_object figObj (obj.get_ancestor ("figure")); @@ -588,7 +538,7 @@ { case NoMode: gh_manager::post_set (figObj.get_handle (), "selectiontype", - Utils::figureSelectionType (event), false); + Utils::figureSelectionType (event, isdblclick), false); updateCurrentPoint (figObj, obj, event); @@ -617,7 +567,21 @@ { bool redraw_figure = true; - if (event->modifiers () == Qt::NoModifier) + if (isdblclick) + { + if (event->button () == Qt::LeftButton) + { + axes::properties& ap = + Utils::properties (axesObj); + + autoscale_axes (ap); + } + else + { + redraw_figure = false; + } + } + else if (event->modifiers () == Qt::NoModifier) { switch (event->buttons ()) { @@ -668,6 +632,7 @@ break; } } + } void