blob: 706a6d8c74abf7f57ddfce010d63ac62e9eb901f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# Copyright (c) 2018 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from cura.CuraApplication import CuraApplication
class Settings:
"""The Interface.Settings API provides a version-proof bridge
between Cura's
(currently) sidebar UI and plug-ins that hook into it.
Usage:
.. code-block:: python
from cura.API import CuraAPI
api = CuraAPI()
api.interface.settings.getContextMenuItems()
data = {
"name": "My Plugin Action",
"iconName": "my-plugin-icon",
"actions": my_menu_actions,
"menu_item": MyPluginAction(self)
}
api.interface.settings.addContextMenuItem(data)
"""
def __init__(self, application: "CuraApplication") -> None:
self.application = application
def addContextMenuItem(self, menu_item: dict) -> None:
"""Add items to the sidebar context menu.
:param menu_item: dict containing the menu item to add.
"""
self.application.addSidebarCustomMenuItem(menu_item)
def getContextMenuItems(self) -> list:
"""Get all custom items currently added to the sidebar context menu.
:return: List containing all custom context menu items.
"""
return self.application.getSidebarCustomMenuItems()
|