From 9ce8f6cf660c6ad9b4f2426b57c26fd7178ea9cd Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 18 Apr 2017 13:48:22 +0200 Subject: [PATCH 01/10] Added new icons CURA-3577 --- .../themes/cura/icons/material_not_selected.svg | 15 +++++++++++++++ resources/themes/cura/icons/material_selected.svg | 15 +++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 resources/themes/cura/icons/material_not_selected.svg create mode 100644 resources/themes/cura/icons/material_selected.svg diff --git a/resources/themes/cura/icons/material_not_selected.svg b/resources/themes/cura/icons/material_not_selected.svg new file mode 100644 index 0000000000..2d4fb7cfd3 --- /dev/null +++ b/resources/themes/cura/icons/material_not_selected.svg @@ -0,0 +1,15 @@ + + + + Artboard 3 + Created with Sketch. + + + + + + + + + + \ No newline at end of file diff --git a/resources/themes/cura/icons/material_selected.svg b/resources/themes/cura/icons/material_selected.svg new file mode 100644 index 0000000000..87ffdf55da --- /dev/null +++ b/resources/themes/cura/icons/material_selected.svg @@ -0,0 +1,15 @@ + + + + Artboard 3 Copy + Created with Sketch. + + + + + + + + + + \ No newline at end of file From 09f23f5f91070fd7d24673b98bcaec12f4817ef7 Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Tue, 25 Apr 2017 11:31:59 +0200 Subject: [PATCH 02/10] Styling fixes in Toolbar QML --- resources/qml/Toolbar.qml | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/resources/qml/Toolbar.qml b/resources/qml/Toolbar.qml index 60fc6fd723..6363aa4e42 100644 --- a/resources/qml/Toolbar.qml +++ b/resources/qml/Toolbar.qml @@ -8,26 +8,30 @@ import QtQuick.Layouts 1.1 import UM 1.0 as UM -Item { +Item +{ id: base; width: buttons.width; height: buttons.height property int activeY - ColumnLayout { + Column + { id: buttons; anchors.bottom: parent.bottom; anchors.left: parent.left; spacing: UM.Theme.getSize("button_lining").width - Repeater { + Repeater + { id: repeat model: UM.ToolModel { } - Button { + Button + { text: model.name iconSource: UM.Theme.getIcon(model.icon); @@ -45,9 +49,11 @@ Item { } //Workaround since using ToolButton"s onClicked would break the binding of the checked property, instead //just catch the click so we do not trigger that behaviour. - MouseArea { + MouseArea + { anchors.fill: parent; - onClicked: { + onClicked: + { forceActiveFocus() //First grab focus, so all the text fields are updated if(parent.checked) { @@ -63,7 +69,8 @@ Item { } } - UM.PointingRectangle { + UM.PointingRectangle + { id: panelBorder; anchors.left: parent.right; @@ -75,7 +82,8 @@ Item { target: Qt.point(parent.right, base.activeY + UM.Theme.getSize("button").height/2) arrowSize: UM.Theme.getSize("default_arrow").width - width: { + width: + { if (panel.item && panel.width > 0){ return Math.max(panel.width + 2 * UM.Theme.getSize("default_margin").width) } @@ -90,7 +98,8 @@ Item { color: UM.Theme.getColor("lining"); - UM.PointingRectangle { + UM.PointingRectangle + { id: panelBackground; color: UM.Theme.getColor("tool_panel_background"); @@ -105,7 +114,8 @@ Item { } } - Loader { + Loader + { id: panel x: UM.Theme.getSize("default_margin").width; @@ -116,6 +126,8 @@ Item { } } + // This rectangle displays the information about the current angle etc. when + // dragging a tool handle. Rectangle { x: -base.x + base.mouseX + UM.Theme.getSize("default_margin").width From c85f63512500e47c0888ec5bc02bfc33cf826d37 Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Tue, 25 Apr 2017 16:09:51 +0200 Subject: [PATCH 03/10] Add support for overriding the background color of a Tool button Contributes to CURA-3577 --- resources/themes/cura/styles.qml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/resources/themes/cura/styles.qml b/resources/themes/cura/styles.qml index a7c7dcb6cd..625ca4996c 100644 --- a/resources/themes/cura/styles.qml +++ b/resources/themes/cura/styles.qml @@ -206,7 +206,10 @@ QtObject { property bool down: control.pressed || (control.checkable && control.checked); color: { - if(control.checkable && control.checked && control.hovered) { + if(control.customColor !== undefined && control.customColor !== null) { + return control.customColor + } + else if(control.checkable && control.checked && control.hovered) { return Theme.getColor("button_active_hover"); } else if(control.pressed || (control.checkable && control.checked)) { return Theme.getColor("button_active"); From 48baf272b4caaaf6c99dcec1302a341a77629fca Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Tue, 25 Apr 2017 16:10:44 +0200 Subject: [PATCH 04/10] Fix the extruder icons to have a proper square aspect ratio Contributes to CURA-3577 --- .../cura/icons/material_not_selected.svg | 90 +++++++++++++++--- .../themes/cura/icons/material_selected.svg | 91 ++++++++++++++++--- 2 files changed, 153 insertions(+), 28 deletions(-) diff --git a/resources/themes/cura/icons/material_not_selected.svg b/resources/themes/cura/icons/material_not_selected.svg index 2d4fb7cfd3..9b3cad88bd 100644 --- a/resources/themes/cura/icons/material_not_selected.svg +++ b/resources/themes/cura/icons/material_not_selected.svg @@ -1,15 +1,77 @@ - - - - Artboard 3 - Created with Sketch. - - - - - - - - + + + + + + image/svg+xml + + Artboard 3 + + + + + + Artboard 3 + Created with Sketch. + + + + + + + - \ No newline at end of file + + diff --git a/resources/themes/cura/icons/material_selected.svg b/resources/themes/cura/icons/material_selected.svg index 87ffdf55da..6589eac416 100644 --- a/resources/themes/cura/icons/material_selected.svg +++ b/resources/themes/cura/icons/material_selected.svg @@ -1,15 +1,78 @@ - - - - Artboard 3 Copy - Created with Sketch. - - - - - - - - + + + + + + image/svg+xml + + Artboard 3 Copy + + + + + + Artboard 3 Copy + Created with Sketch. + + + + + + + - \ No newline at end of file + + From 89e6313143589500a6f9cd77475ee79de0f2d845 Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Tue, 25 Apr 2017 16:11:31 +0200 Subject: [PATCH 05/10] Add buttons to select the extruder for the selection to the toolbar Contributes to CURA-3577 --- resources/qml/ExtruderButton.qml | 86 ++++++++++++++++++++++++++++++++ resources/qml/Toolbar.qml | 22 +++++++- 2 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 resources/qml/ExtruderButton.qml diff --git a/resources/qml/ExtruderButton.qml b/resources/qml/ExtruderButton.qml new file mode 100644 index 0000000000..8a088890a9 --- /dev/null +++ b/resources/qml/ExtruderButton.qml @@ -0,0 +1,86 @@ +// Copyright (c) 2017 Ultimaker B.V. +// Cura is released under the terms of the AGPLv3 or higher. + +import QtQuick 2.2 +import QtQuick.Controls 1.1 + +import UM 1.2 as UM +import Cura 1.0 as Cura + +Button +{ + id: base + + property var extruder; + + text: catalog.i18ncp("@label", "Print Selected Model with %1", "Print Selected Models With %1", UM.Selection.selectionCount).arg(extruder.name) + + style: UM.Theme.styles.tool_button; + iconSource: checked ? UM.Theme.getIcon("material_selected") : UM.Theme.getIcon("material_not_selected"); + + checkable: true; + checked: ExtruderManager.selectedObjectExtruders.indexOf(extruder.id) != -1 + enabled: UM.Selection.hasSelection + + property color customColor: base.hovered ? UM.Theme.getColor("button_hover") : UM.Theme.getColor("button"); + + Rectangle + { + anchors.fill: parent + anchors.margins: UM.Theme.getSize("default_lining").width; + + color: "transparent" + + border.width: base.checked ? UM.Theme.getSize("default_lining").width : 0; + border.color: UM.Theme.getColor("button_text") + } + + Item + { + anchors + { + right: parent.right; + top: parent.top; + margins: UM.Theme.getSize("default_lining").width * 3 + } + width: UM.Theme.getSize("default_margin").width + height: UM.Theme.getSize("default_margin").height + + Text + { + anchors.centerIn: parent; + text: index + 1; + color: parent.enabled ? UM.Theme.getColor("button_text") : UM.Theme.getColor("button_disabled_text") + font: UM.Theme.getFont("default_bold"); + } + } + + Rectangle + { + anchors + { + left: parent.left; + top: parent.top; + margins: UM.Theme.getSize("default_lining").width * 3 + } + + color: model.color + + width: UM.Theme.getSize("default_margin").width + height: UM.Theme.getSize("default_margin").height + + border.width: UM.Theme.getSize("default_lining").width + border.color: UM.Theme.getColor("lining"); + } + + // See line 51, same workaround + MouseArea + { + anchors.fill: parent; + onClicked: + { + forceActiveFocus() //First grab focus, so all the text fields are updated + CuraActions.setExtruderForSelection(extruder.id); + } + } +} diff --git a/resources/qml/Toolbar.qml b/resources/qml/Toolbar.qml index 6363aa4e42..0f930d532b 100644 --- a/resources/qml/Toolbar.qml +++ b/resources/qml/Toolbar.qml @@ -6,7 +6,8 @@ import QtQuick.Controls 1.1 import QtQuick.Controls.Styles 1.1 import QtQuick.Layouts 1.1 -import UM 1.0 as UM +import UM 1.2 as UM +import Cura 1.0 as Cura Item { @@ -67,6 +68,14 @@ Item } } } + + Item { height: UM.Theme.getSize("default_margin").height; width: 1; visible: machineExtruderCount.properties.value > 1 } + + Repeater + { + model: Cura.ExtrudersModel { id: extrudersModel } + ExtruderButton { extruder: model } + } } UM.PointingRectangle @@ -147,4 +156,15 @@ Item visible: toolHint.text != ""; } + + UM.SettingPropertyProvider + { + id: machineExtruderCount + + containerStackId: Cura.MachineManager.activeMachineId + key: "machine_extruder_count" + watchedProperties: [ "value" ] + } + + UM.I18nCatalog { id: catalog; name: "cura" } } From 78221738817dbc5b19873cbc1156cf157317f8cf Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Tue, 25 Apr 2017 16:12:03 +0200 Subject: [PATCH 06/10] Remove extruder selection from per-object settings tool Contributes to CURA-3577 --- .../PerObjectSettingsPanel.qml | 123 ------------------ 1 file changed, 123 deletions(-) diff --git a/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml b/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml index cb65da635b..c3c7249155 100644 --- a/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml +++ b/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml @@ -26,129 +26,6 @@ Item { spacing: UM.Theme.getSize("default_margin").height - Row - { - spacing: UM.Theme.getSize("default_margin").width - Label - { - text: catalog.i18nc("@label Followed by extruder selection drop-down.", "Print model with") - anchors.verticalCenter: extruderSelector.verticalCenter - - color: UM.Theme.getColor("setting_control_text") - font: UM.Theme.getFont("default") - visible: extruderSelector.visible - } - ComboBox - { - id: extruderSelector - - model: Cura.ExtrudersModel - { - id: extrudersModel - onModelChanged: extruderSelector.color = extrudersModel.getItem(extruderSelector.currentIndex).color - } - property string color: extrudersModel.getItem(extruderSelector.currentIndex).color - visible: machineExtruderCount.properties.value > 1 - textRole: "name" - width: UM.Theme.getSize("setting_control").width - height: UM.Theme.getSize("section").height - MouseArea - { - anchors.fill: parent - acceptedButtons: Qt.NoButton - onWheel: wheel.accepted = true; - } - - style: ComboBoxStyle - { - background: Rectangle - { - color: - { - if(extruderSelector.hovered || base.activeFocus) - { - return UM.Theme.getColor("setting_control_highlight"); - } - else - { - return UM.Theme.getColor("setting_control"); - } - } - border.width: UM.Theme.getSize("default_lining").width - border.color: UM.Theme.getColor("setting_control_border") - } - label: Item - { - Rectangle - { - id: swatch - height: UM.Theme.getSize("setting_control").height / 2 - width: height - anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("default_lining").width - anchors.verticalCenter: parent.verticalCenter - - color: extruderSelector.color - border.width: UM.Theme.getSize("default_lining").width - border.color: !enabled ? UM.Theme.getColor("setting_control_disabled_border") : UM.Theme.getColor("setting_control_border") - } - Label - { - anchors.left: swatch.right - anchors.leftMargin: UM.Theme.getSize("default_lining").width - anchors.right: downArrow.left - anchors.rightMargin: UM.Theme.getSize("default_lining").width - anchors.verticalCenter: parent.verticalCenter - - text: extruderSelector.currentText - font: UM.Theme.getFont("default") - color: !enabled ? UM.Theme.getColor("setting_control_disabled_text") : UM.Theme.getColor("setting_control_text") - - elide: Text.ElideRight - verticalAlignment: Text.AlignVCenter - } - - UM.RecolorImage - { - id: downArrow - anchors.right: parent.right - anchors.rightMargin: UM.Theme.getSize("default_lining").width * 2 - anchors.verticalCenter: parent.verticalCenter - - source: UM.Theme.getIcon("arrow_bottom") - width: UM.Theme.getSize("standard_arrow").width - height: UM.Theme.getSize("standard_arrow").height - sourceSize.width: width + 5 - sourceSize.height: width + 5 - - color: UM.Theme.getColor("setting_control_text") - } - } - } - - onActivated: - { - UM.ActiveTool.setProperty("SelectedActiveExtruder", extrudersModel.getItem(index).id); - extruderSelector.color = extrudersModel.getItem(index).color; - } - onModelChanged: updateCurrentIndex(); - - function updateCurrentIndex() - { - for(var i = 0; i < extrudersModel.rowCount(); ++i) - { - if(extrudersModel.getItem(i).id == UM.ActiveTool.properties.getValue("SelectedActiveExtruder")) - { - extruderSelector.currentIndex = i; - extruderSelector.color = extrudersModel.getItem(i).color; - return; - } - } - extruderSelector.currentIndex = -1; - } - } - } - Column { // This is to ensure that the panel is first increasing in size up to 200 and then shows a scrollbar. From 0fad973181209d2f8680cf434de21d465d40f0fd Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Tue, 25 Apr 2017 16:12:36 +0200 Subject: [PATCH 07/10] Never enable the per-object tool when in simple mode Contributes to CURA-3577 --- plugins/PerObjectSettingsTool/PerObjectSettingsTool.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py b/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py index 865401804c..b2d14942ba 100644 --- a/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py +++ b/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py @@ -112,4 +112,4 @@ class PerObjectSettingsTool(Tool): self._single_model_selected = False # Group is selected, so tool needs to be disabled else: self._single_model_selected = True - Application.getInstance().getController().toolEnabledChanged.emit(self._plugin_id, (self._advanced_mode or self._multi_extrusion) and self._single_model_selected) \ No newline at end of file + Application.getInstance().getController().toolEnabledChanged.emit(self._plugin_id, self._advanced_mode and self._single_model_selected) From b4f27f0af7c1fd640638e77f773a84b4a9781f47 Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Wed, 26 Apr 2017 16:17:54 +0200 Subject: [PATCH 08/10] Remove checkable property and MouseArea in favor of onClicked on the button It turns out, setting checkable: true causes binding breakage. Without checkable, checked still works and we can use onClicked of the button directly. --- resources/qml/ExtruderButton.qml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/resources/qml/ExtruderButton.qml b/resources/qml/ExtruderButton.qml index 8a088890a9..ba503dba2b 100644 --- a/resources/qml/ExtruderButton.qml +++ b/resources/qml/ExtruderButton.qml @@ -18,7 +18,6 @@ Button style: UM.Theme.styles.tool_button; iconSource: checked ? UM.Theme.getIcon("material_selected") : UM.Theme.getIcon("material_not_selected"); - checkable: true; checked: ExtruderManager.selectedObjectExtruders.indexOf(extruder.id) != -1 enabled: UM.Selection.hasSelection @@ -73,14 +72,9 @@ Button border.color: UM.Theme.getColor("lining"); } - // See line 51, same workaround - MouseArea + onClicked: { - anchors.fill: parent; - onClicked: - { - forceActiveFocus() //First grab focus, so all the text fields are updated - CuraActions.setExtruderForSelection(extruder.id); - } + forceActiveFocus() //First grab focus, so all the text fields are updated + CuraActions.setExtruderForSelection(extruder.id); } } From 80bf6988caed91b082a644084929a775fe412eee Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Wed, 26 Apr 2017 16:18:14 +0200 Subject: [PATCH 09/10] Remove unnecessary Catalog and SettingPropertyProvider --- resources/qml/Toolbar.qml | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/resources/qml/Toolbar.qml b/resources/qml/Toolbar.qml index 0f930d532b..5100a0dacb 100644 --- a/resources/qml/Toolbar.qml +++ b/resources/qml/Toolbar.qml @@ -69,10 +69,11 @@ Item } } - Item { height: UM.Theme.getSize("default_margin").height; width: 1; visible: machineExtruderCount.properties.value > 1 } + Item { height: UM.Theme.getSize("default_margin").height; width: 1; visible: extruders.count > 0 } Repeater { + id: extruders model: Cura.ExtrudersModel { id: extrudersModel } ExtruderButton { extruder: model } } @@ -156,15 +157,4 @@ Item visible: toolHint.text != ""; } - - UM.SettingPropertyProvider - { - id: machineExtruderCount - - containerStackId: Cura.MachineManager.activeMachineId - key: "machine_extruder_count" - watchedProperties: [ "value" ] - } - - UM.I18nCatalog { id: catalog; name: "cura" } } From 60339eb44bced2362277623c749faad84999a6c8 Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Wed, 26 Apr 2017 16:18:23 +0200 Subject: [PATCH 10/10] Minor codestyle fix --- resources/themes/cura/styles.qml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/resources/themes/cura/styles.qml b/resources/themes/cura/styles.qml index 625ca4996c..899ea3cf79 100644 --- a/resources/themes/cura/styles.qml +++ b/resources/themes/cura/styles.qml @@ -208,8 +208,7 @@ QtObject { color: { if(control.customColor !== undefined && control.customColor !== null) { return control.customColor - } - else if(control.checkable && control.checked && control.hovered) { + } else if(control.checkable && control.checked && control.hovered) { return Theme.getColor("button_active_hover"); } else if(control.pressed || (control.checkable && control.checked)) { return Theme.getColor("button_active");