CURA-4870 Match the printer type in the dropdown with one of the

available printer types in the group
This commit is contained in:
Diego Prado Gesto 2018-03-07 22:33:15 +01:00
parent be8fc9f3f1
commit 3629c3959e
5 changed files with 72 additions and 49 deletions

View file

@ -451,6 +451,12 @@ class MachineManager(QObject):
def stacksHaveErrors(self) -> bool:
return bool(self._stacks_have_errors)
@pyqtProperty(str, notify = globalContainerChanged)
def activeMachineDefinitionName(self) -> str:
if self._global_container_stack:
return self._global_container_stack.definition.getName()
return ""
@pyqtProperty(str, notify = globalContainerChanged)
def activeMachineName(self) -> str:
if self._global_container_stack:
@ -1024,6 +1030,17 @@ class MachineManager(QObject):
self._setMaterial(position, new_material)
continue
def switchPrinterType(self, machine_type):
container_registry = ContainerRegistry.getInstance()
machine_definition = container_registry.findDefinitionContainers(name = machine_type)[0]
self._global_container_stack.definition = machine_definition
self.globalContainerChanged.emit()
# machine_stack = CuraStackBuilder.createMachine("ultimaker_s5" + "_instance", "ultimaker_s5")
# # if not machine_stack:
# # raise Exception("No machine found for ID {}".format(machine_id))
# Logger.log("d", "Setting active machine to %s", machine_stack.getId())
# self.setActiveMachine(machine_stack.getId())
@pyqtSlot(QObject)
def applyRemoteConfiguration(self, configuration: ConfigurationModel):
self.blurSettings.emit()

View file

@ -57,7 +57,7 @@ Column
section.criteria: ViewSection.FullString
section.delegate: sectionHeading
model: outputDevice.uniqueConfigurations
model: (ouputDevice != null) ? outputDevice.uniqueConfigurations : []
delegate: ConfigurationItem
{
width: parent.width - UM.Theme.getSize("default_margin").width

View file

@ -17,6 +17,8 @@ Button
height: parent.height
function updateOnSync()
{
if (outputDevice != undefined)
{
for (var index in outputDevice.uniqueConfigurations)
{
@ -27,6 +29,7 @@ Button
return
}
}
}
base.text = catalog.i18nc("@label:sync indicator", "No match")
}

View file

@ -1,8 +1,8 @@
// Copyright (c) 2018 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick 2.7
import QtQuick.Controls 1.4
import UM 1.3 as UM
import Cura 1.0 as Cura
@ -16,12 +16,12 @@ Menu
Instantiator
{
id: printerTypeInstantiator
model: outputDevice != null ? outputDevice.connectedPrintersTypeCount : null
model: outputDevice != null ? outputDevice.connectedPrintersTypeCount : []
MenuItem {
text: modelData.machine_type
checkable: true
checked: false
checked: Cura.MachineManager.activeMachineDefinitionName == modelData.machine_type
exclusiveGroup: group
// onTriggered:
// {

View file

@ -17,6 +17,7 @@ Column
property int currentExtruderIndex: Cura.ExtruderManager.activeExtruderIndex;
property bool currentExtruderVisible: extrudersList.visible;
property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0
property bool hasManyPrinterTypes: printerConnected ? Cura.MachineManager.printerOutputDevices[0].connectedPrintersTypeCount.length > 1 : false
spacing: Math.round(UM.Theme.getSize("sidebar_margin").width * 0.9)
@ -35,45 +36,6 @@ Column
width: height
}
// Printer Type Row
Item
{
id: printerTypeSelectionRow
height: UM.Theme.getSize("sidebar_setup").height
visible: printerConnected && !sidebar.monitoringPrint && !sidebar.hideSettings
anchors
{
left: parent.left
leftMargin: UM.Theme.getSize("sidebar_margin").width
right: parent.right
rightMargin: UM.Theme.getSize("sidebar_margin").width
}
Label
{
id: configurationLabel
text: catalog.i18nc("@label", "Printer type");
width: Math.round(parent.width * 0.4 - UM.Theme.getSize("default_margin").width)
height: parent.height
verticalAlignment: Text.AlignVCenter
font: UM.Theme.getFont("default");
color: UM.Theme.getColor("text");
}
ToolButton
{
id: printerTypeSelection
text: catalog.i18nc("@label", "Printer type");
height: UM.Theme.getSize("setting_control").height
width: Math.round(parent.width * 0.7) + UM.Theme.getSize("sidebar_margin").width
anchors.right: parent.right
style: UM.Theme.styles.sidebar_header_button
activeFocusOnPress: true;
menu: PrinterTypeMenu { }
}
}
// Extruder Row
Item
{
@ -264,6 +226,47 @@ Column
visible: !extruderSelectionRow.visible
}
// Printer Type Row
Item
{
id: printerTypeSelectionRow
height: UM.Theme.getSize("sidebar_setup").height
visible: printerConnected && hasManyPrinterTypes && !sidebar.monitoringPrint && !sidebar.hideSettings
anchors
{
left: parent.left
leftMargin: UM.Theme.getSize("sidebar_margin").width
right: parent.right
rightMargin: UM.Theme.getSize("sidebar_margin").width
}
Label
{
id: configurationLabel
text: catalog.i18nc("@label", "Printer type");
width: Math.round(parent.width * 0.4 - UM.Theme.getSize("default_margin").width)
height: parent.height
verticalAlignment: Text.AlignVCenter
font: UM.Theme.getFont("default");
color: UM.Theme.getColor("text");
}
ToolButton
{
id: printerTypeSelection
text: Cura.MachineManager.activeMachineDefinitionName
tooltip: Cura.MachineManager.activeMachineDefinitionName
height: UM.Theme.getSize("setting_control").height
width: Math.round(parent.width * 0.7) + UM.Theme.getSize("sidebar_margin").width
anchors.right: parent.right
style: UM.Theme.styles.sidebar_header_button
activeFocusOnPress: true;
menu: PrinterTypeMenu { }
}
}
// Material Row
Item
{