jpcgt/flatcam/Beta слито с Beta

This commit is contained in:
Camellan 2019-08-01 13:29:21 +04:00
commit 40dcb3a070
26 changed files with 7106 additions and 6679 deletions

View File

@ -255,6 +255,15 @@ class App(QtCore.QObject):
json.dump([], f)
f.close()
try:
fp = open(self.data_path + '/recent_projects.json')
fp.close()
except IOError:
App.log.debug('Creating empty recent_projects.json')
fp = open(self.data_path + '/recent_projects.json', 'w')
json.dump([], fp)
fp.close()
# Application directory. CHDIR to it. Otherwise, trying to load
# GUI icons will fail as their path is relative.
# This will fail under cx_freeze ...
@ -294,6 +303,8 @@ class App(QtCore.QObject):
# ### Data ####
# #############
self.recent = []
self.recent_projects = []
self.clipboard = QtWidgets.QApplication.clipboard()
self.proc_container = FCVisibleProcessContainer(self.ui.activity_view)
@ -1499,6 +1510,7 @@ class App(QtCore.QObject):
self.ui.general_defaults_form.general_app_group.units_radio.activated_custom.connect(
lambda: self.on_toggle_units(no_pref=False))
# ##############################
# ### GUI PREFERENCES SIGNALS ##
# ##############################
@ -1960,6 +1972,9 @@ class App(QtCore.QObject):
# Variable to store the GCODE that was edited
self.gcode_edited = ""
# if Preferences are changed in the Edit -> Preferences tab the value will be set to True
self.preferences_changed_flag = False
self.grb_list = ['gbr', 'ger', 'gtl', 'gbl', 'gts', 'gbs', 'gtp', 'gbp', 'gto', 'gbo', 'gm1', 'gm2', 'gm3',
'gko', 'cmp', 'sol', 'stc', 'sts', 'plc', 'pls', 'crc', 'crs', 'tsm', 'bsm', 'ly2', 'ly15',
'dim', 'mil', 'grb', 'top', 'bot', 'smt', 'smb', 'sst', 'ssb', 'spt', 'spb', 'pho', 'gdo',
@ -2922,12 +2937,19 @@ class App(QtCore.QObject):
record = {'kind': str(kind), 'filename': str(filename)}
if record in self.recent:
return
self.recent.insert(0, record)
if record in self.recent_projects:
return
if record['kind'] == 'project':
self.recent_projects.insert(0, record)
else:
self.recent.insert(0, record)
if len(self.recent) > self.defaults['global_recent_limit']: # Limit reached
self.recent.pop()
if len(self.recent_projects) > self.defaults['global_recent_limit']: # Limit reached
self.recent_projects.pop()
try:
f = open(self.data_path + '/recent.json', 'w')
except IOError:
@ -2938,6 +2960,16 @@ class App(QtCore.QObject):
json.dump(self.recent, f, default=to_dict, indent=2, sort_keys=True)
f.close()
try:
fp = open(self.data_path + '/recent_projects.json', 'w')
except IOError:
App.log.error("Failed to open recent items file for writing.")
self.inform.emit(_('[ERROR_NOTCL] Failed to open recent projects file for writing.'))
return
json.dump(self.recent_projects, fp, default=to_dict, indent=2, sort_keys=True)
fp.close()
# Re-build the recent items menu
self.setup_recent_items()
@ -3927,7 +3959,7 @@ class App(QtCore.QObject):
def on_toggle_units_click(self):
try:
self.ui.general_defaults_form.general_app_group.units_radio.activated_custom.disconnect()
except TypeError:
except (TypeError, AttributeError):
pass
if self.defaults["units"] == 'MM':
@ -4541,6 +4573,7 @@ class App(QtCore.QObject):
def on_save_button(self):
log.debug("App.on_save_button() --> Saving preferences to file.")
self.preferences_changed_flag = False
self.save_defaults(silent=False)
# load the defaults so they are updated into the app
@ -5133,7 +5166,6 @@ class App(QtCore.QObject):
self.draw_selection_shape(curr_sel_obj)
def on_preferences(self):
# add the tab if it was closed
self.ui.plot_tab_area.addTab(self.ui.preferences_tab, _("Preferences"))
@ -5145,6 +5177,115 @@ class App(QtCore.QObject):
self.ui.plot_tab_area.setCurrentWidget(self.ui.preferences_tab)
self.ui.show()
# this disconnect() is done so the slot will be connected only once
try:
self.ui.plot_tab_area.tab_closed_signal.disconnect(self.on_preferences_closed)
except (TypeError, AttributeError):
pass
self.ui.plot_tab_area.tab_closed_signal.connect(self.on_preferences_closed)
# detect changes in the preferences
for idx in range(self.ui.pref_tab_area.count()):
for tb in self.ui.pref_tab_area.widget(idx).findChildren(QtCore.QObject):
try:
try:
tb.textEdited.disconnect(self.on_preferences_edited)
except (TypeError, AttributeError):
pass
tb.textEdited.connect(self.on_preferences_edited)
except AttributeError:
pass
try:
try:
tb.modificationChanged.disconnect(self.on_preferences_edited)
except (TypeError, AttributeError):
pass
tb.modificationChanged.connect(self.on_preferences_edited)
except AttributeError:
pass
try:
try:
tb.toggled.disconnect(self.on_preferences_edited)
except (TypeError, AttributeError):
pass
tb.toggled.connect(self.on_preferences_edited)
except AttributeError:
pass
try:
try:
tb.valueChanged.disconnect(self.on_preferences_edited)
except (TypeError, AttributeError):
pass
tb.valueChanged.connect(self.on_preferences_edited)
except AttributeError:
pass
try:
try:
tb.currentIndexChanged.disconnect(self.on_preferences_edited)
except (TypeError, AttributeError):
pass
tb.currentIndexChanged.connect(self.on_preferences_edited)
except AttributeError:
pass
def on_preferences_edited(self):
self.inform.emit(_("[WARNING_NOTCL] Preferences edited but not saved."))
self.preferences_changed_flag = True
def on_preferences_closed(self):
# disconnect
for idx in range(self.ui.pref_tab_area.count()):
for tb in self.ui.pref_tab_area.widget(idx).findChildren(QtCore.QObject):
try:
tb.textEdited.disconnect(self.on_preferences_edited)
except (TypeError, AttributeError):
pass
try:
tb.modificationChanged.disconnect(self.on_preferences_edited)
except (TypeError, AttributeError):
pass
try:
tb.toggled.disconnect(self.on_preferences_edited)
except (TypeError, AttributeError):
pass
try:
tb.valueChanged.disconnect(self.on_preferences_edited)
except (TypeError, AttributeError):
pass
try:
tb.currentIndexChanged.disconnect(self.on_preferences_edited)
except (TypeError, AttributeError):
pass
if self.preferences_changed_flag is True:
msgbox = QtWidgets.QMessageBox()
msgbox.setText(_("One or more values are changed.\n"
"Do you want to save the Preferences?"))
msgbox.setWindowTitle(_("Save Preferences"))
msgbox.setWindowIcon(QtGui.QIcon('share/save_as.png'))
bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.YesRole)
bt_no = msgbox.addButton(_('No'), QtWidgets.QMessageBox.NoRole)
msgbox.setDefaultButton(bt_yes)
msgbox.exec_()
response = msgbox.clickedButton()
if response == bt_yes:
self.on_save_button()
self.inform.emit(_("[success] Defaults saved."))
else:
self.preferences_changed_flag = False
return
def on_flipy(self):
self.report_usage("on_flipy()")
@ -8253,7 +8394,7 @@ class App(QtCore.QObject):
'pdf': lambda fname: self.worker_task.emit({'fcn': self.pdf_tool.open_pdf, 'params': [fname]})
}
# Open file
# Open recent file for files
try:
f = open(self.data_path + '/recent.json')
except IOError:
@ -8270,6 +8411,23 @@ class App(QtCore.QObject):
return
f.close()
# Open recent file for projects
try:
fp = open(self.data_path + '/recent_projects.json')
except IOError:
App.log.error("Failed to load recent project item list.")
self.inform.emit(_("[ERROR_NOTCL] Failed to load recent projects item list."))
return
try:
self.recent_projects = json.load(fp)
except json.scanner.JSONDecodeError:
App.log.error("Failed to parse recent project item list.")
self.inform.emit(_("[ERROR_NOTCL] Failed to parse recent project item list."))
fp.close()
return
fp.close()
# Closure needed to create callbacks in a loop.
# Otherwise late binding occurs.
def make_callback(func, fname):
@ -8277,7 +8435,7 @@ class App(QtCore.QObject):
func(fname)
return opener
def reset_recent():
def reset_recent_files():
# Reset menu
self.ui.recent.clear()
self.recent = []
@ -8289,28 +8447,66 @@ class App(QtCore.QObject):
json.dump(self.recent, f)
def reset_recent_projects():
# Reset menu
self.ui.recent_projects.clear()
self.recent_projects = []
try:
fp = open(self.data_path + '/recent_projects.json', 'w')
except IOError:
App.log.error("Failed to open recent projects items file for writing.")
return
json.dump(self.recent, fp)
# Reset menu
self.ui.recent.clear()
self.ui.recent_projects.clear()
# Create menu items
# Create menu items for projects
for recent in self.recent_projects:
filename = recent['filename'].split('/')[-1].split('\\')[-1]
if recent['kind'] == 'project':
try:
action = QtWidgets.QAction(QtGui.QIcon(icons[recent["kind"]]), filename, self)
# Attach callback
o = make_callback(openers[recent["kind"]], recent['filename'])
action.triggered.connect(o)
self.ui.recent_projects.addAction(action)
except KeyError:
App.log.error("Unsupported file type: %s" % recent["kind"])
# Last action in Recent Files menu is one that Clear the content
clear_action_proj = QtWidgets.QAction(QtGui.QIcon('share/trash32.png'), (_("Clear Recent files")), self)
clear_action_proj.triggered.connect(reset_recent_projects)
self.ui.recent_projects.addSeparator()
self.ui.recent_projects.addAction(clear_action_proj)
# Create menu items for files
for recent in self.recent:
filename = recent['filename'].split('/')[-1].split('\\')[-1]
try:
action = QtWidgets.QAction(QtGui.QIcon(icons[recent["kind"]]), filename, self)
if recent['kind'] != 'project':
try:
action = QtWidgets.QAction(QtGui.QIcon(icons[recent["kind"]]), filename, self)
# Attach callback
o = make_callback(openers[recent["kind"]], recent['filename'])
action.triggered.connect(o)
# Attach callback
o = make_callback(openers[recent["kind"]], recent['filename'])
action.triggered.connect(o)
self.ui.recent.addAction(action)
self.ui.recent.addAction(action)
except KeyError:
App.log.error("Unsupported file type: %s" % recent["kind"])
except KeyError:
App.log.error("Unsupported file type: %s" % recent["kind"])
# Last action in Recent Files menu is one that Clear the content
clear_action = QtWidgets.QAction(QtGui.QIcon('share/trash32.png'), (_("Clear Recent files")), self)
clear_action.triggered.connect(reset_recent)
clear_action.triggered.connect(reset_recent_files)
self.ui.recent.addSeparator()
self.ui.recent.addAction(clear_action)

View File

@ -582,7 +582,7 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
try:
# if connected, disconnect the signal from the slot on item_changed as it creates issues
self.ui.apertures_table.itemChanged.disconnect()
except TypeError:
except (TypeError, AttributeError):
pass
self.apertures_row = 0
@ -726,12 +726,12 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
for row in range(self.ui.apertures_table.rowCount()):
try:
self.ui.apertures_table.cellWidget(row, 5).clicked.disconnect()
except TypeError:
except (TypeError, AttributeError):
pass
try:
self.ui.mark_all_cb.clicked.disconnect(self.on_mark_all_click)
except TypeError:
except (TypeError, AttributeError):
pass
def on_generatenoncopper_button_click(self, *args):
@ -1832,7 +1832,7 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
try:
# if connected, disconnect the signal from the slot on item_changed as it creates issues
self.ui.tools_table.itemChanged.disconnect()
except TypeError:
except (TypeError, AttributeError):
pass
n = len(self.tools)
@ -2120,12 +2120,12 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
for row in range(self.ui.tools_table.rowCount()):
try:
self.ui.tools_table.cellWidget(row, 5).clicked.disconnect()
except TypeError:
except (TypeError, AttributeError):
pass
try:
self.ui.plot_cb.stateChanged.disconnect()
except TypeError:
except (TypeError, AttributeError):
pass
def on_tool_offset_edit(self):
@ -3501,66 +3501,66 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
if isinstance(current_widget, FCCheckBox):
try:
self.ui.grid3.itemAt(i).widget().stateChanged.disconnect(self.gui_form_to_storage)
except TypeError:
except (TypeError, AttributeError):
pass
elif isinstance(current_widget, FCComboBox):
try:
self.ui.grid3.itemAt(i).widget().currentIndexChanged.disconnect(self.gui_form_to_storage)
except TypeError:
except (TypeError, AttributeError):
pass
elif isinstance(current_widget, LengthEntry) or isinstance(current_widget, IntEntry) or \
isinstance(current_widget, FCEntry) or isinstance(current_widget, FloatEntry):
try:
self.ui.grid3.itemAt(i).widget().editingFinished.disconnect(self.gui_form_to_storage)
except TypeError:
except (TypeError, AttributeError):
pass
for row in range(self.ui.geo_tools_table.rowCount()):
for col in [2, 3, 4]:
try:
self.ui.geo_tools_table.cellWidget(row, col).currentIndexChanged.disconnect()
except TypeError:
except (TypeError, AttributeError):
pass
try:
self.ui.addtool_btn.clicked.disconnect()
except TypeError:
except (TypeError, AttributeError):
pass
try:
self.ui.copytool_btn.clicked.disconnect()
except TypeError:
except (TypeError, AttributeError):
pass
try:
self.ui.deltool_btn.clicked.disconnect()
except TypeError:
except (TypeError, AttributeError):
pass
try:
self.ui.geo_tools_table.currentItemChanged.disconnect()
except TypeError:
except (TypeError, AttributeError):
pass
try:
self.ui.geo_tools_table.itemChanged.disconnect()
except TypeError:
except (TypeError, AttributeError):
pass
try:
self.ui.tool_offset_entry.editingFinished.disconnect()
except TypeError:
except (TypeError, AttributeError):
pass
for row in range(self.ui.geo_tools_table.rowCount()):
try:
self.ui.geo_tools_table.cellWidget(row, 6).clicked.disconnect()
except TypeError:
except (TypeError, AttributeError):
pass
try:
self.ui.plot_cb.stateChanged.disconnect()
except TypeError:
except (TypeError, AttributeError):
pass
def on_tool_add(self, dia=None):
@ -5546,7 +5546,7 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
try:
self.ui.annotation_cb.stateChanged.disconnect(self.on_annotation_change)
except TypeError:
except (TypeError, AttributeError):
pass
self.ui.annotation_cb.stateChanged.connect(self.on_annotation_change)
@ -5590,7 +5590,7 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
self.ui.cnc_tools_table.cellWidget(row, 6).clicked.disconnect(self.on_plot_cb_click_table)
try:
self.ui.plot_cb.stateChanged.disconnect(self.on_plot_cb_click)
except TypeError:
except (TypeError, AttributeError):
pass
def on_updateplot_button_click(self, *args):

