- fixed issue when doing th CTRL (or SHIFT) + LMB, the focus is automatically moved to Project Tab
- further work in internationalization, added a fallback to English language in case there is no translation for a string
This commit is contained in:
@@ -10,9 +10,16 @@ import FlatCAMTranslation as fcTranslate
|
||||
fcTranslate.apply_language('ToolMove')
|
||||
|
||||
|
||||
def _tr(text):
|
||||
try:
|
||||
return _(text)
|
||||
except:
|
||||
return text
|
||||
|
||||
|
||||
class ToolMove(FlatCAMTool):
|
||||
|
||||
toolName = _("Move")
|
||||
toolName = _tr("Move")
|
||||
|
||||
def __init__(self, app):
|
||||
FlatCAMTool.__init__(self, app)
|
||||
@@ -67,14 +74,14 @@ class ToolMove(FlatCAMTool):
|
||||
self.app.command_active = "Move"
|
||||
|
||||
if self.app.collection.get_selected():
|
||||
self.app.inform.emit(_("MOVE: Click on the Start point ..."))
|
||||
self.app.inform.emit(_tr("MOVE: Click on the Start point ..."))
|
||||
# draw the selection box
|
||||
self.draw_sel_bbox()
|
||||
else:
|
||||
self.setVisible(False)
|
||||
# signal that there is no command active
|
||||
self.app.command_active = None
|
||||
self.app.inform.emit(_("[WARNING_NOTCL] MOVE action cancelled. No object(s) to move."))
|
||||
self.app.inform.emit(_tr("[WARNING_NOTCL] MOVE action cancelled. No object(s) to move."))
|
||||
|
||||
def on_left_click(self, event):
|
||||
# mouse click will be accepted only if the left button is clicked
|
||||
@@ -96,7 +103,7 @@ class ToolMove(FlatCAMTool):
|
||||
else:
|
||||
self.point2 = copy(self.point1)
|
||||
self.point1 = pos
|
||||
self.app.inform.emit(_("MOVE: Click on the Destination point ..."))
|
||||
self.app.inform.emit(_tr("MOVE: Click on the Destination point ..."))
|
||||
|
||||
if self.clicked_move == 1:
|
||||
try:
|
||||
@@ -114,14 +121,14 @@ class ToolMove(FlatCAMTool):
|
||||
dx = pos[0] - self.point1[0]
|
||||
dy = pos[1] - self.point1[1]
|
||||
|
||||
proc = self.app.proc_container.new(_("Moving ..."))
|
||||
proc = self.app.proc_container.new(_tr("Moving ..."))
|
||||
|
||||
def job_move(app_obj):
|
||||
obj_list = self.app.collection.get_selected()
|
||||
|
||||
try:
|
||||
if not obj_list:
|
||||
self.app.inform.emit(_("[WARNING_NOTCL] No object(s) selected."))
|
||||
self.app.inform.emit(_tr("[WARNING_NOTCL] No object(s) selected."))
|
||||
return "fail"
|
||||
else:
|
||||
for sel_obj in obj_list:
|
||||
@@ -144,13 +151,13 @@ class ToolMove(FlatCAMTool):
|
||||
# self.app.collection.set_active(sel_obj.options['name'])
|
||||
except Exception as e:
|
||||
proc.done()
|
||||
self.app.inform.emit(_('[ERROR_NOTCL] '
|
||||
self.app.inform.emit(_tr('[ERROR_NOTCL] '
|
||||
'ToolMove.on_left_click() --> %s') % str(e))
|
||||
return "fail"
|
||||
proc.done()
|
||||
# delete the selection bounding box
|
||||
self.delete_shape()
|
||||
self.app.inform.emit(_('[success]%s object was moved ...') %
|
||||
self.app.inform.emit(_tr('[success]%s object was moved ...') %
|
||||
str(sel_obj.kind).capitalize())
|
||||
|
||||
self.app.worker_task.emit({'fcn': job_move, 'params': [self]})
|
||||
@@ -160,7 +167,7 @@ class ToolMove(FlatCAMTool):
|
||||
return
|
||||
|
||||
except TypeError:
|
||||
self.app.inform.emit(_('[ERROR_NOTCL] '
|
||||
self.app.inform.emit(_tr('[ERROR_NOTCL] '
|
||||
'ToolMove.on_left_click() --> Error when mouse left click.'))
|
||||
return
|
||||
|
||||
@@ -188,7 +195,7 @@ class ToolMove(FlatCAMTool):
|
||||
def on_key_press(self, event):
|
||||
if event.key == 'escape':
|
||||
# abort the move action
|
||||
self.app.inform.emit(_("[WARNING_NOTCL]Move action cancelled."))
|
||||
self.app.inform.emit(_tr("[WARNING_NOTCL]Move action cancelled."))
|
||||
self.toggle()
|
||||
return
|
||||
|
||||
@@ -200,7 +207,7 @@ class ToolMove(FlatCAMTool):
|
||||
|
||||
obj_list = self.app.collection.get_selected()
|
||||
if not obj_list:
|
||||
self.app.inform.emit(_("[WARNING_NOTCL]Object(s) not selected"))
|
||||
self.app.inform.emit(_tr("[WARNING_NOTCL]Object(s) not selected"))
|
||||
self.toggle()
|
||||
else:
|
||||
# if we have an object selected then we can safely activate the mouse events
|
||||
|
||||
Reference in New Issue
Block a user