From 0b0fb4cd2f5097b8c5413d9c886c0327259f8e34 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Tue, 22 May 2018 14:52:22 +0200 Subject: [PATCH 1/4] CURA-5296 Added "canDowngrade" functionality Shows "Downgrade" instead of "Uninstall" for bundled packages with an upgrade installed. --- .../Toolbox/resources/qml/ToolboxInstalledTile.qml | 2 -- .../resources/qml/ToolboxInstalledTileActions.qml | 10 +++++++++- plugins/Toolbox/src/Toolbox.py | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/plugins/Toolbox/resources/qml/ToolboxInstalledTile.qml b/plugins/Toolbox/resources/qml/ToolboxInstalledTile.qml index 435319b5e9..78c970659c 100644 --- a/plugins/Toolbox/resources/qml/ToolboxInstalledTile.qml +++ b/plugins/Toolbox/resources/qml/ToolboxInstalledTile.qml @@ -10,7 +10,6 @@ Item { height: UM.Theme.getSize("toolbox_installed_tile").height width: parent.width - property bool canUpdate: false property bool isEnabled: true Rectangle @@ -109,7 +108,6 @@ Item { target: toolbox onEnabledChanged: isEnabled = toolbox.isEnabled(model.id) - onMetadataChanged: canUpdate = toolbox.canUpdate(model.id) } } } diff --git a/plugins/Toolbox/resources/qml/ToolboxInstalledTileActions.qml b/plugins/Toolbox/resources/qml/ToolboxInstalledTileActions.qml index 204b755909..0ca0bd4fd5 100644 --- a/plugins/Toolbox/resources/qml/ToolboxInstalledTileActions.qml +++ b/plugins/Toolbox/resources/qml/ToolboxInstalledTileActions.qml @@ -8,6 +8,8 @@ import UM 1.1 as UM Column { + property bool canUpdate: false + property bool canDowngrade: false width: UM.Theme.getSize("toolbox_action_button").width spacing: UM.Theme.getSize("narrow_margin").height @@ -36,7 +38,7 @@ Column Button { id: removeButton - text: catalog.i18nc("@action:button", "Uninstall") + text: canDowngrade ? catalog.i18nc("@action:button", "Downgrade") : catalog.i18nc("@action:button", "Uninstall") visible: !model.is_bundled enabled: !toolbox.isDownloading style: ButtonStyle @@ -72,5 +74,11 @@ Column } } onClicked: toolbox.uninstall(model.id) + Connections + { + target: toolbox + onMetadataChanged: canUpdate = toolbox.canUpdate(model.id) + onMetadataChanged: canDowngrade = toolbox.canDowngrade(model.id) + } } } diff --git a/plugins/Toolbox/src/Toolbox.py b/plugins/Toolbox/src/Toolbox.py index 622198666d..776f2a3870 100644 --- a/plugins/Toolbox/src/Toolbox.py +++ b/plugins/Toolbox/src/Toolbox.py @@ -300,6 +300,20 @@ class Toolbox(QObject, Extension): remote_version = Version(remote_package["package_version"]) return remote_version > local_version + @pyqtSlot(str, result=bool) + def canDowngrade(self, package_id: str) -> bool: + local_package = self._package_manager.getInstalledPackageInfo(package_id) + if local_package is None: + return False + + remote_package = self.getRemotePackage(package_id) + if remote_package is None: + return False + + local_version = Version(local_package["package_version"]) + remote_version = Version(remote_package["package_version"]) + return remote_version < local_version + @pyqtSlot(str, result = bool) def isInstalled(self, package_id: str) -> bool: return self._package_manager.isPackageInstalled(package_id) From eecbe20830ca35c0930d86de90a2ee846f08834d Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Tue, 22 May 2018 15:06:27 +0200 Subject: [PATCH 2/4] Enabled drag-n-drop for curapackages --- cura/CuraPackageManager.py | 9 ++++++++- resources/qml/Cura.qml | 23 +++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/cura/CuraPackageManager.py b/cura/CuraPackageManager.py index 0c2c438fcc..a4b60b3251 100644 --- a/cura/CuraPackageManager.py +++ b/cura/CuraPackageManager.py @@ -8,13 +8,14 @@ import shutil import zipfile import tempfile -from PyQt5.QtCore import pyqtSlot, QObject, pyqtSignal +from PyQt5.QtCore import pyqtSlot, QObject, pyqtSignal, QUrl from UM.Application import Application from UM.Logger import Logger from UM.Resources import Resources from UM.Version import Version + class CuraPackageManager(QObject): Version = 1 @@ -184,6 +185,12 @@ class CuraPackageManager(QObject): def isPackageInstalled(self, package_id: str) -> bool: return self.getInstalledPackageInfo(package_id) is not None + # This is called by drag-and-dropping curapackage files. + @pyqtSlot(QUrl) + def installPackageViaDragAndDrop(self, file_url: str) -> None: + filename = QUrl(file_url).toLocalFile() + return self.installPackage(filename) + # Schedules the given package file to be installed upon the next start. @pyqtSlot(str) def installPackage(self, filename: str) -> None: diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index ac37cce10a..9d21de0535 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -323,6 +323,21 @@ UM.MainWindow { if (drop.urls.length > 0) { + // As the drop area also supports plugins, first check if it's a plugin that was dropped. + if (drop.urls.length == 1) + { + var filename = drop.urls[0]; + if (filename.endsWith(".curapackage")) + { + // Try to install plugin & close. + CuraApplication.getCuraPackageManager().installPackageViaDragAndDrop(filename); + packageInstallDialog.text = catalog.i18nc("@label", "This package will be installed after restarting."); + packageInstallDialog.icon = StandardIcon.Information; + packageInstallDialog.open(); + return; + } + } + openDialog.handleOpenFileUrls(drop.urls); } } @@ -789,6 +804,14 @@ UM.MainWindow } } + MessageDialog + { + id: packageInstallDialog + title: catalog.i18nc("@window:title", "Install Package"); + standardButtons: StandardButton.Ok + modality: Qt.ApplicationModal + } + MessageDialog { id: infoMultipleFilesWithGcodeDialog title: catalog.i18nc("@title:window", "Open File(s)") From 7861840886bd827420312c8fedb5cdbff65f3d0b Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Tue, 22 May 2018 16:04:38 +0200 Subject: [PATCH 3/4] CURA-5296 Small QML bug fix --- .../Toolbox/resources/qml/ToolboxInstalledTileActions.qml | 7 +++++-- resources/bundled_packages.json | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/Toolbox/resources/qml/ToolboxInstalledTileActions.qml b/plugins/Toolbox/resources/qml/ToolboxInstalledTileActions.qml index 0ca0bd4fd5..0ae738b71d 100644 --- a/plugins/Toolbox/resources/qml/ToolboxInstalledTileActions.qml +++ b/plugins/Toolbox/resources/qml/ToolboxInstalledTileActions.qml @@ -77,8 +77,11 @@ Column Connections { target: toolbox - onMetadataChanged: canUpdate = toolbox.canUpdate(model.id) - onMetadataChanged: canDowngrade = toolbox.canDowngrade(model.id) + onMetadataChanged: + { + canUpdate = toolbox.canUpdate(model.id) + canDowngrade = toolbox.canDowngrade(model.id) + } } } } diff --git a/resources/bundled_packages.json b/resources/bundled_packages.json index 5f5ce12554..8d58f226b0 100644 --- a/resources/bundled_packages.json +++ b/resources/bundled_packages.json @@ -974,7 +974,7 @@ "package_type": "material", "display_name": "Ultimaker ABS", "description": "Example package for material and quality profiles for Ultimaker materials.", - "package_version": "0.5.0", + "package_version": "1.0.0", "cura_version": 4, "website": "https://ultimaker.com/products/materials/abs", "author": { From 0a395a7305df15215d7ba74fe9437ca39d7bdbfe Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Tue, 22 May 2018 16:29:04 +0200 Subject: [PATCH 4/4] CURA-5385 Project summary should use scroll view --- resources/qml/WorkspaceSummaryDialog.qml | 399 +++++++++++------------ 1 file changed, 191 insertions(+), 208 deletions(-) diff --git a/resources/qml/WorkspaceSummaryDialog.qml b/resources/qml/WorkspaceSummaryDialog.qml index 4d15860257..0869d7e698 100644 --- a/resources/qml/WorkspaceSummaryDialog.qml +++ b/resources/qml/WorkspaceSummaryDialog.qml @@ -1,4 +1,4 @@ -// Copyright (c) 2016 Ultimaker B.V. +// Copyright (c) 2018 Ultimaker B.V. // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.1 @@ -61,237 +61,220 @@ UM.Dialog { id: palette } - - Column + Label { - anchors.fill: parent - spacing: 2 * screenScaleFactor - Label + id: mainHeading + width: parent.width + text: catalog.i18nc("@action:title", "Summary - Cura Project") + font.pointSize: 18 + anchors.top: parent.top + } + ScrollView + { + id: scroll + width: parent.width + anchors { - id: titleLabel - text: catalog.i18nc("@action:title", "Summary - Cura Project") - font.pointSize: 18 + top: mainHeading.bottom + topMargin: UM.Theme.getSize("default_margin").height + bottom: controls.top + bottomMargin: UM.Theme.getSize("default_margin").height } - Rectangle + style: UM.Theme.styles.scrollview + ColumnLayout { - id: separator - color: palette.text - width: parent.width - height: 1 - } - Item // Spacer - { - height: spacerHeight - width: height - } - - Label - { - text: catalog.i18nc("@action:label", "Printer settings") - font.bold: true - } - Row - { - width: parent.width - height: childrenRect.height - Label + spacing: UM.Theme.getSize("default_margin").height + Column { - text: catalog.i18nc("@action:label", "Type") - width: (parent.width / 3) | 0 - } - Label - { - text: (Cura.MachineManager.activeMachine == null) ? "" : Cura.MachineManager.activeMachine.definition.name - width: (parent.width / 3) | 0 - } - } - Row - { - width: parent.width - height: childrenRect.height - Label - { - text: catalog.i18nc("@action:label", Cura.MachineManager.activeMachineNetworkGroupName != "" ? "Printer Group" : "Name") - width: (parent.width / 3) | 0 - } - Label - { - text: Cura.MachineManager.activeMachineNetworkGroupName != "" ? Cura.MachineManager.activeMachineNetworkGroupName : Cura.MachineManager.activeMachineName - width: (parent.width / 3) | 0 - } - } - Column - { - width: parent.width - visible: Cura.MachineManager.hasVariantBuildplates - Item // Spacer - { - height: spacerHeight - width: height - } - Row - { - width: parent.width - height: childrenRect.height Label { - text: catalog.i18nc("@action:label", "Build plate") - width: (parent.width / 3) | 0 + id: settingsHeading + text: catalog.i18nc("@action:label", "Printer settings") + font.bold: true } - Label - { - text: Cura.MachineManager.activeVariantBuildplateName - width: (parent.width / 3) | 0 - } - } - } - - Repeater - { - model: Cura.MachineManager.currentExtruderPositions - delegate: Column - { - Item // Spacer - { - height: spacerHeight - width: height - } - Label - { - text: catalog.i18nc("@action:label", "Extruder %1").arg(modelData) - } - height: childrenRect.height - width: parent.width Row { width: parent.width height: childrenRect.height Label { - text: catalog.i18nc("@action:label", "%1 & material").arg(Cura.MachineManager.activeDefinitionVariantsName) - width: (parent.width / 3) | 0 + text: catalog.i18nc("@action:label", "Type") + width: Math.floor(scroll.width / 3) | 0 } Label { - text: Cura.MachineManager.activeVariantNames[modelData] + ", " + Cura.MachineManager.getExtruder(modelData).material.name - width: (parent.width / 3) | 0 + text: (Cura.MachineManager.activeMachine == null) ? "" : Cura.MachineManager.activeMachine.definition.name + width: Math.floor(scroll.width / 3) | 0 + } + } + Row + { + width: parent.width + height: childrenRect.height + Label + { + text: catalog.i18nc("@action:label", Cura.MachineManager.activeMachineNetworkGroupName != "" ? "Printer Group" : "Name") + width: Math.floor(scroll.width / 3) | 0 + } + Label + { + text: Cura.MachineManager.activeMachineNetworkGroupName != "" ? Cura.MachineManager.activeMachineNetworkGroupName : Cura.MachineManager.activeMachineName + width: Math.floor(scroll.width / 3) | 0 + } + } + } + Row + { + visible: Cura.MachineManager.hasVariantBuildplates + width: parent.width + height: childrenRect.height + Label + { + text: catalog.i18nc("@action:label", "Build plate") + width: Math.floor(scroll.width / 3) | 0 + } + Label + { + text: Cura.MachineManager.activeVariantBuildplateName + width: Math.floor(scroll.width / 3) | 0 + } + } + Repeater + { + width: parent.width + height: childrenRect.height + model: Cura.MachineManager.currentExtruderPositions + delegate: Column + { + height: childrenRect.height + width: parent.width + Label + { + text: catalog.i18nc("@action:label", "Extruder %1").arg(modelData) + font.bold: true + } + Row + { + width: parent.width + height: childrenRect.height + Label + { + text: catalog.i18nc("@action:label", "%1 & material").arg(Cura.MachineManager.activeDefinitionVariantsName) + width: Math.floor(scroll.width / 3) | 0 + } + Label + { + text: Cura.MachineManager.activeVariantNames[modelData] + ", " + Cura.MachineManager.getExtruder(modelData).material.name + width: Math.floor(scroll.width / 3) | 0 + } + } + } + } + Column + { + width: parent.width + height: childrenRect.height + Label + { + text: catalog.i18nc("@action:label", "Profile settings") + font.bold: true + } + Row + { + width: parent.width + Label + { + text: catalog.i18nc("@action:label", "Not in profile") + width: Math.floor(scroll.width / 3) | 0 + } + Label + { + text: catalog.i18ncp("@action:label", "%1 override", "%1 overrides", Cura.MachineManager.numUserSettings).arg(Cura.MachineManager.numUserSettings) + width: Math.floor(scroll.width / 3) | 0 + } + visible: Cura.MachineManager.numUserSettings + } + Row + { + width: parent.width + height: childrenRect.height + Label + { + text: catalog.i18nc("@action:label", "Name") + width: Math.floor(scroll.width / 3) | 0 + } + Label + { + text: Cura.MachineManager.activeQualityOrQualityChangesName + width: Math.floor(scroll.width / 3) | 0 + } + + } + } + Column + { + width: parent.width + height: childrenRect.height + Label + { + text: catalog.i18nc("@action:label", "Setting visibility") + font.bold: true + } + Row + { + width: parent.width + height: childrenRect.height + Label + { + text: catalog.i18nc("@action:label", "Visible settings:") + width: Math.floor(scroll.width / 3) | 0 + } + Label + { + text: catalog.i18nc("@action:label", "%1 out of %2" ).arg(definitionsModel.visibleCount).arg(Cura.MachineManager.totalNumberOfSettings) + width: Math.floor(scroll.width / 3) | 0 } } } } - - Item // Spacer - { - height: spacerHeight - width: height - } - - Label - { - text: catalog.i18nc("@action:label", "Profile settings") - font.bold: true - } - Row - { - width: parent.width - Label - { - text: catalog.i18nc("@action:label", "Not in profile") - width: (parent.width / 3) | 0 - } - Label - { - text: catalog.i18ncp("@action:label", "%1 override", "%1 overrides", Cura.MachineManager.numUserSettings).arg(Cura.MachineManager.numUserSettings) - width: (parent.width / 3) | 0 - } - visible: Cura.MachineManager.numUserSettings - } - Row - { - width: parent.width - height: childrenRect.height - Label - { - text: catalog.i18nc("@action:label", "Name") - width: (parent.width / 3) | 0 - } - Label - { - text: Cura.MachineManager.activeQualityOrQualityChangesName - width: (parent.width / 3) | 0 - } - - } - - Item // Spacer - { - height: spacerHeight - width: height - } - - Label - { - text: catalog.i18nc("@action:label", "Setting visibility") - font.bold: true - } - Row - { - width: parent.width - height: childrenRect.height - Label - { - text: catalog.i18nc("@action:label", "Visible settings:") - width: (parent.width / 3) | 0 - } - Label - { - text: catalog.i18nc("@action:label", "%1 out of %2" ).arg(definitionsModel.visibleCount).arg(Cura.MachineManager.totalNumberOfSettings) - width: (parent.width / 3) | 0 - } - } - - Item // Spacer - { - height: spacerHeight - width: height - } } - - CheckBox + Item { - id: dontShowAgainCheckbox - anchors.bottom: cancel_button.top - anchors.bottomMargin: UM.Theme.getSize("default_margin").height - anchors.left: parent.left - - text: catalog.i18nc("@action:label", "Don't show project summary on save again") - checked: dontShowAgain - } - - Button - { - id: cancel_button + id: controls + width: parent.width + height: childrenRect.height anchors.bottom: parent.bottom - anchors.right: ok_button.left - anchors.rightMargin: 2 - - text: catalog.i18nc("@action:button","Cancel"); - enabled: true - onClicked: close() - } - - Button - { - id: ok_button - anchors.bottom: parent.bottom - anchors.right: parent.right - - text: catalog.i18nc("@action:button","Save"); - enabled: true - onClicked: { - close() - yes() + CheckBox + { + id: dontShowAgainCheckbox + anchors.left: parent.left + text: catalog.i18nc("@action:label", "Don't show project summary on save again") + checked: dontShowAgain + } + Button + { + id: cancel_button + anchors + { + right: ok_button.left + rightMargin: UM.Theme.getSize("default_margin").width + } + text: catalog.i18nc("@action:button","Cancel"); + enabled: true + onClicked: close() + } + Button + { + id: ok_button + anchors.right: parent.right + text: catalog.i18nc("@action:button","Save"); + enabled: true + onClicked: + { + close() + yes() + } } } } -} +} \ No newline at end of file