View File

@ -9,6 +9,19 @@ CAD program, and create G-Code for Isolation routing.
=================================================
31.07.2019
- changed the order of the menu entries in the FIle -> Open ...
- organized the list of recent files so the Project entries are to the top and separated from the other types of file
- work on identification of changes in Preferences tab
- added categories names for the recent files
- added a detection if any values are changed in the Edit -> Preferences window and on close it will ask the user if he wants to save the changes or not
- created a new menu entry in the File menu named Recent projects that will hold the recent projects and the previous "Recent files" will hold only the previous loaded files
- updated all translations for the new strings
- fixed bug recently introduced that when changing the units in the Edit -> Preferences it did not converted the values
- fixed another bug that when selecting an Excellon object after disabling it it crashed the app
- RELEASE 8.92
30.07.2019
- fixed bug that crashed the software when trying to edit a GUI value in Geometry selected tab without having a tool in the Tools Table

View File

@ -669,7 +669,7 @@ class FCDrillSelect(DrawTool):
# select the diameter of the selected shape in the tool table
try:
self.draw_app.tools_table_exc.cellPressed.disconnect()
except TypeError:
except (TypeError, AttributeError):
pass
sel_tools = set()
@ -1258,12 +1258,12 @@ class FlatCAMExcEditor(QtCore.QObject):
try:
# if connected, disconnect the signal from the slot on item_changed as it creates issues
self.tools_table_exc.itemChanged.disconnect()
except TypeError:
except (TypeError, AttributeError):
pass
try:
self.tools_table_exc.cellPressed.disconnect()
except TypeError:
except (TypeError, AttributeError):
pass
# updated units
@ -1820,17 +1820,17 @@ class FlatCAMExcEditor(QtCore.QObject):
try:
self.app.ui.popmenu_copy.triggered.disconnect(self.exc_copy_drills)
except TypeError:
except (TypeError, AttributeError):
pass
try:
self.app.ui.popmenu_delete.triggered.disconnect(self.on_delete_btn)
except TypeError:
except (TypeError, AttributeError):
pass
try:
self.app.ui.popmenu_move.triggered.disconnect(self.exc_move_drills)
except TypeError:
except (TypeError, AttributeError):
pass
self.app.ui.popmenu_copy.triggered.connect(self.app.on_copy_object)
@ -1840,12 +1840,12 @@ class FlatCAMExcEditor(QtCore.QObject):
# Excellon Editor
try:
self.app.ui.drill.triggered.disconnect(self.exc_add_drill)
except TypeError:
except (TypeError, AttributeError):
pass
try:
self.app.ui.drill_array.triggered.disconnect(self.exc_add_drill_array)
except TypeError:
except (TypeError, AttributeError):
pass
def clear(self):

