mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Removed singleton UM.OperationStack, merged with CuraActions
Removed ActiveTool singleton added to controller singleton CURA-7812
This commit is contained in:
parent
d01b5c1767
commit
676099ccf6
7 changed files with 45 additions and 21 deletions
|
@ -3,10 +3,11 @@
|
|||
|
||||
from typing import List, cast
|
||||
|
||||
from PyQt6.QtCore import QObject, QUrl, QMimeData
|
||||
from PyQt6.QtCore import QObject, QUrl, pyqtSignal, pyqtProperty
|
||||
from PyQt6.QtGui import QDesktopServices
|
||||
from PyQt6.QtWidgets import QApplication
|
||||
|
||||
from UM.Application import Application
|
||||
from UM.Event import CallFunctionEvent
|
||||
from UM.FlameProfiler import pyqtSlot
|
||||
from UM.Math.Vector import Vector
|
||||
|
@ -37,6 +38,10 @@ class CuraActions(QObject):
|
|||
def __init__(self, parent: QObject = None) -> None:
|
||||
super().__init__(parent)
|
||||
|
||||
self._operation_stack = Application.getInstance().getOperationStack()
|
||||
self._operation_stack.changed.connect(self._onUndoStackChanged)
|
||||
|
||||
undoStackChanged = pyqtSignal()
|
||||
@pyqtSlot()
|
||||
def openDocumentation(self) -> None:
|
||||
# Starting a web browser from a signal handler connected to a menu will crash on windows.
|
||||
|
@ -45,6 +50,25 @@ class CuraActions(QObject):
|
|||
event = CallFunctionEvent(self._openUrl, [QUrl("https://ultimaker.com/en/resources/manuals/software?utm_source=cura&utm_medium=software&utm_campaign=dropdown-documentation")], {})
|
||||
cura.CuraApplication.CuraApplication.getInstance().functionEvent(event)
|
||||
|
||||
@pyqtProperty(bool, notify=undoStackChanged)
|
||||
def canUndo(self):
|
||||
return self._operation_stack.canUndo()
|
||||
|
||||
@pyqtProperty(bool, notify=undoStackChanged)
|
||||
def canRedo(self):
|
||||
return self._operation_stack.canRedo()
|
||||
|
||||
@pyqtSlot()
|
||||
def undo(self):
|
||||
self._operation_stack.undo()
|
||||
|
||||
@pyqtSlot()
|
||||
def redo(self):
|
||||
self._operation_stack.redo()
|
||||
|
||||
def _onUndoStackChanged(self):
|
||||
self.undoStackChanged.emit()
|
||||
|
||||
@pyqtSlot()
|
||||
def openBugReportPage(self) -> None:
|
||||
event = CallFunctionEvent(self._openUrl, [QUrl("https://github.com/Ultimaker/Cura/issues/new/choose")], {})
|
||||
|
|
|
@ -25,7 +25,7 @@ UM.TooltipArea
|
|||
onClicked:
|
||||
{
|
||||
addedSettingsModel.setVisible(model.key, checked);
|
||||
UM.ActiveTool.forceUpdate();
|
||||
UM.Controller.forceUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ Item
|
|||
readonly property string infillMeshType: "infill_mesh"
|
||||
readonly property string antiOverhangMeshType: "anti_overhang_mesh"
|
||||
|
||||
property var currentMeshType: UM.ActiveTool.properties.getValue("MeshType")
|
||||
property var currentMeshType: UM.Controller.properties.getValue("MeshType")
|
||||
|
||||
// Update the view every time the currentMeshType changes
|
||||
onCurrentMeshTypeChanged:
|
||||
|
@ -56,7 +56,7 @@ Item
|
|||
|
||||
function setMeshType(type)
|
||||
{
|
||||
UM.ActiveTool.setProperty("MeshType", type)
|
||||
UM.Controller.setProperty("MeshType", type)
|
||||
updateMeshTypeCheckedState(type)
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,7 @@ Item
|
|||
visibilityHandler: Cura.PerObjectSettingVisibilityHandler
|
||||
{
|
||||
id: visibility_handler
|
||||
selectedObjectId: UM.ActiveTool.properties.getValue("SelectedObjectId")
|
||||
selectedObjectId: UM.Controller.properties.getValue("SelectedObjectId")
|
||||
}
|
||||
|
||||
// For some reason the model object is updated after removing him from the memory and
|
||||
|
@ -320,7 +320,7 @@ Item
|
|||
{
|
||||
id: provider
|
||||
|
||||
containerStackId: UM.ActiveTool.properties.getValue("ContainerID")
|
||||
containerStackId: UM.Controller.properties.getValue("ContainerID")
|
||||
key: model.key
|
||||
watchedProperties: [ "value", "enabled", "validationState" ]
|
||||
storeIndex: 0
|
||||
|
@ -330,7 +330,7 @@ Item
|
|||
UM.SettingPropertyProvider
|
||||
{
|
||||
id: inheritStackProvider
|
||||
containerStackId: UM.ActiveTool.properties.getValue("ContainerID")
|
||||
containerStackId: UM.Controller.properties.getValue("ContainerID")
|
||||
key: model.key
|
||||
watchedProperties: [ "limit_to_extruder" ]
|
||||
}
|
||||
|
@ -381,22 +381,22 @@ Item
|
|||
|
||||
Connections
|
||||
{
|
||||
target: UM.ActiveTool
|
||||
target: UM.Controller
|
||||
function onPropertiesChanged()
|
||||
{
|
||||
// the values cannot be bound with UM.ActiveTool.properties.getValue() calls,
|
||||
// the values cannot be bound with UM.Controller.properties.getValue() calls,
|
||||
// so here we connect to the signal and update the those values.
|
||||
if (typeof UM.ActiveTool.properties.getValue("SelectedObjectId") !== "undefined")
|
||||
if (typeof UM.Controller.properties.getValue("SelectedObjectId") !== "undefined")
|
||||
{
|
||||
const selectedObjectId = UM.ActiveTool.properties.getValue("SelectedObjectId")
|
||||
const selectedObjectId = UM.Controller.properties.getValue("SelectedObjectId")
|
||||
if (addedSettingsModel.visibilityHandler.selectedObjectId != selectedObjectId)
|
||||
{
|
||||
addedSettingsModel.visibilityHandler.selectedObjectId = selectedObjectId
|
||||
}
|
||||
}
|
||||
if (typeof UM.ActiveTool.properties.getValue("ContainerID") !== "undefined")
|
||||
if (typeof UM.Controller.properties.getValue("ContainerID") !== "undefined")
|
||||
{
|
||||
const containerId = UM.ActiveTool.properties.getValue("ContainerID")
|
||||
const containerId = UM.Controller.properties.getValue("ContainerID")
|
||||
if (provider.containerStackId !== containerId)
|
||||
{
|
||||
provider.containerStackId = containerId
|
||||
|
|
|
@ -120,8 +120,8 @@ Item
|
|||
text: catalog.i18nc("@action:inmenu menubar:edit", "&Undo")
|
||||
icon.name: "edit-undo"
|
||||
shortcut: StandardKey.Undo
|
||||
onTriggered: UM.OperationStack.undo()
|
||||
enabled: UM.OperationStack.canUndo
|
||||
onTriggered: UM.CuraActions.undo()
|
||||
enabled: UM.CuraActions.canUndo
|
||||
}
|
||||
|
||||
Action
|
||||
|
@ -130,8 +130,8 @@ Item
|
|||
text: catalog.i18nc("@action:inmenu menubar:edit", "&Redo")
|
||||
icon.name: "edit-redo"
|
||||
shortcut: StandardKey.Redo
|
||||
onTriggered: UM.OperationStack.redo()
|
||||
enabled: UM.OperationStack.canRedo
|
||||
onTriggered: UM.CuraActions.redo()
|
||||
enabled: UM.CuraActions.canRedo
|
||||
}
|
||||
|
||||
Action
|
||||
|
|
|
@ -160,7 +160,7 @@ Item
|
|||
ProfileWarningReset
|
||||
{
|
||||
id: profileWarningReset
|
||||
width: childrenRect.width
|
||||
width: parent.width
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
fullWarning: false
|
||||
|
|
|
@ -223,7 +223,7 @@ SettingItem
|
|||
|
||||
cursorShape: Qt.IBeamCursor
|
||||
|
||||
onPressed: {
|
||||
onPressed:(mouse)=> {
|
||||
if (!input.activeFocus)
|
||||
{
|
||||
base.focusGainedByClick = true
|
||||
|
|
|
@ -203,7 +203,7 @@ Item
|
|||
x: UM.Theme.getSize("default_margin").width
|
||||
y: UM.Theme.getSize("default_margin").height
|
||||
|
||||
source: UM.ActiveTool.valid ? UM.ActiveTool.activeToolPanel : ""
|
||||
source: UM.Controller.valid ? UM.Controller.activeToolPanel : ""
|
||||
enabled: UM.Controller.toolsEnabled
|
||||
}
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ Item
|
|||
UM.Label
|
||||
{
|
||||
id: toolHint
|
||||
text: UM.ActiveTool.properties.getValue("ToolHint") != undefined ? UM.ActiveTool.properties.getValue("ToolHint") : ""
|
||||
text: UM.Controller.properties.getValue("ToolHint") != undefined ? UM.ActiveTool.properties.getValue("ToolHint") : ""
|
||||
color: UM.Theme.getColor("tooltip_text")
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue