Просмотр исходного кода

- 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.

Marius Stanciu 6 лет назад
Родитель
Сommit
6d9d29a689
3 измененных файлов с 26 добавлено и 9 удалено
  1. 14 8
      FlatCAMApp.py
  2. 4 0
      README.md
  3. 8 1
      flatcamGUI/FlatCAMGUI.py

+ 14 - 8
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

+ 4 - 0
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

+ 8 - 1
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':