Merge branch 'master' into cloud-output-device

This commit is contained in:
ChrisTerBeke 2018-11-23 14:17:26 +01:00
commit 1adf1096a3
38 changed files with 1062 additions and 286 deletions

View file

@ -13,6 +13,6 @@ TryExec=@CMAKE_INSTALL_FULL_BINDIR@/cura
Icon=cura-icon Icon=cura-icon
Terminal=false Terminal=false
Type=Application Type=Application
MimeType=model/stl;application/vnd.ms-3mfdocument;application/prs.wavefront-obj;image/bmp;image/gif;image/jpeg;image/png;model/x3d+xml; MimeType=model/stl;application/vnd.ms-3mfdocument;application/prs.wavefront-obj;image/bmp;image/gif;image/jpeg;image/png;model/x3d+xml;text/x-gcode;
Categories=Graphics; Categories=Graphics;
Keywords=3D;Printing;Slicer; Keywords=3D;Printing;Slicer;

View file

@ -19,4 +19,12 @@
<glob-deleteall/> <glob-deleteall/>
<glob pattern="*.obj"/> <glob pattern="*.obj"/>
</mime-type> </mime-type>
<mime-type type="text/x-gcode">
<sub-class-of type="text/plain"/>
<comment>Gcode file</comment>
<icon name="unknown"/>
<glob-deleteall/>
<glob pattern="*.gcode"/>
<glob pattern="*.g"/>
</mime-type>
</mime-info> </mime-info>

View file