View File

@ -3296,15 +3296,15 @@ class FlatCAMGeoEditor(QtCore.QObject):
try:
self.app.ui.popmenu_copy.triggered.disconnect(lambda: self.select_tool('copy'))
except TypeError:
except (TypeError, AttributeError):
pass
try:
self.app.ui.popmenu_delete.triggered.disconnect(self.on_delete_btn)
except TypeError:
except (TypeError, AttributeError):
pass
try:
self.app.ui.popmenu_move.triggered.disconnect(lambda: self.select_tool('move'))
except TypeError:
except (TypeError, AttributeError):
pass
self.app.ui.popmenu_copy.triggered.connect(self.app.on_copy_object)
@ -3314,22 +3314,22 @@ class FlatCAMGeoEditor(QtCore.QObject):
# Geometry Editor
try:
self.app.ui.draw_line.triggered.disconnect(self.draw_tool_path)
except TypeError:
except (TypeError, AttributeError):
pass
try:
self.app.ui.draw_rect.triggered.disconnect(self.draw_tool_rectangle)
except TypeError:
except (TypeError, AttributeError):
pass
try:
self.app.ui.draw_cut.triggered.disconnect(self.cutpath)
except TypeError:
except (TypeError, AttributeError):
pass
try:
self.app.ui.draw_move.triggered.disconnect(self.on_move)
except TypeError:
except (TypeError, AttributeError):
pass
def add_shape(self, shape):

