- overloaded the App inform signal to allow not printing to shell if a second bool parameter is given; modified some GUI messages to use this feature

This commit is contained in:
Marius Stanciu
2020-05-29 14:41:02 +03:00
committed by Marius
parent 527c4126b2
commit 15ec620cae
5 changed files with 36 additions and 28 deletions

View File

@@ -3644,6 +3644,7 @@ class MainGUI(QtWidgets.QMainWindow):
self.shell_dock.hide() self.shell_dock.hide()
self.app.plotcanvas.native.setFocus() self.app.plotcanvas.native.setFocus()
self.shell_status_label.setStyleSheet("") self.shell_status_label.setStyleSheet("")
self.app.inform[str, bool].emit(_("Shell disabled."), False)
else: else:
self.shell_dock.show() self.shell_dock.show()
self.shell_status_label.setStyleSheet(""" self.shell_status_label.setStyleSheet("""
@@ -3653,6 +3654,7 @@ class MainGUI(QtWidgets.QMainWindow):
background-color: lightcoral; background-color: lightcoral;
} }
""") """)
self.app.inform[str, bool].emit(_("Shell enabled."), False)
# I want to take the focus and give it to the Tcl Shell when the Tcl Shell is run # I want to take the focus and give it to the Tcl Shell when the Tcl Shell is run
# self.shell._edit.setFocus() # self.shell._edit.setFocus()

View File

@@ -1185,7 +1185,7 @@ class ObjectCollection(QtCore.QAbstractItemModel):
except Exception: except Exception:
pass pass
if obj_list: if obj_list:
self.app.inform.emit('[selected] %s' % _("All objects are selected.")) self.app.inform[str, bool].emit('[selected] %s' % _("All objects are selected."), False)
else: else:
self.set_all_inactive() self.set_all_inactive()
for act in self.app.ui.menuobjects.actions(): for act in self.app.ui.menuobjects.actions():
@@ -1195,6 +1195,6 @@ class ObjectCollection(QtCore.QAbstractItemModel):
pass pass
if obj_list: if obj_list:
self.app.inform.emit('%s' % _("Objects selection is cleared.")) self.app.inform[str, bool].emit('%s' % _("Objects selection is cleared."), False)
else: else:
self.app.inform.emit('') self.app.inform[str, bool].emit('', False)

View File

