- the application now uses only the default values from the app.options dict, the app.defaults dict holds the definitive default values

- fixed some outstanding issues from the PyQt6 port
- PEP8 fixes
- minor fixes
- updated the saving of Preferences to update the self.options too: the `Apply` action will update the self.options but the `Save` action will save the updated preferences to the file on disk
This commit is contained in:
Marius Stanciu
2022-02-18 23:06:58 +02:00
committed by Marius
parent 14d9ea5470
commit 65d8dcc0b2
92 changed files with 1881 additions and 1882 deletions

View File

@@ -5176,26 +5176,24 @@ class FlatCAMActivityView(QtWidgets.QWidget):
This class create and control the activity icon displayed in the App status bar
"""
def __init__(self, app, parent=None):
def __init__(self, icon_location, icon_kind, replot_callback, parent=None):
super().__init__(parent=parent)
self.app = app
if self.app.defaults["global_activity_icon"] == "Ball green":
icon = self.app.resource_location + '/active_2_static.png'
movie = self.app.resource_location + "/active_2.gif"
elif self.app.defaults["global_activity_icon"] == "Ball black":
icon = self.app.resource_location + '/active_static.png'
movie = self.app.resource_location + "/active.gif"
elif self.app.defaults["global_activity_icon"] == "Arrow green":
icon = self.app.resource_location + '/active_3_static.png'
movie = self.app.resource_location + "/active_3.gif"
elif self.app.defaults["global_activity_icon"] == "Eclipse green":
icon = self.app.resource_location + '/active_4_static.png'
movie = self.app.resource_location + "/active_4.gif"
if icon_kind == "Ball green":
icon = icon_location + '/active_2_static.png'
movie = icon_location + "/active_2.gif"
elif icon_kind == "Ball black":
icon = icon_location + '/active_static.png'
movie = icon_location + "/active.gif"
elif icon_kind == "Arrow green":
icon = icon_location + '/active_3_static.png'
movie = icon_location + "/active_3.gif"
elif icon_kind == "Eclipse green":
icon = icon_location + '/active_4_static.png'
movie = icon_location + "/active_4.gif"
else:
icon = self.app.resource_location + '/active_static.png'
movie = self.app.resource_location + "/active.gif"
icon = icon_location + '/active_static.png'
movie = icon_location + "/active.gif"
# ###############################################################3
# self.setMinimumWidth(200)
@@ -5223,7 +5221,7 @@ class FlatCAMActivityView(QtWidgets.QWidget):
layout.addWidget(self.text)
self.icon.clicked.connect(self.app.on_toolbar_replot)
self.icon.clicked.connect(replot_callback)
def set_idle(self):
self.movie.stop()
@@ -5295,7 +5293,6 @@ class FlatCAMInfoBar(QtWidgets.QWidget):
self.icon.setPixmap(self.blue_pamap)
else:
self.icon.setPixmap(self.gray_pmap)
except Exception as e:
self.app.log.error("FlatCAMInfoBar.set_status() set Icon --> %s" % str(e))
@@ -5371,10 +5368,10 @@ class FlatCAMSystemTray(QtWidgets.QSystemTrayIcon):
self.menu_open.addSeparator()
menu_openproject.triggered.connect(self.app.f_handlers.on_file_openproject)
menu_opengerber.triggered.connect(self.app.f_handlers.on_fileopengerber)
menu_openexcellon.triggered.connect(self.app.f_handlers.on_fileopenexcellon)
menu_opengcode.triggered.connect(self.app.f_handlers.on_fileopengcode)
menu_openproject.triggered.connect(lambda: self.app.f_handlers.on_file_openproject())
menu_opengerber.triggered.connect(lambda: self.app.f_handlers.on_fileopengerber())
menu_openexcellon.triggered.connect(lambda: self.app.f_handlers.on_fileopenexcellon())
menu_opengcode.triggered.connect(lambda: self.app.f_handlers.on_fileopengcode())
exitAction = menu.addAction(_("Exit"))
exitAction.setIcon(QtGui.QIcon(self.app.resource_location + '/power16.png'))

View File

@@ -1867,18 +1867,18 @@ class MainGUI(QtWidgets.QMainWindow):
self.infobar.addWidget(self.fcinfo, stretch=1)
self.infobar.addWidget(self.delta_coords_toolbar)
self.delta_coords_toolbar.setVisible(self.app.defaults["global_delta_coordsbar_show"])
self.delta_coords_toolbar.setVisible(self.app.options["global_delta_coordsbar_show"])
self.infobar.addWidget(self.coords_toolbar)
self.coords_toolbar.setVisible(self.app.defaults["global_coordsbar_show"])
self.coords_toolbar.setVisible(self.app.options["global_coordsbar_show"])
self.grid_toolbar.setMaximumHeight(24)
self.infobar.addWidget(self.grid_toolbar)
self.grid_toolbar.setVisible(self.app.defaults["global_gridbar_show"])
self.grid_toolbar.setVisible(self.app.options["global_gridbar_show"])
self.status_toolbar.setMaximumHeight(24)
self.infobar.addWidget(self.status_toolbar)
self.status_toolbar.setVisible(self.app.defaults["global_statusbar_show"])
self.status_toolbar.setVisible(self.app.options["global_statusbar_show"])
self.units_label = FCLabel("[mm]")
self.units_label.setToolTip(_("Application units"))
@@ -1886,7 +1886,9 @@ class MainGUI(QtWidgets.QMainWindow):
self.infobar.addWidget(self.units_label)
# this used to be done in the APP.__init__()
self.activity_view = FlatCAMActivityView(app=self.app)
self.activity_view = FlatCAMActivityView(icon_location=self.app.resource_location,
icon_kind=self.app.options["global_activity_icon"],
replot_callback=self.app.on_toolbar_replot)
self.infobar.addWidget(self.activity_view)
# disabled
@@ -1935,16 +1937,16 @@ class MainGUI(QtWidgets.QMainWindow):
# ########################################################################
# ######################## BUILD PREFERENCES #############################
# ########################################################################
self.general_pref_form = GeneralPreferencesUI(decimals=self.decimals, defaults=self.app.defaults)
self.gerber_pref_form = GerberPreferencesUI(decimals=self.decimals, defaults=self.app.defaults)
self.excellon_pref_form = ExcellonPreferencesUI(decimals=self.decimals, defaults=self.app.defaults)
self.geo_pref_form = GeometryPreferencesUI(decimals=self.decimals, defaults=self.app.defaults)
self.cncjob_pref_form = CNCJobPreferencesUI(decimals=self.decimals, defaults=self.app.defaults)
self.plugin_pref_form = PluginsPreferencesUI(decimals=self.decimals, defaults=self.app.defaults)
self.plugin2_pref_form = Plugins2PreferencesUI(decimals=self.decimals, defaults=self.app.defaults)
self.plugin_eng_pref_form = PluginsEngravingPreferencesUI(decimals=self.decimals, defaults=self.app.defaults)
self.general_pref_form = GeneralPreferencesUI(decimals=self.decimals, defaults=self.app.options)
self.gerber_pref_form = GerberPreferencesUI(decimals=self.decimals, defaults=self.app.options)
self.excellon_pref_form = ExcellonPreferencesUI(decimals=self.decimals, defaults=self.app.options)
self.geo_pref_form = GeometryPreferencesUI(decimals=self.decimals, defaults=self.app.options)
self.cncjob_pref_form = CNCJobPreferencesUI(decimals=self.decimals, defaults=self.app.options)
self.plugin_pref_form = PluginsPreferencesUI(decimals=self.decimals, defaults=self.app.options)
self.plugin2_pref_form = Plugins2PreferencesUI(decimals=self.decimals, defaults=self.app.options)
self.plugin_eng_pref_form = PluginsEngravingPreferencesUI(decimals=self.decimals, defaults=self.app.options)
self.util_pref_form = UtilPreferencesUI(decimals=self.decimals, defaults=self.app.defaults)
self.util_pref_form = UtilPreferencesUI(decimals=self.decimals, defaults=self.app.options)
QtCore.QCoreApplication.instance().installEventFilter(self)
@@ -2042,7 +2044,7 @@ class MainGUI(QtWidgets.QMainWindow):
self.plot_tab_area.tabBar.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.ActionsContextMenu)
self.on_tab_setup_context_menu()
# activate initial state
self.on_detachable_tab_rmb_click(self.app.defaults["global_tabs_detachable"])
self.on_detachable_tab_rmb_click(self.app.options["global_tabs_detachable"])
# status bar activation/deactivation
self.infobar.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.ActionsContextMenu)
@@ -2162,20 +2164,20 @@ class MainGUI(QtWidgets.QMainWindow):
:return: None
"""
self.app.defaults["global_def_win_x"] = x
self.app.defaults["global_def_win_y"] = y
self.app.defaults["global_def_win_w"] = width
self.app.defaults["global_def_win_h"] = height
self.app.defaults["global_def_notebook_width"] = notebook_width
self.app.options["global_def_win_x"] = x
self.app.options["global_def_win_y"] = y
self.app.options["global_def_win_w"] = width
self.app.options["global_def_win_h"] = height
self.app.options["global_def_notebook_width"] = notebook_width
self.app.preferencesUiManager.save_defaults()
def restore_main_win_geom(self):
try:
self.setGeometry(self.app.defaults["global_def_win_x"],
self.app.defaults["global_def_win_y"],
self.app.defaults["global_def_win_w"],
self.app.defaults["global_def_win_h"])
self.splitter.setSizes([self.app.defaults["global_def_notebook_width"], 0])
self.setGeometry(self.app.options["global_def_win_x"],
self.app.options["global_def_win_y"],
self.app.options["global_def_win_w"],
self.app.options["global_def_win_h"])
self.splitter.setSizes([self.app.options["global_def_notebook_width"], 0])
except KeyError as e:
self.app.log.debug("appGUI.MainGUI.restore_main_win_geom() --> %s" % str(e))
@@ -2186,7 +2188,7 @@ class MainGUI(QtWidgets.QMainWindow):
:return: None
"""
tb = self.app.defaults["global_toolbar_view"]
tb = self.app.options["global_toolbar_view"]
if tb & 1:
self.toolbarfile.setVisible(True)
@@ -2236,7 +2238,7 @@ class MainGUI(QtWidgets.QMainWindow):
self.toolbarshell.setVisible(False)
def on_tab_setup_context_menu(self):
initial_checked = self.app.defaults["global_tabs_detachable"]
initial_checked = self.app.options["global_tabs_detachable"]
action_name = str(_("Detachable Tabs"))
action = QtGui.QAction(self)
action.setCheckable(True)
@@ -2254,17 +2256,17 @@ class MainGUI(QtWidgets.QMainWindow):
def on_detachable_tab_rmb_click(self, checked):
self.notebook.set_detachable(val=checked)
self.app.defaults["global_tabs_detachable"] = checked
self.app.options["global_tabs_detachable"] = checked
self.plot_tab_area.set_detachable(val=checked)
self.app.defaults["global_tabs_detachable"] = checked
self.app.options["global_tabs_detachable"] = checked
def build_infobar_context_menu(self):
delta_coords_action_name = str(_("Delta Coordinates Toolbar"))
delta_coords_action = QtGui.QAction(self)
delta_coords_action.setCheckable(True)
delta_coords_action.setText(delta_coords_action_name)
delta_coords_action.setChecked(self.app.defaults["global_delta_coordsbar_show"])
delta_coords_action.setChecked(self.app.options["global_delta_coordsbar_show"])
self.infobar.addAction(delta_coords_action)
delta_coords_action.triggered.connect(self.toggle_delta_coords)
@@ -2272,7 +2274,7 @@ class MainGUI(QtWidgets.QMainWindow):
coords_action = QtGui.QAction(self)
coords_action.setCheckable(True)
coords_action.setText(coords_action_name)
coords_action.setChecked(self.app.defaults["global_coordsbar_show"])
coords_action.setChecked(self.app.options["global_coordsbar_show"])
self.infobar.addAction(coords_action)
coords_action.triggered.connect(self.toggle_coords)
@@ -2280,7 +2282,7 @@ class MainGUI(QtWidgets.QMainWindow):
grid_action = QtGui.QAction(self)
grid_action.setCheckable(True)
grid_action.setText(grid_action_name)
grid_action.setChecked(self.app.defaults["global_gridbar_show"])
grid_action.setChecked(self.app.options["global_gridbar_show"])
self.infobar.addAction(grid_action)
grid_action.triggered.connect(self.toggle_gridbar)
@@ -2288,24 +2290,24 @@ class MainGUI(QtWidgets.QMainWindow):
status_action = QtGui.QAction(self)
status_action.setCheckable(True)
status_action.setText(status_action_name)
status_action.setChecked(self.app.defaults["global_statusbar_show"])
status_action.setChecked(self.app.options["global_statusbar_show"])
self.infobar.addAction(status_action)
status_action.triggered.connect(self.toggle_statusbar)
def toggle_coords(self, checked):
self.app.defaults["global_coordsbar_show"] = checked
self.app.options["global_coordsbar_show"] = checked
self.coords_toolbar.setVisible(checked)
def toggle_delta_coords(self, checked):
self.app.defaults["global_delta_coordsbar_show"] = checked
self.app.options["global_delta_coordsbar_show"] = checked
self.delta_coords_toolbar.setVisible(checked)
def toggle_gridbar(self, checked):
self.app.defaults["global_gridbar_show"] = checked
self.app.options["global_gridbar_show"] = checked
self.grid_toolbar.setVisible(checked)
def toggle_statusbar(self, checked):
self.app.defaults["global_statusbar_show"] = checked
self.app.options["global_statusbar_show"] = checked
self.status_toolbar.setVisible(checked)
def on_preferences_open_folder(self):
@@ -2768,10 +2770,10 @@ class MainGUI(QtWidgets.QMainWindow):
for tb in self.findChildren(QtWidgets.QToolBar):
tb.setVisible(False)
self.coords_toolbar.setVisible(self.app.defaults["global_coordsbar_show"])
self.delta_coords_toolbar.setVisible(self.app.defaults["global_delta_coordsbar_show"])
self.grid_toolbar.setVisible(self.app.defaults["global_gridbar_show"])
self.status_toolbar.setVisible(self.app.defaults["global_statusbar_show"])
self.coords_toolbar.setVisible(self.app.options["global_coordsbar_show"])
self.delta_coords_toolbar.setVisible(self.app.options["global_delta_coordsbar_show"])
self.grid_toolbar.setVisible(self.app.options["global_gridbar_show"])
self.status_toolbar.setVisible(self.app.options["global_statusbar_show"])
self.splitter.setSizes([0, 1])
self.toggle_fscreen = True
@@ -2944,7 +2946,7 @@ class MainGUI(QtWidgets.QMainWindow):
# Open Excellon file
if key == QtCore.Qt.Key.Key_E:
self.app.f_handlers.on_fileopenexcellon(signal=None)
self.app.f_handlers.on_fileopenexcellon()
# Open Gerber file
if key == QtCore.Qt.Key.Key_G:
@@ -2952,7 +2954,7 @@ class MainGUI(QtWidgets.QMainWindow):
if 'editor' in widget_name.lower():
self.app.goto_text_line()
else:
self.app.f_handlers.on_fileopengerber(signal=None)
self.app.f_handlers.on_fileopengerber()
# Distance Tool
if key == QtCore.Qt.Key.Key_M:
@@ -2964,7 +2966,7 @@ class MainGUI(QtWidgets.QMainWindow):
# Open Project
if key == QtCore.Qt.Key.Key_O:
self.app.f_handlers.on_file_openproject(signal=None)
self.app.f_handlers.on_file_openproject()
# Open Project
if key == QtCore.Qt.Key.Key_P:
@@ -3033,7 +3035,7 @@ class MainGUI(QtWidgets.QMainWindow):
# Rotate Object by 90 degree CCW
if key == QtCore.Qt.Key.Key_R:
self.app.on_rotate(silent=True, preset=-float(self.app.defaults['tools_transform_rotate']))
self.app.on_rotate(silent=True, preset=-float(self.app.options['tools_transform_rotate']))
return
# Run a Script
@@ -3348,7 +3350,7 @@ class MainGUI(QtWidgets.QMainWindow):
# Rotate Object by 90 degree CW
if key == QtCore.Qt.Key.Key_R:
self.app.on_rotate(silent=True, preset=self.app.defaults['tools_transform_rotate'])
self.app.on_rotate(silent=True, preset=self.app.options['tools_transform_rotate'])
# Shell toggle
if key == QtCore.Qt.Key.Key_S:
@@ -3379,11 +3381,11 @@ class MainGUI(QtWidgets.QMainWindow):
# Zoom In
if key == QtCore.Qt.Key.Key_Equal:
self.app.plotcanvas.zoom(1 / self.app.defaults['global_zoom_ratio'], self.app.mouse)
self.app.plotcanvas.zoom(1 / self.app.options['global_zoom_ratio'], self.app.mouse)
# Zoom Out
if key == QtCore.Qt.Key.Key_Minus:
self.app.plotcanvas.zoom(self.app.defaults['global_zoom_ratio'], self.app.mouse)
self.app.plotcanvas.zoom(self.app.options['global_zoom_ratio'], self.app.mouse)
# toggle display of Notebook area
if key == QtCore.Qt.Key.Key_QuoteLeft:
@@ -3511,12 +3513,12 @@ class MainGUI(QtWidgets.QMainWindow):
# Zoom Out
if key == QtCore.Qt.Key.Key_Minus or key == '-':
self.app.plotcanvas.zoom(1 / self.app.defaults['global_zoom_ratio'],
self.app.plotcanvas.zoom(1 / self.app.options['global_zoom_ratio'],
[self.app.geo_editor.snap_x, self.app.geo_editor.snap_y])
# Zoom In
if key == QtCore.Qt.Key.Key_Equal or key == '=':
self.app.plotcanvas.zoom(self.app.defaults['global_zoom_ratio'],
self.app.plotcanvas.zoom(self.app.options['global_zoom_ratio'],
[self.app.geo_editor.snap_x, self.app.geo_editor.snap_y])
# Switch to Project Tab
@@ -3748,13 +3750,13 @@ class MainGUI(QtWidgets.QMainWindow):
if key == QtCore.Qt.Key.Key_Minus or key == '-':
self.app.grb_editor.launched_from_shortcuts = True
self.app.plotcanvas.zoom(1 / self.app.defaults['global_zoom_ratio'],
self.app.plotcanvas.zoom(1 / self.app.options['global_zoom_ratio'],
[self.app.grb_editor.snap_x, self.app.grb_editor.snap_y])
return
if key == QtCore.Qt.Key.Key_Equal or key == '=':
self.app.grb_editor.launched_from_shortcuts = True
self.app.plotcanvas.zoom(self.app.defaults['global_zoom_ratio'],
self.app.plotcanvas.zoom(self.app.options['global_zoom_ratio'],
[self.app.grb_editor.snap_x, self.app.grb_editor.snap_y])
return
@@ -3976,13 +3978,13 @@ class MainGUI(QtWidgets.QMainWindow):
if key == QtCore.Qt.Key.Key_Minus or key == '-':
self.app.exc_editor.launched_from_shortcuts = True
self.app.plotcanvas.zoom(1 / self.app.defaults['global_zoom_ratio'],
self.app.plotcanvas.zoom(1 / self.app.options['global_zoom_ratio'],
[self.app.exc_editor.snap_x, self.app.exc_editor.snap_y])
return
if key == QtCore.Qt.Key.Key_Equal or key == '=':
self.app.exc_editor.launched_from_shortcuts = True
self.app.plotcanvas.zoom(self.app.defaults['global_zoom_ratio'],
self.app.plotcanvas.zoom(self.app.options['global_zoom_ratio'],
[self.app.exc_editor.snap_x, self.app.exc_editor.snap_y])
return
@@ -4348,7 +4350,7 @@ class MainGUI(QtWidgets.QMainWindow):
:param event: QT event to filter
:return:
"""
if self.app.defaults["global_toggle_tooltips"] is False:
if self.app.options["global_toggle_tooltips"] is False:
if event.type() == QtCore.QEvent.Type.ToolTip:
return True
else:

