Kaynağa Gözat

- fixed the Punch Gerber Tool bug that did not allowed the projects to be loaded or to create a new project. Fixed issue #456
- in Tool Subtract added an option to delete the source objects after a successful operation. Fixed issue #455

Marius Stanciu 5 yıl önce
ebeveyn
işleme
46900d795d
4 değiştirilmiş dosya ile 49 ekleme ve 17 silme
  1. 2 0
      CHANGELOG.md
  2. 9 1
      appDatabase.py
  3. 6 3
      appGUI/preferences/PreferencesUIManager.py
  4. 32 13
      app_Main.py

+ 2 - 0
CHANGELOG.md

@@ -11,6 +11,8 @@ CHANGELOG for FlatCAM beta
 
 - fixed the Punch Gerber Tool bug that did not allowed the projects to be loaded or to create a new project. Fixed issue #456
 - in Tool Subtract added an option to delete the source objects after a successful operation. Fixed issue #455
+- when entering into an Editor now the Project tab is disabled and the Properties tab where the Editor is installed change the text to 'Editor' and the color is set in Red. After exiting the Tab text is reverted to previous state.
+- fixed and issue where the Tab color that was changed in various states of the app was reverted back to a default color 'black'. Now it reverts to whatever color had before therefore being compatible with an usage of black theme
 
 29.10.2020
 

+ 9 - 1
appDatabase.py