@ -38,13 +38,12 @@ class Account(QObject):
self._callback_port = 32118 self._callback_port = 32118
self._oauth_root = "https://account.ultimaker.com" self._oauth_root = "https://account.ultimaker.com"
self._cloud_api_root = "https://api.ultimaker.com"
self._oauth_settings = OAuth2Settings( self._oauth_settings = OAuth2Settings(
OAUTH_SERVER_URL= self._oauth_root, OAUTH_SERVER_URL= self._oauth_root,
CALLBACK_PORT=self._callback_port, CALLBACK_PORT=self._callback_port,
CALLBACK_URL="http://localhost:{}/callback".format(self._callback_port), CALLBACK_URL="http://localhost:{}/callback".format(self._callback_port),
CLIENT_ID="um---------------ultimaker_cura_drive_plugin", CLIENT_ID="um----------------------------ultimaker_cura",
CLIENT_SCOPES="account.user.read drive.backup.read drive.backup.write packages.download packages.rating.read packages.rating.write", CLIENT_SCOPES="account.user.read drive.backup.read drive.backup.write packages.download packages.rating.read packages.rating.write",
AUTH_DATA_PREFERENCE_KEY="general/ultimaker_auth_data", AUTH_DATA_PREFERENCE_KEY="general/ultimaker_auth_data",
AUTH_SUCCESS_REDIRECT="{}/app/auth-success".format(self._oauth_root), AUTH_SUCCESS_REDIRECT="{}/app/auth-success".format(self._oauth_root),

View file

@ -6,127 +6,213 @@ import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4 import QtQuick.Controls.Styles 1.4
import UM 1.3 as UM import UM 1.3 as UM
import Cura 1.0 as Cura import Cura 1.0 as Cura
import QtGraphicalEffects 1.0
Component { Component
Rectangle { {
id: monitorFrame; Rectangle
property var emphasisColor: UM.Theme.getColor("setting_control_border_highlight"); {
property var cornerRadius: UM.Theme.getSize("monitor_corner_radius").width; id: monitorFrame
color: UM.Theme.getColor("viewport_background");
height: maximumHeight; property var emphasisColor: UM.Theme.getColor("setting_control_border_highlight")
onVisibleChanged: { property var cornerRadius: UM.Theme.getSize("monitor_corner_radius").width
if (monitorFrame != null && !monitorFrame.visible) {
OutputDevice.setActiveCameraUrl(""); color: "transparent"
height: maximumHeight
onVisibleChanged:
{
if (monitorFrame != null && !monitorFrame.visible)
{
OutputDevice.setActiveCameraUrl("")
} }
} }
width: maximumWidth; width: maximumWidth
UM.I18nCatalog { UM.I18nCatalog
id: catalog; {
name: "cura"; id: catalog
name: "cura"
} }
Label { LinearGradient {
id: manageQueueLabel; anchors.fill: parent
anchors { gradient: Gradient {
bottom: queuedLabel.bottom; GradientStop {
right: queuedPrintJobs.right; position: 0.0
rightMargin: 3 * UM.Theme.getSize("default_margin").width; color: "#f6f6f6"
}
color: UM.Theme.getColor("primary");
font: UM.Theme.getFont("default");
linkColor: UM.Theme.getColor("primary");
text: catalog.i18nc("@label link to connect manager", "Manage queue");
}
MouseArea {
anchors.fill: manageQueueLabel;
hoverEnabled: true;
onClicked: Cura.MachineManager.printerOutputDevices[0].openPrintJobControlPanel();
onEntered: manageQueueLabel.font.underline = true;
onExited: manageQueueLabel.font.underline = false;
}
Label {
id: queuedLabel;
anchors {
left: queuedPrintJobs.left;
leftMargin: 3 * UM.Theme.getSize("default_margin").width + 5 * screenScaleFactor;
top: parent.top;
topMargin: 2 * UM.Theme.getSize("default_margin").height;
}
color: UM.Theme.getColor("text");
font: UM.Theme.getFont("large");
text: catalog.i18nc("@label", "Queued");
}
Column {
id: skeletonLoader;
anchors {
bottom: parent.bottom;
bottomMargin: UM.Theme.getSize("default_margin").height;
horizontalCenter: parent.horizontalCenter;
top: queuedLabel.bottom;
topMargin: UM.Theme.getSize("default_margin").height;
}
visible: !queuedPrintJobs.visible;
width: Math.min(800 * screenScaleFactor, maximumWidth);
PrintJobInfoBlock {
anchors {
left: parent.left;
leftMargin: UM.Theme.getSize("default_margin").width;
right: parent.right;
rightMargin: UM.Theme.getSize("default_margin").width;
} }
printJob: null; // Use as skeleton GradientStop {
} position: 1.0
color: "#ffffff"
PrintJobInfoBlock {
anchors {
left: parent.left;
leftMargin: UM.Theme.getSize("default_margin").width;
right: parent.right;
rightMargin: UM.Theme.getSize("default_margin").width;
} }
printJob: null; // Use as skeleton
} }
} }
ScrollView { Item
id: queuedPrintJobs; {
anchors { id: queue
top: queuedLabel.bottom;
topMargin: UM.Theme.getSize("default_margin").height;
horizontalCenter: parent.horizontalCenter;
bottomMargin: UM.Theme.getSize("default_margin").height;
bottom: parent.bottom;
}
style: UM.Theme.styles.scrollview;
visible: OutputDevice.receivedPrintJobs;
width: Math.min(800 * screenScaleFactor, maximumWidth);
ListView { anchors.fill: parent
id: printJobList; anchors.top: parent.top
anchors.fill: parent; anchors.topMargin: 400 * screenScaleFactor // TODO: Insert carousel here
delegate: PrintJobInfoBlock {
anchors { Label
left: parent.left; {
leftMargin: UM.Theme.getSize("default_margin").width; id: queuedLabel
right: parent.right; anchors
rightMargin: UM.Theme.getSize("default_margin").width; {
left: queuedPrintJobs.left
top: parent.top
}
color: UM.Theme.getColor("text")
font: UM.Theme.getFont("large_nonbold")
text: catalog.i18nc("@label", "Queued")
}
Item
{
id: manageQueueLabel
anchors
{
right: queuedPrintJobs.right
verticalCenter: queuedLabel.verticalCenter
}
height: 18 * screenScaleFactor // TODO: Theme!
width: childrenRect.width
UM.RecolorImage
{
id: externalLinkIcon
anchors.verticalCenter: manageQueueLabel.verticalCenter
color: UM.Theme.getColor("primary")
source: "../svg/icons/external_link.svg"
width: 16 * screenScaleFactor // TODO: Theme! (Y U NO USE 18 LIKE ALL OTHER ICONS?!)
height: 16 * screenScaleFactor // TODO: Theme! (Y U NO USE 18 LIKE ALL OTHER ICONS?!)
}
Label
{
id: manageQueueText
anchors
{
left: externalLinkIcon.right
leftMargin: 6 * screenScaleFactor // TODO: Theme!
verticalCenter: externalLinkIcon.verticalCenter
} }
printJob: modelData; color: UM.Theme.getColor("primary")
font: UM.Theme.getFont("default")
linkColor: UM.Theme.getColor("primary")
text: catalog.i18nc("@label link to connect manager", "Manage queue in Cura Connect")
}
}
MouseArea
{
anchors.fill: manageQueueLabel
hoverEnabled: true
onClicked: Cura.MachineManager.printerOutputDevices[0].openPrintJobControlPanel()
onEntered:
{
manageQueueText.font.underline = true
}
onExited:
{
manageQueueText.font.underline = false
}
}
Row
{
id: printJobQueueHeadings
anchors
{
left: queuedPrintJobs.left
leftMargin: 6 * screenScaleFactor // TODO: Theme!
top: queuedLabel.bottom
topMargin: 24 * screenScaleFactor // TODO: Theme!
}
spacing: 18 * screenScaleFactor // TODO: Theme!
Label
{
text: catalog.i18nc("@label", "Print jobs")
color: "#666666"
elide: Text.ElideRight
font: UM.Theme.getFont("medium") // 14pt, regular
anchors.verticalCenter: parent.verticalCenter
width: 284 * screenScaleFactor // TODO: Theme! (Should match column size)
// FIXED-LINE-HEIGHT:
height: 18 * screenScaleFactor // TODO: Theme!
verticalAlignment: Text.AlignVCenter
}
Label
{
text: catalog.i18nc("@label", "Total print time")
color: "#666666"
elide: Text.ElideRight
font: UM.Theme.getFont("medium") // 14pt, regular
anchors.verticalCenter: parent.verticalCenter
width: 216 * screenScaleFactor // TODO: Theme! (Should match column size)
// FIXED-LINE-HEIGHT:
height: 18 * screenScaleFactor // TODO: Theme!
verticalAlignment: Text.AlignVCenter
}
Label
{
text: catalog.i18nc("@label", "Waiting for")
color: "#666666"
elide: Text.ElideRight
font: UM.Theme.getFont("medium") // 14pt, regular
anchors.verticalCenter: parent.verticalCenter
width: 216 * screenScaleFactor // TODO: Theme! (Should match column size)
// FIXED-LINE-HEIGHT:
height: 18 * screenScaleFactor // TODO: Theme!
verticalAlignment: Text.AlignVCenter
}
}
ScrollView
{
id: queuedPrintJobs
anchors {
bottom: parent.bottom
horizontalCenter: parent.horizontalCenter
top: printJobQueueHeadings.bottom
topMargin: 12 * screenScaleFactor // TODO: Theme!
}
style: UM.Theme.styles.scrollview
visible: OutputDevice.receivedPrintJobs
width: Math.min(834 * screenScaleFactor, maximumWidth)
ListView
{
id: printJobList
anchors.fill: parent
delegate: MonitorPrintJobCard
{
anchors
{
left: parent.left
right: parent.right
}
printJob: modelData
}
model: OutputDevice.queuedPrintJobs
spacing: 6
} }
model: OutputDevice.queuedPrintJobs;
spacing: UM.Theme.getSize("default_margin").height - 2 * UM.Theme.getSize("monitor_shadow_radius").width;
} }
} }
PrinterVideoStream { PrinterVideoStream {
anchors.fill: parent; anchors.fill: parent
cameraUrl: OutputDevice.activeCameraUrl; cameraUrl: OutputDevice.activeCameraUrl
visible: OutputDevice.activeCameraUrl != ""; visible: OutputDevice.activeCameraUrl != ""
} }
} }
} }

View file

@ -0,0 +1,82 @@
// Copyright (c) 2018 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.2
import QtQuick.Controls 2.0
import UM 1.3 as UM
import Cura 1.0 as Cura
// TODO: Theme & documentation!
// The expandable component has 3 major sub components:
// * The headerItem Always visible and should hold some info about what happens if the component is expanded
// * The popupItem The content that needs to be shown if the component is expanded.
Item
{
id: base
property bool expanded: false
property var borderWidth: 1
property color borderColor: "#EAEAEC"
property color headerBackgroundColor: "white"
property color headerHoverColor: "#f5f5f5"
property color drawerBackgroundColor: "white"
property alias headerItem: header.children
property alias drawerItem: drawer.children
width: parent.width
height: childrenRect.height
Rectangle
{
id: header
border
{
color: borderColor
width: borderWidth
}
color: headerMouseArea.containsMouse ? headerHoverColor : headerBackgroundColor
height: childrenRect.height
width: parent.width
Behavior on color
{
ColorAnimation
{
duration: 100
}
}
}
MouseArea
{
id: headerMouseArea
anchors.fill: header
onClicked: base.expanded = !base.expanded
hoverEnabled: true
}
Rectangle
{
id: drawer
anchors
{
top: header.bottom
topMargin: -1
}
border
{
color: borderColor
width: borderWidth
}
clip: true
color: headerBackgroundColor
height: base.expanded ? childrenRect.height : 0
width: parent.width
Behavior on height
{
NumberAnimation
{
duration: 100
}
}
}
}

View file

@ -0,0 +1,63 @@
// Copyright (c) 2018 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.2
import QtQuick.Controls 2.0
import UM 1.3 as UM
/**
* This component comprises a buildplate icon and the buildplate name. It is
* used by the MonitorPrinterConfiguration component along with two instances
* of MonitorExtruderConfiguration.
*
* NOTE: For most labels, a fixed height with vertical alignment is used to make
* layouts more deterministic (like the fixed-size textboxes used in original
* mock-ups). This is also a stand-in for CSS's 'line-height' property. Denoted
* with '// FIXED-LINE-HEIGHT:'.
*/
Item
{
// The buildplate name
property alias buildplate: buildplateLabel.text
// Height is one 18px label/icon
height: 18 * screenScaleFactor // TODO: Theme!
width: childrenRect.width
Row
{
height: parent.height
spacing: 12 * screenScaleFactor // TODO: Theme! (Should be same as extruder spacing)
// This wrapper ensures that the buildplate icon is located centered
// below an extruder icon.
Item
{
height: parent.height
width: 32 * screenScaleFactor // TODO: Theme! (Should be same as extruder icon width)
UM.RecolorImage
{
id: buildplateIcon
anchors.centerIn: parent
color: "#0a0850" // TODO: Theme! (Standard purple)
height: parent.height
source: "../svg/icons/buildplate.svg"
width: height
}
}
Label
{
id: buildplateLabel
color: "#191919" // TODO: Theme!
elide: Text.ElideRight
font: UM.Theme.getFont("very_small") // 12pt, regular
text: ""
// FIXED-LINE-HEIGHT:
height: 18 * screenScaleFactor // TODO: Theme!
verticalAlignment: Text.AlignVCenter
}
}
}

View file

@ -0,0 +1,76 @@
// Copyright (c) 2018 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.2
import QtQuick.Controls 2.0
import UM 1.3 as UM
/**
* This component comprises a colored extruder icon, the material name, and the
* print core name. It is used by the MonitorPrinterConfiguration component with
* a sibling instance as well as a MonitorBuildplateConfiguration instance.
*
* NOTE: For most labels, a fixed height with vertical alignment is used to make
* layouts more deterministic (like the fixed-size textboxes used in original
* mock-ups). This is also a stand-in for CSS's 'line-height' property. Denoted
* with '// FIXED-LINE-HEIGHT:'.
*/
Item
{
// The material color
property alias color: extruderIcon.color
// The extruder position; NOTE: Decent human beings count from 0
property alias position: extruderIcon.position
// The material name
property alias material: materialLabel.text
// The print core name (referred to as hotendID in Python)
property alias printCore: printCoreLabel.text
// Height is 2 x 18px labels, plus 4px spacing between them
height: 40 * screenScaleFactor // TODO: Theme!
width: childrenRect.width
MonitorIconExtruder
{
id: extruderIcon
color: "#eeeeee" // TODO: Theme!
position: 0
}
Label
{
id: materialLabel
anchors
{
left: extruderIcon.right
leftMargin: 12 * screenScaleFactor // TODO: Theme!
}
color: "#191919" // TODO: Theme!
elide: Text.ElideRight
font: UM.Theme.getFont("very_small") // 12pt, regular
text: ""
// FIXED-LINE-HEIGHT:
height: 18 * screenScaleFactor // TODO: Theme!
verticalAlignment: Text.AlignVCenter
}
Label
{
id: printCoreLabel
anchors
{
left: materialLabel.left
bottom: parent.bottom
}
color: "#191919" // TODO: Theme!
elide: Text.ElideRight
font: UM.Theme.getFont("small") // 12pt, bold
text: ""
// FIXED-LINE-HEIGHT:
height: 18 * screenScaleFactor // TODO: Theme!
verticalAlignment: Text.AlignVCenter
}
}

View file

@ -0,0 +1,60 @@
// Copyright (c) 2018 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.2
import QtQuick.Controls 2.0
import UM 1.3 as UM
/**
* This component is a sort of "super icon" which includes a colored SVG image
* as well as the extruder position number. It is used in the the
* MonitorExtruderConfiguration component.
*/
Item
{
// The material color
property alias color: icon.color
// The extruder position; NOTE: Decent human beings count from 0
property int position: 0
// The extruder icon size; NOTE: This shouldn't need to be changed
property int size: 32 // TODO: Theme!
// THe extruder icon source; NOTE: This shouldn't need to be changed
property string iconSource: "../svg/icons/extruder.svg"
height: size
width: size
UM.RecolorImage
{
id: icon
anchors.fill: parent
source: iconSource
width: size
}
/*
* The label uses some "fancy" math to ensure that if you change the overall
* icon size, the number scales with it. That is to say, the font properties
* are linked to the icon size, NOT the theme. And that's intentional.
*/
Label
{
id: positionLabel
font
{
pointSize: Math.round(size * 0.3125)
weight: Font.Bold
}
height: Math.round(size / 2) * screenScaleFactor
horizontalAlignment: Text.AlignHCenter
text: position + 1
verticalAlignment: Text.AlignVCenter
width: Math.round(size / 2) * screenScaleFactor
x: Math.round(size * 0.25) * screenScaleFactor
y: Math.round(size * 0.15625) * screenScaleFactor
// TODO: Once 'size' is themed, screenScaleFactor won't be needed
}
}

View file

@ -0,0 +1,179 @@
// Copyright (c) 2018 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.2
import QtQuick.Controls 2.0
import UM 1.3 as UM
/**
* A Print Job Card is essentially just a filled-in Expandable Card item. All
* data within it is derived from being passed a printJob property.
*
* NOTE: For most labels, a fixed height with vertical alignment is used to make
* layouts more deterministic (like the fixed-size textboxes used in original
* mock-ups). This is also a stand-in for CSS's 'line-height' property. Denoted
* with '// FIXED-LINE-HEIGHT:'.
*/
Item
{
id: base
// The print job which all other data is derived from
property var printJob: null
width: parent.width
height: childrenRect.height
ExpandableCard
{
headerItem: Row
{
height: 48 * screenScaleFactor // TODO: Theme!
anchors.left: parent.left
anchors.leftMargin: 24 * screenScaleFactor // TODO: Theme!
spacing: 18 * screenScaleFactor // TODO: Theme!
MonitorPrintJobPreview
{
printJob: base.printJob
size: 32 * screenScaleFactor // TODO: Theme!
anchors.verticalCenter: parent.verticalCenter
}
Label
{
text: printJob && printJob.name ? printJob.name : ""
color: "#374355"
elide: Text.ElideRight
font: UM.Theme.getFont("medium") // 14pt, regular
anchors.verticalCenter: parent.verticalCenter
width: 216 * screenScaleFactor // TODO: Theme! (Should match column size)
// FIXED-LINE-HEIGHT:
height: 18 * screenScaleFactor // TODO: Theme!
verticalAlignment: Text.AlignVCenter
}
Label
{
text: printJob ? OutputDevice.formatDuration(printJob.timeTotal) : ""
color: "#374355"
elide: Text.ElideRight
font: UM.Theme.getFont("medium") // 14pt, regular
anchors.verticalCenter: parent.verticalCenter
width: 216 * screenScaleFactor // TODO: Theme! (Should match column size)
// FIXED-LINE-HEIGHT:
height: 18 * screenScaleFactor // TODO: Theme!
verticalAlignment: Text.AlignVCenter
}
Item
{
anchors.verticalCenter: parent.verticalCenter
height: 18 * screenScaleFactor // TODO: This should be childrenRect.height but QML throws warnings
width: childrenRect.width
Label
{
id: printerAssignmentLabel
anchors.verticalCenter: parent.verticalCenter
color: "#374355"
elide: Text.ElideRight
font: UM.Theme.getFont("medium") // 14pt, regular
text: {
if (printJob !== null) {
if (printJob.assignedPrinter == null)
{
if (printJob.state == "error")
{
return catalog.i18nc("@label", "Unavailable printer")
}
return catalog.i18nc("@label", "First available")
}
return printJob.assignedPrinter.name
}
return ""
}
visible: printJob
// FIXED-LINE-HEIGHT:
height: 18 * screenScaleFactor // TODO: Theme!
verticalAlignment: Text.AlignVCenter
}
Row
{
id: printerFamilyPills
anchors
{
left: printerAssignmentLabel.right;
leftMargin: 12 // TODO: Theme!
verticalCenter: parent.verticalCenter
}
height: childrenRect.height
spacing: 6 // TODO: Theme!
Repeater
{
id: compatiblePills
delegate: MonitorPrinterPill
{
text: modelData
}
model: printJob ? printJob.compatibleMachineFamilies : []
}
}
}
}
drawerItem: Row
{
anchors
{
left: parent.left
leftMargin: 74 * screenScaleFactor // TODO: Theme!
}
height: 108 * screenScaleFactor // TODO: Theme!
spacing: 18 * screenScaleFactor // TODO: Theme!
MonitorPrinterConfiguration
{
id: printerConfiguration
anchors.verticalCenter: parent.verticalCenter
buildplate: "Glass"
configurations:
[
base.printJob.configuration.extruderConfigurations[0],
base.printJob.configuration.extruderConfigurations[1]
]
height: 72 * screenScaleFactor // TODO: Theme!
}
Label {
text: printJob && printJob.owner ? printJob.owner : ""
color: "#374355" // TODO: Theme!
elide: Text.ElideRight
font: UM.Theme.getFont("medium") // 14pt, regular
anchors.top: printerConfiguration.top
// FIXED-LINE-HEIGHT:
height: 18 * screenScaleFactor // TODO: Theme!
verticalAlignment: Text.AlignVCenter
}
}
}
PrintJobContextMenu
{
id: contextButton
anchors
{
right: parent.right;
rightMargin: 8 * screenScaleFactor // TODO: Theme!
top: parent.top
topMargin: 8 * screenScaleFactor // TODO: Theme!
}
printJob: base.printJob
width: 32 * screenScaleFactor // TODO: Theme!
height: 32 * screenScaleFactor // TODO: Theme!
}
}

View file

@ -0,0 +1,63 @@
// Copyright (c) 2018 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.2
import QtQuick.Controls 2.0
import UM 1.3 as UM
// TODO: Documentation!
Item
{
id: printJobPreview
property var printJob: null
property var size: 256
width: size
height: size
// Actual content
Image
{
id: previewImage
anchors.fill: parent
opacity: printJob && printJob.state == "error" ? 0.5 : 1.0
source: printJob ? printJob.previewImageUrl : ""
visible: printJob
}
UM.RecolorImage
{
id: ultiBotImage
anchors.centerIn: printJobPreview
color: UM.Theme.getColor("monitor_placeholder_image")
height: printJobPreview.height
source: "../svg/ultibot.svg"
sourceSize
{
height: height
width: width
}
/* Since print jobs ALWAYS have an image url, we have to check if that image URL errors or
not in order to determine if we show the placeholder (ultibot) image instead. */
visible: printJob && previewImage.status == Image.Error
width: printJobPreview.width
}
UM.RecolorImage
{
id: statusImage
anchors.centerIn: printJobPreview
color: UM.Theme.getColor("monitor_image_overlay")
height: 0.5 * printJobPreview.height
source: printJob && printJob.state == "error" ? "../svg/aborted-icon.svg" : ""
sourceSize
{
height: height
width: width
}
visible: source != ""
width: 0.5 * printJobPreview.width
}
}

View file

@ -0,0 +1,58 @@
// Copyright (c) 2018 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.2
import QtQuick.Controls 2.0
import UM 1.3 as UM
/**
* The MonitorPrinterConfiguration accepts 2 configuration objects as input and
* applies them to a MonitorBuildplateConfiguration instance and two instances
* of MonitorExtruderConfiguration. It's used in both the MonitorPrintJobCard
* component as well as the MonitorPrinterCard component.
*/
Item
{
id: base
// Extracted buildplate configuration
property alias buildplate: buildplateConfig.buildplate
// Array of extracted extruder configurations
property var configurations: null
// Default size, but should be stretched to fill parent
height: 72 * parent.height
width: 450 * screenScaleFactor // TODO: Theme!
Row
{
id: extruderConfigurationRow
spacing: 18 * screenScaleFactor // TODO: Theme!
Repeater
{
id: extruderConfigurationRepeater
model: configurations
MonitorExtruderConfiguration
{
color: modelData.activeMaterial ? modelData.activeMaterial.color : "#eeeeee" // TODO: Theme!
material: modelData.activeMaterial ? modelData.activeMaterial.name : ""
position: modelData.position
printCore: modelData.hotendID
// Keep things responsive!
width: Math.floor((base.width - (configurations.length - 1) * extruderConfigurationRow.spacing) / configurations.length)
}
}
}
MonitorBuildplateConfiguration
{
id: buildplateConfig
anchors.bottom: parent.bottom
buildplate: "Glass" // 'Glass' as a default
}
}

View file

@ -0,0 +1,34 @@
// 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.4
import UM 1.2 as UM
/**
* A MonitorPrinterPill is a blue-colored tag indicating which printers a print
* job is compatible with. It is used by the MonitorPrintJobCard component.
*/
Item
{
// The printer name
property alias text: printerNameLabel.text;
implicitHeight: 18 * screenScaleFactor // TODO: Theme!
implicitWidth: printerNameLabel.contentWidth + 12 // TODO: Theme!
Rectangle {
id: background
anchors.fill: parent
color: "#e4e4f2" // TODO: Theme!
radius: 2 * screenScaleFactor // TODO: Theme!
}
Label {
id: printerNameLabel
anchors.centerIn: parent
color: "#535369" // TODO: Theme!
text: ""
font.pointSize: 10
}
}

View file

@ -0,0 +1,5 @@
<svg width="18px" height="18px" viewBox="0 0 18 18" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<path d="M18,5 L18,6 L9,10 L0,6 L0,5 L9,1 L18,5 Z M18,8.18863507 L9,12.1886351 L0,8.18863507 L0,7.09431753 L9,11.0943175 L18,7.09431753 L18,8.18863507 Z M18,10.3772701 L9,14.3772701 L0,10.3772701 L0,9.2829526 L9,13.2829526 L18,9.2829526 L18,10.3772701 Z M18,12.5659052 L9,16.5659052 L0,12.5659052 L0,11.4715877 L9,15.4715877 L18,11.4715877 L18,12.5659052 Z" id="Combined-Shape" fill="#D10000" fill-rule="nonzero"></path>
</g>
</svg>

After

Width:  |  Height:  |  Size: 672 B

View file

@ -0,0 +1,8 @@
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="External-site" fill="#2671E7">
<path d="M15.2542746,0 L10.117115,0 C9.70521103,0 9.37138968,0.331077601 9.37138968,0.7395961 C9.37138968,1.1481146 9.70521103,1.4791922 10.117115,1.4791922 L13.5368139,1.4791922 L6.21853299,8.73732261 C5.92715567,9.02612743 5.92715567,9.49450277 6.21853299,9.78330758 C6.36413212,9.92770999 6.55504068,10 6.74577014,10 C6.93649962,10 7.12740818,9.92770999 7.2730073,9.78330758 L14.5085492,2.60705849 L14.5085492,5.83435463 C14.5085492,6.24287313 14.8423706,6.57395074 15.2542746,6.57395074 C15.6661786,6.57395074 16,6.24287313 16,5.83435463 L16,0.7395961 C16,0.331077601 15.6661786,0 15.2542746,0 Z" id="Path"></path>
<path d="M12.2810964,7.69220962 C11.8840075,7.69220962 11.5621929,8.01402427 11.5621929,8.41111317 L11.5621929,14.0829238 C11.5621929,14.3427581 11.3427581,14.5621929 11.0829238,14.5621929 L1.91707615,14.5621929 C1.65724189,14.5621929 1.43780712,14.3427581 1.43780712,14.0829238 L1.43780712,4.91707615 C1.43780712,4.65724189 1.65724189,4.43780712 1.91707615,4.43780712 L7.60891391,4.43780712 C8.00600281,4.43780712 8.32781747,4.11599245 8.32781747,3.71890356 C8.32781747,3.32181465 8.00600281,3 7.60891391,3 L1.91707615,3 C0.859956439,3 0,3.85995644 0,4.91707615 L0,14.0829238 C0,15.1400436 0.859956439,16 1.91707615,16 L11.0829238,16 C12.1400436,16 13,15.1400436 13,14.0829238 L13,8.41111317 C13,8.01419692 12.6781853,7.69220962 12.2810964,7.69220962 Z" id="Path"></path>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

View file

@ -0,0 +1,5 @@
<svg width="32px" height="32px" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<path d="M24,24 L16,32 L8,24 L2,24 C0.8954305,24 1.3527075e-16,23.1045695 0,22 L0,2 C-1.3527075e-16,0.8954305 0.8954305,2.02906125e-16 2,0 L30,0 C31.1045695,-2.02906125e-16 32,0.8954305 32,2 L32,22 C32,23.1045695 31.1045695,24 30,24 L24,24 Z M16,21 C20.418278,21 24,17.418278 24,13 C24,8.581722 20.418278,5 16,5 C11.581722,5 8,8.581722 8,13 C8,17.418278 11.581722,21 16,21 Z" id="Combined-Shape" fill="#D8D8D8" fill-rule="nonzero"></path>
</g>
</svg>

After

Width:  |  Height:  |  Size: 690 B

View file

@ -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. # Cura is released under the terms of the LGPLv3 or higher.
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
@ -334,13 +334,12 @@ class UM3OutputDevicePlugin(OutputDevicePlugin):
## Handler for zeroConf detection. ## Handler for zeroConf detection.
# Return True or False indicating if the process succeeded. # Return True or False indicating if the process succeeded.
# Note that this function can take over 3 seconds to complete. Be carefull calling it from the main thread. # Note that this function can take over 3 seconds to complete. Be careful
# calling it from the main thread.
def _onServiceChanged(self, zero_conf, service_type, name, state_change): def _onServiceChanged(self, zero_conf, service_type, name, state_change):
if state_change == ServiceStateChange.Added: if state_change == ServiceStateChange.Added:
Logger.log("d", "Bonjour service added: %s" % name)
# First try getting info from zero-conf cache # First try getting info from zero-conf cache
info = ServiceInfo(service_type, name, properties={}) info = ServiceInfo(service_type, name, properties = {})
for record in zero_conf.cache.entries_with_name(name.lower()): for record in zero_conf.cache.entries_with_name(name.lower()):
info.update_record(zero_conf, time(), record) info.update_record(zero_conf, time(), record)

View file

@ -1,14 +1,16 @@
# Copyright (c) 2016 Ultimaker B.V. # Copyright (c) 2018 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.
import UM.VersionUpgrade #To indicate that a file is of incorrect format.
import UM.VersionUpgradeManager #To schedule more files to be upgraded.
from UM.Resources import Resources #To get the config storage path.
import configparser #To read config files. import configparser #To read config files.
import io #To write config files to strings as if they were files. import io #To write config files to strings as if they were files.
import os.path #To get the path to write new user profiles to. import os.path #To get the path to write new user profiles to.
from typing import Dict, List, Optional, Set, Tuple
import urllib #To serialise the user container file name properly. import urllib #To serialise the user container file name properly.
import urllib.parse
import UM.VersionUpgrade #To indicate that a file is of incorrect format.
import UM.VersionUpgradeManager #To schedule more files to be upgraded.
from UM.Resources import Resources #To get the config storage path.
## Creates a new machine instance instance by parsing a serialised machine ## Creates a new machine instance instance by parsing a serialised machine
# instance in version 1 of the file format. # instance in version 1 of the file format.
@ -18,7 +20,7 @@ import urllib #To serialise the user container file name properly.
# extension. # extension.
# \return A machine instance instance, or None if the file format is # \return A machine instance instance, or None if the file format is
# incorrect. # incorrect.
def importFrom(serialised, filename): def importFrom(serialised: str, filename: str) -> Optional["MachineInstance"]:
try: try:
return MachineInstance(serialised, filename) return MachineInstance(serialised, filename)
except (configparser.Error, UM.VersionUpgrade.FormatException, UM.VersionUpgrade.InvalidVersionException): except (configparser.Error, UM.VersionUpgrade.FormatException, UM.VersionUpgrade.InvalidVersionException):
@ -32,7 +34,7 @@ class MachineInstance:
# \param serialised A string with the contents of a machine instance file, # \param serialised A string with the contents of a machine instance file,
# without extension. # without extension.
# \param filename The supposed file name of this machine instance. # \param filename The supposed file name of this machine instance.
def __init__(self, serialised, filename): def __init__(self, serialised: str, filename: str) -> None:
self._filename = filename self._filename = filename
config = configparser.ConfigParser(interpolation = None) config = configparser.ConfigParser(interpolation = None)
@ -53,11 +55,11 @@ class MachineInstance:
self._type_name = config.get("general", "type") self._type_name = config.get("general", "type")
self._variant_name = config.get("general", "variant", fallback = "empty_variant") self._variant_name = config.get("general", "variant", fallback = "empty_variant")
self._name = config.get("general", "name", fallback = "") self._name = config.get("general", "name", fallback = "")
self._key = config.get("general", "key", fallback = None) self._key = config.get("general", "key", fallback = "")
self._active_profile_name = config.get("general", "active_profile", fallback = "empty_quality") self._active_profile_name = config.get("general", "active_profile", fallback = "empty_quality")
self._active_material_name = config.get("general", "material", fallback = "empty_material") self._active_material_name = config.get("general", "material", fallback = "empty_material")
self._machine_setting_overrides = {} self._machine_setting_overrides = {} # type: Dict[str, str]
for key, value in config["machine_settings"].items(): for key, value in config["machine_settings"].items():
self._machine_setting_overrides[key] = value self._machine_setting_overrides[key] = value
@ -67,7 +69,7 @@ class MachineInstance:
# #
# \return A tuple containing the new filename and a serialised form of # \return A tuple containing the new filename and a serialised form of
# this machine instance, serialised in version 2 of the file format. # this machine instance, serialised in version 2 of the file format.
def export(self): def export(self) -> Tuple[List[str], List[str]]:
config = configparser.ConfigParser(interpolation = None) # Build a config file in the form of version 2. config = configparser.ConfigParser(interpolation = None) # Build a config file in the form of version 2.
config.add_section("general") config.add_section("general")
@ -108,7 +110,7 @@ class MachineInstance:
version_upgrade_manager = UM.VersionUpgradeManager.VersionUpgradeManager.getInstance() version_upgrade_manager = UM.VersionUpgradeManager.VersionUpgradeManager.getInstance()
user_version_to_paths_dict = version_upgrade_manager.getStoragePaths("user") user_version_to_paths_dict = version_upgrade_manager.getStoragePaths("user")
paths_set = set() paths_set = set() # type: Set[str]
for paths in user_version_to_paths_dict.values(): for paths in user_version_to_paths_dict.values():
paths_set |= paths paths_set |= paths

View file

@ -1,8 +1,9 @@
# Copyright (c) 2016 Ultimaker B.V. # Copyright (c) 2018 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.
import configparser #To read config files. import configparser #To read config files.
import io #To output config files to string. import io #To output config files to string.
from typing import List, Optional, Tuple
import UM.VersionUpgrade #To indicate that a file is of the wrong format. import UM.VersionUpgrade #To indicate that a file is of the wrong format.
@ -14,7 +15,7 @@ import UM.VersionUpgrade #To indicate that a file is of the wrong format.
# extension. # extension.
# \return A representation of those preferences, or None if the file format is # \return A representation of those preferences, or None if the file format is
# incorrect. # incorrect.
def importFrom(serialised, filename): def importFrom(serialised: str, filename: str) -> Optional["Preferences"]:
try: try:
return Preferences(serialised, filename) return Preferences(serialised, filename)
except (configparser.Error, UM.VersionUpgrade.FormatException, UM.VersionUpgrade.InvalidVersionException): except (configparser.Error, UM.VersionUpgrade.FormatException, UM.VersionUpgrade.InvalidVersionException):
@ -28,7 +29,7 @@ class Preferences:
# \param serialised A serialised version 2 preferences file. # \param serialised A serialised version 2 preferences file.
# \param filename The supposed filename of the preferences file, without # \param filename The supposed filename of the preferences file, without
# extension. # extension.
def __init__(self, serialised, filename): def __init__(self, serialised: str, filename: str) -> None:
self._filename = filename self._filename = filename
self._config = configparser.ConfigParser(interpolation = None) self._config = configparser.ConfigParser(interpolation = None)
@ -50,7 +51,7 @@ class Preferences:
# #
# \return A tuple containing the new filename and a serialised version of # \return A tuple containing the new filename and a serialised version of
# a preferences file in version 3. # a preferences file in version 3.
def export(self): def export(self) -> Tuple[List[str], List[str]]:
#Reset the cura/categories_expanded property since it works differently now. #Reset the cura/categories_expanded property since it works differently now.
if self._config.has_section("cura") and self._config.has_option("cura", "categories_expanded"): if self._config.has_section("cura") and self._config.has_option("cura", "categories_expanded"):
self._config.remove_option("cura", "categories_expanded") self._config.remove_option("cura", "categories_expanded")
@ -58,11 +59,11 @@ class Preferences:
#Translate the setting names in the visible settings. #Translate the setting names in the visible settings.
if self._config.has_section("machines") and self._config.has_option("machines", "setting_visibility"): if self._config.has_section("machines") and self._config.has_option("machines", "setting_visibility"):
visible_settings = self._config.get("machines", "setting_visibility") visible_settings = self._config.get("machines", "setting_visibility")
visible_settings = visible_settings.split(",") visible_settings_list = visible_settings.split(",")
import VersionUpgrade21to22 #Import here to prevent a circular dependency. import VersionUpgrade21to22 #Import here to prevent a circular dependency.
visible_settings = [VersionUpgrade21to22.VersionUpgrade21to22.VersionUpgrade21to22.translateSettingName(setting_name) visible_settings_list = [VersionUpgrade21to22.VersionUpgrade21to22.VersionUpgrade21to22.translateSettingName(setting_name)
for setting_name in visible_settings] for setting_name in visible_settings_list]
visible_settings = ",".join(visible_settings) visible_settings = ",".join(visible_settings_list)
self._config.set("machines", "setting_visibility", value = visible_settings) self._config.set("machines", "setting_visibility", value = visible_settings)
#Translate the active_instance key. #Translate the active_instance key.

View file

@ -1,10 +1,9 @@
# Copyright (c) 2016 Ultimaker B.V. # Copyright (c) 2018 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.
import configparser #To read config files. import configparser #To read config files.
import io #To write config files to strings as if they were files. import io #To write config files to strings as if they were files.
from typing import Dict from typing import Dict, List, Optional, Tuple
from typing import List
import UM.VersionUpgrade import UM.VersionUpgrade
from UM.Logger import Logger from UM.Logger import Logger
@ -15,7 +14,7 @@ from UM.Logger import Logger
# \param serialised The serialised form of a profile in version 1. # \param serialised The serialised form of a profile in version 1.
# \param filename The supposed filename of the profile, without extension. # \param filename The supposed filename of the profile, without extension.
# \return A profile instance, or None if the file format is incorrect. # \return A profile instance, or None if the file format is incorrect.
def importFrom(serialised, filename): def importFrom(serialised: str, filename: str) -> Optional["Profile"]:
try: try:
return Profile(serialised, filename) return Profile(serialised, filename)
except (configparser.Error, UM.VersionUpgrade.FormatException, UM.VersionUpgrade.InvalidVersionException): except (configparser.Error, UM.VersionUpgrade.FormatException, UM.VersionUpgrade.InvalidVersionException):
@ -77,11 +76,11 @@ class Profile:
# #
# \return A tuple containing the new filename and a serialised form of # \return A tuple containing the new filename and a serialised form of
# this profile, serialised in version 2 of the file format. # this profile, serialised in version 2 of the file format.
def export(self): def export(self) -> Optional[Tuple[List[str], List[str]]]:
import VersionUpgrade21to22 # Import here to prevent circular dependencies. import VersionUpgrade21to22 # Import here to prevent circular dependencies.
if self._name == "Current settings": if self._name == "Current settings":
return None, None #Can't upgrade these, because the new current profile needs to specify the definition ID and the old file only had the machine instance, not the definition. return None #Can't upgrade these, because the new current profile needs to specify the definition ID and the old file only had the machine instance, not the definition.
config = configparser.ConfigParser(interpolation = None) config = configparser.ConfigParser(interpolation = None)

View file

@ -1,7 +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. # Cura is released under the terms of the LGPLv3 or higher.
import configparser #To get version numbers from config files. import configparser #To get version numbers from config files.
from typing import Dict, Iterable, List, Optional, Set, Tuple
from UM.VersionUpgrade import VersionUpgrade # Superclass of the plugin. from UM.VersionUpgrade import VersionUpgrade # Superclass of the plugin.
@ -30,7 +31,7 @@ _machines_with_machine_quality = {
"materials": { "generic_abs", "generic_cpe", "generic_pla", "generic_pva", "generic_cpe_plus", "generic_nylon", "generic_pc", "generic_tpu" }, "materials": { "generic_abs", "generic_cpe", "generic_pla", "generic_pva", "generic_cpe_plus", "generic_nylon", "generic_pc", "generic_tpu" },
"variants": { "0.25 mm", "0.4 mm", "0.6 mm", "0.8 mm" } "variants": { "0.25 mm", "0.4 mm", "0.6 mm", "0.8 mm" }
} }
} } # type: Dict[str, Dict[str, Set[str]]]
## How to translate material names from the old version to the new. ## How to translate material names from the old version to the new.
_material_translations = { _material_translations = {
@ -41,7 +42,7 @@ _material_translations = {
"Nylon": "generic_nylon", "Nylon": "generic_nylon",
"PC": "generic_pc", "PC": "generic_pc",
"TPU": "generic_tpu", "TPU": "generic_tpu",
} } # type: Dict[str, str]
## How to translate material names for in the profile names. ## How to translate material names for in the profile names.
_material_translations_profiles = { _material_translations_profiles = {
@ -52,17 +53,17 @@ _material_translations_profiles = {
"Nylon": "nylon", "Nylon": "nylon",
"PC": "pc", "PC": "pc",
"TPU": "tpu", "TPU": "tpu",
} } # type: Dict[str, str]
## How to translate printer names from the old version to the new. ## How to translate printer names from the old version to the new.
_printer_translations = { _printer_translations = {
"ultimaker2plus": "ultimaker2_plus" "ultimaker2plus": "ultimaker2_plus"
} } # type: Dict[str, str]
_printer_translations_profiles = { _printer_translations_profiles = {
"ultimaker2plus": "um2p", #Does NOT get included in PLA profiles! "ultimaker2plus": "um2p", #Does NOT get included in PLA profiles!
"ultimaker2_extended_plus": "um2ep" #Has no profiles for CPE+, Nylon, PC and TPU! "ultimaker2_extended_plus": "um2ep" #Has no profiles for CPE+, Nylon, PC and TPU!
} } # type: Dict[str, str]
## How to translate profile names from the old version to the new. ## How to translate profile names from the old version to the new.
# #
@ -116,13 +117,13 @@ _profile_translations = {
"tpu_0.25_high": "um2p_tpu_0.25_high", "tpu_0.25_high": "um2p_tpu_0.25_high",
"tpu_0.4_normal": "um2p_tpu_0.4_normal", "tpu_0.4_normal": "um2p_tpu_0.4_normal",
"tpu_0.6_fast": "um2p_tpu_0.6_fast" "tpu_0.6_fast": "um2p_tpu_0.6_fast"
} } # type: Dict[str, str]
## Settings that are no longer in the new version. ## Settings that are no longer in the new version.
_removed_settings = { _removed_settings = {
"fill_perimeter_gaps", "fill_perimeter_gaps",
"support_area_smoothing" "support_area_smoothing"
} } # type: Set[str]
## How to translate setting names from the old version to the new. ## How to translate setting names from the old version to the new.
_setting_name_translations = { _setting_name_translations = {
@ -142,7 +143,7 @@ _setting_name_translations = {
"support_roof_line_distance": "support_interface_line_distance", "support_roof_line_distance": "support_interface_line_distance",
"support_roof_line_width": "support_interface_line_width", "support_roof_line_width": "support_interface_line_width",
"support_roof_pattern": "support_interface_pattern" "support_roof_pattern": "support_interface_pattern"
} } # type: Dict[str, str]
## Custom profiles become quality_changes. This dictates which quality to base ## Custom profiles become quality_changes. This dictates which quality to base
# the quality_changes profile on. # the quality_changes profile on.
@ -190,7 +191,7 @@ _quality_fallbacks = {
#No TPU. #No TPU.
} }
} }
} } # type: Dict[str, Dict[str, Dict[str, str]]]
## How to translate variants of specific machines from the old version to the ## How to translate variants of specific machines from the old version to the
# new. # new.
@ -207,7 +208,7 @@ _variant_translations = {
"0.6 mm": "ultimaker2_extended_plus_0.6", "0.6 mm": "ultimaker2_extended_plus_0.6",
"0.8 mm": "ultimaker2_extended_plus_0.8" "0.8 mm": "ultimaker2_extended_plus_0.8"
} }
} } # type: Dict[str, Dict[str, str]]
## How to translate variant names for in the profile names. ## How to translate variant names for in the profile names.
_variant_translations_profiles = { _variant_translations_profiles = {
@ -215,7 +216,7 @@ _variant_translations_profiles = {
"0.4 mm": "0.4", "0.4 mm": "0.4",
"0.6 mm": "0.6", "0.6 mm": "0.6",
"0.8 mm": "0.8" "0.8 mm": "0.8"
} } # type: Dict[str, str]
## Cura 2.2's material profiles use a different naming scheme for variants. ## Cura 2.2's material profiles use a different naming scheme for variants.
# #
@ -233,7 +234,7 @@ _variant_translations_materials = {
"0.6 mm": "ultimaker2_plus_0.6_mm", "0.6 mm": "ultimaker2_plus_0.6_mm",
"0.8 mm": "ultimaker2_plus_0.8_mm" "0.8 mm": "ultimaker2_plus_0.8_mm"
} }
} } # type: Dict[str, Dict[str, str]]
## Converts configuration from Cura 2.1's file formats to Cura 2.2's. ## Converts configuration from Cura 2.1's file formats to Cura 2.2's.
# #
@ -245,12 +246,12 @@ class VersionUpgrade21to22(VersionUpgrade):
# number is stored in general/version, so get the data from that key. # number is stored in general/version, so get the data from that key.
# #
# \param serialised The contents of a config file. # \param serialised The contents of a config file.
# \return \type{int} The version number of that config file. # \return The version number of that config file.
def getCfgVersion(self, serialised): def getCfgVersion(self, serialised: str) -> int:
parser = configparser.ConfigParser(interpolation = None) parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialised) parser.read_string(serialised)
format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised. format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised.
setting_version = int(parser.get("metadata", "setting_version", fallback = 0)) setting_version = int(parser.get("metadata", "setting_version", fallback = "0"))
return format_version * 1000000 + setting_version return format_version * 1000000 + setting_version
## Gets the fallback quality to use for a specific machine-variant-material ## Gets the fallback quality to use for a specific machine-variant-material
@ -263,7 +264,7 @@ class VersionUpgrade21to22(VersionUpgrade):
# \param variant The variant ID of the user's configuration in 2.2. # \param variant The variant ID of the user's configuration in 2.2.
# \param material The material ID of the user's configuration in 2.2. # \param material The material ID of the user's configuration in 2.2.
@staticmethod @staticmethod
def getQualityFallback(machine, variant, material): def getQualityFallback(machine: str, variant: str, material: str) -> str:
if machine not in _quality_fallbacks: if machine not in _quality_fallbacks:
return "normal" return "normal"
if variant not in _quality_fallbacks[machine]: if variant not in _quality_fallbacks[machine]:
@ -277,14 +278,14 @@ class VersionUpgrade21to22(VersionUpgrade):
# This is required to test if profiles should be converted to a quality # This is required to test if profiles should be converted to a quality
# profile or a quality-changes profile. # profile or a quality-changes profile.
@staticmethod @staticmethod
def builtInProfiles(): def builtInProfiles() -> Iterable[str]:
return _profile_translations.keys() return _profile_translations.keys()
## Gets a set of the machines which now have per-material quality profiles. ## Gets a set of the machines which now have per-material quality profiles.
# #
# \return A set of machine identifiers. # \return A set of machine identifiers.
@staticmethod @staticmethod
def machinesWithMachineQuality(): def machinesWithMachineQuality() -> Dict[str, Dict[str, Set[str]]]:
return _machines_with_machine_quality return _machines_with_machine_quality
## Converts machine instances from format version 1 to version 2. ## Converts machine instances from format version 1 to version 2.
@ -295,10 +296,10 @@ class VersionUpgrade21to22(VersionUpgrade):
# \return A tuple containing the new filename and the serialised machine # \return A tuple containing the new filename and the serialised machine
# instance in version 2, or None if the input was not of the correct # instance in version 2, or None if the input was not of the correct
# format. # format.
def upgradeMachineInstance(self, serialised, filename): def upgradeMachineInstance(self, serialised: str, filename: str) -> Optional[Tuple[List[str], List[str]]]:
machine_instance = MachineInstance.importFrom(serialised, filename) machine_instance = MachineInstance.importFrom(serialised, filename)
if not machine_instance: #Invalid file format. if not machine_instance: #Invalid file format.
return filename, None return None
return machine_instance.export() return machine_instance.export()
## Converts preferences from format version 2 to version 3. ## Converts preferences from format version 2 to version 3.
@ -309,10 +310,10 @@ class VersionUpgrade21to22(VersionUpgrade):
# \return A tuple containing the new filename and the serialised # \return A tuple containing the new filename and the serialised
# preferences in version 3, or None if the input was not of the correct # preferences in version 3, or None if the input was not of the correct
# format. # format.
def upgradePreferences(self, serialised, filename): def upgradePreferences(self, serialised: str, filename: str) -> Optional[Tuple[List[str], List[str]]]:
preferences = Preferences.importFrom(serialised, filename) preferences = Preferences.importFrom(serialised, filename)
if not preferences: #Invalid file format. if not preferences: #Invalid file format.
return filename, None return None
return preferences.export() return preferences.export()
## Converts profiles from format version 1 to version 2. ## Converts profiles from format version 1 to version 2.
@ -322,10 +323,10 @@ class VersionUpgrade21to22(VersionUpgrade):
# extension. # extension.
# \return A tuple containing the new filename and the serialised profile # \return A tuple containing the new filename and the serialised profile
# in version 2, or None if the input was not of the correct format. # in version 2, or None if the input was not of the correct format.
def upgradeProfile(self, serialised, filename): def upgradeProfile(self, serialised: str, filename: str) -> Optional[Tuple[List[str], List[str]]]:
profile = Profile.importFrom(serialised, filename) profile = Profile.importFrom(serialised, filename)
if not profile: # Invalid file format. if not profile: # Invalid file format.
return filename, None return None
return profile.export() return profile.export()
## Translates a material name for the change from Cura 2.1 to 2.2. ## Translates a material name for the change from Cura 2.1 to 2.2.
@ -333,7 +334,7 @@ class VersionUpgrade21to22(VersionUpgrade):
# \param material A material name in Cura 2.1. # \param material A material name in Cura 2.1.
# \return The name of the corresponding material in Cura 2.2. # \return The name of the corresponding material in Cura 2.2.
@staticmethod @staticmethod
def translateMaterial(material): def translateMaterial(material: str) -> str:
if material in _material_translations: if material in _material_translations:
return _material_translations[material] return _material_translations[material]
return material return material
@ -345,7 +346,7 @@ class VersionUpgrade21to22(VersionUpgrade):
# \return The name of the corresponding material in the quality profiles # \return The name of the corresponding material in the quality profiles
# in Cura 2.2. # in Cura 2.2.
@staticmethod @staticmethod
def translateMaterialForProfiles(material): def translateMaterialForProfiles(material: str) -> str:
if material in _material_translations_profiles: if material in _material_translations_profiles:
return _material_translations_profiles[material] return _material_translations_profiles[material]
return material return material
@ -356,7 +357,7 @@ class VersionUpgrade21to22(VersionUpgrade):
# \param printer A printer name in Cura 2.1. # \param printer A printer name in Cura 2.1.
# \return The name of the corresponding printer in Cura 2.2. # \return The name of the corresponding printer in Cura 2.2.
@staticmethod @staticmethod
def translatePrinter(printer): def translatePrinter(printer: str) -> str:
if printer in _printer_translations: if printer in _printer_translations:
return _printer_translations[printer] return _printer_translations[printer]
return printer #Doesn't need to be translated. return printer #Doesn't need to be translated.
@ -367,7 +368,7 @@ class VersionUpgrade21to22(VersionUpgrade):
# \param printer A printer name in 2.1. # \param printer A printer name in 2.1.
# \return The name of the corresponding printer in Cura 2.2. # \return The name of the corresponding printer in Cura 2.2.
@staticmethod @staticmethod
def translatePrinterForProfile(printer): def translatePrinterForProfile(printer: str) -> str:
if printer in _printer_translations_profiles: if printer in _printer_translations_profiles:
return _printer_translations_profiles[printer] return _printer_translations_profiles[printer]
return printer return printer
@ -378,7 +379,7 @@ class VersionUpgrade21to22(VersionUpgrade):
# \param profile A profile name in the old version. # \param profile A profile name in the old version.
# \return The corresponding profile name in the new version. # \return The corresponding profile name in the new version.
@staticmethod @staticmethod
def translateProfile(profile): def translateProfile(profile: str) -> str:
if profile in _profile_translations: if profile in _profile_translations:
return _profile_translations[profile] return _profile_translations[profile]
return profile #Doesn't need to be translated. return profile #Doesn't need to be translated.
@ -392,7 +393,7 @@ class VersionUpgrade21to22(VersionUpgrade):
# \param settings A dictionary of settings (as key-value pairs) to update. # \param settings A dictionary of settings (as key-value pairs) to update.
# \return The same dictionary. # \return The same dictionary.
@staticmethod @staticmethod
def translateSettings(settings): def translateSettings(settings: Dict[str, str]) -> Dict[str, str]:
new_settings = {} new_settings = {}
for key, value in settings.items(): for key, value in settings.items():
if key in _removed_settings: if key in _removed_settings:
@ -414,7 +415,7 @@ class VersionUpgrade21to22(VersionUpgrade):
# \param setting The name of a setting in Cura 2.1. # \param setting The name of a setting in Cura 2.1.
# \return The name of the corresponding setting in Cura 2.2. # \return The name of the corresponding setting in Cura 2.2.
@staticmethod @staticmethod
def translateSettingName(setting): def translateSettingName(setting: str) -> str:
if setting in _setting_name_translations: if setting in _setting_name_translations:
return _setting_name_translations[setting] return _setting_name_translations[setting]
return setting #Doesn't need to be translated. return setting #Doesn't need to be translated.
@ -426,7 +427,7 @@ class VersionUpgrade21to22(VersionUpgrade):
# 2.2's naming. # 2.2's naming.
# \return The name of the corresponding variant in Cura 2.2. # \return The name of the corresponding variant in Cura 2.2.
@staticmethod @staticmethod
def translateVariant(variant, machine): def translateVariant(variant: str, machine: str) -> str:
if machine in _variant_translations and variant in _variant_translations[machine]: if machine in _variant_translations and variant in _variant_translations[machine]:
return _variant_translations[machine][variant] return _variant_translations[machine][variant]
return variant return variant
@ -440,7 +441,7 @@ class VersionUpgrade21to22(VersionUpgrade):
# \return The name of the corresponding variant for in material profiles # \return The name of the corresponding variant for in material profiles
# in Cura 2.2. # in Cura 2.2.
@staticmethod @staticmethod
def translateVariantForMaterials(variant, machine): def translateVariantForMaterials(variant: str, machine: str) -> str:
if machine in _variant_translations_materials and variant in _variant_translations_materials[machine]: if machine in _variant_translations_materials and variant in _variant_translations_materials[machine]:
return _variant_translations_materials[machine][variant] return _variant_translations_materials[machine][variant]
return variant return variant
@ -452,7 +453,7 @@ class VersionUpgrade21to22(VersionUpgrade):
# \return The name of the corresponding variant for in quality profiles in # \return The name of the corresponding variant for in quality profiles in
# Cura 2.2. # Cura 2.2.
@staticmethod @staticmethod
def translateVariantForProfiles(variant): def translateVariantForProfiles(variant: str) -> str:
if variant in _variant_translations_profiles: if variant in _variant_translations_profiles:
return _variant_translations_profiles[variant] return _variant_translations_profiles[variant]
return variant return variant

View file

@ -1,11 +1,16 @@
# Copyright (c) 2016 Ultimaker B.V. # Copyright (c) 2018 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 Any, Dict, TYPE_CHECKING
from . import VersionUpgrade21to22 from . import VersionUpgrade21to22
if TYPE_CHECKING:
from UM.Application import Application
upgrade = VersionUpgrade21to22.VersionUpgrade21to22() upgrade = VersionUpgrade21to22.VersionUpgrade21to22()
def getMetaData(): def getMetaData() -> Dict[str, Any]:
return { return {
"version_upgrade": { "version_upgrade": {
# From To Upgrade function # From To Upgrade function
@ -33,5 +38,5 @@ def getMetaData():
} }
} }
def register(app): def register(app: "Application") -> Dict[str, Any]:
return { "version_upgrade": upgrade } return { "version_upgrade": upgrade }

View file

@ -1,18 +1,18 @@
# Copyright (c) 2017 Ultimaker B.V. # Copyright (c) 2018 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.
import configparser #To get version numbers from config files. import configparser #To get version numbers from config files.
import io
import os import os
import os.path import os.path
import io from typing import Dict, List, Optional, Tuple
from UM.Resources import Resources from UM.Resources import Resources
from UM.VersionUpgrade import VersionUpgrade # Superclass of the plugin. from UM.VersionUpgrade import VersionUpgrade # Superclass of the plugin.
import UM.VersionUpgrade import UM.VersionUpgrade
class VersionUpgrade22to24(VersionUpgrade): class VersionUpgrade22to24(VersionUpgrade):
def upgradeMachineInstance(self, serialised: str, filename: str) -> Optional[Tuple[List[str], List[str]]]:
def upgradeMachineInstance(self, serialised, filename):
# All of this is needed to upgrade custom variant machines from old Cura to 2.4 where # All of this is needed to upgrade custom variant machines from old Cura to 2.4 where
# `definition_changes` instance container has been introduced. Variant files which # `definition_changes` instance container has been introduced. Variant files which
# look like the the handy work of the old machine settings plugin are converted directly # look like the the handy work of the old machine settings plugin are converted directly
@ -22,11 +22,11 @@ class VersionUpgrade22to24(VersionUpgrade):
config.read_string(serialised) # Read the input string as config file. config.read_string(serialised) # Read the input string as config file.
if config.get("metadata", "type") == "definition_changes": if config.get("metadata", "type") == "definition_changes":
# This is not a container stack, don't upgrade it here # This is not a container stack, don't upgrade it here
return return None
config.set("general", "version", "3") config.set("general", "version", "3")
container_list = [] container_list = [] # type: List[str]
if config.has_section("containers"): if config.has_section("containers"):
for index, container_id in config.items("containers"): for index, container_id in config.items("containers"):
container_list.append(container_id) container_list.append(container_id)
@ -37,14 +37,14 @@ class VersionUpgrade22to24(VersionUpgrade):
user_variants = self.__getUserVariants() user_variants = self.__getUserVariants()
name_path_dict = {} name_path_dict = {}
for variant in user_variants: for variant in user_variants:
name_path_dict[variant.get("name")] = variant.get("path") name_path_dict[variant["name"]] = variant["path"]
user_variant_names = set(container_list).intersection(name_path_dict.keys()) user_variant_names = set(container_list).intersection(name_path_dict.keys())
if len(user_variant_names): if len(user_variant_names):
# One of the user defined variants appears in the list of containers in the stack. # One of the user defined variants appears in the list of containers in the stack.
for variant_name in user_variant_names: # really there should just be one variant to convert. for variant_name in user_variant_names: # really there should just be one variant to convert.
config_name = self.__convertVariant(name_path_dict.get(variant_name)) config_name = self.__convertVariant(name_path_dict[variant_name])
# Change the name of variant and insert empty_variant into the stack. # Change the name of variant and insert empty_variant into the stack.
new_container_list = [] new_container_list = []
@ -64,14 +64,14 @@ class VersionUpgrade22to24(VersionUpgrade):
config.remove_option("general", "containers") config.remove_option("general", "containers")
for index in range(len(container_list)): for idx in range(len(container_list)):
config.set("containers", str(index), container_list[index]) config.set("containers", str(idx), container_list[idx])
output = io.StringIO() output = io.StringIO()
config.write(output) config.write(output)
return [filename], [output.getvalue()] return [filename], [output.getvalue()]
def __convertVariant(self, variant_path): def __convertVariant(self, variant_path: str) -> str:
# Copy the variant to the machine_instances/*_settings.inst.cfg # Copy the variant to the machine_instances/*_settings.inst.cfg
variant_config = configparser.ConfigParser(interpolation = None) variant_config = configparser.ConfigParser(interpolation = None)
with open(variant_path, "r", encoding = "utf-8") as fhandle: with open(variant_path, "r", encoding = "utf-8") as fhandle:
@ -99,7 +99,7 @@ class VersionUpgrade22to24(VersionUpgrade):
return config_name return config_name
def __getUserVariants(self): def __getUserVariants(self) -> List[Dict[str, str]]:
resource_path = Resources.getDataStoragePath() resource_path = Resources.getDataStoragePath()
variants_dir = os.path.join(resource_path, "variants") variants_dir = os.path.join(resource_path, "variants")
@ -113,7 +113,7 @@ class VersionUpgrade22to24(VersionUpgrade):
result.append( { "path": entry.path, "name": config.get("general", "name") } ) result.append( { "path": entry.path, "name": config.get("general", "name") } )
return result return result
def upgradeExtruderTrain(self, serialised, filename): def upgradeExtruderTrain(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]:
config = configparser.ConfigParser(interpolation = None) config = configparser.ConfigParser(interpolation = None)
config.read_string(serialised) # Read the input string as config file. config.read_string(serialised) # Read the input string as config file.
config.set("general", "version", "3") # Just bump the version number. That is all we need for now. config.set("general", "version", "3") # Just bump the version number. That is all we need for now.
@ -122,7 +122,7 @@ class VersionUpgrade22to24(VersionUpgrade):
config.write(output) config.write(output)
return [filename], [output.getvalue()] return [filename], [output.getvalue()]
def upgradePreferences(self, serialised, filename): def upgradePreferences(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]:
config = configparser.ConfigParser(interpolation = None) config = configparser.ConfigParser(interpolation = None)
config.read_string(serialised) config.read_string(serialised)
@ -142,7 +142,7 @@ class VersionUpgrade22to24(VersionUpgrade):
config.write(output) config.write(output)
return [filename], [output.getvalue()] return [filename], [output.getvalue()]
def upgradeQuality(self, serialised, filename): def upgradeQuality(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]:
config = configparser.ConfigParser(interpolation = None) config = configparser.ConfigParser(interpolation = None)
config.read_string(serialised) # Read the input string as config file. config.read_string(serialised) # Read the input string as config file.
config.set("metadata", "type", "quality_changes") # Update metadata/type to quality_changes config.set("metadata", "type", "quality_changes") # Update metadata/type to quality_changes
@ -152,9 +152,9 @@ class VersionUpgrade22to24(VersionUpgrade):
config.write(output) config.write(output)
return [filename], [output.getvalue()] return [filename], [output.getvalue()]
def getCfgVersion(self, serialised): def getCfgVersion(self, serialised: str) -> int:
parser = configparser.ConfigParser(interpolation = None) parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialised) parser.read_string(serialised)
format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised. format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised.
setting_version = int(parser.get("metadata", "setting_version", fallback = 0)) setting_version = int(parser.get("metadata", "setting_version", fallback = "0"))
return format_version * 1000000 + setting_version return format_version * 1000000 + setting_version

View file

@ -1,11 +1,16 @@
# Copyright (c) 2016 Ultimaker B.V. # Copyright (c) 2018 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 Any, Dict, TYPE_CHECKING
from . import VersionUpgrade from . import VersionUpgrade
if TYPE_CHECKING:
from UM.Application import Application
upgrade = VersionUpgrade.VersionUpgrade22to24() upgrade = VersionUpgrade.VersionUpgrade22to24()
def getMetaData(): def getMetaData() -> Dict[str, Any]:
return { return {
"version_upgrade": { "version_upgrade": {
# From To Upgrade function # From To Upgrade function
@ -26,5 +31,5 @@ def getMetaData():
} }
} }
def register(app): def register(app: "Application"):
return { "version_upgrade": upgrade } return { "version_upgrade": upgrade }

View file

@ -4,6 +4,7 @@
import configparser #To parse the files we need to upgrade and write the new files. import configparser #To parse the files we need to upgrade and write the new files.
import io #To serialise configparser output to a string. import io #To serialise configparser output to a string.
import os import os
from typing import Dict, List, Set, Tuple
from urllib.parse import quote_plus from urllib.parse import quote_plus
from UM.Resources import Resources from UM.Resources import Resources
@ -12,19 +13,18 @@ from UM.VersionUpgrade import VersionUpgrade
_removed_settings = { #Settings that were removed in 2.5. _removed_settings = { #Settings that were removed in 2.5.
"start_layers_at_same_position", "start_layers_at_same_position",
"sub_div_rad_mult" "sub_div_rad_mult"
} } # type: Set[str]
_split_settings = { #These settings should be copied to all settings it was split into. _split_settings = { #These settings should be copied to all settings it was split into.
"support_interface_line_distance": {"support_roof_line_distance", "support_bottom_line_distance"} "support_interface_line_distance": {"support_roof_line_distance", "support_bottom_line_distance"}
} } # type: Dict[str, Set[str]]
## A collection of functions that convert the configuration of the user in Cura ## A collection of functions that convert the configuration of the user in Cura
# 2.5 to a configuration for Cura 2.6. # 2.5 to a configuration for Cura 2.6.
# #
# All of these methods are essentially stateless. # All of these methods are essentially stateless.
class VersionUpgrade25to26(VersionUpgrade): class VersionUpgrade25to26(VersionUpgrade):
def __init__(self) -> None:
def __init__(self):
super().__init__() super().__init__()
self._current_fdm_printer_count = 2 self._current_fdm_printer_count = 2
@ -39,18 +39,18 @@ class VersionUpgrade25to26(VersionUpgrade):
# \raises ValueError The format of the version number in the file is # \raises ValueError The format of the version number in the file is
# incorrect. # incorrect.
# \raises KeyError The format of the file is incorrect. # \raises KeyError The format of the file is incorrect.
def getCfgVersion(self, serialised): def getCfgVersion(self, serialised: str) -> int:
parser = configparser.ConfigParser(interpolation = None) parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialised) parser.read_string(serialised)
format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised. format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised.
setting_version = int(parser.get("metadata", "setting_version", fallback = 0)) setting_version = int(parser.get("metadata", "setting_version", fallback = "0"))
return format_version * 1000000 + setting_version return format_version * 1000000 + setting_version
## Upgrades the preferences file from version 2.5 to 2.6. ## Upgrades the preferences file from version 2.5 to 2.6.
# #
# \param serialised The serialised form of a preferences file. # \param serialised The serialised form of a preferences file.
# \param filename The name of the file to upgrade. # \param filename The name of the file to upgrade.
def upgradePreferences(self, serialised, filename): def upgradePreferences(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]:
parser = configparser.ConfigParser(interpolation = None) parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialised) parser.read_string(serialised)
@ -86,7 +86,7 @@ class VersionUpgrade25to26(VersionUpgrade):
# #
# \param serialised The serialised form of a quality profile. # \param serialised The serialised form of a quality profile.
# \param filename The name of the file to upgrade. # \param filename The name of the file to upgrade.
def upgradeInstanceContainer(self, serialised, filename): def upgradeInstanceContainer(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]:
parser = configparser.ConfigParser(interpolation = None) parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialised) parser.read_string(serialised)
@ -116,7 +116,7 @@ class VersionUpgrade25to26(VersionUpgrade):
# #
# \param serialised The serialised form of a quality profile. # \param serialised The serialised form of a quality profile.
# \param filename The name of the file to upgrade. # \param filename The name of the file to upgrade.
def upgradeMachineStack(self, serialised, filename): def upgradeMachineStack(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]:
parser = configparser.ConfigParser(interpolation = None) parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialised) parser.read_string(serialised)
@ -149,7 +149,7 @@ class VersionUpgrade25to26(VersionUpgrade):
return [filename], [output.getvalue()] return [filename], [output.getvalue()]
## Acquires the next unique extruder stack index number for the Custom FDM Printer. ## Acquires the next unique extruder stack index number for the Custom FDM Printer.
def _acquireNextUniqueCustomFdmPrinterExtruderStackIdIndex(self): def _acquireNextUniqueCustomFdmPrinterExtruderStackIdIndex(self) -> int:
extruder_stack_dir = os.path.join(Resources.getDataStoragePath(), "extruders") extruder_stack_dir = os.path.join(Resources.getDataStoragePath(), "extruders")
file_name_list = os.listdir(extruder_stack_dir) file_name_list = os.listdir(extruder_stack_dir)
file_name_list = [os.path.basename(file_name) for file_name in file_name_list] file_name_list = [os.path.basename(file_name) for file_name in file_name_list]
@ -169,7 +169,7 @@ class VersionUpgrade25to26(VersionUpgrade):
return self._current_fdm_printer_count return self._current_fdm_printer_count
def _checkCustomFdmPrinterHasExtruderStack(self, machine_id): def _checkCustomFdmPrinterHasExtruderStack(self, machine_id: str) -> bool:
# go through all extruders and make sure that this custom FDM printer has extruder stacks. # go through all extruders and make sure that this custom FDM printer has extruder stacks.
extruder_stack_dir = os.path.join(Resources.getDataStoragePath(), "extruders") extruder_stack_dir = os.path.join(Resources.getDataStoragePath(), "extruders")
has_extruders = False has_extruders = False
@ -197,7 +197,7 @@ class VersionUpgrade25to26(VersionUpgrade):
return has_extruders return has_extruders
def _createCustomFdmPrinterExtruderStack(self, machine_id: str, position: int, quality_id: str, material_id: str): def _createCustomFdmPrinterExtruderStack(self, machine_id: str, position: int, quality_id: str, material_id: str) -> None:
stack_id = "custom_extruder_%s" % (position + 1) stack_id = "custom_extruder_%s" % (position + 1)
if self._current_fdm_printer_count > 1: if self._current_fdm_printer_count > 1:
stack_id += " #%s" % self._current_fdm_printer_count stack_id += " #%s" % self._current_fdm_printer_count
@ -256,7 +256,7 @@ class VersionUpgrade25to26(VersionUpgrade):
## Creates a definition changes container which doesn't contain anything for the Custom FDM Printers. ## Creates a definition changes container which doesn't contain anything for the Custom FDM Printers.
# The container ID will be automatically generated according to the given stack name. # The container ID will be automatically generated according to the given stack name.
def _getCustomFdmPrinterDefinitionChanges(self, stack_id: str): def _getCustomFdmPrinterDefinitionChanges(self, stack_id: str) -> configparser.ConfigParser:
# In 2.5, there is no definition_changes container for the Custom FDM printer, so it should be safe to use the # In 2.5, there is no definition_changes container for the Custom FDM printer, so it should be safe to use the
# default name unless some one names the printer as something like "Custom FDM Printer_settings". # default name unless some one names the printer as something like "Custom FDM Printer_settings".
definition_changes_id = stack_id + "_settings" definition_changes_id = stack_id + "_settings"
@ -277,7 +277,7 @@ class VersionUpgrade25to26(VersionUpgrade):
## Creates a user settings container which doesn't contain anything for the Custom FDM Printers. ## Creates a user settings container which doesn't contain anything for the Custom FDM Printers.
# The container ID will be automatically generated according to the given stack name. # The container ID will be automatically generated according to the given stack name.
def _getCustomFdmPrinterUserSettings(self, stack_id: str): def _getCustomFdmPrinterUserSettings(self, stack_id: str) -> configparser.ConfigParser:
# For the extruder stacks created in the upgrade, also create user_settings containers so the user changes # For the extruder stacks created in the upgrade, also create user_settings containers so the user changes
# will be saved. # will be saved.
user_settings_id = stack_id + "_user" user_settings_id = stack_id + "_user"

