From 65f00ccad71f13ec82fd6e378479b2644bbaee2f Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Wed, 4 Dec 2019 03:24:05 +0200 Subject: [PATCH] - in Preferences added a new button: 'Close' to close the Preferences window without saving --- FlatCAMApp.py | 21 +++++++++++++++++++++ README.md | 1 + flatcamGUI/FlatCAMGUI.py | 9 ++++++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/FlatCAMApp.py b/FlatCAMApp.py index 391701af..23ce3c29 100644 --- a/FlatCAMApp.py +++ b/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() diff --git a/README.md b/README.md index 0bc0f0bd..eb66418b 100644 --- a/README.md +++ b/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 diff --git a/flatcamGUI/FlatCAMGUI.py b/flatcamGUI/FlatCAMGUI.py index e12960e6..3d3e7201 100644 --- a/flatcamGUI/FlatCAMGUI.py +++ b/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 # ########################## # ########################################################################