mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-25 07:33:57 -06:00
Added MachineManagerModel to Cura
CURA-1278
This commit is contained in:
parent
9fcc3930ff
commit
573c1c1a5a
3 changed files with 33 additions and 3 deletions
|
@ -36,10 +36,11 @@ from . import CuraActions
|
|||
from . import MultiMaterialDecorator
|
||||
from . import ZOffsetDecorator
|
||||
from . import CuraSplashScreen
|
||||
from . import MachineManagerModel
|
||||
|
||||
from PyQt5.QtCore import pyqtSlot, QUrl, pyqtSignal, pyqtProperty, QEvent, Q_ENUMS
|
||||
from PyQt5.QtGui import QColor, QIcon
|
||||
from PyQt5.QtQml import qmlRegisterUncreatableType
|
||||
from PyQt5.QtQml import qmlRegisterUncreatableType, qmlRegisterSingletonType
|
||||
|
||||
import platform
|
||||
import sys
|
||||
|
@ -201,6 +202,9 @@ class CuraApplication(QtApplication):
|
|||
self.setMainQml(Resources.getPath(self.ResourceTypes.QmlFiles, "Cura.qml"))
|
||||
self.initializeEngine()
|
||||
|
||||
qmlRegisterSingletonType(MachineManagerModel.MachineManagerModel, "Cura", 1, 0, "MachineManager",
|
||||
MachineManagerModel.createMachineManagerModel)
|
||||
|
||||
if self._engine.rootObjects:
|
||||
self.closeSplash()
|
||||
|
||||
|
|
25
cura/MachineManagerModel.py
Normal file
25
cura/MachineManagerModel.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
|
||||
from PyQt5.QtCore import QObject, pyqtSlot, pyqtProperty, pyqtSignal
|
||||
from UM.Application import Application
|
||||
from UM.Signal import Signal, signalemitter
|
||||
|
||||
class MachineManagerModel(QObject):
|
||||
def __init__(self, parent = None):
|
||||
super().__init__(parent)
|
||||
Application.getInstance().globalContainerStackChanged.connect(self._onGlobalContainerChanged)
|
||||
|
||||
globalContainerChanged = pyqtSignal()
|
||||
|
||||
def _onGlobalContainerChanged(self):
|
||||
self.globalContainerChanged.emit()
|
||||
|
||||
@pyqtSlot(str)
|
||||
def setActiveMachine(self, stack_id):
|
||||
pass
|
||||
|
||||
@pyqtProperty(str, notify = globalContainerChanged)
|
||||
def activeMachineId(self):
|
||||
return Application.getInstance().getGlobalContainerStack().getId()
|
||||
|
||||
def createMachineManagerModel(engine, script_engine):
|
||||
return MachineManagerModel()
|
|
@ -6,6 +6,7 @@ import QtQuick.Controls 1.1
|
|||
import QtQuick.Controls.Styles 1.1
|
||||
|
||||
import UM 1.2 as UM
|
||||
import Cura 1.0 as Cura
|
||||
|
||||
Item
|
||||
{
|
||||
|
@ -79,9 +80,9 @@ Item
|
|||
{
|
||||
text: model.name;
|
||||
checkable: true;
|
||||
checked: model.active;
|
||||
checked: Cura.MachineManager.activeMachineId == model.id
|
||||
exclusiveGroup: machineSelectionMenuGroup;
|
||||
onTriggered: UM.MachineManager.setActiveMachineInstance(model.name);
|
||||
onTriggered: Cura.MachineManager.setActiveMachine(model.id);
|
||||
}
|
||||
onObjectAdded: machineSelectionMenu.insertItem(index, object)
|
||||
onObjectRemoved: machineSelectionMenu.removeItem(object)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue