From 6d9d29a6891075583cbd272d68d6ed16c5450e8c Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Tue, 3 Dec 2019 05:31:33 +0200 Subject: [PATCH] - in Preferences added an Apply button which apply the modified preferences but does not save to a file, minimizing the file IO operations; CTRL+S key combo does the Apply now. --- FlatCAMApp.py | 22 ++++++++++++++-------- README.md | 4 ++++ flatcamGUI/FlatCAMGUI.py | 9 ++++++++- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/FlatCAMApp.py b/FlatCAMApp.py index 31d3b73e..efd2a269 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -1856,7 +1856,9 @@ class App(QtCore.QObject): self.ui.popmenu_properties.triggered.connect(self.obj_properties) # Preferences Plot Area TAB - self.ui.pref_save_button.clicked.connect(self.on_save_button) + 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_import_button.clicked.connect(self.on_import_preferences) self.ui.pref_export_button.clicked.connect(self.on_export_preferences) self.ui.pref_open_button.clicked.connect(self.on_preferences_open_folder) @@ -5731,7 +5733,7 @@ class App(QtCore.QObject): self.defaults["units"] = new_units # save the defaults to file, some may assume that the conversion is enough and it's not - self.on_save_button() + self.on_save_button(save_to_file=True) self.should_we_save = True @@ -6857,8 +6859,8 @@ class App(QtCore.QObject): else: self.ui.cncjob_defaults_form.cncjob_adv_opt_group.toolchange_text.insertPlainText('%%%s%%' % signal_text) - def on_save_button(self): - log.debug("App.on_save_button() --> Saving preferences to file.") + def on_save_button(self, save_to_file=True): + log.debug("App.on_save_button() --> Applying preferences to file.") # Preferences saved, update flag self.preferences_changed_flag = False @@ -6868,9 +6870,13 @@ class App(QtCore.QObject): if self.ui.plot_tab_area.tabText(idx) == _("Preferences"): self.ui.plot_tab_area.tabBar.setTabTextColor(idx, QtGui.QColor('black')) - self.save_defaults(silent=False) - # load the defaults so they are updated into the app - self.load_defaults(filename='current_defaults') + self.inform.emit('%s' % _("Preferences applied.")) + + if save_to_file: + self.save_defaults(silent=False) + # load the defaults so they are updated into the app + self.load_defaults(filename='current_defaults') + # Re-fresh project options self.on_options_app2project() @@ -7689,7 +7695,7 @@ class App(QtCore.QObject): response = msgbox.clickedButton() if response == bt_yes: - self.on_save_button() + self.on_save_button(save_to_file=True) self.inform.emit('[success] %s' % _("Preferences saved.")) else: self.preferences_changed_flag = False diff --git a/README.md b/README.md index bee864e1..286ba9ca 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,10 @@ CAD program, and create G-Code for Isolation routing. ================================================= +3.12.2019 + +- in Preferences added an Apply button which apply the modified preferences but does not save to a file, minimizing the file IO operations; CTRL+S key combo does the Apply now. + 2.12.2019 - fixed issue #343; updated the Image Tool diff --git a/flatcamGUI/FlatCAMGUI.py b/flatcamGUI/FlatCAMGUI.py index 9ebe045f..e12960e6 100644 --- a/flatcamGUI/FlatCAMGUI.py +++ b/flatcamGUI/FlatCAMGUI.py @@ -1084,6 +1084,13 @@ class FlatCAMGUI(QtWidgets.QMainWindow): self.pref_tab_bottom_layout_2.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.pref_tab_bottom_layout.addLayout(self.pref_tab_bottom_layout_2) + self.pref_apply_button = FCButton() + self.pref_apply_button.setText(_("Apply")) + self.pref_apply_button.setMinimumWidth(130) + self.pref_apply_button.setToolTip( + _("Apply the current preferences without saving to a file.")) + 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.setMinimumWidth(130) @@ -2427,7 +2434,7 @@ class FlatCAMGUI(QtWidgets.QMainWindow): if key == QtCore.Qt.Key_S: widget_name = self.plot_tab_area.currentWidget().objectName() if widget_name == 'preferences_tab': - self.app.on_save_button() + self.app.on_save_button(save_to_file=False) return if widget_name == 'database_tab':