- added ability to lock toolbars within the context menu that is popped up on any toolbars right mouse click. The value is saved in QSettings and it is persistent between application startup's.

This commit is contained in:
Marius Stanciu
2019-08-18 19:35:21 +03:00
parent 8b12dbd52d
commit c2563b4857
3 changed files with 82 additions and 27 deletions

View File

@@ -3625,6 +3625,8 @@ class App(QtCore.QObject):
settings.setValue('axis_font_size',
self.ui.general_defaults_form.general_gui_set_group.axis_font_size_spinner.get_value())
settings.setValue('toolbar_lock', self.ui.lock_action.isChecked())
# This will write the setting to the platform specific storage.
del settings
log.debug("App.final_save() --> App UI state saved.")
@@ -9062,6 +9064,13 @@ The normal flow when working in FlatCAM is the following:</span></p>
else:
self.inform.emit(_("[ERROR_NOTCL] Failed to save project file: %s. Retry to save it.") % filename)
settings = QSettings("Open Source", "FlatCAM")
lock_state = self.ui.lock_action.isChecked()
settings.setValue('toolbar_lock', lock_state)
# This will write the setting to the platform specific storage.
del settings
# if quit:
# t = threading.Thread(target=lambda: self.check_project_file_size(1, filename=filename))
# t.start()

View File

@@ -21,6 +21,7 @@ CAD program, and create G-Code for Isolation routing.
- modified NCC tool so for simple objects (single Polygon) the external object used as reference can have any shape, for the other types of objects the copper cleared area will be the convex hull of the reference object
- modified the strings of the app wherever they contained the char seq <b> </b> so it is not included in the translated string
- updated the translation files for the modified strings (and for the newly added strings)
- added ability to lock toolbars within the context menu that is popped up on any toolbars right mouse click. The value is saved in QSettings and it is persistent between application startup's.
17.08.2019

View File

@@ -1614,7 +1614,6 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.sh_editor.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
self.sh_hlay.addWidget(self.sh_editor)
# ########################################################### ##
# # ## HERE WE BUILD THE CONTEXT MENU FOR RMB CLICK ON CANVAS # ##
# ########################################################### ##
@@ -1671,7 +1670,8 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.grb_draw_track = self.grb_editor_cmenu.addAction(QtGui.QIcon('share/track32.png'), _("Track"))
self.grb_draw_region = self.grb_editor_cmenu.addAction(QtGui.QIcon('share/polygon32.png'), _("Region"))
self.grb_draw_poligonize = self.grb_editor_cmenu.addAction(QtGui.QIcon('share/poligonize32.png'), _("Poligonize"))
self.grb_draw_poligonize = self.grb_editor_cmenu.addAction(QtGui.QIcon('share/poligonize32.png'),
_("Poligonize"))
self.grb_draw_semidisc = self.grb_editor_cmenu.addAction(QtGui.QIcon('share/semidisc32.png'), _("SemiDisc"))
self.grb_draw_disc = self.grb_editor_cmenu.addAction(QtGui.QIcon('share/disc32.png'), _("Disc"))
self.grb_editor_cmenu.addSeparator()
@@ -1902,6 +1902,31 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
del settings
log.debug("FlatCAMGUI.__init__() --> UI layout restored from defaults. QSettings set to 'standard'")
# construct the Toolbar Lock menu entry to the context menu of the QMainWindow
self.lock_action = QtWidgets.QAction()
self.lock_action.setText(_("Lock Toolbars"))
self.lock_action.setCheckable(True)
settings = QSettings("Open Source", "FlatCAM")
if settings.contains("toolbar_lock"):
lock_val = settings.value('toolbar_lock')
if lock_val == 'true':
lock_state = True
self.lock_action.setChecked(True)
else:
lock_state = False
self.lock_action.setChecked(False)
else:
lock_state = False
settings.setValue('toolbar_lock', lock_state)
# This will write the setting to the platform specific storage.
del settings
self.lock_toolbar(lock=lock_state)
self.lock_action.triggered[bool].connect(self.lock_toolbar)
def eventFilter(self, obj, event):
if self.general_defaults_form.general_app_group.toggle_tooltips_cb.get_value() is False:
if event.type() == QtCore.QEvent.ToolTip:
@@ -3158,6 +3183,30 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.app.ui.grid_snap_btn.trigger()
return
def createPopupMenu(self):
menu = super().createPopupMenu()
menu.addSeparator()
menu.addAction(self.lock_action)
return menu
def lock_toolbar(self, lock=False):
"""
Used to (un)lock the toolbars of the app.
:param lock: boolean, will lock all toolbars in place when set True
:return: None
"""
if lock:
for widget in self.children():
if isinstance(widget, QtWidgets.QToolBar):
widget.setMovable(False)
else:
for widget in self.children():
if isinstance(widget, QtWidgets.QToolBar):
widget.setMovable(True)
def dragEnterEvent(self, event):
if event.mimeData().hasUrls:
event.accept()
@@ -3864,7 +3913,6 @@ class GeneralGUISetGroupUI(OptionsGroupUI):
self.form_box.addRow(self.notebook_font_size_label, self.notebook_font_size_spinner)
self.form_box.addRow(self.axis_font_size_label, self.axis_font_size_spinner)
# Add the QFormLayout that holds the Application general defaults
# to the main layout of this TAB
self.layout.addLayout(self.form_box)
@@ -5715,8 +5763,7 @@ class GeometryAdvOptPrefGroupUI(OptionsGroupUI):
"(in units per minute).\n"
"This is for the rapid move G00.\n"
"It is useful only for Marlin,\n"
"ignore for any other cases."
)
"ignore for any other cases.")
)
grid1.addWidget(fr_rapid_label, 4, 0)
self.cncfeedrate_rapid_entry = LengthEntry()
@@ -5869,9 +5916,7 @@ class CNCJobGenPrefGroupUI(OptionsGroupUI):
self.annotation_label = QtWidgets.QLabel(_("Display Annotation:"))
self.annotation_label.setToolTip(
_("This selects if to display text annotation on the plot.\n"
"When checked it will display numbers in order for each end\n"
"of a travel line."
)
"When checked it will display numbers in order for each end\n")
)
self.annotation_cb = FCCheckBox()