View File

@ -1693,7 +1693,7 @@ class FCScale(FCShapeTool):
try:
self.draw_app.scale_button.clicked.disconnect()
except TypeError:
except (TypeError, AttributeError):
pass
self.draw_app.scale_button.clicked.connect(self.on_scale_click)
@ -1735,7 +1735,7 @@ class FCBuffer(FCShapeTool):
try:
self.draw_app.buffer_button.clicked.disconnect()
except TypeError:
except (TypeError, AttributeError):
pass
self.draw_app.buffer_button.clicked.connect(self.on_buffer_click)
@ -1777,7 +1777,7 @@ class FCMarkArea(FCShapeTool):
try:
self.draw_app.ma_threshold__button.clicked.disconnect()
except TypeError:
except (TypeError, AttributeError):
pass
self.draw_app.ma_threshold__button.clicked.connect(self.on_markarea_click)
@ -2934,12 +2934,12 @@ class FlatCAMGrbEditor(QtCore.QObject):
try:
# if connected, disconnect the signal from the slot on item_changed as it creates issues
self.apertures_table.itemChanged.disconnect()
except TypeError:
except (TypeError, AttributeError):
pass
try:
self.apertures_table.cellPressed.disconnect()
except TypeError:
except (TypeError, AttributeError):
pass
# updated units
@ -3488,17 +3488,17 @@ class FlatCAMGrbEditor(QtCore.QObject):
try:
self.app.ui.popmenu_copy.triggered.disconnect(self.on_copy_button)
except TypeError:
except (TypeError, AttributeError):
pass
try:
self.app.ui.popmenu_delete.triggered.disconnect(self.on_delete_btn)
except TypeError:
except (TypeError, AttributeError):
pass
try:
self.app.ui.popmenu_move.triggered.disconnect(self.on_move_button)
except TypeError:
except (TypeError, AttributeError):
pass
self.app.ui.popmenu_copy.triggered.connect(self.app.on_copy_object)
@ -3509,22 +3509,22 @@ class FlatCAMGrbEditor(QtCore.QObject):
try:
self.app.ui.grb_draw_pad.triggered.disconnect(self.on_pad_add)
except TypeError:
except (TypeError, AttributeError):
pass
try:
self.app.ui.grb_draw_pad_array.triggered.disconnect(self.on_pad_add_array)
except TypeError:
except (TypeError, AttributeError):
pass
try:
self.app.ui.grb_draw_track.triggered.disconnect(self.on_track_add)
except TypeError:
except (TypeError, AttributeError):
pass
try:
self.app.ui.grb_draw_region.triggered.disconnect(self.on_region_add)
except TypeError:
except (TypeError, AttributeError):
pass
def clear(self):

