- fixed an issue due of recent changes that made the application think that is run always for the first time; fixed not applying the selected language translation

- some more code is refactored in the Preferences
- the axis will now be drawn on the canvas as they were left in the previous run (just like the HUD and the Workspace)
- for processors with less than 4 cores now the default number of workers is 1 (changed from 2)
- some graphical settings go now directly to the defaults dictionary and will not pass through the `options` app dictionary
This commit is contained in:
Marius Stanciu
2022-02-20 22:32:54 +02:00
committed by Marius
parent 42c809c1ff
commit 72186cf8b8
11 changed files with 95 additions and 89 deletions

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.options["global_delta_coordsbar_show"])
self.delta_coords_toolbar.setVisible(self.app.defaults["global_delta_coordsbar_show"])
self.infobar.addWidget(self.coords_toolbar)
self.coords_toolbar.setVisible(self.app.options["global_coordsbar_show"])
self.coords_toolbar.setVisible(self.app.defaults["global_coordsbar_show"])
self.grid_toolbar.setMaximumHeight(24)
self.infobar.addWidget(self.grid_toolbar)
self.grid_toolbar.setVisible(self.app.options["global_gridbar_show"])
self.grid_toolbar.setVisible(self.app.defaults["global_gridbar_show"])
self.status_toolbar.setMaximumHeight(24)
self.infobar.addWidget(self.status_toolbar)
self.status_toolbar.setVisible(self.app.options["global_statusbar_show"])
self.status_toolbar.setVisible(self.app.defaults["global_statusbar_show"])
self.units_label = FCLabel("[mm]")
self.units_label.setToolTip(_("Application units"))
@@ -1887,7 +1887,7 @@ class MainGUI(QtWidgets.QMainWindow):
# this used to be done in the APP.__init__()
self.activity_view = FlatCAMActivityView(icon_location=self.app.resource_location,
icon_kind=self.app.options["global_activity_icon"],
icon_kind=self.app.defaults["global_activity_icon"],
replot_callback=self.app.on_toolbar_replot)
self.infobar.addWidget(self.activity_view)
@@ -1946,7 +1946,7 @@ class MainGUI(QtWidgets.QMainWindow):
self.plugin2_pref_form = Plugins2PreferencesUI(app=self.app)
self.plugin_eng_pref_form = PluginsEngravingPreferencesUI(app=self.app)
self.util_pref_form = UtilPreferencesUI(decimals=self.decimals, defaults=self.app.options)
self.util_pref_form = UtilPreferencesUI(app=self.app)
QtCore.QCoreApplication.instance().installEventFilter(self)
@@ -2044,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.options["global_tabs_detachable"])
self.on_detachable_tab_rmb_click(self.app.defaults["global_tabs_detachable"])
# status bar activation/deactivation
self.infobar.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.ActionsContextMenu)
@@ -2164,20 +2164,20 @@ class MainGUI(QtWidgets.QMainWindow):
:return: None
"""
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.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.preferencesUiManager.save_defaults()
def restore_main_win_geom(self):
try:
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])
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])
except KeyError as e:
self.app.log.debug("appGUI.MainGUI.restore_main_win_geom() --> %s" % str(e))
@@ -2188,7 +2188,7 @@ class MainGUI(QtWidgets.QMainWindow):
:return: None
"""
tb = self.app.options["global_toolbar_view"]
tb = self.app.defaults["global_toolbar_view"]
if tb & 1:
self.toolbarfile.setVisible(True)
@@ -2238,7 +2238,7 @@ class MainGUI(QtWidgets.QMainWindow):
self.toolbarshell.setVisible(False)
def on_tab_setup_context_menu(self):
initial_checked = self.app.options["global_tabs_detachable"]
initial_checked = self.app.defaults["global_tabs_detachable"]
action_name = str(_("Detachable Tabs"))
action = QtGui.QAction(self)
action.setCheckable(True)
@@ -2256,17 +2256,17 @@ class MainGUI(QtWidgets.QMainWindow):
def on_detachable_tab_rmb_click(self, checked):
self.notebook.set_detachable(val=checked)
self.app.options["global_tabs_detachable"] = checked
self.app.defaults["global_tabs_detachable"] = checked
self.plot_tab_area.set_detachable(val=checked)
self.app.options["global_tabs_detachable"] = checked
self.app.defaults["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.options["global_delta_coordsbar_show"])
delta_coords_action.setChecked(self.app.defaults["global_delta_coordsbar_show"])
self.infobar.addAction(delta_coords_action)
delta_coords_action.triggered.connect(self.toggle_delta_coords)
@@ -2274,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.options["global_coordsbar_show"])
coords_action.setChecked(self.app.defaults["global_coordsbar_show"])
self.infobar.addAction(coords_action)
coords_action.triggered.connect(self.toggle_coords)
@@ -2282,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.options["global_gridbar_show"])
grid_action.setChecked(self.app.defaults["global_gridbar_show"])
self.infobar.addAction(grid_action)
grid_action.triggered.connect(self.toggle_gridbar)
@@ -2290,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.options["global_statusbar_show"])
status_action.setChecked(self.app.defaults["global_statusbar_show"])
self.infobar.addAction(status_action)
status_action.triggered.connect(self.toggle_statusbar)
def toggle_coords(self, checked):
self.app.options["global_coordsbar_show"] = checked
self.app.defaults["global_coordsbar_show"] = checked
self.coords_toolbar.setVisible(checked)
def toggle_delta_coords(self, checked):
self.app.options["global_delta_coordsbar_show"] = checked
self.app.defaults["global_delta_coordsbar_show"] = checked
self.delta_coords_toolbar.setVisible(checked)
def toggle_gridbar(self, checked):
self.app.options["global_gridbar_show"] = checked
self.app.defaults["global_gridbar_show"] = checked
self.grid_toolbar.setVisible(checked)
def toggle_statusbar(self, checked):
self.app.options["global_statusbar_show"] = checked
self.app.defaults["global_statusbar_show"] = checked
self.status_toolbar.setVisible(checked)
def on_preferences_open_folder(self):
@@ -2770,10 +2770,10 @@ class MainGUI(QtWidgets.QMainWindow):
for tb in self.findChildren(QtWidgets.QToolBar):
tb.setVisible(False)
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.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.splitter.setSizes([0, 1])
self.toggle_fscreen = True
@@ -3381,11 +3381,11 @@ class MainGUI(QtWidgets.QMainWindow):
# Zoom In
if key == QtCore.Qt.Key.Key_Equal:
self.app.plotcanvas.zoom(1 / self.app.options['global_zoom_ratio'], self.app.mouse)
self.app.plotcanvas.zoom(1 / self.app.defaults['global_zoom_ratio'], self.app.mouse)
# Zoom Out
if key == QtCore.Qt.Key.Key_Minus:
self.app.plotcanvas.zoom(self.app.options['global_zoom_ratio'], self.app.mouse)
self.app.plotcanvas.zoom(self.app.defaults['global_zoom_ratio'], self.app.mouse)
# toggle display of Notebook area
if key == QtCore.Qt.Key.Key_QuoteLeft:
@@ -3513,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.options['global_zoom_ratio'],
self.app.plotcanvas.zoom(1 / self.app.defaults['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.options['global_zoom_ratio'],
self.app.plotcanvas.zoom(self.app.defaults['global_zoom_ratio'],
[self.app.geo_editor.snap_x, self.app.geo_editor.snap_y])
# Switch to Project Tab
@@ -3750,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.options['global_zoom_ratio'],
self.app.plotcanvas.zoom(1 / self.app.defaults['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.options['global_zoom_ratio'],
self.app.plotcanvas.zoom(self.app.defaults['global_zoom_ratio'],
[self.app.grb_editor.snap_x, self.app.grb_editor.snap_y])
return
@@ -3978,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.options['global_zoom_ratio'],
self.app.plotcanvas.zoom(1 / self.app.defaults['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.options['global_zoom_ratio'],
self.app.plotcanvas.zoom(self.app.defaults['global_zoom_ratio'],
[self.app.exc_editor.snap_x, self.app.exc_editor.snap_y])
return