diff --git a/CHANGELOG.md b/CHANGELOG.md index 61fadf85..bb2ad8f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ CHANGELOG for FlatCAM beta ================================================= +25.08.2021 + +- fixed some issues in the convert_units +- added a new GUI element, a radio button that can change a setting in the self.defaults preferences dict +- made sure that the update of the default properties tab (in the Notebook) is done only for certain keys in self.defaults not for all + 24.08.2021 - using PyQt6 with multi monitors, when the pixel ratio (scaling in WIndows) is different than 1.0 there are visual issues in the 3D canvas - trying to solve by updating the dpi - partial solve diff --git a/appGUI/GUIElements.py b/appGUI/GUIElements.py index cbf1f5f3..3240f455 100644 --- a/appGUI/GUIElements.py +++ b/appGUI/GUIElements.py @@ -109,6 +109,40 @@ class RadioSet(QtWidgets.QWidget): option['radio'].setDisabled(val) +class RadioSetDefaults(RadioSet): + + def __init__(self, choices, dictionary=None, key_spec=None, orientation='horizontal', stretch=None, parent=None): + """ + When a choice is made then the selected value is set in the key key_spec from the dictionary 'dictionary' + The choices are specified as a list of dictionaries containing: + + * 'label': Shown in the UI + * 'value': The value returned is selected + + :param choices: List of choices. See description. + :param orientation: 'horizontal' (default) of 'vertical'. + :param parent: Qt parent widget. + :type choices: list + :param dictionary: + :type dictionary: "dict" + :param key_spec: + :type key_spec: 'str' + """ + + super(RadioSetDefaults, self).__init__(choices=choices, orientation=orientation, stretch=stretch, parent=parent) + self.dictionary = dictionary + self.key_spec = key_spec + + def on_toggle(self, checked): + if checked: + self.group_toggle_fn() + ret_val = str(self.get_value()) + if self.dictionary is not None and self.key_spec is not None: + self.dictionary[self.key_spec] = ret_val + self.activated_custom.emit(ret_val) + return + + # class RadioGroupChoice(QtWidgets.QWidget): # def __init__(self, label_1, label_2, to_check, hide_list, show_list, parent=None): # """ diff --git a/appGUI/preferences/general/GeneralAppPrefGroupUI.py b/appGUI/preferences/general/GeneralAppPrefGroupUI.py index d4fca850..cbef327f 100644 --- a/appGUI/preferences/general/GeneralAppPrefGroupUI.py +++ b/appGUI/preferences/general/GeneralAppPrefGroupUI.py @@ -4,7 +4,7 @@ from PyQt6 import QtWidgets from PyQt6.QtCore import QSettings from appGUI.GUIElements import RadioSet, FCSpinner, FCCheckBox, FCComboBox, FCButton, OptionalInputSection, \ - FCDoubleSpinner, FCLabel, FCGridLayout + FCDoubleSpinner, FCLabel, FCGridLayout, RadioSetDefaults from appGUI.preferences.OptionsGroupUI import OptionsGroupUI import gettext @@ -35,8 +35,9 @@ class GeneralAppPrefGroupUI(OptionsGroupUI): self.unitslabel.setToolTip(_("The default value for the application units.\n" "Whatever is selected here is set every time\n" "FlatCAM is started.")) - self.units_radio = RadioSet([{'label': _('MM'), 'value': 'MM'}, - {'label': _('IN'), 'value': 'IN'}]) + self.units_radio = RadioSetDefaults( + choices=[{'label': _('MM'), 'value': 'MM'}, {'label': _('IN'), 'value': 'IN'}] + ) grid0.addWidget(self.unitslabel, 0, 0) grid0.addWidget(self.units_radio, 0, 1) diff --git a/app_Main.py b/app_Main.py index c89eddda..1f34bd9a 100644 --- a/app_Main.py +++ b/app_Main.py @@ -1396,7 +1396,7 @@ class App(QtCore.QObject): self.file_saved.connect(lambda kind, filename: self.register_save_folder(filename)) # when the defaults dictionary values change - self.defaults.defaults.set_change_callback(callback=self.on_properties_tab_click) + self.defaults.defaults.set_change_callback(callback=self.on_defaults_value_changed) # ########################################################################################################### # ########################################## Standard signals ############################################### @@ -1806,6 +1806,18 @@ class App(QtCore.QObject): def log_path(self): return os.path.join(self.data_path, 'log.txt') + def on_defaults_value_changed(self, key_changed): + # when changing those properties the associated keys change so we get an updated Properties default Tab + if key_changed in [ + "global_grid_lines", "global_grid_snap", "global_axis", "global_workspace", "global_workspaceT", + "global_workspace_orientation", "global_hud" + ]: + self.on_properties_tab_click(index=None) + + # TODO handle changing the units in the Preferences + # if key_changed == "units": + # self.on_toggle_units(no_pref=False) + def on_app_restart(self): # make sure that the Sys Tray icon is hidden before restart otherwise it will @@ -4600,7 +4612,7 @@ class App(QtCore.QObject): if dim in ['tools_mill_tooldia', 'tools_ncc_tools', 'tools_solderpaste_tools', 'tools_iso_tooldia', 'tools_paint_tooldia', 'tools_transform_ref_point', 'tools_cal_toolchange_xy', 'gerber_editor_newdim', 'tools_drill_toolchangexy', 'tools_drill_endxy', - 'geometry_toolchangexy', 'geometry_endxy', 'tools_solderpaste_xy_toolchange']: + 'tools_mill_toolchangexy', 'tools_mill_endxy', 'tools_solderpaste_xy_toolchange']: if not self.defaults[dim] or self.defaults[dim] == '': continue @@ -4672,6 +4684,8 @@ class App(QtCore.QObject): self.log.debug("on_toggle_units(): Same as previous, ignoring.") return + # new_units = self.defaults["units"] + # Keys in self.defaults for which to scale their values dimensions = [ # Global @@ -4693,15 +4707,15 @@ class App(QtCore.QObject): "excellon_editor_slot_length", # Geometry Object - 'geometry_cutz', "geometry_depthperpass", 'geometry_travelz', 'geometry_feedrate', - 'geometry_feedrate_rapid', "geometry_toolchangez", "geometry_feedrate_z", - "geometry_toolchangexy", 'tools_mill_tooldia', 'geometry_endz', 'geometry_endxy', - "geometry_extracut_length", "geometry_z_pdepth", - "geometry_feedrate_probe", "geometry_startz", "geometry_segx", "geometry_segy", "geometry_area_overz", + 'tools_mill_cutz', "tools_mill_depthperpass", 'tools_mill_travelz', 'tools_mill_feedrate', + 'tools_mill_feedrate_rapid', "tools_mill_toolchangez", "tools_mill_feedrate_z", + "tools_mill_toolchangexy", 'tools_mill_tooldia', 'tools_mill_endz', 'tools_mill_endxy', + "tools_mill_extracut_length", "tools_mill_z_pdepth", + "tools_mill_feedrate_probe", "tools_mill_startz", "geometry_segx", "geometry_segy", "tools_mill_area_overz", # CNCJob Object - 'cncjob_tooldia', "cncjob_al_travelz", "cncjob_al_probe_depth", "cncjob_al_grbl_jog_step", - "cncjob_al_grbl_jog_fr", "cncjob_al_grbl_travelz", + 'cncjob_tooldia', "tools_al_travelz", "tools_al_probe_depth", "tools_al_grbl_jog_step", + "tools_al_grbl_jog_fr", "tools_al_grbl_travelz", # Isolation Tool "tools_iso_tool_cutz",