- when doing 'Set Origin' the right mouse click will cancel the action

This commit is contained in:
Marius Stanciu
2021-01-22 16:01:36 +02:00
committed by Marius
parent 5b0ec590f3
commit 575e29fcaa
2 changed files with 24 additions and 7 deletions

View File

@@ -14,6 +14,7 @@ CHANGELOG for FlatCAM beta
- fixed minor issue with not having the Cancel option on exiting the GCode Editor through the Toolbar button - fixed minor issue with not having the Cancel option on exiting the GCode Editor through the Toolbar button
- in Gerber Editor fixed the canvas context menu not showing - in Gerber Editor fixed the canvas context menu not showing
- made sure that the Offset fields in the Properties Tab are updated on object: move, origin change, transformations - made sure that the Offset fields in the Properties Tab are updated on object: move, origin change, transformations
- when doing 'Set Origin' the right mouse click will cancel the action
19.01.2021 19.01.2021

View File

@@ -367,8 +367,12 @@ class App(QtCore.QObject):
# Variable to be used for situations when we don't want the LMB click on canvas to auto open the Project Tab # Variable to be used for situations when we don't want the LMB click on canvas to auto open the Project Tab
self.click_noproject = False self.click_noproject = False
# store here the mouse cursor
self.cursor = None self.cursor = None
# while True no canvas context menu will be showen
self.inhibit_context_menu = False
# Variable to store the GCODE that was edited # Variable to store the GCODE that was edited
self.gcode_edited = "" self.gcode_edited = ""
@@ -4976,8 +4980,10 @@ class App(QtCore.QObject):
# and ask him to click on the desired position # and ask him to click on the desired position
self.defaults.report_usage("on_set_origin()") self.defaults.report_usage("on_set_origin()")
def origin_replot(): self.inform.emit(_('Click to set the origin ...'))
self.inhibit_context_menu = True
def origin_replot():
def worker_task(): def worker_task():
with self.proc_container.new('%s...' % _("Plotting")): with self.proc_container.new('%s...' % _("Plotting")):
for obj in self.collection.get_list(): for obj in self.collection.get_list():
@@ -4986,12 +4992,12 @@ class App(QtCore.QObject):
if self.is_legacy: if self.is_legacy:
self.plotcanvas.graph_event_disconnect(self.mp_zc) self.plotcanvas.graph_event_disconnect(self.mp_zc)
else: else:
self.plotcanvas.graph_event_disconnect('mouse_press', self.on_set_zero_click) self.plotcanvas.graph_event_disconnect('mouse_release', self.on_set_zero_click)
self.inhibit_context_menu = False
self.worker_task.emit({'fcn': worker_task, 'params': []}) self.worker_task.emit({'fcn': worker_task, 'params': []})
self.inform.emit(_('Click to set the origin ...')) self.mp_zc = self.plotcanvas.graph_event_connect('mouse_release', self.on_set_zero_click)
self.mp_zc = self.plotcanvas.graph_event_connect('mouse_press', self.on_set_zero_click)
# first disconnect it as it may have been used by something else # first disconnect it as it may have been used by something else
try: try:
@@ -5011,6 +5017,11 @@ class App(QtCore.QObject):
""" """
noplot_sig = noplot noplot_sig = noplot
if self.is_legacy is False:
right_button = 2
else:
right_button = 3
def worker_task(): def worker_task():
with self.proc_container.new(_("Setting Origin...")): with self.proc_container.new(_("Setting Origin...")):
obj_list = self.collection.get_list() obj_list = self.collection.get_list()
@@ -5084,6 +5095,10 @@ class App(QtCore.QObject):
else: else:
worker_task() worker_task()
self.should_we_save = True self.should_we_save = True
elif event is not None and event.button == right_button:
if self.ui.popMenu.mouse_is_panning is False:
self.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled."))
self.inhibit_context_menu = False
def on_move2origin(self, use_thread=True): def on_move2origin(self, use_thread=True):
""" """
@@ -7048,9 +7063,10 @@ class App(QtCore.QObject):
if event.button == right_button and self.ui.popMenu.mouse_is_panning is False: # right click if event.button == right_button and self.ui.popMenu.mouse_is_panning is False: # right click
self.ui.popMenu.mouse_is_panning = False self.ui.popMenu.mouse_is_panning = False
self.cursor = QtGui.QCursor() if self.inhibit_context_menu is False:
self.populate_cmenu_grids() self.cursor = QtGui.QCursor()
self.ui.popMenu.popup(self.cursor.pos()) self.populate_cmenu_grids()
self.ui.popMenu.popup(self.cursor.pos())
# if the released mouse button was LMB then test if we had a right-to-left selection or a left-to-right # if the released mouse button was LMB then test if we had a right-to-left selection or a left-to-right
# selection and then select a type of selection ("enclosing" or "touching") # selection and then select a type of selection ("enclosing" or "touching")