View File

@@ -128,7 +128,7 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas):
self.create_native()
self.native.setParent(self.fcapp.ui)
axis_default_color = self.fcapp.defaults['global_axis_color']
axis_default_color = self.fcapp.options['global_axis_color']
self.axis_transparency = 0.8
axis_color = self.color_hex2tuple(axis_default_color)
@@ -144,8 +144,8 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas):
parent=self.view.scene)
self.line_parent = None
if self.fcapp.defaults["global_cursor_color_enabled"]:
c_color = Color(self.fcapp.defaults["global_cursor_color"]).rgba
if self.fcapp.options["global_cursor_color_enabled"]:
c_color = Color(self.fcapp.options["global_cursor_color"]).rgba
else:
c_color = self.line_color
@@ -168,14 +168,14 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas):
# draw a rectangle made out of 4 lines on the canvas to serve as a hint for the work area
# all CNC have a limited workspace
if self.fcapp.defaults['global_workspace'] is True:
self.draw_workspace(workspace_size=self.fcapp.defaults["global_workspaceT"])
if self.fcapp.options['global_workspace'] is True:
self.draw_workspace(workspace_size=self.fcapp.options["global_workspaceT"])
# HUD Display
self.hud_enabled = False
# enable the HUD if it is activated in FlatCAM Preferences
if self.fcapp.defaults['global_hud'] is True:
if self.fcapp.options['global_hud'] is True:
self.on_toggle_hud(state=True, silent=True)
# Axis Display
@@ -229,7 +229,7 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas):
if state:
self.axis_enabled = True
self.fcapp.defaults['global_axis'] = True
self.fcapp.options['global_axis'] = True
self.v_line.parent = self.view.scene
self.h_line.parent = self.view.scene
self.fcapp.ui.axis_status_label.setStyleSheet("""
@@ -243,7 +243,7 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas):
self.fcapp.inform[str, bool].emit(_("Axis enabled."), False)
else:
self.axis_enabled = False
self.fcapp.defaults['global_axis'] = False
self.fcapp.options['global_axis'] = False
self.v_line.parent = None
self.h_line.parent = None
self.fcapp.ui.axis_status_label.setStyleSheet("")
@@ -253,7 +253,7 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas):
def apply_axis_color(self):
self.fcapp.log.debug('PlotCanvas.apply_axis_color() -> axis color applied')
axis_default_color = self.fcapp.defaults['global_axis_color']
axis_default_color = self.fcapp.options['global_axis_color']
axis_color = self.color_hex2tuple(axis_default_color)
axis_color = axis_color[0], axis_color[1], axis_color[2], self.axis_transparency
@@ -277,7 +277,7 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas):
self.hud_enabled = True
self.rect_hud.parent = self.view
self.text_hud.parent = self.view
self.fcapp.defaults['global_hud'] = True
self.fcapp.options['global_hud'] = True
self.fcapp.ui.hud_label.setStyleSheet("""
QLabel
{
@@ -292,7 +292,7 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas):
self.hud_enabled = False
self.rect_hud.parent = None
self.text_hud.parent = None
self.fcapp.defaults['global_hud'] = False
self.fcapp.options['global_hud'] = False
self.fcapp.ui.hud_label.setStyleSheet("")
if silent is None:
self.fcapp.inform[str, bool].emit(_("HUD disabled."), False)
@@ -386,14 +386,14 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas):
color = '#dededeff'
if state:
self.fcapp.defaults['global_grid_lines'] = True
self.fcapp.options['global_grid_lines'] = True
self.grid_lines_enabled = True
# self.grid.parent = self.view.scene
self.grid._grid_color_fn['color'] = Color(color).rgba
if silent is None:
self.fcapp.inform[str, bool].emit(_("Grid enabled."), False)
else:
self.fcapp.defaults['global_grid_lines'] = False
self.fcapp.options['global_grid_lines'] = False
self.grid_lines_enabled = False
# self.grid.parent = None
self.grid._grid_color_fn['color'] = Color('#FFFFFFFF').rgba
@@ -424,7 +424,7 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas):
self.app.log.error("PlotCanvas.draw_workspace() --> %s" % str(e))
return
if self.fcapp.defaults['global_workspace_orientation'] == 'l':
if self.fcapp.options['global_workspace_orientation'] == 'l':
dims = (dims[1], dims[0])
a = np.array([(0, 0), (dims[0], 0), (dims[0], dims[1]), (0, dims[1])])
@@ -534,8 +534,8 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas):
def on_mouse_position(self, pos):
if self.fcapp.defaults['global_cursor_color_enabled']:
color = Color(self.fcapp.defaults['global_cursor_color']).rgba
if self.fcapp.options['global_cursor_color_enabled']:
color = Color(self.fcapp.options['global_cursor_color']).rgba
else:
color = self.line_color
@@ -547,8 +547,8 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas):
# key modifiers
modifiers = event.modifiers
pan_delta_x = self.fcapp.defaults["global_gridx"]
pan_delta_y = self.fcapp.defaults["global_gridy"]
pan_delta_x = self.fcapp.options["global_gridx"]
pan_delta_y = self.fcapp.options["global_gridy"]
curr_pos = event.pos
# Controlled pan by mouse wheel
@@ -578,8 +578,8 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas):
# Update cursor
self.fcapp.app_cursor.set_data(np.asarray([(pos[0], pos[1])]),
symbol='++', edge_color=self.fcapp.cursor_color_3D,
edge_width=self.fcapp.defaults["global_cursor_width"],
size=self.fcapp.defaults["global_cursor_size"])
edge_width=self.fcapp.options["global_cursor_width"],
size=self.fcapp.options["global_cursor_size"])
def new_text_group(self, collection=None):
if collection:
@@ -689,7 +689,7 @@ class CursorBig(QtCore.QObject):
# if 'edge_color' in kwargs:
# color = kwargs['edge_color']
# else:
# if self.app.defaults['global_theme'] == 'white':
# if self.app.options['global_theme'] == 'white':
# color = '#000000FF'
# else:
# color = '#FFFFFFFF'

View File

@@ -151,8 +151,8 @@ class PlotCanvas3d(QtCore.QObject, scene.SceneCanvas):
self.container.addWidget(self.native)
self.line_parent = None
if self.fcapp.defaults["global_cursor_color_enabled"]:
c_color = Color(self.fcapp.defaults["global_cursor_color"]).rgba
if self.fcapp.options["global_cursor_color_enabled"]:
c_color = Color(self.fcapp.options["global_cursor_color"]).rgba
else:
c_color = self.line_color
@@ -253,8 +253,8 @@ class PlotCanvas3d(QtCore.QObject, scene.SceneCanvas):
# key modifiers
modifiers = event.modifiers
pan_delta_x = self.fcapp.defaults["global_gridx"]
pan_delta_y = self.fcapp.defaults["global_gridy"]
pan_delta_x = self.fcapp.options["global_gridx"]
pan_delta_y = self.fcapp.options["global_gridy"]
curr_pos = event.pos
# Controlled pan by mouse wheel
@@ -284,8 +284,8 @@ class PlotCanvas3d(QtCore.QObject, scene.SceneCanvas):
# # Update cursor
# self.fcapp.app_cursor.set_data(np.asarray([(pos[0], pos[1])]),
# symbol='++', edge_color=self.fcapp.cursor_color_3D,
# edge_width=self.fcapp.defaults["global_cursor_width"],
# size=self.fcapp.defaults["global_cursor_size"])
# edge_width=self.fcapp.options["global_cursor_width"],
# size=self.fcapp.options["global_cursor_size"])
def new_text_group(self, collection=None):
if collection:

