Explorar o código

- in Preferences added a new button: 'Close' to close the Preferences window without saving

Marius Stanciu %!s(int64=6) %!d(string=hai) anos
pai
achega
65f00ccad7
Modificáronse 3 ficheiros con 30 adicións e 1 borrados
  1. 21 0
      FlatCAMApp.py
  2. 1 0
      README.md
  3. 8 1
      flatcamGUI/FlatCAMGUI.py

+ 21 - 0
FlatCAMApp.py

@@ -1866,6 +1866,7 @@ class App(QtCore.QObject):
         # Preferences Plot Area TAB
         self.ui.pref_save_button.clicked.connect(lambda: self.on_save_button(save_to_file=True))
         self.ui.pref_apply_button.clicked.connect(lambda: self.on_save_button(save_to_file=False))
+        self.ui.pref_close_button.clicked.connect(self.on_pref_close_button)
 
         self.ui.pref_import_button.clicked.connect(self.on_import_preferences)
         self.ui.pref_export_button.clicked.connect(self.on_export_preferences)
@@ -6950,6 +6951,26 @@ class App(QtCore.QObject):
         # This will write the setting to the platform specific storage.
         del settgs
 
+    def on_pref_close_button(self):
+        # Preferences saved, update flag
+        self.preferences_changed_flag = False
+        try:
+            self.ui.plot_tab_area.tab_closed_signal.disconnect(self.on_plot_area_tab_closed)
+        except TypeError:
+            pass
+
+        self.defaults_write_form()
+
+        # 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.closeTab(idx)
+                break
+
+        self.inform.emit('%s' % _("Preferences closed without saving."))
+        self.ui.plot_tab_area.tab_closed_signal.connect(self.on_plot_area_tab_closed)
+
     def on_tool_add_keypress(self):
         # ## Current application units in Upper Case
         self.units = self.defaults['units'].upper()

+ 1 - 0
README.md

@@ -12,6 +12,7 @@ CAD program, and create G-Code for Isolation routing.
 4.12.2019 
 
 - made sure that if an older preferences file is detected then there are no errors and only the parameters that are currently active are loaded; the factory defaults file is deleted and recreated in the new format
+- in Preferences added a new button: 'Close' to close the Preferences window without saving
 
 3.12.2019
 

+ 8 - 1
flatcamGUI/FlatCAMGUI.py

@@ -1092,13 +1092,20 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
         self.pref_tab_bottom_layout_2.addWidget(self.pref_apply_button)
 
         self.pref_save_button = QtWidgets.QPushButton()
-        self.pref_save_button.setText(_("Save Preferences"))
+        self.pref_save_button.setText(_("Save"))
         self.pref_save_button.setMinimumWidth(130)
         self.pref_save_button.setToolTip(
             _("Save the current settings in the 'current_defaults' file\n"
               "which is the file storing the working default preferences."))
         self.pref_tab_bottom_layout_2.addWidget(self.pref_save_button)
 
+        self.pref_close_button = QtWidgets.QPushButton()
+        self.pref_close_button.setText(_("Cancel"))
+        self.pref_close_button.setMinimumWidth(130)
+        self.pref_close_button.setToolTip(
+            _("Will not save the changes and will close the preferences window."))
+        self.pref_tab_bottom_layout_2.addWidget(self.pref_close_button)
+
         # ########################################################################
         # #################### SHORTCUT LIST AREA Tab # ##########################
         # ########################################################################