mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
Added icon for custom Menu items
This commit is contained in:
parent
f577789859
commit
c4fa50a8fc
2 changed files with 8 additions and 4 deletions
|
@ -5,12 +5,14 @@ class SidebarCustomMenuItemsModel(ListModel):
|
|||
NameRole = Qt.UserRole + 1
|
||||
ActionsRole = Qt.UserRole + 2
|
||||
MenuItemRole = Qt.UserRole + 3
|
||||
MenuItemIconNameRole = Qt.UserRole + 5
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.addRoleName(self.NameRole, "name")
|
||||
self.addRoleName(self.ActionsRole, "actions")
|
||||
self.addRoleName(self.MenuItemRole, "menu_item")
|
||||
self.addRoleName(self.MenuItemIconNameRole, "iconName")
|
||||
self._updateExtensionList()
|
||||
|
||||
def _updateExtensionList(self)-> None:
|
||||
|
@ -19,14 +21,15 @@ class SidebarCustomMenuItemsModel(ListModel):
|
|||
|
||||
self.appendItem({
|
||||
"name": menu_item["name"],
|
||||
"iconName": menu_item["iconName"],
|
||||
"actions": menu_item["actions"],
|
||||
"menu_item": menu_item["menu_item"]
|
||||
})
|
||||
|
||||
@pyqtSlot(str, "QVariantList")
|
||||
def callMenuItemMethod(self, menu_item_name: str, menu_item_actions: list)-> None:
|
||||
@pyqtSlot(str, "QVariantList", "QVariantMap")
|
||||
def callMenuItemMethod(self, menu_item_name: str, menu_item_actions: list, kwargs)-> None:
|
||||
for item in self._items:
|
||||
if menu_item_name == item["name"]:
|
||||
for method in menu_item_actions:
|
||||
getattr(item["menu_item"], method)()
|
||||
getattr(item["menu_item"], method)(kwargs)
|
||||
break
|
Loading…
Add table
Add a link
Reference in a new issue