From 2db98c18cdf2480fb8a752e3f96e1fd1b8ed3354 Mon Sep 17 00:00:00 2001 From: THeijmans Date: Mon, 23 Apr 2018 17:07:31 +0200 Subject: [PATCH 01/34] PP formula based temperatures fix --- .../ultimaker3/um3_aa0.4_PP_Draft_Print.inst.cfg | 10 +++++----- .../ultimaker3/um3_aa0.4_PP_Fast_Print.inst.cfg | 10 +++++----- .../ultimaker3/um3_aa0.4_PP_Normal_Quality.inst.cfg | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/resources/quality/ultimaker3/um3_aa0.4_PP_Draft_Print.inst.cfg b/resources/quality/ultimaker3/um3_aa0.4_PP_Draft_Print.inst.cfg index 1db33d9073..1c9b29b0ec 100644 --- a/resources/quality/ultimaker3/um3_aa0.4_PP_Draft_Print.inst.cfg +++ b/resources/quality/ultimaker3/um3_aa0.4_PP_Draft_Print.inst.cfg @@ -30,11 +30,11 @@ line_width = =machine_nozzle_size * 0.95 machine_min_cool_heat_time_window = 15 machine_nozzle_cool_down_speed = 0.85 machine_nozzle_heat_up_speed = 1.5 -material_bed_temperature_layer_0 = 90 -material_final_print_temperature = 205 -material_initial_print_temperature = 210 -material_print_temperature = 215 -material_print_temperature_layer_0 = 220 +material_bed_temperature_layer_0 = =material_bed_temperature + 5 +material_final_print_temperature = =material_print_temperature - 10 +material_initial_print_temperature = =material_print_temperature - 5 +material_print_temperature = =default_material_print_temperature - 5 +material_print_temperature_layer_0 = =material_print_temperature + 5 material_standby_temperature = 100 multiple_mesh_overlap = 0 prime_tower_enable = False diff --git a/resources/quality/ultimaker3/um3_aa0.4_PP_Fast_Print.inst.cfg b/resources/quality/ultimaker3/um3_aa0.4_PP_Fast_Print.inst.cfg index fe7da92bbe..02b86b4eb5 100644 --- a/resources/quality/ultimaker3/um3_aa0.4_PP_Fast_Print.inst.cfg +++ b/resources/quality/ultimaker3/um3_aa0.4_PP_Fast_Print.inst.cfg @@ -30,11 +30,11 @@ line_width = =machine_nozzle_size * 0.95 machine_min_cool_heat_time_window = 15 machine_nozzle_cool_down_speed = 0.85 machine_nozzle_heat_up_speed = 1.5 -material_bed_temperature_layer_0 = 90 -material_final_print_temperature = 195 -material_initial_print_temperature = 205 -material_print_temperature = 207 -material_print_temperature_layer_0 = 210 +material_bed_temperature_layer_0 = =material_bed_temperature + 5 +material_final_print_temperature = =material_print_temperature - 12 +material_initial_print_temperature = =material_print_temperature - 2 +material_print_temperature = =default_material_print_temperature - 13 +material_print_temperature_layer_0 = =material_print_temperature + 3 material_standby_temperature = 100 multiple_mesh_overlap = 0 prime_tower_enable = False diff --git a/resources/quality/ultimaker3/um3_aa0.4_PP_Normal_Quality.inst.cfg b/resources/quality/ultimaker3/um3_aa0.4_PP_Normal_Quality.inst.cfg index 8bbb0118b5..20c30282cc 100644 --- a/resources/quality/ultimaker3/um3_aa0.4_PP_Normal_Quality.inst.cfg +++ b/resources/quality/ultimaker3/um3_aa0.4_PP_Normal_Quality.inst.cfg @@ -29,11 +29,11 @@ line_width = =machine_nozzle_size * 0.95 machine_min_cool_heat_time_window = 15 machine_nozzle_cool_down_speed = 0.85 machine_nozzle_heat_up_speed = 1.5 -material_bed_temperature_layer_0 = 90 -material_final_print_temperature = 195 -material_initial_print_temperature = 200 -material_print_temperature = 205 -material_print_temperature_layer_0 = 208 +material_bed_temperature_layer_0 = =material_bed_temperature + 5 +material_final_print_temperature = =material_print_temperature - 10 +material_initial_print_temperature = =material_print_temperature - 5 +material_print_temperature = =default_material_print_temperature - 15 +material_print_temperature_layer_0 = =material_print_temperature + 3 material_standby_temperature = 100 multiple_mesh_overlap = 0 prime_tower_enable = False From 352d32b116aaa26e90318233c46e4753e78783c0 Mon Sep 17 00:00:00 2001 From: THeijmans Date: Tue, 1 May 2018 09:31:54 +0200 Subject: [PATCH 02/34] Added 0.25mm temperature formulas --- .../ultimaker3/um3_aa0.25_PP_Normal_Quality.inst.cfg | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/resources/quality/ultimaker3/um3_aa0.25_PP_Normal_Quality.inst.cfg b/resources/quality/ultimaker3/um3_aa0.25_PP_Normal_Quality.inst.cfg index 6bdd94f58f..62a5c6dfa3 100644 --- a/resources/quality/ultimaker3/um3_aa0.25_PP_Normal_Quality.inst.cfg +++ b/resources/quality/ultimaker3/um3_aa0.25_PP_Normal_Quality.inst.cfg @@ -25,11 +25,11 @@ jerk_enabled = True jerk_print = 25 line_width = =machine_nozzle_size * 0.92 machine_min_cool_heat_time_window = 15 -material_bed_temperature_layer_0 = 90 -material_final_print_temperature = 195 -material_initial_print_temperature = 200 -material_print_temperature = 205 -material_print_temperature_layer_0 = 208 +material_bed_temperature_layer_0 = =material_bed_temperature + 5 +material_final_print_temperature = =material_print_temperature - 10 +material_initial_print_temperature = =material_print_temperature - 5 +material_print_temperature = =default_material_print_temperature - 15 +material_print_temperature_layer_0 = =material_print_temperature + 3 multiple_mesh_overlap = 0 prime_tower_enable = False prime_tower_size = 16 From c6823c1b911fa6493b3c29d89ab33588e85761de Mon Sep 17 00:00:00 2001 From: ChrisTerBeke Date: Tue, 1 May 2018 13:32:31 +0200 Subject: [PATCH 03/34] Ignore CuraDrivePlugin --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index a91d3f9377..c0cb27efe0 100644 --- a/.gitignore +++ b/.gitignore @@ -38,6 +38,7 @@ plugins/cura-god-mode-plugin plugins/cura-siemensnx-plugin plugins/CuraBlenderPlugin plugins/CuraCloudPlugin +plugins/CuraDrivePlugin plugins/CuraLiveScriptingPlugin plugins/CuraOpenSCADPlugin plugins/CuraPrintProfileCreator From ef436cafbb166e107f9fa90b1488d54a3ef98b89 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Wed, 2 May 2018 16:13:02 +0200 Subject: [PATCH 04/34] Improve thumbnail rendering --- plugins/Toolbox/resources/qml/ToolboxDownloadsGridTile.qml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/Toolbox/resources/qml/ToolboxDownloadsGridTile.qml b/plugins/Toolbox/resources/qml/ToolboxDownloadsGridTile.qml index e0e25982db..9e1a7c5a86 100644 --- a/plugins/Toolbox/resources/qml/ToolboxDownloadsGridTile.qml +++ b/plugins/Toolbox/resources/qml/ToolboxDownloadsGridTile.qml @@ -1,7 +1,7 @@ // Copyright (c) 2018 Ultimaker B.V. // Toolbox is released under the terms of the LGPLv3 or higher. -import QtQuick 2.2 +import QtQuick 2.3 import QtQuick.Controls 1.4 import QtQuick.Controls.Styles 1.4 import QtQuick.Layouts 1.3 @@ -38,6 +38,7 @@ Item height: UM.Theme.getSize("toolbox_thumbnail_small").height - 26 fillMode: Image.PreserveAspectFit source: model.icon_url || "../images/logobot.svg" + mipmap: true } } Column From 3d0a0da035c5199c26c52a68530772e6d149e00b Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Wed, 2 May 2018 16:22:19 +0200 Subject: [PATCH 05/34] Fix text rendering on some OSX systems --- plugins/Toolbox/resources/qml/ToolboxFooter.qml | 2 +- plugins/Toolbox/resources/qml/ToolboxInstalledTile.qml | 2 +- plugins/Toolbox/resources/qml/ToolboxTabButton.qml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/Toolbox/resources/qml/ToolboxFooter.qml b/plugins/Toolbox/resources/qml/ToolboxFooter.qml index 098a52d49a..b83d14a08b 100644 --- a/plugins/Toolbox/resources/qml/ToolboxFooter.qml +++ b/plugins/Toolbox/resources/qml/ToolboxFooter.qml @@ -49,7 +49,7 @@ Item implicitHeight: Math.floor(UM.Theme.getSize("toolbox_footer_button").height) color: control.hovered ? UM.Theme.getColor("primary_hover") : UM.Theme.getColor("primary") } - label: Text + label: Label { color: UM.Theme.getColor("button_text") font: UM.Theme.getFont("default_bold") diff --git a/plugins/Toolbox/resources/qml/ToolboxInstalledTile.qml b/plugins/Toolbox/resources/qml/ToolboxInstalledTile.qml index ff27e004b2..2389cca7e7 100644 --- a/plugins/Toolbox/resources/qml/ToolboxInstalledTile.qml +++ b/plugins/Toolbox/resources/qml/ToolboxInstalledTile.qml @@ -130,7 +130,7 @@ Item color: UM.Theme.getColor("lining") } } - label: Text + label: Label { text: control.text color: UM.Theme.getColor("text") diff --git a/plugins/Toolbox/resources/qml/ToolboxTabButton.qml b/plugins/Toolbox/resources/qml/ToolboxTabButton.qml index a61e77d241..0f759c75fb 100644 --- a/plugins/Toolbox/resources/qml/ToolboxTabButton.qml +++ b/plugins/Toolbox/resources/qml/ToolboxTabButton.qml @@ -25,7 +25,7 @@ Button height: UM.Theme.getSize("sidebar_header_highlight").height } } - label: Text + label: Label { text: control.text color: From a3436bb24b0fb50eef089f070844f9928b765940 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Wed, 2 May 2018 16:25:27 +0200 Subject: [PATCH 06/34] Fix title color on dark theme --- plugins/Toolbox/resources/qml/ToolboxDetailPage.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/Toolbox/resources/qml/ToolboxDetailPage.qml b/plugins/Toolbox/resources/qml/ToolboxDetailPage.qml index 5a73bcc981..98cc396f91 100644 --- a/plugins/Toolbox/resources/qml/ToolboxDetailPage.qml +++ b/plugins/Toolbox/resources/qml/ToolboxDetailPage.qml @@ -56,6 +56,7 @@ Item } text: details.name font: UM.Theme.getFont("large") + color: UM.Theme.getColor("text") wrapMode: Text.WordWrap width: parent.width height: UM.Theme.getSize("toolbox_property_label").height From 132a1a19513aabbb395b07275eae39a92937cc96 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Wed, 2 May 2018 17:20:15 +0200 Subject: [PATCH 07/34] Fix binding loop errors --- plugins/Toolbox/resources/qml/ToolboxDetailTile.qml | 2 +- .../Toolbox/resources/qml/ToolboxDownloadsShowcaseTile.qml | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/Toolbox/resources/qml/ToolboxDetailTile.qml b/plugins/Toolbox/resources/qml/ToolboxDetailTile.qml index 6bad12236b..82b973609f 100644 --- a/plugins/Toolbox/resources/qml/ToolboxDetailTile.qml +++ b/plugins/Toolbox/resources/qml/ToolboxDetailTile.qml @@ -11,7 +11,7 @@ Item id: tile property bool installed: toolbox.isInstalled(model.id) width: detailList.width - UM.Theme.getSize("wide_margin").width - height: Math.max(UM.Theme.getSize("toolbox_detail_tile").height, childrenRect.height + UM.Theme.getSize("default_margin").height) + height: normalData.height + supportedConfigsChart.height + 3 * UM.Theme.getSize("default_margin").height Item { id: normalData diff --git a/plugins/Toolbox/resources/qml/ToolboxDownloadsShowcaseTile.qml b/plugins/Toolbox/resources/qml/ToolboxDownloadsShowcaseTile.qml index a699e9dae6..d6ba984774 100644 --- a/plugins/Toolbox/resources/qml/ToolboxDownloadsShowcaseTile.qml +++ b/plugins/Toolbox/resources/qml/ToolboxDownloadsShowcaseTile.qml @@ -9,7 +9,7 @@ import UM 1.1 as UM Item { width: UM.Theme.getSize("toolbox_thumbnail_large").width - height: childrenRect.height + height: thumbnail.height + packageName.height Rectangle { id: highlight @@ -44,10 +44,11 @@ Item } Label { + id: packageName text: model.name anchors { - bottom: parent.bottom + top: thumbnail.bottom horizontalCenter: parent.horizontalCenter } verticalAlignment: Text.AlignVCenter From ecbfae2f27523dacbbe2d7ec9c4f8125ac560f28 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Wed, 2 May 2018 17:22:00 +0200 Subject: [PATCH 08/34] Remove minimise button from toolbox dialog --- plugins/Toolbox/resources/qml/Toolbox.qml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/Toolbox/resources/qml/Toolbox.qml b/plugins/Toolbox/resources/qml/Toolbox.qml index cdbe2f0710..f7784ec7ce 100644 --- a/plugins/Toolbox/resources/qml/Toolbox.qml +++ b/plugins/Toolbox/resources/qml/Toolbox.qml @@ -12,6 +12,8 @@ Window property var selection: null title: catalog.i18nc("@title", "Toolbox") modality: Qt.ApplicationModal + flags: Qt.Dialog | Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowCloseButtonHint + width: 720 * screenScaleFactor height: 640 * screenScaleFactor minimumWidth: 720 * screenScaleFactor From d326e91008dc246494360421ba3ecdd02333096c Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Wed, 2 May 2018 17:54:48 +0200 Subject: [PATCH 09/34] Fix dpi scaling --- plugins/Toolbox/resources/qml/ToolboxDetailTile.qml | 4 ++-- plugins/Toolbox/resources/qml/ToolboxDownloadsGridTile.qml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/Toolbox/resources/qml/ToolboxDetailTile.qml b/plugins/Toolbox/resources/qml/ToolboxDetailTile.qml index 82b973609f..3888b314e0 100644 --- a/plugins/Toolbox/resources/qml/ToolboxDetailTile.qml +++ b/plugins/Toolbox/resources/qml/ToolboxDetailTile.qml @@ -79,8 +79,8 @@ Item { background: Rectangle { - implicitWidth: 96 - implicitHeight: 30 + implicitWidth: 96 * screenScaleFactor + implicitHeight: 30 * screenScaleFactor color: { if (installed) diff --git a/plugins/Toolbox/resources/qml/ToolboxDownloadsGridTile.qml b/plugins/Toolbox/resources/qml/ToolboxDownloadsGridTile.qml index 9e1a7c5a86..b1586e5c52 100644 --- a/plugins/Toolbox/resources/qml/ToolboxDownloadsGridTile.qml +++ b/plugins/Toolbox/resources/qml/ToolboxDownloadsGridTile.qml @@ -34,8 +34,8 @@ Item Image { anchors.centerIn: parent - width: UM.Theme.getSize("toolbox_thumbnail_small").width - 26 - height: UM.Theme.getSize("toolbox_thumbnail_small").height - 26 + width: UM.Theme.getSize("toolbox_thumbnail_small").width - UM.Theme.getSize("default_margin").width + height: UM.Theme.getSize("toolbox_thumbnail_small").height - UM.Theme.getSize("default_margin").width fillMode: Image.PreserveAspectFit source: model.icon_url || "../images/logobot.svg" mipmap: true From 1f542f176d4d42fe2d8a12f90f4e27e0f02676d9 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Wed, 2 May 2018 19:18:03 +0200 Subject: [PATCH 10/34] Fix some more image rendering occurrences --- plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml | 3 ++- plugins/Toolbox/resources/qml/ToolboxDetailPage.qml | 3 ++- plugins/Toolbox/resources/qml/ToolboxDownloadsShowcaseTile.qml | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml b/plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml index 6c87f9d2e2..06801b068a 100644 --- a/plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml +++ b/plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml @@ -1,7 +1,7 @@ // Copyright (c) 2018 Ultimaker B.V. // Toolbox is released under the terms of the LGPLv3 or higher. -import QtQuick 2.2 +import QtQuick 2.3 import QtQuick.Controls 1.4 import QtQuick.Controls.Styles 1.4 import UM 1.1 as UM @@ -32,6 +32,7 @@ Item height: UM.Theme.getSize("toolbox_thumbnail_medium").height fillMode: Image.PreserveAspectFit source: details.icon_url || "../images/logobot.svg" + mipmap: true anchors { top: parent.top diff --git a/plugins/Toolbox/resources/qml/ToolboxDetailPage.qml b/plugins/Toolbox/resources/qml/ToolboxDetailPage.qml index 98cc396f91..6af1c2e76e 100644 --- a/plugins/Toolbox/resources/qml/ToolboxDetailPage.qml +++ b/plugins/Toolbox/resources/qml/ToolboxDetailPage.qml @@ -1,7 +1,7 @@ // Copyright (c) 2018 Ultimaker B.V. // Toolbox is released under the terms of the LGPLv3 or higher. -import QtQuick 2.2 +import QtQuick 2.3 import QtQuick.Controls 1.4 import QtQuick.Controls.Styles 1.4 import UM 1.1 as UM @@ -33,6 +33,7 @@ Item height: UM.Theme.getSize("toolbox_thumbnail_medium").height fillMode: Image.PreserveAspectFit source: details.icon_url || "../images/logobot.svg" + mipmap: true anchors { top: parent.top diff --git a/plugins/Toolbox/resources/qml/ToolboxDownloadsShowcaseTile.qml b/plugins/Toolbox/resources/qml/ToolboxDownloadsShowcaseTile.qml index d6ba984774..f665404df7 100644 --- a/plugins/Toolbox/resources/qml/ToolboxDownloadsShowcaseTile.qml +++ b/plugins/Toolbox/resources/qml/ToolboxDownloadsShowcaseTile.qml @@ -1,7 +1,7 @@ // Copyright (c) 2018 Ultimaker B.V. // Toolbox is released under the terms of the LGPLv3 or higher. -import QtQuick 2.2 +import QtQuick 2.3 import QtQuick.Controls 1.4 import QtQuick.Controls.Styles 1.4 import UM 1.1 as UM @@ -40,6 +40,7 @@ Item height: UM.Theme.getSize("toolbox_thumbnail_large").height - 2 * UM.Theme.getSize("default_margin").height fillMode: Image.PreserveAspectFit source: model.icon_url || "../images/logobot.svg" + mipmap: true } } Label From 46e7a6665d0f314e922a86ae4c7cbd3d61d8c475 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Wed, 2 May 2018 19:20:52 +0200 Subject: [PATCH 11/34] Theme link colors --- plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml | 1 + plugins/Toolbox/resources/qml/ToolboxDetailPage.qml | 1 + plugins/Toolbox/resources/qml/ToolboxInstalledTile.qml | 1 + 3 files changed, 3 insertions(+) diff --git a/plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml b/plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml index 06801b068a..3858e2c122 100644 --- a/plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml +++ b/plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml @@ -115,6 +115,7 @@ Item } font: UM.Theme.getFont("very_small") color: UM.Theme.getColor("text") + linkColor: UM.Theme.getColor("text_link") onLinkActivated: Qt.openUrlExternally(link) } } diff --git a/plugins/Toolbox/resources/qml/ToolboxDetailPage.qml b/plugins/Toolbox/resources/qml/ToolboxDetailPage.qml index 6af1c2e76e..cee06bf9e2 100644 --- a/plugins/Toolbox/resources/qml/ToolboxDetailPage.qml +++ b/plugins/Toolbox/resources/qml/ToolboxDetailPage.qml @@ -135,6 +135,7 @@ Item } font: UM.Theme.getFont("very_small") color: UM.Theme.getColor("text") + linkColor: UM.Theme.getColor("text_link") onLinkActivated: Qt.openUrlExternally(link) } } diff --git a/plugins/Toolbox/resources/qml/ToolboxInstalledTile.qml b/plugins/Toolbox/resources/qml/ToolboxInstalledTile.qml index 2389cca7e7..0ed71845f5 100644 --- a/plugins/Toolbox/resources/qml/ToolboxInstalledTile.qml +++ b/plugins/Toolbox/resources/qml/ToolboxInstalledTile.qml @@ -89,6 +89,7 @@ Item horizontalAlignment: Text.AlignLeft onLinkActivated: Qt.openUrlExternally("mailto:" + model.author_email + "?Subject=Cura: " + model.name + " Plugin") color: model.enabled ? UM.Theme.getColor("text") : UM.Theme.getColor("lining") + linkColor: UM.Theme.getColor("text_link") } } Column From ca8b7bb1da1352336ef13a3a78f5e021cde588c2 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Wed, 2 May 2018 20:34:50 +0200 Subject: [PATCH 12/34] Fix QML warnings --- plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml | 6 +++--- plugins/Toolbox/resources/qml/ToolboxDetailPage.qml | 6 +++--- plugins/Toolbox/resources/qml/ToolboxLicenseDialog.qml | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml b/plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml index 3858e2c122..04b055ed66 100644 --- a/plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml +++ b/plugins/Toolbox/resources/qml/ToolboxAuthorPage.qml @@ -9,7 +9,7 @@ import UM 1.1 as UM Item { id: page - property var details: base.selection + property var details: base.selection || {} anchors.fill: parent ToolboxBackColumn { @@ -54,7 +54,7 @@ Item rightMargin: UM.Theme.getSize("wide_margin").width bottomMargin: UM.Theme.getSize("default_margin").height } - text: details.name + text: details.name || "" font: UM.Theme.getFont("large") wrapMode: Text.WordWrap width: parent.width @@ -63,7 +63,7 @@ Item Label { id: description - text: details.description + text: details.description || "" anchors { top: title.bottom diff --git a/plugins/Toolbox/resources/qml/ToolboxDetailPage.qml b/plugins/Toolbox/resources/qml/ToolboxDetailPage.qml index cee06bf9e2..c1419fb620 100644 --- a/plugins/Toolbox/resources/qml/ToolboxDetailPage.qml +++ b/plugins/Toolbox/resources/qml/ToolboxDetailPage.qml @@ -9,7 +9,7 @@ import UM 1.1 as UM Item { id: page - property var details: base.selection + property var details: base.selection || {} anchors.fill: parent width: parent.width ToolboxBackColumn @@ -55,7 +55,7 @@ Item rightMargin: UM.Theme.getSize("wide_margin").width bottomMargin: UM.Theme.getSize("default_margin").height } - text: details.name + text: details.name || "" font: UM.Theme.getFont("large") color: UM.Theme.getColor("text") wrapMode: Text.WordWrap @@ -106,7 +106,7 @@ Item spacing: Math.floor(UM.Theme.getSize("narrow_margin").height) Label { - text: details.version + text: details.version || "" font: UM.Theme.getFont("very_small") color: UM.Theme.getColor("text") } diff --git a/plugins/Toolbox/resources/qml/ToolboxLicenseDialog.qml b/plugins/Toolbox/resources/qml/ToolboxLicenseDialog.qml index 33bc466d29..b8baf7bc83 100644 --- a/plugins/Toolbox/resources/qml/ToolboxLicenseDialog.qml +++ b/plugins/Toolbox/resources/qml/ToolboxLicenseDialog.qml @@ -42,7 +42,7 @@ UM.Dialog anchors.right: parent.right anchors.topMargin: UM.Theme.getSize("default_margin").height readOnly: true - text: licenseDialog.licenseContent + text: licenseDialog.licenseContent || "" } } rightButtons: From 685b80fc3af65a54249147b2ab08afd28ea083d6 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Wed, 2 May 2018 21:56:23 +0200 Subject: [PATCH 13/34] Fix more QML warnings --- .../resources/qml/ToolboxCompatibilityChart.qml | 12 ++++++------ plugins/Toolbox/resources/qml/ToolboxDetailTile.qml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/Toolbox/resources/qml/ToolboxCompatibilityChart.qml b/plugins/Toolbox/resources/qml/ToolboxCompatibilityChart.qml index 1c58b46b96..4f5589d8d0 100644 --- a/plugins/Toolbox/resources/qml/ToolboxCompatibilityChart.qml +++ b/plugins/Toolbox/resources/qml/ToolboxCompatibilityChart.qml @@ -36,8 +36,8 @@ Item Label { anchors.verticalCenter: parent.verticalCenter - elide: styleData.elideMode - text: styleData.value + elide: styleData.elideMode || Text.ElideNone + text: styleData.value || "" color: UM.Theme.getColor("text") font: UM.Theme.getFont("default_bold") } @@ -55,8 +55,8 @@ Item Label { anchors.verticalCenter: parent.verticalCenter - elide: styleData.elideMode - text: styleData.value + elide: styleData.elideMode || Text.ElideNone + text: styleData.value || "" color: UM.Theme.getColor("text_medium") font: UM.Theme.getFont("default") } @@ -67,8 +67,8 @@ Item Label { anchors.verticalCenter: parent.verticalCenter - elide: styleData.elideMode - text: styleData.value + elide: styleData.elideMode || Text.ElideNone + text: styleData.value || "" color: UM.Theme.getColor("text_medium") font: UM.Theme.getFont("default") } diff --git a/plugins/Toolbox/resources/qml/ToolboxDetailTile.qml b/plugins/Toolbox/resources/qml/ToolboxDetailTile.qml index e93fdb646f..b50a7466e4 100644 --- a/plugins/Toolbox/resources/qml/ToolboxDetailTile.qml +++ b/plugins/Toolbox/resources/qml/ToolboxDetailTile.qml @@ -12,7 +12,7 @@ Item property bool installed: toolbox.isInstalled(model.id) property var packageData: model width: detailList.width - UM.Theme.getSize("wide_margin").width - height: normalData.height + supportedConfigsChart.height + 3 * UM.Theme.getSize("default_margin").height + height: normalData.height + compatibilityChart.height + 3 * UM.Theme.getSize("default_margin").height Item { id: normalData From c2c5228eeee985dca0f4d5b153679caa5234afb7 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Wed, 2 May 2018 23:19:13 +0200 Subject: [PATCH 14/34] Fix plugin details Previous fix for QML warnings broke the details display. --- plugins/Toolbox/resources/qml/ToolboxDetailPage.qml | 2 +- plugins/Toolbox/resources/qml/ToolboxDetailTile.qml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/Toolbox/resources/qml/ToolboxDetailPage.qml b/plugins/Toolbox/resources/qml/ToolboxDetailPage.qml index c35b9ff618..d57acac52d 100644 --- a/plugins/Toolbox/resources/qml/ToolboxDetailPage.qml +++ b/plugins/Toolbox/resources/qml/ToolboxDetailPage.qml @@ -9,7 +9,7 @@ import UM 1.1 as UM Item { id: page - property var details: base.selection || {} + property var details: base.selection anchors.fill: parent width: parent.width ToolboxBackColumn diff --git a/plugins/Toolbox/resources/qml/ToolboxDetailTile.qml b/plugins/Toolbox/resources/qml/ToolboxDetailTile.qml index b50a7466e4..a5982f8c43 100644 --- a/plugins/Toolbox/resources/qml/ToolboxDetailTile.qml +++ b/plugins/Toolbox/resources/qml/ToolboxDetailTile.qml @@ -12,7 +12,7 @@ Item property bool installed: toolbox.isInstalled(model.id) property var packageData: model width: detailList.width - UM.Theme.getSize("wide_margin").width - height: normalData.height + compatibilityChart.height + 3 * UM.Theme.getSize("default_margin").height + height: normalData.height + compatibilityChart.height + 4 * UM.Theme.getSize("default_margin").height Item { id: normalData From 65a6c751cde73b058c126478bc3b0e048a08f1cd Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Thu, 3 May 2018 09:29:04 +0200 Subject: [PATCH 15/34] Change attribute of the download request to follow redirects. That makes the download feature of the Toolbox compatible with Qt 5.8.2. --- plugins/Toolbox/src/Toolbox.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/Toolbox/src/Toolbox.py b/plugins/Toolbox/src/Toolbox.py index ea5a535196..2ffc48c8b6 100644 --- a/plugins/Toolbox/src/Toolbox.py +++ b/plugins/Toolbox/src/Toolbox.py @@ -300,7 +300,7 @@ class Toolbox(QObject, Extension): Logger.log("i", "Toolbox: Attempting to download & install package from %s.", url) url = QUrl(url) self._download_request = QNetworkRequest(url) - self._download_request.setAttribute(QNetworkRequest.RedirectPolicyAttribute, QNetworkRequest.NoLessSafeRedirectPolicy) + self._download_request.setAttribute(QNetworkRequest.FollowRedirectsAttribute, True) self._download_request.setRawHeader(*self._request_header) self._download_reply = self._network_manager.get(self._download_request) self.setDownloadProgress(0) From b62b68257069881a7a50c55313b23db014ed605f Mon Sep 17 00:00:00 2001 From: ChrisTerBeke Date: Thu, 3 May 2018 13:33:32 +0200 Subject: [PATCH 16/34] Make Qt network redirects work in both 5.8 and 5.9+ --- plugins/Toolbox/src/Toolbox.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/Toolbox/src/Toolbox.py b/plugins/Toolbox/src/Toolbox.py index a2a5b5fc34..718a205aa2 100644 --- a/plugins/Toolbox/src/Toolbox.py +++ b/plugins/Toolbox/src/Toolbox.py @@ -301,7 +301,12 @@ class Toolbox(QObject, Extension): Logger.log("i", "Toolbox: Attempting to download & install package from %s.", url) url = QUrl(url) self._download_request = QNetworkRequest(url) - self._download_request.setAttribute(QNetworkRequest.FollowRedirectsAttribute, True) + if hasattr(QNetworkRequest, "FollowRedirectsAttribute"): + # Patch for Qt 5.6-5.8 + self._download_request.setAttribute(QNetworkRequest.FollowRedirectsAttribute, True) + if hasattr(QNetworkRequest, "RedirectPolicyAttribute"): + # Patch for Qt 5.9+ + self._download_request.setAttribute(QNetworkRequest.RedirectPolicyAttribute, True) self._download_request.setRawHeader(*self._request_header) self._download_reply = self._network_manager.get(self._download_request) self.setDownloadProgress(0) From 80d7dc18cbb8dfc7b9d8899106d629389331fe53 Mon Sep 17 00:00:00 2001 From: ChrisTerBeke Date: Thu, 3 May 2018 13:37:33 +0200 Subject: [PATCH 17/34] Fix is_dir for Python 3.5 --- cura/CuraPackageManager.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cura/CuraPackageManager.py b/cura/CuraPackageManager.py index 4006cddd77..afc0fc2231 100644 --- a/cura/CuraPackageManager.py +++ b/cura/CuraPackageManager.py @@ -341,7 +341,8 @@ class CuraPackageManager(QObject): try: # Go through all the files and use the first successful read as the result for file_info in archive.infolist(): - if file_info.is_dir() or not file_info.filename.startswith("files/"): + is_dir = lambda file_info: file_info.filename.endswith('/') + if is_dir or not file_info.filename.startswith("files/"): continue filename_parts = os.path.basename(file_info.filename.lower()).split(".") From ce7f64d8e31675b61700d3cdd26ab24daa9d9bd5 Mon Sep 17 00:00:00 2001 From: Mark Date: Thu, 3 May 2018 14:36:08 +0200 Subject: [PATCH 18/34] ignore empty directories in plugin folder --- cura/CuraPackageManager.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cura/CuraPackageManager.py b/cura/CuraPackageManager.py index afc0fc2231..95232fb022 100644 --- a/cura/CuraPackageManager.py +++ b/cura/CuraPackageManager.py @@ -139,6 +139,9 @@ class CuraPackageManager(QObject): # Also get all bundled plugins all_metadata = self._plugin_registry.getAllMetaData() for item in all_metadata: + if item == {}: + continue + plugin_package_info = self.__convertPluginMetadataToPackageMetadata(item) # Only gather the bundled plugins here. package_id = plugin_package_info["package_id"] From 0d56d7276038362130b987ade0f96dbdabc9a136 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Thu, 3 May 2018 16:14:08 +0200 Subject: [PATCH 19/34] CURA-5234 Make use of the function to add wrong containers to the set. --- cura/Machines/MaterialManager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cura/Machines/MaterialManager.py b/cura/Machines/MaterialManager.py index c3c4430b00..719795ac45 100644 --- a/cura/Machines/MaterialManager.py +++ b/cura/Machines/MaterialManager.py @@ -220,7 +220,7 @@ class MaterialManager(QObject): else: # Add this container id to the wrong containers list in the registry Logger.log("w", "Not adding {id} to the material manager because the variant does not exist.".format(id = material_metadata["id"])) - self._container_registry.wrong_container_ids.append(material_metadata["id"]) + self._container_registry.addWrongContainerId(material_metadata["id"]) self.materialsUpdated.emit() From c5e9acf66417c64c8fd60a803940a9df0c9f5b1c Mon Sep 17 00:00:00 2001 From: Aleksei S Date: Thu, 3 May 2018 17:14:56 +0200 Subject: [PATCH 20/34] Fix: Manually added printer by ip address shows proper printer type CURA-5264 --- plugins/UM3NetworkPrinting/UM3OutputDevicePlugin.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/UM3NetworkPrinting/UM3OutputDevicePlugin.py b/plugins/UM3NetworkPrinting/UM3OutputDevicePlugin.py index 5a0d5fa275..2add388db6 100644 --- a/plugins/UM3NetworkPrinting/UM3OutputDevicePlugin.py +++ b/plugins/UM3NetworkPrinting/UM3OutputDevicePlugin.py @@ -189,10 +189,14 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): b"name": system_info["name"].encode("utf-8"), b"address": address.encode("utf-8"), b"firmware_version": system_info["firmware"].encode("utf-8"), - b"manual": b"true", - b"machine": system_info["variant"].encode("utf-8") + b"manual": b"true" } + if "hardware" in system_info and 'typeid' in system_info["hardware"]: + properties[b"machine"] = str(system_info['hardware']["typeid"]).encode("utf-8") + else: + properties[b"machine"] = system_info["variant"].encode("utf-8") + if has_cluster_capable_firmware: # Cluster needs an additional request, before it's completed. properties[b"incomplete"] = b"true" From a1e6792664af409b23e4aa754dadcfcd9731b64a Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Thu, 3 May 2018 18:03:30 +0200 Subject: [PATCH 21/34] Set the LocalContainerProvider as a required plugin. --- cura/CuraApplication.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 441b0153e5..d490b1cfbf 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -270,6 +270,7 @@ class CuraApplication(QtApplication): "PrepareStage", "MonitorStage", "LocalFileOutputDevice", + "LocalContainerProvider", # Views: "SimpleView", From defb22dc07077f88aa26a6b27464897785dce9d8 Mon Sep 17 00:00:00 2001 From: Aleksei S Date: Thu, 3 May 2018 18:11:45 +0200 Subject: [PATCH 22/34] Keep 'dot' in file name for type *.gcode.gz CURA-5323 --- cura/PrintInformation.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cura/PrintInformation.py b/cura/PrintInformation.py index 27c8c853b1..22f7ea5407 100644 --- a/cura/PrintInformation.py +++ b/cura/PrintInformation.py @@ -337,11 +337,16 @@ class PrintInformation(QObject): if is_gcode or is_project_file or (is_empty or (self._base_name == "" and self._base_name != name)): # Only take the file name part, Note : file name might have 'dot' in name as well if is_project_file: + # This is for .curaproject self._base_name = ".".join(filename_parts) elif len(filename_parts) > 1: - self._base_name = ".".join(filename_parts[0:-1]) + if "gcode" in filename_parts: + gcode_index = filename_parts.index('gcode') + self._base_name = ".".join(filename_parts[0:gcode_index]) + else: + self._base_name = name else: - self._base_name = filename_parts[0] + self._base_name = name self._updateJobName() From 7665f8a7cb008eaf3eadd1b1d06c4f2f1b4fa981 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 3 May 2018 20:22:38 +0200 Subject: [PATCH 23/34] Reading packages from archive now uses With context --- cura/CuraPackageManager.py | 57 +++++++++++++++++----------------- plugins/Toolbox/src/Toolbox.py | 9 ++---- 2 files changed, 31 insertions(+), 35 deletions(-) diff --git a/cura/CuraPackageManager.py b/cura/CuraPackageManager.py index 95232fb022..a789e0d63f 100644 --- a/cura/CuraPackageManager.py +++ b/cura/CuraPackageManager.py @@ -190,6 +190,8 @@ class CuraPackageManager(QObject): try: # Get package information package_info = self.getPackageInfo(filename) + if not package_info: + return package_id = package_info["package_id"] # Check the delayed installation and removal lists first @@ -282,30 +284,28 @@ class CuraPackageManager(QObject): self._purgePackage(package_id) # Install the package - archive = zipfile.ZipFile(filename, "r") + with zipfile.ZipFile(filename, "r") as archive: - temp_dir = tempfile.TemporaryDirectory() - archive.extractall(temp_dir.name) + temp_dir = tempfile.TemporaryDirectory() + archive.extractall(temp_dir.name) - from cura.CuraApplication import CuraApplication - installation_dirs_dict = { - "materials": Resources.getStoragePath(CuraApplication.ResourceTypes.MaterialInstanceContainer), - "quality": Resources.getStoragePath(CuraApplication.ResourceTypes.QualityInstanceContainer), - "plugins": os.path.abspath(Resources.getStoragePath(Resources.Plugins)), - } + from cura.CuraApplication import CuraApplication + installation_dirs_dict = { + "materials": Resources.getStoragePath(CuraApplication.ResourceTypes.MaterialInstanceContainer), + "quality": Resources.getStoragePath(CuraApplication.ResourceTypes.QualityInstanceContainer), + "plugins": os.path.abspath(Resources.getStoragePath(Resources.Plugins)), + } - for sub_dir_name, installation_root_dir in installation_dirs_dict.items(): - src_dir_path = os.path.join(temp_dir.name, "files", sub_dir_name) - dst_dir_path = os.path.join(installation_root_dir, package_id) + for sub_dir_name, installation_root_dir in installation_dirs_dict.items(): + src_dir_path = os.path.join(temp_dir.name, "files", sub_dir_name) + dst_dir_path = os.path.join(installation_root_dir, package_id) - if not os.path.exists(src_dir_path): - continue + if not os.path.exists(src_dir_path): + continue - # Need to rename the container files so they don't get ID conflicts - to_rename_files = sub_dir_name not in ("plugins",) - self.__installPackageFiles(package_id, src_dir_path, dst_dir_path, need_to_rename_files= to_rename_files) - - archive.close() + # Need to rename the container files so they don't get ID conflicts + to_rename_files = sub_dir_name not in ("plugins",) + self.__installPackageFiles(package_id, src_dir_path, dst_dir_path, need_to_rename_files= to_rename_files) # Remove the file os.remove(filename) @@ -325,16 +325,15 @@ class CuraPackageManager(QObject): # Gets package information from the given file. def getPackageInfo(self, filename: str) -> dict: - archive = zipfile.ZipFile(filename, "r") - try: - # All information is in package.json - with archive.open("package.json", "r") as f: - package_info_dict = json.loads(f.read().decode("utf-8")) - return package_info_dict - except Exception as e: - raise RuntimeError("Could not get package information from file '%s': %s" % (filename, e)) - finally: - archive.close() + with zipfile.ZipFile(filename, "r") as archive: + try: + # All information is in package.json + with archive.open("package.json", "r") as f: + package_info_dict = json.loads(f.read().decode("utf-8")) + return package_info_dict + except Exception as e: + Logger.logException("Could not get package information from file '%s': %s" % (filename, e)) + return {} # Gets the license file content if present in the given package file. # Returns None if there is no license file found. diff --git a/plugins/Toolbox/src/Toolbox.py b/plugins/Toolbox/src/Toolbox.py index 718a205aa2..b1775e3116 100644 --- a/plugins/Toolbox/src/Toolbox.py +++ b/plugins/Toolbox/src/Toolbox.py @@ -420,10 +420,9 @@ class Toolbox(QObject, Extension): def _onDownloadComplete(self, file_path: str): Logger.log("i", "Toolbox: Download complete.") - try: - package_info = self._package_manager.getPackageInfo(file_path) - except: - Logger.logException("w", "Toolbox: Package file [%s] was not a valid CuraPackage.", file_path) + package_info = self._package_manager.getPackageInfo(file_path) + if not package_info: + Logger.log("w", "Toolbox: Package file [%s] was not a valid CuraPackage.", file_path) return license_content = self._package_manager.getPackageLicense(file_path) @@ -434,8 +433,6 @@ class Toolbox(QObject, Extension): self.install(file_path) return - - # Getter & Setters for Properties: # -------------------------------------------------------------------------- def setDownloadProgress(self, progress: int): From f3be394080d9e7d11fe3a2904c84a7d6d33150fc Mon Sep 17 00:00:00 2001 From: Ruben D Date: Thu, 3 May 2018 20:23:14 +0200 Subject: [PATCH 24/34] Properly get the application Why are we getting this passed via parent??? --- cura/CuraPackageManager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cura/CuraPackageManager.py b/cura/CuraPackageManager.py index a789e0d63f..2f16a893ca 100644 --- a/cura/CuraPackageManager.py +++ b/cura/CuraPackageManager.py @@ -25,7 +25,7 @@ class CuraPackageManager(QObject): def __init__(self, parent = None): super().__init__(parent) - self._application = parent + self._application = Application.getInstance() self._container_registry = self._application.getContainerRegistry() self._plugin_registry = self._application.getPluginRegistry() From 21e2fcbcf6e45a272b3013c6442f7488c1314ea7 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 3 May 2018 20:27:02 +0200 Subject: [PATCH 25/34] Also added missing context usage of archive --- cura/CuraPackageManager.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/cura/CuraPackageManager.py b/cura/CuraPackageManager.py index a789e0d63f..2c63dac8fd 100644 --- a/cura/CuraPackageManager.py +++ b/cura/CuraPackageManager.py @@ -1,7 +1,7 @@ # Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. -from typing import Optional +from typing import Optional, Dict, Any import json import os import shutil @@ -324,23 +324,22 @@ class CuraPackageManager(QObject): os.rename(old_file_path, new_file_path) # Gets package information from the given file. - def getPackageInfo(self, filename: str) -> dict: - with zipfile.ZipFile(filename, "r") as archive: + def getPackageInfo(self, filename: str) -> Dict[str, Any]: + with zipfile.ZipFile(filename) as archive: try: # All information is in package.json - with archive.open("package.json", "r") as f: + with archive.open("package.json") as f: package_info_dict = json.loads(f.read().decode("utf-8")) return package_info_dict except Exception as e: - Logger.logException("Could not get package information from file '%s': %s" % (filename, e)) + Logger.logException("w", "Could not get package information from file '%s': %s" % (filename, e)) return {} # Gets the license file content if present in the given package file. # Returns None if there is no license file found. def getPackageLicense(self, filename: str) -> Optional[str]: license_string = None - archive = zipfile.ZipFile(filename) - try: + with zipfile.ZipFile(filename) as archive: # Go through all the files and use the first successful read as the result for file_info in archive.infolist(): is_dir = lambda file_info: file_info.filename.endswith('/') @@ -350,7 +349,7 @@ class CuraPackageManager(QObject): filename_parts = os.path.basename(file_info.filename.lower()).split(".") stripped_filename = filename_parts[0] if stripped_filename in ("license", "licence"): - Logger.log("i", "Found potential license file '%s'", file_info.filename) + Logger.log("d", "Found potential license file '%s'", file_info.filename) try: with archive.open(file_info.filename, "r") as f: data = f.read() @@ -360,8 +359,4 @@ class CuraPackageManager(QObject): Logger.logException("e", "Failed to load potential license file '%s' as text file.", file_info.filename) license_string = None - except Exception as e: - raise RuntimeError("Could not get package license from file '%s': %s" % (filename, e)) - finally: - archive.close() return license_string From 7d2257838bc6534696a69f14635d7c4ba77cd86a Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 3 May 2018 20:42:06 +0200 Subject: [PATCH 26/34] Added missing typing --- cura/CuraPackageManager.py | 1 + plugins/Toolbox/src/Toolbox.py | 72 +++++++++++++++++----------------- 2 files changed, 36 insertions(+), 37 deletions(-) diff --git a/cura/CuraPackageManager.py b/cura/CuraPackageManager.py index eeda26a7de..cecdfa4a0d 100644 --- a/cura/CuraPackageManager.py +++ b/cura/CuraPackageManager.py @@ -15,6 +15,7 @@ from UM.Logger import Logger from UM.Resources import Resources from UM.Version import Version + class CuraPackageManager(QObject): Version = 1 diff --git a/plugins/Toolbox/src/Toolbox.py b/plugins/Toolbox/src/Toolbox.py index b1775e3116..2f6f39d005 100644 --- a/plugins/Toolbox/src/Toolbox.py +++ b/plugins/Toolbox/src/Toolbox.py @@ -1,7 +1,7 @@ # Copyright (c) 2018 Ultimaker B.V. # Toolbox is released under the terms of the LGPLv3 or higher. -from typing import Dict +from typing import Dict, Optional, Union, Any import json import os import tempfile @@ -25,9 +25,10 @@ from .ConfigsModel import ConfigsModel i18n_catalog = i18nCatalog("cura") + ## The Toolbox class is responsible of communicating with the server through the API class Toolbox(QObject, Extension): - def __init__(self, parent=None): + def __init__(self, parent=None) -> None: super().__init__(parent) self._application = Application.getInstance() @@ -142,7 +143,7 @@ class Toolbox(QObject, Extension): def getLicenseDialogLicenseContent(self) -> str: return self._license_dialog_license_content - def openLicenseDialog(self, plugin_name: str, license_content: str, plugin_file_location: str): + def openLicenseDialog(self, plugin_name: str, license_content: str, plugin_file_location: str) -> None: self._license_dialog_plugin_name = plugin_name self._license_dialog_license_content = license_content self._license_dialog_plugin_file_location = plugin_file_location @@ -150,11 +151,11 @@ class Toolbox(QObject, Extension): # This is a plugin, so most of the components required are not ready when # this is initialized. Therefore, we wait until the application is ready. - def _onAppInitialized(self): + def _onAppInitialized(self) -> None: self._package_manager = Application.getInstance().getCuraPackageManager() @pyqtSlot() - def browsePackages(self): + def browsePackages(self) -> None: # Create the network manager: # This was formerly its own function but really had no reason to be as # it was never called more than once ever. @@ -181,14 +182,14 @@ class Toolbox(QObject, Extension): # Apply enabled/disabled state to installed plugins self.enabledChanged.emit() - def _createDialog(self, qml_name: str): + def _createDialog(self, qml_name: str) -> Optional[QObject]: Logger.log("d", "Toolbox: Creating dialog [%s].", qml_name) path = os.path.join(PluginRegistry.getInstance().getPluginPath(self.getPluginId()), "resources", "qml", qml_name) dialog = Application.getInstance().createQmlComponent(path, {"toolbox": self}) return dialog @pyqtSlot() - def _updateInstalledModels(self): + def _updateInstalledModels(self) -> None: all_packages = self._package_manager.getAllInstalledPackagesInfo() if "plugin" in all_packages: self._metadata["plugins_installed"] = all_packages["plugin"] @@ -200,7 +201,7 @@ class Toolbox(QObject, Extension): self.metadataChanged.emit() @pyqtSlot(str) - def install(self, file_path: str): + def install(self, file_path: str) -> None: self._package_manager.installPackage(file_path) self.installChanged.emit() self._updateInstalledModels() @@ -209,7 +210,7 @@ class Toolbox(QObject, Extension): self.restartRequiredChanged.emit() @pyqtSlot(str) - def uninstall(self, plugin_id: str): + def uninstall(self, plugin_id: str) -> None: self._package_manager.removePackage(plugin_id) self.installChanged.emit() self._updateInstalledModels() @@ -218,7 +219,7 @@ class Toolbox(QObject, Extension): self.restartRequiredChanged.emit() @pyqtSlot(str) - def enable(self, plugin_id: str): + def enable(self, plugin_id: str) -> None: self._plugin_registry.enablePlugin(plugin_id) self.enabledChanged.emit() Logger.log("i", "%s was set as 'active'.", plugin_id) @@ -226,7 +227,7 @@ class Toolbox(QObject, Extension): self.restartRequiredChanged.emit() @pyqtSlot(str) - def disable(self, plugin_id: str): + def disable(self, plugin_id: str) -> None: self._plugin_registry.disablePlugin(plugin_id) self.enabledChanged.emit() Logger.log("i", "%s was set as 'deactive'.", plugin_id) @@ -234,11 +235,11 @@ class Toolbox(QObject, Extension): self.restartRequiredChanged.emit() @pyqtProperty(bool, notify = metadataChanged) - def dataReady(self): + def dataReady(self) -> bool: return self._packages_model is not None @pyqtProperty(bool, notify = restartRequiredChanged) - def restartRequired(self): + def restartRequired(self) -> bool: return self._restart_required @pyqtSlot() @@ -246,8 +247,6 @@ class Toolbox(QObject, Extension): self._package_manager._removeAllScheduledPackages() CuraApplication.getInstance().windowClosed() - - # Checks # -------------------------------------------------------------------------- @pyqtSlot(str, result = bool) @@ -286,18 +285,16 @@ class Toolbox(QObject, Extension): return True return False - - # Make API Calls # -------------------------------------------------------------------------- - def _makeRequestByType(self, type: str): + def _makeRequestByType(self, type: str) -> None: Logger.log("i", "Toolbox: Requesting %s metadata from server.", type) request = QNetworkRequest(self._request_urls[type]) request.setRawHeader(*self._request_header) self._network_manager.get(request) @pyqtSlot(str) - def startDownload(self, url: str): + def startDownload(self, url: str) -> None: Logger.log("i", "Toolbox: Attempting to download & install package from %s.", url) url = QUrl(url) self._download_request = QNetworkRequest(url) @@ -314,12 +311,11 @@ class Toolbox(QObject, Extension): self._download_reply.downloadProgress.connect(self._onDownloadProgress) @pyqtSlot() - def cancelDownload(self): + def cancelDownload(self) -> None: Logger.log("i", "Toolbox: User cancelled the download of a plugin.") self.resetDownload() - return - def resetDownload(self): + def resetDownload(self) -> None: if self._download_reply: self._download_reply.abort() self._download_reply.downloadProgress.disconnect(self._onDownloadProgress) @@ -328,15 +324,13 @@ class Toolbox(QObject, Extension): self.setDownloadProgress(0) self.setIsDownloading(False) - - # Handlers for Network Events # -------------------------------------------------------------------------- - def _onNetworkAccessibleChanged(self, accessible: int): + def _onNetworkAccessibleChanged(self, accessible: int) -> None: if accessible == 0: self.resetDownload() - def _onRequestFinished(self, reply: QNetworkReply): + def _onRequestFinished(self, reply: QNetworkReply) -> None: if reply.error() == QNetworkReply.TimeoutError: Logger.log("w", "Got a timeout.") @@ -402,21 +396,20 @@ class Toolbox(QObject, Extension): # Ignore any operation that is not a get operation pass - def _onDownloadProgress(self, bytes_sent: int, bytes_total: int): + def _onDownloadProgress(self, bytes_sent: int, bytes_total: int) -> None: if bytes_total > 0: new_progress = bytes_sent / bytes_total * 100 self.setDownloadProgress(new_progress) if bytes_sent == bytes_total: self.setIsDownloading(False) self._download_reply.downloadProgress.disconnect(self._onDownloadProgress) - # must not delete the temporary file on Windows + # None: if progress != self._download_progress: self._download_progress = progress self.onDownloadProgressChanged.emit() + @pyqtProperty(int, fset = setDownloadProgress, notify = onDownloadProgressChanged) def downloadProgress(self) -> int: return self._download_progress - def setIsDownloading(self, is_downloading: bool): + def setIsDownloading(self, is_downloading: bool) -> None: if self._is_downloading != is_downloading: self._is_downloading = is_downloading self.onIsDownloadingChanged.emit() + @pyqtProperty(bool, fset = setIsDownloading, notify = onIsDownloadingChanged) def isDownloading(self) -> bool: return self._is_downloading - def setActivePackage(self, package: dict): + def setActivePackage(self, package: Dict[str, Any]) -> None: self._active_package = package self.activePackageChanged.emit() - @pyqtProperty(QObject, fset = setActivePackage, notify = activePackageChanged) - def activePackage(self) -> dict: + + @pyqtProperty("QVariantMap", fset = setActivePackage, notify = activePackageChanged) + def activePackage(self) -> Optional[Dict[str, Any]]: return self._active_package - def setViewCategory(self, category: str = "plugin"): + def setViewCategory(self, category: str = "plugin") -> None: self._view_category = category self.viewChanged.emit() + @pyqtProperty(str, fset = setViewCategory, notify = viewChanged) def viewCategory(self) -> str: return self._view_category - def setViewPage(self, page: str = "overview"): + def setViewPage(self, page: str = "overview") -> None: self._view_page = page self.viewChanged.emit() + @pyqtProperty(str, fset = setViewPage, notify = viewChanged) def viewPage(self) -> str: return self._view_page From 7c80bc203cad0b7b9c2004e8895ae9d8fe763aa2 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 3 May 2018 21:14:06 +0200 Subject: [PATCH 27/34] Fixed bunch of wrong / missing typing --- cura/Settings/MachineManager.py | 103 +++++++++++++++++--------------- 1 file changed, 54 insertions(+), 49 deletions(-) diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index 14f4f5fc33..436f9814db 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -7,6 +7,8 @@ import time from typing import List, Dict, TYPE_CHECKING, Optional from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator +from UM.Settings.InstanceContainer import InstanceContainer +from UM.Settings.Interfaces import ContainerInterface from UM.Signal import Signal from PyQt5.QtCore import QObject, pyqtProperty, pyqtSignal, QTimer @@ -28,6 +30,7 @@ from cura.PrinterOutput.ConfigurationModel import ConfigurationModel from cura.PrinterOutput.ExtruderConfigurationModel import ExtruderConfigurationModel from cura.PrinterOutput.MaterialOutputModel import MaterialOutputModel from cura.Settings.ExtruderManager import ExtruderManager +from cura.Settings.ExtruderStack import ExtruderStack from .CuraStackBuilder import CuraStackBuilder @@ -38,16 +41,15 @@ if TYPE_CHECKING: from cura.Settings.CuraContainerStack import CuraContainerStack from cura.Settings.GlobalStack import GlobalStack - class MachineManager(QObject): def __init__(self, parent = None): super().__init__(parent) - self._active_container_stack = None # type: CuraContainerStack - self._global_container_stack = None # type: GlobalStack + self._active_container_stack = None # type: Optional[ExtruderManager] + self._global_container_stack = None # type: Optional[GlobalStack] - self._current_root_material_id = {} + self._current_root_material_id = {} # type: Dict[str, str] self._current_quality_group = None self._current_quality_changes_group = None @@ -62,7 +64,7 @@ class MachineManager(QObject): self._application = Application.getInstance() self._application.globalContainerStackChanged.connect(self._onGlobalContainerChanged) - self._application.getContainerRegistry().containerLoadComplete.connect(self._onInstanceContainersChanged) + self._application.getContainerRegistry().containerLoadComplete.connect(self._onContainersChanged) ## When the global container is changed, active material probably needs to be updated. self.globalContainerChanged.connect(self.activeMaterialChanged) @@ -99,7 +101,7 @@ class MachineManager(QObject): self._global_event_keys = set() - self._printer_output_devices = [] + self._printer_output_devices = [] # type: List[PrinterOutputDevice] Application.getInstance().getOutputDeviceManager().outputDevicesChanged.connect(self._onOutputDevicesChanged) # There might already be some output devices by the time the signal is connected self._onOutputDevicesChanged() @@ -160,7 +162,7 @@ class MachineManager(QObject): rootMaterialChanged = pyqtSignal() - def setInitialActiveMachine(self): + def setInitialActiveMachine(self) -> None: active_machine_id = Preferences.getInstance().getValue("cura/active_machine") if active_machine_id != "" and ContainerRegistry.getInstance().findContainerStacksMetadata(id = active_machine_id): # An active machine was saved, so restore it. @@ -177,7 +179,7 @@ class MachineManager(QObject): self.outputDevicesChanged.emit() @pyqtProperty(QObject, notify = currentConfigurationChanged) - def currentConfiguration(self): + def currentConfiguration(self) -> ConfigurationModel: return self._current_printer_configuration def _onCurrentConfigurationChanged(self) -> None: @@ -210,7 +212,7 @@ class MachineManager(QObject): return self._current_printer_configuration == configuration @pyqtProperty("QVariantList", notify = outputDevicesChanged) - def printerOutputDevices(self): + def printerOutputDevices(self) -> List[PrinterOutputDevice]: return self._printer_output_devices @pyqtProperty(int, constant=True) @@ -224,7 +226,7 @@ class MachineManager(QObject): except TypeError: # pyQtSignal gives a TypeError when disconnecting from something that was already disconnected. pass try: - self._global_container_stack.containersChanged.disconnect(self._onInstanceContainersChanged) + self._global_container_stack.containersChanged.disconnect(self._onContainersChanged) except TypeError: pass try: @@ -234,7 +236,7 @@ class MachineManager(QObject): for extruder_stack in ExtruderManager.getInstance().getActiveExtruderStacks(): extruder_stack.propertyChanged.disconnect(self._onPropertyChanged) - extruder_stack.containersChanged.disconnect(self._onInstanceContainersChanged) + extruder_stack.containersChanged.disconnect(self._onContainersChanged) # Update the local global container stack reference self._global_container_stack = Application.getInstance().getGlobalContainerStack() @@ -248,7 +250,7 @@ class MachineManager(QObject): Preferences.getInstance().setValue("cura/active_machine", self._global_container_stack.getId()) self._global_container_stack.nameChanged.connect(self._onMachineNameChanged) - self._global_container_stack.containersChanged.connect(self._onInstanceContainersChanged) + self._global_container_stack.containersChanged.connect(self._onContainersChanged) self._global_container_stack.propertyChanged.connect(self._onPropertyChanged) # Global stack can have only a variant if it is a buildplate @@ -265,7 +267,7 @@ class MachineManager(QObject): # Listen for changes on all extruder stacks for extruder_stack in ExtruderManager.getInstance().getActiveExtruderStacks(): extruder_stack.propertyChanged.connect(self._onPropertyChanged) - extruder_stack.containersChanged.connect(self._onInstanceContainersChanged) + extruder_stack.containersChanged.connect(self._onContainersChanged) if self._global_container_stack.getId() in self.machine_extruder_material_update_dict: for func in self.machine_extruder_material_update_dict[self._global_container_stack.getId()]: @@ -292,7 +294,7 @@ class MachineManager(QObject): self.rootMaterialChanged.emit() - def _onInstanceContainersChanged(self, container) -> None: + def _onContainersChanged(self, container: ContainerInterface) -> None: self._instance_container_timer.start() def _onPropertyChanged(self, key: str, property_name: str) -> None: @@ -301,7 +303,7 @@ class MachineManager(QObject): self.activeStackValueChanged.emit() ## Given a global_stack, make sure that it's all valid by searching for this quality group and applying it again - def _initMachineState(self, global_stack): + def _initMachineState(self, global_stack: "CuraContainerStack") -> None: material_dict = {} for position, extruder in global_stack.extruders.items(): material_dict[position] = extruder.material.getMetaDataEntry("base_file") @@ -620,7 +622,7 @@ class MachineManager(QObject): ## Copy the value of the setting of the current extruder to all other extruders as well as the global container. @pyqtSlot(str) - def copyValueToExtruders(self, key: str): + def copyValueToExtruders(self, key: str) -> None: new_value = self._active_container_stack.getProperty(key, "value") extruder_stacks = [stack for stack in ExtruderManager.getInstance().getMachineExtruders(self._global_container_stack.getId())] @@ -631,7 +633,7 @@ class MachineManager(QObject): ## Copy the value of all manually changed settings of the current extruder to all other extruders. @pyqtSlot() - def copyAllValuesToExtruders(self): + def copyAllValuesToExtruders(self) -> None: extruder_stacks = list(self._global_container_stack.extruders.values()) for extruder_stack in extruder_stacks: if extruder_stack != self._active_container_stack: @@ -685,7 +687,7 @@ class MachineManager(QObject): return fallback_title @pyqtSlot(str, str) - def renameMachine(self, machine_id: str, new_name: str): + def renameMachine(self, machine_id: str, new_name: str) -> None: container_registry = ContainerRegistry.getInstance() machine_stack = container_registry.findContainerStacks(id = machine_id) if machine_stack: @@ -694,7 +696,7 @@ class MachineManager(QObject): self.globalContainerChanged.emit() @pyqtSlot(str) - def removeMachine(self, machine_id: str): + def removeMachine(self, machine_id: str) -> None: # If the machine that is being removed is the currently active machine, set another machine as the active machine. activate_new_machine = (self._global_container_stack and self._global_container_stack.getId() == machine_id) @@ -791,9 +793,9 @@ class MachineManager(QObject): if containers: return containers[0].definition.getId() - def getIncompatibleSettingsOnEnabledExtruders(self, container): + def getIncompatibleSettingsOnEnabledExtruders(self, container: InstanceContainer) -> List[str]: extruder_count = self._global_container_stack.getProperty("machine_extruder_count", "value") - result = [] + result = [] # type: List[str] for setting_instance in container.findInstances(): setting_key = setting_instance.definition.key setting_enabled = self._global_container_stack.getProperty(setting_key, "enabled") @@ -815,7 +817,7 @@ class MachineManager(QObject): return result ## Update extruder number to a valid value when the number of extruders are changed, or when an extruder is changed - def correctExtruderSettings(self): + def correctExtruderSettings(self) -> None: for setting_key in self.getIncompatibleSettingsOnEnabledExtruders(self._global_container_stack.userChanges): self._global_container_stack.userChanges.removeInstance(setting_key) add_user_changes = self.getIncompatibleSettingsOnEnabledExtruders(self._global_container_stack.qualityChanges) @@ -832,7 +834,7 @@ class MachineManager(QObject): ## Set the amount of extruders on the active machine (global stack) # \param extruder_count int the number of extruders to set - def setActiveMachineExtruderCount(self, extruder_count): + def setActiveMachineExtruderCount(self, extruder_count: int) -> None: extruder_manager = Application.getInstance().getExtruderManager() definition_changes_container = self._global_container_stack.definitionChanges @@ -887,13 +889,13 @@ class MachineManager(QObject): self.forceUpdateAllSettings() @pyqtSlot(int, result = QObject) - def getExtruder(self, position: int): + def getExtruder(self, position: int) -> Optional[ExtruderStack]: extruder = None if self._global_container_stack: extruder = self._global_container_stack.extruders.get(str(position)) return extruder - def updateDefaultExtruder(self): + def updateDefaultExtruder(self) -> None: extruder_items = sorted(self._global_container_stack.extruders.items()) old_position = self._default_extruder_position new_default_position = "0" @@ -905,7 +907,7 @@ class MachineManager(QObject): self._default_extruder_position = new_default_position self.extruderChanged.emit() - def updateNumberExtrudersEnabled(self): + def updateNumberExtrudersEnabled(self) -> None: definition_changes_container = self._global_container_stack.definitionChanges machine_extruder_count = self._global_container_stack.getProperty("machine_extruder_count", "value") extruder_count = 0 @@ -917,16 +919,16 @@ class MachineManager(QObject): self.numberExtrudersEnabledChanged.emit() @pyqtProperty(int, notify = numberExtrudersEnabledChanged) - def numberExtrudersEnabled(self): + def numberExtrudersEnabled(self) -> int: return self._global_container_stack.definitionChanges.getProperty("extruders_enabled_count", "value") @pyqtProperty(str, notify = extruderChanged) - def defaultExtruderPosition(self): + def defaultExtruderPosition(self) -> str: return self._default_extruder_position ## This will fire the propertiesChanged for all settings so they will be updated in the front-end @pyqtSlot() - def forceUpdateAllSettings(self): + def forceUpdateAllSettings(self) -> None: with postponeSignals(*self._getContainerChangedSignals(), compress = CompressTechnique.CompressPerParameterValue): property_names = ["value", "resolve", "validationState"] for container in [self._global_container_stack] + list(self._global_container_stack.extruders.values()): @@ -934,8 +936,11 @@ class MachineManager(QObject): container.propertiesChanged.emit(setting_key, property_names) @pyqtSlot(int, bool) - def setExtruderEnabled(self, position: int, enabled) -> None: + def setExtruderEnabled(self, position: int, enabled: bool) -> None: extruder = self.getExtruder(position) + if not extruder: + Logger.log("w", "Could not find extruder on position %s", position) + extruder.setEnabled(enabled) self.updateDefaultExtruder() self.updateNumberExtrudersEnabled() @@ -952,13 +957,13 @@ class MachineManager(QObject): # Also trigger the build plate compatibility to update self.activeMaterialChanged.emit() - def _onMachineNameChanged(self): + def _onMachineNameChanged(self) -> None: self.globalContainerChanged.emit() - def _onMaterialNameChanged(self): + def _onMaterialNameChanged(self) -> None: self.activeMaterialChanged.emit() - def _onQualityNameChanged(self): + def _onQualityNameChanged(self) -> None: self.activeQualityChanged.emit() def _getContainerChangedSignals(self) -> List[Signal]: @@ -969,19 +974,19 @@ class MachineManager(QObject): return [ s.containersChanged for s in stacks ] @pyqtSlot(str, str, str) - def setSettingForAllExtruders(self, setting_name: str, property_name: str, property_value: str): + def setSettingForAllExtruders(self, setting_name: str, property_name: str, property_value: str) -> None: for key, extruder in self._global_container_stack.extruders.items(): container = extruder.userChanges container.setProperty(setting_name, property_name, property_value) @pyqtProperty("QVariantList", notify = globalContainerChanged) - def currentExtruderPositions(self): + def currentExtruderPositions(self) -> List[str]: if self._global_container_stack is None: return [] return sorted(list(self._global_container_stack.extruders.keys())) ## Update _current_root_material_id when the current root material was changed. - def _onRootMaterialChanged(self): + def _onRootMaterialChanged(self) -> None: self._current_root_material_id = {} if self._global_container_stack: @@ -989,13 +994,13 @@ class MachineManager(QObject): self._current_root_material_id[position] = self._global_container_stack.extruders[position].material.getMetaDataEntry("base_file") @pyqtProperty("QVariant", notify = rootMaterialChanged) - def currentRootMaterialId(self): + def currentRootMaterialId(self) -> Dict[str, str]: return self._current_root_material_id ## Return the variant names in the extruder stack(s). ## For the variant in the global stack, use activeVariantBuildplateName @pyqtProperty("QVariant", notify = activeVariantChanged) - def activeVariantNames(self): + def activeVariantNames(self) -> Dict[str, str]: result = {} active_stacks = ExtruderManager.getInstance().getActiveExtruderStacks() @@ -1011,7 +1016,7 @@ class MachineManager(QObject): # Sets all quality and quality_changes containers to empty_quality and empty_quality_changes containers # for all stacks in the currently active machine. # - def _setEmptyQuality(self): + def _setEmptyQuality(self) -> None: self._current_quality_group = None self._current_quality_changes_group = None self._global_container_stack.quality = self._empty_quality_container @@ -1023,7 +1028,7 @@ class MachineManager(QObject): self.activeQualityGroupChanged.emit() self.activeQualityChangesGroupChanged.emit() - def _setQualityGroup(self, quality_group, empty_quality_changes = True): + def _setQualityGroup(self, quality_group, empty_quality_changes: bool = True) -> None: if quality_group.node_for_global.getContainer() is None: return for node in quality_group.nodes_for_extruders.values(): @@ -1219,7 +1224,7 @@ class MachineManager(QObject): ## Given a printer definition name, select the right machine instance. In case it doesn't exist, create a new # instance with the same network key. @pyqtSlot(str) - def switchPrinterType(self, machine_name): + def switchPrinterType(self, machine_name: str): # Don't switch if the user tries to change to the same type of printer if self.activeMachineDefinitionName == machine_name: return @@ -1243,7 +1248,7 @@ class MachineManager(QObject): self.setActiveMachine(new_machine.getId()) @pyqtSlot(QObject) - def applyRemoteConfiguration(self, configuration: ConfigurationModel): + def applyRemoteConfiguration(self, configuration: ConfigurationModel) -> None: self.blurSettings.emit() with postponeSignals(*self._getContainerChangedSignals(), compress = CompressTechnique.CompressPerParameterValue): self.switchPrinterType(configuration.printerType) @@ -1273,7 +1278,7 @@ class MachineManager(QObject): self._updateQualityWithMaterial() ## Find all container stacks that has the pair 'key = value' in its metadata and replaces the value with 'new_value' - def replaceContainersMetadata(self, key: str, value: str, new_value: str): + def replaceContainersMetadata(self, key: str, value: str, new_value: str) -> None: machines = ContainerRegistry.getInstance().findContainerStacks(type = "machine") for machine in machines: if machine.getMetaDataEntry(key) == value: @@ -1282,7 +1287,7 @@ class MachineManager(QObject): ## This method checks if the name of the group stored in the definition container is correct. # After updating from 3.2 to 3.3 some group names may be temporary. If there is a mismatch in the name of the group # then all the container stacks are updated, both the current and the hidden ones. - def checkCorrectGroupName(self, device_id: str, group_name: str): + def checkCorrectGroupName(self, device_id: str, group_name: str) -> None: if self._global_container_stack and device_id == self.activeMachineNetworkKey: # Check if the connect_group_name is correct. If not, update all the containers connected to the same printer if self.activeMachineNetworkGroupName != group_name: @@ -1316,7 +1321,7 @@ class MachineManager(QObject): self.setMaterial(position, material_node) @pyqtSlot(str, "QVariant") - def setMaterial(self, position, container_node): + def setMaterial(self, position: str, container_node) -> None: position = str(position) self.blurSettings.emit() with postponeSignals(*self._getContainerChangedSignals(), compress = CompressTechnique.CompressPerParameterValue): @@ -1324,13 +1329,13 @@ class MachineManager(QObject): self._updateQualityWithMaterial() @pyqtSlot(str, str) - def setVariantByName(self, position, variant_name): + def setVariantByName(self, position: str, variant_name: str) -> None: machine_definition_id = self._global_container_stack.definition.id variant_node = self._variant_manager.getVariantNode(machine_definition_id, variant_name) self.setVariant(position, variant_node) @pyqtSlot(str, "QVariant") - def setVariant(self, position, container_node): + def setVariant(self, position: str, container_node): position = str(position) self.blurSettings.emit() with postponeSignals(*self._getContainerChangedSignals(), compress = CompressTechnique.CompressPerParameterValue): @@ -1339,7 +1344,7 @@ class MachineManager(QObject): self._updateQualityWithMaterial() @pyqtSlot(str) - def setQualityGroupByQualityType(self, quality_type): + def setQualityGroupByQualityType(self, quality_type: str) -> None: if self._global_container_stack is None: return # Get all the quality groups for this global stack and filter out by quality_type @@ -1391,7 +1396,7 @@ class MachineManager(QObject): name = self._current_quality_group.name return name - def _updateUponMaterialMetadataChange(self): + def _updateUponMaterialMetadataChange(self) -> None: if self._global_container_stack is None: return with postponeSignals(*self._getContainerChangedSignals(), compress = CompressTechnique.CompressPerParameterValue): From dfd9283ed5ceeeb9ce4200a6f4fd0b7a2bceac81 Mon Sep 17 00:00:00 2001 From: Aleksei S Date: Fri, 4 May 2018 10:29:09 +0200 Subject: [PATCH 28/34] Project name after importing CURA-5323 --- cura/PrintInformation.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cura/PrintInformation.py b/cura/PrintInformation.py index 22f7ea5407..0de57d00e0 100644 --- a/cura/PrintInformation.py +++ b/cura/PrintInformation.py @@ -337,12 +337,16 @@ class PrintInformation(QObject): if is_gcode or is_project_file or (is_empty or (self._base_name == "" and self._base_name != name)): # Only take the file name part, Note : file name might have 'dot' in name as well if is_project_file: - # This is for .curaproject + # This is for .curaproject, loaded as project self._base_name = ".".join(filename_parts) elif len(filename_parts) > 1: if "gcode" in filename_parts: gcode_index = filename_parts.index('gcode') self._base_name = ".".join(filename_parts[0:gcode_index]) + elif "curaproject" in filename_parts: + #load a project and import only models + curaproject_index = filename_parts.index('curaproject') + self._base_name = ".".join(filename_parts[0:curaproject_index]) else: self._base_name = name else: From 89322b9db6d69ea7916e95fedcfe70079ba31da9 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Fri, 4 May 2018 10:41:45 +0200 Subject: [PATCH 29/34] Move toolbox button style into theme --- .../resources/qml/ToolboxDetailTile.qml | 53 +----------------- resources/themes/cura-light/styles.qml | 55 +++++++++++++++++++ resources/themes/cura-light/theme.json | 3 +- 3 files changed, 59 insertions(+), 52 deletions(-) diff --git a/plugins/Toolbox/resources/qml/ToolboxDetailTile.qml b/plugins/Toolbox/resources/qml/ToolboxDetailTile.qml index a5982f8c43..7056cb3777 100644 --- a/plugins/Toolbox/resources/qml/ToolboxDetailTile.qml +++ b/plugins/Toolbox/resources/qml/ToolboxDetailTile.qml @@ -76,58 +76,9 @@ Item } enabled: installed || !(toolbox.isDownloading && toolbox.activePackage != model) //Don't allow installing while another download is running. opacity: enabled ? 1.0 : 0.5 - style: ButtonStyle - { - background: Rectangle - { - implicitWidth: 96 * screenScaleFactor - implicitHeight: 30 * screenScaleFactor - color: - { - if (installed) - { - return UM.Theme.getColor("action_button_disabled") - } - else - { - if ( control.hovered ) - { - return UM.Theme.getColor("primary_hover") - } - else - { - return UM.Theme.getColor("primary") - } - } - } - } - label: Label - { - text: control.text - color: - { - if (installed) - { - return UM.Theme.getColor("action_button_disabled_text") - } - else - { - if ( control.hovered ) - { - return UM.Theme.getColor("button_text_hover") - } - else - { - return UM.Theme.getColor("button_text") - } - } - } - verticalAlignment: Text.AlignVCenter - horizontalAlignment: Text.AlignHCenter - font: UM.Theme.getFont("default_bold") - } - } + property alias installed: tile.installed + style: UM.Theme.styles.toolbox_action_button onClicked: { if (installed) diff --git a/resources/themes/cura-light/styles.qml b/resources/themes/cura-light/styles.qml index 6b454b7cf1..14e7d196a7 100755 --- a/resources/themes/cura-light/styles.qml +++ b/resources/themes/cura-light/styles.qml @@ -1033,4 +1033,59 @@ QtObject { label: Item { } } } + + property Component toolbox_action_button: Component { + ButtonStyle + { + background: Rectangle + { + implicitWidth: UM.Theme.getSize("toolbox_action_button").width + implicitHeight: UM.Theme.getSize("toolbox_action_button").height + color: + { + if (control.installed) + { + return UM.Theme.getColor("action_button_disabled") + } + else + { + if (control.hovered) + { + return UM.Theme.getColor("primary_hover") + } + else + { + return UM.Theme.getColor("primary") + } + } + + } + } + label: Label + { + text: control.text + color: + { + if (control.installed) + { + return UM.Theme.getColor("action_button_disabled_text") + } + else + { + if (control.hovered) + { + return UM.Theme.getColor("button_text_hover") + } + else + { + return UM.Theme.getColor("button_text") + } + } + } + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + font: UM.Theme.getFont("default_bold") + } + } + } } diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index c78a51a3a9..1be61b523a 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -460,6 +460,7 @@ "toolbox_header": [1.0, 4.0], "toolbox_action_button": [8.0, 2.5], "toolbox_progress_bar": [8.0, 0.5], - "toolbox_chart_row": [1.0, 2.0] + "toolbox_chart_row": [1.0, 2.0], + "toolbox_action_button": [8.0, 2.5] } } From 1f675f505f611ce3dcb8473b88aa227c36e51bc9 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Fri, 4 May 2018 10:42:03 +0200 Subject: [PATCH 30/34] Tweak margins --- plugins/Toolbox/resources/qml/ToolboxDownloadsGridTile.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/Toolbox/resources/qml/ToolboxDownloadsGridTile.qml b/plugins/Toolbox/resources/qml/ToolboxDownloadsGridTile.qml index b1586e5c52..17b28fe136 100644 --- a/plugins/Toolbox/resources/qml/ToolboxDownloadsGridTile.qml +++ b/plugins/Toolbox/resources/qml/ToolboxDownloadsGridTile.qml @@ -34,8 +34,8 @@ Item Image { anchors.centerIn: parent - width: UM.Theme.getSize("toolbox_thumbnail_small").width - UM.Theme.getSize("default_margin").width - height: UM.Theme.getSize("toolbox_thumbnail_small").height - UM.Theme.getSize("default_margin").width + width: UM.Theme.getSize("toolbox_thumbnail_small").width - UM.Theme.getSize("wide_margin").width + height: UM.Theme.getSize("toolbox_thumbnail_small").height - UM.Theme.getSize("wide_margin").width fillMode: Image.PreserveAspectFit source: model.icon_url || "../images/logobot.svg" mipmap: true From 4e305079ec9a99a26fda9cfd1c2403ec005da371 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Fri, 4 May 2018 11:42:45 +0200 Subject: [PATCH 31/34] Simplify --- plugins/Toolbox/resources/qml/ToolboxCompatibilityChart.qml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/Toolbox/resources/qml/ToolboxCompatibilityChart.qml b/plugins/Toolbox/resources/qml/ToolboxCompatibilityChart.qml index 4f5589d8d0..3c225c521a 100644 --- a/plugins/Toolbox/resources/qml/ToolboxCompatibilityChart.qml +++ b/plugins/Toolbox/resources/qml/ToolboxCompatibilityChart.qml @@ -36,7 +36,7 @@ Item Label { anchors.verticalCenter: parent.verticalCenter - elide: styleData.elideMode || Text.ElideNone + elide: Text.ElideRight text: styleData.value || "" color: UM.Theme.getColor("text") font: UM.Theme.getFont("default_bold") @@ -55,7 +55,7 @@ Item Label { anchors.verticalCenter: parent.verticalCenter - elide: styleData.elideMode || Text.ElideNone + elide: Text.ElideRight text: styleData.value || "" color: UM.Theme.getColor("text_medium") font: UM.Theme.getFont("default") @@ -67,7 +67,7 @@ Item Label { anchors.verticalCenter: parent.verticalCenter - elide: styleData.elideMode || Text.ElideNone + elide: Text.ElideRight text: styleData.value || "" color: UM.Theme.getColor("text_medium") font: UM.Theme.getFont("default") From 6b214d244378b2c1bd19dda95f353bc2f73a3392 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Fri, 4 May 2018 13:05:29 +0200 Subject: [PATCH 32/34] CURA-4644 Change the return type to QObject --- plugins/Toolbox/src/Toolbox.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/Toolbox/src/Toolbox.py b/plugins/Toolbox/src/Toolbox.py index 2f6f39d005..0451494d14 100644 --- a/plugins/Toolbox/src/Toolbox.py +++ b/plugins/Toolbox/src/Toolbox.py @@ -403,7 +403,7 @@ class Toolbox(QObject, Extension): if bytes_sent == bytes_total: self.setIsDownloading(False) self._download_reply.downloadProgress.disconnect(self._onDownloadProgress) - # Optional[Dict[str, Any]]: return self._active_package From 736f28bdb9a64747a3c4179db14db71bc554d80a Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 4 May 2018 13:30:11 +0200 Subject: [PATCH 33/34] Move platform model slightly further down Otherwise it clips with the build volume. This looks much nicer. --- resources/definitions/vertex_k8400.def.json | 2 +- resources/definitions/vertex_k8400_dual.def.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/definitions/vertex_k8400.def.json b/resources/definitions/vertex_k8400.def.json index 8abf9acd7f..92c016aa70 100644 --- a/resources/definitions/vertex_k8400.def.json +++ b/resources/definitions/vertex_k8400.def.json @@ -8,7 +8,7 @@ "file_formats": "text/x-gcode", "icon": "icon_ultimaker2", "platform": "Vertex_build_panel.stl", - "platform_offset": [0, -2, 0], + "platform_offset": [0, -3, 0], "supports_usb_connection": true, "supported_actions": ["MachineSettingsAction"] }, diff --git a/resources/definitions/vertex_k8400_dual.def.json b/resources/definitions/vertex_k8400_dual.def.json index fc006a1d5f..e4b4f609c1 100644 --- a/resources/definitions/vertex_k8400_dual.def.json +++ b/resources/definitions/vertex_k8400_dual.def.json @@ -8,7 +8,7 @@ "file_formats": "text/x-gcode", "icon": "icon_ultimaker2", "platform": "Vertex_build_panel.stl", - "platform_offset": [0, -2, 0], + "platform_offset": [0, -3, 0], "machine_extruder_trains": { "0": "vertex_k8400_dual_1st", "1": "vertex_k8400_dual_2nd" From b00d51a6eb668d734cb54398f5e1f4c02d550256 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Fri, 4 May 2018 14:03:26 +0200 Subject: [PATCH 34/34] CURA-4644 Set the property in the component where is being used. --- plugins/Toolbox/resources/qml/ToolboxCompatibilityChart.qml | 1 + plugins/Toolbox/resources/qml/ToolboxDetailTile.qml | 3 ++- plugins/Toolbox/src/PackagesModel.py | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/Toolbox/resources/qml/ToolboxCompatibilityChart.qml b/plugins/Toolbox/resources/qml/ToolboxCompatibilityChart.qml index 1c58b46b96..f0066c2698 100644 --- a/plugins/Toolbox/resources/qml/ToolboxCompatibilityChart.qml +++ b/plugins/Toolbox/resources/qml/ToolboxCompatibilityChart.qml @@ -8,6 +8,7 @@ import UM 1.1 as UM Item { + property var packageData anchors.topMargin: UM.Theme.getSize("default_margin").height height: visible ? childrenRect.height : 0 visible: packageData.type == "material" && packageData.has_configs diff --git a/plugins/Toolbox/resources/qml/ToolboxDetailTile.qml b/plugins/Toolbox/resources/qml/ToolboxDetailTile.qml index b2b41d30ea..dab90f8e06 100644 --- a/plugins/Toolbox/resources/qml/ToolboxDetailTile.qml +++ b/plugins/Toolbox/resources/qml/ToolboxDetailTile.qml @@ -10,7 +10,6 @@ Item { id: tile property bool installed: toolbox.isInstalled(model.id) - property var packageData: model width: detailList.width - UM.Theme.getSize("wide_margin").width height: Math.max(UM.Theme.getSize("toolbox_detail_tile").height, childrenRect.height + UM.Theme.getSize("default_margin").height) Item @@ -46,6 +45,7 @@ Item font: UM.Theme.getFont("default") } } + Item { id: controls @@ -164,6 +164,7 @@ Item id: compatibilityChart anchors.top: normalData.bottom width: normalData.width + packageData: model } Rectangle diff --git a/plugins/Toolbox/src/PackagesModel.py b/plugins/Toolbox/src/PackagesModel.py index 611d24af9d..d1905e1742 100644 --- a/plugins/Toolbox/src/PackagesModel.py +++ b/plugins/Toolbox/src/PackagesModel.py @@ -59,7 +59,7 @@ class PackagesModel(ListModel): "version": package["package_version"], "author_id": package["author"]["author_id"] if "author_id" in package["author"] else package["author"]["name"], "author_name": package["author"]["display_name"] if "display_name" in package["author"] else package["author"]["name"], - "author_email": package["author"]["email"] if "email" in package["author"] else "None", + "author_email": package["author"]["email"] if "email" in package["author"] else None, "description": package["description"], "icon_url": package["icon_url"] if "icon_url" in package else None, "image_urls": package["image_urls"] if "image_urls" in package else None,