View file

@ -1,11 +1,16 @@
# Copyright (c) 2017 Ultimaker B.V. # Copyright (c) 2018 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 Any, Dict, TYPE_CHECKING
from . import VersionUpgrade25to26 from . import VersionUpgrade25to26
if TYPE_CHECKING:
from UM.Application import Application
upgrade = VersionUpgrade25to26.VersionUpgrade25to26() upgrade = VersionUpgrade25to26.VersionUpgrade25to26()
def getMetaData(): def getMetaData() -> Dict[str, Any]:
return { return {
"version_upgrade": { "version_upgrade": {
# From To Upgrade function # From To Upgrade function
@ -41,5 +46,5 @@ def getMetaData():
} }
} }
def register(app): def register(app: "Application") -> Dict[str, Any]:
return { "version_upgrade": upgrade } return { "version_upgrade": upgrade }

View file

@ -3,6 +3,7 @@
import configparser #To parse the files we need to upgrade and write the new files. import configparser #To parse the files we need to upgrade and write the new files.
import io #To serialise configparser output to a string. import io #To serialise configparser output to a string.
from typing import Dict, List, Tuple
from UM.VersionUpgrade import VersionUpgrade from UM.VersionUpgrade import VersionUpgrade
@ -61,7 +62,7 @@ _renamed_quality_profiles = {
"um3_bb0.8_TPU_Not_Supported_Quality": "um3_bb0.8_TPU_Fast_print", "um3_bb0.8_TPU_Not_Supported_Quality": "um3_bb0.8_TPU_Fast_print",
"um3_bb0.8_TPU_Not_Supported_Superdraft_Quality": "um3_bb0.8_TPU_Superdraft_Print", "um3_bb0.8_TPU_Not_Supported_Superdraft_Quality": "um3_bb0.8_TPU_Superdraft_Print",
} } # type: Dict[str, str]
## A collection of functions that convert the configuration of the user in Cura ## A collection of functions that convert the configuration of the user in Cura
# 2.6 to a configuration for Cura 2.7. # 2.6 to a configuration for Cura 2.7.
@ -79,19 +80,19 @@ class VersionUpgrade26to27(VersionUpgrade):
# \raises ValueError The format of the version number in the file is # \raises ValueError The format of the version number in the file is
# incorrect. # incorrect.
# \raises KeyError The format of the file is incorrect. # \raises KeyError The format of the file is incorrect.
def getCfgVersion(self, serialised): def getCfgVersion(self, serialised: str) -> int:
parser = configparser.ConfigParser(interpolation = None) parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialised) parser.read_string(serialised)
format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised. format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised.
setting_version = int(parser.get("metadata", "setting_version", fallback = 0)) setting_version = int(parser.get("metadata", "setting_version", fallback = "0"))
return format_version * 1000000 + setting_version return format_version * 1000000 + setting_version
## Upgrades a preferences file from version 2.6 to 2.7. ## Upgrades a preferences file from version 2.6 to 2.7.
# #
# \param serialised The serialised form of a preferences file. # \param serialised The serialised form of a preferences file.
# \param filename The name of the file to upgrade. # \param filename The name of the file to upgrade.
def upgradePreferences(self, serialised, filename): def upgradePreferences(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]:
parser = configparser.ConfigParser(interpolation=None) parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialised) parser.read_string(serialised)
# Update version numbers # Update version numbers
@ -117,8 +118,8 @@ class VersionUpgrade26to27(VersionUpgrade):
# #
# \param serialised The serialised form of a container file. # \param serialised The serialised form of a container file.
# \param filename The name of the file to upgrade. # \param filename The name of the file to upgrade.
def upgradeOtherContainer(self, serialised, filename): def upgradeOtherContainer(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]:
parser = configparser.ConfigParser(interpolation=None) parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialised) parser.read_string(serialised)
# Update version numbers # Update version numbers
@ -139,7 +140,7 @@ class VersionUpgrade26to27(VersionUpgrade):
# #
# \param serialised The serialised form of a container stack. # \param serialised The serialised form of a container stack.
# \param filename The name of the file to upgrade. # \param filename The name of the file to upgrade.
def upgradeStack(self, serialised, filename): def upgradeStack(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]:
parser = configparser.ConfigParser(interpolation = None) parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialised) parser.read_string(serialised)

View file

@ -1,11 +1,16 @@
# Copyright (c) 2017 Ultimaker B.V. # Copyright (c) 2018 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 Any, Dict, TYPE_CHECKING
from . import VersionUpgrade26to27 from . import VersionUpgrade26to27
if TYPE_CHECKING:
from UM.Application import Application
upgrade = VersionUpgrade26to27.VersionUpgrade26to27() upgrade = VersionUpgrade26to27.VersionUpgrade26to27()
def getMetaData(): def getMetaData() -> Dict[str, Any]:
return { return {
"version_upgrade": { "version_upgrade": {
# From To Upgrade function # From To Upgrade function
@ -59,5 +64,5 @@ def getMetaData():
} }
} }
def register(app): def register(app: "Application") -> Dict[str, Any]:
return { "version_upgrade": upgrade } return { "version_upgrade": upgrade }

View file

@ -1,9 +1,10 @@
# Copyright (c) 2017 Ultimaker B.V. # Copyright (c) 2018 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.
import configparser #To parse preference files. import configparser #To parse preference files.
import io #To serialise the preference files afterwards. import io #To serialise the preference files afterwards.
import os import os
from typing import Dict, List, Tuple
import urllib.parse import urllib.parse
import re import re
@ -11,7 +12,7 @@ from UM.VersionUpgrade import VersionUpgrade #We're inheriting from this.
_renamed_themes = { _renamed_themes = {
"cura": "cura-light" "cura": "cura-light"
} } # type: Dict[str, str]
_renamed_i18n = { _renamed_i18n = {
"7s": "en_7S", "7s": "en_7S",
"de": "de_DE", "de": "de_DE",
@ -28,7 +29,7 @@ _renamed_i18n = {
"ptbr": "pt_BR", "ptbr": "pt_BR",
"ru": "ru_RU", "ru": "ru_RU",
"tr": "tr_TR" "tr": "tr_TR"
} } # type: Dict[str, str]
class VersionUpgrade27to30(VersionUpgrade): class VersionUpgrade27to30(VersionUpgrade):
@ -43,19 +44,19 @@ class VersionUpgrade27to30(VersionUpgrade):
# \raises ValueError The format of the version number in the file is # \raises ValueError The format of the version number in the file is
# incorrect. # incorrect.
# \raises KeyError The format of the file is incorrect. # \raises KeyError The format of the file is incorrect.
def getCfgVersion(self, serialised): def getCfgVersion(self, serialised: str) -> int:
parser = configparser.ConfigParser(interpolation = None) parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialised) parser.read_string(serialised)
format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised. format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised.
setting_version = int(parser.get("metadata", "setting_version", fallback = 0)) setting_version = int(parser.get("metadata", "setting_version", fallback = "0"))
return format_version * 1000000 + setting_version return format_version * 1000000 + setting_version
## Upgrades a preferences file from version 2.7 to 3.0. ## Upgrades a preferences file from version 2.7 to 3.0.
# #
# \param serialised The serialised form of a preferences file. # \param serialised The serialised form of a preferences file.
# \param filename The name of the file to upgrade. # \param filename The name of the file to upgrade.
def upgradePreferences(self, serialised, filename): def upgradePreferences(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]:
parser = configparser.ConfigParser(interpolation=None) parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialised) parser.read_string(serialised)
# Update version numbers # Update version numbers
@ -100,8 +101,8 @@ class VersionUpgrade27to30(VersionUpgrade):
# #
# \param serialised The serialised form of the container file. # \param serialised The serialised form of the container file.
# \param filename The name of the file to upgrade. # \param filename The name of the file to upgrade.
def upgradeQualityChangesContainer(self, serialised, filename): def upgradeQualityChangesContainer(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]:
parser = configparser.ConfigParser(interpolation=None) parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialised) parser.read_string(serialised)
# Update the skin pre-shrink settings: # Update the skin pre-shrink settings:
@ -156,8 +157,8 @@ class VersionUpgrade27to30(VersionUpgrade):
# #
# \param serialised The serialised form of the container file. # \param serialised The serialised form of the container file.
# \param filename The name of the file to upgrade. # \param filename The name of the file to upgrade.
def upgradeOtherContainer(self, serialised, filename): def upgradeOtherContainer(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]:
parser = configparser.ConfigParser(interpolation=None) parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialised) parser.read_string(serialised)
# Update the skin pre-shrink settings: # Update the skin pre-shrink settings:
@ -185,7 +186,7 @@ class VersionUpgrade27to30(VersionUpgrade):
# #
# \param serialised The serialised form of a container stack. # \param serialised The serialised form of a container stack.
# \param filename The name of the file to upgrade. # \param filename The name of the file to upgrade.
def upgradeStack(self, serialised, filename): def upgradeStack(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]:
parser = configparser.ConfigParser(interpolation=None) parser = configparser.ConfigParser(interpolation=None)
parser.read_string(serialised) parser.read_string(serialised)