@@ -204,7 +204,7 @@ class App(QtCore.QObject):
# Inform the user # Inform the user
# Handled by: # Handled by:
# * App.info() --> Print on the status bar # * App.info() --> Print on the status bar
inform = QtCore.pyqtSignal(str) inform = QtCore.pyqtSignal([str], [str, bool])
app_quit = QtCore.pyqtSignal() app_quit = QtCore.pyqtSignal()
@@ -757,7 +757,9 @@ class App(QtCore.QObject):
# ########################################## Custom signals ################################################ # ########################################## Custom signals ################################################
# signal for displaying messages in status bar # signal for displaying messages in status bar
self.inform.connect(self.info) self.inform[str].connect(self.info)
self.inform[str, bool].connect(self.info)
# signal to be called when the app is quiting # signal to be called when the app is quiting
self.app_quit.connect(self.quit_application, type=Qt.QueuedConnection) self.app_quit.connect(self.quit_application, type=Qt.QueuedConnection)
self.message.connect(lambda: message_dialog(parent=self.ui)) self.message.connect(lambda: message_dialog(parent=self.ui))
@@ -2362,7 +2364,9 @@ class App(QtCore.QObject):
loc = os.path.dirname(__file__) loc = os.path.dirname(__file__)
return loc return loc
def info(self, msg): @QtCore.pyqtSlot(str)
@QtCore.pyqtSlot(str, bool)
def info(self, msg, shell_echo=True):
""" """
Informs the user. Normally on the status bar, optionally Informs the user. Normally on the status bar, optionally
also on the shell. also on the shell.
@@ -2378,6 +2382,7 @@ class App(QtCore.QObject):
msg_ = match.group(2) msg_ = match.group(2)
self.ui.fcinfo.set_status(str(msg_), level=level) self.ui.fcinfo.set_status(str(msg_), level=level)
if shell_echo is True:
if level.lower() == "error": if level.lower() == "error":
self.shell_message(msg, error=True, show=True) self.shell_message(msg, error=True, show=True)
elif level.lower() == "warning": elif level.lower() == "warning":
@@ -2403,7 +2408,7 @@ class App(QtCore.QObject):
# make sure that if the message is to clear the infobar with a space # make sure that if the message is to clear the infobar with a space
# is not printed over and over on the shell # is not printed over and over on the shell
if msg != '': if msg != '' and shell_echo is True:
self.shell_message(msg) self.shell_message(msg)
def on_import_preferences(self): def on_import_preferences(self):
@@ -4120,9 +4125,9 @@ class App(QtCore.QObject):
self.plotcanvas.on_toggle_hud(state=new_state) self.plotcanvas.on_toggle_hud(state=new_state)
if new_state is False: if new_state is False:
self.inform.emit(_("HUD disabled.")) self.inform[str, bool].emit(_("HUD disabled."), False)
else: else:
self.inform.emit(_("HUD enabled.")) self.inform[str, bool].emit(_("HUD enabled."), False)
def on_toggle_grid_lines(self): def on_toggle_grid_lines(self):
self.defaults.report_usage("on_toggle_grd_lines()") self.defaults.report_usage("on_toggle_grd_lines()")
@@ -4211,10 +4216,10 @@ class App(QtCore.QObject):
def on_workspace(self): def on_workspace(self):
if self.ui.general_defaults_form.general_app_set_group.workspace_cb.get_value(): if self.ui.general_defaults_form.general_app_set_group.workspace_cb.get_value():
self.plotcanvas.draw_workspace(workspace_size=self.defaults['global_workspaceT']) self.plotcanvas.draw_workspace(workspace_size=self.defaults['global_workspaceT'])
self.inform.emit(_("Workspace enabled.")) self.inform[str, bool].emit(_("Workspace enabled."), False)
else: else:
self.plotcanvas.delete_workspace() self.plotcanvas.delete_workspace()
self.inform.emit(_("Workspace disabled.")) self.inform[str, bool].emit(_("Workspace disabled."), False)
self.preferencesUiManager.defaults_read_form() self.preferencesUiManager.defaults_read_form()
# self.save_defaults(silent=True) # self.save_defaults(silent=True)
@@ -4399,13 +4404,13 @@ class App(QtCore.QObject):
while self.collection.get_selected(): while self.collection.get_selected():
self.delete_first_selected() self.delete_first_selected()
self.inform.emit('%s...' % _("Object(s) deleted"))
# make sure that the selection shape is deleted, too # make sure that the selection shape is deleted, too
self.delete_selection_shape() self.delete_selection_shape()
# if there are no longer objects delete also the exclusion areas shapes # if there are no longer objects delete also the exclusion areas shapes
if not self.collection.get_list(): if not self.collection.get_list():
self.exc_areas.clear_shapes() self.exc_areas.clear_shapes()
self.inform.emit('%s...' % _("Object(s) deleted"))
else: else:
self.inform.emit('[ERROR_NOTCL] %s' % _("Failed. No object(s) selected...")) self.inform.emit('[ERROR_NOTCL] %s' % _("Failed. No object(s) selected..."))
else: else:

View File

@@ -14,6 +14,7 @@ CHANGELOG for FlatCAM beta
- some changes in the UI; added in the status bar an icon to control the Shell Dock - some changes in the UI; added in the status bar an icon to control the Shell Dock
- clicking on the activity icon will replot all objects - clicking on the activity icon will replot all objects
- optimized UI in Tool Isolation - optimized UI in Tool Isolation
- overloaded the App inform signal to allow not printing to shell if a second bool parameter is given; modified some GUI messages to use this feature
28.05.2020 28.05.2020

View File

@@ -572,7 +572,7 @@ class ExclusionAreas(QtCore.QObject):
AppTool.delete_moving_selection_shape(self) AppTool.delete_moving_selection_shape(self)
self.app.delete_selection_shape() self.app.delete_selection_shape()
AppTool.delete_tool_selection_shape(self, shapes_storage=self.exclusion_shapes) AppTool.delete_tool_selection_shape(self, shapes_storage=self.exclusion_shapes)
self.app.inform.emit('[success] %s' % _("All exclusion zones deleted.")) self.app.inform.emit('%s' % _("All exclusion zones deleted."))
def delete_sel_shapes(self, idxs): def delete_sel_shapes(self, idxs):
""" """
@@ -621,7 +621,7 @@ class ExclusionAreas(QtCore.QObject):
""") """)
self.cnc_button.setToolTip('%s' % _("Generate the CNC Job object.")) self.cnc_button.setToolTip('%s' % _("Generate the CNC Job object."))
self.app.inform.emit('[success] %s' % _("All exclusion zones deleted.")) self.app.inform.emit('%s' % _("All exclusion zones deleted."))
def travel_coordinates(self, start_point, end_point, tooldia): def travel_coordinates(self, start_point, end_point, tooldia):
""" """