Просмотр исходного кода

- 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.

Marius Stanciu 6 лет назад
Родитель
Сommit
c2563b4857
3 измененных файлов с 82 добавлено и 27 удалено
  1. 9 0
      FlatCAMApp.py
  2. 1 0
      README.md
  3. 72 27
      flatcamGUI/FlatCAMGUI.py

+ 9 - 0
FlatCAMApp.py

@@ -3625,6 +3625,8 @@ class App(QtCore.QObject):
         settings.setValue('axis_font_size',
         settings.setValue('axis_font_size',
                           self.ui.general_defaults_form.general_gui_set_group.axis_font_size_spinner.get_value())
                           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.
         # This will write the setting to the platform specific storage.
         del settings
         del settings
         log.debug("App.final_save() --> App UI state saved.")
         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:
                 else:
                     self.inform.emit(_("[ERROR_NOTCL] Failed to save project file: %s. Retry to save it.") % filename)
                     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:
             # if quit:
                 # t = threading.Thread(target=lambda: self.check_project_file_size(1, filename=filename))
                 # t = threading.Thread(target=lambda: self.check_project_file_size(1, filename=filename))
                 # t.start()
                 # t.start()

+ 1 - 0
README.md

@@ -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 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
 - 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)
 - 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
 17.08.2019
 
 

+ 72 - 27
flatcamGUI/FlatCAMGUI.py

@@ -467,7 +467,7 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
         self.exc_add_array_slot_menuitem = self.exc_editor_menu.addAction(
         self.exc_add_array_slot_menuitem = self.exc_editor_menu.addAction(
             QtGui.QIcon('share/slot_array26.png'), _('Add Slot Array\tQ'))
             QtGui.QIcon('share/slot_array26.png'), _('Add Slot Array\tQ'))
         self.exc_add_slot_menuitem = self.exc_editor_menu.addAction(QtGui.QIcon('share/slot26.png'),
         self.exc_add_slot_menuitem = self.exc_editor_menu.addAction(QtGui.QIcon('share/slot26.png'),
-                                                                     _('Add Slot\tW'))
+                                                                    _('Add Slot\tW'))
         self.exc_editor_menu.addSeparator()
         self.exc_editor_menu.addSeparator()
 
 
         self.exc_resize_drill_menuitem = self.exc_editor_menu.addAction(
         self.exc_resize_drill_menuitem = self.exc_editor_menu.addAction(
@@ -958,8 +958,8 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
         self.pref_export_button.setText(_("Export Preferences"))
         self.pref_export_button.setText(_("Export Preferences"))
         self.pref_export_button.setMinimumWidth(130)
         self.pref_export_button.setMinimumWidth(130)
         self.pref_export_button.setToolTip(
         self.pref_export_button.setToolTip(
-           _( "Export a full set of FlatCAM settings in a file\n"
-              "that is saved on HDD."))
+           _("Export a full set of FlatCAM settings in a file\n"
+             "that is saved on HDD."))
         self.pref_tab_bottom_layout_1.addWidget(self.pref_export_button)
         self.pref_tab_bottom_layout_1.addWidget(self.pref_export_button)
 
 
         self.pref_open_button = QtWidgets.QPushButton()
         self.pref_open_button = QtWidgets.QPushButton()
@@ -1614,7 +1614,6 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
         self.sh_editor.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
         self.sh_editor.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
         self.sh_hlay.addWidget(self.sh_editor)
         self.sh_hlay.addWidget(self.sh_editor)
 
 
-
         # ########################################################### ##
         # ########################################################### ##
         # # ## HERE WE BUILD THE CONTEXT MENU FOR RMB CLICK ON CANVAS # ##
         # # ## 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_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_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_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_draw_disc = self.grb_editor_cmenu.addAction(QtGui.QIcon('share/disc32.png'), _("Disc"))
         self.grb_editor_cmenu.addSeparator()
         self.grb_editor_cmenu.addSeparator()
@@ -1692,7 +1692,7 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
         self.slot = self.e_editor_cmenu.addAction(QtGui.QIcon('share/slot26.png'), _("Add Slot"))
         self.slot = self.e_editor_cmenu.addAction(QtGui.QIcon('share/slot26.png'), _("Add Slot"))
         self.slot_array = self.e_editor_cmenu.addAction(QtGui.QIcon('share/slot_array26.png'), _("Add Slot Array"))
         self.slot_array = self.e_editor_cmenu.addAction(QtGui.QIcon('share/slot_array26.png'), _("Add Slot Array"))
         self.e_editor_cmenu.addSeparator()
         self.e_editor_cmenu.addSeparator()
-        self.drill_resize= self.e_editor_cmenu.addAction(QtGui.QIcon('share/resize16.png'), _("Resize Drill"))
+        self.drill_resize = self.e_editor_cmenu.addAction(QtGui.QIcon('share/resize16.png'), _("Resize Drill"))
 
 
         self.popMenu.addSeparator()
         self.popMenu.addSeparator()
         self.popmenu_copy = self.popMenu.addAction(QtGui.QIcon('share/copy32.png'), _("Copy"))
         self.popmenu_copy = self.popMenu.addAction(QtGui.QIcon('share/copy32.png'), _("Copy"))
@@ -1902,6 +1902,31 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
             del settings
             del settings
             log.debug("FlatCAMGUI.__init__() --> UI layout restored from defaults. QSettings set to 'standard'")
             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):
     def eventFilter(self, obj, event):
         if self.general_defaults_form.general_app_group.toggle_tooltips_cb.get_value() is False:
         if self.general_defaults_form.general_app_group.toggle_tooltips_cb.get_value() is False:
             if event.type() == QtCore.QEvent.ToolTip:
             if event.type() == QtCore.QEvent.ToolTip:
@@ -3158,6 +3183,30 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
                     self.app.ui.grid_snap_btn.trigger()
                     self.app.ui.grid_snap_btn.trigger()
                     return
                     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):
     def dragEnterEvent(self, event):
         if event.mimeData().hasUrls:
         if event.mimeData().hasUrls:
             event.accept()
             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.notebook_font_size_label, self.notebook_font_size_spinner)
         self.form_box.addRow(self.axis_font_size_label, self.axis_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
         # Add the QFormLayout that holds the Application general defaults
         # to the main layout of this TAB
         # to the main layout of this TAB
         self.layout.addLayout(self.form_box)
         self.layout.addLayout(self.form_box)
@@ -5015,7 +5063,7 @@ class ExcellonAdvOptPrefGroupUI(OptionsGroupUI):
         # Probe feedrate
         # Probe feedrate
         self.feedrate_probe_label = QtWidgets.QLabel(_("Feedrate Probe:"))
         self.feedrate_probe_label = QtWidgets.QLabel(_("Feedrate Probe:"))
         self.feedrate_probe_label.setToolTip(
         self.feedrate_probe_label.setToolTip(
-           _( "The feedrate used while the probe is probing.")
+           _("The feedrate used while the probe is probing.")
         )
         )
         grid1.addWidget(self.feedrate_probe_label, 6, 0)
         grid1.addWidget(self.feedrate_probe_label, 6, 0)
         self.feedrate_probe_entry = FCEntry()
         self.feedrate_probe_entry = FCEntry()
@@ -5101,7 +5149,7 @@ class ExcellonExpPrefGroupUI(OptionsGroupUI):
         )
         )
         hlay1.addWidget(self.format_whole_entry, QtCore.Qt.AlignLeft)
         hlay1.addWidget(self.format_whole_entry, QtCore.Qt.AlignLeft)
 
 
-        excellon_separator_label= QtWidgets.QLabel(':')
+        excellon_separator_label = QtWidgets.QLabel(':')
         excellon_separator_label.setFixedWidth(5)
         excellon_separator_label.setFixedWidth(5)
         hlay1.addWidget(excellon_separator_label, QtCore.Qt.AlignLeft)
         hlay1.addWidget(excellon_separator_label, QtCore.Qt.AlignLeft)
 
 
