From a978b5621d5893cf8f97750dd9c93937b62d3b69 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Fri, 15 Feb 2019 01:48:34 +0200 Subject: [PATCH] - the notebook is automatically collapsed when there are no objects in the collection and it is showed when adding an object - added new options in Edit -> Preferences -> General -> App Preferences to control if the Notebook is showed at startup and if the notebook is closed when there are no objects in the collection and showed when the collection has objects. --- FlatCAMApp.py | 15 +++++++++++++++ FlatCAMGUI.py | 41 +++++++++++++++++++++++++++++------------ FlatCAMObj.py | 15 +++++++++------ ObjectCollection.py | 11 +++++++++++ README.md | 2 ++ share/notebook32.png | Bin 0 -> 287 bytes 6 files changed, 66 insertions(+), 18 deletions(-) create mode 100644 share/notebook32.png diff --git a/FlatCAMApp.py b/FlatCAMApp.py index 45270735..1bcabed4 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -305,6 +305,9 @@ class App(QtCore.QObject): "global_shell_at_startup": self.general_defaults_form.general_app_group.shell_startup_cb, "global_version_check": self.general_defaults_form.general_app_group.version_check_cb, "global_send_stats": self.general_defaults_form.general_app_group.send_stats_cb, + "global_project_at_startup": self.general_defaults_form.general_app_group.project_startup_cb, + "global_project_autohide": self.general_defaults_form.general_app_group.project_autohide_cb, + "global_gridx": self.general_defaults_form.general_gui_group.gridx_entry, "global_gridy": self.general_defaults_form.general_gui_group.gridy_entry, "global_snap_max": self.general_defaults_form.general_gui_group.snap_max_dist_entry, @@ -471,6 +474,9 @@ class App(QtCore.QObject): "units": "IN", "global_version_check": True, "global_send_stats": True, + "global_project_at_startup": False, + "global_project_autohide": True, + "global_gridx": 1.0, "global_gridy": 1.0, "global_snap_max": 0.05, @@ -1116,6 +1122,8 @@ class App(QtCore.QObject): self.ui.menuview_zoom_out.triggered.connect(lambda: self.plotcanvas.zoom(1.5)) self.ui.menuview_toggle_fscreen.triggered.connect(self.on_fullscreen) self.ui.menuview_toggle_parea.triggered.connect(self.on_toggle_plotarea) + self.ui.menuview_toggle_notebook.triggered.connect(self.on_toggle_notebook) + self.ui.menuview_toggle_grid.triggered.connect(self.on_toggle_grid) self.ui.menuview_toggle_axis.triggered.connect(self.on_toggle_axis) self.ui.menuview_toggle_workspace.triggered.connect(self.on_workspace_menu) @@ -1264,6 +1272,13 @@ class App(QtCore.QObject): # this is a flag to signal to other tools that the ui tooltab is locked and not accessible self.tool_tab_locked = False + # decide if to show or hide the Notebook side of the screen at startup + if self.defaults["global_project_at_startup"] is True: + self.ui.splitter.setSizes([1, 1]) + else: + self.ui.splitter.setSizes([0, 1]) + + #################### ### Other setups ### #################### diff --git a/FlatCAMGUI.py b/FlatCAMGUI.py index ae46a58a..75124df4 100644 --- a/FlatCAMGUI.py +++ b/FlatCAMGUI.py @@ -273,6 +273,8 @@ class FlatCAMGUI(QtWidgets.QMainWindow): QtGui.QIcon('share/fscreen32.png'), "&Toggle FullScreen\tALT+F10") self.menuview_toggle_parea = self.menuview.addAction( QtGui.QIcon('share/plot32.png'), "&Toggle Plot Area\tCTRL+F10") + self.menuview_toggle_notebook = self.menuview.addAction( + QtGui.QIcon('share/notebook32.png'), "&Toggle Project/Sel/Tool\t`") self.menuview.addSeparator() self.menuview_toggle_grid = self.menuview.addAction(QtGui.QIcon('share/grid32.png'), "&Toggle Grid Snap\tG") @@ -2819,18 +2821,31 @@ class GeneralAppPrefGroupUI(OptionsGroupUI): self.mselect_radio = RadioSet([{'label': 'CTRL', 'value': 'Control'}, {'label': 'SHIFT', 'value': 'Shift'}]) - # # Mouse panning with "Space" key, CB - # self.pan_with_space_label = QtWidgets.QLabel('Pan w/ Space:') - # self.pan_with_space_label.setToolTip( - # "Check this box if you want to pan when mouse is moved,\n" - # "and key 'Space' is pressed." - # ) - # self.pan_with_space_cb = FCCheckBox(label='') - # self.pan_with_space_cb.setToolTip( - # "Check this box if you want to pan when mouse is moved,\n" - # "and key 'Space' is pressed." - # ) + # Project at StartUp CB + self.project_startup_label = QtWidgets.QLabel('Project at StartUp:') + self.project_startup_label.setToolTip( + "Check this box if you want the project/selected/tool tab area to\n" + "to be shown automatically at startup." + ) + self.project_startup_cb = FCCheckBox(label='') + self.project_startup_cb.setToolTip( + "Check this box if you want the project/selected/tool tab area to\n" + "to be shown automatically at startup." + ) + # Project autohide CB + self.project_autohide_label = QtWidgets.QLabel('Project AutoHide:') + self.project_autohide_label.setToolTip( + "Check this box if you want the project/selected/tool tab area to\n" + "hide automatically when there are no objects loaded and\n" + "to show whenever a new object is created." + ) + self.project_autohide_cb = FCCheckBox(label='') + self.project_autohide_cb.setToolTip( + "Check this box if you want the project/selected/tool tab area to\n" + "hide automatically when there are no objects loaded and\n" + "to show whenever a new object is created." + ) # Just to add empty rows self.spacelabel = QtWidgets.QLabel('') @@ -2847,7 +2862,9 @@ class GeneralAppPrefGroupUI(OptionsGroupUI): self.form_box.addRow(self.panbuttonlabel, self.pan_button_radio) self.form_box.addRow(self.mselectlabel, self.mselect_radio) - # self.form_box.addRow(self.pan_with_space_label, self.pan_with_space_cb) + self.form_box.addRow(self.project_startup_label, self.project_startup_cb) + self.form_box.addRow(self.project_autohide_label, self.project_autohide_cb) + self.form_box.addRow(self.spacelabel, self.spacelabel) # Add the QFormLayout that holds the Application general defaults diff --git a/FlatCAMObj.py b/FlatCAMObj.py index 6f4c48e4..bf6c744f 100644 --- a/FlatCAMObj.py +++ b/FlatCAMObj.py @@ -531,13 +531,16 @@ class FlatCAMGerber(FlatCAMObj, Gerber): ap_dim_item = QtWidgets.QTableWidgetItem('') ap_dim_item.setFlags(QtCore.Qt.ItemIsEnabled) - if self.apertures[ap_code]['size'] is not None: - ap_size_item = QtWidgets.QTableWidgetItem('%.4f' % - float(self.apertures[ap_code]['size'] * - self.file_units_factor)) - ap_size_item.setFlags(QtCore.Qt.ItemIsEnabled) - else: + try: + if self.apertures[ap_code]['size'] is not None: + ap_size_item = QtWidgets.QTableWidgetItem('%.4f' % + float(self.apertures[ap_code]['size'] * + self.file_units_factor)) + else: + ap_size_item = QtWidgets.QTableWidgetItem('') + except KeyError: ap_size_item = QtWidgets.QTableWidgetItem('') + ap_size_item.setFlags(QtCore.Qt.ItemIsEnabled) plot_item = FCCheckBox() plot_item.setLayoutDirection(QtCore.Qt.RightToLeft) diff --git a/ObjectCollection.py b/ObjectCollection.py index 22f9c3fd..45eb3a38 100644 --- a/ObjectCollection.py +++ b/ObjectCollection.py @@ -676,6 +676,11 @@ class ObjectCollection(QtCore.QAbstractItemModel): if group.child_count() is 1: self.view.setExpanded(group_index, True) + # decide if to show or hide the Notebook side of the screen + if self.app.defaults["global_project_autohide"] is True: + # always open the notebook on object added to collection + self.app.ui.splitter.setSizes([1, 1]) + def get_names(self): """ Gets a list of the names of all objects in the collection. @@ -768,6 +773,12 @@ class ObjectCollection(QtCore.QAbstractItemModel): # always go to the Project Tab after object deletion as it may be done with a shortcut key self.app.ui.notebook.setCurrentWidget(self.app.ui.project_tab) + # decide if to show or hide the Notebook side of the screen + if self.app.defaults["global_project_autohide"] is True: + # hide the notebook if there are no objects in the collection + if not self.get_list(): + self.app.ui.splitter.setSizes([0, 1]) + def delete_all(self): FlatCAMApp.App.log.debug(str(inspect.stack()[1][3]) + "--> OC.delete_all()") diff --git a/README.md b/README.md index 66109853..796944b3 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ CAD program, and create G-Code for Isolation routing. - when linked, the grid snap on Y will copy the value in grid snap on X in real time - in Gerber aperture table now the values are displayed in the current units set in FlatCAM - added shortcut key 'J' (jump to location) in Editors and added an icon to the dialog popup window +- the notebook is automatically collapsed when there are no objects in the collection and it is showed when adding an object +- added new options in Edit -> Preferences -> General -> App Preferences to control if the Notebook is showed at startup and if the notebook is closed when there are no objects in the collection and showed when the collection has objects. 13.02.2019 diff --git a/share/notebook32.png b/share/notebook32.png new file mode 100644 index 0000000000000000000000000000000000000000..ebf69e04c5ed3f5de14af722909cf538429caee1 GIT binary patch literal 287 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdzmSQK*5Dp-y;YjHK@;M7UB8wRq zxP?KOkzv*x383IXPZ!6Kh}O5$9r>CJ1YGC07-#HRXn61PiD@kblELB)8y8;lyF7E( z3;$gTjQ5hQM7Ul`GK5#y@G&u}TbNtc9y1ks86o2k{vz#WCezYq#_Ip?Gp9dDQx$4D zuamk<%W&IK4KDe{#Y-DRZ8Q=%?{h{Rwr!Lu@K130#yPcTK9lSRo$mpamW;yP7q`eo zA6Xs5+j-X{(wpV?k)TJ}i=#YU?oaXW^yY2!b>jXfmQn8_)Hvm7XsCm#?}A^?LV_9{ c8|&*C=T#MdjR~0S4fG6yr>mdKI;Vst0QhNR+yDRo literal 0 HcmV?d00001