- in Tools Database added a new column showing the intended target and also added in the context menu an entry that will sort the tools by tool diameter
- fixed in Tools Database the message pop-up that tools are modified but not saved on Toos Database tab closing
This commit is contained in:
committed by
Marius Stanciu
parent
fb983872d0
commit
d49f8a87e6
@@ -20,6 +20,8 @@ CHANGELOG for FlatCAM beta
|
|||||||
- added a text placeholder in the Tcl Shell
|
- added a text placeholder in the Tcl Shell
|
||||||
- added Find function in Tcl Shell (will search for either the selected text in the command line or for the one stored on the clipboard)
|
- added Find function in Tcl Shell (will search for either the selected text in the command line or for the one stored on the clipboard)
|
||||||
- using 'Escape' key shortcut while the focus is in the Tcl Shell command line will set focus on the main canvas
|
- using 'Escape' key shortcut while the focus is in the Tcl Shell command line will set focus on the main canvas
|
||||||
|
- in Tools Database added a new column showing the intended target and also added in the context menu an entry that will sort the tools by tool diameter
|
||||||
|
- fixed in Tools Database the message pop-up that tools are modified but not saved on Toos Database tab closing
|
||||||
|
|
||||||
24.11.2020
|
24.11.2020
|
||||||
|
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ class ToolsDB2UI:
|
|||||||
tree_layout = QtWidgets.QVBoxLayout()
|
tree_layout = QtWidgets.QVBoxLayout()
|
||||||
self.g_lay.addLayout(tree_layout, 0, 0)
|
self.g_lay.addLayout(tree_layout, 0, 0)
|
||||||
|
|
||||||
self.tree_widget = FCTree(columns=2, header_hidden=False, protected_column=[0])
|
self.tree_widget = FCTree(columns=3, header_hidden=False, protected_column=[0, 2])
|
||||||
self.tree_widget.setHeaderLabels([_("ID"), _("Tool Name")])
|
self.tree_widget.setHeaderLabels([_("ID"), _("Tool Name"), _("Target")])
|
||||||
self.tree_widget.setIndentation(0)
|
self.tree_widget.setIndentation(0)
|
||||||
self.tree_widget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
|
self.tree_widget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
|
||||||
self.tree_widget.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
|
self.tree_widget.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
|
||||||
@@ -1388,7 +1388,7 @@ class ToolsDB2(QtWidgets.QWidget):
|
|||||||
|
|
||||||
self.on_tool_request = callback_on_tool_request
|
self.on_tool_request = callback_on_tool_request
|
||||||
|
|
||||||
self.tools_db_changed_flag = False
|
self.app.tools_db_changed_flag = False
|
||||||
|
|
||||||
'''
|
'''
|
||||||
dict to hold all the tools in the Tools DB
|
dict to hold all the tools in the Tools DB
|
||||||
@@ -1624,6 +1624,16 @@ class ToolsDB2(QtWidgets.QWidget):
|
|||||||
def on_menu_request(self, pos):
|
def on_menu_request(self, pos):
|
||||||
|
|
||||||
menu = QtWidgets.QMenu()
|
menu = QtWidgets.QMenu()
|
||||||
|
|
||||||
|
# sort_by_id = menu.addAction(QtGui.QIcon(self.app.resource_location + '/plus16.png'), _("Sort by Operation"))
|
||||||
|
# sort_by_id.triggered.connect(self.on_sort_operation)
|
||||||
|
|
||||||
|
sort_by_dia = menu.addAction(QtGui.QIcon
|
||||||
|
(self.app.resource_location + '/desc_sort32.png'), _("Sort by Diameter"))
|
||||||
|
sort_by_dia.triggered.connect(self.on_sort_dia)
|
||||||
|
|
||||||
|
menu.addSeparator()
|
||||||
|
|
||||||
add_tool = menu.addAction(QtGui.QIcon(self.app.resource_location + '/plus16.png'), _("Add to DB"))
|
add_tool = menu.addAction(QtGui.QIcon(self.app.resource_location + '/plus16.png'), _("Add to DB"))
|
||||||
add_tool.triggered.connect(self.on_tool_add)
|
add_tool.triggered.connect(self.on_tool_add)
|
||||||
|
|
||||||
@@ -1633,7 +1643,7 @@ class ToolsDB2(QtWidgets.QWidget):
|
|||||||
delete_tool = menu.addAction(QtGui.QIcon(self.app.resource_location + '/delete32.png'), _("Delete from DB"))
|
delete_tool = menu.addAction(QtGui.QIcon(self.app.resource_location + '/delete32.png'), _("Delete from DB"))
|
||||||
delete_tool.triggered.connect(self.on_tool_delete)
|
delete_tool.triggered.connect(self.on_tool_delete)
|
||||||
|
|
||||||
# sep = menu.addSeparator()
|
menu.addSeparator()
|
||||||
|
|
||||||
save_changes = menu.addAction(QtGui.QIcon(self.app.resource_location + '/save_as.png'), _("Save changes"))
|
save_changes = menu.addAction(QtGui.QIcon(self.app.resource_location + '/save_as.png'), _("Save changes"))
|
||||||
save_changes.triggered.connect(self.on_save_changes)
|
save_changes.triggered.connect(self.on_save_changes)
|
||||||
@@ -1662,8 +1672,37 @@ class ToolsDB2(QtWidgets.QWidget):
|
|||||||
def on_list_item_edited(self, item, column):
|
def on_list_item_edited(self, item, column):
|
||||||
if column == 0:
|
if column == 0:
|
||||||
return
|
return
|
||||||
|
elif column == 1:
|
||||||
|
self.ui.name_entry.set_value(item.text(1))
|
||||||
|
|
||||||
self.ui.name_entry.set_value(item.text(1))
|
def on_sort_operation(self):
|
||||||
|
for tool in self.db_tool_dict.values():
|
||||||
|
dia = tool['tooldia']
|
||||||
|
target = tool['data']['tool_target']
|
||||||
|
|
||||||
|
ordered_by_target = sorted(self.db_tool_dict.items(), key=lambda x: x[1]['data']['tool_target'])
|
||||||
|
for td, k in ordered_by_target:
|
||||||
|
print(td,k)
|
||||||
|
|
||||||
|
self.build_db_ui()
|
||||||
|
self.on_tools_db_edited()
|
||||||
|
|
||||||
|
def on_sort_dia(self):
|
||||||
|
dias = [tool['tooldia'] for tool in self.db_tool_dict.values()]
|
||||||
|
if dias:
|
||||||
|
dias.sort()
|
||||||
|
|
||||||
|
new_dict = {}
|
||||||
|
t_id = 0
|
||||||
|
for dia in dias:
|
||||||
|
for tool in self.db_tool_dict.values():
|
||||||
|
if tool['tooldia'] == dia:
|
||||||
|
t_id += 1
|
||||||
|
new_dict[str(t_id)] = tool
|
||||||
|
|
||||||
|
self.db_tool_dict = deepcopy(new_dict)
|
||||||
|
self.build_db_ui()
|
||||||
|
self.on_tools_db_edited()
|
||||||
|
|
||||||
def storage_to_form(self, dict_storage):
|
def storage_to_form(self, dict_storage):
|
||||||
self.ui_disconnect()
|
self.ui_disconnect()
|
||||||
@@ -1744,11 +1783,21 @@ class ToolsDB2(QtWidgets.QWidget):
|
|||||||
nr_crt += 1
|
nr_crt += 1
|
||||||
|
|
||||||
t_name = dict_val['name']
|
t_name = dict_val['name']
|
||||||
|
op_name = {
|
||||||
|
0: _("General"),
|
||||||
|
1: _("Milling"),
|
||||||
|
2: _("Drilling"),
|
||||||
|
3: _('Isolation'),
|
||||||
|
4: _('Paint'),
|
||||||
|
5: _('NCC'),
|
||||||
|
6: _('Cutout')
|
||||||
|
}[dict_val['data']['tool_target']]
|
||||||
try:
|
try:
|
||||||
# self.add_tool_table_line(row, name=t_name, tooldict=dict_val)
|
# self.add_tool_table_line(row, name=t_name, tooldict=dict_val)
|
||||||
self.ui.tree_widget.blockSignals(True)
|
self.ui.tree_widget.blockSignals(True)
|
||||||
try:
|
try:
|
||||||
self.ui.tree_widget.addParentEditable(parent=parent, title=[str(row+1), t_name], editable=True)
|
self.ui.tree_widget.addParentEditable(
|
||||||
|
parent=parent, title=[str(row+1), t_name, op_name], editable=True)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('FlatCAMCoomn.ToolDB2.build_db_ui() -> ', str(e))
|
print('FlatCAMCoomn.ToolDB2.build_db_ui() -> ', str(e))
|
||||||
self.ui.tree_widget.blockSignals(False)
|
self.ui.tree_widget.blockSignals(False)
|
||||||
@@ -2584,7 +2633,7 @@ class ToolsDB2(QtWidgets.QWidget):
|
|||||||
|
|
||||||
self.ui.save_db_btn.setStyleSheet("QPushButton {color: red;}")
|
self.ui.save_db_btn.setStyleSheet("QPushButton {color: red;}")
|
||||||
|
|
||||||
self.tools_db_changed_flag = True
|
self.app.tools_db_changed_flag = True
|
||||||
if silent is None:
|
if silent is None:
|
||||||
msg = '[WARNING_NOTCL] %s' % _("Tools in Tools Database edited but not saved.")
|
msg = '[WARNING_NOTCL] %s' % _("Tools in Tools Database edited but not saved.")
|
||||||
self.app.inform[str, bool].emit(msg, False)
|
self.app.inform[str, bool].emit(msg, False)
|
||||||
|
|||||||
@@ -1153,7 +1153,7 @@ class PreferencesUIManager:
|
|||||||
|
|
||||||
self.preferences_changed_flag = True
|
self.preferences_changed_flag = True
|
||||||
|
|
||||||
def on_close_preferences_tab(self):
|
def on_close_preferences_tab(self, parent):
|
||||||
if self.ignore_tab_close_event:
|
if self.ignore_tab_close_event:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -1190,9 +1190,9 @@ class PreferencesUIManager:
|
|||||||
|
|
||||||
# Prompt user to save
|
# Prompt user to save
|
||||||
if self.preferences_changed_flag is True:
|
if self.preferences_changed_flag is True:
|
||||||
msgbox = QtWidgets.QMessageBox()
|
msgbox = QtWidgets.QMessageBox(parent=parent)
|
||||||
msgbox.setText(_("One or more values are changed.\n"
|
msgbox.setText(_("One or more values are changed.\n"
|
||||||
"Do you want to save the Preferences?"))
|
"Do you want to save?"))
|
||||||
msgbox.setWindowTitle(_("Save Preferences"))
|
msgbox.setWindowTitle(_("Save Preferences"))
|
||||||
msgbox.setWindowIcon(QtGui.QIcon(self.ui.app.resource_location + '/save_as.png'))
|
msgbox.setWindowIcon(QtGui.QIcon(self.ui.app.resource_location + '/save_as.png'))
|
||||||
msgbox.setIcon(QtWidgets.QMessageBox.Question)
|
msgbox.setIcon(QtWidgets.QMessageBox.Question)
|
||||||
|
|||||||
@@ -6095,15 +6095,15 @@ class App(QtCore.QObject):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if tab_obj_name == "preferences_tab":
|
if tab_obj_name == "preferences_tab":
|
||||||
self.preferencesUiManager.on_close_preferences_tab()
|
self.preferencesUiManager.on_close_preferences_tab(parent=self.ui)
|
||||||
elif tab_obj_name == "database_tab":
|
elif tab_obj_name == "database_tab":
|
||||||
# disconnect the signals from the table widget in tab
|
# disconnect the signals from the table widget in tab
|
||||||
self.tools_db_tab.ui_disconnect()
|
self.tools_db_tab.ui_disconnect()
|
||||||
|
|
||||||
if self.tools_db_changed_flag is True:
|
if self.tools_db_changed_flag is True:
|
||||||
msgbox = QtWidgets.QMessageBox()
|
msgbox = QtWidgets.QMessageBox(parent=self.ui)
|
||||||
msgbox.setText(_("One or more Tools are edited.\n"
|
msgbox.setText(_("One or more Tools are edited.\n"
|
||||||
"Do you want to update the Tools Database?"))
|
"Do you want to save?"))
|
||||||
msgbox.setWindowTitle(_("Save Tools Database"))
|
msgbox.setWindowTitle(_("Save Tools Database"))
|
||||||
msgbox.setWindowIcon(QtGui.QIcon(self.resource_location + '/save_as.png'))
|
msgbox.setWindowIcon(QtGui.QIcon(self.resource_location + '/save_as.png'))
|
||||||
msgbox.setIcon(QtWidgets.QMessageBox.Question)
|
msgbox.setIcon(QtWidgets.QMessageBox.Question)
|
||||||
|
|||||||
BIN
assets/resources/dark_resources/desc_sort32.png
Normal file
BIN
assets/resources/dark_resources/desc_sort32.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 751 B |
BIN
assets/resources/desc_sort32.png
Normal file
BIN
assets/resources/desc_sort32.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 680 B |
Reference in New Issue
Block a user