mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-24 15:13:56 -06:00
Get default settings view to work as sidebar component
This commit is contained in:
parent
5eeb98bbcf
commit
3c863fc388
8 changed files with 138 additions and 49 deletions
36
cura/Sidebar/SidebarControllerProxy.py
Normal file
36
cura/Sidebar/SidebarControllerProxy.py
Normal file
|
@ -0,0 +1,36 @@
|
|||
# Copyright (c) 2017 Ultimaker B.V.
|
||||
from PyQt5.QtCore import QObject, pyqtSlot, QUrl, pyqtProperty, pyqtSignal
|
||||
from UM.Application import Application
|
||||
|
||||
|
||||
## The sidebar controller proxy acts a proxy between the sidebar controller and the QMl context of the controller.
|
||||
class SidebarControllerProxy(QObject):
|
||||
|
||||
def __init__(self, parent = None):
|
||||
super().__init__(parent)
|
||||
self._controller = Application.getInstance().getSidebarController()
|
||||
self._controller.activeSidebarViewChanged.connect(self._onActiveSidebarComponentChanged)
|
||||
|
||||
## Emitted when the active view changes.
|
||||
activeSidebarViewChanged = pyqtSignal()
|
||||
|
||||
@classmethod
|
||||
def createSidebarControllerProxy(self, engine, script_engine):
|
||||
return SidebarControllerProxy()
|
||||
|
||||
@pyqtSlot()
|
||||
def setActiveView(self, sidebar_view):
|
||||
self._controller.setActiveSidebarView(sidebar_view)
|
||||
|
||||
@pyqtProperty(QUrl, notify = activeSidebarViewChanged)
|
||||
def activeComponentPath(self):
|
||||
if not self._controller.getActiveSidebarView():
|
||||
return QUrl()
|
||||
return self._controller.getActiveSidebarView().getComponentPath()
|
||||
|
||||
@pyqtSlot(QUrl)
|
||||
def getSidebarComponentPath(self, sidebar_id):
|
||||
self._controller.getSidebarView(sidebar_id).getComponentPath()
|
||||
|
||||
def _onActiveSidebarComponentChanged(self):
|
||||
self.activeSidebarViewChanged.emit()
|
Loading…
Add table
Add a link
Reference in a new issue