From d6dd64ae685bf557cf2c5fa2e3e8bd5a371ece43 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Mon, 26 Oct 2020 11:49:20 +0200 Subject: [PATCH] - added a new menu entry and functionality in the View category: enable all non-selected (shortcut key ALT+3) - fixed shortcut keys for a number of functionality and in some cases added some new - fixed the enable/disable all plots functionality - fixed issue with the app window restored in a shifted position after doing Fullscreen - fixed issue with coords, delta_coords and status toolbars being disabled when entering fullscreen mode and remaining disabled after restore to normal mode --- CHANGELOG.md | 9 ++++ appGUI/MainGUI.py | 88 ++++++++++++++++++++++++------------ appTools/ToolInvertGerber.py | 2 +- app_Main.py | 30 ++++++------ defaults.py | 8 ++-- 5 files changed, 90 insertions(+), 47 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1fec945..a112f0c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,15 @@ CHANGELOG for FlatCAM beta ================================================= +26.10.2020 + +- added a new menu entry and functionality in the View category: enable all non-selected (shortcut key ALT+3) +- fixed shortcut keys for a number of functionality and in some cases added some new +- fixed the enable/disable all plots functionality +- fixed issue with the app window restored in a shifted position after doing Fullscreen +- fixed issue with coords, delta_coords and status toolbars being disabled when entering fullscreen mode and remaining disabled after restore to normal mode + + 25.10.2020 - updated the Italian translation (by Massimiliano Golfetto) diff --git a/appGUI/MainGUI.py b/appGUI/MainGUI.py index 2d7b7797..d4ce9df2 100644 --- a/appGUI/MainGUI.py +++ b/appGUI/MainGUI.py @@ -455,8 +455,11 @@ class MainGUI(QtWidgets.QMainWindow): QtGui.QIcon(self.app.resource_location + '/replot16.png'), _('Enable all plots\tAlt+1')) self.menuviewdisableall = self.menuview.addAction( QtGui.QIcon(self.app.resource_location + '/clear_plot16.png'), _('Disable all plots\tAlt+2')) + self.menuviewenableother = self.menuview.addAction( + QtGui.QIcon(self.app.resource_location + '/replot16.png'), _('Enable non-selected\tAlt+3')) self.menuviewdisableother = self.menuview.addAction( - QtGui.QIcon(self.app.resource_location + '/clear_plot16.png'), _('Disable non-selected\tAlt+3')) + QtGui.QIcon(self.app.resource_location + '/clear_plot16.png'), _('Disable non-selected\tAlt+4')) + # Separator self.menuview.addSeparator() self.menuview_zoom_fit = self.menuview.addAction( @@ -486,13 +489,13 @@ class MainGUI(QtWidgets.QMainWindow): self.menuview_toggle_grid = self.menuview.addAction( QtGui.QIcon(self.app.resource_location + '/grid32.png'), _("Toggle Grid Snap\tG")) self.menuview_toggle_grid_lines = self.menuview.addAction( - QtGui.QIcon(self.app.resource_location + '/grid_lines32.png'), _("Toggle Grid Lines\tAlt+G")) + QtGui.QIcon(self.app.resource_location + '/grid_lines32.png'), _("Toggle Grid Lines\tShift+G")) self.menuview_toggle_axis = self.menuview.addAction( - QtGui.QIcon(self.app.resource_location + '/axis32.png'), _("Toggle Axis\tShift+G")) + QtGui.QIcon(self.app.resource_location + '/axis32.png'), _("Toggle Axis\tShift+A")) self.menuview_toggle_workspace = self.menuview.addAction( QtGui.QIcon(self.app.resource_location + '/workspace24.png'), _("Toggle Workspace\tShift+W")) self.menuview_toggle_hud = self.menuview.addAction( - QtGui.QIcon(self.app.resource_location + '/hud_32.png'), _("Toggle HUD\tAlt+H")) + QtGui.QIcon(self.app.resource_location + '/hud_32.png'), _("Toggle HUD\tShift+H")) # ######################################################################## # ########################## Objects # ################################### @@ -1595,18 +1598,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_coords_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.defaults["global_coords_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.defaults["global_grid_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.defaults["global_status_show"]) + self.status_toolbar.setVisible(self.app.defaults["global_statusbar_show"]) self.units_label = QtWidgets.QLabel("[mm]") self.units_label.setToolTip(_("Application units")) @@ -1754,6 +1757,7 @@ class MainGUI(QtWidgets.QMainWindow): self.y_pos = None self.width = None self.height = None + self.titlebar_height = None self.geom_update[int, int, int, int, int].connect(self.save_geometry) self.final_save.connect(self.app.final_save) @@ -1887,7 +1891,7 @@ class MainGUI(QtWidgets.QMainWindow): delta_coords_action = QtWidgets.QAction(self) delta_coords_action.setCheckable(True) delta_coords_action.setText(delta_coords_action_name) - delta_coords_action.setChecked(self.app.defaults["global_delta_coords_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) @@ -1895,7 +1899,7 @@ class MainGUI(QtWidgets.QMainWindow): coords_action = QtWidgets.QAction(self) coords_action.setCheckable(True) coords_action.setText(coords_action_name) - coords_action.setChecked(self.app.defaults["global_coords_show"]) + coords_action.setChecked(self.app.defaults["global_coordsbar_show"]) self.infobar.addAction(coords_action) coords_action.triggered.connect(self.toggle_coords) @@ -1903,7 +1907,7 @@ class MainGUI(QtWidgets.QMainWindow): grid_action = QtWidgets.QAction(self) grid_action.setCheckable(True) grid_action.setText(grid_action_name) - grid_action.setChecked(self.app.defaults["global_grid_show"]) + grid_action.setChecked(self.app.defaults["global_gridbar_show"]) self.infobar.addAction(grid_action) grid_action.triggered.connect(self.toggle_gridbar) @@ -1911,24 +1915,24 @@ class MainGUI(QtWidgets.QMainWindow): status_action = QtWidgets.QAction(self) status_action.setCheckable(True) status_action.setText(status_action_name) - status_action.setChecked(self.app.defaults["global_status_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.defaults["global_coords_show"] = checked + self.app.defaults["global_coordsbar_show"] = checked self.coords_toolbar.setVisible(checked) def toggle_delta_coords(self, checked): - self.app.defaults["global_delta_coords_show"] = checked + self.app.defaults["global_delta_coordsbar_show"] = checked self.delta_coords_toolbar.setVisible(checked) def toggle_gridbar(self, checked): - self.app.defaults["global_grid_show"] = checked + self.app.defaults["global_gridbar_show"] = checked self.grid_toolbar.setVisible(checked) def toggle_statusbar(self, checked): - self.app.defaults["global_status_show"] = checked + self.app.defaults["global_statusbar_show"] = checked self.status_toolbar.setVisible(checked) def eventFilter(self, obj, event): @@ -2399,6 +2403,10 @@ class MainGUI(QtWidgets.QMainWindow): # SHIFT elif modifiers == QtCore.Qt.ShiftModifier: + # Toggle axis + if key == QtCore.Qt.Key_A: + self.app.plotcanvas.on_toggle_axis() + # Copy Object Name if key == QtCore.Qt.Key_C: self.app.on_copy_name() @@ -2407,9 +2415,10 @@ class MainGUI(QtWidgets.QMainWindow): if key == QtCore.Qt.Key_E: self.app.on_toggle_code_editor() - # Toggle axis + # Toggle Grid lines if key == QtCore.Qt.Key_G: - self.app.plotcanvas.on_toggle_axis() + self.app.plotcanvas.on_toggle_grid_lines() + return # Toggle HUD (Heads-Up Display) if key == QtCore.Qt.Key_H: @@ -2464,6 +2473,10 @@ class MainGUI(QtWidgets.QMainWindow): # Disable all other plots if key == Qt.Key_3: + self.app.enable_other_plots() + + # Disable all other plots + if key == Qt.Key_4: self.app.disable_other_plots() # Align in Object Tool @@ -2490,10 +2503,9 @@ class MainGUI(QtWidgets.QMainWindow): self.app.fiducial_tool.run(toggle=True) return - # Toggle Grid lines + # Punch Gerber Tool if key == QtCore.Qt.Key_G: - self.app.plotcanvas.on_toggle_grid_lines() - return + self.app.invert_tool.run(toggle=True) # Punch Gerber Tool if key == QtCore.Qt.Key_H: @@ -3748,13 +3760,14 @@ class MainGUI(QtWidgets.QMainWindow): self.y_pos = a.y() self.width = a.width() self.height = a.height() + self.titlebar_height = self.app.qapp.style().pixelMetric(QtWidgets.QStyle.PM_TitleBarHeight) # set new geometry to full desktop rect # Subtracting and adding the pixels below it's hack to bypass a bug in Qt5 and OpenGL that made that a # window drawn with OpenGL in fullscreen will not show any other windows on top which means that menus and # everything else will not work without this hack. This happen in Windows. # https://bugreports.qt.io/browse/QTBUG-41309 - desktop = QtWidgets.QApplication.desktop() + desktop = self.app.qapp.desktop() screen = desktop.screenNumber(QtGui.QCursor.pos()) rec = desktop.screenGeometry(screen) @@ -3762,6 +3775,7 @@ class MainGUI(QtWidgets.QMainWindow): y = rec.y() - 1 h = rec.height() + 2 w = rec.width() + 2 + self.setGeometry(x, y, w, h) self.show() @@ -3769,13 +3783,17 @@ class MainGUI(QtWidgets.QMainWindow): for tb in self.findChildren(QtWidgets.QToolBar): tb.setVisible(False) - self.grid_toolbar.setVisible(self.app.defaults["global_grid_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 elif self.toggle_fscreen is True or disable is True: self.setWindowFlags(flags & ~Qt.FramelessWindowHint) - self.setGeometry(self.x_pos, self.y_pos, self.width, self.height) + # the additions are made to account for the pixels we subtracted/added above in the (x, y, h, w) + self.setGeometry(self.x_pos+1, self.y_pos+self.titlebar_height+4, self.width, self.height) self.showNormal() self.restore_toolbar_view() self.toggle_fscreen = False @@ -4040,6 +4058,10 @@ class ShortcutsTab(QtWidgets.QWidget):     + + Shift+A +  %s + Shift+C  %s @@ -4052,6 +4074,10 @@ class ShortcutsTab(QtWidgets.QWidget): Shift+G  %s + + Shift+H +  %s + Shift+J  %s @@ -4190,6 +4216,10 @@ class ShortcutsTab(QtWidgets.QWidget): Alt+3  %s + + Alt+4 +  %s + Alt+F10  %s @@ -4270,22 +4300,24 @@ class ShortcutsTab(QtWidgets.QWidget): _("Open Project"), _("Print (PDF)"), _("PDF Import Tool"), _("Save Project"), _("Toggle Plot Area"), # SHIFT section - _("Copy Obj_Name"), - _("Toggle Code Editor"), _("Toggle the axis"), _("Locate in Object"), _("Distance Minimum Tool"), + _("Toggle the axis"), _("Copy Obj_Name"), + _("Toggle Code Editor"), _("Toggle Grid Lines"), _("Toggle HUD"), _("Locate in Object"), + _("Distance Minimum Tool"), _("Open Preferences Window"), _("Rotate by 90 degree CCW"), _("Run a Script"), _("Toggle the workspace"), _("Skew on X axis"), _("Skew on Y axis"), # ALT section _("Align Objects Tool"), _("Calculators Tool"), _("2-Sided PCB Tool"), _("Extract Drills Tool"), - _("Fiducials Tool"), _("Toggle Grid Lines"), + _("Fiducials Tool"), _("Invert Gerber Tool"), _("Punch Gerber Tool"), _("Isolation Tool"), _("Copper Thieving Tool"), _("Solder Paste Dispensing Tool"), _("Film PCB Tool"), _("Corner Markers Tool"), _("Non-Copper Clearing Tool"), _("Optimal Tool"), _("Paint Area Tool"), _("QRCode Tool"), _("Rules Check Tool"), _("View File Source"), _("Transformations Tool"), _("Subtract Tool"), _("Cutout PCB Tool"), _("Panelize PCB"), - _("Enable all Plots"), _("Disable all Plots"), _("Disable Non-selected Plots"), + _("Enable all Plots"), _("Disable all Plots"), + _("Enable Non-selected Plots"), _("Disable Non-selected Plots"), _("Toggle Full Screen"), # CTRL + ALT section diff --git a/appTools/ToolInvertGerber.py b/appTools/ToolInvertGerber.py index 3d03224e..59270e9f 100644 --- a/appTools/ToolInvertGerber.py +++ b/appTools/ToolInvertGerber.py @@ -44,7 +44,7 @@ class ToolInvertGerber(AppTool): self.ui.reset_button.clicked.connect(self.set_tool_ui) def install(self, icon=None, separator=None, **kwargs): - AppTool.install(self, icon, separator, shortcut='', **kwargs) + AppTool.install(self, icon, separator, shortcut='ALT+G', **kwargs) def run(self, toggle=True): self.app.defaults.report_usage("ToolInvertGerber()") diff --git a/app_Main.py b/app_Main.py index 2a92c157..518594d3 100644 --- a/app_Main.py +++ b/app_Main.py @@ -1440,9 +1440,10 @@ class App(QtCore.QObject): self.ui.menuoptions_view_source.triggered.connect(self.on_view_source) self.ui.menuoptions_tools_db.triggered.connect(lambda: self.on_tools_database(source='app')) - self.ui.menuviewdisableall.triggered.connect(self.disable_all_plots) - self.ui.menuviewdisableother.triggered.connect(self.disable_other_plots) self.ui.menuviewenable.triggered.connect(self.enable_all_plots) + self.ui.menuviewdisableall.triggered.connect(self.disable_all_plots) + self.ui.menuviewenableother.triggered.connect(self.enable_other_plots) + self.ui.menuviewdisableother.triggered.connect(self.disable_other_plots) self.ui.menuview_zoom_fit.triggered.connect(self.on_zoom_fit) self.ui.menuview_zoom_in.triggered.connect(self.on_zoom_in) @@ -5763,8 +5764,8 @@ class App(QtCore.QObject): pass # restore the coords toolbars - self.ui.toggle_coords(checked=self.defaults["global_coords_show"]) - self.ui.toggle_delta_coords(checked=self.defaults["global_delta_coords_show"]) + self.ui.toggle_coords(checked=self.defaults["global_coordsbar_show"]) + self.ui.toggle_delta_coords(checked=self.defaults["global_delta_coordsbar_show"]) def on_flipy(self): """ @@ -7536,22 +7537,25 @@ class App(QtCore.QObject): self.defaults.report_usage("disable_all_plots()") self.disable_plots(self.collection.get_list()) - self.inform.emit('[success] %s' % - _("All plots disabled.")) + self.inform.emit('[success] %s' % _("All plots disabled.")) def disable_other_plots(self): self.defaults.report_usage("disable_other_plots()") self.disable_plots(self.collection.get_non_selected()) - self.inform.emit('[success] %s' % - _("All non selected plots disabled.")) + self.inform.emit('[success] %s' % _("All non selected plots disabled.")) def enable_all_plots(self): self.defaults.report_usage("enable_all_plots()") self.enable_plots(self.collection.get_list()) - self.inform.emit('[success] %s' % - _("All plots enabled.")) + self.inform.emit('[success] %s' % _("All plots enabled.")) + + def enable_other_plots(self): + self.defaults.report_usage("enable_other_plots()") + + self.enable_plots(self.collection.get_non_selected()) + self.inform.emit('[success] %s' % _("All non selected plots enabled.")) def on_enable_sel_plots(self): log.debug("App.on_enable_sel_plot()") @@ -7616,10 +7620,6 @@ class App(QtCore.QObject): :return: """ - # if no objects selected then do nothing - if not self.collection.get_selected(): - return - log.debug("Disabling plots ...") # self.inform.emit(_("Working ...")) @@ -7654,6 +7654,8 @@ class App(QtCore.QObject): plot_obj.plot(visible=False, kind=self.defaults["cncjob_plot_kind"]) else: plot_obj.plot(visible=False) + for plot_obj in objs: + plot_obj.shapes.redraw() self.worker_task.emit({'fcn': worker_task, 'params': [objects]}) diff --git a/defaults.py b/defaults.py index 61fef51c..92cde5f0 100644 --- a/defaults.py +++ b/defaults.py @@ -31,9 +31,9 @@ class FlatCAMDefaults: "global_stats": dict(), "global_tabs_detachable": True, - "global_coords_show": True, - "global_delta_coords_show": False, - "global_status_show": True, + "global_coordsbar_show": True, + "global_delta_coordsbar_show": False, + "global_statusbar_show": True, "global_jump_ref": 'abs', "global_locate_pt": 'bl', @@ -124,7 +124,7 @@ class FlatCAMDefaults: "global_project_autohide": True, # General App Settings - "global_grid_show": True, + "global_gridbar_show": True, "global_gridx": 1.0, "global_gridy": 1.0, "global_snap_max": 0.05,