mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-23 06:33:55 -06:00
Some final tweaks
Contributes to CURA-5595
This commit is contained in:
parent
6d237b09e8
commit
16db297613
4 changed files with 40 additions and 15 deletions
|
@ -13,6 +13,7 @@ from cura.Backups.BackupsManager import BackupsManager
|
||||||
# api = CuraAPI()
|
# api = CuraAPI()
|
||||||
# api.backups.createBackup()
|
# api.backups.createBackup()
|
||||||
# api.backups.restoreBackup(my_zip_file, {"cura_release": "3.1"})``
|
# api.backups.restoreBackup(my_zip_file, {"cura_release": "3.1"})``
|
||||||
|
|
||||||
class Backups:
|
class Backups:
|
||||||
manager = BackupsManager() # Re-used instance of the backups manager.
|
manager = BackupsManager() # Re-used instance of the backups manager.
|
||||||
|
|
||||||
|
|
|
@ -3,32 +3,31 @@
|
||||||
|
|
||||||
from cura.CuraApplication import CuraApplication
|
from cura.CuraApplication import CuraApplication
|
||||||
|
|
||||||
## The sidebar context menu API provides a version-proof bridge between Cura's
|
## The Interface.Settings API provides a version-proof bridge between Cura's
|
||||||
# Sidebar Context Menu and plug-ins that hook into it.
|
# (currently) sidebar UI and plug-ins that hook into it.
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# ``from cura.API import CuraAPI
|
# ``from cura.API import CuraAPI
|
||||||
# api = CuraAPI()
|
# api = CuraAPI()
|
||||||
# api.sidebar.getContextMenuItems()
|
# api.interface.settings.getContextMenuItems()
|
||||||
# menu_actions = []
|
|
||||||
# menu_actions.append("sidebarMenuItemOnClickHandler")
|
|
||||||
# data = {
|
# data = {
|
||||||
# "name": "My Plugin Action",
|
# "name": "My Plugin Action",
|
||||||
# "iconName": "my-plugin-icon",
|
# "iconName": "my-plugin-icon",
|
||||||
# "actions": menu_actions,
|
# "actions": my_menu_actions,
|
||||||
# "menu_item": MyPluginAction(self)
|
# "menu_item": MyPluginAction(self)
|
||||||
# }
|
# }
|
||||||
# api.sidebar.addContextMenuItem(data)``
|
# api.interface.settings.addContextMenuItem(data)``
|
||||||
class Sidebar:
|
|
||||||
|
|
||||||
_application = CuraApplication.getInstance() # type: CuraApplication
|
class Settings:
|
||||||
|
# Re-used instance of Cura:
|
||||||
|
application = CuraApplication.getInstance() # type: CuraApplication
|
||||||
|
|
||||||
## Add items to the sidebar context menu.
|
## Add items to the sidebar context menu.
|
||||||
# \param menu_item dict containing the menu item to add.
|
# \param menu_item dict containing the menu item to add.
|
||||||
def addContextMenuItem(self, menu_item: dict) -> None:
|
def addContextMenuItem(self, menu_item: dict) -> None:
|
||||||
self._application.addSidebarCustomMenuItem(menu_item)
|
self.application.addSidebarCustomMenuItem(menu_item)
|
||||||
|
|
||||||
## Get all custom items currently added to the sidebar context menu.
|
## Get all custom items currently added to the sidebar context menu.
|
||||||
# \return List containing all custom context menu items.
|
# \return List containing all custom context menu items.
|
||||||
def getContextMenuItems(self) -> list:
|
def getContextMenuItems(self) -> list:
|
||||||
return self._application.getSidebarCustomMenuItems()
|
return self.application.getSidebarCustomMenuItems()
|
24
cura/API/Interface/__init__.py
Normal file
24
cura/API/Interface/__init__.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# Copyright (c) 2018 Ultimaker B.V.
|
||||||
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
|
from UM.PluginRegistry import PluginRegistry
|
||||||
|
from cura.API.Interface.Settings import Settings
|
||||||
|
|
||||||
|
## The Interface class serves as a common root for the specific API
|
||||||
|
# methods for each interface element.
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# ``from cura.API import CuraAPI
|
||||||
|
# api = CuraAPI()
|
||||||
|
# api.interface.settings.addContextMenuItem()
|
||||||
|
# api.interface.viewport.addOverlay() # Not implemented, just a hypothetical
|
||||||
|
# api.interface.toolbar.getToolButtonCount() # Not implemented, just a hypothetical
|
||||||
|
# # etc.``
|
||||||
|
|
||||||
|
class Interface:
|
||||||
|
|
||||||
|
# For now we use the same API version to be consistent.
|
||||||
|
VERSION = PluginRegistry.APIVersion
|
||||||
|
|
||||||
|
# API methods specific to the settings portion of the UI
|
||||||
|
settings = Settings()
|
|
@ -2,7 +2,7 @@
|
||||||
# Cura is released under the terms of the LGPLv3 or higher.
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
from UM.PluginRegistry import PluginRegistry
|
from UM.PluginRegistry import PluginRegistry
|
||||||
from cura.API.Backups import Backups
|
from cura.API.Backups import Backups
|
||||||
from cura.API.Sidebar import Sidebar
|
from cura.API.Interface import Interface
|
||||||
|
|
||||||
## The official Cura API that plug-ins can use to interact with Cura.
|
## The official Cura API that plug-ins can use to interact with Cura.
|
||||||
#
|
#
|
||||||
|
@ -10,13 +10,14 @@ from cura.API.Sidebar import Sidebar
|
||||||
# this API provides a version-safe interface with proper deprecation warnings
|
# this API provides a version-safe interface with proper deprecation warnings
|
||||||
# etc. Usage of any other methods than the ones provided in this API can cause
|
# etc. Usage of any other methods than the ones provided in this API can cause
|
||||||
# plug-ins to be unstable.
|
# plug-ins to be unstable.
|
||||||
|
|
||||||
class CuraAPI:
|
class CuraAPI:
|
||||||
|
|
||||||
# For now we use the same API version to be consistent.
|
# For now we use the same API version to be consistent.
|
||||||
VERSION = PluginRegistry.APIVersion
|
VERSION = PluginRegistry.APIVersion
|
||||||
|
|
||||||
# Backups API.
|
# Backups API
|
||||||
backups = Backups()
|
backups = Backups()
|
||||||
|
|
||||||
# Sidebar Context Menu API
|
# Interface API
|
||||||
sidebar = Sidebar()
|
interface = Interface()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue