From 9b67fa94b48a5ed3176d224187d3daff78fdc32c Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Wed, 24 May 2017 13:27:11 +0200 Subject: [PATCH 1/8] Add material info button to show Ultimaker.com materials page CURA-3810 Add a new info button for materials. When a user clicks on the button, it will open the materials information page on the Ultimaker website. --- resources/qml/SidebarHeader.qml | 48 ++++++++++++++++++++++++++++++-- resources/themes/cura/styles.qml | 31 +++++++++++++++++++++ resources/themes/cura/theme.json | 11 ++++++-- 3 files changed, 86 insertions(+), 4 deletions(-) diff --git a/resources/qml/SidebarHeader.qml b/resources/qml/SidebarHeader.qml index e4070c5d43..a388c68323 100644 --- a/resources/qml/SidebarHeader.qml +++ b/resources/qml/SidebarHeader.qml @@ -196,16 +196,60 @@ Column } anchors.verticalCenter: parent.verticalCenter - width: parent.width * 0.45 - UM.Theme.getSize("default_margin").width + width: parent.width * 0.30 font: UM.Theme.getFont("default"); color: UM.Theme.getColor("text"); } + Text + { + width: parent.width * 0.05 + } + + Button + { + id: materialInfoButton + height: parent.height * 0.70 + width: height + anchors.margins: UM.Theme.getSize("default_margin").width + anchors.verticalCenter: parent.verticalCenter + + text: "i" + style: UM.Theme.styles.info_button + + onClicked: + { + // open the material URL with web browser + var url = "https://ultimaker.com/en/resources/23121-materials"; + Qt.openUrlExternally(url); + } + + onHoveredChanged: + { + if (hovered) + { + var content = catalog.i18nc("@tooltip", "Click to check the material compatibility on Ultimaker.com."); + base.showTooltip( + variantRow, Qt.point(0, variantRow.height / 2), catalog.i18nc("@tooltip", content) + ); + } + else + { + base.hideTooltip(); + } + } + } + + Text + { + width: parent.width * 0.10 - materialInfoButton.width - UM.Theme.getSize("default_margin").width + } + Item { anchors.verticalCenter: parent.verticalCenter - width: parent.width * 0.55 + UM.Theme.getSize("default_margin").width + width: parent.width * 0.50 + UM.Theme.getSize("default_margin").width height: UM.Theme.getSize("setting_control").height ToolButton { diff --git a/resources/themes/cura/styles.qml b/resources/themes/cura/styles.qml index ffe866f2c6..b8375ae025 100755 --- a/resources/themes/cura/styles.qml +++ b/resources/themes/cura/styles.qml @@ -8,6 +8,37 @@ import QtQuick.Controls.Styles 1.1 import UM 1.1 as UM QtObject { + property Component info_button: Component { + ButtonStyle { + label: Text { + renderType: Text.NativeRendering + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + font: UM.Theme.getFont("small") + color: UM.Theme.getColor("info_button_text") + text: control.text + } + + background: Rectangle { + implicitHeight: UM.Theme.getSize("info_button").height + implicitWidth: width + border.width: 0 + radius: height * 0.5 + + color: { + if (control.pressed) { + return UM.Theme.getColor("info_button_background_active"); + } else if (control.hovered) { + return UM.Theme.getColor("info_button_background_hover"); + } else { + return UM.Theme.getColor("info_button_background"); + } + } + Behavior on color { ColorAnimation { duration: 50; } } + } + } + } + property Component mode_switch: Component { SwitchStyle { groove: Rectangle { diff --git a/resources/themes/cura/theme.json b/resources/themes/cura/theme.json index 5f0b3656c8..0c0d80fa7c 100644 --- a/resources/themes/cura/theme.json +++ b/resources/themes/cura/theme.json @@ -243,7 +243,12 @@ "layerview_support_infill": [0, 255, 255, 255], "layerview_move_combing": [0, 0, 255, 255], "layerview_move_retraction": [128, 128, 255, 255], - "layerview_support_interface": [64, 192, 255, 255] + "layerview_support_interface": [64, 192, 255, 255], + + "info_button_text": [255, 255, 255, 255], + "info_button_background": [127, 127, 127, 255], + "info_button_background_hover": [24, 41, 77, 255], + "info_button_background_active": [70, 84, 113, 255] }, "sizes": { @@ -329,6 +334,8 @@ "infill_button_margin": [0.5, 0.5], - "jobspecs_line": [2.0, 2.0] + "jobspecs_line": [2.0, 2.0], + + "info_button": [0.6, 0.6] } } From 85e875257b34bd69ca1a3e2385889fdd23f6bb82 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Mon, 29 May 2017 15:23:49 +0200 Subject: [PATCH 2/8] Use "//" as the material info URL suffix CURA-3810 --- cura/CuraApplication.py | 4 ++++ cura/Settings/MachineManager.py | 6 ++++++ resources/qml/SidebarHeader.qml | 5 ++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index ba42dd2aec..f4290af24b 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -1362,3 +1362,7 @@ class CuraApplication(QtApplication): node = node.getParent() Selection.add(node) + + @pyqtSlot(result=str) + def getCuraVersion(self): + return CuraVersion diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index 96ccc89ccf..dc05e4fa4d 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -474,6 +474,12 @@ class MachineManager(QObject): def activeMachine(self) -> "GlobalStack": return self._global_container_stack + @pyqtProperty(str, notify = globalContainerChanged) + def activeMachineDefinitionId(self) -> str: + if self._global_container_stack and self._global_container_stack.definition: + return self._global_container_stack.definition.getId() + return "" + @pyqtProperty(str, notify = activeStackChanged) def activeStackId(self) -> str: if self._active_container_stack: diff --git a/resources/qml/SidebarHeader.qml b/resources/qml/SidebarHeader.qml index a388c68323..f99f6875ae 100644 --- a/resources/qml/SidebarHeader.qml +++ b/resources/qml/SidebarHeader.qml @@ -220,7 +220,10 @@ Column onClicked: { // open the material URL with web browser - var url = "https://ultimaker.com/en/resources/23121-materials"; + var version = CuraApplication.getCuraVersion(); + var machineName = Cura.MachineManager.activeMachineDefinitionId; + + var url = "https://ultimaker.com/materialcompatibility/" + version + "/" + machineName; Qt.openUrlExternally(url); } From c80e1b67a5a941e09fb34ff1e130f30ee6db1ef2 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Mon, 29 May 2017 16:01:32 +0200 Subject: [PATCH 3/8] Only show material info button for multi-extrusion machines CURA-3810 --- cura/CuraApplication.py | 4 ---- resources/qml/SidebarHeader.qml | 10 +++++++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index f4290af24b..ba42dd2aec 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -1362,7 +1362,3 @@ class CuraApplication(QtApplication): node = node.getParent() Selection.add(node) - - @pyqtSlot(result=str) - def getCuraVersion(self): - return CuraVersion diff --git a/resources/qml/SidebarHeader.qml b/resources/qml/SidebarHeader.qml index f99f6875ae..94e04c3317 100644 --- a/resources/qml/SidebarHeader.qml +++ b/resources/qml/SidebarHeader.qml @@ -213,6 +213,7 @@ Column width: height anchors.margins: UM.Theme.getSize("default_margin").width anchors.verticalCenter: parent.verticalCenter + visible: extrudersList.visible text: "i" style: UM.Theme.styles.info_button @@ -220,7 +221,7 @@ Column onClicked: { // open the material URL with web browser - var version = CuraApplication.getCuraVersion(); + var version = UM.Application.version; var machineName = Cura.MachineManager.activeMachineDefinitionId; var url = "https://ultimaker.com/materialcompatibility/" + version + "/" + machineName; @@ -243,6 +244,13 @@ Column } } + Text // to take the space of the material info button when the active machine doesn't have multiple extruders + { + height: parent.height * 0.70 + width: height + visible: !extrudersList.visible + } + Text { width: parent.width * 0.10 - materialInfoButton.width - UM.Theme.getSize("default_margin").width From 3a3d9afc2455bf749e10132bcf4f8c5c7fbb0f98 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Mon, 29 May 2017 18:06:35 +0200 Subject: [PATCH 4/8] Use "button" style for material info button CURA-3810 --- resources/themes/cura/styles.qml | 8 ++++---- resources/themes/cura/theme.json | 7 +------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/resources/themes/cura/styles.qml b/resources/themes/cura/styles.qml index b8375ae025..496cc8e489 100755 --- a/resources/themes/cura/styles.qml +++ b/resources/themes/cura/styles.qml @@ -15,7 +15,7 @@ QtObject { verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter font: UM.Theme.getFont("small") - color: UM.Theme.getColor("info_button_text") + color: UM.Theme.getColor("button_text") text: control.text } @@ -27,11 +27,11 @@ QtObject { color: { if (control.pressed) { - return UM.Theme.getColor("info_button_background_active"); + return UM.Theme.getColor("button_active"); } else if (control.hovered) { - return UM.Theme.getColor("info_button_background_hover"); + return UM.Theme.getColor("button_hover"); } else { - return UM.Theme.getColor("info_button_background"); + return UM.Theme.getColor("button"); } } Behavior on color { ColorAnimation { duration: 50; } } diff --git a/resources/themes/cura/theme.json b/resources/themes/cura/theme.json index 0c0d80fa7c..e7d49cb5e8 100644 --- a/resources/themes/cura/theme.json +++ b/resources/themes/cura/theme.json @@ -243,12 +243,7 @@ "layerview_support_infill": [0, 255, 255, 255], "layerview_move_combing": [0, 0, 255, 255], "layerview_move_retraction": [128, 128, 255, 255], - "layerview_support_interface": [64, 192, 255, 255], - - "info_button_text": [255, 255, 255, 255], - "info_button_background": [127, 127, 127, 255], - "info_button_background_hover": [24, 41, 77, 255], - "info_button_background_active": [70, 84, 113, 255] + "layerview_support_interface": [64, 192, 255, 255] }, "sizes": { From 68bd5a6e3767616edfe3f2732257dfe00edb2dd9 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Tue, 30 May 2017 09:16:24 +0200 Subject: [PATCH 5/8] Use Item and anchors to set material row layout CURA-3810 --- resources/qml/SidebarHeader.qml | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/resources/qml/SidebarHeader.qml b/resources/qml/SidebarHeader.qml index 94e04c3317..8e9c9bc6ba 100644 --- a/resources/qml/SidebarHeader.qml +++ b/resources/qml/SidebarHeader.qml @@ -159,7 +159,7 @@ Column visible: !extruderSelectionRow.visible } - Row + Item { id: variantRow @@ -196,23 +196,22 @@ Column } anchors.verticalCenter: parent.verticalCenter + anchors.left: variantRow.left width: parent.width * 0.30 font: UM.Theme.getFont("default"); color: UM.Theme.getColor("text"); } - Text - { - width: parent.width * 0.05 - } - Button { id: materialInfoButton height: parent.height * 0.70 width: height - anchors.margins: UM.Theme.getSize("default_margin").width + + anchors.left: variantLabel.right + anchors.leftMargin: UM.Theme.getSize("default_margin").width * 2 anchors.verticalCenter: parent.verticalCenter + visible: extrudersList.visible text: "i" @@ -244,21 +243,10 @@ Column } } - Text // to take the space of the material info button when the active machine doesn't have multiple extruders - { - height: parent.height * 0.70 - width: height - visible: !extrudersList.visible - } - - Text - { - width: parent.width * 0.10 - materialInfoButton.width - UM.Theme.getSize("default_margin").width - } - Item { anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right width: parent.width * 0.50 + UM.Theme.getSize("default_margin").width height: UM.Theme.getSize("setting_control").height From 9333ed1e35dc03e2e31bb3b7944b1e2fc6f6e095 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Tue, 30 May 2017 09:16:56 +0200 Subject: [PATCH 6/8] Update copyright in comments CURA-3810 --- resources/qml/SidebarHeader.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/SidebarHeader.qml b/resources/qml/SidebarHeader.qml index 8e9c9bc6ba..2d24506d19 100644 --- a/resources/qml/SidebarHeader.qml +++ b/resources/qml/SidebarHeader.qml @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Ultimaker B.V. +// Copyright (c) 2017 Ultimaker B.V. // Cura is released under the terms of the AGPLv3 or higher. import QtQuick 2.2 From 7be05229d86557477f6df3e3b83fc7a8e851830b Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Tue, 30 May 2017 11:47:45 +0200 Subject: [PATCH 7/8] Fix material info button tooltip position CURA-3810 --- resources/qml/SidebarHeader.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/SidebarHeader.qml b/resources/qml/SidebarHeader.qml index 2d24506d19..9c46062743 100644 --- a/resources/qml/SidebarHeader.qml +++ b/resources/qml/SidebarHeader.qml @@ -233,7 +233,7 @@ Column { var content = catalog.i18nc("@tooltip", "Click to check the material compatibility on Ultimaker.com."); base.showTooltip( - variantRow, Qt.point(0, variantRow.height / 2), catalog.i18nc("@tooltip", content) + extruderSelectionRow, Qt.point(0, extruderSelectionRow.height + variantRow.height / 2), catalog.i18nc("@tooltip", content) ); } else From 8af1cc886ff90bea6ae348e3c1bb64f214ffe4a9 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Tue, 30 May 2017 12:49:10 +0200 Subject: [PATCH 8/8] Use .definition to access DefinitionContainer in qml CURA-3810 --- cura/Settings/CuraContainerStack.py | 4 ++-- cura/Settings/MachineManager.py | 8 +------- resources/qml/SidebarHeader.qml | 2 +- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/cura/Settings/CuraContainerStack.py b/cura/Settings/CuraContainerStack.py index d14f2d04c9..fc90e3b239 100755 --- a/cura/Settings/CuraContainerStack.py +++ b/cura/Settings/CuraContainerStack.py @@ -5,7 +5,7 @@ import os.path from typing import Any, Optional -from PyQt5.QtCore import pyqtProperty, pyqtSignal +from PyQt5.QtCore import pyqtProperty, pyqtSignal, QObject from UM.FlameProfiler import pyqtSlot from UM.Decorators import override @@ -250,7 +250,7 @@ class CuraContainerStack(ContainerStack): ## Get the definition container. # # \return The definition container. Should always be a valid container, but can be equal to the empty InstanceContainer. - @pyqtProperty(DefinitionContainer, fset = setDefinition, notify = pyqtContainersChanged) + @pyqtProperty(QObject, fset = setDefinition, notify = pyqtContainersChanged) def definition(self) -> DefinitionContainer: return self._containers[_ContainerIndexes.Definition] diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index dc05e4fa4d..8738b044fb 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -470,16 +470,10 @@ class MachineManager(QObject): return "" - @pyqtProperty("QObject", notify = globalContainerChanged) + @pyqtProperty(QObject, notify = globalContainerChanged) def activeMachine(self) -> "GlobalStack": return self._global_container_stack - @pyqtProperty(str, notify = globalContainerChanged) - def activeMachineDefinitionId(self) -> str: - if self._global_container_stack and self._global_container_stack.definition: - return self._global_container_stack.definition.getId() - return "" - @pyqtProperty(str, notify = activeStackChanged) def activeStackId(self) -> str: if self._active_container_stack: diff --git a/resources/qml/SidebarHeader.qml b/resources/qml/SidebarHeader.qml index 9c46062743..32e1db607a 100644 --- a/resources/qml/SidebarHeader.qml +++ b/resources/qml/SidebarHeader.qml @@ -221,7 +221,7 @@ Column { // open the material URL with web browser var version = UM.Application.version; - var machineName = Cura.MachineManager.activeMachineDefinitionId; + var machineName = Cura.MachineManager.activeMachine.definition.id; var url = "https://ultimaker.com/materialcompatibility/" + version + "/" + machineName; Qt.openUrlExternally(url);