mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Fix Olsson Block binding in UM2 machine settings
CURA-4897
This commit is contained in:
parent
4cf07f5fe6
commit
cfd60e5557
2 changed files with 33 additions and 11 deletions
|
@ -2,7 +2,6 @@
|
||||||
# Uranium is released under the terms of the LGPLv3 or higher.
|
# Uranium is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
from UM.Settings.ContainerRegistry import ContainerRegistry
|
from UM.Settings.ContainerRegistry import ContainerRegistry
|
||||||
from UM.Settings.InstanceContainer import InstanceContainer
|
|
||||||
from cura.MachineAction import MachineAction
|
from cura.MachineAction import MachineAction
|
||||||
from PyQt5.QtCore import pyqtSlot, pyqtSignal, pyqtProperty
|
from PyQt5.QtCore import pyqtSlot, pyqtSignal, pyqtProperty
|
||||||
|
|
||||||
|
@ -11,8 +10,6 @@ from UM.Application import Application
|
||||||
from UM.Util import parseBool
|
from UM.Util import parseBool
|
||||||
catalog = i18nCatalog("cura")
|
catalog = i18nCatalog("cura")
|
||||||
|
|
||||||
import UM.Settings.InstanceContainer
|
|
||||||
|
|
||||||
|
|
||||||
## The Ultimaker 2 can have a few revisions & upgrades.
|
## The Ultimaker 2 can have a few revisions & upgrades.
|
||||||
class UM2UpgradeSelection(MachineAction):
|
class UM2UpgradeSelection(MachineAction):
|
||||||
|
@ -22,18 +19,29 @@ class UM2UpgradeSelection(MachineAction):
|
||||||
|
|
||||||
self._container_registry = ContainerRegistry.getInstance()
|
self._container_registry = ContainerRegistry.getInstance()
|
||||||
|
|
||||||
|
self._current_global_stack = None
|
||||||
|
|
||||||
|
from cura.CuraApplication import CuraApplication
|
||||||
|
CuraApplication.getInstance().globalContainerStackChanged.connect(self._onGlobalStackChanged)
|
||||||
|
self._reset()
|
||||||
|
|
||||||
def _reset(self):
|
def _reset(self):
|
||||||
self.hasVariantsChanged.emit()
|
self.hasVariantsChanged.emit()
|
||||||
|
|
||||||
|
def _onGlobalStackChanged(self):
|
||||||
|
if self._current_global_stack:
|
||||||
|
self._current_global_stack.metaDataChanged.disconnect(self._onGlobalStackMetaDataChanged)
|
||||||
|
|
||||||
|
self._current_global_stack = Application.getInstance().getGlobalContainerStack()
|
||||||
|
if self._current_global_stack:
|
||||||
|
self._current_global_stack.metaDataChanged.connect(self._onGlobalStackMetaDataChanged)
|
||||||
|
self._reset()
|
||||||
|
|
||||||
|
def _onGlobalStackMetaDataChanged(self):
|
||||||
|
self._reset()
|
||||||
|
|
||||||
hasVariantsChanged = pyqtSignal()
|
hasVariantsChanged = pyqtSignal()
|
||||||
|
|
||||||
@pyqtProperty(bool, notify = hasVariantsChanged)
|
|
||||||
def hasVariants(self):
|
|
||||||
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
|
||||||
if global_container_stack:
|
|
||||||
return parseBool(global_container_stack.getMetaDataEntry("has_variants", "false"))
|
|
||||||
|
|
||||||
@pyqtSlot(bool)
|
|
||||||
def setHasVariants(self, has_variants = True):
|
def setHasVariants(self, has_variants = True):
|
||||||
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
||||||
if global_container_stack:
|
if global_container_stack:
|
||||||
|
@ -62,3 +70,9 @@ class UM2UpgradeSelection(MachineAction):
|
||||||
global_container_stack.extruders["0"].variant = ContainerRegistry.getInstance().getEmptyInstanceContainer()
|
global_container_stack.extruders["0"].variant = ContainerRegistry.getInstance().getEmptyInstanceContainer()
|
||||||
|
|
||||||
Application.getInstance().globalContainerStackChanged.emit()
|
Application.getInstance().globalContainerStackChanged.emit()
|
||||||
|
self._reset()
|
||||||
|
|
||||||
|
@pyqtProperty(bool, fset = setHasVariants, notify = hasVariantsChanged)
|
||||||
|
def hasVariants(self):
|
||||||
|
if self._current_global_stack:
|
||||||
|
return parseBool(self._current_global_stack.getMetaDataEntry("has_variants", "false"))
|
||||||
|
|
|
@ -13,6 +13,7 @@ import Cura 1.0 as Cura
|
||||||
Cura.MachineAction
|
Cura.MachineAction
|
||||||
{
|
{
|
||||||
anchors.fill: parent;
|
anchors.fill: parent;
|
||||||
|
|
||||||
Item
|
Item
|
||||||
{
|
{
|
||||||
id: upgradeSelectionMachineAction
|
id: upgradeSelectionMachineAction
|
||||||
|
@ -39,12 +40,19 @@ Cura.MachineAction
|
||||||
|
|
||||||
CheckBox
|
CheckBox
|
||||||
{
|
{
|
||||||
|
id: olssonBlockCheckBox
|
||||||
anchors.top: pageDescription.bottom
|
anchors.top: pageDescription.bottom
|
||||||
anchors.topMargin: UM.Theme.getSize("default_margin").height
|
anchors.topMargin: UM.Theme.getSize("default_margin").height
|
||||||
|
|
||||||
text: catalog.i18nc("@label", "Olsson Block")
|
text: catalog.i18nc("@label", "Olsson Block")
|
||||||
checked: manager.hasVariants
|
checked: manager.hasVariants
|
||||||
onClicked: manager.setHasVariants(checked)
|
onClicked: manager.hasVariants = checked
|
||||||
|
|
||||||
|
Connections
|
||||||
|
{
|
||||||
|
target: manager
|
||||||
|
onHasVariantsChanged: olssonBlockCheckBox.checked = manager.hasVariants
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UM.I18nCatalog { id: catalog; name: "cura"; }
|
UM.I18nCatalog { id: catalog; name: "cura"; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue