- updated the Objects menu signals so whenever an object is (de)selected in the Project Tab, it's state will reflect the (un)checked state of the actions in the Object menu

This commit is contained in:
Marius Stanciu 2019-10-21 15:55:49 +03:00
parent 6b1df4d0e3
commit 127a78e06e
3 changed files with 26 additions and 0 deletions

View File

@ -2123,6 +2123,7 @@ class App(QtCore.QObject):
# Object list # Object list
self.collection.view.activated.connect(self.on_row_activated) self.collection.view.activated.connect(self.on_row_activated)
self.collection.item_selected.connect(self.on_row_selected)
self.object_status_changed.connect(self.on_collection_updated) self.object_status_changed.connect(self.on_collection_updated)
@ -7923,6 +7924,25 @@ class App(QtCore.QObject):
self.ui.notebook.setCurrentWidget(self.ui.selected_tab) self.ui.notebook.setCurrentWidget(self.ui.selected_tab)
self.collection.on_item_activated(index) self.collection.on_item_activated(index)
def on_row_selected(self, obj_name):
# this is a special string; when received it will make all entries unchecked
# it mean we clicked outside of the items and deselected all
if obj_name =='none':
for act in self.ui.menuobjects.actions():
act.setChecked(False)
return
# get the name of the selected objects and add them to a list
name_list = list()
for obj in self.collection.get_selected():
name_list.append(obj.options['name'])
# set all actions as unchecked but the ones selected make them checked
for act in self.ui.menuobjects.actions():
act.setChecked(False)
if act.text() in name_list:
act.setChecked(True)
def on_collection_updated(self, obj, state, old_name): def on_collection_updated(self, obj, state, old_name):
""" """
Create a menu from the object loaded in the collection. Create a menu from the object loaded in the collection.

View File

@ -219,6 +219,9 @@ class ObjectCollection(QtCore.QAbstractItemModel):
"document": "share/notes16_1.png" "document": "share/notes16_1.png"
} }
# will emit the name of the object that was just selected
item_selected = QtCore.pyqtSignal(str)
root_item = None root_item = None
# app = None # app = None
@ -779,6 +782,7 @@ class ObjectCollection(QtCore.QAbstractItemModel):
try: try:
obj = current.indexes()[0].internalPointer().obj obj = current.indexes()[0].internalPointer().obj
self.item_selected.emit(obj.options['name'])
if obj.kind == 'gerber': if obj.kind == 'gerber':
self.app.inform.emit(_('[selected]<span style="color:{color};">{name}</span> selected').format( self.app.inform.emit(_('[selected]<span style="color:{color};">{name}</span> selected').format(
@ -799,6 +803,7 @@ class ObjectCollection(QtCore.QAbstractItemModel):
self.app.inform.emit(_('[selected]<span style="color:{color};">{name}</span> selected').format( self.app.inform.emit(_('[selected]<span style="color:{color};">{name}</span> selected').format(
color='darkCyan', name=str(obj.options['name']))) color='darkCyan', name=str(obj.options['name'])))
except IndexError: except IndexError:
self.item_selected.emit('none')
# FlatCAMApp.App.log.debug("on_list_selection_change(): Index Error (Nothing selected?)") # FlatCAMApp.App.log.debug("on_list_selection_change(): Index Error (Nothing selected?)")
self.app.inform.emit('') self.app.inform.emit('')
try: try:

View File

@ -13,6 +13,7 @@ CAD program, and create G-Code for Isolation routing.
- the context menu for the Tabs in notebook and PlotTabArea is launched now on right mouse click on tabs themselves - the context menu for the Tabs in notebook and PlotTabArea is launched now on right mouse click on tabs themselves
- fixed an error when trying to view the source file and there is no object selected - fixed an error when trying to view the source file and there is no object selected
- updated the Objects menu signals so whenever an object is (de)selected in the Project Tab, it's state will reflect the (un)checked state of the actions in the Object menu
18.10.2019 18.10.2019