Merge branch 'master' into CURA-6449_fix_non_host_printers

This commit is contained in:
Lipu Fei 2019-04-15 11:37:02 +02:00 committed by GitHub
commit d9018220b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 61 additions and 66 deletions

View File

@ -7,6 +7,7 @@ from PyQt5.QtCore import pyqtSlot, pyqtProperty, pyqtSignal, QObject
from UM.i18n import i18nCatalog from UM.i18n import i18nCatalog
from UM.Logger import Logger from UM.Logger import Logger
from UM.Util import parseBool
if TYPE_CHECKING: if TYPE_CHECKING:
from PyQt5.QtCore import QObject from PyQt5.QtCore import QObject
@ -100,7 +101,8 @@ class DiscoveredPrintersModel(QObject):
@pyqtProperty(list, notify = discoveredPrintersChanged) @pyqtProperty(list, notify = discoveredPrintersChanged)
def discoveredPrinters(self) -> List["DiscoveredPrinter"]: def discoveredPrinters(self) -> List["DiscoveredPrinter"]:
item_list = list(x for x in self._discovered_printer_by_ip_dict.values()) item_list = list(
x for x in self._discovered_printer_by_ip_dict.values() if not parseBool(x.device.getProperty("temporary")))
item_list.sort(key = lambda x: (int(not x.isUnknownMachineType), getattr(x.device, "clusterSize", 1), x.device.name), reverse = True) item_list.sort(key = lambda x: (int(not x.isUnknownMachineType), getattr(x.device, "clusterSize", 1), x.device.name), reverse = True)
return item_list return item_list

View File

@ -212,7 +212,7 @@ class GlobalStack(CuraContainerStack):
# Determine whether or not we should try to get the "resolve" property instead of the # Determine whether or not we should try to get the "resolve" property instead of the
# requested property. # requested property.
def _shouldResolve(self, key: str, property_name: str, context: Optional[PropertyEvaluationContext] = None) -> bool: def _shouldResolve(self, key: str, property_name: str, context: Optional[PropertyEvaluationContext] = None) -> bool:
if property_name is not "value": if property_name != "value":
# Do not try to resolve anything but the "value" property # Do not try to resolve anything but the "value" property
return False return False

View File