@@ -5715,8 +5763,7 @@ class GeometryAdvOptPrefGroupUI(OptionsGroupUI):
               "(in units per minute).\n"
               "(in units per minute).\n"
               "This is for the rapid move G00.\n"
               "This is for the rapid move G00.\n"
               "It is useful only for Marlin,\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)
         grid1.addWidget(fr_rapid_label, 4, 0)
         self.cncfeedrate_rapid_entry = LengthEntry()
         self.cncfeedrate_rapid_entry = LengthEntry()
@@ -5869,9 +5916,7 @@ class CNCJobGenPrefGroupUI(OptionsGroupUI):
         self.annotation_label = QtWidgets.QLabel(_("Display Annotation:"))
         self.annotation_label = QtWidgets.QLabel(_("Display Annotation:"))
         self.annotation_label.setToolTip(
         self.annotation_label.setToolTip(
             _("This selects if to display text annotation on the plot.\n"
             _("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()
         self.annotation_cb = FCCheckBox()
 
 
@@ -5930,7 +5975,7 @@ class CNCJobGenPrefGroupUI(OptionsGroupUI):
         )
         )
         grid0.addWidget(tdlabel, 6, 0)
         grid0.addWidget(tdlabel, 6, 0)
         self.tooldia_entry = LengthEntry()
         self.tooldia_entry = LengthEntry()
-        grid0.addWidget(self.tooldia_entry,6, 1)
+        grid0.addWidget(self.tooldia_entry, 6, 1)
 
 
         # Number of decimals to use in GCODE coordinates
         # Number of decimals to use in GCODE coordinates
         cdeclabel = QtWidgets.QLabel(_('Coords dec.:'))
         cdeclabel = QtWidgets.QLabel(_('Coords dec.:'))
@@ -6130,15 +6175,15 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI):
 
 
         nccoverlabel = QtWidgets.QLabel(_('Overlap Rate:'))
         nccoverlabel = QtWidgets.QLabel(_('Overlap Rate:'))
         nccoverlabel.setToolTip(
         nccoverlabel.setToolTip(
-           _( "How much (fraction) of the tool width to overlap each tool pass.\n"
-              "Example:\n"
-              "A value here of 0.25 means 25% from the tool diameter found above.\n\n"
-              "Adjust the value starting with lower values\n"
-              "and increasing it if areas that should be cleared are still \n"
-              "not cleared.\n"
-              "Lower values = faster processing, faster execution on PCB.\n"
-              "Higher values = slow processing and slow execution on CNC\n"
-              "due of too many paths.")
+           _("How much (fraction) of the tool width to overlap each tool pass.\n"
+             "Example:\n"
+             "A value here of 0.25 means 25% from the tool diameter found above.\n\n"
+             "Adjust the value starting with lower values\n"
+             "and increasing it if areas that should be cleared are still \n"
+             "not cleared.\n"
+             "Lower values = faster processing, faster execution on PCB.\n"
+             "Higher values = slow processing and slow execution on CNC\n"
+             "due of too many paths.")
         )
         )
         grid0.addWidget(nccoverlabel, 2, 0)
         grid0.addWidget(nccoverlabel, 2, 0)
         self.ncc_overlap_entry = FloatEntry()
         self.ncc_overlap_entry = FloatEntry()
@@ -6630,9 +6675,9 @@ class ToolsPanelizePrefGroupUI(OptionsGroupUI):
                                           {'label': _('Geo'), 'value': 'geometry'}])
                                           {'label': _('Geo'), 'value': 'geometry'}])
         self.panel_type_label = QtWidgets.QLabel(_("Panel Type:"))
         self.panel_type_label = QtWidgets.QLabel(_("Panel Type:"))
         self.panel_type_label.setToolTip(
         self.panel_type_label.setToolTip(
-           _( "Choose the type of object for the panel object:\n"
-              "- Gerber\n"
-              "- Geometry")
+           _("Choose the type of object for the panel object:\n"
+             "- Gerber\n"
+             "- Geometry")
         )
         )
 
 
         grid0.addWidget(self.panel_type_label, 4, 0)
         grid0.addWidget(self.panel_type_label, 4, 0)