View File

@@ -82,7 +82,7 @@ class CanvasCache(QtCore.QObject):
self.axes.set_xticks([])
self.axes.set_yticks([])
if self.app.defaults['global_theme'] == 'white':
if self.app.options['global_theme'] == 'white':
self.axes.set_facecolor('#FFFFFF')
else:
self.axes.set_facecolor('#000000')
@@ -154,7 +154,7 @@ class PlotCanvasLegacy(QtCore.QObject):
self.app = app
if self.app.defaults['global_theme'] == 'white':
if self.app.options['global_theme'] == 'white':
theme_color = '#FFFFFF'
tick_color = '#000000'
self.rect_hud_color = '#0000FF10'
@@ -241,7 +241,7 @@ class PlotCanvasLegacy(QtCore.QObject):
self.axes.set_aspect(1)
self.axes.grid(True, color='gray')
axis_default_color = self.app.defaults['global_axis_color']
axis_default_color = self.app.options['global_axis_color']
self.axis_transparency = 0.8
axis_color = self.color_hex2tuple(axis_default_color)
@@ -322,7 +322,7 @@ class PlotCanvasLegacy(QtCore.QObject):
self.hud_enabled = False
self.text_hud = self.Thud(plotcanvas=self)
if self.app.defaults['global_hud'] is True:
if self.app.options['global_hud'] is True:
self.on_toggle_hud(state=True, silent=None)
# enable Grid lines
@@ -330,8 +330,8 @@ class PlotCanvasLegacy(QtCore.QObject):
# draw a rectangle made out of 4 lines on the canvas to serve as a hint for the work area
# all CNC have a limited workspace
if self.app.defaults['global_workspace'] is True:
self.draw_workspace(workspace_size=self.app.defaults["global_workspaceT"])
if self.app.options['global_workspace'] is True:
self.draw_workspace(workspace_size=self.app.options["global_workspaceT"])
# Axis Display
self.axis_enabled = True
@@ -365,7 +365,7 @@ class PlotCanvasLegacy(QtCore.QObject):
def apply_axis_color(self):
self.app.self.app.log.debug('PlotCanvasLegacy.apply_axis_color() -> axis color applied')
axis_default_color = self.app.defaults['global_axis_color']
axis_default_color = self.app.options['global_axis_color']
axis_color = self.color_hex2tuple(axis_default_color)
axis_color = axis_color[0], axis_color[1], axis_color[2]
@@ -380,7 +380,7 @@ class PlotCanvasLegacy(QtCore.QObject):
if state:
self.axis_enabled = True
self.app.defaults['global_axis'] = True
self.app.options['global_axis'] = True
if self.h_line not in self.axes.lines and self.v_line not in self.axes.lines:
self.h_line = self.axes.axhline(color=(0.70, 0.3, 0.3), linewidth=2)
self.v_line = self.axes.axvline(color=(0.70, 0.3, 0.3), linewidth=2)
@@ -395,7 +395,7 @@ class PlotCanvasLegacy(QtCore.QObject):
self.app.inform[str, bool].emit(_("Axis enabled."), False)
else:
self.axis_enabled = False
self.app.defaults['global_axis'] = False
self.app.options['global_axis'] = False
if self.h_line in self.axes.lines and self.v_line in self.axes.lines:
self.axes.lines.remove(self.h_line)
self.axes.lines.remove(self.v_line)
@@ -412,7 +412,7 @@ class PlotCanvasLegacy(QtCore.QObject):
if state:
self.hud_enabled = True
self.text_hud.add_artist()
self.app.defaults['global_hud'] = True
self.app.options['global_hud'] = True
self.app.ui.hud_label.setStyleSheet("""
QLabel
@@ -426,7 +426,7 @@ class PlotCanvasLegacy(QtCore.QObject):
else:
self.hud_enabled = False
self.text_hud.remove_artist()
self.app.defaults['global_hud'] = False
self.app.options['global_hud'] = False
self.app.ui.hud_label.setStyleSheet("")
if silent is None:
self.app.inform[str, bool].emit(_("HUD disabled."), False)
@@ -523,7 +523,7 @@ class PlotCanvasLegacy(QtCore.QObject):
state = not self.grid_lines_enabled
if state:
self.app.defaults['global_grid_lines'] = True
self.app.options['global_grid_lines'] = True
self.grid_lines_enabled = True
self.axes.grid(True)
try:
@@ -533,7 +533,7 @@ class PlotCanvasLegacy(QtCore.QObject):
if silent is None:
self.app.inform[str, bool].emit(_("Grid enabled."), False)
else:
self.app.defaults['global_grid_lines'] = False
self.app.options['global_grid_lines'] = False
self.grid_lines_enabled = False
self.axes.grid(False)
try:
@@ -558,7 +558,7 @@ class PlotCanvasLegacy(QtCore.QObject):
self.app.log.error("PlotCanvasLegacy.draw_workspace() --> %s" % str(e))
return
if self.app.defaults['global_workspace_orientation'] == 'l':
if self.app.options['global_workspace_orientation'] == 'l':
dims = (dims[1], dims[0])
xdata = [0, dims[0], dims[0], 0, 0]
@@ -631,18 +631,18 @@ class PlotCanvasLegacy(QtCore.QObject):
# else:
# c = MplCursor(axes=axes, color='black', linewidth=1)
if self.app.defaults["global_cursor_color_enabled"]:
color = self.app.defaults["global_cursor_color"]
if self.app.options["global_cursor_color_enabled"]:
color = self.app.options["global_cursor_color"]
else:
if self.app.defaults['global_theme'] == 'white':
if self.app.options['global_theme'] == 'white':
color = '#000000'
else:
color = '#FFFFFF'
if big is True:
self.big_cursor = True
self.ch_line = self.axes.axhline(color=color, linewidth=self.app.defaults["global_cursor_width"])
self.cv_line = self.axes.axvline(color=color, linewidth=self.app.defaults["global_cursor_width"])
self.ch_line = self.axes.axhline(color=color, linewidth=self.app.options["global_cursor_width"])
self.cv_line = self.axes.axvline(color=color, linewidth=self.app.options["global_cursor_width"])
self.big_cursor_isdisabled = False
else:
self.big_cursor = False
@@ -667,7 +667,7 @@ class PlotCanvasLegacy(QtCore.QObject):
if color:
color = color
else:
if self.app.defaults['global_theme'] == 'white':
if self.app.options['global_theme'] == 'white':
color = '#000000'
else:
color = '#FFFFFF'
@@ -679,9 +679,9 @@ class PlotCanvasLegacy(QtCore.QObject):
# Pointer (snapped)
# The size of the cursor is multiplied by 1.65 because that value made the cursor similar with the
# one in the OpenGL(3D) graphic engine
pointer_size = int(float(self.app.defaults["global_cursor_size"]) * 1.65)
pointer_size = int(float(self.app.options["global_cursor_size"]) * 1.65)
elements = self.axes.plot(x, y, '+', color=color, ms=pointer_size,
mew=self.app.defaults["global_cursor_width"], animated=True)
mew=self.app.options["global_cursor_width"], animated=True)
for el in elements:
self.axes.draw_artist(el)
except Exception as e:
@@ -691,8 +691,8 @@ class PlotCanvasLegacy(QtCore.QObject):
self.app.log.error("PlotCanvasLegacy.draw_cursor() big_cursor is False --> %s" % str(e))
else:
try:
self.ch_line.set_markeredgewidth(self.app.defaults["global_cursor_width"])
self.cv_line.set_markeredgewidth(self.app.defaults["global_cursor_width"])
self.ch_line.set_markeredgewidth(self.app.options["global_cursor_width"])
self.cv_line.set_markeredgewidth(self.app.options["global_cursor_width"])
except Exception:
pass
@@ -712,18 +712,18 @@ class PlotCanvasLegacy(QtCore.QObject):
def clear_cursor(self, state):
if state is True:
if self.big_cursor is True and self.big_cursor_isdisabled is True:
if self.app.defaults["global_cursor_color_enabled"]:
color = self.app.defaults["global_cursor_color"]
if self.app.options["global_cursor_color_enabled"]:
color = self.app.options["global_cursor_color"]
else:
if self.app.defaults['global_theme'] == 'white':
if self.app.options['global_theme'] == 'white':
color = '#000000'
else:
color = '#FFFFFF'
self.ch_line = self.axes.axhline(color=color, linewidth=self.app.defaults["global_cursor_width"])
self.cv_line = self.axes.axvline(color=color, linewidth=self.app.defaults["global_cursor_width"])
self.ch_line = self.axes.axhline(color=color, linewidth=self.app.options["global_cursor_width"])
self.cv_line = self.axes.axvline(color=color, linewidth=self.app.options["global_cursor_width"])
self.big_cursor_isdisabled = False
if self.app.defaults["global_cursor_color_enabled"] is True:
if self.app.options["global_cursor_color_enabled"] is True:
self.draw_cursor(x_pos=self.mouse[0], y_pos=self.mouse[1], color=self.app.cursor_color_3D)
else:
self.draw_cursor(x_pos=self.mouse[0], y_pos=self.mouse[1])
@@ -1035,7 +1035,7 @@ class PlotCanvasLegacy(QtCore.QObject):
self.mouse_press_pos = (event.x, event.y)
# Check for middle mouse button press
if self.app.defaults["global_pan_button"] == '2':
if self.app.options["global_pan_button"] == '2':
pan_button = 3 # right button for Matplotlib
else:
pan_button = 2 # middle button for Matplotlib
@@ -1066,7 +1066,7 @@ class PlotCanvasLegacy(QtCore.QObject):
# Check for middle mouse button release to complete pan procedure
# Check for middle mouse button press
if self.app.defaults["global_pan_button"] == '2':
if self.app.options["global_pan_button"] == '2':
pan_button = 3 # right button for Matplotlib
else:
pan_button = 2 # middle button for Matplotlib
@@ -1079,7 +1079,7 @@ class PlotCanvasLegacy(QtCore.QObject):
self.panning = False
# And update the cursor
if self.app.defaults["global_cursor_color_enabled"] is True:
if self.app.options["global_cursor_color_enabled"] is True:
self.draw_cursor(x_pos=self.mouse[0], y_pos=self.mouse[1], color=self.app.cursor_color_3D)
else:
self.draw_cursor(x_pos=self.mouse[0], y_pos=self.mouse[1])
@@ -1116,7 +1116,7 @@ class PlotCanvasLegacy(QtCore.QObject):
# #### Temporary place-holder for cached update #####
# self.update_screen_request.emit([0, 0, 0, 0, 0])
if self.app.defaults["global_cursor_color_enabled"] is True:
if self.app.options["global_cursor_color_enabled"] is True:
self.draw_cursor(x_pos=x, y_pos=y, color=self.app.cursor_color_3D)
else:
self.draw_cursor(x_pos=x, y_pos=y)
@@ -1181,10 +1181,10 @@ class PlotCanvasLegacy(QtCore.QObject):
# ### Grid snap
if self.app.grid_status():
if self.app.defaults["global_gridx"] != 0:
if self.app.options["global_gridx"] != 0:
try:
snap_x_ = round(x / float(self.app.defaults["global_gridx"])) * \
float(self.app.defaults["global_gridx"])
snap_x_ = round(x / float(self.app.options["global_gridx"])) * \
float(self.app.options["global_gridx"])
except TypeError:
snap_x_ = x
else:
@@ -1193,19 +1193,19 @@ class PlotCanvasLegacy(QtCore.QObject):
# If the Grid_gap_linked on Grid Toolbar is checked then the snap distance on GridY entry will be ignored
# and it will use the snap distance from GridX entry
if self.app.ui.grid_gap_link_cb.isChecked():
if self.app.defaults["global_gridx"] != 0:
if self.app.options["global_gridx"] != 0:
try:
snap_y_ = round(y / float(self.app.defaults["global_gridx"])) * \
float(self.app.defaults["global_gridx"])
snap_y_ = round(y / float(self.app.options["global_gridx"])) * \
float(self.app.options["global_gridx"])
except TypeError:
snap_y_ = y
else:
snap_y_ = y
else:
if self.app.defaults["global_gridy"] != 0:
if self.app.options["global_gridy"] != 0:
try:
snap_y_ = round(y / float(self.app.defaults["global_gridy"])) * \
float(self.app.defaults["global_gridy"])
snap_y_ = round(y / float(self.app.options["global_gridy"])) * \
float(self.app.options["global_gridy"])
except TypeError:
snap_y_ = y
else:

View File

@@ -16,7 +16,7 @@ if '_' not in builtins.__dict__:
class PreferencesUIManager:
def __init__(self, defaults: FlatCAMDefaults, data_path: str, ui, inform):
def __init__(self, defaults: FlatCAMDefaults, data_path: str, ui, inform, options):
"""
Class that control the Preferences Tab
@@ -24,6 +24,7 @@ class PreferencesUIManager:
:param data_path: a path to the file where all the preferences are stored for persistence
:param ui: reference to the MainGUI class which constructs the UI
:param inform: a pyqtSignal used to display information's in the StatusBar of the GUI
:param options: a dict holding the current defaults loaded in the application
"""
self.defaults = defaults
@@ -1093,15 +1094,20 @@ class PreferencesUIManager:
else:
self.ui.general_pref_form.general_app_group.ge_radio.set_value(ge)
if save_to_file or should_restart is True:
# Re-fresh project options
self.ui.app.on_options_app2project()
# #############################################################################################################
# ############################ Here is done the actual preferences updates ##################################
# #############################################################################################################
# update the `defaults` dict from the Preferences UI form
self.defaults_read_form()
# Apply the `defaults` dict to project options
self.ui.app.options.update(self.defaults)
# #############################################################################################################
if save_to_file or should_restart is True:
self.save_defaults(silent=False)
# load the defaults so they are updated into the app
self.defaults.load(filename=os.path.join(self.data_path,
'current_defaults_%s.FlatConfig' % self.defaults.version),
inform=self.inform)
saved_filename_path = os.path.join(self.data_path, 'current_defaults_%s.FlatConfig' % self.defaults.version)
self.defaults.load(filename=saved_filename_path, inform=self.inform)
settgs = QSettings("Open Source", "FlatCAM")

View File

@@ -63,4 +63,4 @@ class CNCJobAdvOptPrefGroupUI(OptionsGroupUI):
self.annotation_fontcolor_entry.editingFinished.connect(self.on_annotation_fontcolor_entry)
def on_annotation_fontcolor_entry(self):
self.app.defaults['cncjob_annotation_fontcolor'] = self.annotation_fontcolor_entry.get_value()
self.app.options['cncjob_annotation_fontcolor'] = self.annotation_fontcolor_entry.get_value()

View File

@@ -238,28 +238,28 @@ class CNCJobGenPrefGroupUI(OptionsGroupUI):
# Setting travel colors handlers
# ------------------------------------------------------
def on_tfill_color_entry(self):
self.app.defaults['cncjob_travel_fill'] = self.tfill_color_entry.get_value()[:7] + \
self.app.defaults['cncjob_travel_fill'][7:9]
self.app.options['cncjob_travel_fill'] = self.tfill_color_entry.get_value()[:7] + \
self.app.options['cncjob_travel_fill'][7:9]
def on_tline_color_entry(self):
self.app.defaults['cncjob_travel_line'] = self.tline_color_entry.get_value()[:7] + \
self.app.defaults['cncjob_travel_line'][7:9]
self.app.options['cncjob_travel_line'] = self.tline_color_entry.get_value()[:7] + \
self.app.options['cncjob_travel_line'][7:9]
def on_cncjob_alpha_changed(self, spinner_value):
self.app.defaults['cncjob_travel_fill'] = \
self.app.defaults['cncjob_travel_fill'][:7] + \
self.app.options['cncjob_travel_fill'] = \
self.app.options['cncjob_travel_fill'][:7] + \
(hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00')
self.app.defaults['cncjob_travel_line'] = \
self.app.defaults['cncjob_travel_line'][:7] + \
self.app.options['cncjob_travel_line'] = \
self.app.options['cncjob_travel_line'][:7] + \
(hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00')
# ------------------------------------------------------
# Setting plot colors handlers
# ------------------------------------------------------
def on_fill_color_entry(self):
self.app.defaults['cncjob_plot_fill'] = self.fill_color_entry.get_value()[:7] + \
self.app.defaults['cncjob_plot_fill'][7:9]
self.app.options['cncjob_plot_fill'] = self.fill_color_entry.get_value()[:7] + \
self.app.options['cncjob_plot_fill'][7:9]
def on_line_color_entry(self):
self.app.defaults['cncjob_plot_line'] = self.line_color_entry.get_value()[:7] + \
self.app.defaults['cncjob_plot_line'][7:9]
self.app.options['cncjob_plot_line'] = self.line_color_entry.get_value()[:7] + \
self.app.options['cncjob_plot_line'][7:9]

View File

@@ -366,7 +366,7 @@ class ExcellonGenPrefGroupUI(OptionsGroupUI):
self.update_excellon_cb.stateChanged.connect(self.on_update_exc_export)
# call it once to make sure it is updated at startup
self.on_update_exc_export(state=self.app.defaults["excellon_update"])
self.on_update_exc_export(state=self.app.options["excellon_update"])
self.excellon_optimization_radio.activated_custom.connect(self.optimization_selection)
@@ -388,19 +388,19 @@ class ExcellonGenPrefGroupUI(OptionsGroupUI):
# Setting plot colors handlers
def on_fill_color_entry(self):
self.app.defaults['excellon_plot_fill'] = self.fill_color_entry.get_value()[:7] + \
self.app.defaults['excellon_plot_fill'][7:9]
self.app.options['excellon_plot_fill'] = self.fill_color_entry.get_value()[:7] + \
self.app.options['excellon_plot_fill'][7:9]
def on_line_color_entry(self):
self.app.defaults['excellon_plot_line'] = self.line_color_entry.get_value()[:7] + \
self.app.defaults['excellon_plot_line'][7:9]
self.app.options['excellon_plot_line'] = self.line_color_entry.get_value()[:7] + \
self.app.options['excellon_plot_line'][7:9]
def on_excellon_alpha_changed(self, spinner_value):
self.app.defaults['excellon_plot_fill'] = \
self.app.defaults['excellon_plot_fill'][:7] + \
self.app.options['excellon_plot_fill'] = \
self.app.options['excellon_plot_fill'][:7] + \
(hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00')
self.app.defaults['excellon_plot_line'] = \
self.app.defaults['excellon_plot_line'][:7] + \
self.app.options['excellon_plot_line'] = \
self.app.options['excellon_plot_line'][:7] + \
(hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00')
def on_excellon_defaults_button(self):

View File

@@ -490,7 +490,7 @@ class GeneralAPPSetGroupUI(OptionsGroupUI):
def on_mouse_cursor_color_enable(self, val):
if val:
self.app.cursor_color_3D = self.app.defaults["global_cursor_color"]
self.app.cursor_color_3D = self.app.options["global_cursor_color"]
else:
theme_settings = QtCore.QSettings("Open Source", "FlatCAM")
if theme_settings.contains("theme"):
@@ -504,9 +504,9 @@ class GeneralAPPSetGroupUI(OptionsGroupUI):
self.app.cursor_color_3D = 'gray'
def on_mouse_cursor_entry(self):
self.app.defaults['global_cursor_color'] = self.mouse_cursor_entry.get_value()
self.app.cursor_color_3D = self.app.defaults["global_cursor_color"]
self.app.options['global_cursor_color'] = self.mouse_cursor_entry.get_value()
self.app.cursor_color_3D = self.app.options["global_cursor_color"]
def on_axis_color_entry(self):
self.app.defaults['global_axis_color'] = self.axis_color_entry.get_value()
self.app.options['global_axis_color'] = self.axis_color_entry.get_value()
self.app.plotcanvas.apply_axis_color()

View File

@@ -286,7 +286,7 @@ class GeneralAppSettingsGroupUI(OptionsGroupUI2):
def on_mouse_cursor_color_enable(self, val):
if val:
self.app.cursor_color_3D = self.app.defaults["global_cursor_color"]
self.app.cursor_color_3D = self.app.options["global_cursor_color"]
else:
theme_settings = QtCore.QSettings("Open Source", "FlatCAM")
if theme_settings.contains("theme"):
@@ -300,5 +300,5 @@ class GeneralAppSettingsGroupUI(OptionsGroupUI2):
self.app.cursor_color_3D = 'gray'
def on_mouse_cursor_entry(self):
self.app.defaults['global_cursor_color'] = self.mouse_cursor_color_field.get_value()
self.app.cursor_color_3D = self.app.defaults["global_cursor_color"]
self.app.options['global_cursor_color'] = self.mouse_cursor_color_field.get_value()
self.app.cursor_color_3D = self.app.options["global_cursor_color"]

View File

@@ -332,11 +332,11 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI):
# Setting selection colors (left - right) handlers
def on_sf_color_entry(self):
self.app.defaults['global_sel_fill'] = self.app.defaults['global_sel_fill'][7:9]
self.app.options['global_sel_fill'] = self.app.options['global_sel_fill'][7:9]
def on_sl_color_entry(self):
self.app.defaults['global_sel_line'] = self.sl_color_entry.get_value()[:7] + \
self.app.defaults['global_sel_line'][7:9]
self.app.options['global_sel_line'] = self.sl_color_entry.get_value()[:7] + \
self.app.options['global_sel_line'][7:9]
def on_left_right_alpha_changed(self, spinner_value):
"""
@@ -349,19 +349,19 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI):
:rtype:
"""
self.app.defaults['global_sel_fill'] = self.app.defaults['global_sel_fill'][:7] + \
self.app.options['global_sel_fill'] = self.app.options['global_sel_fill'][:7] + \
(hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00')
self.app.defaults['global_sel_line'] = self.app.defaults['global_sel_line'][:7] + \
self.app.options['global_sel_line'] = self.app.options['global_sel_line'][:7] + \
(hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00')
# Setting selection colors (right - left) handlers
def on_alt_sf_color_entry(self):
self.app.defaults['global_alt_sel_fill'] = self.alt_sf_color_entry.get_value()[:7] + \
self.app.defaults['global_alt_sel_fill'][7:9]
self.app.options['global_alt_sel_fill'] = self.alt_sf_color_entry.get_value()[:7] + \
self.app.options['global_alt_sel_fill'][7:9]
def on_alt_sl_color_entry(self):
self.app.defaults['global_alt_sel_line'] = self.alt_sl_color_entry.get_value()[:7] + \
self.app.defaults['global_alt_sel_line'][7:9]
self.app.options['global_alt_sel_line'] = self.alt_sl_color_entry.get_value()[:7] + \
self.app.options['global_alt_sel_line'][7:9]
def on_right_left_alpha_changed(self, spinner_value):
"""
@@ -374,20 +374,20 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI):
:rtype:
"""
self.app.defaults['global_alt_sel_fill'] = self.app.defaults['global_alt_sel_fill'][:7] + \
self.app.options['global_alt_sel_fill'] = self.app.options['global_alt_sel_fill'][:7] + \
(hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00')
self.app.defaults['global_alt_sel_line'] = self.app.defaults['global_alt_sel_line'][:7] + \
self.app.options['global_alt_sel_line'] = self.app.options['global_alt_sel_line'][:7] + \
(hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00')
# Setting Editor colors
def on_draw_color_entry(self):
self.app.defaults['global_draw_color'] = self.draw_color_entry.get_value()
self.app.options['global_draw_color'] = self.draw_color_entry.get_value()
def on_sel_draw_color_entry(self):
self.app.defaults['global_sel_draw_color'] = self.sel_draw_color_entry.get_value()
self.app.options['global_sel_draw_color'] = self.sel_draw_color_entry.get_value()
def on_proj_color_entry(self):
self.app.defaults['global_proj_item_color'] = self.proj_color_entry.get_value()
self.app.options['global_proj_item_color'] = self.proj_color_entry.get_value()
def on_proj_color_dis_entry(self):
self.app.defaults['global_proj_item_dis_color'] = self.proj_color_dis_entry.get_value()
self.app.options['global_proj_item_dis_color'] = self.proj_color_dis_entry.get_value()

View File

@@ -184,7 +184,7 @@ class GeometryGenPrefGroupUI(OptionsGroupUI):
self.line_color_entry.editingFinished.connect(self.on_line_color_entry)
def on_line_color_entry(self):
self.app.defaults['geometry_plot_line'] = self.line_color_entry.get_value()[:7] + 'FF'
self.app.options['geometry_plot_line'] = self.line_color_entry.get_value()[:7] + 'FF'
def optimization_selection(self, val):
if platform.architecture()[0] != '64bit':

View File

@@ -292,8 +292,8 @@ class GerberGenPrefGroupUI(OptionsGroupUI):
:return:
:rtype:
"""
self.app.defaults['gerber_plot_fill'] = self.fill_color_entry.get_value()[:7] + \
self.app.defaults['gerber_plot_fill'][7:9]
self.app.options['gerber_plot_fill'] = self.fill_color_entry.get_value()[:7] + \
self.app.options['gerber_plot_fill'][7:9]
def on_gerber_alpha_changed(self, spinner_value):
"""
@@ -303,11 +303,11 @@ class GerberGenPrefGroupUI(OptionsGroupUI):
:return:
:rtype:
"""
self.app.defaults['gerber_plot_fill'] = \
self.app.defaults['gerber_plot_fill'][:7] + \
self.app.options['gerber_plot_fill'] = \
self.app.options['gerber_plot_fill'][:7] + \
(hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00')
self.app.defaults['gerber_plot_line'] = \
self.app.defaults['gerber_plot_line'][:7] + \
self.app.options['gerber_plot_line'] = \
self.app.options['gerber_plot_line'][:7] + \
(hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00')
def on_line_color_changed(self):
@@ -316,8 +316,8 @@ class GerberGenPrefGroupUI(OptionsGroupUI):
:return:
:rtype:
"""
self.app.defaults['gerber_plot_line'] = (self.line_color_entry.get_value()[:7] +
self.app.defaults['gerber_plot_line'][7:9])
self.app.options['gerber_plot_line'] = (self.line_color_entry.get_value()[:7] +
self.app.options['gerber_plot_line'][7:9])
def on_colors_clear_clicked(self):
"""
@@ -325,7 +325,7 @@ class GerberGenPrefGroupUI(OptionsGroupUI):
:return:
:rtype:
"""
self.app.defaults["gerber_color_list"].clear()
self.app.options["gerber_color_list"].clear()
self.app.inform.emit('[WARNING_NOTCL] %s' % _("Stored colors for Gerber objects are deleted."))
def on_layers_manager(self):
@@ -348,7 +348,7 @@ class ColorsManager(QtWidgets.QDialog):
self.ok = False
self.color_list = []
self.original_color_list = deepcopy(self.app.defaults["gerber_color_list"])
self.original_color_list = deepcopy(self.app.options["gerber_color_list"])
self.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/set_colors64.png'))
self.setWindowTitle('%s' % _('Color manager'))
@@ -502,8 +502,8 @@ class ColorsManager(QtWidgets.QDialog):
layer_nr = list_len
self.original_color_list.append(
(
self.app.defaults['gerber_plot_line'],
self.app.defaults['gerber_plot_fill'],
self.app.options['gerber_plot_line'],
self.app.options['gerber_plot_fill'],
'%s_%d' % (_("Layer"), layer_nr)
)
)

View File

@@ -186,7 +186,7 @@ class Tools2QRCodePrefGroupUI(OptionsGroupUI):
self.back_color_entry.editingFinished.connect(self.on_qrcode_back_color_entry)
def on_qrcode_fill_color_entry(self):
self.app.defaults['tools_qrcode_fill_color'] = self.fill_color_entry.get_value()
self.app.options['tools_qrcode_fill_color'] = self.fill_color_entry.get_value()
def on_qrcode_back_color_entry(self):
self.app.defaults['tools_qrcode_back_color'] = self.back_color_entry.get_value()
self.app.options['tools_qrcode_back_color'] = self.back_color_entry.get_value()

View File

@@ -375,4 +375,4 @@ class ToolsFilmPrefGroupUI(OptionsGroupUI):
self.film_color_entry.editingFinished.connect(self.on_film_color_entry)
def on_film_color_entry(self):
self.app.defaults['tools_film_color'] = self.film_color_entry.get_value()
self.app.options['tools_film_color'] = self.film_color_entry.get_value()