@@ -1425,6 +1425,8 @@ class ToolsDB2(QtWidgets.QWidget):
         '''
         self.db_tool_dict = {}
 
+        self.old_color = QtGui.QColor('black')
+
         # ##############################################################################
         # ##############################################################################
         # TOOLS DATABASE UI
@@ -1719,6 +1721,12 @@ class ToolsDB2(QtWidgets.QWidget):
         self.ui_connect()
 
     def setup_db_ui(self):
+
+        # set the old color for the Tools Database Tab
+        for idx in range(self.app.ui.plot_tab_area.count()):
+            if self.app.ui.plot_tab_area.tabText(idx) == _("Tools Database"):
+                self.old_color = self.app.ui.plot_tab_area.tabBar.tabTextColor(idx)
+
         filename = self.app.tools_database_path()
 
         # load the database tools from the file
@@ -2155,7 +2163,7 @@ class ToolsDB2(QtWidgets.QWidget):
         # Preferences save, update the color of the Tools DB Tab text
         for idx in range(self.app_ui.plot_tab_area.count()):
             if self.app_ui.plot_tab_area.tabText(idx) == _("Tools Database"):
-                self.app_ui.plot_tab_area.tabBar.setTabTextColor(idx, QtGui.QColor('black'))
+                self.app_ui.plot_tab_area.tabBar.setTabTextColor(idx, self.old_color)
                 self.ui.save_db_btn.setStyleSheet("")
 
                 # clean the dictionary and leave only keys of interest

+ 6 - 3
appGUI/preferences/PreferencesUIManager.py

@@ -42,6 +42,8 @@ class PreferencesUIManager:
         # if Preferences are changed in the Edit -> Preferences tab the value will be set to True
         self.preferences_changed_flag = False
 
+        self.old_color = QtGui.QColor('black')
+
         # when adding entries here read the comments in the  method found below named:
         # def app_obj.new_object(self, kind, name, initialize, active=True, fit=True, plot=True)
         self.defaults_form_fields = {
@@ -908,7 +910,7 @@ class PreferencesUIManager:
         # Preferences save, update the color of the Preferences Tab text
         for idx in range(self.ui.plot_tab_area.count()):
             if self.ui.plot_tab_area.tabText(idx) == _("Preferences"):
-                self.ui.plot_tab_area.tabBar.setTabTextColor(idx, QtGui.QColor('black'))
+                self.ui.plot_tab_area.tabBar.setTabTextColor(idx, self.old_color)
 
         # restore the default stylesheet by setting a blank one
         self.ui.pref_apply_button.setStyleSheet("")
@@ -1001,7 +1003,7 @@ class PreferencesUIManager:
             # close the tab and delete it
             for idx in range(self.ui.plot_tab_area.count()):
                 if self.ui.plot_tab_area.tabText(idx) == _("Preferences"):
-                    self.ui.plot_tab_area.tabBar.setTabTextColor(idx, QtGui.QColor('black'))
+                    self.ui.plot_tab_area.tabBar.setTabTextColor(idx, self.old_color)
                     self.ui.plot_tab_area.closeTab(idx)
                     break
 
@@ -1029,7 +1031,7 @@ class PreferencesUIManager:
         # Preferences save, update the color of the Preferences Tab text
         for idx in range(self.ui.plot_tab_area.count()):
             if self.ui.plot_tab_area.tabText(idx) == _("Preferences"):
-                self.ui.plot_tab_area.tabBar.setTabTextColor(idx, QtGui.QColor('black'))
+                self.ui.plot_tab_area.tabBar.setTabTextColor(idx, self.old_color)
                 self.ui.plot_tab_area.closeTab(idx)
                 break
 
@@ -1134,6 +1136,7 @@ class PreferencesUIManager:
 
             for idx in range(self.ui.plot_tab_area.count()):
                 if self.ui.plot_tab_area.tabText(idx) == _("Preferences"):
+                    self.old_color = self.ui.plot_tab_area.tabBar.tabTextColor(idx)
                     self.ui.plot_tab_area.tabBar.setTabTextColor(idx, QtGui.QColor('red'))
 
             self.ui.pref_apply_button.setStyleSheet("QPushButton {color: red;}")

+ 32 - 13
app_Main.py

@@ -1184,6 +1184,9 @@ class App(QtCore.QObject):
 
         self.text_editor_tab = None
 
+        # here store the color of a Tab text before it is changed so it can be restored in the future
+        self.old_tab_text_color = None
+
         # reference for the self.ui.code_editor
         self.reference_code_editor = None
         self.script_code = ''
@@ -2186,7 +2189,7 @@ class App(QtCore.QObject):
         :return: None
         """
         self.defaults.report_usage("object2editor()")
-
+        self.log.debug("######################### Starting the EDITOR ################################")
         # disable the objects menu as it may interfere with the appEditors
         self.ui.menuobjects.setDisabled(True)
 
@@ -2236,7 +2239,6 @@ class App(QtCore.QObject):
 
             # set call source to the Editor we go into
             self.call_source = 'geo_editor'
-
         elif isinstance(edited_object, ExcellonObject):
             # store the Excellon Editor Toolbar visibility before entering in the Editor
             self.exc_editor.toolbar_old_state = True if self.ui.exc_edit_toolbar.isVisible() else False
@@ -2248,7 +2250,6 @@ class App(QtCore.QObject):
 
             # set call source to the Editor we go into
             self.call_source = 'exc_editor'
-
         elif isinstance(edited_object, GerberObject):
             # store the Gerber Editor Toolbar visibility before entering in the Editor
             self.grb_editor.toolbar_old_state = True if self.ui.grb_edit_toolbar.isVisible() else False
@@ -2263,7 +2264,6 @@ class App(QtCore.QObject):
 
             # reset the following variables so the UI is built again after edit
             edited_object.ui_build = False
-
         elif isinstance(edited_object, CNCJobObject):
 
             if self.ui.splitter.sizes()[0] == 0:
@@ -2275,9 +2275,19 @@ class App(QtCore.QObject):
             self.gcode_editor.edit_fcgcode(edited_object)
 
         # make sure that we can't select another object while in Editor Mode:
-        # self.collection.view.setSelectionMode(QtWidgets.QAbstractItemView.NoSelection)
         self.ui.project_frame.setDisabled(True)
 
+        for idx in range(self.ui.notebook.count()):
+            # store the Properties Tab text color here and change the color and text
+            if self.ui.notebook.tabText(idx) == _("Properties"):
+                self.old_tab_text_color = self.ui.notebook.tabBar.tabTextColor(idx)
+                self.ui.notebook.tabBar.setTabTextColor(idx, QtGui.QColor('red'))
+                self.ui.notebook.tabBar.setTabText(idx, _("Editor"))
+
+            # disable the Project Tab
+            if self.ui.notebook.tabText(idx) == _("Project"):
+                self.ui.notebook.tabBar.setTabEnabled(idx, False)
+
         # delete any selection shape that might be active as they are not relevant in Editor
         self.delete_selection_shape()
 
@@ -2302,6 +2312,7 @@ class App(QtCore.QObject):
         :return: None
         """
         self.defaults.report_usage("editor2object()")
+        self.log.debug("######################### Closing the EDITOR ################################")
 
         # re-enable the objects menu that was disabled on entry in Editor mode
         self.ui.menuobjects.setDisabled(False)
@@ -2431,7 +2442,6 @@ class App(QtCore.QObject):
                         return
 
                     self.inform.emit('[selected] %s %s' % (obj_type, _("is updated, returning to App...")))
-
                 elif response == bt_no:
                     # show the Tools Toolbar
                     tools_tb = self.ui.toolbartools
@@ -2498,6 +2508,16 @@ class App(QtCore.QObject):
             if self.ui.splitter.sizes()[0] == 0:
                 self.ui.splitter.setSizes([1, 1])
 
+            for idx in range(self.ui.notebook.count()):
+                # restore the Properties Tab text and color
+                if self.ui.notebook.tabText(idx) == _("Editor"):
+                    self.ui.notebook.tabBar.setTabTextColor(idx, self.old_tab_text_color)
+                    self.ui.notebook.tabBar.setTabText(idx, _("Properties"))
+
+                # enable the Project Tab
+                if self.ui.notebook.tabText(idx) == _("Project"):
+                    self.ui.notebook.tabBar.setTabEnabled(idx, True)
+
             # restore the call_source to app
             self.call_source = 'app'
 
@@ -2506,7 +2526,6 @@ class App(QtCore.QObject):
             self.ui.plot_tab_area.protectTab(0)
 
             # make sure that we reenable the selection on Project Tab after returning from Editor Mode:
-            # self.collection.view.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
             self.ui.project_frame.setDisabled(False)
 
     def get_last_folder(self):
@@ -5598,12 +5617,12 @@ class App(QtCore.QObject):
         # self.ui.show()
 
         self.ui.pref_status_label.setStyleSheet("""
-                                                            QLabel
-                                                            {
-                                                                color: black;
-                                                                background-color: lightseagreen;
-                                                            }
-                                                            """
+                                                QLabel
+                                                {
+                                                    color: black;
+                                                    background-color: lightseagreen;
+                                                }
+                                                """
                                                 )
 
         # detect changes in the preferences