Преглед на файлове

- 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

Marius Stanciu преди 5 години
родител
ревизия
15ec620cae
променени са 5 файла, в които са добавени 36 реда и са изтрити 28 реда
  1. 2 0
      AppGUI/MainGUI.py
  2. 3 3
      AppObjects/ObjectCollection.py
  3. 28 23
      App_Main.py
  4. 1 0
      CHANGELOG.md
  5. 2 2
      Common.py

+ 2 - 0
AppGUI/MainGUI.py

@@ -3644,6 +3644,7 @@ class MainGUI(QtWidgets.QMainWindow):
             self.shell_dock.hide()
             self.app.plotcanvas.native.setFocus()
             self.shell_status_label.setStyleSheet("")
+            self.app.inform[str, bool].emit(_("Shell disabled."), False)
         else:
             self.shell_dock.show()
             self.shell_status_label.setStyleSheet("""
@@ -3653,6 +3654,7 @@ class MainGUI(QtWidgets.QMainWindow):
                                                       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
             # self.shell._edit.setFocus()

+ 3 - 3
AppObjects/ObjectCollection.py

@@ -1185,7 +1185,7 @@ class ObjectCollection(QtCore.QAbstractItemModel):
                 except Exception:
                     pass
             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:
             self.set_all_inactive()
             for act in self.app.ui.menuobjects.actions():
@@ -1195,6 +1195,6 @@ class ObjectCollection(QtCore.QAbstractItemModel):
                     pass
 
             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:
-                self.app.inform.emit('')
+                self.app.inform[str, bool].emit('', False)

+ 28 - 23
App_Main.py

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

+ 1 - 0
CHANGELOG.md

@@ -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
 - clicking on the activity icon will replot all objects
 - 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
 

+ 2 - 2
Common.py

@@ -572,7 +572,7 @@ class ExclusionAreas(QtCore.QObject):
         AppTool.delete_moving_selection_shape(self)
         self.app.delete_selection_shape()
         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):
         """
@@ -621,7 +621,7 @@ class ExclusionAreas(QtCore.QObject):
                                             """)
             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):
         """