View file

@ -1,11 +1,16 @@
# Copyright (c) 2017 Ultimaker B.V. # Copyright (c) 2018 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 Any, Dict, TYPE_CHECKING
from . import VersionUpgrade27to30 from . import VersionUpgrade27to30
if TYPE_CHECKING:
from UM.Application import Application
upgrade = VersionUpgrade27to30.VersionUpgrade27to30() upgrade = VersionUpgrade27to30.VersionUpgrade27to30()
def getMetaData(): def getMetaData() -> Dict[str, Any]:
return { return {
"version_upgrade": { "version_upgrade": {
# From To Upgrade function # From To Upgrade function
@ -51,5 +56,5 @@ def getMetaData():
} }
} }
def register(app): def register(app: "Application") -> Dict[str, Any]:
return { "version_upgrade": upgrade } return { "version_upgrade": upgrade }

View file

@ -1,14 +1,15 @@
# Copyright (c) 2017 Ultimaker B.V. # Copyright (c) 2018 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.
import configparser #To parse preference files. import configparser #To parse preference files.
import io #To serialise the preference files afterwards. import io #To serialise the preference files afterwards.
from typing import Dict, List, Set, Tuple
from UM.VersionUpgrade import VersionUpgrade #We're inheriting from this. from UM.VersionUpgrade import VersionUpgrade #We're inheriting from this.
# a list of all legacy "Not Supported" quality profiles # a list of all legacy "Not Supported" quality profiles
_OLD_NOT_SUPPORTED_PROFILES = [ _OLD_NOT_SUPPORTED_PROFILES = {
"um2p_pp_0.25_normal", "um2p_pp_0.25_normal",
"um2p_tpu_0.8_normal", "um2p_tpu_0.8_normal",
"um3_bb0.4_ABS_Fast_Print", "um3_bb0.4_ABS_Fast_Print",
@ -42,7 +43,7 @@ _OLD_NOT_SUPPORTED_PROFILES = [
"um3_bb0.8_PP_Superdraft_Print", "um3_bb0.8_PP_Superdraft_Print",
"um3_bb0.8_TPU_Fast_print", "um3_bb0.8_TPU_Fast_print",
"um3_bb0.8_TPU_Superdraft_Print", "um3_bb0.8_TPU_Superdraft_Print",
] } # type: Set[str]
# Some containers have their specific empty containers, those need to be set correctly. # Some containers have their specific empty containers, those need to be set correctly.
@ -51,13 +52,13 @@ _EMPTY_CONTAINER_DICT = {
"2": "empty_quality", "2": "empty_quality",
"3": "empty_material", "3": "empty_material",
"4": "empty_variant", "4": "empty_variant",
} } # type: Dict[str, str]
# Renamed definition files # Renamed definition files
_RENAMED_DEFINITION_DICT = { _RENAMED_DEFINITION_DICT = {
"jellybox": "imade3d_jellybox", "jellybox": "imade3d_jellybox",
} } # type: Dict[str, str]
class VersionUpgrade30to31(VersionUpgrade): class VersionUpgrade30to31(VersionUpgrade):
@ -72,18 +73,18 @@ class VersionUpgrade30to31(VersionUpgrade):
# \raises ValueError The format of the version number in the file is # \raises ValueError The format of the version number in the file is
# incorrect. # incorrect.
# \raises KeyError The format of the file is incorrect. # \raises KeyError The format of the file is incorrect.
def getCfgVersion(self, serialised): def getCfgVersion(self, serialised: str) -> int:
parser = configparser.ConfigParser(interpolation = None) parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialised) parser.read_string(serialised)
format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised. format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised.
setting_version = int(parser.get("metadata", "setting_version", fallback = 0)) setting_version = int(parser.get("metadata", "setting_version", fallback = "0"))
return format_version * 1000000 + setting_version return format_version * 1000000 + setting_version
## Upgrades a preferences file from version 3.0 to 3.1. ## Upgrades a preferences file from version 3.0 to 3.1.
# #
# \param serialised The serialised form of a preferences file. # \param serialised The serialised form of a preferences file.
# \param filename The name of the file to upgrade. # \param filename The name of the file to upgrade.
def upgradePreferences(self, serialised, filename): def upgradePreferences(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]:
parser = configparser.ConfigParser(interpolation = None) parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialised) parser.read_string(serialised)
@ -104,7 +105,7 @@ class VersionUpgrade30to31(VersionUpgrade):
# #
# \param serialised The serialised form of the container file. # \param serialised The serialised form of the container file.
# \param filename The name of the file to upgrade. # \param filename The name of the file to upgrade.
def upgradeInstanceContainer(self, serialised, filename): def upgradeInstanceContainer(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]:
parser = configparser.ConfigParser(interpolation = None) parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialised) parser.read_string(serialised)
@ -129,7 +130,7 @@ class VersionUpgrade30to31(VersionUpgrade):
# #
# \param serialised The serialised form of a container stack. # \param serialised The serialised form of a container stack.
# \param filename The name of the file to upgrade. # \param filename The name of the file to upgrade.
def upgradeStack(self, serialised, filename): def upgradeStack(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]:
parser = configparser.ConfigParser(interpolation = None) parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialised) parser.read_string(serialised)

View file

@ -1,11 +1,16 @@
# Copyright (c) 2017 Ultimaker B.V. # Copyright (c) 2018 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 Any, Dict, TYPE_CHECKING
from . import VersionUpgrade30to31 from . import VersionUpgrade30to31
if TYPE_CHECKING:
from UM.Application import Application
upgrade = VersionUpgrade30to31.VersionUpgrade30to31() upgrade = VersionUpgrade30to31.VersionUpgrade30to31()
def getMetaData(): def getMetaData() -> Dict[str, Any]:
return { return {
"version_upgrade": { "version_upgrade": {
# From To Upgrade function # From To Upgrade function
@ -55,5 +60,5 @@ def getMetaData():
} }
} }
def register(app): def register(app: "Application") -> Dict[str, Any]:
return { "version_upgrade": upgrade } return { "version_upgrade": upgrade }

View file

@ -3,6 +3,7 @@
import configparser #To parse preference files. import configparser #To parse preference files.
import io #To serialise the preference files afterwards. import io #To serialise the preference files afterwards.
from typing import Dict, List, Tuple
from UM.VersionUpgrade import VersionUpgrade #We're inheriting from this. from UM.VersionUpgrade import VersionUpgrade #We're inheriting from this.
@ -51,22 +52,22 @@ _EXTRUDER_TO_POSITION = {
"ultimaker_original_dual_2nd": 1, "ultimaker_original_dual_2nd": 1,
"vertex_k8400_dual_1st": 0, "vertex_k8400_dual_1st": 0,
"vertex_k8400_dual_2nd": 1 "vertex_k8400_dual_2nd": 1
} } # type: Dict[str, int]
_RENAMED_QUALITY_PROFILES = { _RENAMED_QUALITY_PROFILES = {
"low": "fast", "low": "fast",
"um2_low": "um2_fast" "um2_low": "um2_fast"
} } # type: Dict[str, str]
_RENAMED_QUALITY_TYPES = { _RENAMED_QUALITY_TYPES = {
"low": "fast" "low": "fast"
} } # type: Dict[str, str]
## Upgrades configurations from the state they were in at version 3.2 to the ## Upgrades configurations from the state they were in at version 3.2 to the
# state they should be in at version 3.3. # state they should be in at version 3.3.
class VersionUpgrade32to33(VersionUpgrade): class VersionUpgrade32to33(VersionUpgrade):
temporary_group_name_counter = 1 temporary_group_name_counter = 1
## Gets the version number from a CFG file in Uranium's 3.2 format. ## Gets the version number from a CFG file in Uranium's 3.2 format.
# #
# Since the format may change, this is implemented for the 3.2 format only # Since the format may change, this is implemented for the 3.2 format only
@ -78,18 +79,18 @@ class VersionUpgrade32to33(VersionUpgrade):
# \raises ValueError The format of the version number in the file is # \raises ValueError The format of the version number in the file is
# incorrect. # incorrect.
# \raises KeyError The format of the file is incorrect. # \raises KeyError The format of the file is incorrect.
def getCfgVersion(self, serialised): def getCfgVersion(self, serialised: str) -> int:
parser = configparser.ConfigParser(interpolation = None) parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialised) parser.read_string(serialised)
format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised. format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised.
setting_version = int(parser.get("metadata", "setting_version", fallback = 0)) setting_version = int(parser.get("metadata", "setting_version", fallback = "0"))
return format_version * 1000000 + setting_version return format_version * 1000000 + setting_version
## Upgrades a preferences file from version 3.2 to 3.3. ## Upgrades a preferences file from version 3.2 to 3.3.
# #
# \param serialised The serialised form of a preferences file. # \param serialised The serialised form of a preferences file.
# \param filename The name of the file to upgrade. # \param filename The name of the file to upgrade.
def upgradePreferences(self, serialised, filename): def upgradePreferences(self, serialised: str, filename: str) -> Tuple[List[str], List[str]]:
parser = configparser.ConfigParser(interpolation = None) parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialised) parser.read_string(serialised)
@ -117,7 +118,7 @@ class VersionUpgrade32to33(VersionUpgrade):
# #
# \param serialised The serialised form of a container stack. # \param serialised The serialised form of a container stack.
# \param filename The name of the file to upgrade. # \param filename The name of the file to upgrade.
def upgradeStack(self, serialized, filename): def upgradeStack(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]:
parser = configparser.ConfigParser(interpolation = None) parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialized) parser.read_string(serialized)
@ -141,7 +142,7 @@ class VersionUpgrade32to33(VersionUpgrade):
## Upgrades non-quality-changes instance containers to have the new version ## Upgrades non-quality-changes instance containers to have the new version
# number. # number.
def upgradeInstanceContainer(self, serialized, filename): def upgradeInstanceContainer(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]:
parser = configparser.ConfigParser(interpolation = None) parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialized) parser.read_string(serialized)
@ -153,7 +154,7 @@ class VersionUpgrade32to33(VersionUpgrade):
return [filename], [result.getvalue()] return [filename], [result.getvalue()]
## Upgrades a quality changes container to the new format. ## Upgrades a quality changes container to the new format.
def upgradeQualityChanges(self, serialized, filename): def upgradeQualityChanges(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]:
parser = configparser.ConfigParser(interpolation = None) parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialized) parser.read_string(serialized)
@ -182,7 +183,7 @@ class VersionUpgrade32to33(VersionUpgrade):
return [filename], [result.getvalue()] return [filename], [result.getvalue()]
## Upgrades a variant container to the new format. ## Upgrades a variant container to the new format.
def upgradeVariants(self, serialized, filename): def upgradeVariants(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]:
parser = configparser.ConfigParser(interpolation = None) parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialized) parser.read_string(serialized)

View file

@ -1,11 +1,16 @@
# Copyright (c) 2018 Ultimaker B.V. # Copyright (c) 2018 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 Any, Dict, TYPE_CHECKING
from . import VersionUpgrade32to33 from . import VersionUpgrade32to33
if TYPE_CHECKING:
from UM.Application import Application
upgrade = VersionUpgrade32to33.VersionUpgrade32to33() upgrade = VersionUpgrade32to33.VersionUpgrade32to33()
def getMetaData(): def getMetaData() -> Dict[str, Any]:
return { return {
"version_upgrade": { "version_upgrade": {
# From To Upgrade function # From To Upgrade function
@ -51,5 +56,5 @@ def getMetaData():
} }
} }
def register(app): def register(app: "Application") -> Dict[str, Any]:
return { "version_upgrade": upgrade } return { "version_upgrade": upgrade }

View file

@ -3,17 +3,17 @@
import configparser #To parse preference files. import configparser #To parse preference files.
import io #To serialise the preference files afterwards. import io #To serialise the preference files afterwards.
from typing import Dict, List, Tuple
from UM.VersionUpgrade import VersionUpgrade #We're inheriting from this. from UM.VersionUpgrade import VersionUpgrade #We're inheriting from this.
_renamed_settings = { _renamed_settings = {
"infill_hollow": "infill_support_enabled" "infill_hollow": "infill_support_enabled"
} } # type: Dict[str, str]
## Upgrades configurations from the state they were in at version 3.3 to the ## Upgrades configurations from the state they were in at version 3.3 to the
# state they should be in at version 3.4. # state they should be in at version 3.4.
class VersionUpgrade33to34(VersionUpgrade): class VersionUpgrade33to34(VersionUpgrade):
## Gets the version number from a CFG file in Uranium's 3.3 format. ## Gets the version number from a CFG file in Uranium's 3.3 format.
# #
# Since the format may change, this is implemented for the 3.3 format only # Since the format may change, this is implemented for the 3.3 format only
@ -25,16 +25,16 @@ class VersionUpgrade33to34(VersionUpgrade):
# \raises ValueError The format of the version number in the file is # \raises ValueError The format of the version number in the file is
# incorrect. # incorrect.
# \raises KeyError The format of the file is incorrect. # \raises KeyError The format of the file is incorrect.
def getCfgVersion(self, serialised): def getCfgVersion(self, serialised: str) -> int:
parser = configparser.ConfigParser(interpolation = None) parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialised) parser.read_string(serialised)
format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised. format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised.
setting_version = int(parser.get("metadata", "setting_version", fallback = 0)) setting_version = int(parser.get("metadata", "setting_version", fallback = "0"))
return format_version * 1000000 + setting_version return format_version * 1000000 + setting_version
## Upgrades instance containers to have the new version ## Upgrades instance containers to have the new version
# number. # number.
def upgradeInstanceContainer(self, serialized, filename): def upgradeInstanceContainer(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]:
parser = configparser.ConfigParser(interpolation = None) parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialized) parser.read_string(serialized)

View file

@ -1,11 +1,16 @@
# Copyright (c) 2018 Ultimaker B.V. # Copyright (c) 2018 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 Any, Dict, TYPE_CHECKING
from . import VersionUpgrade33to34 from . import VersionUpgrade33to34
if TYPE_CHECKING:
from UM.Application import Application
upgrade = VersionUpgrade33to34.VersionUpgrade33to34() upgrade = VersionUpgrade33to34.VersionUpgrade33to34()
def getMetaData(): def getMetaData() -> Dict[str, Any]:
return { return {
"version_upgrade": { "version_upgrade": {
# From To Upgrade function # From To Upgrade function
@ -35,5 +40,5 @@ def getMetaData():
} }
def register(app): def register(app: "Application") -> Dict[str, Any]:
return { "version_upgrade": upgrade } return { "version_upgrade": upgrade }

View file

@ -3,13 +3,14 @@
import configparser import configparser
import io import io
from typing import Dict, List, Set, Tuple
from UM.VersionUpgrade import VersionUpgrade from UM.VersionUpgrade import VersionUpgrade
deleted_settings = {"prime_tower_wall_thickness", "dual_pre_wipe", "prime_tower_purge_volume"} deleted_settings = {"prime_tower_wall_thickness", "dual_pre_wipe", "prime_tower_purge_volume"} # type: Set[str]
changed_settings = {'retraction_combing': 'noskin'} changed_settings = {"retraction_combing": "noskin"} # type: Dict[str, str]
updated_settings = {'retraction_combing': 'infill'} updated_settings = {"retraction_combing": "infill"} # type: Dict[str, str]
_RENAMED_MATERIAL_PROFILES = { _RENAMED_MATERIAL_PROFILES = {
"dsm_arnitel2045_175_cartesio_0.25_mm": "dsm_arnitel2045_175_cartesio_0.25mm_thermoplastic_extruder", "dsm_arnitel2045_175_cartesio_0.25_mm": "dsm_arnitel2045_175_cartesio_0.25mm_thermoplastic_extruder",
@ -57,12 +58,11 @@ _RENAMED_MATERIAL_PROFILES = {
"ultimaker_pva_cartesio_0.25_mm": "ultimaker_pva_cartesio_0.25mm_thermoplastic_extruder", "ultimaker_pva_cartesio_0.25_mm": "ultimaker_pva_cartesio_0.25mm_thermoplastic_extruder",
"ultimaker_pva_cartesio_0.4_mm": "ultimaker_pva_cartesio_0.4mm_thermoplastic_extruder", "ultimaker_pva_cartesio_0.4_mm": "ultimaker_pva_cartesio_0.4mm_thermoplastic_extruder",
"ultimaker_pva_cartesio_0.8_mm": "ultimaker_pva_cartesio_0.8mm_thermoplastic_extruder" "ultimaker_pva_cartesio_0.8_mm": "ultimaker_pva_cartesio_0.8mm_thermoplastic_extruder"
} } # type: Dict[str, str]
## Upgrades configurations from the state they were in at version 3.4 to the ## Upgrades configurations from the state they were in at version 3.4 to the
# state they should be in at version 3.5. # state they should be in at version 3.5.
class VersionUpgrade34to35(VersionUpgrade): class VersionUpgrade34to35(VersionUpgrade):
## Gets the version number from a CFG file in Uranium's 3.3 format. ## Gets the version number from a CFG file in Uranium's 3.3 format.
# #
# Since the format may change, this is implemented for the 3.3 format only # Since the format may change, this is implemented for the 3.3 format only
@ -74,15 +74,15 @@ class VersionUpgrade34to35(VersionUpgrade):
# \raises ValueError The format of the version number in the file is # \raises ValueError The format of the version number in the file is
# incorrect. # incorrect.
# \raises KeyError The format of the file is incorrect. # \raises KeyError The format of the file is incorrect.
def getCfgVersion(self, serialised): def getCfgVersion(self, serialised: str) -> int:
parser = configparser.ConfigParser(interpolation = None) parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialised) parser.read_string(serialised)
format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised. format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised.
setting_version = int(parser.get("metadata", "setting_version", fallback = 0)) setting_version = int(parser.get("metadata", "setting_version", fallback = "0"))
return format_version * 1000000 + setting_version return format_version * 1000000 + setting_version
## Upgrades Preferences to have the new version number. ## Upgrades Preferences to have the new version number.
def upgradePreferences(self, serialized, filename): def upgradePreferences(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]:
parser = configparser.ConfigParser(interpolation = None) parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialized) parser.read_string(serialized)
@ -103,7 +103,7 @@ class VersionUpgrade34to35(VersionUpgrade):
return [filename], [result.getvalue()] return [filename], [result.getvalue()]
## Upgrades stacks to have the new version number. ## Upgrades stacks to have the new version number.
def upgradeStack(self, serialized, filename): def upgradeStack(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]:
parser = configparser.ConfigParser(interpolation = None) parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialized) parser.read_string(serialized)
@ -121,7 +121,7 @@ class VersionUpgrade34to35(VersionUpgrade):
## Upgrades instance containers to have the new version ## Upgrades instance containers to have the new version
# number. # number.
def upgradeInstanceContainer(self, serialized, filename): def upgradeInstanceContainer(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]:
parser = configparser.ConfigParser(interpolation = None) parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialized) parser.read_string(serialized)
@ -147,7 +147,7 @@ class VersionUpgrade34to35(VersionUpgrade):
parser.write(result) parser.write(result)
return [filename], [result.getvalue()] return [filename], [result.getvalue()]
def _resetConcentric3DInfillPattern(self, parser): def _resetConcentric3DInfillPattern(self, parser: configparser.ConfigParser) -> None:
if "values" not in parser: if "values" not in parser:
return return
@ -162,4 +162,3 @@ class VersionUpgrade34to35(VersionUpgrade):
continue continue
if parser["values"][key] == "concentric_3d": if parser["values"][key] == "concentric_3d":
del parser["values"][key] del parser["values"][key]

View file

@ -1,11 +1,16 @@
# Copyright (c) 2018 Ultimaker B.V. # Copyright (c) 2018 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 Any, Dict, TYPE_CHECKING
from . import VersionUpgrade34to35 from . import VersionUpgrade34to35
if TYPE_CHECKING:
from UM.Application import Application
upgrade = VersionUpgrade34to35.VersionUpgrade34to35() upgrade = VersionUpgrade34to35.VersionUpgrade34to35()
def getMetaData(): def getMetaData() -> Dict[str, Any]:
return { return {
"version_upgrade": { "version_upgrade": {
# From To Upgrade function # From To Upgrade function
@ -52,5 +57,5 @@ def getMetaData():
} }
def register(app): def register(app: "Application") -> Dict[str, Any]:
return { "version_upgrade": upgrade } return { "version_upgrade": upgrade }

View file

@ -189,7 +189,7 @@
"settable_per_mesh": false, "settable_per_mesh": false,
"settable_per_extruder": true, "settable_per_extruder": true,
"settable_per_meshgroup": false, "settable_per_meshgroup": false,
"setttable_globally": false "settable_globally": false
} }
} }
}, },