@ -65,6 +65,7 @@ Item
{ {
id: description id: description
text: details.description || "" text: details.description || ""
font: UM.Theme.getFont("default")
anchors anchors
{ {
top: title.bottom top: title.bottom

View File

@ -53,7 +53,7 @@ class AuthorsModel(ListModel):
# Filter on all the key-word arguments. # Filter on all the key-word arguments.
for key, value in self._filter.items(): for key, value in self._filter.items():
if key is "package_types": if key == "package_types":
key_filter = lambda item, value = value: value in item["package_types"] # type: ignore key_filter = lambda item, value = value: value in item["package_types"] # type: ignore
elif "*" in value: elif "*" in value:
key_filter = lambda item, key = key, value = value: self._matchRegExp(item, key, value) # type: ignore key_filter = lambda item, key = key, value = value: self._matchRegExp(item, key, value) # type: ignore

View File

@ -112,7 +112,7 @@ class PackagesModel(ListModel):
# Filter on all the key-word arguments. # Filter on all the key-word arguments.
for key, value in self._filter.items(): for key, value in self._filter.items():
if key is "tags": if key == "tags":
key_filter = lambda item, v = value: v in item["tags"] key_filter = lambda item, v = value: v in item["tags"]
elif "*" in value: elif "*" in value:
key_filter = lambda candidate, k = key, v = value: self._matchRegExp(candidate, k, v) key_filter = lambda candidate, k = key, v = value: self._matchRegExp(candidate, k, v)

View File

@ -613,12 +613,12 @@ class Toolbox(QObject, Extension):
self._server_response_data[response_type] = json_data["data"] self._server_response_data[response_type] = json_data["data"]
self._models[response_type].setMetadata(self._server_response_data[response_type]) self._models[response_type].setMetadata(self._server_response_data[response_type])
if response_type is "packages": if response_type == "packages":
self._models[response_type].setFilter({"type": "plugin"}) self._models[response_type].setFilter({"type": "plugin"})
self.reBuildMaterialsModels() self.reBuildMaterialsModels()
self.reBuildPluginsModels() self.reBuildPluginsModels()
self._notifyPackageManager() self._notifyPackageManager()
elif response_type is "authors": elif response_type == "authors":
self._models[response_type].setFilter({"package_types": "material"}) self._models[response_type].setFilter({"package_types": "material"})
self._models[response_type].setFilter({"tags": "generic"}) self._models[response_type].setFilter({"tags": "generic"})

View File

@ -1,15 +1,16 @@
# Copyright (c) 2019 Ultimaker B.V. # Copyright (c) 2019 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher. # Cura is released under the terms of the LGPLv3 or higher.
from typing import cast from typing import TYPE_CHECKING
from Charon.VirtualFile import VirtualFile from Charon.VirtualFile import VirtualFile
from UM.Mesh.MeshReader import MeshReader from UM.Mesh.MeshReader import MeshReader
from UM.MimeTypeDatabase import MimeType, MimeTypeDatabase from UM.MimeTypeDatabase import MimeType, MimeTypeDatabase
from UM.PluginRegistry import PluginRegistry from UM.PluginRegistry import PluginRegistry
from cura.Scene.CuraSceneNode import CuraSceneNode
from plugins.GCodeReader.GCodeReader import GCodeReader if TYPE_CHECKING:
from cura.Scene.CuraSceneNode import CuraSceneNode
class UFPReader(MeshReader): class UFPReader(MeshReader):
@ -26,7 +27,7 @@ class UFPReader(MeshReader):
) )
self._supported_extensions = [".ufp"] self._supported_extensions = [".ufp"]
def _read(self, file_name: str) -> CuraSceneNode: def _read(self, file_name: str) -> "CuraSceneNode":
# Open the file # Open the file
archive = VirtualFile() archive = VirtualFile()
archive.open(file_name) archive.open(file_name)
@ -36,6 +37,6 @@ class UFPReader(MeshReader):
gcode_stream = gcode_data["/3D/model.gcode"].decode("utf-8") gcode_stream = gcode_data["/3D/model.gcode"].decode("utf-8")
# Open the GCodeReader to parse the data # Open the GCodeReader to parse the data
gcode_reader = cast(GCodeReader, PluginRegistry.getInstance().getPluginObject("GCodeReader")) gcode_reader = PluginRegistry.getInstance().getPluginObject("GCodeReader") # type: ignore
gcode_reader.preReadFromStream(gcode_stream) gcode_reader.preReadFromStream(gcode_stream)
return gcode_reader.readFromStream(gcode_stream) return gcode_reader.readFromStream(gcode_stream)

View File

@ -27,6 +27,7 @@ from UM.Version import Version
from . import ClusterUM3OutputDevice, LegacyUM3OutputDevice from . import ClusterUM3OutputDevice, LegacyUM3OutputDevice
from .Cloud.CloudOutputDeviceManager import CloudOutputDeviceManager from .Cloud.CloudOutputDeviceManager import CloudOutputDeviceManager
from .Cloud.CloudOutputDevice import CloudOutputDevice # typing
if TYPE_CHECKING: if TYPE_CHECKING:
from PyQt5.QtNetwork import QNetworkReply from PyQt5.QtNetwork import QNetworkReply
@ -181,7 +182,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
um_network_key = CuraApplication.getInstance().getGlobalContainerStack().getMetaDataEntry("um_network_key") um_network_key = CuraApplication.getInstance().getGlobalContainerStack().getMetaDataEntry("um_network_key")
if key == um_network_key: if key == um_network_key:
self.getOutputDeviceManager().addOutputDevice(self._discovered_devices[key]) self.getOutputDeviceManager().addOutputDevice(self._discovered_devices[key])
self.checkCloudFlowIsPossible() self.checkCloudFlowIsPossible(None)
else: else:
self.getOutputDeviceManager().removeOutputDevice(key) self.getOutputDeviceManager().removeOutputDevice(key)
if key.startswith("manual:"): if key.startswith("manual:"):
@ -488,7 +489,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
return True return True
## Check if the prerequsites are in place to start the cloud flow ## Check if the prerequsites are in place to start the cloud flow
def checkCloudFlowIsPossible(self) -> None: def checkCloudFlowIsPossible(self, cluster: Optional[CloudOutputDevice]) -> None:
Logger.log("d", "Checking if cloud connection is possible...") Logger.log("d", "Checking if cloud connection is possible...")
# Pre-Check: Skip if active machine already has been cloud connected or you said don't ask again # Pre-Check: Skip if active machine already has been cloud connected or you said don't ask again
@ -595,7 +596,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
self._cloud_flow_complete_message.hide() self._cloud_flow_complete_message.hide()
# Check for cloud flow again with newly selected machine # Check for cloud flow again with newly selected machine
self.checkCloudFlowIsPossible() self.checkCloudFlowIsPossible(None)
def _createCloudFlowStartMessage(self): def _createCloudFlowStartMessage(self):
self._start_cloud_flow_message = Message( self._start_cloud_flow_message = Message(

View File

@ -9,10 +9,9 @@ import Cura 1.1 as Cura
Column Column
{ {
width: Math.max(title.width, width: Math.max(title.width, accountButton.width) + 2 * UM.Theme.getSize("default_margin").width
accountButton.width) * 1.5
spacing: UM.Theme.getSize("default_margin").width spacing: UM.Theme.getSize("default_margin").height
Label Label
{ {
@ -20,17 +19,11 @@ Column
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
renderType: Text.NativeRendering renderType: Text.NativeRendering
text: catalog.i18nc("@label The argument is a username.", "Hi %1").format(profile.username) text: catalog.i18nc("@label The argument is a username.", "Hi %1").arg(profile.username)
font: UM.Theme.getFont("large_bold") font: UM.Theme.getFont("large_bold")
color: UM.Theme.getColor("text") color: UM.Theme.getColor("text")
} }
// placeholder
Label
{
text: " "
}
Cura.SecondaryButton Cura.SecondaryButton
{ {
id: accountButton id: accountButton

View File

@ -205,7 +205,7 @@ Item
Row Row
{ {
height: visible ? childrenRect.height : 0 height: visible ? UM.Theme.getSize("setting_control").height : 0
visible: extrudersModel.count > 1 // If there is only one extruder, there is no point to enable/disable that. visible: extrudersModel.count > 1 // If there is only one extruder, there is no point to enable/disable that.
Label Label
@ -223,7 +223,7 @@ Item
{ {
checked: Cura.MachineManager.activeStack != null ? Cura.MachineManager.activeStack.isEnabled : false checked: Cura.MachineManager.activeStack != null ? Cura.MachineManager.activeStack.isEnabled : false
enabled: !checked || Cura.MachineManager.numberExtrudersEnabled > 1 //Disable if it's the last enabled extruder. enabled: !checked || Cura.MachineManager.numberExtrudersEnabled > 1 //Disable if it's the last enabled extruder.
height: UM.Theme.getSize("setting_control").height height: parent.height
style: UM.Theme.styles.checkbox style: UM.Theme.styles.checkbox
/* Use a MouseArea to process the click on this checkbox. /* Use a MouseArea to process the click on this checkbox.
@ -242,7 +242,7 @@ Item
Row Row
{ {
height: visible ? childrenRect.height: 0 height: visible ? UM.Theme.getSize("print_setup_big_item").height : 0
visible: Cura.MachineManager.hasMaterials visible: Cura.MachineManager.hasMaterials
Label Label
@ -267,7 +267,7 @@ Item
tooltip: text tooltip: text
width: selectors.controlWidth width: selectors.controlWidth
height: UM.Theme.getSize("print_setup_big_item").height height: parent.height
style: UM.Theme.styles.print_setup_header_button style: UM.Theme.styles.print_setup_header_button
activeFocusOnPress: true activeFocusOnPress: true
@ -302,7 +302,7 @@ Item
Row Row
{ {
height: visible ? childrenRect.height: 0 height: visible ? UM.Theme.getSize("print_setup_big_item").height : 0
visible: Cura.MachineManager.hasVariants visible: Cura.MachineManager.hasVariants
Label Label
@ -321,7 +321,7 @@ Item
id: variantSelection id: variantSelection
text: Cura.MachineManager.activeVariantName text: Cura.MachineManager.activeVariantName
tooltip: Cura.MachineManager.activeVariantName tooltip: Cura.MachineManager.activeVariantName
height: UM.Theme.getSize("print_setup_big_item").height height: parent.height
width: selectors.controlWidth width: selectors.controlWidth
style: UM.Theme.styles.print_setup_header_button style: UM.Theme.styles.print_setup_header_button
activeFocusOnPress: true; activeFocusOnPress: true;

View File

@ -133,7 +133,14 @@ Item
supportExtruderCombobox.color = supportExtruderCombobox.model.getItem(supportExtruderCombobox.currentIndex).color supportExtruderCombobox.color = supportExtruderCombobox.model.getItem(supportExtruderCombobox.currentIndex).color
} }
} }
onCurrentIndexChanged: supportExtruderCombobox.color = supportExtruderCombobox.model.getItem(supportExtruderCombobox.currentIndex).color onCurrentIndexChanged:
{
var maybeColor = supportExtruderCombobox.model.getItem(supportExtruderCombobox.currentIndex).color
if(maybeColor)
{
supportExtruderCombobox.color = maybeColor
}
}
Binding Binding
{ {

View File

@ -7,9 +7,6 @@ import QtQuick.Controls 2.3
import UM 1.3 as UM import UM 1.3 as UM
import Cura 1.1 as Cura import Cura 1.1 as Cura
import "../PrinterSelector"
// //
// This is the widget for adding a network printer. There are 2 parts in this widget. One is a scroll view of a list // This is the widget for adding a network printer. There are 2 parts in this widget. One is a scroll view of a list
// of discovered network printers. Beneath the scroll view is a container with 3 buttons: "Refresh", "Add by IP", and // of discovered network printers. Beneath the scroll view is a container with 3 buttons: "Refresh", "Add by IP", and
@ -105,13 +102,11 @@ Item
} }
} }
delegate: MachineSelectorButton delegate: Cura.MachineSelectorButton
{ {
text: modelData.device.name text: modelData.device.name
anchors.left: parent.left width: networkPrinterListView.width
anchors.right: parent.right
anchors.rightMargin: UM.Theme.getSize("default_margin").width
outputDevice: modelData.device outputDevice: modelData.device
enabled: !modelData.isUnknownMachineType && modelData.isHostOfGroup enabled: !modelData.isUnknownMachineType && modelData.isHostOfGroup
@ -140,22 +135,23 @@ Item
} }
} }
// Horizontal line separating the buttons (below) and the discovered network printers (above)
Rectangle
{
id: separator
anchors.left: parent.left
anchors.top: networkPrinterInfo.bottom
anchors.right: parent.right
height: UM.Theme.getSize("default_lining").height
color: UM.Theme.getColor("lining")
}
Item Item
{ {
id: controlsRectangle id: controlsRectangle
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.top: networkPrinterInfo.bottom anchors.top: separator.bottom
// Horizontal line separating the buttons (below) and the discovered network printers (above)
Rectangle
{
anchors.left: parent.left
anchors.top: parent.top
anchors.right: parent.right
height: UM.Theme.getSize("default_lining").width
color: UM.Theme.getColor("lining")
}
height: UM.Theme.getSize("message_action_button").height + UM.Theme.getSize("default_margin").height height: UM.Theme.getSize("message_action_button").height + UM.Theme.getSize("default_margin").height

View File

@ -61,6 +61,7 @@ Item
anchors.top: parent.top anchors.top: parent.top
font: UM.Theme.getFont("default") font: UM.Theme.getFont("default")
renderType: Text.NativeRendering
text: catalog.i18nc("@label", "Enter the IP address or hostname of your printer on the network.") text: catalog.i18nc("@label", "Enter the IP address or hostname of your printer on the network.")
} }
@ -106,17 +107,7 @@ Item
UM.OutputDeviceManager.addManualDevice(hostnameField.text, hostnameField.text); UM.OutputDeviceManager.addManualDevice(hostnameField.text, hostnameField.text);
} }
} }
busy: !enabled && !addPrinterByIpScreen.hasSentRequest && !addPrinterByIpScreen.haveConnection
BusyIndicator
{
anchors.fill: parent
running:
{
! parent.enabled &&
! addPrinterByIpScreen.hasSentRequest &&
! addPrinterByIpScreen.haveConnection
}
}
Connections Connections
{ {
@ -138,6 +129,7 @@ Item
anchors.top: parent.top anchors.top: parent.top
anchors.margins: UM.Theme.getSize("default_margin").width anchors.margins: UM.Theme.getSize("default_margin").width
font: UM.Theme.getFont("default") font: UM.Theme.getFont("default")
renderType: Text.NativeRendering
visible: visible:
{ {
@ -170,6 +162,7 @@ Item
id: printerNameLabel id: printerNameLabel
anchors.top: parent.top anchors.top: parent.top
font: UM.Theme.getFont("large") font: UM.Theme.getFont("large")
renderType: Text.NativeRendering
text: "???" text: "???"
} }
@ -182,14 +175,14 @@ Item
columns: 2 columns: 2
columnSpacing: UM.Theme.getSize("default_margin").width columnSpacing: UM.Theme.getSize("default_margin").width
Label { font: UM.Theme.getFont("default"); text: catalog.i18nc("@label", "Type") } Label { font: UM.Theme.getFont("default"); text: catalog.i18nc("@label", "Type"); renderType: Text.NativeRendering }
Label { id: typeText; font: UM.Theme.getFont("default"); text: "?" } Label { id: typeText; font: UM.Theme.getFont("default"); text: "?"; renderType: Text.NativeRendering }
Label { font: UM.Theme.getFont("default"); text: catalog.i18nc("@label", "Firmware version") } Label { font: UM.Theme.getFont("default"); text: catalog.i18nc("@label", "Firmware version"); renderType: Text.NativeRendering }
Label { id: firmwareText; font: UM.Theme.getFont("default"); text: "0.0.0.0" } Label { id: firmwareText; font: UM.Theme.getFont("default"); text: "0.0.0.0"; renderType: Text.NativeRendering }
Label { font: UM.Theme.getFont("default"); text: catalog.i18nc("@label", "Address") } Label { font: UM.Theme.getFont("default"); text: catalog.i18nc("@label", "Address"); renderType: Text.NativeRendering }
Label { id: addressText; font: UM.Theme.getFont("default"); text: "0.0.0.0" } Label { id: addressText; font: UM.Theme.getFont("default"); text: "0.0.0.0"; renderType: Text.NativeRendering }
Connections Connections
{ {

View File

@ -1,6 +1,7 @@
module Cura module Cura
MachineSelector 1.0 MachineSelector.qml MachineSelector 1.0 MachineSelector.qml
MachineSelectorButton 1.0 MachineSelectorButton.qml
CustomConfigurationSelector 1.0 CustomConfigurationSelector.qml CustomConfigurationSelector 1.0 CustomConfigurationSelector.qml
PrintSetupSelector 1.0 PrintSetupSelector.qml PrintSetupSelector 1.0 PrintSetupSelector.qml
ActionButton 1.0 ActionButton.qml ActionButton 1.0 ActionButton.qml