فهرست منبع

- fixed issue with not using the current units in the tool tables after unit conversion
- after unit conversion from Preferences, the default values are automatically saved by the app

Marius Stanciu 6 سال پیش
والد
کامیت
338f12707d
3فایلهای تغییر یافته به همراه28 افزوده شده و 2 حذف شده
  1. 11 1
      FlatCAMApp.py
  2. 12 1
      FlatCAMObj.py
  3. 5 0
      README.md

+ 11 - 1
FlatCAMApp.py

@@ -3873,6 +3873,9 @@ class App(QtCore.QObject):
                 scale_defaults(factor)
                 self.defaults_write_form(fl_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.should_we_save = True
 
             # change this only if the workspace is active
@@ -3918,12 +3921,17 @@ class App(QtCore.QObject):
         self.defaults_read_form()
 
     def on_toggle_units_click(self):
-        self.ui.general_defaults_form.general_app_group.units_radio.activated_custom.disconnect()
+        try:
+            self.ui.general_defaults_form.general_app_group.units_radio.activated_custom.disconnect()
+        except TypeError:
+            pass
+
         if self.defaults["units"] == 'MM':
             self.ui.general_defaults_form.general_app_group.units_radio.set_value("IN")
         else:
             self.ui.general_defaults_form.general_app_group.units_radio.set_value("MM")
         self.on_toggle_units(no_pref=True)
+
         self.ui.general_defaults_form.general_app_group.units_radio.activated_custom.connect(
             lambda: self.on_toggle_units(no_pref=False))
 
@@ -4528,6 +4536,8 @@ class App(QtCore.QObject):
             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.")
+
         self.save_defaults(silent=False)
         # load the defaults so they are updated into the app
         self.load_defaults(filename='current_defaults')

+ 12 - 1
FlatCAMObj.py

@@ -93,7 +93,8 @@ class FlatCAMObj(QtCore.QObject):
         self.isHovering = False
         self.notHovering = True
 
-        self.units = 'IN'
+        # self.units = 'IN'
+        self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper()
 
         # assert isinstance(self.ui, ObjectUI)
         # self.ui.name_entry.returnPressed.connect(self.on_name_activate)
@@ -1787,6 +1788,8 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
     def build_ui(self):
         FlatCAMObj.build_ui(self)
 
+        self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper()
+
         try:
             # if connected, disconnect the signal from the slot on item_changed as it creates issues
             self.ui.tools_table.itemChanged.disconnect()
@@ -1993,6 +1996,8 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
 
         FlatCAMApp.App.log.debug("FlatCAMExcellon.set_ui()")
 
+        self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper()
+
         self.form_fields.update({
             "plot": self.ui.plot_cb,
             "solid": self.ui.solid_cb,
@@ -2089,6 +2094,8 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
         self.ui.tools_table.itemChanged.disconnect()
         # self.tools_table_exc.selectionModel().currentChanged.disconnect()
 
+        self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper()
+
         self.is_modified = True
 
         row_of_item_changed = self.ui.tools_table.currentRow()
@@ -3027,6 +3034,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
         self.ui_disconnect()
         FlatCAMObj.build_ui(self)
 
+        self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper()
+
         offset = 0
         tool_idx = 0
 
@@ -3518,6 +3527,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
     def on_tool_add(self, dia=None):
         self.ui_disconnect()
 
+        self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value().upper()
+
         # if a Tool diameter entered is a char instead a number the final message of Tool adding is changed
         # because the Default value for Tool is used.
         change_message = False

+ 5 - 0
README.md

@@ -9,6 +9,11 @@ CAD program, and create G-Code for Isolation routing.
 
 =================================================
 
+28.07.2019
+
+- fixed issue with not using the current units in the tool tables after unit conversion
+- after unit conversion from Preferences, the default values are automatically saved by the app
+
 20.07.2019
 
 - updated the CutOut tool so it will work on single PCB Gerbers or on PCB panel Gerbers