mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Swap out UpdatableMachinesModel for MachineListModel.
This has to be instantiated with the WorkspaceDialog but attaching the listeners throws an error because it is done too early. The listeners are not needed anyway, so they have been disabled. Update WorkspaceDialog.qml to use MachineListModel CURA-9424
This commit is contained in:
parent
1ebf5bb650
commit
088ea0a768
2 changed files with 47 additions and 48 deletions
|
@ -5,6 +5,7 @@ from PyQt6.QtCore import pyqtSignal, QObject, pyqtProperty, QCoreApplication, QU
|
||||||
from PyQt6.QtGui import QDesktopServices
|
from PyQt6.QtGui import QDesktopServices
|
||||||
from typing import List, Optional, Dict, cast
|
from typing import List, Optional, Dict, cast
|
||||||
|
|
||||||
|
from cura.Machines.Models.MachineListModel import MachineListModel
|
||||||
from cura.Settings.GlobalStack import GlobalStack
|
from cura.Settings.GlobalStack import GlobalStack
|
||||||
from UM.Application import Application
|
from UM.Application import Application
|
||||||
from UM.FlameProfiler import pyqtSlot
|
from UM.FlameProfiler import pyqtSlot
|
||||||
|
@ -14,8 +15,6 @@ from UM.Message import Message
|
||||||
from UM.PluginRegistry import PluginRegistry
|
from UM.PluginRegistry import PluginRegistry
|
||||||
from UM.Settings.ContainerRegistry import ContainerRegistry
|
from UM.Settings.ContainerRegistry import ContainerRegistry
|
||||||
|
|
||||||
from .UpdatableMachinesModel import UpdatableMachinesModel
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
@ -63,7 +62,7 @@ class WorkspaceDialog(QObject):
|
||||||
self._extruders = []
|
self._extruders = []
|
||||||
self._objects_on_plate = False
|
self._objects_on_plate = False
|
||||||
self._is_printer_group = False
|
self._is_printer_group = False
|
||||||
self._updatable_machines_model = UpdatableMachinesModel(self)
|
self._updatable_machines_model = MachineListModel(self, listenToChanges=False)
|
||||||
self._missing_package_metadata: List[Dict[str, str]] = []
|
self._missing_package_metadata: List[Dict[str, str]] = []
|
||||||
self._plugin_registry: PluginRegistry = CuraApplication.getInstance().getPluginRegistry()
|
self._plugin_registry: PluginRegistry = CuraApplication.getInstance().getPluginRegistry()
|
||||||
self._install_missing_package_dialog: Optional[QObject] = None
|
self._install_missing_package_dialog: Optional[QObject] = None
|
||||||
|
@ -161,8 +160,8 @@ class WorkspaceDialog(QObject):
|
||||||
self.machineNameChanged.emit()
|
self.machineNameChanged.emit()
|
||||||
|
|
||||||
@pyqtProperty(QObject, notify = updatableMachinesChanged)
|
@pyqtProperty(QObject, notify = updatableMachinesChanged)
|
||||||
def updatableMachinesModel(self) -> UpdatableMachinesModel:
|
def updatableMachinesModel(self) -> MachineListModel:
|
||||||
return cast(UpdatableMachinesModel, self._updatable_machines_model)
|
return cast(MachineListModel, self._updatable_machines_model)
|
||||||
|
|
||||||
def setUpdatableMachines(self, updatable_machines: List[GlobalStack]) -> None:
|
def setUpdatableMachines(self, updatable_machines: List[GlobalStack]) -> None:
|
||||||
self._updatable_machines_model.update(updatable_machines)
|
self._updatable_machines_model.update(updatable_machines)
|
||||||
|
|
|
@ -107,50 +107,50 @@ UM.Dialog
|
||||||
comboboxTitle: catalog.i18nc("@action:label", "Open With")
|
comboboxTitle: catalog.i18nc("@action:label", "Open With")
|
||||||
comboboxTooltipText: catalog.i18nc("@info:tooltip", "How should the conflict in the machine be resolved?")
|
comboboxTooltipText: catalog.i18nc("@info:tooltip", "How should the conflict in the machine be resolved?")
|
||||||
comboboxVisible: workspaceDialog.visible && manager.updatableMachinesModel.count > 1
|
comboboxVisible: workspaceDialog.visible && manager.updatableMachinesModel.count > 1
|
||||||
combobox: Cura.ComboBox
|
combobox: Cura.MachineSelector
|
||||||
{
|
{
|
||||||
id: machineResolveComboBox
|
id: machineSelector
|
||||||
model: manager.updatableMachinesModel
|
headerCornerSide: Cura.RoundedRectangle.Direction.All
|
||||||
textRole: "displayName"
|
width: UM.Theme.getSize("machine_selector_widget").width
|
||||||
visible: workspaceDialog.visible && model.count > 1
|
height: parent.height
|
||||||
currentIndex: machineVisibleChanged()
|
anchors.centerIn: parent
|
||||||
|
machineListModel: manager.updatableMachinesModel
|
||||||
onCurrentIndexChanged:
|
// onCurrentIndexChanged:
|
||||||
{
|
// {
|
||||||
if (model.getItem(currentIndex).id == "new"
|
// if (model.getItem(currentIndex).id == "new"
|
||||||
&& model.getItem(currentIndex).type == "default_option")
|
// && model.getItem(currentIndex).type == "default_option")
|
||||||
{
|
// {
|
||||||
manager.setResolveStrategy("machine", "new")
|
// manager.setResolveStrategy("machine", "new")
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
manager.setResolveStrategy("machine", "override")
|
// manager.setResolveStrategy("machine", "override")
|
||||||
manager.setMachineToOverride(model.getItem(currentIndex).id)
|
// manager.setMachineToOverride(model.getItem(currentIndex).id)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
function machineVisibleChanged()
|
// function machineVisibleChanged()
|
||||||
{
|
// {
|
||||||
if (!visible) {return}
|
// if (!visible) {return}
|
||||||
|
//
|
||||||
currentIndex = 0
|
// currentIndex = 0
|
||||||
// If the project printer exists in Cura, set it as the default dropdown menu option.
|
// // If the project printer exists in Cura, set it as the default dropdown menu option.
|
||||||
// No need to check object 0, which is the "Create new" option
|
// // No need to check object 0, which is the "Create new" option
|
||||||
for (var i = 1; i < model.count; i++)
|
// for (var i = 1; i < model.count; i++)
|
||||||
{
|
// {
|
||||||
if (model.getItem(i).name == manager.machineName)
|
// if (model.getItem(i).name == manager.machineName)
|
||||||
{
|
// {
|
||||||
currentIndex = i
|
// currentIndex = i
|
||||||
break
|
// break
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
// The project printer does not exist in Cura. If there is at least one printer of the same
|
// // The project printer does not exist in Cura. If there is at least one printer of the same
|
||||||
// type, select the first one, else set the index to "Create new"
|
// // type, select the first one, else set the index to "Create new"
|
||||||
if (currentIndex == 0 && model.count > 1)
|
// if (currentIndex == 0 && model.count > 1)
|
||||||
{
|
// {
|
||||||
currentIndex = 1
|
// currentIndex = 1
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue