mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-10 00:07:51 -06:00
CURA-4870 Prepare the UI to show the list of configurations
This commit is contained in:
parent
6e35fc5035
commit
49fcf35d9b
9 changed files with 113 additions and 100 deletions
|
@ -1,11 +1,13 @@
|
|||
# Copyright (c) 2018 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
from PyQt5.QtCore import pyqtProperty, QObject
|
||||
from PyQt5.QtCore import pyqtProperty, QObject, pyqtSignal
|
||||
|
||||
|
||||
class ConfigurationModel(QObject):
|
||||
|
||||
configurationChanged = pyqtSignal()
|
||||
|
||||
def __init__(self):
|
||||
self._printer_type = None
|
||||
self._extruder_configurations = []
|
||||
|
@ -21,14 +23,14 @@ class ConfigurationModel(QObject):
|
|||
def setExtruderConfigurations(self, extruder_configurations):
|
||||
self._extruder_configurations = extruder_configurations
|
||||
|
||||
@pyqtProperty("QVariantList", fset = setExtruderConfigurations, constant = True)
|
||||
@pyqtProperty("QVariantList", fset = setExtruderConfigurations, notify = configurationChanged)
|
||||
def extruderConfigurations(self):
|
||||
return self._extruder_configurations
|
||||
|
||||
def setBuildplateConfiguration(self, buildplate_configuration):
|
||||
self._buildplate_configuration = buildplate_configuration
|
||||
|
||||
@pyqtProperty(str, fset = setBuildplateConfiguration, constant = True)
|
||||
@pyqtProperty(str, fset = setBuildplateConfiguration, notify = configurationChanged)
|
||||
def buildplateConfiguration(self):
|
||||
return self._buildplate_configuration
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
# Copyright (c) 2017 Ultimaker B.V.
|
||||
# Copyright (c) 2018 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
from PyQt5.QtCore import pyqtSignal, pyqtProperty, QObject, QVariant, pyqtSlot
|
||||
from UM.Logger import Logger
|
||||
from PyQt5.QtCore import pyqtSignal, pyqtProperty, QObject, pyqtSlot
|
||||
|
||||
from typing import Optional
|
||||
|
||||
|
@ -83,7 +82,7 @@ class ExtruderOutputModel(QObject):
|
|||
self._extruder_configuration = {
|
||||
"position": self._position,
|
||||
"material": self._active_material.type if self.activeMaterial is not None else None,
|
||||
"hotend_id": self._hotend_id
|
||||
"hotendID": self._hotend_id
|
||||
}
|
||||
print("Recalculating extruder configuration:", self._extruder_configuration)
|
||||
self.extruderConfigurationChanged.emit()
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
# Copyright (c) 2017 Ultimaker B.V.
|
||||
# Copyright (c) 2018 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
from PyQt5.QtCore import pyqtSignal, pyqtProperty, QObject, QVariant, pyqtSlot
|
||||
from UM.Logger import Logger
|
||||
from typing import Optional, List
|
||||
from typing import Optional
|
||||
from UM.Math.Vector import Vector
|
||||
from cura.PrinterOutput.ConfigurationModel import ConfigurationModel
|
||||
from cura.PrinterOutput.ExtruderOutputModel import ExtruderOutputModel
|
||||
|
@ -42,7 +41,7 @@ class PrinterOutputModel(QObject):
|
|||
self._printer_state = "unknown"
|
||||
self._is_preheating = False
|
||||
self._type = ""
|
||||
# Update the configuration every time the one of the extruders changes its configuration
|
||||
# Update the printer configuration every time any of the extruders changes its configuration
|
||||
for extruder in self._extruders:
|
||||
extruder.extruderConfigurationChanged.connect(self._updatePrinterConfiguration)
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Copyright (c) 2017 Ultimaker B.V.
|
||||
# Copyright (c) 2018 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
from UM.i18n import i18nCatalog
|
||||
|
@ -6,13 +6,12 @@ from UM.OutputDevice.OutputDevice import OutputDevice
|
|||
from PyQt5.QtCore import pyqtProperty, QObject, QTimer, pyqtSignal
|
||||
from PyQt5.QtWidgets import QMessageBox
|
||||
|
||||
|
||||
from UM.Logger import Logger
|
||||
from UM.Signal import signalemitter
|
||||
from UM.Application import Application
|
||||
|
||||
from enum import IntEnum # For the connection state tracking.
|
||||
from typing import List, Optional
|
||||
from typing import List, Set, Optional
|
||||
|
||||
MYPY = False
|
||||
if MYPY:
|
||||
|
@ -46,13 +45,13 @@ class PrinterOutputDevice(QObject, OutputDevice):
|
|||
connectionTextChanged = pyqtSignal()
|
||||
|
||||
# Signal to indicate that the configuration of one of the printers has changed.
|
||||
configurationChanged = pyqtSignal()
|
||||
uniqueConfigurationsChanged = pyqtSignal()
|
||||
|
||||
def __init__(self, device_id, parent = None):
|
||||
super().__init__(device_id = device_id, parent = parent)
|
||||
|
||||
self._printers = [] # type: List[PrinterOutputModel]
|
||||
self._unique_configurations = [] # type: List[ConfigurationModel]
|
||||
self._unique_configurations = {} # type: Set[ConfigurationModel]
|
||||
|
||||
self._monitor_view_qml_path = ""
|
||||
self._monitor_component = None
|
||||
|
@ -182,20 +181,22 @@ class PrinterOutputDevice(QObject, OutputDevice):
|
|||
self.acceptsCommandsChanged.emit()
|
||||
|
||||
# Returns the unique configurations of the current printers
|
||||
@pyqtProperty("QVariantList", notify = configurationChanged)
|
||||
def uniqueConfiguration(self):
|
||||
@pyqtProperty("QVariantMap", notify = uniqueConfigurationsChanged)
|
||||
def uniqueConfigurations(self):
|
||||
return self._unique_configurations
|
||||
|
||||
def _updateUniqueConfigurations(self):
|
||||
print("Calculating the unique configurations")
|
||||
self._unique_configurations = list(set([printer.printerConfiguration for printer in self._printers]))
|
||||
print(self._unique_configurations)
|
||||
self.configurationChanged.emit()
|
||||
self._unique_configurations = set([printer.printerConfiguration for printer in self._printers])
|
||||
self.uniqueConfigurationsChanged.emit()
|
||||
|
||||
def _onPrintersChanged(self):
|
||||
for printer in self._printers:
|
||||
printer.configurationChanged.connect(self._updateUniqueConfigurations)
|
||||
|
||||
# If at this point the list of unique configurations is empty, we force the calculation
|
||||
if not self._unique_configurations:
|
||||
self._updateUniqueConfigurations()
|
||||
|
||||
|
||||
## The current processing state of the backend.
|
||||
class ConnectionState(IntEnum):
|
||||
|
|
|
@ -11,7 +11,7 @@ Rectangle
|
|||
{
|
||||
id: configurationItem
|
||||
|
||||
property var printer: null
|
||||
property var configuration: null
|
||||
signal configurationSelected()
|
||||
|
||||
height: childrenRect.height
|
||||
|
@ -26,7 +26,7 @@ Rectangle
|
|||
|
||||
Label
|
||||
{
|
||||
text: printer.name
|
||||
text: configuration.printerType
|
||||
}
|
||||
|
||||
Row
|
||||
|
@ -41,7 +41,7 @@ Rectangle
|
|||
Repeater
|
||||
{
|
||||
height: childrenRect.height
|
||||
model: printer.extruders
|
||||
model: configuration.extruderConfigurations
|
||||
delegate: PrintCoreConfiguration
|
||||
{
|
||||
printCoreConfiguration: modelData
|
||||
|
@ -55,7 +55,7 @@ Rectangle
|
|||
//
|
||||
// Label
|
||||
// {
|
||||
// text: printer.name + "-" + printer.type
|
||||
// text: configuration.buildplateConfiguration
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
// Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
import QtQuick 2.7
|
||||
import QtQuick.Controls 2.0
|
||||
import QtQuick.Controls 1.4
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
|
||||
import UM 1.2 as UM
|
||||
import Cura 1.0 as Cura
|
||||
|
@ -21,12 +22,13 @@ Column
|
|||
width: parent.width - 2 * parent.padding
|
||||
}
|
||||
|
||||
Item
|
||||
{
|
||||
ScrollView {
|
||||
id: container
|
||||
width: parent.width - 2 * parent.padding
|
||||
height: childrenRect.height
|
||||
|
||||
style: UM.Theme.styles.scrollview
|
||||
|
||||
Repeater {
|
||||
height: childrenRect.height
|
||||
model: outputDevice != null ? outputDevice.connectedPrintersTypeCount : null
|
||||
|
@ -42,23 +44,24 @@ Column
|
|||
|
||||
ListView
|
||||
{
|
||||
id: grid
|
||||
id: configurationList
|
||||
anchors.top: printerTypeHeader.bottom
|
||||
anchors.topMargin: UM.Theme.getSize("default_margin").height
|
||||
width: container.width
|
||||
height: childrenRect.height
|
||||
model: outputDevice.printers
|
||||
model: outputDevice.uniqueConfigurations
|
||||
delegate: ConfigurationItem
|
||||
{
|
||||
height: parent.height
|
||||
width: parent.width
|
||||
printer: modelData
|
||||
configuration: modelData
|
||||
onConfigurationSelected:
|
||||
{
|
||||
print("SELECCIONANDO IMPRESORA", printer.name)
|
||||
outputDevice.setActivePrinter(printer)
|
||||
print("SELECCIONANDO CONFIGURACION", JSON.stringify(configuration))
|
||||
}
|
||||
Component.onCompleted: {print("$$$$$$$$$$$$$$$$$$ Configuracion", JSON.stringify(configuration))}
|
||||
}
|
||||
Component.onCompleted: {print("$$$$$$$$$$$$$$$$$$ Elementos del modelo", JSON.stringify(outputDevice.uniqueConfigurations))}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
// Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
import QtQuick 2.7
|
||||
import QtQuick.Controls 1.4
|
||||
import QtQuick.Controls 2.3 as QQC2
|
||||
import QtQuick.Layouts 1.1
|
||||
import QtQuick.Controls 2.3
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
|
||||
import UM 1.2 as UM
|
||||
|
@ -15,70 +13,10 @@ Item
|
|||
id: configurationSelector
|
||||
property var panelWidth: control.width
|
||||
property var panelVisible: false
|
||||
Button
|
||||
{
|
||||
text: "Matched"
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
|
||||
style: ButtonStyle
|
||||
{
|
||||
background: Rectangle
|
||||
{
|
||||
color:
|
||||
{
|
||||
if(control.pressed)
|
||||
{
|
||||
return UM.Theme.getColor("sidebar_header_active");
|
||||
}
|
||||
else if(control.hovered)
|
||||
{
|
||||
return UM.Theme.getColor("sidebar_header_hover");
|
||||
}
|
||||
else
|
||||
{
|
||||
return UM.Theme.getColor("sidebar_header_bar");
|
||||
}
|
||||
}
|
||||
Behavior on color { ColorAnimation { duration: 50; } }
|
||||
SyncButton { }
|
||||
|
||||
UM.RecolorImage
|
||||
{
|
||||
id: downArrow
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: UM.Theme.getSize("default_margin").width
|
||||
width: UM.Theme.getSize("standard_arrow").width
|
||||
height: UM.Theme.getSize("standard_arrow").height
|
||||
sourceSize.width: width
|
||||
sourceSize.height: width
|
||||
color: UM.Theme.getColor("text_emphasis")
|
||||
source: UM.Theme.getIcon("arrow_bottom")
|
||||
}
|
||||
Label
|
||||
{
|
||||
id: sidebarComboBoxLabel
|
||||
color: UM.Theme.getColor("sidebar_header_text_active")
|
||||
text: control.text
|
||||
elide: Text.ElideRight
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: UM.Theme.getSize("default_margin").width * 2
|
||||
anchors.right: downArrow.left
|
||||
anchors.rightMargin: control.rightMargin
|
||||
anchors.verticalCenter: parent.verticalCenter;
|
||||
font: UM.Theme.getFont("large")
|
||||
}
|
||||
}
|
||||
label: Label {}
|
||||
}
|
||||
|
||||
onClicked:
|
||||
{
|
||||
panelVisible = !panelVisible
|
||||
}
|
||||
}
|
||||
|
||||
QQC2.Popup
|
||||
Popup
|
||||
{
|
||||
id: popup
|
||||
y: configurationSelector.height - UM.Theme.getSize("default_lining").height
|
||||
|
|
|
@ -17,7 +17,7 @@ Item
|
|||
Label
|
||||
{
|
||||
id: materialLabel
|
||||
text: printCoreConfiguration.activeMaterial != null ? printCoreConfiguration.activeMaterial.name : ""
|
||||
text: printCoreConfiguration.material
|
||||
elide: Text.ElideRight
|
||||
width: parent.width
|
||||
font: UM.Theme.getFont("very_small")
|
||||
|
|
71
resources/qml/Menus/ConfigurationMenu/SyncButton.qml
Normal file
71
resources/qml/Menus/ConfigurationMenu/SyncButton.qml
Normal file
|
@ -0,0 +1,71 @@
|
|||
// Copyright (c) 2018 Ultimaker B.V.
|
||||
// Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
import QtQuick 2.7
|
||||
import QtQuick.Controls 1.4
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
|
||||
import UM 1.2 as UM
|
||||
|
||||
Button
|
||||
{
|
||||
text: "Matched"
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
|
||||
style: ButtonStyle
|
||||
{
|
||||
background: Rectangle
|
||||
{
|
||||
color:
|
||||
{
|
||||
if(control.pressed)
|
||||
{
|
||||
return UM.Theme.getColor("sidebar_header_active");
|
||||
}
|
||||
else if(control.hovered)
|
||||
{
|
||||
return UM.Theme.getColor("sidebar_header_hover");
|
||||
}
|
||||
else
|
||||
{
|
||||
return UM.Theme.getColor("sidebar_header_bar");
|
||||
}
|
||||
}
|
||||
Behavior on color { ColorAnimation { duration: 50; } }
|
||||
|
||||
UM.RecolorImage
|
||||
{
|
||||
id: downArrow
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: UM.Theme.getSize("default_margin").width
|
||||
width: UM.Theme.getSize("standard_arrow").width
|
||||
height: UM.Theme.getSize("standard_arrow").height
|
||||
sourceSize.width: width
|
||||
sourceSize.height: width
|
||||
color: UM.Theme.getColor("text_emphasis")
|
||||
source: UM.Theme.getIcon("arrow_bottom")
|
||||
}
|
||||
Label
|
||||
{
|
||||
id: sidebarComboBoxLabel
|
||||
color: UM.Theme.getColor("sidebar_header_text_active")
|
||||
text: control.text
|
||||
elide: Text.ElideRight
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: UM.Theme.getSize("default_margin").width * 2
|
||||
anchors.right: downArrow.left
|
||||
anchors.rightMargin: control.rightMargin
|
||||
anchors.verticalCenter: parent.verticalCenter;
|
||||
font: UM.Theme.getFont("large")
|
||||
}
|
||||
}
|
||||
label: Label {}
|
||||
}
|
||||
|
||||
onClicked:
|
||||
{
|
||||
panelVisible = !panelVisible
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue