mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-21 20:19:32 +08:00
Checked build plates in context menu now actually match the selected item's build plates; changed collapse arrow. CURA-4525
This commit is contained in:
parent
0839125076
commit
fda4badab1
@ -2,6 +2,7 @@ from UM.Qt.ListModel import ListModel
|
|||||||
from PyQt5.QtCore import pyqtSignal, pyqtProperty, pyqtSlot
|
from PyQt5.QtCore import pyqtSignal, pyqtProperty, pyqtSlot
|
||||||
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
|
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
|
||||||
from UM.Scene.SceneNode import SceneNode
|
from UM.Scene.SceneNode import SceneNode
|
||||||
|
from UM.Scene.Selection import Selection
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
from UM.Application import Application
|
from UM.Application import Application
|
||||||
|
|
||||||
@ -9,13 +10,17 @@ from UM.Application import Application
|
|||||||
class BuildPlateModel(ListModel):
|
class BuildPlateModel(ListModel):
|
||||||
maxBuildPlateChanged = pyqtSignal()
|
maxBuildPlateChanged = pyqtSignal()
|
||||||
activeBuildPlateChanged = pyqtSignal()
|
activeBuildPlateChanged = pyqtSignal()
|
||||||
|
selectionChanged = pyqtSignal()
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
Application.getInstance().getController().getScene().sceneChanged.connect(self.updateMaxBuildPlate) # it may be a bit inefficient when changing a lot simultaneously
|
Application.getInstance().getController().getScene().sceneChanged.connect(self.updateMaxBuildPlate) # it may be a bit inefficient when changing a lot simultaneously
|
||||||
|
Application.getInstance().getController().getScene().sceneChanged.connect(self._updateSelectedObjectBuildPlateNumbers)
|
||||||
|
Selection.selectionChanged.connect(self._updateSelectedObjectBuildPlateNumbers)
|
||||||
|
|
||||||
self._max_build_plate = 1 # default
|
self._max_build_plate = 1 # default
|
||||||
self._active_build_plate = -1
|
self._active_build_plate = -1
|
||||||
|
self._selection_build_plates = []
|
||||||
|
|
||||||
@pyqtSlot(int)
|
@pyqtSlot(int)
|
||||||
def setActiveBuildPlate(self, nr):
|
def setActiveBuildPlate(self, nr):
|
||||||
@ -60,3 +65,14 @@ class BuildPlateModel(ListModel):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def createBuildPlateModel():
|
def createBuildPlateModel():
|
||||||
return BuildPlateModel()
|
return BuildPlateModel()
|
||||||
|
|
||||||
|
def _updateSelectedObjectBuildPlateNumbers(self, *args):
|
||||||
|
result = set()
|
||||||
|
for node in Selection.getAllSelectedObjects():
|
||||||
|
result.add(node.callDecoration("getBuildPlateNumber"))
|
||||||
|
self._selection_build_plates = list(result)
|
||||||
|
self.selectionChanged.emit()
|
||||||
|
|
||||||
|
@pyqtProperty("QVariantList", notify = selectionChanged)
|
||||||
|
def selectionBuildPlates(self):
|
||||||
|
return self._selection_build_plates
|
||||||
|
@ -49,7 +49,7 @@ Menu
|
|||||||
text: Cura.BuildPlateModel.getItem(index).name;
|
text: Cura.BuildPlateModel.getItem(index).name;
|
||||||
onTriggered: CuraActions.setBuildPlateForSelection(Cura.BuildPlateModel.getItem(index).buildPlateNumber);
|
onTriggered: CuraActions.setBuildPlateForSelection(Cura.BuildPlateModel.getItem(index).buildPlateNumber);
|
||||||
checkable: true
|
checkable: true
|
||||||
checked: Cura.BuildPlateModel.getItem(index).buildPlateNumber == Cura.BuildPlateModel.activeBuildPlate
|
checked: Cura.BuildPlateModel.selectionBuildPlates.indexOf(Cura.BuildPlateModel.getItem(index).buildPlateNumber) != -1;
|
||||||
visible: UM.Preferences.getValue("cura/use_multi_build_plate")
|
visible: UM.Preferences.getValue("cura/use_multi_build_plate")
|
||||||
}
|
}
|
||||||
onObjectAdded: base.insertItem(index, object);
|
onObjectAdded: base.insertItem(index, object);
|
||||||
@ -57,7 +57,10 @@ Menu
|
|||||||
}
|
}
|
||||||
MenuItem {
|
MenuItem {
|
||||||
text: "New build plate";
|
text: "New build plate";
|
||||||
onTriggered: CuraActions.setBuildPlateForSelection(Cura.BuildPlateModel.maxBuildPlate + 1);
|
onTriggered: {
|
||||||
|
CuraActions.setBuildPlateForSelection(Cura.BuildPlateModel.maxBuildPlate + 1);
|
||||||
|
checked = false;
|
||||||
|
}
|
||||||
checkable: true
|
checkable: true
|
||||||
checked: false
|
checked: false
|
||||||
visible: UM.Preferences.getValue("cura/use_multi_build_plate")
|
visible: UM.Preferences.getValue("cura/use_multi_build_plate")
|
||||||
|
@ -56,7 +56,7 @@ Rectangle
|
|||||||
sourceSize.width: width
|
sourceSize.width: width
|
||||||
sourceSize.height: width
|
sourceSize.height: width
|
||||||
color: UM.Theme.getColor("setting_control_text")
|
color: UM.Theme.getColor("setting_control_text")
|
||||||
source: collapsed ? UM.Theme.getIcon("arrow_top") : UM.Theme.getIcon("arrow_bottom")
|
source: collapsed ? UM.Theme.getIcon("arrow_left") : UM.Theme.getIcon("arrow_bottom")
|
||||||
}
|
}
|
||||||
label: Label{ }
|
label: Label{ }
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user