View File

@ -79,13 +79,16 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.menufile_open = self.menufile.addMenu(QtGui.QIcon('share/folder32_bis.png'), _('Open'))
self.menufile_open.setToolTipsVisible(True)
# Open gerber ...
# Open Project ...
self.menufileopenproject = QtWidgets.QAction(QtGui.QIcon('share/folder16.png'), _('Open &Project ...'), self)
self.menufile_open.addAction(self.menufileopenproject)
self.menufile_open.addSeparator()
# Open Gerber ...
self.menufileopengerber = QtWidgets.QAction(QtGui.QIcon('share/flatcam_icon24.png'),
_('Open &Gerber ...\tCTRL+G'), self)
self.menufile_open.addAction(self.menufileopengerber)
self.menufile_open.addSeparator()
# Open Excellon ...
self.menufileopenexcellon = QtWidgets.QAction(QtGui.QIcon('share/open_excellon32.png'),
_('Open &Excellon ...\tCTRL+E'), self)
@ -95,10 +98,6 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.menufileopengcode = QtWidgets.QAction(QtGui.QIcon('share/code.png'), _('Open G-&Code ...'), self)
self.menufile_open.addAction(self.menufileopengcode)
# Open Project ...
self.menufileopenproject = QtWidgets.QAction(QtGui.QIcon('share/folder16.png'), _('Open &Project ...'), self)
self.menufile_open.addAction(self.menufileopenproject)
self.menufile_open.addSeparator()
# Open Config File...
@ -106,6 +105,7 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.menufile_open.addAction(self.menufileopenconfig)
# Recent
self.recent_projects = self.menufile.addMenu(QtGui.QIcon('share/recent_files.png'), _("Recent projects"))
self.recent = self.menufile.addMenu(QtGui.QIcon('share/recent_files.png'), _("Recent files"))
# Separator
@ -757,10 +757,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.snap_max_dist_entry.setToolTip(_("Max. magnet distance"))
self.snap_magnet = self.snap_toolbar.addWidget(self.snap_max_dist_entry)
############## ##
# ############# ##
# ## Notebook # ##
############## ##
# ############# ##
# ## Project # ##
# self.project_tab = QtWidgets.QWidget()
@ -811,7 +810,7 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.right_lay.setContentsMargins(0, 0, 0, 0)
self.right_widget.setLayout(self.right_lay)
# self.plot_tab_area = FCTab()
self.plot_tab_area = FCDetachableTab(protect=False, protect_by_name=[_('Plot Area')])
self.plot_tab_area = FCDetachableTab2(protect=False, protect_by_name=[_('Plot Area')])
self.plot_tab_area.useOldIndex(True)
self.right_lay.addWidget(self.plot_tab_area)
@ -828,9 +827,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
# remove the close button from the Plot Area tab (first tab index = 0) as this one will always be ON
self.plot_tab_area.protectTab(0)
###################################### ##
# ##################################### ##
# ## HERE WE BUILD THE PREF. TAB AREA # ##
###################################### ##
# ##################################### ##
self.preferences_tab = QtWidgets.QWidget()
self.pref_tab_layout = QtWidgets.QVBoxLayout(self.preferences_tab)
self.pref_tab_layout.setContentsMargins(2, 2, 2, 2)
@ -843,6 +842,7 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.pref_tab_layout.addWidget(self.pref_tab_area)
self.general_tab = QtWidgets.QWidget()
self.general_tab.setObjectName("general_tab")
self.pref_tab_area.addTab(self.general_tab, _("General"))
self.general_tab_lay = QtWidgets.QVBoxLayout()
self.general_tab_lay.setContentsMargins(2, 2, 2, 2)
@ -864,6 +864,7 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.general_tab_lay.addWidget(self.general_scroll_area)
self.gerber_tab = QtWidgets.QWidget()
self.gerber_tab.setObjectName("gerber_tab")
self.pref_tab_area.addTab(self.gerber_tab, _("GERBER"))
self.gerber_tab_lay = QtWidgets.QVBoxLayout()
self.gerber_tab_lay.setContentsMargins(2, 2, 2, 2)
@ -873,6 +874,7 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.gerber_tab_lay.addWidget(self.gerber_scroll_area)
self.excellon_tab = QtWidgets.QWidget()
self.excellon_tab.setObjectName("excellon_tab")
self.pref_tab_area.addTab(self.excellon_tab, _("EXCELLON"))
self.excellon_tab_lay = QtWidgets.QVBoxLayout()
self.excellon_tab_lay.setContentsMargins(2, 2, 2, 2)
@ -882,6 +884,7 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.excellon_tab_lay.addWidget(self.excellon_scroll_area)
self.geometry_tab = QtWidgets.QWidget()
self.geometry_tab.setObjectName("geometry_tab")
self.pref_tab_area.addTab(self.geometry_tab, _("GEOMETRY"))
self.geometry_tab_lay = QtWidgets.QVBoxLayout()
self.geometry_tab_lay.setContentsMargins(2, 2, 2, 2)
@ -2484,7 +2487,7 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
if key == QtCore.Qt.Key_3 or key == '3':
self.app.on_select_tab('tool')
if self.app.geo_editor.active_tool is not None and self.geo_select_btn.isChecked() == False:
if self.app.geo_editor.active_tool is not None and self.geo_select_btn.isChecked() is False:
response = self.app.geo_editor.active_tool.on_key(key=key)
if response is not None:
self.app.inform.emit(response)

View File

@ -884,6 +884,7 @@ class FCDetachableTab(QtWidgets.QTabWidget):
:param currentIndex:
:return:
"""
self.removeTab(currentIndex)
def protectTab(self, currentIndex):
@ -1348,6 +1349,28 @@ class FCDetachableTab(QtWidgets.QTabWidget):
self.detachedTabDropSignal.emit(name, index, dropPos)
class FCDetachableTab2(FCDetachableTab):
tab_closed_signal = pyqtSignal()
def __init__(self, protect=None, protect_by_name=None, parent=None):
super(FCDetachableTab2, self).__init__(protect=protect, protect_by_name=protect_by_name, parent=parent)
def closeTab(self, currentIndex):
"""
Slot connected to the tabCloseRequested signal
:param currentIndex:
:return:
"""
idx = self.currentIndex()
# emit the signal only if the name is the one we want; the name should be a parameter somehow
if self.tabText(idx) == _("Preferences"):
self.tab_closed_signal.emit()
self.removeTab(currentIndex)
class VerticalScrollArea(QtWidgets.QScrollArea):
"""
This widget extends QtGui.QScrollArea to make a vertical-only

View File

@ -461,7 +461,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
try:
# if connected, disconnect the signal from the slot on item_changed as it creates issues
self.tools_table.itemChanged.disconnect(self.on_tool_edit)
except TypeError:
except (TypeError, AttributeError):
pass
def on_tool_add(self, dia=None, muted=None):

View File

@ -366,7 +366,7 @@ class ToolPDF(FlatCAMTool):
self.check_thread.setInterval(check_period)
try:
self.check_thread.timeout.disconnect(self.periodic_check_handler)
except TypeError:
except (TypeError, AttributeError):
pass
self.check_thread.timeout.connect(self.periodic_check_handler)

View File

@ -437,7 +437,7 @@ class ToolPaint(FlatCAMTool, Gerber):
try:
# if connected, disconnect the signal from the slot on item_changed as it creates issues
self.tools_table.itemChanged.disconnect()
except TypeError:
except (TypeError, AttributeError):
pass
# updated units

View File

@ -646,22 +646,22 @@ class SolderPaste(FlatCAMTool):
if isinstance(self.gcode_form_layout.itemAt(i).widget(), FCComboBox):
try:
self.gcode_form_layout.itemAt(i).widget().currentIndexChanged.disconnect()
except TypeError:
except (TypeError, AttributeError):
pass
if isinstance(self.gcode_form_layout.itemAt(i).widget(), FCEntry):
try:
self.gcode_form_layout.itemAt(i).widget().editingFinished.disconnect()
except TypeError:
except (TypeError, AttributeError):
pass
try:
self.tools_table.itemChanged.disconnect(self.on_tool_edit)
except TypeError:
except (TypeError, AttributeError):
pass
try:
self.tools_table.currentItemChanged.disconnect(self.on_row_selection_change)
except TypeError:
except (TypeError, AttributeError):
pass
def update_comboboxes(self, obj, status):

View File

@ -175,13 +175,13 @@ class ToolSub(FlatCAMTool):
try:
self.intersect_btn.clicked.disconnect(self.on_grb_intersection_click)
except TypeError:
except (TypeError, AttributeError):
pass
self.intersect_btn.clicked.connect(self.on_grb_intersection_click)
try:
self.intersect_geo_btn.clicked.disconnect()
except TypeError:
except (TypeError, AttributeError):
pass
self.intersect_geo_btn.clicked.connect(self.on_geo_intersection_click)
@ -569,14 +569,14 @@ class ToolSub(FlatCAMTool):
try:
self.check_thread.stop()
except TypeError:
except (TypeError, AttributeError):
pass
if reset:
self.check_thread.setInterval(check_period)
try:
self.check_thread.timeout.disconnect(self.periodic_check_handler)
except TypeError:
except (TypeError, AttributeError):
pass
self.check_thread.timeout.connect(self.periodic_check_handler)

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff