From 4bccd2b7b5b0faac7ddd6140c5bebe81c43659cf Mon Sep 17 00:00:00 2001 From: Aleksei S Date: Tue, 20 Nov 2018 23:46:03 +0100 Subject: [PATCH 01/70] Restyle printer settings dropdown CURA-5941 --- plugins/PreviewStage/PreviewMenu.qml | 2 +- resources/qml/ActionButton.qml | 18 +- resources/qml/MachineSelector.qml | 2 +- .../QuickConfigurationSelector.qml | 2 +- resources/qml/PrintSetupSelector.qml | 343 ++++++++++++------ resources/themes/cura-light/theme.json | 7 +- 6 files changed, 251 insertions(+), 123 deletions(-) diff --git a/plugins/PreviewStage/PreviewMenu.qml b/plugins/PreviewStage/PreviewMenu.qml index b331ff69c5..7b3a3af4e3 100644 --- a/plugins/PreviewStage/PreviewMenu.qml +++ b/plugins/PreviewStage/PreviewMenu.qml @@ -3,7 +3,7 @@ import QtQuick 2.7 -import QtQuick.Controls 2.4 +import QtQuick.Controls 2.3 import UM 1.3 as UM import Cura 1.1 as Cura diff --git a/resources/qml/ActionButton.qml b/resources/qml/ActionButton.qml index 2a8b894867..08f4d9d679 100644 --- a/resources/qml/ActionButton.qml +++ b/resources/qml/ActionButton.qml @@ -12,6 +12,7 @@ Button id: button property alias cursorShape: mouseArea.cursorShape property alias iconSource: buttonIcon.source + property alias iconSourceRight: buttonIconRight.source property alias textFont: buttonText.font property alias cornerRadius: backgroundRect.radius property alias tooltip: tooltip.text @@ -29,7 +30,8 @@ Button // we elide the text to the right so the text will be cut off with the three dots at the end. property var fixedWidthMode: false - contentItem: Row + width: buttonIcon.width + buttonText.width + buttonIconRight.width + contentItem: Item { UM.RecolorImage { @@ -57,6 +59,20 @@ Button horizontalAlignment: Text.AlignHCenter elide: Text.ElideRight } + + UM.RecolorImage + { + id: buttonIconRight + source: "" + height: Math.round(0.6 * parent.height) + width: height + sourceSize.width: width + sourceSize.height: height + color: button.hovered ? button.textHoverColor : button.textColor + visible: source != "" + anchors.verticalCenter: parent.verticalCenter + anchors.right: source != "" ? parent.right : undefined + } } background: Rectangle diff --git a/resources/qml/MachineSelector.qml b/resources/qml/MachineSelector.qml index a464949192..c9756d93ba 100644 --- a/resources/qml/MachineSelector.qml +++ b/resources/qml/MachineSelector.qml @@ -2,7 +2,7 @@ // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.2 -import QtQuick.Controls 2.4 +import QtQuick.Controls 2.3 import QtQuick.Controls.Styles 1.1 import QtQuick.Layouts 1.1 diff --git a/resources/qml/Menus/ConfigurationMenu/QuickConfigurationSelector.qml b/resources/qml/Menus/ConfigurationMenu/QuickConfigurationSelector.qml index 33610135fe..d428a05463 100644 --- a/resources/qml/Menus/ConfigurationMenu/QuickConfigurationSelector.qml +++ b/resources/qml/Menus/ConfigurationMenu/QuickConfigurationSelector.qml @@ -4,7 +4,7 @@ import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Controls.Styles 1.4 -import QtQuick.Layouts 1.11 +import QtQuick.Layouts 1.3 import QtQuick.Controls 1.1 as OldControls diff --git a/resources/qml/PrintSetupSelector.qml b/resources/qml/PrintSetupSelector.qml index b843244147..ed09238b51 100644 --- a/resources/qml/PrintSetupSelector.qml +++ b/resources/qml/PrintSetupSelector.qml @@ -28,8 +28,15 @@ Cura.ExpandableComponent height: childrenRect.height iconSource: UM.Theme.getIcon("pencil") + popupPadding : 0 + onCurrentModeIndexChanged: UM.Preferences.setValue("cura/active_mode", currentModeIndex) + Component.onCompleted: + { + popupItemWrapper.width = base.width + } + UM.I18nCatalog { id: catalog @@ -109,142 +116,242 @@ Cura.ExpandableComponent } } - popupItem: Item + + Cura.ExtrudersModel { - height: settingsModeSelection.height + sidebarContents.height + 2 * UM.Theme.getSize("default_margin").height - width: UM.Theme.getSize("print_setup_widget").width - ListView - { - // Settings mode selection toggle - id: settingsModeSelection - model: modesListModel - height: UM.Theme.getSize("print_setup_mode_toggle").height - visible: !hideSettings + id: extrudersModel + } - anchors - { - right: parent.right - left: parent.left - margins: UM.Theme.getSize("thick_margin").width - } + popupItem: Rectangle + { + property var total_height: popupItemHeader.height + popupItemContent.height + 10 + separator_footer.height + id: popupItemWrapper + height: total_height - ButtonGroup - { - id: modeMenuGroup - } - - delegate: Button - { - id: control - - height: settingsModeSelection.height - width: Math.round(parent.width / 2) - - anchors.left: parent.left - anchors.leftMargin: model.index * Math.round(settingsModeSelection.width / 2) - anchors.verticalCenter: parent.verticalCenter - - ButtonGroup.group: modeMenuGroup - - checkable: true - checked: base.currentModeIndex == index - onClicked: base.currentModeIndex = index - - onHoveredChanged: - { - if (hovered) - { - tooltipDelayTimer.item = settingsModeSelection - tooltipDelayTimer.text = model.tooltipText - tooltipDelayTimer.start() - } - else - { - tooltipDelayTimer.stop() - base.hideTooltip() - } - } - - background: Rectangle - { - border.width: control.checked ? UM.Theme.getSize("default_lining").width * 2 : UM.Theme.getSize("default_lining").width - border.color: (control.checked || control.pressed) ? UM.Theme.getColor("action_button_active_border") : control.hovered ? UM.Theme.getColor("action_button_hovered_border") : UM.Theme.getColor("action_button_border") - - // For some reason, QtQuick decided to use the color of the background property as text color for the contentItem, so here it is - color: (control.checked || control.pressed) ? UM.Theme.getColor("action_button_active") : control.hovered ? UM.Theme.getColor("action_button_hovered") : UM.Theme.getColor("action_button") - } - - contentItem: Label - { - text: model.text - font: UM.Theme.getFont("default") - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - renderType: Text.NativeRendering - elide: Text.ElideRight - color: - { - if(control.pressed) - { - return UM.Theme.getColor("action_button_active_text") - } - else if(control.hovered) - { - return UM.Theme.getColor("action_button_hovered_text") - } - return UM.Theme.getColor("action_button_text") - } - } - } - } + border.width: UM.Theme.getSize("default_lining").width + border.color: UM.Theme.getColor("lining") Item { - id: sidebarContents - anchors.top: settingsModeSelection.bottom - anchors.topMargin: UM.Theme.getSize("thick_margin").height - anchors.left: parent.left - anchors.right: parent.right - height: UM.Theme.getSize("print_setup_widget").height + id: popupItemHeader + height: 36 - visible: !hideSettings - - // We load both of them at once (instead of using a loader) because the advanced sidebar can take - // quite some time to load. So in this case we sacrifice memory for speed. - SidebarAdvanced + anchors { - anchors.fill: parent - visible: currentModeIndex == 1 - onShowTooltip: base.showTooltip(item, location, text) - onHideTooltip: base.hideTooltip() + top: parent.top + right: parent.right + left: parent.left } - SidebarSimple + Label { - anchors.fill: parent - visible: currentModeIndex != 1 - onShowTooltip: base.showTooltip(item, location, text) - onHideTooltip: base.hideTooltip() + id: popupItemHeaderText + text: catalog.i18nc("@label", "Print settings"); + font: UM.Theme.getFont("default") + verticalAlignment: Text.AlignVCenter + color: UM.Theme.getColor("text") + height: parent.height + anchors.topMargin: UM.Theme.getSize("sidebar_margin").height + anchors.bottomMargin: UM.Theme.getSize("sidebar_margin").height + anchors.left: parent.left + anchors.leftMargin: UM.Theme.getSize("print_setup_selector_margin").height + } + + Rectangle + { + width: parent.width + height: UM.Theme.getSize("default_lining").height + anchors.top: popupItemHeaderText.bottom + color: UM.Theme.getColor("action_button_border") + + } } - // Setting mode: Recommended or Custom - ListModel + Rectangle { - id: modesListModel + id: popupItemContent + width: parent.width + height: tabBar.height + sidebarContents.height + anchors + { + top: popupItemHeader.bottom + topMargin: 10 + right: parent.right + left: parent.left + leftMargin: 5 + rightMargin: 5 + } + + + TabBar + { + id: tabBar + onCurrentIndexChanged: Cura.ExtruderManager.setActiveExtruderIndex(currentIndex) + width: parent.width + height: UM.Theme.getSize("print_setup_tap_bar").width + z: 1 + Repeater + { + id: extruder_model_repeater + model: extrudersModel + + delegate: TabButton + { + z: 2 + width: ListView.view != null ? Math.round(ListView.view.width / extrudersModel.rowCount()): 0 + implicitHeight: parent.height + + contentItem: Rectangle + { + z: 2 + Cura.ExtruderIcon + { + anchors.horizontalCenter: parent.horizontalCenter + materialColor: model.color + extruderEnabled: model.enabled + width: parent.height + height: parent.height + } + + } + + background: Rectangle + { + + width: parent.width + z: 1 + border.width: UM.Theme.getSize("default_lining").width * 2 + border.color: UM.Theme.getColor("action_button_border") + + visible: + { + return index == tabBar.currentIndex + } + + // overlap bottom border + Rectangle + { + width: parent.width - 4 + height: 4 + anchors.bottom: parent.bottom + anchors.bottomMargin: -2 + anchors.leftMargin: 2 + anchors.left: parent.left + + } + } + } + } + } + + Rectangle + { + id: sidebarContents + anchors.top: tabBar.bottom + anchors.left: parent.left + anchors.right: parent.right + height: UM.Theme.getSize("print_setup_widget").height + + + border.width: UM.Theme.getSize("default_lining").width * 2 + border.color: UM.Theme.getColor("action_button_border") + + SidebarSimple + { + anchors.topMargin: UM.Theme.getSize("print_setup_content_top_margin").height + id: sidebar_simple_id + anchors.fill: parent + visible: currentModeIndex != 1 + onShowTooltip: base.showTooltip(item, location, text) + onHideTooltip: base.hideTooltip() + } + + SidebarAdvanced + { + anchors.topMargin: UM.Theme.getSize("print_setup_content_top_margin").height + anchors.bottomMargin: 2 //does not overlap bottom border + anchors.fill: parent + visible: currentModeIndex == 1 + onShowTooltip: base.showTooltip(item, location, text) + onHideTooltip: base.hideTooltip() + } + + } } + + Item + { + id: separator_footer + anchors.top: popupItemContent.bottom + anchors.topMargin: 10 + width: parent.width + height: settingControlButton.height + 4 + + Rectangle + { + width: parent.width + height: UM.Theme.getSize("default_lining").height + color: UM.Theme.getColor("action_button_border") + } + + Cura.ActionButton + { + id: settingControlButton + + leftPadding: UM.Theme.getSize("default_margin").width + rightPadding: UM.Theme.getSize("default_margin").width + height: UM.Theme.getSize("action_panel_button").height + text: catalog.i18nc("@button", "Custom") + color: UM.Theme.getColor("secondary") + hoverColor: UM.Theme.getColor("secondary") + textColor: UM.Theme.getColor("primary") + textHoverColor: UM.Theme.getColor("text") + iconSourceRight: UM.Theme.getIcon("arrow_right") + width: UM.Theme.getSize("print_setup_action_button").width + fixedWidthMode: true + visible: currentModeIndex == 0 + anchors + { + top: parent.top + topMargin: 10 + bottomMargin: 10 + right: parent.right + rightMargin: 5 + } + + onClicked: currentModeIndex = 1 + } + + Cura.ActionButton + { + height: UM.Theme.getSize("action_panel_button").height + text: catalog.i18nc("@button", "Recommended") + color: UM.Theme.getColor("secondary") + hoverColor: UM.Theme.getColor("secondary") + textColor: UM.Theme.getColor("primary") + textHoverColor: UM.Theme.getColor("text") + iconSource: UM.Theme.getIcon("arrow_left") + width: UM.Theme.getSize("print_setup_action_button").width + + + fixedWidthMode: true + visible: currentModeIndex == 1 + anchors + { + top: parent.top + topMargin: UM.Theme.getSize("print_setup_selector_margin").height * 2 + bottomMargin: UM.Theme.getSize("print_setup_selector_margin").height * 2 + left: parent.left + leftMargin: UM.Theme.getSize("print_setup_selector_margin").height + } + + onClicked: currentModeIndex = 0 + } + } Component.onCompleted: { - modesListModel.append({ - text: catalog.i18nc("@title:tab", "Recommended"), - tooltipText: "%1

%2".arg(catalog.i18nc("@tooltip:title", "Recommended Print Setup")).arg(catalog.i18nc("@tooltip", "Print with the recommended settings for the selected printer, material and quality.")) - }) - modesListModel.append({ - text: catalog.i18nc("@title:tab", "Custom"), - tooltipText: "%1

%2".arg(catalog.i18nc("@tooltip:title", "Custom Print Setup")).arg(catalog.i18nc("@tooltip", "Print with finegrained control over every last bit of the slicing process.")) - }) - var index = Math.round(UM.Preferences.getValue("cura/active_mode")) if(index != null && !isNaN(index)) @@ -257,4 +364,4 @@ Cura.ExpandableComponent } } } -} +} \ No newline at end of file diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index d28611529b..fc62edc480 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -528,6 +528,11 @@ "monitor_thick_lining": [0.16, 0.16], "monitor_corner_radius": [0.3, 0.3], "monitor_shadow_radius": [0.4, 0.4], - "monitor_shadow_offset": [0.15, 0.15] + "monitor_shadow_offset": [0.15, 0.15], + + "print_setup_selector_margin": [0.5, 0.5], + "print_setup_action_button": [13, 5], + "print_setup_tap_bar": [4, 4], + "print_setup_content_top_margin": [3, 3] } } From bfd8e666570d636293bae9dbda0c2134de992065 Mon Sep 17 00:00:00 2001 From: Aleksei S Date: Wed, 21 Nov 2018 12:50:18 +0100 Subject: [PATCH 02/70] Removed margins and unused arches CURA-5941 --- resources/qml/PrintSetupSelector.qml | 46 +++++++++++++--------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/resources/qml/PrintSetupSelector.qml b/resources/qml/PrintSetupSelector.qml index ed09238b51..61cc06b426 100644 --- a/resources/qml/PrintSetupSelector.qml +++ b/resources/qml/PrintSetupSelector.qml @@ -116,7 +116,6 @@ Cura.ExpandableComponent } } - Cura.ExtrudersModel { id: extrudersModel @@ -124,7 +123,7 @@ Cura.ExpandableComponent popupItem: Rectangle { - property var total_height: popupItemHeader.height + popupItemContent.height + 10 + separator_footer.height + property var total_height: popupItemHeader.height + popupItemContent.height + footerControll.height + UM.Theme.getSize("print_setup_selector_margin").height * 2 id: popupItemWrapper height: total_height @@ -176,7 +175,7 @@ Cura.ExpandableComponent anchors { top: popupItemHeader.bottom - topMargin: 10 + topMargin: UM.Theme.getSize("print_setup_selector_margin").height right: parent.right left: parent.left leftMargin: 5 @@ -213,7 +212,6 @@ Cura.ExpandableComponent width: parent.height height: parent.height } - } background: Rectangle @@ -232,11 +230,11 @@ Cura.ExpandableComponent // overlap bottom border Rectangle { - width: parent.width - 4 - height: 4 + width: parent.width - UM.Theme.getSize("default_lining").width * 4 + height: UM.Theme.getSize("default_lining").width * 4 anchors.bottom: parent.bottom - anchors.bottomMargin: -2 - anchors.leftMargin: 2 + anchors.bottomMargin: - (UM.Theme.getSize("default_lining").width * 2) + anchors.leftMargin: UM.Theme.getSize("default_lining").width * 2 anchors.left: parent.left } @@ -249,18 +247,17 @@ Cura.ExpandableComponent { id: sidebarContents anchors.top: tabBar.bottom + anchors.bottom: parent.bottom anchors.left: parent.left anchors.right: parent.right height: UM.Theme.getSize("print_setup_widget").height - border.width: UM.Theme.getSize("default_lining").width * 2 border.color: UM.Theme.getColor("action_button_border") SidebarSimple { anchors.topMargin: UM.Theme.getSize("print_setup_content_top_margin").height - id: sidebar_simple_id anchors.fill: parent visible: currentModeIndex != 1 onShowTooltip: base.showTooltip(item, location, text) @@ -270,25 +267,22 @@ Cura.ExpandableComponent SidebarAdvanced { anchors.topMargin: UM.Theme.getSize("print_setup_content_top_margin").height - anchors.bottomMargin: 2 //does not overlap bottom border + anchors.bottomMargin: 2 //don't overlap bottom border anchors.fill: parent visible: currentModeIndex == 1 onShowTooltip: base.showTooltip(item, location, text) onHideTooltip: base.hideTooltip() } - } } - Item { - id: separator_footer + id: footerControll anchors.top: popupItemContent.bottom - anchors.topMargin: 10 + anchors.topMargin: UM.Theme.getSize("print_setup_selector_margin").height * 2 width: parent.width - height: settingControlButton.height + 4 - + height: settingControlButton.height + UM.Theme.getSize("default_lining").height * 4 Rectangle { width: parent.width @@ -299,7 +293,6 @@ Cura.ExpandableComponent Cura.ActionButton { id: settingControlButton - leftPadding: UM.Theme.getSize("default_margin").width rightPadding: UM.Theme.getSize("default_margin").width height: UM.Theme.getSize("action_panel_button").height @@ -315,10 +308,10 @@ Cura.ExpandableComponent anchors { top: parent.top - topMargin: 10 - bottomMargin: 10 + topMargin: UM.Theme.getSize("print_setup_selector_margin").height * 2 + bottomMargin: UM.Theme.getSize("print_setup_selector_margin").height * 2 right: parent.right - rightMargin: 5 + rightMargin: UM.Theme.getSize("print_setup_selector_margin").height } onClicked: currentModeIndex = 1 @@ -334,8 +327,6 @@ Cura.ExpandableComponent textHoverColor: UM.Theme.getColor("text") iconSource: UM.Theme.getIcon("arrow_left") width: UM.Theme.getSize("print_setup_action_button").width - - fixedWidthMode: true visible: currentModeIndex == 1 anchors @@ -347,7 +338,14 @@ Cura.ExpandableComponent leftMargin: UM.Theme.getSize("print_setup_selector_margin").height } - onClicked: currentModeIndex = 0 +// onClicked: currentModeIndex = 0 + MouseArea { + anchors.fill: parent + onClicked: { + currentModeIndex = 0 + + } + } } } Component.onCompleted: From 666ed595e5ed91cf4140b164abb745a021da03e7 Mon Sep 17 00:00:00 2001 From: Aleksei S Date: Fri, 23 Nov 2018 11:36:31 +0100 Subject: [PATCH 03/70] Added space --- resources/qml/PrintSetupSelector.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/qml/PrintSetupSelector.qml b/resources/qml/PrintSetupSelector.qml index 61cc06b426..7cb47002a7 100644 --- a/resources/qml/PrintSetupSelector.qml +++ b/resources/qml/PrintSetupSelector.qml @@ -348,6 +348,7 @@ Cura.ExpandableComponent } } } + Component.onCompleted: { var index = Math.round(UM.Preferences.getValue("cura/active_mode")) From c4d0207cc13abfb75da88a8c50c3a9c19147b964 Mon Sep 17 00:00:00 2001 From: Aleksei S Date: Fri, 23 Nov 2018 13:10:48 +0100 Subject: [PATCH 04/70] Added close button in right top corner CURA-5941 --- resources/qml/PrintSetupSelector.qml | 33 +++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/resources/qml/PrintSetupSelector.qml b/resources/qml/PrintSetupSelector.qml index 7cb47002a7..8271484e6a 100644 --- a/resources/qml/PrintSetupSelector.qml +++ b/resources/qml/PrintSetupSelector.qml @@ -151,7 +151,7 @@ Cura.ExpandableComponent color: UM.Theme.getColor("text") height: parent.height anchors.topMargin: UM.Theme.getSize("sidebar_margin").height - anchors.bottomMargin: UM.Theme.getSize("sidebar_margin").height +// anchors.bottomMargin: UM.Theme.getSize("sidebar_margin").height anchors.left: parent.left anchors.leftMargin: UM.Theme.getSize("print_setup_selector_margin").height } @@ -165,6 +165,37 @@ Cura.ExpandableComponent } + + Button + { + id: closeButton; + width: UM.Theme.getSize("message_close").width; + height: UM.Theme.getSize("message_close").height; + + anchors + { + right: parent.right; + rightMargin: UM.Theme.getSize("default_margin").width; + top: parent.top; + topMargin: 10 + } + + UM.RecolorImage + { + anchors.fill: parent; + sourceSize.width: width + sourceSize.height: width + color: UM.Theme.getColor("message_text") + source: UM.Theme.getIcon("cross1") + } + + onClicked: base.model.hideMessage(model.id) + + background: Rectangle + { + color: UM.Theme.getColor("message_background") + } + } } Rectangle From 2e262dd9d22add74f7ee5b638a64c1b9bc63ff27 Mon Sep 17 00:00:00 2001 From: Aleksei S Date: Fri, 23 Nov 2018 17:35:55 +0100 Subject: [PATCH 05/70] Added Icons to SidebarSimple --- resources/qml/SidebarSimple.qml | 58 ++++++++++++++++----------------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/resources/qml/SidebarSimple.qml b/resources/qml/SidebarSimple.qml index 5e723a3d70..52fc9320f2 100644 --- a/resources/qml/SidebarSimple.qml +++ b/resources/qml/SidebarSimple.qml @@ -187,12 +187,11 @@ Item } } - Label + IconWithText { id: qualityRowTitle + source: UM.Theme.getIcon("category_layer_height") text: catalog.i18nc("@label", "Layer Height") - font: UM.Theme.getFont("default") - color: UM.Theme.getColor("text") } // Show titles for the each quality slider ticks @@ -532,17 +531,19 @@ Item width: Math.round(UM.Theme.getSize("print_setup_widget").width * .45) - UM.Theme.getSize("thick_margin").width - Label + IconWithText { id: infillLabel - text: catalog.i18nc("@label", "Infill") - font: UM.Theme.getFont("default") - color: UM.Theme.getColor("text") + source: UM.Theme.getIcon("category_infill") + text: catalog.i18nc("@label", "Infill") + " (%)" - anchors.top: parent.top - anchors.topMargin: Math.round(UM.Theme.getSize("thick_margin").height * 1.7) - anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("thick_margin").width + anchors + { + top: parent.top + topMargin: Math.round(UM.Theme.getSize("thick_margin").height * 1.7) + left: parent.left + leftMargin: UM.Theme.getSize("thick_margin").width + } } } @@ -855,23 +856,23 @@ Item // // Enable support // - Label + IconWithText { id: enableSupportLabel visible: enableSupportCheckBox.visible + source: UM.Theme.getIcon("category_support") + text: catalog.i18nc("@label", "Support") - anchors.top: infillCellRight.bottom - anchors.topMargin: Math.round(UM.Theme.getSize("thick_margin").height * 1.5) - anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("thick_margin").width - anchors.right: infillCellLeft.right - anchors.rightMargin: UM.Theme.getSize("thick_margin").width - anchors.verticalCenter: enableSupportCheckBox.verticalCenter - - text: catalog.i18nc("@label", "Generate Support") - font: UM.Theme.getFont("default") - color: UM.Theme.getColor("text") - elide: Text.ElideRight + anchors + { + top: infillCellRight.bottom + topMargin: Math.round(UM.Theme.getSize("thick_margin").height * 1.5) + left: parent.left + leftMargin: UM.Theme.getSize("thick_margin").width + right: infillCellLeft.right + rightMargin: UM.Theme.getSize("thick_margin").width + verticalCenter: enableSupportCheckBox.verticalCenter + } } CheckBox @@ -980,15 +981,12 @@ Item } - Label + IconWithText { id: adhesionHelperLabel visible: adhesionCheckBox.visible - - text: catalog.i18nc("@label", "Build Plate Adhesion") - font: UM.Theme.getFont("default") - color: UM.Theme.getColor("text") - elide: Text.ElideRight + source: UM.Theme.getIcon("category_adhesion") + text: catalog.i18nc("@label", "Adhesion") anchors { From ec63e6c13066d307238a7e176f04adee8df1dbf3 Mon Sep 17 00:00:00 2001 From: Aleksei S Date: Tue, 27 Nov 2018 09:27:25 +0100 Subject: [PATCH 06/70] Added icons CURA-5941 --- resources/qml/SidebarSimple.qml | 53 ++++++--------------------------- 1 file changed, 9 insertions(+), 44 deletions(-) diff --git a/resources/qml/SidebarSimple.qml b/resources/qml/SidebarSimple.qml index 52fc9320f2..2e0f0d6c4c 100644 --- a/resources/qml/SidebarSimple.qml +++ b/resources/qml/SidebarSimple.qml @@ -192,13 +192,15 @@ Item id: qualityRowTitle source: UM.Theme.getIcon("category_layer_height") text: catalog.i18nc("@label", "Layer Height") + anchors.bottom: speedSlider.bottom + } // Show titles for the each quality slider ticks Item { - y: -5; anchors.left: speedSlider.left + anchors.top: speedSlider.bottom Repeater { model: qualityModel @@ -206,8 +208,7 @@ Item Label { anchors.verticalCenter: parent.verticalCenter - anchors.top: parent.top - anchors.topMargin: Math.round(UM.Theme.getSize("thick_margin").height / 2) + anchors.top: parent.bottom color: (Cura.MachineManager.activeMachine != null && Cura.QualityProfilesDropDownMenuModel.getItem(index).available) ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") text: { @@ -258,7 +259,7 @@ Item } //Print speed slider - Item + Rectangle { id: speedSlider width: Math.round(base.width * 0.55) @@ -367,12 +368,12 @@ Item Rectangle { - anchors.verticalCenter: parent.verticalCenter color: Cura.QualityProfilesDropDownMenuModel.getItem(index).available ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") - width: 1 * screenScaleFactor - height: 6 * screenScaleFactor - y: 0 + implicitWidth: 5 * screenScaleFactor + implicitHeight: implicitWidth + anchors.verticalCenter: qualitySlider.verticalCenter x: Math.round(qualityModel.qualitySliderStepWidth * index) + radius: Math.round(implicitWidth / 2) } } @@ -453,42 +454,6 @@ Item } } - Label - { - id: speedLabel - anchors.top: speedSlider.bottom - - anchors.left: parent.left - - text: catalog.i18nc("@label", "Print Speed") - font: UM.Theme.getFont("default") - color: UM.Theme.getColor("text") - width: Math.round(UM.Theme.getSize("print_setup_widget").width * 0.35) - elide: Text.ElideRight - } - - Label - { - anchors.bottom: speedLabel.bottom - anchors.left: speedSlider.left - - text: catalog.i18nc("@label", "Slower") - font: UM.Theme.getFont("default") - color: (qualityModel.availableTotalTicks > 1) ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") - horizontalAlignment: Text.AlignLeft - } - - Label - { - anchors.bottom: speedLabel.bottom - anchors.right: speedSlider.right - - text: catalog.i18nc("@label", "Faster") - font: UM.Theme.getFont("default") - color: (qualityModel.availableTotalTicks > 1) ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") - horizontalAlignment: Text.AlignRight - } - UM.SimpleButton { id: customisedSettings From e6c2238fd51a5eec44a645ad4a1e798120bf58a5 Mon Sep 17 00:00:00 2001 From: Aleksei S Date: Tue, 27 Nov 2018 11:24:09 +0100 Subject: [PATCH 07/70] Added popup spacing by Y coordinate CURA-5941 --- resources/qml/ExpandableComponent.qml | 5 ++++- resources/qml/PrintSetupSelector.qml | 12 ++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/resources/qml/ExpandableComponent.qml b/resources/qml/ExpandableComponent.qml index 262c6bfd3f..3b1105ddd6 100644 --- a/resources/qml/ExpandableComponent.qml +++ b/resources/qml/ExpandableComponent.qml @@ -24,6 +24,9 @@ Item // How much spacing is needed around the popupItem property alias popupPadding: popup.padding + // How much spacing is needed for the popupItem by Y coordinate + property var popupSpacingY: 0 + // How much padding is needed around the header & button property alias headerPadding: background.padding @@ -143,7 +146,7 @@ Item id: popup // Ensure that the popup is located directly below the headerItem - y: headerItemLoader.height + 2 * background.padding + y: headerItemLoader.height + 2 * background.padding + popupSpacingY // Make the popup right aligned with the rest. The 3x padding is due to left, right and padding between // the button & text. diff --git a/resources/qml/PrintSetupSelector.qml b/resources/qml/PrintSetupSelector.qml index 8271484e6a..5f593f9ba2 100644 --- a/resources/qml/PrintSetupSelector.qml +++ b/resources/qml/PrintSetupSelector.qml @@ -29,6 +29,7 @@ Cura.ExpandableComponent iconSource: UM.Theme.getIcon("pencil") popupPadding : 0 + popupSpacingY: 10 onCurrentModeIndexChanged: UM.Preferences.setValue("cura/active_mode", currentModeIndex) @@ -150,10 +151,13 @@ Cura.ExpandableComponent verticalAlignment: Text.AlignVCenter color: UM.Theme.getColor("text") height: parent.height - anchors.topMargin: UM.Theme.getSize("sidebar_margin").height -// anchors.bottomMargin: UM.Theme.getSize("sidebar_margin").height - anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("print_setup_selector_margin").height + + anchors + { + topMargin: UM.Theme.getSize("sidebar_margin").height + left: parent.left + leftMargin: UM.Theme.getSize("print_setup_selector_margin").height + } } Rectangle From 6956a732a0453f6f51dea1f381451346fe241009 Mon Sep 17 00:00:00 2001 From: Aleksei S Date: Tue, 27 Nov 2018 13:49:04 +0100 Subject: [PATCH 08/70] Use tapbar component from UM, change the print_setup_widget width --- resources/qml/PrintSetupSelector.qml | 17 +++++------------ resources/themes/cura-light/theme.json | 2 +- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/resources/qml/PrintSetupSelector.qml b/resources/qml/PrintSetupSelector.qml index 5f593f9ba2..279254ec64 100644 --- a/resources/qml/PrintSetupSelector.qml +++ b/resources/qml/PrintSetupSelector.qml @@ -5,7 +5,7 @@ import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Layouts 1.3 -import UM 1.2 as UM +import UM 1.3 as UM import Cura 1.0 as Cura import "Menus" import "Menus/ConfigurationMenu" @@ -217,25 +217,18 @@ Cura.ExpandableComponent rightMargin: 5 } - - TabBar + UM.TabRow { id: tabBar + anchors.top: popupItemHeader.bottom + anchors.topMargin: UM.Theme.getSize("default_margin").height onCurrentIndexChanged: Cura.ExtruderManager.setActiveExtruderIndex(currentIndex) - width: parent.width - height: UM.Theme.getSize("print_setup_tap_bar").width z: 1 Repeater { - id: extruder_model_repeater model: extrudersModel - - delegate: TabButton + delegate: UM.TabRowButton { - z: 2 - width: ListView.view != null ? Math.round(ListView.view.width / extrudersModel.rowCount()): 0 - implicitHeight: parent.height - contentItem: Rectangle { z: 2 diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index 029da9c14b..e6889b50c0 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -381,7 +381,7 @@ "account_button": [12, 3], - "print_setup_widget": [30.0, 42.0], + "print_setup_widget": [38.0, 42.0], "print_setup_mode_toggle": [0.0, 2.0], "print_setup_item": [0.0, 2.0], "print_setup_extruder_box": [0.0, 6.0], From 8784ecd49acad58d0cbbebb8b06bebfe520145e1 Mon Sep 17 00:00:00 2001 From: Aleksei S Date: Tue, 27 Nov 2018 14:09:47 +0100 Subject: [PATCH 09/70] Change native rendering CURA-5941 --- resources/qml/PrintSetupSelector.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/qml/PrintSetupSelector.qml b/resources/qml/PrintSetupSelector.qml index 279254ec64..371232372d 100644 --- a/resources/qml/PrintSetupSelector.qml +++ b/resources/qml/PrintSetupSelector.qml @@ -148,6 +148,7 @@ Cura.ExpandableComponent id: popupItemHeaderText text: catalog.i18nc("@label", "Print settings"); font: UM.Theme.getFont("default") + renderType: Text.NativeRendering verticalAlignment: Text.AlignVCenter color: UM.Theme.getColor("text") height: parent.height From d47806de509d9aeeeebff5c5c410fb17ab35f26d Mon Sep 17 00:00:00 2001 From: Aleksei S Date: Tue, 27 Nov 2018 15:05:35 +0100 Subject: [PATCH 10/70] Change style, added close popitem close behaviour CURA-5941 --- resources/qml/ExpandableComponent.qml | 3 +++ resources/qml/PrintSetupSelector.qml | 37 ++++++++++++-------------- resources/themes/cura-light/theme.json | 2 -- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/resources/qml/ExpandableComponent.qml b/resources/qml/ExpandableComponent.qml index 3b1105ddd6..707b947c7f 100644 --- a/resources/qml/ExpandableComponent.qml +++ b/resources/qml/ExpandableComponent.qml @@ -49,6 +49,9 @@ Item // On what side should the header corners be shown? 1 is down, 2 is left, 3 is up and 4 is right. property alias headerCornerSide: background.cornerSide + // Change the popupItem close behaviour + property alias popupClosePolicy : popup.closePolicy + function togglePopup() { if(popup.visible) diff --git a/resources/qml/PrintSetupSelector.qml b/resources/qml/PrintSetupSelector.qml index 371232372d..b20d8e116b 100644 --- a/resources/qml/PrintSetupSelector.qml +++ b/resources/qml/PrintSetupSelector.qml @@ -29,7 +29,9 @@ Cura.ExpandableComponent iconSource: UM.Theme.getIcon("pencil") popupPadding : 0 - popupSpacingY: 10 + popupSpacingY: UM.Theme.getSize("narrow_margin").width + + popupClosePolicy: Popup.CloseOnEscape onCurrentModeIndexChanged: UM.Preferences.setValue("cura/active_mode", currentModeIndex) @@ -124,7 +126,7 @@ Cura.ExpandableComponent popupItem: Rectangle { - property var total_height: popupItemHeader.height + popupItemContent.height + footerControll.height + UM.Theme.getSize("print_setup_selector_margin").height * 2 + property var total_height: popupItemHeader.height + popupItemContent.height + footerControll.height + UM.Theme.getSize("narrow_margin").height * 2 id: popupItemWrapper height: total_height @@ -157,7 +159,7 @@ Cura.ExpandableComponent { topMargin: UM.Theme.getSize("sidebar_margin").height left: parent.left - leftMargin: UM.Theme.getSize("print_setup_selector_margin").height + leftMargin: UM.Theme.getSize("narrow_margin").height } } @@ -194,7 +196,7 @@ Cura.ExpandableComponent source: UM.Theme.getIcon("cross1") } - onClicked: base.model.hideMessage(model.id) + onClicked: base.togglePopup() // Will hide the popup item background: Rectangle { @@ -211,17 +213,16 @@ Cura.ExpandableComponent anchors { top: popupItemHeader.bottom - topMargin: UM.Theme.getSize("print_setup_selector_margin").height + topMargin: UM.Theme.getSize("narrow_margin").height right: parent.right left: parent.left - leftMargin: 5 - rightMargin: 5 + leftMargin: UM.Theme.getSize("thick_margin").width / 1.5 + rightMargin: UM.Theme.getSize("thick_margin").width / 1.5 } UM.TabRow { id: tabBar - anchors.top: popupItemHeader.bottom anchors.topMargin: UM.Theme.getSize("default_margin").height onCurrentIndexChanged: Cura.ExtruderManager.setActiveExtruderIndex(currentIndex) z: 1 @@ -309,7 +310,7 @@ Cura.ExpandableComponent { id: footerControll anchors.top: popupItemContent.bottom - anchors.topMargin: UM.Theme.getSize("print_setup_selector_margin").height * 2 + anchors.topMargin: UM.Theme.getSize("narrow_margin").height * 2 width: parent.width height: settingControlButton.height + UM.Theme.getSize("default_lining").height * 4 Rectangle @@ -337,10 +338,10 @@ Cura.ExpandableComponent anchors { top: parent.top - topMargin: UM.Theme.getSize("print_setup_selector_margin").height * 2 - bottomMargin: UM.Theme.getSize("print_setup_selector_margin").height * 2 + topMargin: UM.Theme.getSize("narrow_margin").height * 2 + bottomMargin: UM.Theme.getSize("narrow_margin").height * 2 right: parent.right - rightMargin: UM.Theme.getSize("print_setup_selector_margin").height + rightMargin: UM.Theme.getSize("narrow_margin").height } onClicked: currentModeIndex = 1 @@ -361,19 +362,15 @@ Cura.ExpandableComponent anchors { top: parent.top - topMargin: UM.Theme.getSize("print_setup_selector_margin").height * 2 - bottomMargin: UM.Theme.getSize("print_setup_selector_margin").height * 2 + topMargin: UM.Theme.getSize("narrow_margin").height * 2 + bottomMargin: UM.Theme.getSize("narrow_margin").height * 2 left: parent.left - leftMargin: UM.Theme.getSize("print_setup_selector_margin").height + leftMargin: UM.Theme.getSize("narrow_margin").height } -// onClicked: currentModeIndex = 0 MouseArea { anchors.fill: parent - onClicked: { - currentModeIndex = 0 - - } + onClicked: currentModeIndex = 0 } } } diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index e6889b50c0..1228e52b9d 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -535,9 +535,7 @@ "monitor_shadow_radius": [0.4, 0.4], "monitor_shadow_offset": [0.15, 0.15], - "print_setup_selector_margin": [0.5, 0.5], "print_setup_action_button": [13, 5], - "print_setup_tap_bar": [4, 4], "print_setup_content_top_margin": [3, 3] } } From ff851b0382b688b6c190d48127be3e0a369a2960 Mon Sep 17 00:00:00 2001 From: Aleksei S Date: Tue, 27 Nov 2018 16:36:27 +0100 Subject: [PATCH 11/70] Added margins CURA-5941 --- resources/qml/PrintSetupSelector.qml | 4 ++-- resources/qml/SidebarSimple.qml | 10 ++-------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/resources/qml/PrintSetupSelector.qml b/resources/qml/PrintSetupSelector.qml index b20d8e116b..6edb297721 100644 --- a/resources/qml/PrintSetupSelector.qml +++ b/resources/qml/PrintSetupSelector.qml @@ -216,8 +216,8 @@ Cura.ExpandableComponent topMargin: UM.Theme.getSize("narrow_margin").height right: parent.right left: parent.left - leftMargin: UM.Theme.getSize("thick_margin").width / 1.5 - rightMargin: UM.Theme.getSize("thick_margin").width / 1.5 + leftMargin: UM.Theme.getSize("default_margin").width + rightMargin: UM.Theme.getSize("default_margin").width } UM.TabRow diff --git a/resources/qml/SidebarSimple.qml b/resources/qml/SidebarSimple.qml index 2e0f0d6c4c..f2e998f526 100644 --- a/resources/qml/SidebarSimple.qml +++ b/resources/qml/SidebarSimple.qml @@ -38,6 +38,8 @@ Item width: childrenRect.width height: childrenRect.height + anchors.left: parent.left + anchors.leftMargin: UM.Theme.getSize("default_margin").width // // Quality profile // @@ -48,7 +50,6 @@ Item height: UM.Theme.getSize("thick_margin").height anchors.topMargin: UM.Theme.getSize("thick_margin").height anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("thick_margin").width anchors.right: parent.right Timer @@ -193,7 +194,6 @@ Item source: UM.Theme.getIcon("category_layer_height") text: catalog.i18nc("@label", "Layer Height") anchors.bottom: speedSlider.bottom - } // Show titles for the each quality slider ticks @@ -507,7 +507,6 @@ Item top: parent.top topMargin: Math.round(UM.Theme.getSize("thick_margin").height * 1.7) left: parent.left - leftMargin: UM.Theme.getSize("thick_margin").width } } } @@ -526,9 +525,7 @@ Item Label { id: selectedInfillRateText - //anchors.top: parent.top anchors.left: infillSlider.left - anchors.leftMargin: Math.round((infillSlider.value / infillSlider.stepSize) * (infillSlider.width / (infillSlider.maximumValue / infillSlider.stepSize)) - 10 * screenScaleFactor) anchors.right: parent.right text: parseInt(infillDensity.properties.value) + "%" @@ -833,7 +830,6 @@ Item top: infillCellRight.bottom topMargin: Math.round(UM.Theme.getSize("thick_margin").height * 1.5) left: parent.left - leftMargin: UM.Theme.getSize("thick_margin").width right: infillCellLeft.right rightMargin: UM.Theme.getSize("thick_margin").width verticalCenter: enableSupportCheckBox.verticalCenter @@ -956,7 +952,6 @@ Item anchors { left: parent.left - leftMargin: UM.Theme.getSize("thick_margin").width right: infillCellLeft.right rightMargin: UM.Theme.getSize("thick_margin").width verticalCenter: adhesionCheckBox.verticalCenter @@ -1037,7 +1032,6 @@ Item { id: tipsText anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("thick_margin").width anchors.right: parent.right anchors.rightMargin: UM.Theme.getSize("thick_margin").width anchors.top: parent.top From 85b34d60053b5c2c3d2f6cf279d2ecc243c2929b Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Wed, 28 Nov 2018 13:07:39 +0100 Subject: [PATCH 12/70] Refactor the PrintSetupSelector The file was splitted in several other files to improve readability. There is a new folder called PrintSetupSelector where all those files will be. Contributes to CURA-5941. --- plugins/PrepareStage/PrepareMenu.qml | 1 - resources/qml/PrintSetupSelector.qml | 392 ------------------ .../CustomPrintSetup.qml} | 4 +- .../PrintSetupSelector/PrintSetupSelector.qml | 68 +++ .../PrintSetupSelectorContents.qml | 276 ++++++++++++ .../PrintSetupSelectorHeader.qml | 69 +++ .../RecommendedPrintSetup.qml} | 8 +- 7 files changed, 419 insertions(+), 399 deletions(-) delete mode 100644 resources/qml/PrintSetupSelector.qml rename resources/qml/{SidebarAdvanced.qml => PrintSetupSelector/CustomPrintSetup.qml} (68%) create mode 100644 resources/qml/PrintSetupSelector/PrintSetupSelector.qml create mode 100644 resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml create mode 100644 resources/qml/PrintSetupSelector/PrintSetupSelectorHeader.qml rename resources/qml/{SidebarSimple.qml => PrintSetupSelector/RecommendedPrintSetup.qml} (99%) diff --git a/plugins/PrepareStage/PrepareMenu.qml b/plugins/PrepareStage/PrepareMenu.qml index 10b4262f01..7c01b1f8b0 100644 --- a/plugins/PrepareStage/PrepareMenu.qml +++ b/plugins/PrepareStage/PrepareMenu.qml @@ -45,7 +45,6 @@ Item Cura.MachineSelector { id: machineSelection - z: openFileButton.z - 1 //Ensure that the tooltip of the open file button stays above the item row. headerCornerSide: Cura.RoundedRectangle.Direction.Left Layout.minimumWidth: UM.Theme.getSize("machine_selector_widget").width Layout.maximumWidth: UM.Theme.getSize("machine_selector_widget").width diff --git a/resources/qml/PrintSetupSelector.qml b/resources/qml/PrintSetupSelector.qml deleted file mode 100644 index 253a13c0f0..0000000000 --- a/resources/qml/PrintSetupSelector.qml +++ /dev/null @@ -1,392 +0,0 @@ -// Copyright (c) 2018 Ultimaker B.V. -// Cura is released under the terms of the LGPLv3 or higher. - -import QtQuick 2.7 -import QtQuick.Controls 2.0 -import QtQuick.Layouts 1.3 - -import UM 1.3 as UM -import Cura 1.0 as Cura -import "Menus" -import "Menus/ConfigurationMenu" - -Cura.ExpandableComponent -{ - id: base - - property int currentModeIndex: -1 - property bool hideSettings: PrintInformation.preSliced - - property string enabledText: catalog.i18nc("@label:Should be short", "On") - property string disabledText: catalog.i18nc("@label:Should be short", "Off") - - // This widget doesn't show tooltips by itself. Instead it emits signals so others can do something with it. - signal showTooltip(Item item, point location, string text) - signal hideTooltip() - - implicitWidth: 200 * screenScaleFactor - height: childrenRect.height - iconSource: UM.Theme.getIcon("pencil") - - popupPadding : 0 - popupSpacingY: UM.Theme.getSize("narrow_margin").width - - popupClosePolicy: Popup.CloseOnEscape - - onCurrentModeIndexChanged: UM.Preferences.setValue("cura/active_mode", currentModeIndex) - - Component.onCompleted: - { - popupItemWrapper.width = base.width - } - - UM.I18nCatalog - { - id: catalog - name: "cura" - } - - Timer - { - id: tooltipDelayTimer - interval: 500 - repeat: false - property var item - property string text - - onTriggered: base.showTooltip(base, {x: 0, y: item.y}, text) - } - - headerItem: RowLayout - { - anchors.fill: parent - - IconWithText - { - source: UM.Theme.getIcon("category_layer_height") - text: Cura.MachineManager.activeStack ? Cura.MachineManager.activeQualityOrQualityChangesName + " " + layerHeight.properties.value + "mm" : "" - - UM.SettingPropertyProvider - { - id: layerHeight - containerStack: Cura.MachineManager.activeStack - key: "layer_height" - watchedProperties: ["value"] - } - } - - IconWithText - { - source: UM.Theme.getIcon("category_infill") - text: Cura.MachineManager.activeStack ? parseInt(infillDensity.properties.value) + "%" : "0%" - - UM.SettingPropertyProvider - { - id: infillDensity - containerStack: Cura.MachineManager.activeStack - key: "infill_sparse_density" - watchedProperties: ["value"] - } - } - - IconWithText - { - source: UM.Theme.getIcon("category_support") - text: supportEnabled.properties.value == "True" ? enabledText : disabledText - - - UM.SettingPropertyProvider - { - id: supportEnabled - containerStack: Cura.MachineManager.activeMachine - key: "support_enable" - watchedProperties: ["value"] - } - } - - IconWithText - { - source: UM.Theme.getIcon("category_adhesion") - text: platformAdhesionType.properties.value != "skirt" && platformAdhesionType.properties.value != "none" ? enabledText : disabledText - - UM.SettingPropertyProvider - { - id: platformAdhesionType - containerStack: Cura.MachineManager.activeMachine - key: "adhesion_type" - watchedProperties: [ "value"] - } - } - } - - Cura.ExtrudersModel - { - id: extrudersModel - } - - popupItem: Rectangle - { - property var total_height: popupItemHeader.height + popupItemContent.height + footerControll.height + UM.Theme.getSize("narrow_margin").height * 2 - id: popupItemWrapper - height: total_height - - border.width: UM.Theme.getSize("default_lining").width - border.color: UM.Theme.getColor("lining") - - Item - { - id: popupItemHeader - height: 36 - - anchors - { - top: parent.top - right: parent.right - left: parent.left - } - - Label - { - id: popupItemHeaderText - text: catalog.i18nc("@label", "Print settings"); - font: UM.Theme.getFont("default") - renderType: Text.NativeRendering - verticalAlignment: Text.AlignVCenter - color: UM.Theme.getColor("text") - height: parent.height - - anchors - { - topMargin: UM.Theme.getSize("sidebar_margin").height - left: parent.left - leftMargin: UM.Theme.getSize("narrow_margin").height - } - } - - Rectangle - { - width: parent.width - height: UM.Theme.getSize("default_lining").height - anchors.top: popupItemHeaderText.bottom - color: UM.Theme.getColor("action_button_border") - - - } - - Button - { - id: closeButton; - width: UM.Theme.getSize("message_close").width; - height: UM.Theme.getSize("message_close").height; - - anchors - { - right: parent.right; - rightMargin: UM.Theme.getSize("default_margin").width; - top: parent.top; - topMargin: 10 - } - - UM.RecolorImage - { - anchors.fill: parent; - sourceSize.width: width - sourceSize.height: width - color: UM.Theme.getColor("message_text") - source: UM.Theme.getIcon("cross1") - } - - onClicked: base.togglePopup() // Will hide the popup item - - background: Rectangle - { - color: UM.Theme.getColor("message_background") - } - } - } - - Rectangle - { - id: popupItemContent - width: parent.width - height: tabBar.height + sidebarContents.height - anchors - { - top: popupItemHeader.bottom - topMargin: UM.Theme.getSize("narrow_margin").height - right: parent.right - left: parent.left - leftMargin: UM.Theme.getSize("default_margin").width - rightMargin: UM.Theme.getSize("default_margin").width - } - - UM.TabRow - { - id: tabBar - anchors.topMargin: UM.Theme.getSize("default_margin").height - onCurrentIndexChanged: Cura.ExtruderManager.setActiveExtruderIndex(currentIndex) - z: 1 - Repeater - { - model: extrudersModel - delegate: UM.TabRowButton - { - contentItem: Rectangle - { - z: 2 - Cura.ExtruderIcon - { - anchors.horizontalCenter: parent.horizontalCenter - materialColor: model.color - extruderEnabled: model.enabled - width: parent.height - height: parent.height - } - } - - background: Rectangle - { - - width: parent.width - z: 1 - border.width: UM.Theme.getSize("default_lining").width * 2 - border.color: UM.Theme.getColor("action_button_border") - - visible: - { - return index == tabBar.currentIndex - } - - // overlap bottom border - Rectangle - { - width: parent.width - UM.Theme.getSize("default_lining").width * 4 - height: UM.Theme.getSize("default_lining").width * 4 - anchors.bottom: parent.bottom - anchors.bottomMargin: - (UM.Theme.getSize("default_lining").width * 2) - anchors.leftMargin: UM.Theme.getSize("default_lining").width * 2 - anchors.left: parent.left - - } - } - } - } - } - - Rectangle - { - id: sidebarContents - anchors.top: tabBar.bottom - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.right: parent.right - height: UM.Theme.getSize("print_setup_widget").height - - border.width: UM.Theme.getSize("default_lining").width * 2 - border.color: UM.Theme.getColor("action_button_border") - - SidebarSimple - { - anchors.topMargin: UM.Theme.getSize("print_setup_content_top_margin").height - anchors.fill: parent - visible: currentModeIndex != 1 - onShowTooltip: base.showTooltip(item, location, text) - onHideTooltip: base.hideTooltip() - } - - SidebarAdvanced - { - anchors.topMargin: UM.Theme.getSize("print_setup_content_top_margin").height - anchors.bottomMargin: 2 //don't overlap bottom border - anchors.fill: parent - visible: currentModeIndex == 1 - onShowTooltip: base.showTooltip(item, location, text) - onHideTooltip: base.hideTooltip() - } - } - } - - Item - { - id: footerControll - anchors.top: popupItemContent.bottom - anchors.topMargin: UM.Theme.getSize("narrow_margin").height * 2 - width: parent.width - height: settingControlButton.height + UM.Theme.getSize("default_lining").height * 4 - Rectangle - { - width: parent.width - height: UM.Theme.getSize("default_lining").height - color: UM.Theme.getColor("action_button_border") - } - - Cura.ActionButton - { - id: settingControlButton - leftPadding: UM.Theme.getSize("default_margin").width - rightPadding: UM.Theme.getSize("default_margin").width - height: UM.Theme.getSize("action_panel_button").height - text: catalog.i18nc("@button", "Custom") - color: UM.Theme.getColor("secondary") - hoverColor: UM.Theme.getColor("secondary") - textColor: UM.Theme.getColor("primary") - textHoverColor: UM.Theme.getColor("text") - iconSourceRight: UM.Theme.getIcon("arrow_right") - width: UM.Theme.getSize("print_setup_action_button").width - fixedWidthMode: true - visible: currentModeIndex == 0 - anchors - { - top: parent.top - topMargin: UM.Theme.getSize("narrow_margin").height * 2 - bottomMargin: UM.Theme.getSize("narrow_margin").height * 2 - right: parent.right - rightMargin: UM.Theme.getSize("narrow_margin").height - } - - onClicked: currentModeIndex = 1 - } - - Cura.ActionButton - { - height: UM.Theme.getSize("action_panel_button").height - text: catalog.i18nc("@button", "Recommended") - color: UM.Theme.getColor("secondary") - hoverColor: UM.Theme.getColor("secondary") - textColor: UM.Theme.getColor("primary") - textHoverColor: UM.Theme.getColor("text") - iconSource: UM.Theme.getIcon("arrow_left") - width: UM.Theme.getSize("print_setup_action_button").width - fixedWidthMode: true - visible: currentModeIndex == 1 - anchors - { - top: parent.top - topMargin: UM.Theme.getSize("narrow_margin").height * 2 - bottomMargin: UM.Theme.getSize("narrow_margin").height * 2 - left: parent.left - leftMargin: UM.Theme.getSize("narrow_margin").height - } - - MouseArea { - anchors.fill: parent - onClicked: currentModeIndex = 0 - } - } - } - - Component.onCompleted: - { - var index = Math.round(UM.Preferences.getValue("cura/active_mode")) - - if(index != null && !isNaN(index)) - { - currentModeIndex = index - } - else - { - currentModeIndex = 0 - } - } - } -} \ No newline at end of file diff --git a/resources/qml/SidebarAdvanced.qml b/resources/qml/PrintSetupSelector/CustomPrintSetup.qml similarity index 68% rename from resources/qml/SidebarAdvanced.qml rename to resources/qml/PrintSetupSelector/CustomPrintSetup.qml index ff5f545c80..f58695b48f 100644 --- a/resources/qml/SidebarAdvanced.qml +++ b/resources/qml/PrintSetupSelector/CustomPrintSetup.qml @@ -1,10 +1,10 @@ -// Copyright (c) 2015 Ultimaker B.V. +// Copyright (c) 2018 Ultimaker B.V. // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.7 import QtQuick.Controls 2.0 -import "Settings" +import "../Settings" SettingView { } diff --git a/resources/qml/PrintSetupSelector/PrintSetupSelector.qml b/resources/qml/PrintSetupSelector/PrintSetupSelector.qml new file mode 100644 index 0000000000..c69dd56520 --- /dev/null +++ b/resources/qml/PrintSetupSelector/PrintSetupSelector.qml @@ -0,0 +1,68 @@ +// Copyright (c) 2018 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.7 +import QtQuick.Controls 2.0 + +import UM 1.3 as UM +import Cura 1.0 as Cura + +Cura.ExpandableComponent +{ + id: base + + property int currentModeIndex: -1 + property bool hideSettings: PrintInformation.preSliced + + property string enabledText: catalog.i18nc("@label:Should be short", "On") + property string disabledText: catalog.i18nc("@label:Should be short", "Off") + + // This widget doesn't show tooltips by itself. Instead it emits signals so others can do something with it. + signal showTooltip(Item item, point location, string text) + signal hideTooltip() + + iconSource: UM.Theme.getIcon("pencil") + popupPadding: UM.Theme.getSize("default_lining").width + popupSpacingY: UM.Theme.getSize("narrow_margin").width + + popupClosePolicy: Popup.CloseOnEscape + + onCurrentModeIndexChanged: UM.Preferences.setValue("cura/active_mode", currentModeIndex) + + Component.onCompleted: + { + popupItemWrapper.width = base.width + } + + UM.I18nCatalog + { + id: catalog + name: "cura" + } + + Timer + { + id: tooltipDelayTimer + interval: 500 + repeat: false + property var item + property string text + + onTriggered: base.showTooltip(base, {x: 0, y: item.y}, text) + } + + headerItem: PrintSetupSelectorHeader + { + anchors.fill: parent + } + + Cura.ExtrudersModel + { + id: extrudersModel + } + + popupItem: PrintSetupSelectorContents + { + + } +} \ No newline at end of file diff --git a/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml b/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml new file mode 100644 index 0000000000..e7b3b94b11 --- /dev/null +++ b/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml @@ -0,0 +1,276 @@ +// Copyright (c) 2018 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.7 +import QtQuick.Controls 2.3 +import QtQuick.Layouts 1.3 + +import UM 1.3 as UM +import Cura 1.0 as Cura + +Rectangle +{ + property var total_height: popupItemHeader.height + popupItemContent.height + footerControll.height + UM.Theme.getSize("narrow_margin").height * 2 + id: popupItemWrapper + height: total_height + + border.width: UM.Theme.getSize("default_lining").width + border.color: UM.Theme.getColor("lining") + + Item + { + id: popupItemHeader + height: 36 + + anchors + { + top: parent.top + right: parent.right + left: parent.left + } + + Label + { + id: popupItemHeaderText + text: catalog.i18nc("@label", "Print settings"); + font: UM.Theme.getFont("default") + renderType: Text.NativeRendering + verticalAlignment: Text.AlignVCenter + color: UM.Theme.getColor("text") + height: parent.height + + anchors + { + topMargin: UM.Theme.getSize("sidebar_margin").height + left: parent.left + leftMargin: UM.Theme.getSize("narrow_margin").height + } + } + + Rectangle + { + width: parent.width + height: UM.Theme.getSize("default_lining").height + anchors.top: popupItemHeaderText.bottom + color: UM.Theme.getColor("action_button_border") + + + } + + Button + { + id: closeButton; + width: UM.Theme.getSize("message_close").width; + height: UM.Theme.getSize("message_close").height; + + anchors + { + right: parent.right; + rightMargin: UM.Theme.getSize("default_margin").width; + top: parent.top; + topMargin: 10 + } + + UM.RecolorImage + { + anchors.fill: parent; + sourceSize.width: width + sourceSize.height: width + color: UM.Theme.getColor("message_text") + source: UM.Theme.getIcon("cross1") + } + + onClicked: base.togglePopup() // Will hide the popup item + + background: Rectangle + { + color: UM.Theme.getColor("message_background") + } + } + } + + Rectangle + { + id: popupItemContent + width: parent.width + height: tabBar.height + sidebarContents.height + + anchors + { + top: popupItemHeader.bottom + topMargin: UM.Theme.getSize("narrow_margin").height + right: parent.right + left: parent.left + leftMargin: UM.Theme.getSize("default_margin").width + rightMargin: UM.Theme.getSize("default_margin").width + } + + UM.TabRow + { + id: tabBar + anchors.topMargin: UM.Theme.getSize("default_margin").height + onCurrentIndexChanged: Cura.ExtruderManager.setActiveExtruderIndex(currentIndex) + z: 1 + Repeater + { + model: extrudersModel + delegate: UM.TabRowButton + { + contentItem: Rectangle + { + z: 2 + Cura.ExtruderIcon + { + anchors.horizontalCenter: parent.horizontalCenter + materialColor: model.color + extruderEnabled: model.enabled + width: parent.height + height: parent.height + } + } + + background: Rectangle + { + + width: parent.width + z: 1 + border.width: UM.Theme.getSize("default_lining").width * 2 + border.color: UM.Theme.getColor("action_button_border") + + visible: + { + return index == tabBar.currentIndex + } + + // overlap bottom border + Rectangle + { + width: parent.width - UM.Theme.getSize("default_lining").width * 4 + height: UM.Theme.getSize("default_lining").width * 4 + anchors.bottom: parent.bottom + anchors.bottomMargin: - (UM.Theme.getSize("default_lining").width * 2) + anchors.leftMargin: UM.Theme.getSize("default_lining").width * 2 + anchors.left: parent.left + + } + } + } + } + } + + Rectangle + { + id: sidebarContents + anchors.top: tabBar.bottom + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.right: parent.right + height: UM.Theme.getSize("print_setup_widget").height + + border.width: UM.Theme.getSize("default_lining").width * 2 + border.color: UM.Theme.getColor("action_button_border") + + RecommendedPrintSetup + { + anchors.topMargin: UM.Theme.getSize("print_setup_content_top_margin").height + anchors.fill: parent + visible: currentModeIndex != 1 + onShowTooltip: base.showTooltip(item, location, text) + onHideTooltip: base.hideTooltip() + } + + CustomPrintSetup + { + anchors.topMargin: UM.Theme.getSize("print_setup_content_top_margin").height + anchors.bottomMargin: 2 //don't overlap bottom border + anchors.fill: parent + visible: currentModeIndex == 1 + onShowTooltip: base.showTooltip(item, location, text) + onHideTooltip: base.hideTooltip() + } + } + } + + Item + { + id: footerControll + anchors.top: popupItemContent.bottom + anchors.topMargin: UM.Theme.getSize("narrow_margin").height * 2 + width: parent.width + height: settingControlButton.height + UM.Theme.getSize("default_lining").height * 4 + Rectangle + { + width: parent.width + height: UM.Theme.getSize("default_lining").height + color: UM.Theme.getColor("action_button_border") + } + + Cura.ActionButton + { + id: settingControlButton + leftPadding: UM.Theme.getSize("default_margin").width + rightPadding: UM.Theme.getSize("default_margin").width + height: UM.Theme.getSize("action_panel_button").height + text: catalog.i18nc("@button", "Custom") + color: UM.Theme.getColor("secondary") + hoverColor: UM.Theme.getColor("secondary") + textColor: UM.Theme.getColor("primary") + textHoverColor: UM.Theme.getColor("text") + iconSourceRight: UM.Theme.getIcon("arrow_right") + width: UM.Theme.getSize("print_setup_action_button").width + fixedWidthMode: true + visible: currentModeIndex == 0 + anchors + { + top: parent.top + topMargin: UM.Theme.getSize("narrow_margin").height * 2 + bottomMargin: UM.Theme.getSize("narrow_margin").height * 2 + right: parent.right + rightMargin: UM.Theme.getSize("narrow_margin").height + } + + onClicked: currentModeIndex = 1 + } + + Cura.ActionButton + { + height: UM.Theme.getSize("action_panel_button").height + text: catalog.i18nc("@button", "Recommended") + color: UM.Theme.getColor("secondary") + hoverColor: UM.Theme.getColor("secondary") + textColor: UM.Theme.getColor("primary") + textHoverColor: UM.Theme.getColor("text") + iconSource: UM.Theme.getIcon("arrow_left") + width: UM.Theme.getSize("print_setup_action_button").width + fixedWidthMode: true + visible: currentModeIndex == 1 + anchors + { + top: parent.top + topMargin: UM.Theme.getSize("narrow_margin").height * 2 + bottomMargin: UM.Theme.getSize("narrow_margin").height * 2 + left: parent.left + leftMargin: UM.Theme.getSize("narrow_margin").height + } + + MouseArea { + anchors.fill: parent + onClicked: currentModeIndex = 0 + } + } + } + + Component.onCompleted: + { + var index = Math.round(UM.Preferences.getValue("cura/active_mode")) + + if(index != null && !isNaN(index)) + { + currentModeIndex = index + } + else + { + currentModeIndex = 0 + } + } +} \ No newline at end of file diff --git a/resources/qml/PrintSetupSelector/PrintSetupSelectorHeader.qml b/resources/qml/PrintSetupSelector/PrintSetupSelectorHeader.qml new file mode 100644 index 0000000000..f8fb246085 --- /dev/null +++ b/resources/qml/PrintSetupSelector/PrintSetupSelectorHeader.qml @@ -0,0 +1,69 @@ +// Copyright (c) 2018 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.7 +import QtQuick.Controls 2.3 +import QtQuick.Layouts 1.3 + +import UM 1.3 as UM +import Cura 1.0 as Cura + +RowLayout +{ + Cura.IconLabel + { + source: UM.Theme.getIcon("category_layer_height") + text: Cura.MachineManager.activeStack ? Cura.MachineManager.activeQualityOrQualityChangesName + " " + layerHeight.properties.value + "mm" : "" + + UM.SettingPropertyProvider + { + id: layerHeight + containerStack: Cura.MachineManager.activeStack + key: "layer_height" + watchedProperties: ["value"] + } + } + + Cura.IconLabel + { + source: UM.Theme.getIcon("category_infill") + text: Cura.MachineManager.activeStack ? parseInt(infillDensity.properties.value) + "%" : "0%" + + UM.SettingPropertyProvider + { + id: infillDensity + containerStack: Cura.MachineManager.activeStack + key: "infill_sparse_density" + watchedProperties: ["value"] + } + } + + Cura.IconLabel + { + source: UM.Theme.getIcon("category_support") + text: supportEnabled.properties.value == "True" ? enabledText : disabledText + + + UM.SettingPropertyProvider + { + id: supportEnabled + containerStack: Cura.MachineManager.activeMachine + key: "support_enable" + watchedProperties: ["value"] + } + } + + Cura.IconLabel + { + source: UM.Theme.getIcon("category_adhesion") + text: platformAdhesionType.properties.value != "skirt" && platformAdhesionType.properties.value != "none" ? enabledText : disabledText + + UM.SettingPropertyProvider + { + id: platformAdhesionType + containerStack: Cura.MachineManager.activeMachine + key: "adhesion_type" + watchedProperties: [ "value"] + } + } +} \ No newline at end of file diff --git a/resources/qml/SidebarSimple.qml b/resources/qml/PrintSetupSelector/RecommendedPrintSetup.qml similarity index 99% rename from resources/qml/SidebarSimple.qml rename to resources/qml/PrintSetupSelector/RecommendedPrintSetup.qml index f2e998f526..a11eae3218 100644 --- a/resources/qml/SidebarSimple.qml +++ b/resources/qml/PrintSetupSelector/RecommendedPrintSetup.qml @@ -188,7 +188,7 @@ Item } } - IconWithText + Cura.IconLabel { id: qualityRowTitle source: UM.Theme.getIcon("category_layer_height") @@ -496,7 +496,7 @@ Item width: Math.round(UM.Theme.getSize("print_setup_widget").width * .45) - UM.Theme.getSize("thick_margin").width - IconWithText + Cura.IconLabel { id: infillLabel source: UM.Theme.getIcon("category_infill") @@ -818,7 +818,7 @@ Item // // Enable support // - IconWithText + Cura.IconLabel { id: enableSupportLabel visible: enableSupportCheckBox.visible @@ -942,7 +942,7 @@ Item } - IconWithText + Cura.IconLabel { id: adhesionHelperLabel visible: adhesionCheckBox.visible From 0fdaebaaf83b3d34d94995dd628e246f63c8322c Mon Sep 17 00:00:00 2001 From: Aleksei S Date: Wed, 28 Nov 2018 13:51:54 +0100 Subject: [PATCH 13/70] Updated action button CURA-5941 --- resources/qml/ActionButton.qml | 50 +++++++++++----------------- resources/qml/PrintSetupSelector.qml | 24 +++++++------ 2 files changed, 33 insertions(+), 41 deletions(-) diff --git a/resources/qml/ActionButton.qml b/resources/qml/ActionButton.qml index 732858c67f..e754365033 100644 --- a/resources/qml/ActionButton.qml +++ b/resources/qml/ActionButton.qml @@ -1,22 +1,17 @@ // Copyright (c) 2018 Ultimaker B.V. // Cura is released under the terms of the LGPLv3 or higher. - import QtQuick 2.7 import QtQuick.Controls 2.1 - import QtGraphicalEffects 1.0 // For the dropshadow - import UM 1.1 as UM - Button { id: button - property alias iconSource: buttonIcon.source - property alias iconSourceRight: buttonIconRight.source + property alias iconSource: buttonIconLeft.source + property var iconOnRightSide: false property alias textFont: buttonText.font property alias cornerRadius: backgroundRect.radius property alias tooltip: tooltip.text - property color color: UM.Theme.getColor("primary") property color hoverColor: UM.Theme.getColor("primary_hover") property color disabledColor: color @@ -26,33 +21,31 @@ Button property color outlineColor: color property color outlineHoverColor: hoverColor property color outlineDisabledColor: outlineColor - hoverEnabled: true - property alias shadowColor: shadow.color property alias shadowEnabled: shadow.visible - // This property is used to indicate whether the button has a fixed width or the width would depend on the contents // Be careful when using fixedWidthMode, the translated texts can be too long that they won't fit. In any case, // we elide the text to the right so the text will be cut off with the three dots at the end. property var fixedWidthMode: false - - width: buttonIcon.width + buttonText.width + buttonIconRight.width - contentItem: Item + leftPadding: UM.Theme.getSize("default_margin").width + rightPadding: UM.Theme.getSize("default_margin").width + height: UM.Theme.getSize("action_button").height + contentItem: Row { + //Icon if displayed on the left side. UM.RecolorImage { - id: buttonIcon + id: buttonIconLeft source: "" - height: Math.round(0.6 * parent.height) - width: height + height: buttonText.height + width: visible ? height : 0 sourceSize.width: width sourceSize.height: height color: button.hovered ? button.textHoverColor : button.textColor - visible: source != "" + visible: source != "" && !button.iconOnRightSide anchors.verticalCenter: parent.verticalCenter } - Label { id: buttonText @@ -66,22 +59,21 @@ Button horizontalAlignment: Text.AlignHCenter elide: Text.ElideRight } - + //Icon if displayed on the right side. UM.RecolorImage { id: buttonIconRight - source: "" - height: Math.round(0.6 * parent.height) - width: height + source: buttonIconLeft.source + anchors.right: parent.right + height: buttonText.height + width: visible ? height : 0 sourceSize.width: width sourceSize.height: height - color: button.hovered ? button.textHoverColor : button.textColor - visible: source != "" - anchors.verticalCenter: parent.verticalCenter - anchors.right: source != "" ? parent.right : undefined + color: buttonIconLeft.color + visible: source != "" && button.iconOnRightSide + anchors.verticalCenter: buttonIconLeft.verticalCenter } } - background: Rectangle { id: backgroundRect @@ -90,7 +82,6 @@ Button border.width: UM.Theme.getSize("default_lining").width border.color: button.enabled ? (button.hovered ? button.outlineHoverColor : button.outlineColor) : button.outlineDisabledColor } - DropShadow { id: shadow @@ -103,7 +94,6 @@ Button // Should always be drawn behind the background. z: backgroundRect.z - 1 } - ToolTip { id: tooltip @@ -111,4 +101,4 @@ Button delay: 500 visible: text != "" && button.hovered } -} +} \ No newline at end of file diff --git a/resources/qml/PrintSetupSelector.qml b/resources/qml/PrintSetupSelector.qml index 253a13c0f0..85472bae8d 100644 --- a/resources/qml/PrintSetupSelector.qml +++ b/resources/qml/PrintSetupSelector.qml @@ -323,18 +323,9 @@ Cura.ExpandableComponent Cura.ActionButton { id: settingControlButton - leftPadding: UM.Theme.getSize("default_margin").width - rightPadding: UM.Theme.getSize("default_margin").width - height: UM.Theme.getSize("action_panel_button").height - text: catalog.i18nc("@button", "Custom") - color: UM.Theme.getColor("secondary") - hoverColor: UM.Theme.getColor("secondary") - textColor: UM.Theme.getColor("primary") - textHoverColor: UM.Theme.getColor("text") - iconSourceRight: UM.Theme.getIcon("arrow_right") - width: UM.Theme.getSize("print_setup_action_button").width - fixedWidthMode: true visible: currentModeIndex == 0 + text: catalog.i18nc("@button", "Custom") + width: UM.Theme.getSize("print_setup_action_button").width anchors { top: parent.top @@ -344,6 +335,13 @@ Cura.ExpandableComponent rightMargin: UM.Theme.getSize("narrow_margin").height } + color: UM.Theme.getColor("secondary") + hoverColor: UM.Theme.getColor("secondary") + textColor: UM.Theme.getColor("primary") + textHoverColor: UM.Theme.getColor("text") + iconSource: UM.Theme.getIcon("arrow_right") + iconOnRightSide: true + onClicked: currentModeIndex = 1 } @@ -351,13 +349,17 @@ Cura.ExpandableComponent { height: UM.Theme.getSize("action_panel_button").height text: catalog.i18nc("@button", "Recommended") + color: UM.Theme.getColor("secondary") hoverColor: UM.Theme.getColor("secondary") textColor: UM.Theme.getColor("primary") textHoverColor: UM.Theme.getColor("text") + iconSource: UM.Theme.getIcon("arrow_left") + width: UM.Theme.getSize("print_setup_action_button").width fixedWidthMode: true + visible: currentModeIndex == 1 anchors { From 990c653af4eaf11e22dc49a9f9ea1c96d61a43d4 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Wed, 28 Nov 2018 17:29:25 +0100 Subject: [PATCH 14/70] Refactor the code a bit more to better align the components in the recommended mode. Contributes to CURA-5941. --- resources/qml/ActionButton.qml | 18 +- resources/qml/ExpandableComponent.qml | 2 +- resources/qml/IconLabel.qml | 5 +- .../PrintSetupSelector/PrintSetupSelector.qml | 13 +- .../PrintSetupSelectorContents.qml | 294 +-- .../PrintSetupSelectorHeader.qml | 8 +- .../RecommendedPrintSetup.qml | 2034 ++++++++--------- resources/qml/qmldir | 1 + resources/themes/cura-light/theme.json | 1 + 9 files changed, 1134 insertions(+), 1242 deletions(-) diff --git a/resources/qml/ActionButton.qml b/resources/qml/ActionButton.qml index 732858c67f..b9a04f3b46 100644 --- a/resources/qml/ActionButton.qml +++ b/resources/qml/ActionButton.qml @@ -12,7 +12,6 @@ Button { id: button property alias iconSource: buttonIcon.source - property alias iconSourceRight: buttonIconRight.source property alias textFont: buttonText.font property alias cornerRadius: backgroundRect.radius property alias tooltip: tooltip.text @@ -37,8 +36,7 @@ Button // we elide the text to the right so the text will be cut off with the three dots at the end. property var fixedWidthMode: false - width: buttonIcon.width + buttonText.width + buttonIconRight.width - contentItem: Item + contentItem: Row { UM.RecolorImage { @@ -66,20 +64,6 @@ Button horizontalAlignment: Text.AlignHCenter elide: Text.ElideRight } - - UM.RecolorImage - { - id: buttonIconRight - source: "" - height: Math.round(0.6 * parent.height) - width: height - sourceSize.width: width - sourceSize.height: height - color: button.hovered ? button.textHoverColor : button.textColor - visible: source != "" - anchors.verticalCenter: parent.verticalCenter - anchors.right: source != "" ? parent.right : undefined - } } background: Rectangle diff --git a/resources/qml/ExpandableComponent.qml b/resources/qml/ExpandableComponent.qml index 897d44d941..0c3a8f80b9 100644 --- a/resources/qml/ExpandableComponent.qml +++ b/resources/qml/ExpandableComponent.qml @@ -74,7 +74,7 @@ Item function togglePopup() { - if(popup.visible) + if (popup.visible) { popup.close() } diff --git a/resources/qml/IconLabel.qml b/resources/qml/IconLabel.qml index 0941254e7b..ee4a1254ec 100644 --- a/resources/qml/IconLabel.qml +++ b/resources/qml/IconLabel.qml @@ -2,8 +2,7 @@ // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.7 -import QtQuick.Controls 2.1 -import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.3 import UM 1.1 as UM @@ -48,7 +47,7 @@ Item text: "Empty label" elide: Text.ElideRight color: UM.Theme.getColor("text") - font: UM.Theme.getFont("very_small") + font: UM.Theme.getFont("default") renderType: Text.NativeRendering } } \ No newline at end of file diff --git a/resources/qml/PrintSetupSelector/PrintSetupSelector.qml b/resources/qml/PrintSetupSelector/PrintSetupSelector.qml index c69dd56520..1794a54cdf 100644 --- a/resources/qml/PrintSetupSelector/PrintSetupSelector.qml +++ b/resources/qml/PrintSetupSelector/PrintSetupSelector.qml @@ -11,7 +11,6 @@ Cura.ExpandableComponent { id: base - property int currentModeIndex: -1 property bool hideSettings: PrintInformation.preSliced property string enabledText: catalog.i18nc("@label:Should be short", "On") @@ -27,13 +26,6 @@ Cura.ExpandableComponent popupClosePolicy: Popup.CloseOnEscape - onCurrentModeIndexChanged: UM.Preferences.setValue("cura/active_mode", currentModeIndex) - - Component.onCompleted: - { - popupItemWrapper.width = base.width - } - UM.I18nCatalog { id: catalog @@ -61,8 +53,5 @@ Cura.ExpandableComponent id: extrudersModel } - popupItem: PrintSetupSelectorContents - { - - } + popupItem: PrintSetupSelectorContents {} } \ No newline at end of file diff --git a/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml b/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml index e7b3b94b11..c36a0fbb80 100644 --- a/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml +++ b/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml @@ -3,24 +3,26 @@ import QtQuick 2.7 import QtQuick.Controls 2.3 -import QtQuick.Layouts 1.3 import UM 1.3 as UM import Cura 1.0 as Cura -Rectangle +Item { - property var total_height: popupItemHeader.height + popupItemContent.height + footerControll.height + UM.Theme.getSize("narrow_margin").height * 2 - id: popupItemWrapper - height: total_height + id: popup - border.width: UM.Theme.getSize("default_lining").width - border.color: UM.Theme.getColor("lining") + width: UM.Theme.getSize("print_setup_widget").width + height: childrenRect.height - Item + property int currentModeIndex: -1 + onCurrentModeIndexChanged: UM.Preferences.setValue("cura/active_mode", currentModeIndex) + + // Header of the popup + Rectangle { - id: popupItemHeader - height: 36 + id: header + height: UM.Theme.getSize("print_setup_widget_header").height + color: UM.Theme.getColor("action_button_hovered") // TODO: It's not clear the color that we need to use here anchors { @@ -31,8 +33,8 @@ Rectangle Label { - id: popupItemHeaderText - text: catalog.i18nc("@label", "Print settings"); + id: headerLabel + text: catalog.i18nc("@label", "Print settings") font: UM.Theme.getFont("default") renderType: Text.NativeRendering verticalAlignment: Text.AlignVCenter @@ -47,221 +49,153 @@ Rectangle } } - Rectangle - { - width: parent.width - height: UM.Theme.getSize("default_lining").height - anchors.top: popupItemHeaderText.bottom - color: UM.Theme.getColor("action_button_border") - - - } - Button { - id: closeButton; - width: UM.Theme.getSize("message_close").width; - height: UM.Theme.getSize("message_close").height; + id: closeButton + width: UM.Theme.getSize("message_close").width + height: UM.Theme.getSize("message_close").height anchors { - right: parent.right; - rightMargin: UM.Theme.getSize("default_margin").width; - top: parent.top; - topMargin: 10 + right: parent.right + rightMargin: UM.Theme.getSize("default_margin").width + verticalCenter: parent.verticalCenter } - UM.RecolorImage + contentItem: UM.RecolorImage { - anchors.fill: parent; + anchors.fill: parent sourceSize.width: width sourceSize.height: width color: UM.Theme.getColor("message_text") source: UM.Theme.getIcon("cross1") } - onClicked: base.togglePopup() // Will hide the popup item + background: Item {} - background: Rectangle - { - color: UM.Theme.getColor("message_background") - } + onClicked: togglePopup() // Will hide the popup item } } Rectangle { - id: popupItemContent - width: parent.width - height: tabBar.height + sidebarContents.height + id: topSeparator + anchors.bottom: header.bottom + width: parent.width + height: UM.Theme.getSize("default_lining").height + color: UM.Theme.getColor("lining") + } + + Loader + { + id: loader + width: parent.width anchors { - top: popupItemHeader.bottom - topMargin: UM.Theme.getSize("narrow_margin").height - right: parent.right - left: parent.left + top: header.bottom leftMargin: UM.Theme.getSize("default_margin").width rightMargin: UM.Theme.getSize("default_margin").width } + sourceComponent: currentModeIndex == 0 ? recommendedPrintSetup : customPrintSetup + } - UM.TabRow - { - id: tabBar - anchors.topMargin: UM.Theme.getSize("default_margin").height - onCurrentIndexChanged: Cura.ExtruderManager.setActiveExtruderIndex(currentIndex) - z: 1 - Repeater - { - model: extrudersModel - delegate: UM.TabRowButton - { - contentItem: Rectangle - { - z: 2 - Cura.ExtruderIcon - { - anchors.horizontalCenter: parent.horizontalCenter - materialColor: model.color - extruderEnabled: model.enabled - width: parent.height - height: parent.height - } - } +// Item +// { +// id: content +// width: parent.width +// height: 100 +////// height: tabBar.height + sidebarContents.height +//// +// anchors +// { +// top: header.bottom +// leftMargin: UM.Theme.getSize("default_margin").width +// rightMargin: UM.Theme.getSize("default_margin").width +// } +//// +//// Rectangle +//// { +//// id: sidebarContents +//// anchors.top: tabBar.bottom +//// anchors.bottom: parent.bottom +//// anchors.left: parent.left +//// anchors.right: parent.right +//// height: UM.Theme.getSize("print_setup_widget").height +//// +//// border.width: UM.Theme.getSize("default_lining").width * 2 +//// border.color: UM.Theme.getColor("action_button_border") +//// } +// } - background: Rectangle - { + Rectangle + { + id: buttonsSeparator - width: parent.width - z: 1 - border.width: UM.Theme.getSize("default_lining").width * 2 - border.color: UM.Theme.getColor("action_button_border") - - visible: - { - return index == tabBar.currentIndex - } - - // overlap bottom border - Rectangle - { - width: parent.width - UM.Theme.getSize("default_lining").width * 4 - height: UM.Theme.getSize("default_lining").width * 4 - anchors.bottom: parent.bottom - anchors.bottomMargin: - (UM.Theme.getSize("default_lining").width * 2) - anchors.leftMargin: UM.Theme.getSize("default_lining").width * 2 - anchors.left: parent.left - - } - } - } - } - } - - Rectangle - { - id: sidebarContents - anchors.top: tabBar.bottom - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.right: parent.right - height: UM.Theme.getSize("print_setup_widget").height - - border.width: UM.Theme.getSize("default_lining").width * 2 - border.color: UM.Theme.getColor("action_button_border") - - RecommendedPrintSetup - { - anchors.topMargin: UM.Theme.getSize("print_setup_content_top_margin").height - anchors.fill: parent - visible: currentModeIndex != 1 - onShowTooltip: base.showTooltip(item, location, text) - onHideTooltip: base.hideTooltip() - } - - CustomPrintSetup - { - anchors.topMargin: UM.Theme.getSize("print_setup_content_top_margin").height - anchors.bottomMargin: 2 //don't overlap bottom border - anchors.fill: parent - visible: currentModeIndex == 1 - onShowTooltip: base.showTooltip(item, location, text) - onHideTooltip: base.hideTooltip() - } - } + anchors.top: loader.bottom + width: parent.width + height: UM.Theme.getSize("default_lining").height + color: UM.Theme.getColor("lining") } Item { - id: footerControll - anchors.top: popupItemContent.bottom - anchors.topMargin: UM.Theme.getSize("narrow_margin").height * 2 - width: parent.width - height: settingControlButton.height + UM.Theme.getSize("default_lining").height * 4 - Rectangle + id: buttonRow + height: childrenRect.height + + // The buttonsSeparator is inside the buttonRow. This is to avoid some weird behaviours with the scroll bar. + anchors { - width: parent.width - height: UM.Theme.getSize("default_lining").height - color: UM.Theme.getColor("action_button_border") + top: buttonsSeparator.top + left: parent.left + right: parent.right } - Cura.ActionButton + Cura.SecondaryButton { - id: settingControlButton + anchors.left: parent.left leftPadding: UM.Theme.getSize("default_margin").width rightPadding: UM.Theme.getSize("default_margin").width - height: UM.Theme.getSize("action_panel_button").height - text: catalog.i18nc("@button", "Custom") - color: UM.Theme.getColor("secondary") - hoverColor: UM.Theme.getColor("secondary") - textColor: UM.Theme.getColor("primary") - textHoverColor: UM.Theme.getColor("text") - iconSourceRight: UM.Theme.getIcon("arrow_right") - width: UM.Theme.getSize("print_setup_action_button").width - fixedWidthMode: true - visible: currentModeIndex == 0 - anchors - { - top: parent.top - topMargin: UM.Theme.getSize("narrow_margin").height * 2 - bottomMargin: UM.Theme.getSize("narrow_margin").height * 2 - right: parent.right - rightMargin: UM.Theme.getSize("narrow_margin").height - } - - onClicked: currentModeIndex = 1 + text: catalog.i18nc("@button", "Recommended") + visible: currentModeIndex == 1 + onClicked: currentModeIndex = 0 } - Cura.ActionButton + Cura.SecondaryButton { - height: UM.Theme.getSize("action_panel_button").height - text: catalog.i18nc("@button", "Recommended") - color: UM.Theme.getColor("secondary") - hoverColor: UM.Theme.getColor("secondary") - textColor: UM.Theme.getColor("primary") - textHoverColor: UM.Theme.getColor("text") - iconSource: UM.Theme.getIcon("arrow_left") - width: UM.Theme.getSize("print_setup_action_button").width - fixedWidthMode: true - visible: currentModeIndex == 1 - anchors - { - top: parent.top - topMargin: UM.Theme.getSize("narrow_margin").height * 2 - bottomMargin: UM.Theme.getSize("narrow_margin").height * 2 - left: parent.left - leftMargin: UM.Theme.getSize("narrow_margin").height - } - - MouseArea { - anchors.fill: parent - onClicked: currentModeIndex = 0 - } + anchors.right: parent.right + leftPadding: UM.Theme.getSize("default_margin").width + rightPadding: UM.Theme.getSize("default_margin").width + text: catalog.i18nc("@button", "Custom") + visible: currentModeIndex == 0 + onClicked: currentModeIndex = 1 } } + Component + { + id: recommendedPrintSetup + RecommendedPrintSetup + { + onShowTooltip: base.showTooltip(item, location, text) + onHideTooltip: base.hideTooltip() + } + } + + Component + { + id: customPrintSetup + CustomPrintSetup + { + onShowTooltip: base.showTooltip(item, location, text) + onHideTooltip: base.hideTooltip() + } + } + + Component.onCompleted: { + print(height, "!!!!!!!!!!!!!!!!!!!!!!!") var index = Math.round(UM.Preferences.getValue("cura/active_mode")) if(index != null && !isNaN(index)) diff --git a/resources/qml/PrintSetupSelector/PrintSetupSelectorHeader.qml b/resources/qml/PrintSetupSelector/PrintSetupSelectorHeader.qml index f8fb246085..d4057289f6 100644 --- a/resources/qml/PrintSetupSelector/PrintSetupSelectorHeader.qml +++ b/resources/qml/PrintSetupSelector/PrintSetupSelectorHeader.qml @@ -10,7 +10,7 @@ import Cura 1.0 as Cura RowLayout { - Cura.IconLabel + Cura.IconWithText { source: UM.Theme.getIcon("category_layer_height") text: Cura.MachineManager.activeStack ? Cura.MachineManager.activeQualityOrQualityChangesName + " " + layerHeight.properties.value + "mm" : "" @@ -24,7 +24,7 @@ RowLayout } } - Cura.IconLabel + Cura.IconWithText { source: UM.Theme.getIcon("category_infill") text: Cura.MachineManager.activeStack ? parseInt(infillDensity.properties.value) + "%" : "0%" @@ -38,7 +38,7 @@ RowLayout } } - Cura.IconLabel + Cura.IconWithText { source: UM.Theme.getIcon("category_support") text: supportEnabled.properties.value == "True" ? enabledText : disabledText @@ -53,7 +53,7 @@ RowLayout } } - Cura.IconLabel + Cura.IconWithText { source: UM.Theme.getIcon("category_adhesion") text: platformAdhesionType.properties.value != "skirt" && platformAdhesionType.properties.value != "none" ? enabledText : disabledText diff --git a/resources/qml/PrintSetupSelector/RecommendedPrintSetup.qml b/resources/qml/PrintSetupSelector/RecommendedPrintSetup.qml index a11eae3218..5d195bdde4 100644 --- a/resources/qml/PrintSetupSelector/RecommendedPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/RecommendedPrintSetup.qml @@ -4,7 +4,6 @@ import QtQuick 2.7 import QtQuick.Controls 1.4 import QtQuick.Controls.Styles 1.4 -import QtQuick.Layouts 1.3 import UM 1.2 as UM import Cura 1.0 as Cura @@ -15,6 +14,7 @@ Item signal showTooltip(Item item, point location, string text) signal hideTooltip() + height: childrenRect.height property Action configureSettings @@ -26,1088 +26,1072 @@ Item name: "cura" } - ScrollView + // + // Quality profile + // + Item { - visible: Cura.MachineManager.activeMachineName != "" // If no printers added then the view is invisible - anchors.fill: parent - style: UM.Theme.styles.scrollview - flickableItem.flickableDirection: Flickable.VerticalFlick + id: qualityRow - Item + height: UM.Theme.getSize("thick_margin").height + anchors.topMargin: UM.Theme.getSize("thick_margin").height + anchors.left: parent.left + anchors.right: parent.right + + Timer { - width: childrenRect.width - height: childrenRect.height - - anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("default_margin").width - // - // Quality profile - // - Item + id: qualitySliderChangeTimer + interval: 50 + running: false + repeat: false + onTriggered: { - id: qualityRow + var item = Cura.QualityProfilesDropDownMenuModel.getItem(qualitySlider.value); + Cura.MachineManager.activeQualityGroup = item.quality_group; + } + } - height: UM.Theme.getSize("thick_margin").height - anchors.topMargin: UM.Theme.getSize("thick_margin").height - anchors.left: parent.left - anchors.right: parent.right + Component.onCompleted: qualityModel.update() - Timer + Connections + { + target: Cura.QualityProfilesDropDownMenuModel + onItemsChanged: qualityModel.update() + } + + Connections { + target: base + onVisibleChanged: + { + // update needs to be called when the widgets are visible, otherwise the step width calculation + // will fail because the width of an invisible item is 0. + if (visible) { - id: qualitySliderChangeTimer - interval: 50 - running: false - repeat: false - onTriggered: - { - var item = Cura.QualityProfilesDropDownMenuModel.getItem(qualitySlider.value); - Cura.MachineManager.activeQualityGroup = item.quality_group; - } + qualityModel.update(); } + } + } - Component.onCompleted: qualityModel.update() + ListModel + { + id: qualityModel - Connections + property var totalTicks: 0 + property var availableTotalTicks: 0 + property var existingQualityProfile: 0 + + property var qualitySliderActiveIndex: 0 + property var qualitySliderStepWidth: 0 + property var qualitySliderAvailableMin: 0 + property var qualitySliderAvailableMax: 0 + property var qualitySliderMarginRight: 0 + + function update () + { + reset() + + var availableMin = -1 + var availableMax = -1 + + for (var i = 0; i < Cura.QualityProfilesDropDownMenuModel.rowCount(); i++) { - target: Cura.QualityProfilesDropDownMenuModel - onItemsChanged: qualityModel.update() - } + var qualityItem = Cura.QualityProfilesDropDownMenuModel.getItem(i) - Connections { - target: base - onVisibleChanged: + // Add each quality item to the UI quality model + qualityModel.append(qualityItem) + + // Set selected value + if (Cura.MachineManager.activeQualityType == qualityItem.quality_type) { - // update needs to be called when the widgets are visible, otherwise the step width calculation - // will fail because the width of an invisible item is 0. - if (visible) + // set to -1 when switching to user created profile so all ticks are clickable + if (Cura.SimpleModeSettingsManager.isProfileUserCreated) { - qualityModel.update(); - } - } - } - - ListModel - { - id: qualityModel - - property var totalTicks: 0 - property var availableTotalTicks: 0 - property var existingQualityProfile: 0 - - property var qualitySliderActiveIndex: 0 - property var qualitySliderStepWidth: 0 - property var qualitySliderAvailableMin: 0 - property var qualitySliderAvailableMax: 0 - property var qualitySliderMarginRight: 0 - - function update () - { - reset() - - var availableMin = -1 - var availableMax = -1 - - for (var i = 0; i < Cura.QualityProfilesDropDownMenuModel.rowCount(); i++) - { - var qualityItem = Cura.QualityProfilesDropDownMenuModel.getItem(i) - - // Add each quality item to the UI quality model - qualityModel.append(qualityItem) - - // Set selected value - if (Cura.MachineManager.activeQualityType == qualityItem.quality_type) - { - // set to -1 when switching to user created profile so all ticks are clickable - if (Cura.SimpleModeSettingsManager.isProfileUserCreated) - { - qualityModel.qualitySliderActiveIndex = -1 - } - else - { - qualityModel.qualitySliderActiveIndex = i - } - - qualityModel.existingQualityProfile = 1 - } - - // Set min available - if (qualityItem.available && availableMin == -1) - { - availableMin = i - } - - // Set max available - if (qualityItem.available) - { - availableMax = i - } - } - - // Set total available ticks for active slider part - if (availableMin != -1) - { - qualityModel.availableTotalTicks = availableMax - availableMin + 1 - } - - // Calculate slider values - calculateSliderStepWidth(qualityModel.totalTicks) - calculateSliderMargins(availableMin, availableMax, qualityModel.totalTicks) - - qualityModel.qualitySliderAvailableMin = availableMin - qualityModel.qualitySliderAvailableMax = availableMax - } - - function calculateSliderStepWidth (totalTicks) - { - qualityModel.qualitySliderStepWidth = totalTicks != 0 ? Math.round((base.width * 0.55) / (totalTicks)) : 0 - } - - function calculateSliderMargins (availableMin, availableMax, totalTicks) - { - if (availableMin == -1 || (availableMin == 0 && availableMax == 0)) - { - qualityModel.qualitySliderMarginRight = Math.round(base.width * 0.55) - } - else if (availableMin == availableMax) - { - qualityModel.qualitySliderMarginRight = Math.round((totalTicks - availableMin) * qualitySliderStepWidth) + qualityModel.qualitySliderActiveIndex = -1 } else { - qualityModel.qualitySliderMarginRight = Math.round((totalTicks - availableMax) * qualitySliderStepWidth) + qualityModel.qualitySliderActiveIndex = i } + + qualityModel.existingQualityProfile = 1 } - function reset () { - qualityModel.clear() - qualityModel.availableTotalTicks = 0 - qualityModel.existingQualityProfile = 0 + // Set min available + if (qualityItem.available && availableMin == -1) + { + availableMin = i + } - // check, the ticks count cannot be less than zero - qualityModel.totalTicks = Math.max(0, Cura.QualityProfilesDropDownMenuModel.rowCount() - 1) + // Set max available + if (qualityItem.available) + { + availableMax = i } } - Cura.IconLabel + // Set total available ticks for active slider part + if (availableMin != -1) { - id: qualityRowTitle - source: UM.Theme.getIcon("category_layer_height") - text: catalog.i18nc("@label", "Layer Height") - anchors.bottom: speedSlider.bottom + qualityModel.availableTotalTicks = availableMax - availableMin + 1 } - // Show titles for the each quality slider ticks - Item + // Calculate slider values + calculateSliderStepWidth(qualityModel.totalTicks) + calculateSliderMargins(availableMin, availableMax, qualityModel.totalTicks) + + qualityModel.qualitySliderAvailableMin = availableMin + qualityModel.qualitySliderAvailableMax = availableMax + } + + function calculateSliderStepWidth (totalTicks) + { + qualityModel.qualitySliderStepWidth = totalTicks != 0 ? Math.round((base.width * 0.55) / (totalTicks)) : 0 + } + + function calculateSliderMargins (availableMin, availableMax, totalTicks) + { + if (availableMin == -1 || (availableMin == 0 && availableMax == 0)) { - anchors.left: speedSlider.left - anchors.top: speedSlider.bottom - Repeater - { - model: qualityModel - - Label - { - anchors.verticalCenter: parent.verticalCenter - anchors.top: parent.bottom - color: (Cura.MachineManager.activeMachine != null && Cura.QualityProfilesDropDownMenuModel.getItem(index).available) ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") - text: - { - var result = "" - if(Cura.MachineManager.activeMachine != null) - { - result = Cura.QualityProfilesDropDownMenuModel.getItem(index).layer_height - - if(result == undefined) - { - result = ""; - } - else - { - result = Number(Math.round(result + "e+2") + "e-2"); //Round to 2 decimals. Javascript makes this difficult... - if (result == undefined || result != result) //Parse failure. - { - result = ""; - } - } - } - return result - } - - x: - { - // Make sure the text aligns correctly with each tick - if (qualityModel.totalTicks == 0) - { - // If there is only one tick, align it centrally - return Math.round(((base.width * 0.55) - width) / 2) - } - else if (index == 0) - { - return Math.round(base.width * 0.55 / qualityModel.totalTicks) * index - } - else if (index == qualityModel.totalTicks) - { - return Math.round(base.width * 0.55 / qualityModel.totalTicks) * index - width - } - else - { - return Math.round((base.width * 0.55 / qualityModel.totalTicks) * index - (width / 2)) - } - } - } - } + qualityModel.qualitySliderMarginRight = Math.round(base.width * 0.55) } - - //Print speed slider - Rectangle + else if (availableMin == availableMax) { - id: speedSlider - width: Math.round(base.width * 0.55) - height: UM.Theme.getSize("thick_margin").height - anchors.right: parent.right - anchors.top: parent.top - anchors.topMargin: UM.Theme.getSize("thick_margin").height - - // This Item is used only for tooltip, for slider area which is unavailable - Item - { - function showTooltip (showTooltip) - { - if (showTooltip) - { - var content = catalog.i18nc("@tooltip", "This quality profile is not available for you current material and nozzle configuration. Please change these to enable this quality profile") - base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), content) - } - else - { - base.hideTooltip() - } - } - - id: unavailableLineToolTip - height: 20 * screenScaleFactor // hovered area height - z: parent.z + 1 // should be higher, otherwise the area can be hovered - x: 0 - anchors.verticalCenter: qualitySlider.verticalCenter - - Rectangle - { - id: leftArea - width: - { - if (qualityModel.availableTotalTicks == 0) - { - return qualityModel.qualitySliderStepWidth * qualityModel.totalTicks - } - return qualityModel.qualitySliderStepWidth * qualityModel.qualitySliderAvailableMin - 10 - } - height: parent.height - color: "transparent" - - MouseArea - { - anchors.fill: parent - hoverEnabled: true - enabled: Cura.SimpleModeSettingsManager.isProfileUserCreated == false - onEntered: unavailableLineToolTip.showTooltip(true) - onExited: unavailableLineToolTip.showTooltip(false) - } - } - - Item - { - id: rightArea - width: - { - if(qualityModel.availableTotalTicks == 0) - return 0 - - return qualityModel.qualitySliderMarginRight - 10 - } - height: parent.height - x: - { - if (qualityModel.availableTotalTicks == 0) - { - return 0 - } - - var leftUnavailableArea = qualityModel.qualitySliderStepWidth * qualityModel.qualitySliderAvailableMin - var totalGap = qualityModel.qualitySliderStepWidth * (qualityModel.availableTotalTicks -1) + leftUnavailableArea + 10 - - return totalGap - } - - MouseArea - { - anchors.fill: parent - hoverEnabled: true - enabled: Cura.SimpleModeSettingsManager.isProfileUserCreated == false - onEntered: unavailableLineToolTip.showTooltip(true) - onExited: unavailableLineToolTip.showTooltip(false) - } - } - } - - // Draw Unavailable line - Rectangle - { - id: groovechildrect - width: Math.round(base.width * 0.55) - height: 2 * screenScaleFactor - color: UM.Theme.getColor("quality_slider_unavailable") - anchors.verticalCenter: qualitySlider.verticalCenter - x: 0 - } - - // Draw ticks - Repeater - { - id: qualityRepeater - model: qualityModel.totalTicks > 0 ? qualityModel : 0 - - Rectangle - { - color: Cura.QualityProfilesDropDownMenuModel.getItem(index).available ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") - implicitWidth: 5 * screenScaleFactor - implicitHeight: implicitWidth - anchors.verticalCenter: qualitySlider.verticalCenter - x: Math.round(qualityModel.qualitySliderStepWidth * index) - radius: Math.round(implicitWidth / 2) - } - } - - Slider - { - id: qualitySlider - height: UM.Theme.getSize("thick_margin").height - anchors.bottom: speedSlider.bottom - enabled: qualityModel.totalTicks > 0 && !Cura.SimpleModeSettingsManager.isProfileCustomized - visible: qualityModel.availableTotalTicks > 0 - updateValueWhileDragging : false - - minimumValue: qualityModel.qualitySliderAvailableMin >= 0 ? qualityModel.qualitySliderAvailableMin : 0 - // maximumValue must be greater than minimumValue to be able to see the handle. While the value is strictly - // speaking not always correct, it seems to have the correct behavior (switching from 0 available to 1 available) - maximumValue: qualityModel.qualitySliderAvailableMax >= 1 ? qualityModel.qualitySliderAvailableMax : 1 - stepSize: 1 - - value: qualityModel.qualitySliderActiveIndex - - width: qualityModel.qualitySliderStepWidth * (qualityModel.availableTotalTicks - 1) - - anchors.right: parent.right - anchors.rightMargin: qualityModel.qualitySliderMarginRight - - style: SliderStyle - { - //Draw Available line - groove: Rectangle - { - implicitHeight: 2 * screenScaleFactor - color: UM.Theme.getColor("quality_slider_available") - radius: Math.round(height / 2) - } - handle: Item - { - Rectangle - { - id: qualityhandleButton - anchors.centerIn: parent - color: UM.Theme.getColor("quality_slider_available") - implicitWidth: 10 * screenScaleFactor - implicitHeight: implicitWidth - radius: Math.round(implicitWidth / 2) - visible: !Cura.SimpleModeSettingsManager.isProfileCustomized && !Cura.SimpleModeSettingsManager.isProfileUserCreated && qualityModel.existingQualityProfile - } - } - } - - onValueChanged: - { - // only change if an active machine is set and the slider is visible at all. - if (Cura.MachineManager.activeMachine != null && visible) - { - // prevent updating during view initializing. Trigger only if the value changed by user - if (qualitySlider.value != qualityModel.qualitySliderActiveIndex && qualityModel.qualitySliderActiveIndex != -1) - { - // start updating with short delay - qualitySliderChangeTimer.start() - } - } - } - } - - MouseArea - { - id: speedSliderMouseArea - anchors.fill: parent - hoverEnabled: true - enabled: Cura.SimpleModeSettingsManager.isProfileUserCreated - - onEntered: - { - var content = catalog.i18nc("@tooltip","A custom profile is currently active. To enable the quality slider, choose a default quality profile in Custom tab") - base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), content) - } - onExited: base.hideTooltip() - } + qualityModel.qualitySliderMarginRight = Math.round((totalTicks - availableMin) * qualitySliderStepWidth) } - - UM.SimpleButton + else { - id: customisedSettings - - visible: Cura.SimpleModeSettingsManager.isProfileCustomized || Cura.SimpleModeSettingsManager.isProfileUserCreated - height: Math.round(speedSlider.height * 0.8) - width: Math.round(speedSlider.height * 0.8) - - anchors.verticalCenter: speedSlider.verticalCenter - anchors.right: speedSlider.left - anchors.rightMargin: Math.round(UM.Theme.getSize("thick_margin").width / 2) - - color: hovered ? UM.Theme.getColor("setting_control_button_hover") : UM.Theme.getColor("setting_control_button"); - iconSource: UM.Theme.getIcon("reset"); - - onClicked: - { - // if the current profile is user-created, switch to a built-in quality - Cura.MachineManager.resetToUseDefaultQuality() - } - onEntered: - { - var content = catalog.i18nc("@tooltip","You have modified some profile settings. If you want to change these go to custom mode.") - base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), content) - } - onExited: base.hideTooltip() + qualityModel.qualitySliderMarginRight = Math.round((totalTicks - availableMax) * qualitySliderStepWidth) } } - // - // Infill - // - Item - { - id: infillCellLeft + function reset () { + qualityModel.clear() + qualityModel.availableTotalTicks = 0 + qualityModel.existingQualityProfile = 0 - anchors.top: qualityRow.bottom - anchors.topMargin: UM.Theme.getSize("thick_margin").height * 2 - anchors.left: parent.left - - width: Math.round(UM.Theme.getSize("print_setup_widget").width * .45) - UM.Theme.getSize("thick_margin").width - - Cura.IconLabel - { - id: infillLabel - source: UM.Theme.getIcon("category_infill") - text: catalog.i18nc("@label", "Infill") + " (%)" - - anchors - { - top: parent.top - topMargin: Math.round(UM.Theme.getSize("thick_margin").height * 1.7) - left: parent.left - } - } + // check, the ticks count cannot be less than zero + qualityModel.totalTicks = Math.max(0, Cura.QualityProfilesDropDownMenuModel.rowCount() - 1) } + } - Item + Cura.IconWithText + { + id: qualityRowTitle + source: UM.Theme.getIcon("category_layer_height") + text: catalog.i18nc("@label", "Layer Height") + anchors.bottom: speedSlider.bottom + } + + // Show titles for the each quality slider ticks + Item + { + anchors.left: speedSlider.left + anchors.top: speedSlider.bottom + Repeater { - id: infillCellRight - - height: infillSlider.height + UM.Theme.getSize("thick_margin").height + enableGradualInfillCheckBox.visible * (enableGradualInfillCheckBox.height + UM.Theme.getSize("thick_margin").height) - width: Math.round(UM.Theme.getSize("print_setup_widget").width * .55) - - anchors.left: infillCellLeft.right - anchors.top: infillCellLeft.top - anchors.topMargin: UM.Theme.getSize("thick_margin").height - - Label { - id: selectedInfillRateText - - anchors.left: infillSlider.left - anchors.right: parent.right - - text: parseInt(infillDensity.properties.value) + "%" - horizontalAlignment: Text.AlignLeft - - color: infillSlider.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") - } - - // We use a binding to make sure that after manually setting infillSlider.value it is still bound to the property provider - Binding - { - target: infillSlider - property: "value" - value: parseInt(infillDensity.properties.value) - } - - Slider - { - id: infillSlider - - anchors.top: selectedInfillRateText.bottom - anchors.left: parent.left - anchors.right: infillIcon.left - anchors.rightMargin: UM.Theme.getSize("thick_margin").width - - height: UM.Theme.getSize("thick_margin").height - width: parseInt(infillCellRight.width - UM.Theme.getSize("thick_margin").width - style.handleWidth) - - minimumValue: 0 - maximumValue: 100 - stepSize: 1 - tickmarksEnabled: true - - // disable slider when gradual support is enabled - enabled: parseInt(infillSteps.properties.value) == 0 - - // set initial value from stack - value: parseInt(infillDensity.properties.value) - - onValueChanged: - { - - // Don't round the value if it's already the same - if (parseInt(infillDensity.properties.value) == infillSlider.value) - { - return - } - - // Round the slider value to the nearest multiple of 10 (simulate step size of 10) - var roundedSliderValue = Math.round(infillSlider.value / 10) * 10 - - // Update the slider value to represent the rounded value - infillSlider.value = roundedSliderValue - - // Update value only if the Recomended mode is Active, - // Otherwise if I change the value in the Custom mode the Recomended view will try to repeat - // same operation - var active_mode = UM.Preferences.getValue("cura/active_mode") - - if (active_mode == 0 || active_mode == "simple") - { - Cura.MachineManager.setSettingForAllExtruders("infill_sparse_density", "value", roundedSliderValue) - Cura.MachineManager.resetSettingForAllExtruders("infill_line_distance") - } - } - - style: SliderStyle - { - groove: Rectangle - { - id: groove - implicitWidth: 200 * screenScaleFactor - implicitHeight: 2 * screenScaleFactor - color: control.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") - radius: 1 - } - - handle: Item - { - Rectangle - { - id: handleButton - anchors.centerIn: parent - color: control.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") - implicitWidth: 10 * screenScaleFactor - implicitHeight: 10 * screenScaleFactor - radius: 10 * screenScaleFactor - } - } - - tickmarks: Repeater - { - id: repeater - model: control.maximumValue / control.stepSize + 1 - - // check if a tick should be shown based on it's index and wether the infill density is a multiple of 10 (slider step size) - function shouldShowTick (index) - { - if (index % 10 == 0) - { - return true - } - return false - } - - Rectangle - { - anchors.verticalCenter: parent.verticalCenter - color: control.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") - width: 1 * screenScaleFactor - height: 6 * screenScaleFactor - x: Math.round(styleData.handleWidth / 2 + index * ((repeater.width - styleData.handleWidth) / (repeater.count-1))) - visible: shouldShowTick(index) - } - } - } - } - - Rectangle - { - id: infillIcon - - width: Math.round((parent.width / 5) - (UM.Theme.getSize("thick_margin").width)) - height: width - - anchors.right: parent.right - anchors.top: parent.top - anchors.topMargin: Math.round(UM.Theme.getSize("thick_margin").height / 2) - - // we loop over all density icons and only show the one that has the current density and steps - Repeater - { - id: infillIconList - model: infillModel - anchors.fill: parent - - function activeIndex () - { - for (var i = 0; i < infillModel.count; i++) - { - var density = Math.round(infillDensity.properties.value) - var steps = Math.round(infillSteps.properties.value) - var infillModelItem = infillModel.get(i) - - if (infillModelItem != "undefined" - && density >= infillModelItem.percentageMin - && density <= infillModelItem.percentageMax - && steps >= infillModelItem.stepsMin - && steps <= infillModelItem.stepsMax) - { - return i - } - } - return -1 - } - - Rectangle - { - anchors.fill: parent - visible: infillIconList.activeIndex() == index - - border.width: UM.Theme.getSize("default_lining").width - border.color: UM.Theme.getColor("quality_slider_unavailable") - - UM.RecolorImage - { - anchors.fill: parent - anchors.margins: 2 * screenScaleFactor - sourceSize.width: width - sourceSize.height: width - source: UM.Theme.getIcon(model.icon) - color: UM.Theme.getColor("quality_slider_unavailable") - } - } - } - } - - // Gradual Support Infill Checkbox - CheckBox - { - id: enableGradualInfillCheckBox - property alias _hovered: enableGradualInfillMouseArea.containsMouse - - anchors.top: infillSlider.bottom - anchors.topMargin: Math.round(UM.Theme.getSize("thick_margin").height / 2) // closer to slider since it belongs to the same category - anchors.left: infillCellRight.left - - style: UM.Theme.styles.checkbox - enabled: base.settingsEnabled - visible: infillSteps.properties.enabled == "True" - checked: parseInt(infillSteps.properties.value) > 0 - - MouseArea - { - id: enableGradualInfillMouseArea - - anchors.fill: parent - hoverEnabled: true - enabled: true - - property var previousInfillDensity: parseInt(infillDensity.properties.value) - - onClicked: - { - // Set to 90% only when enabling gradual infill - var newInfillDensity; - if (parseInt(infillSteps.properties.value) == 0) - { - previousInfillDensity = parseInt(infillDensity.properties.value) - newInfillDensity = 90 - } else { - newInfillDensity = previousInfillDensity - } - Cura.MachineManager.setSettingForAllExtruders("infill_sparse_density", "value", String(newInfillDensity)) - - var infill_steps_value = 0 - if (parseInt(infillSteps.properties.value) == 0) - { - infill_steps_value = 5 - } - - Cura.MachineManager.setSettingForAllExtruders("gradual_infill_steps", "value", infill_steps_value) - } - - onEntered: base.showTooltip(enableGradualInfillCheckBox, Qt.point(-infillCellRight.x, 0), - catalog.i18nc("@label", "Gradual infill will gradually increase the amount of infill towards the top.")) - - onExited: base.hideTooltip() - - } - - Label - { - id: gradualInfillLabel - height: parent.height - anchors.left: enableGradualInfillCheckBox.right - anchors.leftMargin: Math.round(UM.Theme.getSize("thick_margin").width / 2) - verticalAlignment: Text.AlignVCenter; - text: catalog.i18nc("@label", "Enable gradual") - font: UM.Theme.getFont("default") - color: UM.Theme.getColor("text") - } - } - - // Infill list model for mapping icon - ListModel - { - id: infillModel - Component.onCompleted: - { - infillModel.append({ - percentageMin: -1, - percentageMax: 0, - stepsMin: -1, - stepsMax: 0, - icon: "hollow" - }) - infillModel.append({ - percentageMin: 0, - percentageMax: 40, - stepsMin: -1, - stepsMax: 0, - icon: "sparse" - }) - infillModel.append({ - percentageMin: 40, - percentageMax: 89, - stepsMin: -1, - stepsMax: 0, - icon: "dense" - }) - infillModel.append({ - percentageMin: 90, - percentageMax: 9999999999, - stepsMin: -1, - stepsMax: 0, - icon: "solid" - }) - infillModel.append({ - percentageMin: 0, - percentageMax: 9999999999, - stepsMin: 1, - stepsMax: 9999999999, - icon: "gradual" - }) - } - } - } - - // - // Enable support - // - Cura.IconLabel - { - id: enableSupportLabel - visible: enableSupportCheckBox.visible - source: UM.Theme.getIcon("category_support") - text: catalog.i18nc("@label", "Support") - - anchors - { - top: infillCellRight.bottom - topMargin: Math.round(UM.Theme.getSize("thick_margin").height * 1.5) - left: parent.left - right: infillCellLeft.right - rightMargin: UM.Theme.getSize("thick_margin").width - verticalCenter: enableSupportCheckBox.verticalCenter - } - } - - CheckBox - { - id: enableSupportCheckBox - property alias _hovered: enableSupportMouseArea.containsMouse - - anchors.top: enableSupportLabel.top - anchors.left: infillCellRight.left - - style: UM.Theme.styles.checkbox - enabled: base.settingsEnabled - - visible: supportEnabled.properties.enabled == "True" - checked: supportEnabled.properties.value == "True" - - MouseArea - { - id: enableSupportMouseArea - anchors.fill: parent - hoverEnabled: true - onClicked: supportEnabled.setPropertyValue("value", supportEnabled.properties.value != "True") - - onEntered: base.showTooltip(enableSupportCheckBox, Qt.point(-enableSupportCheckBox.x, 0), - catalog.i18nc("@label", "Generate structures to support parts of the model which have overhangs. Without these structures, such parts would collapse during printing.")) - - onExited: base.hideTooltip() - - } - } - - ComboBox - { - id: supportExtruderCombobox - visible: enableSupportCheckBox.visible && (supportEnabled.properties.value == "True") && (extrudersEnabledCount.properties.value > 1) - model: extruderModel - - property string color_override: "" // for manually setting values - property string color: // is evaluated automatically, but the first time is before extruderModel being filled - { - var current_extruder = extruderModel.get(currentIndex); - color_override = ""; - if (current_extruder === undefined) return "" - return (current_extruder.color) ? current_extruder.color : ""; - } - - textRole: "text" // this solves that the combobox isn't populated in the first time Cura is started - - anchors.top: enableSupportCheckBox.top - - anchors.left: enableSupportCheckBox.right - anchors.leftMargin: Math.round(UM.Theme.getSize("thick_margin").width / 2) - - width: Math.round(UM.Theme.getSize("print_setup_widget").width * .55) - Math.round(UM.Theme.getSize("thick_margin").width / 2) - enableSupportCheckBox.width - height: ((supportEnabled.properties.value == "True") && (machineExtruderCount.properties.value > 1)) ? UM.Theme.getSize("setting_control").height : 0 - - Behavior on height { NumberAnimation { duration: 100 } } - - style: UM.Theme.styles.combobox_color - enabled: base.settingsEnabled - property alias _hovered: supportExtruderMouseArea.containsMouse - - currentIndex: - { - if (supportExtruderNr.properties == null) - { - return Cura.MachineManager.defaultExtruderPosition - } - else - { - var extruder = parseInt(supportExtruderNr.properties.value) - if ( extruder === -1) - { - return Cura.MachineManager.defaultExtruderPosition - } - return extruder; - } - } - - onActivated: supportExtruderNr.setPropertyValue("value", String(index)) - - MouseArea - { - id: supportExtruderMouseArea - anchors.fill: parent - hoverEnabled: true - enabled: base.settingsEnabled - acceptedButtons: Qt.NoButton - onEntered: - { - base.showTooltip(supportExtruderCombobox, Qt.point(-supportExtruderCombobox.x, 0), - catalog.i18nc("@label", "Select which extruder to use for support. This will build up supporting structures below the model to prevent the model from sagging or printing in mid air.")); - } - onExited: base.hideTooltip() - - } - - function updateCurrentColor() - { - var current_extruder = extruderModel.get(currentIndex) - if (current_extruder !== undefined) - { - supportExtruderCombobox.color_override = current_extruder.color - } - } - - } - - Cura.IconLabel - { - id: adhesionHelperLabel - visible: adhesionCheckBox.visible - source: UM.Theme.getIcon("category_adhesion") - text: catalog.i18nc("@label", "Adhesion") - - anchors - { - left: parent.left - right: infillCellLeft.right - rightMargin: UM.Theme.getSize("thick_margin").width - verticalCenter: adhesionCheckBox.verticalCenter - } - } - - CheckBox - { - id: adhesionCheckBox - property alias _hovered: adhesionMouseArea.containsMouse - - anchors.top: enableSupportCheckBox.bottom - anchors.topMargin: UM.Theme.getSize("thick_margin").height - anchors.left: infillCellRight.left - - //: Setting enable printing build-plate adhesion helper checkbox - style: UM.Theme.styles.checkbox - enabled: base.settingsEnabled - - visible: platformAdhesionType.properties.enabled == "True" - checked: platformAdhesionType.properties.value != "skirt" && platformAdhesionType.properties.value != "none" - - MouseArea - { - id: adhesionMouseArea - anchors.fill: parent - hoverEnabled: true - enabled: base.settingsEnabled - onClicked: - { - var adhesionType = "skirt" - if(!parent.checked) - { - // Remove the "user" setting to see if the rest of the stack prescribes a brim or a raft - platformAdhesionType.removeFromContainer(0) - adhesionType = platformAdhesionType.properties.value - if(adhesionType == "skirt" || adhesionType == "none") - { - // If the rest of the stack doesn't prescribe an adhesion-type, default to a brim - adhesionType = "brim" - } - } - platformAdhesionType.setPropertyValue("value", adhesionType) - } - onEntered: - { - base.showTooltip(adhesionCheckBox, Qt.point(-adhesionCheckBox.x, 0), - catalog.i18nc("@label", "Enable printing a brim or raft. This will add a flat area around or under your object which is easy to cut off afterwards.")); - } - onExited: base.hideTooltip() - - } - } - - ListModel - { - id: extruderModel - Component.onCompleted: populateExtruderModel() - } - - //: Model used to populate the extrudelModel - Cura.ExtrudersModel - { - id: extruders - onModelChanged: populateExtruderModel() - } - - Item - { - id: tipsCell - anchors.top: adhesionCheckBox.visible ? adhesionCheckBox.bottom : (enableSupportCheckBox.visible ? supportExtruderCombobox.bottom : infillCellRight.bottom) - anchors.topMargin: Math.round(UM.Theme.getSize("thick_margin").height * 2) - anchors.left: parent.left - width: parent.width - height: tipsText.contentHeight * tipsText.lineCount + model: qualityModel Label { - id: tipsText - anchors.left: parent.left - anchors.right: parent.right - anchors.rightMargin: UM.Theme.getSize("thick_margin").width - anchors.top: parent.top - wrapMode: Text.WordWrap - text: catalog.i18nc("@label", "Need help improving your prints?
Read the Ultimaker Troubleshooting Guides").arg("https://ultimaker.com/en/troubleshooting") - font: UM.Theme.getFont("default"); - color: UM.Theme.getColor("text"); - linkColor: UM.Theme.getColor("text_link") - onLinkActivated: Qt.openUrlExternally(link) + anchors.verticalCenter: parent.verticalCenter + anchors.top: parent.bottom + color: (Cura.MachineManager.activeMachine != null && Cura.QualityProfilesDropDownMenuModel.getItem(index).available) ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") + text: + { + var result = "" + if(Cura.MachineManager.activeMachine != null) + { + result = Cura.QualityProfilesDropDownMenuModel.getItem(index).layer_height + + if(result == undefined) + { + result = ""; + } + else + { + result = Number(Math.round(result + "e+2") + "e-2"); //Round to 2 decimals. Javascript makes this difficult... + if (result == undefined || result != result) //Parse failure. + { + result = ""; + } + } + } + return result + } + + x: + { + // Make sure the text aligns correctly with each tick + if (qualityModel.totalTicks == 0) + { + // If there is only one tick, align it centrally + return Math.round(((base.width * 0.55) - width) / 2) + } + else if (index == 0) + { + return Math.round(base.width * 0.55 / qualityModel.totalTicks) * index + } + else if (index == qualityModel.totalTicks) + { + return Math.round(base.width * 0.55 / qualityModel.totalTicks) * index - width + } + else + { + return Math.round((base.width * 0.55 / qualityModel.totalTicks) * index - (width / 2)) + } + } + } + } + } + + //Print speed slider + Rectangle + { + id: speedSlider + width: Math.round(base.width * 0.55) + height: UM.Theme.getSize("thick_margin").height + anchors.right: parent.right + anchors.top: parent.top + anchors.topMargin: UM.Theme.getSize("thick_margin").height + + // This Item is used only for tooltip, for slider area which is unavailable + Item + { + function showTooltip (showTooltip) + { + if (showTooltip) + { + var content = catalog.i18nc("@tooltip", "This quality profile is not available for you current material and nozzle configuration. Please change these to enable this quality profile") + base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), content) + } + else + { + base.hideTooltip() + } + } + + id: unavailableLineToolTip + height: 20 * screenScaleFactor // hovered area height + z: parent.z + 1 // should be higher, otherwise the area can be hovered + x: 0 + anchors.verticalCenter: qualitySlider.verticalCenter + + Rectangle + { + id: leftArea + width: + { + if (qualityModel.availableTotalTicks == 0) + { + return qualityModel.qualitySliderStepWidth * qualityModel.totalTicks + } + return qualityModel.qualitySliderStepWidth * qualityModel.qualitySliderAvailableMin - 10 + } + height: parent.height + color: "transparent" + + MouseArea + { + anchors.fill: parent + hoverEnabled: true + enabled: Cura.SimpleModeSettingsManager.isProfileUserCreated == false + onEntered: unavailableLineToolTip.showTooltip(true) + onExited: unavailableLineToolTip.showTooltip(false) + } + } + + Item + { + id: rightArea + width: + { + if(qualityModel.availableTotalTicks == 0) + return 0 + + return qualityModel.qualitySliderMarginRight - 10 + } + height: parent.height + x: + { + if (qualityModel.availableTotalTicks == 0) + { + return 0 + } + + var leftUnavailableArea = qualityModel.qualitySliderStepWidth * qualityModel.qualitySliderAvailableMin + var totalGap = qualityModel.qualitySliderStepWidth * (qualityModel.availableTotalTicks -1) + leftUnavailableArea + 10 + + return totalGap + } + + MouseArea + { + anchors.fill: parent + hoverEnabled: true + enabled: Cura.SimpleModeSettingsManager.isProfileUserCreated == false + onEntered: unavailableLineToolTip.showTooltip(true) + onExited: unavailableLineToolTip.showTooltip(false) + } } } - UM.SettingPropertyProvider + // Draw Unavailable line + Rectangle { - id: infillExtruderNumber - containerStackId: Cura.MachineManager.activeStackId - key: "infill_extruder_nr" - watchedProperties: [ "value" ] - storeIndex: 0 + id: groovechildrect + width: Math.round(base.width * 0.55) + height: 2 * screenScaleFactor + color: UM.Theme.getColor("quality_slider_unavailable") + anchors.verticalCenter: qualitySlider.verticalCenter + x: 0 } - UM.SettingPropertyProvider + // Draw ticks + Repeater { - id: infillDensity - containerStackId: Cura.MachineManager.activeStackId - key: "infill_sparse_density" - watchedProperties: [ "value" ] - storeIndex: 0 + id: qualityRepeater + model: qualityModel.totalTicks > 0 ? qualityModel : 0 + + Rectangle + { + color: Cura.QualityProfilesDropDownMenuModel.getItem(index).available ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") + implicitWidth: 5 * screenScaleFactor + implicitHeight: implicitWidth + anchors.verticalCenter: qualitySlider.verticalCenter + x: Math.round(qualityModel.qualitySliderStepWidth * index) + radius: Math.round(implicitWidth / 2) + } } - UM.SettingPropertyProvider + Slider { - id: infillSteps - containerStackId: Cura.MachineManager.activeStackId - key: "gradual_infill_steps" - watchedProperties: ["value", "enabled"] - storeIndex: 0 + id: qualitySlider + height: UM.Theme.getSize("thick_margin").height + anchors.bottom: speedSlider.bottom + enabled: qualityModel.totalTicks > 0 && !Cura.SimpleModeSettingsManager.isProfileCustomized + visible: qualityModel.availableTotalTicks > 0 + updateValueWhileDragging : false + + minimumValue: qualityModel.qualitySliderAvailableMin >= 0 ? qualityModel.qualitySliderAvailableMin : 0 + // maximumValue must be greater than minimumValue to be able to see the handle. While the value is strictly + // speaking not always correct, it seems to have the correct behavior (switching from 0 available to 1 available) + maximumValue: qualityModel.qualitySliderAvailableMax >= 1 ? qualityModel.qualitySliderAvailableMax : 1 + stepSize: 1 + + value: qualityModel.qualitySliderActiveIndex + + width: qualityModel.qualitySliderStepWidth * (qualityModel.availableTotalTicks - 1) + + anchors.right: parent.right + anchors.rightMargin: qualityModel.qualitySliderMarginRight + + style: SliderStyle + { + //Draw Available line + groove: Rectangle + { + implicitHeight: 2 * screenScaleFactor + color: UM.Theme.getColor("quality_slider_available") + radius: Math.round(height / 2) + } + handle: Item + { + Rectangle + { + id: qualityhandleButton + anchors.centerIn: parent + color: UM.Theme.getColor("quality_slider_available") + implicitWidth: 10 * screenScaleFactor + implicitHeight: implicitWidth + radius: Math.round(implicitWidth / 2) + visible: !Cura.SimpleModeSettingsManager.isProfileCustomized && !Cura.SimpleModeSettingsManager.isProfileUserCreated && qualityModel.existingQualityProfile + } + } + } + + onValueChanged: + { + // only change if an active machine is set and the slider is visible at all. + if (Cura.MachineManager.activeMachine != null && visible) + { + // prevent updating during view initializing. Trigger only if the value changed by user + if (qualitySlider.value != qualityModel.qualitySliderActiveIndex && qualityModel.qualitySliderActiveIndex != -1) + { + // start updating with short delay + qualitySliderChangeTimer.start() + } + } + } } - UM.SettingPropertyProvider + MouseArea { - id: platformAdhesionType - containerStack: Cura.MachineManager.activeMachine - removeUnusedValue: false //Doesn't work with settings that are resolved. - key: "adhesion_type" - watchedProperties: [ "value", "enabled" ] - storeIndex: 0 - } + id: speedSliderMouseArea + anchors.fill: parent + hoverEnabled: true + enabled: Cura.SimpleModeSettingsManager.isProfileUserCreated - UM.SettingPropertyProvider - { - id: supportEnabled - containerStack: Cura.MachineManager.activeMachine - key: "support_enable" - watchedProperties: [ "value", "enabled", "description" ] - storeIndex: 0 - } - - UM.SettingPropertyProvider - { - id: extrudersEnabledCount - containerStack: Cura.MachineManager.activeMachine - key: "extruders_enabled_count" - watchedProperties: [ "value" ] - storeIndex: 0 - } - - UM.SettingPropertyProvider - { - id: supportExtruderNr - containerStack: Cura.MachineManager.activeMachine - key: "support_extruder_nr" - watchedProperties: [ "value" ] - storeIndex: 0 + onEntered: + { + var content = catalog.i18nc("@tooltip","A custom profile is currently active. To enable the quality slider, choose a default quality profile in Custom tab") + base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), content) + } + onExited: base.hideTooltip() } } + + UM.SimpleButton + { + id: customisedSettings + + visible: Cura.SimpleModeSettingsManager.isProfileCustomized || Cura.SimpleModeSettingsManager.isProfileUserCreated + height: Math.round(speedSlider.height * 0.8) + width: Math.round(speedSlider.height * 0.8) + + anchors.verticalCenter: speedSlider.verticalCenter + anchors.right: speedSlider.left + anchors.rightMargin: Math.round(UM.Theme.getSize("thick_margin").width / 2) + + color: hovered ? UM.Theme.getColor("setting_control_button_hover") : UM.Theme.getColor("setting_control_button"); + iconSource: UM.Theme.getIcon("reset"); + + onClicked: + { + // if the current profile is user-created, switch to a built-in quality + Cura.MachineManager.resetToUseDefaultQuality() + } + onEntered: + { + var content = catalog.i18nc("@tooltip","You have modified some profile settings. If you want to change these go to custom mode.") + base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), content) + } + onExited: base.hideTooltip() + } + } + + // + // Infill + // + Item + { + id: infillCellLeft + + anchors.top: qualityRow.bottom + anchors.topMargin: UM.Theme.getSize("thick_margin").height * 2 + anchors.left: parent.left + + width: Math.round(UM.Theme.getSize("print_setup_widget").width * .45) - UM.Theme.getSize("thick_margin").width + + Cura.IconWithText + { + id: infillLabel + source: UM.Theme.getIcon("category_infill") + text: catalog.i18nc("@label", "Infill") + " (%)" + + anchors + { + top: parent.top + topMargin: Math.round(UM.Theme.getSize("thick_margin").height * 1.7) + left: parent.left + } + } + } + + Item + { + id: infillCellRight + + height: infillSlider.height + UM.Theme.getSize("thick_margin").height + enableGradualInfillCheckBox.visible * (enableGradualInfillCheckBox.height + UM.Theme.getSize("thick_margin").height) + width: Math.round(UM.Theme.getSize("print_setup_widget").width * .55) + + anchors.left: infillCellLeft.right + anchors.top: infillCellLeft.top + anchors.topMargin: UM.Theme.getSize("thick_margin").height + + Label { + id: selectedInfillRateText + + anchors.left: infillSlider.left + anchors.right: parent.right + + text: parseInt(infillDensity.properties.value) + "%" + horizontalAlignment: Text.AlignLeft + + color: infillSlider.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") + } + + // We use a binding to make sure that after manually setting infillSlider.value it is still bound to the property provider + Binding + { + target: infillSlider + property: "value" + value: parseInt(infillDensity.properties.value) + } + + Slider + { + id: infillSlider + + anchors.top: selectedInfillRateText.bottom + anchors.left: parent.left + anchors.right: infillIcon.left + anchors.rightMargin: UM.Theme.getSize("thick_margin").width + + height: UM.Theme.getSize("thick_margin").height + width: parseInt(infillCellRight.width - UM.Theme.getSize("thick_margin").width - style.handleWidth) + + minimumValue: 0 + maximumValue: 100 + stepSize: 1 + tickmarksEnabled: true + + // disable slider when gradual support is enabled + enabled: parseInt(infillSteps.properties.value) == 0 + + // set initial value from stack + value: parseInt(infillDensity.properties.value) + + onValueChanged: + { + + // Don't round the value if it's already the same + if (parseInt(infillDensity.properties.value) == infillSlider.value) + { + return + } + + // Round the slider value to the nearest multiple of 10 (simulate step size of 10) + var roundedSliderValue = Math.round(infillSlider.value / 10) * 10 + + // Update the slider value to represent the rounded value + infillSlider.value = roundedSliderValue + + // Update value only if the Recomended mode is Active, + // Otherwise if I change the value in the Custom mode the Recomended view will try to repeat + // same operation + var active_mode = UM.Preferences.getValue("cura/active_mode") + + if (active_mode == 0 || active_mode == "simple") + { + Cura.MachineManager.setSettingForAllExtruders("infill_sparse_density", "value", roundedSliderValue) + Cura.MachineManager.resetSettingForAllExtruders("infill_line_distance") + } + } + + style: SliderStyle + { + groove: Rectangle + { + id: groove + implicitWidth: 200 * screenScaleFactor + implicitHeight: 2 * screenScaleFactor + color: control.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") + radius: 1 + } + + handle: Item + { + Rectangle + { + id: handleButton + anchors.centerIn: parent + color: control.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") + implicitWidth: 10 * screenScaleFactor + implicitHeight: 10 * screenScaleFactor + radius: 10 * screenScaleFactor + } + } + + tickmarks: Repeater + { + id: repeater + model: control.maximumValue / control.stepSize + 1 + + // check if a tick should be shown based on it's index and wether the infill density is a multiple of 10 (slider step size) + function shouldShowTick (index) + { + if (index % 10 == 0) + { + return true + } + return false + } + + Rectangle + { + anchors.verticalCenter: parent.verticalCenter + color: control.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") + width: 1 * screenScaleFactor + height: 6 * screenScaleFactor + x: Math.round(styleData.handleWidth / 2 + index * ((repeater.width - styleData.handleWidth) / (repeater.count-1))) + visible: shouldShowTick(index) + } + } + } + } + + Rectangle + { + id: infillIcon + + width: Math.round((parent.width / 5) - (UM.Theme.getSize("thick_margin").width)) + height: width + + anchors.right: parent.right + anchors.top: parent.top + anchors.topMargin: Math.round(UM.Theme.getSize("thick_margin").height / 2) + + // we loop over all density icons and only show the one that has the current density and steps + Repeater + { + id: infillIconList + model: infillModel + anchors.fill: parent + + function activeIndex () + { + for (var i = 0; i < infillModel.count; i++) + { + var density = Math.round(infillDensity.properties.value) + var steps = Math.round(infillSteps.properties.value) + var infillModelItem = infillModel.get(i) + + if (infillModelItem != "undefined" + && density >= infillModelItem.percentageMin + && density <= infillModelItem.percentageMax + && steps >= infillModelItem.stepsMin + && steps <= infillModelItem.stepsMax) + { + return i + } + } + return -1 + } + + Rectangle + { + anchors.fill: parent + visible: infillIconList.activeIndex() == index + + border.width: UM.Theme.getSize("default_lining").width + border.color: UM.Theme.getColor("quality_slider_unavailable") + + UM.RecolorImage + { + anchors.fill: parent + anchors.margins: 2 * screenScaleFactor + sourceSize.width: width + sourceSize.height: width + source: UM.Theme.getIcon(model.icon) + color: UM.Theme.getColor("quality_slider_unavailable") + } + } + } + } + + // Gradual Support Infill Checkbox + CheckBox + { + id: enableGradualInfillCheckBox + property alias _hovered: enableGradualInfillMouseArea.containsMouse + + anchors.top: infillSlider.bottom + anchors.topMargin: Math.round(UM.Theme.getSize("thick_margin").height / 2) // closer to slider since it belongs to the same category + anchors.left: infillCellRight.left + + style: UM.Theme.styles.checkbox + enabled: base.settingsEnabled + visible: infillSteps.properties.enabled == "True" + checked: parseInt(infillSteps.properties.value) > 0 + + MouseArea + { + id: enableGradualInfillMouseArea + + anchors.fill: parent + hoverEnabled: true + enabled: true + + property var previousInfillDensity: parseInt(infillDensity.properties.value) + + onClicked: + { + // Set to 90% only when enabling gradual infill + var newInfillDensity; + if (parseInt(infillSteps.properties.value) == 0) + { + previousInfillDensity = parseInt(infillDensity.properties.value) + newInfillDensity = 90 + } else { + newInfillDensity = previousInfillDensity + } + Cura.MachineManager.setSettingForAllExtruders("infill_sparse_density", "value", String(newInfillDensity)) + + var infill_steps_value = 0 + if (parseInt(infillSteps.properties.value) == 0) + { + infill_steps_value = 5 + } + + Cura.MachineManager.setSettingForAllExtruders("gradual_infill_steps", "value", infill_steps_value) + } + + onEntered: base.showTooltip(enableGradualInfillCheckBox, Qt.point(-infillCellRight.x, 0), + catalog.i18nc("@label", "Gradual infill will gradually increase the amount of infill towards the top.")) + + onExited: base.hideTooltip() + + } + + Label + { + id: gradualInfillLabel + height: parent.height + anchors.left: enableGradualInfillCheckBox.right + anchors.leftMargin: Math.round(UM.Theme.getSize("thick_margin").width / 2) + verticalAlignment: Text.AlignVCenter; + text: catalog.i18nc("@label", "Enable gradual") + font: UM.Theme.getFont("default") + color: UM.Theme.getColor("text") + } + } + + // Infill list model for mapping icon + ListModel + { + id: infillModel + Component.onCompleted: + { + infillModel.append({ + percentageMin: -1, + percentageMax: 0, + stepsMin: -1, + stepsMax: 0, + icon: "hollow" + }) + infillModel.append({ + percentageMin: 0, + percentageMax: 40, + stepsMin: -1, + stepsMax: 0, + icon: "sparse" + }) + infillModel.append({ + percentageMin: 40, + percentageMax: 89, + stepsMin: -1, + stepsMax: 0, + icon: "dense" + }) + infillModel.append({ + percentageMin: 90, + percentageMax: 9999999999, + stepsMin: -1, + stepsMax: 0, + icon: "solid" + }) + infillModel.append({ + percentageMin: 0, + percentageMax: 9999999999, + stepsMin: 1, + stepsMax: 9999999999, + icon: "gradual" + }) + } + } + } + + // + // Enable support + // + Cura.IconWithText + { + id: enableSupportLabel + visible: enableSupportCheckBox.visible + source: UM.Theme.getIcon("category_support") + text: catalog.i18nc("@label", "Support") + + anchors + { + top: infillCellRight.bottom + topMargin: Math.round(UM.Theme.getSize("thick_margin").height * 1.5) + left: parent.left + right: infillCellLeft.right + rightMargin: UM.Theme.getSize("thick_margin").width + verticalCenter: enableSupportCheckBox.verticalCenter + } + } + + CheckBox + { + id: enableSupportCheckBox + property alias _hovered: enableSupportMouseArea.containsMouse + + anchors.top: enableSupportLabel.top + anchors.left: infillCellRight.left + + style: UM.Theme.styles.checkbox + enabled: base.settingsEnabled + + visible: supportEnabled.properties.enabled == "True" + checked: supportEnabled.properties.value == "True" + + MouseArea + { + id: enableSupportMouseArea + anchors.fill: parent + hoverEnabled: true + onClicked: supportEnabled.setPropertyValue("value", supportEnabled.properties.value != "True") + + onEntered: base.showTooltip(enableSupportCheckBox, Qt.point(-enableSupportCheckBox.x, 0), + catalog.i18nc("@label", "Generate structures to support parts of the model which have overhangs. Without these structures, such parts would collapse during printing.")) + + onExited: base.hideTooltip() + + } + } + + ComboBox + { + id: supportExtruderCombobox + visible: enableSupportCheckBox.visible && (supportEnabled.properties.value == "True") && (extrudersEnabledCount.properties.value > 1) + model: extruderModel + + property string color_override: "" // for manually setting values + property string color: // is evaluated automatically, but the first time is before extruderModel being filled + { + var current_extruder = extruderModel.get(currentIndex); + color_override = ""; + if (current_extruder === undefined) return "" + return (current_extruder.color) ? current_extruder.color : ""; + } + + textRole: "text" // this solves that the combobox isn't populated in the first time Cura is started + + anchors.top: enableSupportCheckBox.top + + anchors.left: enableSupportCheckBox.right + anchors.leftMargin: Math.round(UM.Theme.getSize("thick_margin").width / 2) + + width: Math.round(UM.Theme.getSize("print_setup_widget").width * .55) - Math.round(UM.Theme.getSize("thick_margin").width / 2) - enableSupportCheckBox.width + height: ((supportEnabled.properties.value == "True") && (machineExtruderCount.properties.value > 1)) ? UM.Theme.getSize("setting_control").height : 0 + + Behavior on height { NumberAnimation { duration: 100 } } + + style: UM.Theme.styles.combobox_color + enabled: base.settingsEnabled + property alias _hovered: supportExtruderMouseArea.containsMouse + + currentIndex: + { + if (supportExtruderNr.properties == null) + { + return Cura.MachineManager.defaultExtruderPosition + } + else + { + var extruder = parseInt(supportExtruderNr.properties.value) + if ( extruder === -1) + { + return Cura.MachineManager.defaultExtruderPosition + } + return extruder; + } + } + + onActivated: supportExtruderNr.setPropertyValue("value", String(index)) + + MouseArea + { + id: supportExtruderMouseArea + anchors.fill: parent + hoverEnabled: true + enabled: base.settingsEnabled + acceptedButtons: Qt.NoButton + onEntered: + { + base.showTooltip(supportExtruderCombobox, Qt.point(-supportExtruderCombobox.x, 0), + catalog.i18nc("@label", "Select which extruder to use for support. This will build up supporting structures below the model to prevent the model from sagging or printing in mid air.")); + } + onExited: base.hideTooltip() + + } + + function updateCurrentColor() + { + var current_extruder = extruderModel.get(currentIndex) + if (current_extruder !== undefined) + { + supportExtruderCombobox.color_override = current_extruder.color + } + } + + } + + Cura.IconWithText + { + id: adhesionHelperLabel + visible: adhesionCheckBox.visible + source: UM.Theme.getIcon("category_adhesion") + text: catalog.i18nc("@label", "Adhesion") + + anchors + { + left: parent.left + right: infillCellLeft.right + rightMargin: UM.Theme.getSize("thick_margin").width + verticalCenter: adhesionCheckBox.verticalCenter + } + } + + CheckBox + { + id: adhesionCheckBox + property alias _hovered: adhesionMouseArea.containsMouse + + anchors.top: enableSupportCheckBox.bottom + anchors.topMargin: UM.Theme.getSize("thick_margin").height + anchors.left: infillCellRight.left + + //: Setting enable printing build-plate adhesion helper checkbox + style: UM.Theme.styles.checkbox + enabled: base.settingsEnabled + + visible: platformAdhesionType.properties.enabled == "True" + checked: platformAdhesionType.properties.value != "skirt" && platformAdhesionType.properties.value != "none" + + MouseArea + { + id: adhesionMouseArea + anchors.fill: parent + hoverEnabled: true + enabled: base.settingsEnabled + onClicked: + { + var adhesionType = "skirt" + if(!parent.checked) + { + // Remove the "user" setting to see if the rest of the stack prescribes a brim or a raft + platformAdhesionType.removeFromContainer(0) + adhesionType = platformAdhesionType.properties.value + if(adhesionType == "skirt" || adhesionType == "none") + { + // If the rest of the stack doesn't prescribe an adhesion-type, default to a brim + adhesionType = "brim" + } + } + platformAdhesionType.setPropertyValue("value", adhesionType) + } + onEntered: + { + base.showTooltip(adhesionCheckBox, Qt.point(-adhesionCheckBox.x, 0), + catalog.i18nc("@label", "Enable printing a brim or raft. This will add a flat area around or under your object which is easy to cut off afterwards.")); + } + onExited: base.hideTooltip() + + } + } + + ListModel + { + id: extruderModel + Component.onCompleted: populateExtruderModel() + } + + //: Model used to populate the extrudelModel + Cura.ExtrudersModel + { + id: extruders + onModelChanged: populateExtruderModel() + } + + Item + { + id: tipsCell + anchors.top: adhesionCheckBox.visible ? adhesionCheckBox.bottom : (enableSupportCheckBox.visible ? supportExtruderCombobox.bottom : infillCellRight.bottom) + anchors.topMargin: Math.round(UM.Theme.getSize("thick_margin").height * 2) + anchors.left: parent.left + width: parent.width + height: tipsText.contentHeight * tipsText.lineCount + + Label + { + id: tipsText + anchors.left: parent.left + anchors.right: parent.right + anchors.rightMargin: UM.Theme.getSize("thick_margin").width + anchors.top: parent.top + wrapMode: Text.WordWrap + text: catalog.i18nc("@label", "Need help improving your prints?
Read the Ultimaker Troubleshooting Guides").arg("https://ultimaker.com/en/troubleshooting") + font: UM.Theme.getFont("default"); + color: UM.Theme.getColor("text"); + linkColor: UM.Theme.getColor("text_link") + onLinkActivated: Qt.openUrlExternally(link) + } + } + + UM.SettingPropertyProvider + { + id: infillExtruderNumber + containerStackId: Cura.MachineManager.activeStackId + key: "infill_extruder_nr" + watchedProperties: [ "value" ] + storeIndex: 0 + } + + UM.SettingPropertyProvider + { + id: infillDensity + containerStackId: Cura.MachineManager.activeStackId + key: "infill_sparse_density" + watchedProperties: [ "value" ] + storeIndex: 0 + } + + UM.SettingPropertyProvider + { + id: infillSteps + containerStackId: Cura.MachineManager.activeStackId + key: "gradual_infill_steps" + watchedProperties: ["value", "enabled"] + storeIndex: 0 + } + + UM.SettingPropertyProvider + { + id: platformAdhesionType + containerStack: Cura.MachineManager.activeMachine + removeUnusedValue: false //Doesn't work with settings that are resolved. + key: "adhesion_type" + watchedProperties: [ "value", "enabled" ] + storeIndex: 0 + } + + UM.SettingPropertyProvider + { + id: supportEnabled + containerStack: Cura.MachineManager.activeMachine + key: "support_enable" + watchedProperties: [ "value", "enabled", "description" ] + storeIndex: 0 + } + + UM.SettingPropertyProvider + { + id: extrudersEnabledCount + containerStack: Cura.MachineManager.activeMachine + key: "extruders_enabled_count" + watchedProperties: [ "value" ] + storeIndex: 0 + } + + UM.SettingPropertyProvider + { + id: supportExtruderNr + containerStack: Cura.MachineManager.activeMachine + key: "support_extruder_nr" + watchedProperties: [ "value" ] + storeIndex: 0 } function populateExtruderModel() diff --git a/resources/qml/qmldir b/resources/qml/qmldir index 2475f398f8..6db8e0c544 100644 --- a/resources/qml/qmldir +++ b/resources/qml/qmldir @@ -9,6 +9,7 @@ MaterialMenu 1.0 MaterialMenu.qml NozzleMenu 1.0 NozzleMenu.qml ActionPanelWidget 1.0 ActionPanelWidget.qml IconLabel 1.0 IconLabel.qml +IconWithText 1.0 IconWithText.qml OutputDevicesActionButton 1.0 OutputDevicesActionButton.qml ExpandableComponent 1.0 ExpandableComponent.qml PrinterTypeLabel 1.0 PrinterTypeLabel.qml diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index 08ea73a7c5..dfaa9008f7 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -372,6 +372,7 @@ "print_setup_mode_toggle": [0.0, 2.0], "print_setup_item": [0.0, 2.0], "print_setup_extruder_box": [0.0, 6.0], + "print_setup_widget_header": [0.0, 3.0], "configuration_selector_mode_tabs": [0.0, 3.0], From b9d9a3586809b7e517550d402d31a9cf419e59ba Mon Sep 17 00:00:00 2001 From: Aleksei S Date: Thu, 29 Nov 2018 00:00:22 +0100 Subject: [PATCH 15/70] Move profile dropdown to another file CURA-5941 --- resources/qml/GlobalProfileButton.qml | 89 ++++++++++++++++++++++++++ resources/qml/PrintSetupSelector.qml | 46 +++++++------ resources/qml/Settings/SettingView.qml | 89 +------------------------- 3 files changed, 115 insertions(+), 109 deletions(-) create mode 100644 resources/qml/GlobalProfileButton.qml diff --git a/resources/qml/GlobalProfileButton.qml b/resources/qml/GlobalProfileButton.qml new file mode 100644 index 0000000000..bac2732037 --- /dev/null +++ b/resources/qml/GlobalProfileButton.qml @@ -0,0 +1,89 @@ +// Copyright (c) 2018 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.7 +import QtQuick.Controls 1.1 +import QtQuick.Controls.Styles 1.1 +import QtQuick.Layouts 1.2 + +import UM 1.2 as UM +import Cura 1.0 as Cura + +import "Menus" + +Item +{ + id: globalProfileRow + height: UM.Theme.getSize("print_setup_item").height + + Label + { + id: globalProfileLabel + text: catalog.i18nc("@label","Profile:") + textFormat: Text.PlainText + width: Math.round(parent.width * 0.45 - UM.Theme.getSize("thick_margin").width - 2) + font: UM.Theme.getFont("default") + color: UM.Theme.getColor("text") + verticalAlignment: Text.AlignVCenter + anchors.top: parent.top + anchors.bottom: parent.bottom + } + + ToolButton + { + id: globalProfileSelection + + text: generateActiveQualityText() + width: Math.round(parent.width * 0.55) + height: UM.Theme.getSize("setting_control").height + anchors.left: globalProfileLabel.right + anchors.right: parent.right + tooltip: Cura.MachineManager.activeQualityOrQualityChangesName + style: UM.Theme.styles.sidebar_header_button + activeFocusOnPress: true + menu: ProfileMenu { } + + function generateActiveQualityText () { + var result = Cura.MachineManager.activeQualityOrQualityChangesName; + + if (Cura.MachineManager.isActiveQualitySupported) { + if (Cura.MachineManager.activeQualityLayerHeight > 0) { + result += " " + result += " - " + result += Cura.MachineManager.activeQualityLayerHeight + "mm" + result += "" + } + } + + return result + } + + UM.SimpleButton + { + id: customisedSettings + + visible: Cura.MachineManager.hasUserSettings + height: Math.round(parent.height * 0.6) + width: Math.round(parent.height * 0.6) + + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + anchors.rightMargin: Math.round(UM.Theme.getSize("setting_preferences_button_margin").width - UM.Theme.getSize("thick_margin").width) + + color: hovered ? UM.Theme.getColor("setting_control_button_hover") : UM.Theme.getColor("setting_control_button"); + iconSource: UM.Theme.getIcon("star"); + + onClicked: + { + forceActiveFocus(); + Cura.Actions.manageProfiles.trigger() + } + onEntered: + { + var content = catalog.i18nc("@tooltip","Some setting/override values are different from the values stored in the profile.\n\nClick to open the profile manager.") + base.showTooltip(globalProfileRow, Qt.point(-UM.Theme.getSize("thick_margin").width, 0), content) + } + onExited: base.hideTooltip() + } + } +} \ No newline at end of file diff --git a/resources/qml/PrintSetupSelector.qml b/resources/qml/PrintSetupSelector.qml index 85472bae8d..855af9f9fa 100644 --- a/resources/qml/PrintSetupSelector.qml +++ b/resources/qml/PrintSetupSelector.qml @@ -126,7 +126,9 @@ Cura.ExpandableComponent popupItem: Rectangle { - property var total_height: popupItemHeader.height + popupItemContent.height + footerControll.height + UM.Theme.getSize("narrow_margin").height * 2 + + property var totalMargins: UM.Theme.getSize("narrow_margin").height * 11 + property var total_height: popupItemHeader.height + popupItemContent.height + totalMargins id: popupItemWrapper height: total_height @@ -157,9 +159,9 @@ Cura.ExpandableComponent anchors { - topMargin: UM.Theme.getSize("sidebar_margin").height + //topMargin: UM.Theme.getSize("sidebar_margin").height left: parent.left - leftMargin: UM.Theme.getSize("narrow_margin").height + leftMargin: UM.Theme.getSize("narrow_margin").height * 2 } } @@ -169,8 +171,6 @@ Cura.ExpandableComponent height: UM.Theme.getSize("default_lining").height anchors.top: popupItemHeaderText.bottom color: UM.Theme.getColor("action_button_border") - - } Button @@ -209,21 +209,33 @@ Cura.ExpandableComponent { id: popupItemContent width: parent.width - height: tabBar.height + sidebarContents.height + height: globalProfileRow.height + tabBar.height + UM.Theme.getSize("print_setup_widget").height - UM.Theme.getSize("print_setup_item").height anchors { top: popupItemHeader.bottom - topMargin: UM.Theme.getSize("narrow_margin").height + topMargin: UM.Theme.getSize("default_margin").height * 1.5 right: parent.right left: parent.left leftMargin: UM.Theme.getSize("default_margin").width rightMargin: UM.Theme.getSize("default_margin").width } + GlobalProfileButton + { + id: globalProfileRow + anchors + { + top: parent.top + left: parent.left + right: parent.right + } + } + UM.TabRow { id: tabBar - anchors.topMargin: UM.Theme.getSize("default_margin").height + anchors.top: globalProfileRow.bottom + anchors.topMargin: UM.Theme.getSize("default_margin").height * 1.5 onCurrentIndexChanged: Cura.ExtruderManager.setActiveExtruderIndex(currentIndex) z: 1 Repeater @@ -280,8 +292,6 @@ Cura.ExpandableComponent anchors.bottom: parent.bottom anchors.left: parent.left anchors.right: parent.right - height: UM.Theme.getSize("print_setup_widget").height - border.width: UM.Theme.getSize("default_lining").width * 2 border.color: UM.Theme.getColor("action_button_border") @@ -296,8 +306,8 @@ Cura.ExpandableComponent SidebarAdvanced { - anchors.topMargin: UM.Theme.getSize("print_setup_content_top_margin").height - anchors.bottomMargin: 2 //don't overlap bottom border + anchors.topMargin: Math.round(UM.Theme.getSize("wide_margin").height / 1.7) + anchors.bottomMargin: 2 //prevent bottom line overlapping anchors.fill: parent visible: currentModeIndex == 1 onShowTooltip: base.showTooltip(item, location, text) @@ -312,7 +322,6 @@ Cura.ExpandableComponent anchors.top: popupItemContent.bottom anchors.topMargin: UM.Theme.getSize("narrow_margin").height * 2 width: parent.width - height: settingControlButton.height + UM.Theme.getSize("default_lining").height * 4 Rectangle { width: parent.width @@ -330,9 +339,8 @@ Cura.ExpandableComponent { top: parent.top topMargin: UM.Theme.getSize("narrow_margin").height * 2 - bottomMargin: UM.Theme.getSize("narrow_margin").height * 2 right: parent.right - rightMargin: UM.Theme.getSize("narrow_margin").height + rightMargin: UM.Theme.getSize("narrow_margin").height * 2 } color: UM.Theme.getColor("secondary") @@ -349,14 +357,11 @@ Cura.ExpandableComponent { height: UM.Theme.getSize("action_panel_button").height text: catalog.i18nc("@button", "Recommended") - color: UM.Theme.getColor("secondary") hoverColor: UM.Theme.getColor("secondary") textColor: UM.Theme.getColor("primary") textHoverColor: UM.Theme.getColor("text") - iconSource: UM.Theme.getIcon("arrow_left") - width: UM.Theme.getSize("print_setup_action_button").width fixedWidthMode: true @@ -365,9 +370,8 @@ Cura.ExpandableComponent { top: parent.top topMargin: UM.Theme.getSize("narrow_margin").height * 2 - bottomMargin: UM.Theme.getSize("narrow_margin").height * 2 left: parent.left - leftMargin: UM.Theme.getSize("narrow_margin").height + leftMargin: UM.Theme.getSize("narrow_margin").height * 2 } MouseArea { @@ -376,7 +380,7 @@ Cura.ExpandableComponent } } } - + Component.onCompleted: { var index = Math.round(UM.Preferences.getValue("cura/active_mode")) diff --git a/resources/qml/Settings/SettingView.qml b/resources/qml/Settings/SettingView.qml index cd9701aab6..3960f99aaa 100644 --- a/resources/qml/Settings/SettingView.qml +++ b/resources/qml/Settings/SettingView.qml @@ -21,92 +21,6 @@ Item signal showTooltip(Item item, point location, string text) signal hideTooltip() - Item - { - id: globalProfileRow - height: UM.Theme.getSize("print_setup_item").height - - anchors - { - top: parent.top - left: parent.left - leftMargin: Math.round(UM.Theme.getSize("thick_margin").width) - right: parent.right - rightMargin: Math.round(UM.Theme.getSize("thick_margin").width) - } - - Label - { - id: globalProfileLabel - text: catalog.i18nc("@label","Profile:") - textFormat: Text.PlainText - width: Math.round(parent.width * 0.45 - UM.Theme.getSize("thick_margin").width - 2) - font: UM.Theme.getFont("default") - color: UM.Theme.getColor("text") - verticalAlignment: Text.AlignVCenter - anchors.top: parent.top - anchors.bottom: parent.bottom - } - - ToolButton - { - id: globalProfileSelection - - text: generateActiveQualityText() - width: Math.round(parent.width * 0.55) - height: UM.Theme.getSize("setting_control").height - anchors.left: globalProfileLabel.right - anchors.right: parent.right - tooltip: Cura.MachineManager.activeQualityOrQualityChangesName - style: UM.Theme.styles.sidebar_header_button - activeFocusOnPress: true - menu: ProfileMenu { } - - function generateActiveQualityText () { - var result = Cura.MachineManager.activeQualityOrQualityChangesName; - - if (Cura.MachineManager.isActiveQualitySupported) { - if (Cura.MachineManager.activeQualityLayerHeight > 0) { - result += " " - result += " - " - result += Cura.MachineManager.activeQualityLayerHeight + "mm" - result += "" - } - } - - return result - } - - UM.SimpleButton - { - id: customisedSettings - - visible: Cura.MachineManager.hasUserSettings - height: Math.round(parent.height * 0.6) - width: Math.round(parent.height * 0.6) - - anchors.verticalCenter: parent.verticalCenter - anchors.right: parent.right - anchors.rightMargin: Math.round(UM.Theme.getSize("setting_preferences_button_margin").width - UM.Theme.getSize("thick_margin").width) - - color: hovered ? UM.Theme.getColor("setting_control_button_hover") : UM.Theme.getColor("setting_control_button"); - iconSource: UM.Theme.getIcon("star"); - - onClicked: - { - forceActiveFocus(); - Cura.Actions.manageProfiles.trigger() - } - onEntered: - { - var content = catalog.i18nc("@tooltip","Some setting/override values are different from the values stored in the profile.\n\nClick to open the profile manager.") - base.showTooltip(globalProfileRow, Qt.point(-UM.Theme.getSize("thick_margin").width, 0), content) - } - onExited: base.hideTooltip() - } - } - } - ToolButton { id: settingVisibilityMenu @@ -115,7 +29,6 @@ Item height: UM.Theme.getSize("setting_control").height anchors { - top: globalProfileRow.bottom topMargin: UM.Theme.getSize("thick_margin").height right: parent.right rightMargin: UM.Theme.getSize("thick_margin").width @@ -168,7 +81,7 @@ Item anchors { - top: globalProfileRow.bottom + //top: globalProfileRow.bottom topMargin: UM.Theme.getSize("thick_margin").height left: parent.left leftMargin: UM.Theme.getSize("thick_margin").width From 706fc311bccb730e82e48bf6c752e4bd0a3bf856 Mon Sep 17 00:00:00 2001 From: Aleksei S Date: Thu, 29 Nov 2018 00:47:25 +0100 Subject: [PATCH 16/70] Added margins to the setting list CURA-5941 --- resources/qml/Settings/SettingCategory.qml | 4 ++-- resources/qml/Settings/SettingItem.qml | 4 ++-- resources/qml/Settings/SettingView.qml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/resources/qml/Settings/SettingCategory.qml b/resources/qml/Settings/SettingCategory.qml index aafe36c546..4ec6294d61 100644 --- a/resources/qml/Settings/SettingCategory.qml +++ b/resources/qml/Settings/SettingCategory.qml @@ -12,8 +12,8 @@ Button id: base anchors.left: parent.left anchors.right: parent.right - anchors.leftMargin: UM.Theme.getSize("thick_margin").width - anchors.rightMargin: UM.Theme.getSize("thick_margin").width + anchors.leftMargin: UM.Theme.getSize("default_margin").width + anchors.rightMargin: UM.Theme.getSize("default_margin").width * 3 hoverEnabled: true background: Rectangle diff --git a/resources/qml/Settings/SettingItem.qml b/resources/qml/Settings/SettingItem.qml index cad6a28bd6..036dcfeba4 100644 --- a/resources/qml/Settings/SettingItem.qml +++ b/resources/qml/Settings/SettingItem.qml @@ -108,7 +108,7 @@ Item { id: label; anchors.left: parent.left; - anchors.leftMargin: doDepthIndentation ? Math.round((UM.Theme.getSize("section_icon_column").width + 5) + ((definition.depth - 1) * UM.Theme.getSize("setting_control_depth_margin").width)) : 0 + anchors.leftMargin: doDepthIndentation ? Math.round((UM.Theme.getSize("section_icon_column").width / 1.2) + ((definition.depth - 1) * UM.Theme.getSize("setting_control_depth_margin").width)) : 0 anchors.right: settingControls.left; anchors.verticalCenter: parent.verticalCenter @@ -290,7 +290,7 @@ Item { enabled: propertyProvider.isValueUsed anchors.right: parent.right; - anchors.rightMargin: UM.Theme.getSize("thick_margin").width + anchors.rightMargin: UM.Theme.getSize("default_margin").width * 3 anchors.verticalCenter: parent.verticalCenter; width: UM.Theme.getSize("setting_control").width; height: UM.Theme.getSize("setting_control").height diff --git a/resources/qml/Settings/SettingView.qml b/resources/qml/Settings/SettingView.qml index 3960f99aaa..8a336a7ed1 100644 --- a/resources/qml/Settings/SettingView.qml +++ b/resources/qml/Settings/SettingView.qml @@ -81,10 +81,9 @@ Item anchors { - //top: globalProfileRow.bottom topMargin: UM.Theme.getSize("thick_margin").height left: parent.left - leftMargin: UM.Theme.getSize("thick_margin").width + leftMargin: UM.Theme.getSize("default_margin").width right: settingVisibilityMenu.left rightMargin: Math.floor(UM.Theme.getSize("default_margin").width / 2) } @@ -202,6 +201,7 @@ Item anchors.right: parent.right; anchors.left: parent.left; anchors.topMargin: UM.Theme.getSize("thick_margin").height + anchors.rightMargin: UM.Theme.getSize("narrow_margin").height / 3 style: UM.Theme.styles.scrollview; flickableItem.flickableDirection: Flickable.VerticalFlick; From 7639983925f712a48a3a64bd71d221d2dcf3b4f2 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Thu, 29 Nov 2018 08:54:04 +0100 Subject: [PATCH 17/70] Clean the recommended mode print setup Contributes to CURA-5941 --- .../PrintSetupSelectorContents.qml | 31 - .../RecommendedPrintSetup.qml | 1205 ++++++++--------- 2 files changed, 580 insertions(+), 656 deletions(-) diff --git a/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml b/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml index c36a0fbb80..6e71526f25 100644 --- a/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml +++ b/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml @@ -94,40 +94,10 @@ Item anchors { top: header.bottom - leftMargin: UM.Theme.getSize("default_margin").width - rightMargin: UM.Theme.getSize("default_margin").width } sourceComponent: currentModeIndex == 0 ? recommendedPrintSetup : customPrintSetup } -// Item -// { -// id: content -// width: parent.width -// height: 100 -////// height: tabBar.height + sidebarContents.height -//// -// anchors -// { -// top: header.bottom -// leftMargin: UM.Theme.getSize("default_margin").width -// rightMargin: UM.Theme.getSize("default_margin").width -// } -//// -//// Rectangle -//// { -//// id: sidebarContents -//// anchors.top: tabBar.bottom -//// anchors.bottom: parent.bottom -//// anchors.left: parent.left -//// anchors.right: parent.right -//// height: UM.Theme.getSize("print_setup_widget").height -//// -//// border.width: UM.Theme.getSize("default_lining").width * 2 -//// border.color: UM.Theme.getColor("action_button_border") -//// } -// } - Rectangle { id: buttonsSeparator @@ -195,7 +165,6 @@ Item Component.onCompleted: { - print(height, "!!!!!!!!!!!!!!!!!!!!!!!") var index = Math.round(UM.Preferences.getValue("cura/active_mode")) if(index != null && !isNaN(index)) diff --git a/resources/qml/PrintSetupSelector/RecommendedPrintSetup.qml b/resources/qml/PrintSetupSelector/RecommendedPrintSetup.qml index 5d195bdde4..b48282135b 100644 --- a/resources/qml/PrintSetupSelector/RecommendedPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/RecommendedPrintSetup.qml @@ -8,17 +8,22 @@ import QtQuick.Controls.Styles 1.4 import UM 1.2 as UM import Cura 1.0 as Cura -Item +Column { id: base signal showTooltip(Item item, point location, string text) signal hideTooltip() - height: childrenRect.height + height: childrenRect.height + 2 * padding + + padding: UM.Theme.getSize("thick_margin").width + spacing: UM.Theme.getSize("default_margin").height property Action configureSettings property bool settingsEnabled: Cura.ExtruderManager.activeExtruderStackId || extrudersEnabledCount.properties.value == 1 + property real labelColumnWidth: Math.round(width / 3) + property real settingsColumnWidth: width - labelColumnWidth UM.I18nCatalog { @@ -33,10 +38,9 @@ Item { id: qualityRow - height: UM.Theme.getSize("thick_margin").height - anchors.topMargin: UM.Theme.getSize("thick_margin").height anchors.left: parent.left anchors.right: parent.right + height: childrenRect.height Timer { @@ -145,14 +149,14 @@ Item function calculateSliderStepWidth (totalTicks) { - qualityModel.qualitySliderStepWidth = totalTicks != 0 ? Math.round((base.width * 0.55) / (totalTicks)) : 0 + qualityModel.qualitySliderStepWidth = totalTicks != 0 ? Math.round((settingsColumnWidth) / (totalTicks)) : 0 } function calculateSliderMargins (availableMin, availableMax, totalTicks) { if (availableMin == -1 || (availableMin == 0 && availableMax == 0)) { - qualityModel.qualitySliderMarginRight = Math.round(base.width * 0.55) + qualityModel.qualitySliderMarginRight = Math.round(settingsColumnWidth) } else if (availableMin == availableMax) { @@ -180,6 +184,7 @@ Item source: UM.Theme.getIcon("category_layer_height") text: catalog.i18nc("@label", "Layer Height") anchors.bottom: speedSlider.bottom + width: labelColumnWidth } // Show titles for the each quality slider ticks @@ -187,6 +192,7 @@ Item { anchors.left: speedSlider.left anchors.top: speedSlider.bottom + Repeater { model: qualityModel @@ -194,7 +200,7 @@ Item Label { anchors.verticalCenter: parent.verticalCenter - anchors.top: parent.bottom + anchors.top: parent.top color: (Cura.MachineManager.activeMachine != null && Cura.QualityProfilesDropDownMenuModel.getItem(index).available) ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") text: { @@ -225,19 +231,19 @@ Item if (qualityModel.totalTicks == 0) { // If there is only one tick, align it centrally - return Math.round(((base.width * 0.55) - width) / 2) + return Math.round(((settingsColumnWidth) - width) / 2) } else if (index == 0) { - return Math.round(base.width * 0.55 / qualityModel.totalTicks) * index + return Math.round(settingsColumnWidth / qualityModel.totalTicks) * index } else if (index == qualityModel.totalTicks) { - return Math.round(base.width * 0.55 / qualityModel.totalTicks) * index - width + return Math.round(settingsColumnWidth / qualityModel.totalTicks) * index - width } else { - return Math.round((base.width * 0.55 / qualityModel.totalTicks) * index - (width / 2)) + return Math.round((settingsColumnWidth / qualityModel.totalTicks) * index - (width / 2)) } } } @@ -248,126 +254,127 @@ Item Rectangle { id: speedSlider - width: Math.round(base.width * 0.55) - height: UM.Theme.getSize("thick_margin").height - anchors.right: parent.right - anchors.top: parent.top - anchors.topMargin: UM.Theme.getSize("thick_margin").height + + anchors + { + left: qualityRowTitle.right + right: parent.right + } // This Item is used only for tooltip, for slider area which is unavailable - Item - { - function showTooltip (showTooltip) - { - if (showTooltip) - { - var content = catalog.i18nc("@tooltip", "This quality profile is not available for you current material and nozzle configuration. Please change these to enable this quality profile") - base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), content) - } - else - { - base.hideTooltip() - } - } - - id: unavailableLineToolTip - height: 20 * screenScaleFactor // hovered area height - z: parent.z + 1 // should be higher, otherwise the area can be hovered - x: 0 - anchors.verticalCenter: qualitySlider.verticalCenter - - Rectangle - { - id: leftArea - width: - { - if (qualityModel.availableTotalTicks == 0) - { - return qualityModel.qualitySliderStepWidth * qualityModel.totalTicks - } - return qualityModel.qualitySliderStepWidth * qualityModel.qualitySliderAvailableMin - 10 - } - height: parent.height - color: "transparent" - - MouseArea - { - anchors.fill: parent - hoverEnabled: true - enabled: Cura.SimpleModeSettingsManager.isProfileUserCreated == false - onEntered: unavailableLineToolTip.showTooltip(true) - onExited: unavailableLineToolTip.showTooltip(false) - } - } - - Item - { - id: rightArea - width: - { - if(qualityModel.availableTotalTicks == 0) - return 0 - - return qualityModel.qualitySliderMarginRight - 10 - } - height: parent.height - x: - { - if (qualityModel.availableTotalTicks == 0) - { - return 0 - } - - var leftUnavailableArea = qualityModel.qualitySliderStepWidth * qualityModel.qualitySliderAvailableMin - var totalGap = qualityModel.qualitySliderStepWidth * (qualityModel.availableTotalTicks -1) + leftUnavailableArea + 10 - - return totalGap - } - - MouseArea - { - anchors.fill: parent - hoverEnabled: true - enabled: Cura.SimpleModeSettingsManager.isProfileUserCreated == false - onEntered: unavailableLineToolTip.showTooltip(true) - onExited: unavailableLineToolTip.showTooltip(false) - } - } - } +// Item +// { +// function showTooltip (showTooltip) +// { +// if (showTooltip) +// { +// var content = catalog.i18nc("@tooltip", "This quality profile is not available for you current material and nozzle configuration. Please change these to enable this quality profile") +// base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), content) +// } +// else +// { +// base.hideTooltip() +// } +// } +// +// id: unavailableLineToolTip +// height: 20 * screenScaleFactor // hovered area height +// z: parent.z + 1 // should be higher, otherwise the area can be hovered +// x: 0 +// anchors.verticalCenter: qualitySlider.verticalCenter +// +// Rectangle +// { +// id: leftArea +// width: +// { +// if (qualityModel.availableTotalTicks == 0) +// { +// return qualityModel.qualitySliderStepWidth * qualityModel.totalTicks +// } +// return qualityModel.qualitySliderStepWidth * qualityModel.qualitySliderAvailableMin - 10 +// } +// height: parent.height +// color: "transparent" +// +// MouseArea +// { +// anchors.fill: parent +// hoverEnabled: true +// enabled: Cura.SimpleModeSettingsManager.isProfileUserCreated == false +// onEntered: unavailableLineToolTip.showTooltip(true) +// onExited: unavailableLineToolTip.showTooltip(false) +// } +// } +// +// Item +// { +// id: rightArea +// width: +// { +// if(qualityModel.availableTotalTicks == 0) +// return 0 +// +// return qualityModel.qualitySliderMarginRight - 10 +// } +// height: parent.height +// x: +// { +// if (qualityModel.availableTotalTicks == 0) +// { +// return 0 +// } +// +// var leftUnavailableArea = qualityModel.qualitySliderStepWidth * qualityModel.qualitySliderAvailableMin +// var totalGap = qualityModel.qualitySliderStepWidth * (qualityModel.availableTotalTicks -1) + leftUnavailableArea + 10 +// +// return totalGap +// } +// +// MouseArea +// { +// anchors.fill: parent +// hoverEnabled: true +// enabled: Cura.SimpleModeSettingsManager.isProfileUserCreated == false +// onEntered: unavailableLineToolTip.showTooltip(true) +// onExited: unavailableLineToolTip.showTooltip(false) +// } +// } +// } // Draw Unavailable line Rectangle { id: groovechildrect - width: Math.round(base.width * 0.55) + width: parent.width height: 2 * screenScaleFactor color: UM.Theme.getColor("quality_slider_unavailable") anchors.verticalCenter: qualitySlider.verticalCenter - x: 0 - } - // Draw ticks - Repeater - { - id: qualityRepeater - model: qualityModel.totalTicks > 0 ? qualityModel : 0 - - Rectangle + // Draw ticks + Repeater { - color: Cura.QualityProfilesDropDownMenuModel.getItem(index).available ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") - implicitWidth: 5 * screenScaleFactor - implicitHeight: implicitWidth - anchors.verticalCenter: qualitySlider.verticalCenter - x: Math.round(qualityModel.qualitySliderStepWidth * index) - radius: Math.round(implicitWidth / 2) + id: qualityRepeater + model: qualityModel.totalTicks > 0 ? qualityModel : 0 + + Rectangle + { + color: Cura.QualityProfilesDropDownMenuModel.getItem(index).available ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") + implicitWidth: 4 * screenScaleFactor + implicitHeight: implicitWidth + anchors.verticalCenter: parent.verticalCenter + x: Math.round(qualityModel.qualitySliderStepWidth * index) + radius: Math.round(implicitWidth / 2) + } } } + // Draw available slider Slider { id: qualitySlider height: UM.Theme.getSize("thick_margin").height - anchors.bottom: speedSlider.bottom + anchors.bottom: parent.bottom enabled: qualityModel.totalTicks > 0 && !Cura.SimpleModeSettingsManager.isProfileCustomized visible: qualityModel.availableTotalTicks > 0 updateValueWhileDragging : false @@ -394,18 +401,15 @@ Item color: UM.Theme.getColor("quality_slider_available") radius: Math.round(height / 2) } - handle: Item + + handle: Rectangle { - Rectangle - { - id: qualityhandleButton - anchors.centerIn: parent - color: UM.Theme.getColor("quality_slider_available") - implicitWidth: 10 * screenScaleFactor - implicitHeight: implicitWidth - radius: Math.round(implicitWidth / 2) - visible: !Cura.SimpleModeSettingsManager.isProfileCustomized && !Cura.SimpleModeSettingsManager.isProfileUserCreated && qualityModel.existingQualityProfile - } + id: qualityhandleButton + color: UM.Theme.getColor("quality_slider_available") + implicitWidth: 12 * screenScaleFactor + implicitHeight: implicitWidth + radius: Math.round(implicitWidth / 2) + visible: !Cura.SimpleModeSettingsManager.isProfileCustomized && !Cura.SimpleModeSettingsManager.isProfileUserCreated && qualityModel.existingQualityProfile } } @@ -433,7 +437,7 @@ Item onEntered: { - var content = catalog.i18nc("@tooltip","A custom profile is currently active. To enable the quality slider, choose a default quality profile in Custom tab") + var content = catalog.i18nc("@tooltip", "A custom profile is currently active. To enable the quality slider, choose a default quality profile in Custom tab") base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), content) } onExited: base.hideTooltip() @@ -474,329 +478,319 @@ Item // Item { - id: infillCellLeft - - anchors.top: qualityRow.bottom - anchors.topMargin: UM.Theme.getSize("thick_margin").height * 2 anchors.left: parent.left - - width: Math.round(UM.Theme.getSize("print_setup_widget").width * .45) - UM.Theme.getSize("thick_margin").width + anchors.right: parent.right + height: childrenRect.height Cura.IconWithText { - id: infillLabel + id: infillRowTitle source: UM.Theme.getIcon("category_infill") text: catalog.i18nc("@label", "Infill") + " (%)" - - anchors - { - top: parent.top - topMargin: Math.round(UM.Theme.getSize("thick_margin").height * 1.7) - left: parent.left - } + anchors.bottom: parent.bottom + width: labelColumnWidth } - } - Item - { - id: infillCellRight + Item + { + id: infillCellRight - height: infillSlider.height + UM.Theme.getSize("thick_margin").height + enableGradualInfillCheckBox.visible * (enableGradualInfillCheckBox.height + UM.Theme.getSize("thick_margin").height) - width: Math.round(UM.Theme.getSize("print_setup_widget").width * .55) + height: infillSlider.height + UM.Theme.getSize("thick_margin").height + enableGradualInfillCheckBox.visible * (enableGradualInfillCheckBox.height + UM.Theme.getSize("thick_margin").height) - anchors.left: infillCellLeft.right - anchors.top: infillCellLeft.top - anchors.topMargin: UM.Theme.getSize("thick_margin").height - - Label { - id: selectedInfillRateText - - anchors.left: infillSlider.left + anchors.left: infillRowTitle.right anchors.right: parent.right - text: parseInt(infillDensity.properties.value) + "%" - horizontalAlignment: Text.AlignLeft - - color: infillSlider.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") - } - - // We use a binding to make sure that after manually setting infillSlider.value it is still bound to the property provider - Binding - { - target: infillSlider - property: "value" - value: parseInt(infillDensity.properties.value) - } - - Slider - { - id: infillSlider - - anchors.top: selectedInfillRateText.bottom - anchors.left: parent.left - anchors.right: infillIcon.left - anchors.rightMargin: UM.Theme.getSize("thick_margin").width - - height: UM.Theme.getSize("thick_margin").height - width: parseInt(infillCellRight.width - UM.Theme.getSize("thick_margin").width - style.handleWidth) - - minimumValue: 0 - maximumValue: 100 - stepSize: 1 - tickmarksEnabled: true - - // disable slider when gradual support is enabled - enabled: parseInt(infillSteps.properties.value) == 0 - - // set initial value from stack - value: parseInt(infillDensity.properties.value) - - onValueChanged: - { - - // Don't round the value if it's already the same - if (parseInt(infillDensity.properties.value) == infillSlider.value) - { - return - } - - // Round the slider value to the nearest multiple of 10 (simulate step size of 10) - var roundedSliderValue = Math.round(infillSlider.value / 10) * 10 - - // Update the slider value to represent the rounded value - infillSlider.value = roundedSliderValue - - // Update value only if the Recomended mode is Active, - // Otherwise if I change the value in the Custom mode the Recomended view will try to repeat - // same operation - var active_mode = UM.Preferences.getValue("cura/active_mode") - - if (active_mode == 0 || active_mode == "simple") - { - Cura.MachineManager.setSettingForAllExtruders("infill_sparse_density", "value", roundedSliderValue) - Cura.MachineManager.resetSettingForAllExtruders("infill_line_distance") - } - } - - style: SliderStyle - { - groove: Rectangle - { - id: groove - implicitWidth: 200 * screenScaleFactor - implicitHeight: 2 * screenScaleFactor - color: control.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") - radius: 1 - } - - handle: Item - { - Rectangle - { - id: handleButton - anchors.centerIn: parent - color: control.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") - implicitWidth: 10 * screenScaleFactor - implicitHeight: 10 * screenScaleFactor - radius: 10 * screenScaleFactor - } - } - - tickmarks: Repeater - { - id: repeater - model: control.maximumValue / control.stepSize + 1 - - // check if a tick should be shown based on it's index and wether the infill density is a multiple of 10 (slider step size) - function shouldShowTick (index) - { - if (index % 10 == 0) - { - return true - } - return false - } - - Rectangle - { - anchors.verticalCenter: parent.verticalCenter - color: control.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") - width: 1 * screenScaleFactor - height: 6 * screenScaleFactor - x: Math.round(styleData.handleWidth / 2 + index * ((repeater.width - styleData.handleWidth) / (repeater.count-1))) - visible: shouldShowTick(index) - } - } - } - } - - Rectangle - { - id: infillIcon - - width: Math.round((parent.width / 5) - (UM.Theme.getSize("thick_margin").width)) - height: width - - anchors.right: parent.right - anchors.top: parent.top - anchors.topMargin: Math.round(UM.Theme.getSize("thick_margin").height / 2) - - // we loop over all density icons and only show the one that has the current density and steps - Repeater - { - id: infillIconList - model: infillModel - anchors.fill: parent - - function activeIndex () - { - for (var i = 0; i < infillModel.count; i++) - { - var density = Math.round(infillDensity.properties.value) - var steps = Math.round(infillSteps.properties.value) - var infillModelItem = infillModel.get(i) - - if (infillModelItem != "undefined" - && density >= infillModelItem.percentageMin - && density <= infillModelItem.percentageMax - && steps >= infillModelItem.stepsMin - && steps <= infillModelItem.stepsMax) - { - return i - } - } - return -1 - } - - Rectangle - { - anchors.fill: parent - visible: infillIconList.activeIndex() == index - - border.width: UM.Theme.getSize("default_lining").width - border.color: UM.Theme.getColor("quality_slider_unavailable") - - UM.RecolorImage - { - anchors.fill: parent - anchors.margins: 2 * screenScaleFactor - sourceSize.width: width - sourceSize.height: width - source: UM.Theme.getIcon(model.icon) - color: UM.Theme.getColor("quality_slider_unavailable") - } - } - } - } - - // Gradual Support Infill Checkbox - CheckBox - { - id: enableGradualInfillCheckBox - property alias _hovered: enableGradualInfillMouseArea.containsMouse - - anchors.top: infillSlider.bottom - anchors.topMargin: Math.round(UM.Theme.getSize("thick_margin").height / 2) // closer to slider since it belongs to the same category - anchors.left: infillCellRight.left - - style: UM.Theme.styles.checkbox - enabled: base.settingsEnabled - visible: infillSteps.properties.enabled == "True" - checked: parseInt(infillSteps.properties.value) > 0 - - MouseArea - { - id: enableGradualInfillMouseArea - - anchors.fill: parent - hoverEnabled: true - enabled: true - - property var previousInfillDensity: parseInt(infillDensity.properties.value) - - onClicked: - { - // Set to 90% only when enabling gradual infill - var newInfillDensity; - if (parseInt(infillSteps.properties.value) == 0) - { - previousInfillDensity = parseInt(infillDensity.properties.value) - newInfillDensity = 90 - } else { - newInfillDensity = previousInfillDensity - } - Cura.MachineManager.setSettingForAllExtruders("infill_sparse_density", "value", String(newInfillDensity)) - - var infill_steps_value = 0 - if (parseInt(infillSteps.properties.value) == 0) - { - infill_steps_value = 5 - } - - Cura.MachineManager.setSettingForAllExtruders("gradual_infill_steps", "value", infill_steps_value) - } - - onEntered: base.showTooltip(enableGradualInfillCheckBox, Qt.point(-infillCellRight.x, 0), - catalog.i18nc("@label", "Gradual infill will gradually increase the amount of infill towards the top.")) - - onExited: base.hideTooltip() - - } - Label { - id: gradualInfillLabel - height: parent.height - anchors.left: enableGradualInfillCheckBox.right - anchors.leftMargin: Math.round(UM.Theme.getSize("thick_margin").width / 2) - verticalAlignment: Text.AlignVCenter; - text: catalog.i18nc("@label", "Enable gradual") - font: UM.Theme.getFont("default") - color: UM.Theme.getColor("text") - } - } + id: selectedInfillRateText - // Infill list model for mapping icon - ListModel - { - id: infillModel - Component.onCompleted: + anchors.left: infillSlider.left + anchors.right: parent.right + + text: parseInt(infillDensity.properties.value) + "%" + horizontalAlignment: Text.AlignLeft + + color: infillSlider.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") + } + + // We use a binding to make sure that after manually setting infillSlider.value it is still bound to the property provider + Binding { - infillModel.append({ - percentageMin: -1, - percentageMax: 0, - stepsMin: -1, - stepsMax: 0, - icon: "hollow" - }) - infillModel.append({ - percentageMin: 0, - percentageMax: 40, - stepsMin: -1, - stepsMax: 0, - icon: "sparse" - }) - infillModel.append({ - percentageMin: 40, - percentageMax: 89, - stepsMin: -1, - stepsMax: 0, - icon: "dense" - }) - infillModel.append({ - percentageMin: 90, - percentageMax: 9999999999, - stepsMin: -1, - stepsMax: 0, - icon: "solid" - }) - infillModel.append({ - percentageMin: 0, - percentageMax: 9999999999, - stepsMin: 1, - stepsMax: 9999999999, - icon: "gradual" - }) + target: infillSlider + property: "value" + value: parseInt(infillDensity.properties.value) + } + + Slider + { + id: infillSlider + + anchors.top: selectedInfillRateText.bottom + anchors.left: parent.left + anchors.right: infillIcon.left + anchors.rightMargin: UM.Theme.getSize("thick_margin").width + + height: UM.Theme.getSize("thick_margin").height + width: parseInt(infillCellRight.width - UM.Theme.getSize("thick_margin").width - style.handleWidth) + + minimumValue: 0 + maximumValue: 100 + stepSize: 1 + tickmarksEnabled: true + + // disable slider when gradual support is enabled + enabled: parseInt(infillSteps.properties.value) == 0 + + // set initial value from stack + value: parseInt(infillDensity.properties.value) + + onValueChanged: + { + + // Don't round the value if it's already the same + if (parseInt(infillDensity.properties.value) == infillSlider.value) + { + return + } + + // Round the slider value to the nearest multiple of 10 (simulate step size of 10) + var roundedSliderValue = Math.round(infillSlider.value / 10) * 10 + + // Update the slider value to represent the rounded value + infillSlider.value = roundedSliderValue + + // Update value only if the Recomended mode is Active, + // Otherwise if I change the value in the Custom mode the Recomended view will try to repeat + // same operation + var active_mode = UM.Preferences.getValue("cura/active_mode") + + if (active_mode == 0 || active_mode == "simple") + { + Cura.MachineManager.setSettingForAllExtruders("infill_sparse_density", "value", roundedSliderValue) + Cura.MachineManager.resetSettingForAllExtruders("infill_line_distance") + } + } + + style: SliderStyle + { + groove: Rectangle + { + id: groove + implicitWidth: 200 * screenScaleFactor + implicitHeight: 2 * screenScaleFactor + color: control.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") + radius: 1 + } + + handle: Item + { + Rectangle + { + id: handleButton + anchors.centerIn: parent + color: control.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") + implicitWidth: 10 * screenScaleFactor + implicitHeight: 10 * screenScaleFactor + radius: 10 * screenScaleFactor + } + } + + tickmarks: Repeater + { + id: repeater + model: control.maximumValue / control.stepSize + 1 + + // check if a tick should be shown based on it's index and wether the infill density is a multiple of 10 (slider step size) + function shouldShowTick (index) + { + if (index % 10 == 0) + { + return true + } + return false + } + + Rectangle + { + anchors.verticalCenter: parent.verticalCenter + color: control.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") + width: 1 * screenScaleFactor + height: 6 * screenScaleFactor + x: Math.round(styleData.handleWidth / 2 + index * ((repeater.width - styleData.handleWidth) / (repeater.count-1))) + visible: shouldShowTick(index) + } + } + } + } + + Rectangle + { + id: infillIcon + + width: Math.round((parent.width / 5) - (UM.Theme.getSize("thick_margin").width)) + height: width + + anchors.right: parent.right + anchors.top: parent.top + anchors.topMargin: Math.round(UM.Theme.getSize("thick_margin").height / 2) + + // we loop over all density icons and only show the one that has the current density and steps + Repeater + { + id: infillIconList + model: infillModel + anchors.fill: parent + + function activeIndex () + { + for (var i = 0; i < infillModel.count; i++) + { + var density = Math.round(infillDensity.properties.value) + var steps = Math.round(infillSteps.properties.value) + var infillModelItem = infillModel.get(i) + + if (infillModelItem != "undefined" + && density >= infillModelItem.percentageMin + && density <= infillModelItem.percentageMax + && steps >= infillModelItem.stepsMin + && steps <= infillModelItem.stepsMax) + { + return i + } + } + return -1 + } + + Rectangle + { + anchors.fill: parent + visible: infillIconList.activeIndex() == index + + border.width: UM.Theme.getSize("default_lining").width + border.color: UM.Theme.getColor("quality_slider_unavailable") + + UM.RecolorImage + { + anchors.fill: parent + anchors.margins: 2 * screenScaleFactor + sourceSize.width: width + sourceSize.height: width + source: UM.Theme.getIcon(model.icon) + color: UM.Theme.getColor("quality_slider_unavailable") + } + } + } + } + + // Gradual Support Infill Checkbox + CheckBox + { + id: enableGradualInfillCheckBox + property alias _hovered: enableGradualInfillMouseArea.containsMouse + + anchors.top: infillSlider.bottom + anchors.topMargin: Math.round(UM.Theme.getSize("thick_margin").height / 2) // closer to slider since it belongs to the same category + anchors.left: infillCellRight.left + + style: UM.Theme.styles.checkbox + enabled: base.settingsEnabled + visible: infillSteps.properties.enabled == "True" + checked: parseInt(infillSteps.properties.value) > 0 + + MouseArea + { + id: enableGradualInfillMouseArea + + anchors.fill: parent + hoverEnabled: true + enabled: true + + property var previousInfillDensity: parseInt(infillDensity.properties.value) + + onClicked: + { + // Set to 90% only when enabling gradual infill + var newInfillDensity; + if (parseInt(infillSteps.properties.value) == 0) + { + previousInfillDensity = parseInt(infillDensity.properties.value) + newInfillDensity = 90 + } else { + newInfillDensity = previousInfillDensity + } + Cura.MachineManager.setSettingForAllExtruders("infill_sparse_density", "value", String(newInfillDensity)) + + var infill_steps_value = 0 + if (parseInt(infillSteps.properties.value) == 0) + { + infill_steps_value = 5 + } + + Cura.MachineManager.setSettingForAllExtruders("gradual_infill_steps", "value", infill_steps_value) + } + + onEntered: base.showTooltip(enableGradualInfillCheckBox, Qt.point(-infillCellRight.x, 0), + catalog.i18nc("@label", "Gradual infill will gradually increase the amount of infill towards the top.")) + + onExited: base.hideTooltip() + + } + + Label + { + id: gradualInfillLabel + height: parent.height + anchors.left: enableGradualInfillCheckBox.right + anchors.leftMargin: Math.round(UM.Theme.getSize("thick_margin").width / 2) + verticalAlignment: Text.AlignVCenter; + text: catalog.i18nc("@label", "Enable gradual") + font: UM.Theme.getFont("default") + color: UM.Theme.getColor("text") + } + } + + // Infill list model for mapping icon + ListModel + { + id: infillModel + Component.onCompleted: + { + infillModel.append({ + percentageMin: -1, + percentageMax: 0, + stepsMin: -1, + stepsMax: 0, + icon: "hollow" + }) + infillModel.append({ + percentageMin: 0, + percentageMax: 40, + stepsMin: -1, + stepsMax: 0, + icon: "sparse" + }) + infillModel.append({ + percentageMin: 40, + percentageMax: 89, + stepsMin: -1, + stepsMax: 0, + icon: "dense" + }) + infillModel.append({ + percentageMin: 90, + percentageMax: 9999999999, + stepsMin: -1, + stepsMax: 0, + icon: "solid" + }) + infillModel.append({ + percentageMin: 0, + percentageMax: 9999999999, + stepsMin: 1, + stepsMax: 9999999999, + icon: "gradual" + }) + } } } } @@ -804,191 +798,177 @@ Item // // Enable support // - Cura.IconWithText + Row { - id: enableSupportLabel - visible: enableSupportCheckBox.visible - source: UM.Theme.getIcon("category_support") - text: catalog.i18nc("@label", "Support") + anchors.left: parent.left + anchors.right: parent.right + height: childrenRect.height - anchors + Cura.IconWithText { - top: infillCellRight.bottom - topMargin: Math.round(UM.Theme.getSize("thick_margin").height * 1.5) - left: parent.left - right: infillCellLeft.right - rightMargin: UM.Theme.getSize("thick_margin").width - verticalCenter: enableSupportCheckBox.verticalCenter - } - } - - CheckBox - { - id: enableSupportCheckBox - property alias _hovered: enableSupportMouseArea.containsMouse - - anchors.top: enableSupportLabel.top - anchors.left: infillCellRight.left - - style: UM.Theme.styles.checkbox - enabled: base.settingsEnabled - - visible: supportEnabled.properties.enabled == "True" - checked: supportEnabled.properties.value == "True" - - MouseArea - { - id: enableSupportMouseArea - anchors.fill: parent - hoverEnabled: true - onClicked: supportEnabled.setPropertyValue("value", supportEnabled.properties.value != "True") - - onEntered: base.showTooltip(enableSupportCheckBox, Qt.point(-enableSupportCheckBox.x, 0), - catalog.i18nc("@label", "Generate structures to support parts of the model which have overhangs. Without these structures, such parts would collapse during printing.")) - - onExited: base.hideTooltip() - - } - } - - ComboBox - { - id: supportExtruderCombobox - visible: enableSupportCheckBox.visible && (supportEnabled.properties.value == "True") && (extrudersEnabledCount.properties.value > 1) - model: extruderModel - - property string color_override: "" // for manually setting values - property string color: // is evaluated automatically, but the first time is before extruderModel being filled - { - var current_extruder = extruderModel.get(currentIndex); - color_override = ""; - if (current_extruder === undefined) return "" - return (current_extruder.color) ? current_extruder.color : ""; + id: enableSupportLabel + visible: enableSupportCheckBox.visible + source: UM.Theme.getIcon("category_support") + text: catalog.i18nc("@label", "Support") + width: labelColumnWidth } - textRole: "text" // this solves that the combobox isn't populated in the first time Cura is started - - anchors.top: enableSupportCheckBox.top - - anchors.left: enableSupportCheckBox.right - anchors.leftMargin: Math.round(UM.Theme.getSize("thick_margin").width / 2) - - width: Math.round(UM.Theme.getSize("print_setup_widget").width * .55) - Math.round(UM.Theme.getSize("thick_margin").width / 2) - enableSupportCheckBox.width - height: ((supportEnabled.properties.value == "True") && (machineExtruderCount.properties.value > 1)) ? UM.Theme.getSize("setting_control").height : 0 - - Behavior on height { NumberAnimation { duration: 100 } } - - style: UM.Theme.styles.combobox_color - enabled: base.settingsEnabled - property alias _hovered: supportExtruderMouseArea.containsMouse - - currentIndex: + CheckBox { - if (supportExtruderNr.properties == null) + id: enableSupportCheckBox + property alias _hovered: enableSupportMouseArea.containsMouse + + style: UM.Theme.styles.checkbox + enabled: base.settingsEnabled + + visible: supportEnabled.properties.enabled == "True" + checked: supportEnabled.properties.value == "True" + + MouseArea { - return Cura.MachineManager.defaultExtruderPosition + id: enableSupportMouseArea + anchors.fill: parent + hoverEnabled: true + onClicked: supportEnabled.setPropertyValue("value", supportEnabled.properties.value != "True") + + onEntered: base.showTooltip(enableSupportCheckBox, Qt.point(-enableSupportCheckBox.x, 0), + catalog.i18nc("@label", "Generate structures to support parts of the model which have overhangs. Without these structures, such parts would collapse during printing.")) + + onExited: base.hideTooltip() + } - else + } + + ComboBox + { + id: supportExtruderCombobox + visible: enableSupportCheckBox.visible && (supportEnabled.properties.value == "True") && (extrudersEnabledCount.properties.value > 1) + model: extruderModel + + property string color_override: "" // for manually setting values + property string color: // is evaluated automatically, but the first time is before extruderModel being filled { - var extruder = parseInt(supportExtruderNr.properties.value) - if ( extruder === -1) + var current_extruder = extruderModel.get(currentIndex); + color_override = ""; + if (current_extruder === undefined) return "" + return (current_extruder.color) ? current_extruder.color : ""; + } + + textRole: "text" // this solves that the combobox isn't populated in the first time Cura is started + + width: Math.round(UM.Theme.getSize("print_setup_widget").width * .55) - Math.round(UM.Theme.getSize("thick_margin").width / 2) - enableSupportCheckBox.width + height: ((supportEnabled.properties.value == "True") && (machineExtruderCount.properties.value > 1)) ? UM.Theme.getSize("setting_control").height : 0 + + Behavior on height { NumberAnimation { duration: 100 } } + + style: UM.Theme.styles.combobox_color + enabled: base.settingsEnabled + property alias _hovered: supportExtruderMouseArea.containsMouse + + currentIndex: + { + if (supportExtruderNr.properties == null) { return Cura.MachineManager.defaultExtruderPosition } - return extruder; - } - } - - onActivated: supportExtruderNr.setPropertyValue("value", String(index)) - - MouseArea - { - id: supportExtruderMouseArea - anchors.fill: parent - hoverEnabled: true - enabled: base.settingsEnabled - acceptedButtons: Qt.NoButton - onEntered: - { - base.showTooltip(supportExtruderCombobox, Qt.point(-supportExtruderCombobox.x, 0), - catalog.i18nc("@label", "Select which extruder to use for support. This will build up supporting structures below the model to prevent the model from sagging or printing in mid air.")); - } - onExited: base.hideTooltip() - - } - - function updateCurrentColor() - { - var current_extruder = extruderModel.get(currentIndex) - if (current_extruder !== undefined) - { - supportExtruderCombobox.color_override = current_extruder.color - } - } - - } - - Cura.IconWithText - { - id: adhesionHelperLabel - visible: adhesionCheckBox.visible - source: UM.Theme.getIcon("category_adhesion") - text: catalog.i18nc("@label", "Adhesion") - - anchors - { - left: parent.left - right: infillCellLeft.right - rightMargin: UM.Theme.getSize("thick_margin").width - verticalCenter: adhesionCheckBox.verticalCenter - } - } - - CheckBox - { - id: adhesionCheckBox - property alias _hovered: adhesionMouseArea.containsMouse - - anchors.top: enableSupportCheckBox.bottom - anchors.topMargin: UM.Theme.getSize("thick_margin").height - anchors.left: infillCellRight.left - - //: Setting enable printing build-plate adhesion helper checkbox - style: UM.Theme.styles.checkbox - enabled: base.settingsEnabled - - visible: platformAdhesionType.properties.enabled == "True" - checked: platformAdhesionType.properties.value != "skirt" && platformAdhesionType.properties.value != "none" - - MouseArea - { - id: adhesionMouseArea - anchors.fill: parent - hoverEnabled: true - enabled: base.settingsEnabled - onClicked: - { - var adhesionType = "skirt" - if(!parent.checked) + else { - // Remove the "user" setting to see if the rest of the stack prescribes a brim or a raft - platformAdhesionType.removeFromContainer(0) - adhesionType = platformAdhesionType.properties.value - if(adhesionType == "skirt" || adhesionType == "none") + var extruder = parseInt(supportExtruderNr.properties.value) + if ( extruder === -1) { - // If the rest of the stack doesn't prescribe an adhesion-type, default to a brim - adhesionType = "brim" + return Cura.MachineManager.defaultExtruderPosition } + return extruder; } - platformAdhesionType.setPropertyValue("value", adhesionType) } - onEntered: - { - base.showTooltip(adhesionCheckBox, Qt.point(-adhesionCheckBox.x, 0), - catalog.i18nc("@label", "Enable printing a brim or raft. This will add a flat area around or under your object which is easy to cut off afterwards.")); - } - onExited: base.hideTooltip() + onActivated: supportExtruderNr.setPropertyValue("value", String(index)) + + MouseArea + { + id: supportExtruderMouseArea + anchors.fill: parent + hoverEnabled: true + enabled: base.settingsEnabled + acceptedButtons: Qt.NoButton + onEntered: + { + base.showTooltip(supportExtruderCombobox, Qt.point(-supportExtruderCombobox.x, 0), + catalog.i18nc("@label", "Select which extruder to use for support. This will build up supporting structures below the model to prevent the model from sagging or printing in mid air.")); + } + onExited: base.hideTooltip() + + } + + function updateCurrentColor() + { + var current_extruder = extruderModel.get(currentIndex) + if (current_extruder !== undefined) + { + supportExtruderCombobox.color_override = current_extruder.color + } + } + + } + } + + // Adhesion + Row + { + anchors.left: parent.left + anchors.right: parent.right + height: childrenRect.height + + Cura.IconWithText + { + id: adhesionHelperLabel + visible: adhesionCheckBox.visible + source: UM.Theme.getIcon("category_adhesion") + text: catalog.i18nc("@label", "Adhesion") + width: labelColumnWidth + } + + CheckBox + { + id: adhesionCheckBox + property alias _hovered: adhesionMouseArea.containsMouse + + //: Setting enable printing build-plate adhesion helper checkbox + style: UM.Theme.styles.checkbox + enabled: base.settingsEnabled + + visible: platformAdhesionType.properties.enabled == "True" + checked: platformAdhesionType.properties.value != "skirt" && platformAdhesionType.properties.value != "none" + + MouseArea + { + id: adhesionMouseArea + anchors.fill: parent + hoverEnabled: true + enabled: base.settingsEnabled + onClicked: + { + var adhesionType = "skirt" + if(!parent.checked) + { + // Remove the "user" setting to see if the rest of the stack prescribes a brim or a raft + platformAdhesionType.removeFromContainer(0) + adhesionType = platformAdhesionType.properties.value + if(adhesionType == "skirt" || adhesionType == "none") + { + // If the rest of the stack doesn't prescribe an adhesion-type, default to a brim + adhesionType = "brim" + } + } + platformAdhesionType.setPropertyValue("value", adhesionType) + } + onEntered: + { + base.showTooltip(adhesionCheckBox, Qt.point(-adhesionCheckBox.x, 0), + catalog.i18nc("@label", "Enable printing a brim or raft. This will add a flat area around or under your object which is easy to cut off afterwards.")); + } + onExited: base.hideTooltip() + } } } @@ -1005,31 +985,6 @@ Item onModelChanged: populateExtruderModel() } - Item - { - id: tipsCell - anchors.top: adhesionCheckBox.visible ? adhesionCheckBox.bottom : (enableSupportCheckBox.visible ? supportExtruderCombobox.bottom : infillCellRight.bottom) - anchors.topMargin: Math.round(UM.Theme.getSize("thick_margin").height * 2) - anchors.left: parent.left - width: parent.width - height: tipsText.contentHeight * tipsText.lineCount - - Label - { - id: tipsText - anchors.left: parent.left - anchors.right: parent.right - anchors.rightMargin: UM.Theme.getSize("thick_margin").width - anchors.top: parent.top - wrapMode: Text.WordWrap - text: catalog.i18nc("@label", "Need help improving your prints?
Read the Ultimaker Troubleshooting Guides").arg("https://ultimaker.com/en/troubleshooting") - font: UM.Theme.getFont("default"); - color: UM.Theme.getColor("text"); - linkColor: UM.Theme.getColor("text_link") - onLinkActivated: Qt.openUrlExternally(link) - } - } - UM.SettingPropertyProvider { id: infillExtruderNumber @@ -1096,8 +1051,8 @@ Item function populateExtruderModel() { - extruderModel.clear(); - for(var extruderNumber = 0; extruderNumber < extruders.rowCount() ; extruderNumber++) + extruderModel.clear() + for (var extruderNumber = 0; extruderNumber < extruders.rowCount(); extruderNumber++) { extruderModel.append({ text: extruders.getItem(extruderNumber).name, From bc8bf8780959db152ba572a39a4dc545d1900006 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Thu, 29 Nov 2018 15:54:02 +0100 Subject: [PATCH 18/70] Align the buttons at the bottom of the panel Contributes to CURA-5941. --- resources/qml/ExpandableComponent.qml | 3 +- .../PrintSetupSelectorContents.qml | 71 +++++++++++-------- 2 files changed, 45 insertions(+), 29 deletions(-) diff --git a/resources/qml/ExpandableComponent.qml b/resources/qml/ExpandableComponent.qml index 0c3a8f80b9..47fa226e9d 100644 --- a/resources/qml/ExpandableComponent.qml +++ b/resources/qml/ExpandableComponent.qml @@ -163,6 +163,7 @@ Item onExited: background.color = headerBackgroundColor } } + DropShadow { id: shadow @@ -182,7 +183,7 @@ Item id: popup // Ensure that the popup is located directly below the headerItem - y: headerItemLoader.height + 2 * background.padding + base.shadowOffset + popupSpacingY + y: background.height + base.shadowOffset + popupSpacingY // Make the popup aligned with the rest, using the property popupAlignment to decide whether is right or left. // In case of right alignment, the 3x padding is due to left, right and padding between the button & text. diff --git a/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml b/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml index 6e71526f25..309d612fae 100644 --- a/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml +++ b/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml @@ -11,7 +11,7 @@ Item { id: popup - width: UM.Theme.getSize("print_setup_widget").width + width: UM.Theme.getSize("print_setup_widget").width - 2 * UM.Theme.getSize("default_margin").width height: childrenRect.height property int currentModeIndex: -1 @@ -87,22 +87,50 @@ Item color: UM.Theme.getColor("lining") } - Loader + Item { - id: loader - width: parent.width + id: contents + height: childrenRect.height + anchors { top: header.bottom + left: parent.left + right: parent.right + } + + RecommendedPrintSetup + { + anchors + { + left: parent.left + right: parent.right + top: parent.top + } + onShowTooltip: base.showTooltip(item, location, text) + onHideTooltip: base.hideTooltip() + visible: currentModeIndex == 0 + } + + CustomPrintSetup + { + anchors + { + left: parent.left + right: parent.right + top: parent.top + } + onShowTooltip: base.showTooltip(item, location, text) + onHideTooltip: base.hideTooltip() + visible: currentModeIndex == 1 } - sourceComponent: currentModeIndex == 0 ? recommendedPrintSetup : customPrintSetup } Rectangle { id: buttonsSeparator - anchors.top: loader.bottom + anchors.top: contents.bottom width: parent.width height: UM.Theme.getSize("default_lining").height color: UM.Theme.getColor("lining") @@ -111,7 +139,8 @@ Item Item { id: buttonRow - height: childrenRect.height + property real padding: UM.Theme.getSize("default_margin").width + height: childrenRect.height + 2 * padding // The buttonsSeparator is inside the buttonRow. This is to avoid some weird behaviours with the scroll bar. anchors @@ -123,46 +152,32 @@ Item Cura.SecondaryButton { + anchors.top: parent.top anchors.left: parent.left + anchors.margins: parent.padding leftPadding: UM.Theme.getSize("default_margin").width rightPadding: UM.Theme.getSize("default_margin").width text: catalog.i18nc("@button", "Recommended") + iconSource: UM.Theme.getIcon("arrow_left") visible: currentModeIndex == 1 onClicked: currentModeIndex = 0 } Cura.SecondaryButton { + anchors.top: parent.top anchors.right: parent.right + anchors.margins: UM.Theme.getSize("default_margin").width leftPadding: UM.Theme.getSize("default_margin").width rightPadding: UM.Theme.getSize("default_margin").width text: catalog.i18nc("@button", "Custom") + iconSource: UM.Theme.getIcon("arrow_right") + iconOnRightSide: true visible: currentModeIndex == 0 onClicked: currentModeIndex = 1 } } - Component - { - id: recommendedPrintSetup - RecommendedPrintSetup - { - onShowTooltip: base.showTooltip(item, location, text) - onHideTooltip: base.hideTooltip() - } - } - - Component - { - id: customPrintSetup - CustomPrintSetup - { - onShowTooltip: base.showTooltip(item, location, text) - onHideTooltip: base.hideTooltip() - } - } - - Component.onCompleted: { var index = Math.round(UM.Preferences.getValue("cura/active_mode")) From 17945c6b16ca3d0be7274a6946f68f4d381c8d48 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Fri, 30 Nov 2018 11:32:24 +0100 Subject: [PATCH 19/70] [WIP] Separate components in different files Contributes to CURA-5941 --- resources/qml/ExpandableComponent.qml | 3 + .../{ => Custom}/CustomPrintSetup.qml | 4 +- .../PrintSetupSelectorContents.qml | 31 +- .../RecommendedInfillDensitySelector.qml | 348 ++++++ .../Recommended/RecommendedPrintSetup.qml | 162 +++ .../RecommendedQualityProfileSelector.qml | 464 +++++++ .../RecommendedSupportSelector.qml | 175 +++ .../RecommendedPrintSetup.qml | 1064 ----------------- resources/qml/qmldir | 3 +- 9 files changed, 1173 insertions(+), 1081 deletions(-) rename resources/qml/PrintSetupSelector/{ => Custom}/CustomPrintSetup.qml (77%) create mode 100644 resources/qml/PrintSetupSelector/Recommended/RecommendedInfillDensitySelector.qml create mode 100644 resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml create mode 100644 resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml create mode 100644 resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml delete mode 100644 resources/qml/PrintSetupSelector/RecommendedPrintSetup.qml diff --git a/resources/qml/ExpandableComponent.qml b/resources/qml/ExpandableComponent.qml index 47fa226e9d..82747d1c5b 100644 --- a/resources/qml/ExpandableComponent.qml +++ b/resources/qml/ExpandableComponent.qml @@ -27,6 +27,9 @@ Item // The popupItem holds the QML item that is shown when the "open" button is pressed property var popupItem + // The popupItem holds the QML item that is shown when the "open" button is pressed + property var componentItem + property color popupBackgroundColor: UM.Theme.getColor("action_button") property color headerBackgroundColor: UM.Theme.getColor("action_button") diff --git a/resources/qml/PrintSetupSelector/CustomPrintSetup.qml b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml similarity index 77% rename from resources/qml/PrintSetupSelector/CustomPrintSetup.qml rename to resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml index f58695b48f..51cd8eff0d 100644 --- a/resources/qml/PrintSetupSelector/CustomPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml @@ -4,7 +4,7 @@ import QtQuick 2.7 import QtQuick.Controls 2.0 -import "../Settings" +import Cura 1.0 as Cura -SettingView { +Cura.SettingView { } diff --git a/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml b/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml index 309d612fae..f21253acd7 100644 --- a/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml +++ b/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml @@ -7,6 +7,9 @@ import QtQuick.Controls 2.3 import UM 1.3 as UM import Cura 1.0 as Cura +import "Recommended" +import "Custom" + Item { id: popup @@ -22,7 +25,7 @@ Item { id: header height: UM.Theme.getSize("print_setup_widget_header").height - color: UM.Theme.getColor("action_button_hovered") // TODO: It's not clear the color that we need to use here + color: "transparent" //UM.Theme.getColor("action_button_hovered") // TODO: It's not clear the color that we need to use here anchors { @@ -111,19 +114,19 @@ Item onHideTooltip: base.hideTooltip() visible: currentModeIndex == 0 } - - CustomPrintSetup - { - anchors - { - left: parent.left - right: parent.right - top: parent.top - } - onShowTooltip: base.showTooltip(item, location, text) - onHideTooltip: base.hideTooltip() - visible: currentModeIndex == 1 - } +// +// CustomPrintSetup +// { +// anchors +// { +// left: parent.left +// right: parent.right +// top: parent.top +// } +// onShowTooltip: base.showTooltip(item, location, text) +// onHideTooltip: base.hideTooltip() +// visible: currentModeIndex == 1 +// } } Rectangle diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedInfillDensitySelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedInfillDensitySelector.qml new file mode 100644 index 0000000000..34cb8f2f20 --- /dev/null +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedInfillDensitySelector.qml @@ -0,0 +1,348 @@ +// Copyright (c) 2018 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.7 +import QtQuick.Controls 1.4 +import QtQuick.Controls.Styles 1.4 + +import UM 1.2 as UM +import Cura 1.0 as Cura + + +// +// Infill +// +Item +{ + id: infillRow + + Cura.IconWithText + { + id: infillRowTitle + source: UM.Theme.getIcon("category_infill") + text: catalog.i18nc("@label", "Infill") + " (%)" + anchors.bottom: parent.bottom + width: labelColumnWidth + } + + Item + { + id: infillCellRight + + height: infillSlider.height + UM.Theme.getSize("thick_margin").height + enableGradualInfillCheckBox.visible * (enableGradualInfillCheckBox.height + UM.Theme.getSize("thick_margin").height) + + anchors.left: infillRowTitle.right + anchors.right: parent.right + + Label + { + id: selectedInfillRateText + + anchors.left: infillSlider.left + anchors.right: parent.right + + text: parseInt(infillDensity.properties.value) + "%" + horizontalAlignment: Text.AlignLeft + + color: infillSlider.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") + } + + // We use a binding to make sure that after manually setting infillSlider.value it is still bound to the property provider + Binding + { + target: infillSlider + property: "value" + value: parseInt(infillDensity.properties.value) + } + + Slider + { + id: infillSlider + + anchors.top: selectedInfillRateText.bottom + anchors.left: parent.left + anchors.right: infillIcon.left + anchors.rightMargin: UM.Theme.getSize("thick_margin").width + + height: UM.Theme.getSize("thick_margin").height + width: parseInt(infillCellRight.width - UM.Theme.getSize("thick_margin").width - style.handleWidth) + + minimumValue: 0 + maximumValue: 100 + stepSize: 1 + tickmarksEnabled: true + + // disable slider when gradual support is enabled + enabled: parseInt(infillSteps.properties.value) == 0 + + // set initial value from stack + value: parseInt(infillDensity.properties.value) + + onValueChanged: + { + + // Don't round the value if it's already the same + if (parseInt(infillDensity.properties.value) == infillSlider.value) + { + return + } + + // Round the slider value to the nearest multiple of 10 (simulate step size of 10) + var roundedSliderValue = Math.round(infillSlider.value / 10) * 10 + + // Update the slider value to represent the rounded value + infillSlider.value = roundedSliderValue + + // Update value only if the Recomended mode is Active, + // Otherwise if I change the value in the Custom mode the Recomended view will try to repeat + // same operation + var active_mode = UM.Preferences.getValue("cura/active_mode") + + if (active_mode == 0 || active_mode == "simple") + { + Cura.MachineManager.setSettingForAllExtruders("infill_sparse_density", "value", roundedSliderValue) + Cura.MachineManager.resetSettingForAllExtruders("infill_line_distance") + } + } + + style: SliderStyle + { + groove: Rectangle + { + id: groove + implicitWidth: 200 * screenScaleFactor + implicitHeight: 2 * screenScaleFactor + color: control.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") + radius: 1 + } + + handle: Item + { + Rectangle + { + id: handleButton + anchors.centerIn: parent + color: control.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") + implicitWidth: 10 * screenScaleFactor + implicitHeight: 10 * screenScaleFactor + radius: 10 * screenScaleFactor + } + } + + tickmarks: Repeater + { + id: repeater + model: control.maximumValue / control.stepSize + 1 + + // check if a tick should be shown based on it's index and wether the infill density is a multiple of 10 (slider step size) + function shouldShowTick (index) + { + if (index % 10 == 0) + { + return true + } + return false + } + + Rectangle + { + anchors.verticalCenter: parent.verticalCenter + color: control.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") + width: 1 * screenScaleFactor + height: 6 * screenScaleFactor + x: Math.round(styleData.handleWidth / 2 + index * ((repeater.width - styleData.handleWidth) / (repeater.count-1))) + visible: shouldShowTick(index) + } + } + } + } + + Rectangle + { + id: infillIcon + + width: Math.round((parent.width / 5) - (UM.Theme.getSize("thick_margin").width)) + height: width + + anchors.right: parent.right + anchors.top: parent.top + anchors.topMargin: Math.round(UM.Theme.getSize("thick_margin").height / 2) + + // we loop over all density icons and only show the one that has the current density and steps + Repeater + { + id: infillIconList + model: infillModel + anchors.fill: parent + + function activeIndex () + { + for (var i = 0; i < infillModel.count; i++) + { + var density = Math.round(infillDensity.properties.value) + var steps = Math.round(infillSteps.properties.value) + var infillModelItem = infillModel.get(i) + + if (infillModelItem != "undefined" + && density >= infillModelItem.percentageMin + && density <= infillModelItem.percentageMax + && steps >= infillModelItem.stepsMin + && steps <= infillModelItem.stepsMax) + { + return i + } + } + return -1 + } + + Rectangle + { + anchors.fill: parent + visible: infillIconList.activeIndex() == index + + border.width: UM.Theme.getSize("default_lining").width + border.color: UM.Theme.getColor("quality_slider_unavailable") + + UM.RecolorImage + { + anchors.fill: parent + anchors.margins: 2 * screenScaleFactor + sourceSize.width: width + sourceSize.height: width + source: UM.Theme.getIcon(model.icon) + color: UM.Theme.getColor("quality_slider_unavailable") + } + } + } + } + + // Gradual Support Infill Checkbox + CheckBox + { + id: enableGradualInfillCheckBox + property alias _hovered: enableGradualInfillMouseArea.containsMouse + + anchors.top: infillSlider.bottom + anchors.topMargin: Math.round(UM.Theme.getSize("thick_margin").height / 2) // closer to slider since it belongs to the same category + anchors.left: infillCellRight.left + + style: UM.Theme.styles.checkbox + enabled: base.settingsEnabled + visible: infillSteps.properties.enabled == "True" + checked: parseInt(infillSteps.properties.value) > 0 + + MouseArea + { + id: enableGradualInfillMouseArea + + anchors.fill: parent + hoverEnabled: true + enabled: true + + property var previousInfillDensity: parseInt(infillDensity.properties.value) + + onClicked: + { + // Set to 90% only when enabling gradual infill + var newInfillDensity; + if (parseInt(infillSteps.properties.value) == 0) + { + previousInfillDensity = parseInt(infillDensity.properties.value) + newInfillDensity = 90 + } else { + newInfillDensity = previousInfillDensity + } + Cura.MachineManager.setSettingForAllExtruders("infill_sparse_density", "value", String(newInfillDensity)) + + var infill_steps_value = 0 + if (parseInt(infillSteps.properties.value) == 0) + { + infill_steps_value = 5 + } + + Cura.MachineManager.setSettingForAllExtruders("gradual_infill_steps", "value", infill_steps_value) + } + + onEntered: base.showTooltip(enableGradualInfillCheckBox, Qt.point(-infillCellRight.x, 0), + catalog.i18nc("@label", "Gradual infill will gradually increase the amount of infill towards the top.")) + + onExited: base.hideTooltip() + + } + + Label + { + id: gradualInfillLabel + height: parent.height + anchors.left: enableGradualInfillCheckBox.right + anchors.leftMargin: Math.round(UM.Theme.getSize("thick_margin").width / 2) + verticalAlignment: Text.AlignVCenter; + text: catalog.i18nc("@label", "Enable gradual") + font: UM.Theme.getFont("default") + color: UM.Theme.getColor("text") + } + } + + // Infill list model for mapping icon + ListModel + { + id: infillModel + Component.onCompleted: + { + infillModel.append({ + percentageMin: -1, + percentageMax: 0, + stepsMin: -1, + stepsMax: 0, + icon: "hollow" + }) + infillModel.append({ + percentageMin: 0, + percentageMax: 40, + stepsMin: -1, + stepsMax: 0, + icon: "sparse" + }) + infillModel.append({ + percentageMin: 40, + percentageMax: 89, + stepsMin: -1, + stepsMax: 0, + icon: "dense" + }) + infillModel.append({ + percentageMin: 90, + percentageMax: 9999999999, + stepsMin: -1, + stepsMax: 0, + icon: "solid" + }) + infillModel.append({ + percentageMin: 0, + percentageMax: 9999999999, + stepsMin: 1, + stepsMax: 9999999999, + icon: "gradual" + }) + } + } + } + + UM.SettingPropertyProvider + { + id: infillDensity + containerStackId: Cura.MachineManager.activeStackId + key: "infill_sparse_density" + watchedProperties: [ "value" ] + storeIndex: 0 + } + + UM.SettingPropertyProvider + { + id: infillSteps + containerStackId: Cura.MachineManager.activeStackId + key: "gradual_infill_steps" + watchedProperties: ["value", "enabled"] + storeIndex: 0 + } +} \ No newline at end of file diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml new file mode 100644 index 0000000000..2d4308c8be --- /dev/null +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml @@ -0,0 +1,162 @@ +// Copyright (c) 2018 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.7 +import QtQuick.Controls 1.4 +import QtQuick.Controls.Styles 1.4 + +import UM 1.2 as UM +import Cura 1.0 as Cura + +Rectangle +{ + id: base + + signal showTooltip(Item item, point location, string text) + signal hideTooltip() +// width: parent.width + height: childrenRect.height + 2 * padding + color: "red" + opacity: 0.5 + + property Action configureSettings + + property bool settingsEnabled: Cura.ExtruderManager.activeExtruderStackId || extrudersEnabledCount.properties.value == 1 + property real padding: UM.Theme.getSize("thick_margin").width + + UM.I18nCatalog + { + id: catalog + name: "cura" + } + +// Rectangle +// { +// width: parent.width - 2 * parent.padding +// anchors +// { +// left: parent.left +// right: parent.right +// top: parent.top +// margins: parent.padding +// } +// color: "blue" +// height: 50 +// } + + Column + { + width: parent.width - 2 * parent.padding + spacing: UM.Theme.getSize("default_margin").height + anchors + { + left: parent.left + right: parent.right + top: parent.top + margins: parent.padding + } + + // TODO + property real labelColumnWidth: Math.round(width / 3) + property real settingsColumnWidth: width - labelColumnWidth + + RecommendedQualityProfileSelector + { + width: parent.width + // TODO Create a reusable component with these properties to not define them separately for each component + property real labelColumnWidth: parent.labelColumnWidth + property real settingsColumnWidth: parent.settingsColumnWidth + } + +// RecommendedInfillDensitySelector +// { +// width: parent.width +// height: childrenRect.height +// // TODO Create a reusable component with these properties to not define them separately for each component +// property real labelColumnWidth: parent.labelColumnWidth +// property real settingsColumnWidth: parent.settingsColumnWidth +// } +// +// RecommendedSupportSelector +// { +// width: parent.width +// height: childrenRect.height +// // TODO Create a reusable component with these properties to not define them separately for each component +// property real labelColumnWidth: parent.labelColumnWidth +// property real settingsColumnWidth: parent.settingsColumnWidth +// } + + +// +// // Adhesion +// Row +// { +// anchors.left: parent.left +// anchors.right: parent.right +// height: childrenRect.height +// +// Cura.IconWithText +// { +// id: adhesionHelperLabel +// visible: adhesionCheckBox.visible +// source: UM.Theme.getIcon("category_adhesion") +// text: catalog.i18nc("@label", "Adhesion") +// width: labelColumnWidth +// } +// +// CheckBox +// { +// id: adhesionCheckBox +// property alias _hovered: adhesionMouseArea.containsMouse +// +// //: Setting enable printing build-plate adhesion helper checkbox +// style: UM.Theme.styles.checkbox +// enabled: base.settingsEnabled +// +// visible: platformAdhesionType.properties.enabled == "True" +// checked: platformAdhesionType.properties.value != "skirt" && platformAdhesionType.properties.value != "none" +// +// MouseArea +// { +// id: adhesionMouseArea +// anchors.fill: parent +// hoverEnabled: true +// enabled: base.settingsEnabled +// onClicked: +// { +// var adhesionType = "skirt" +// if(!parent.checked) +// { +// // Remove the "user" setting to see if the rest of the stack prescribes a brim or a raft +// platformAdhesionType.removeFromContainer(0) +// adhesionType = platformAdhesionType.properties.value +// if(adhesionType == "skirt" || adhesionType == "none") +// { +// // If the rest of the stack doesn't prescribe an adhesion-type, default to a brim +// adhesionType = "brim" +// } +// } +// platformAdhesionType.setPropertyValue("value", adhesionType) +// } +// onEntered: +// { +// base.showTooltip(adhesionCheckBox, Qt.point(-adhesionCheckBox.x, 0), +// catalog.i18nc("@label", "Enable printing a brim or raft. This will add a flat area around or under your object which is easy to cut off afterwards.")); +// } +// onExited: base.hideTooltip() +// } +// } +// } + } + + + UM.SettingPropertyProvider + { + id: platformAdhesionType + containerStack: Cura.MachineManager.activeMachine + removeUnusedValue: false //Doesn't work with settings that are resolved. + key: "adhesion_type" + watchedProperties: [ "value", "enabled" ] + storeIndex: 0 + } +} diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml new file mode 100644 index 0000000000..3bf93c0c07 --- /dev/null +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml @@ -0,0 +1,464 @@ +// Copyright (c) 2018 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.7 +import QtQuick.Controls 1.4 +import QtQuick.Controls.Styles 1.4 + +import UM 1.2 as UM +import Cura 1.0 as Cura + + +// +// Quality profile +// +Item +{ + id: qualityRow + height: childrenRect.height + + Timer + { + id: qualitySliderChangeTimer + interval: 50 + running: false + repeat: false + onTriggered: + { + var item = Cura.QualityProfilesDropDownMenuModel.getItem(qualitySlider.value); + Cura.MachineManager.activeQualityGroup = item.quality_group; + } + } + + Component.onCompleted: qualityModel.update() + + Connections + { + target: Cura.QualityProfilesDropDownMenuModel + onItemsChanged: qualityModel.update() + } + + Connections { + target: base + onVisibleChanged: + { + // update needs to be called when the widgets are visible, otherwise the step width calculation + // will fail because the width of an invisible item is 0. + if (visible) + { + qualityModel.update(); + } + } + } + + ListModel + { + id: qualityModel + + property var totalTicks: 0 + property var availableTotalTicks: 0 + property var existingQualityProfile: 0 + + property var qualitySliderActiveIndex: 0 + property var qualitySliderStepWidth: 0 + property var qualitySliderAvailableMin: 0 + property var qualitySliderAvailableMax: 0 + property var qualitySliderMarginRight: 0 + + function update () + { + reset() + + var availableMin = -1 + var availableMax = -1 + + for (var i = 0; i < Cura.QualityProfilesDropDownMenuModel.rowCount(); i++) + { + var qualityItem = Cura.QualityProfilesDropDownMenuModel.getItem(i) + + // Add each quality item to the UI quality model + qualityModel.append(qualityItem) + + // Set selected value + if (Cura.MachineManager.activeQualityType == qualityItem.quality_type) + { + // set to -1 when switching to user created profile so all ticks are clickable + if (Cura.SimpleModeSettingsManager.isProfileUserCreated) + { + qualityModel.qualitySliderActiveIndex = -1 + } + else + { + qualityModel.qualitySliderActiveIndex = i + } + + qualityModel.existingQualityProfile = 1 + } + + // Set min available + if (qualityItem.available && availableMin == -1) + { + availableMin = i + } + + // Set max available + if (qualityItem.available) + { + availableMax = i + } + } + + // Set total available ticks for active slider part + if (availableMin != -1) + { + qualityModel.availableTotalTicks = availableMax - availableMin + 1 + } + + // Calculate slider values + calculateSliderStepWidth(qualityModel.totalTicks) + calculateSliderMargins(availableMin, availableMax, qualityModel.totalTicks) + + qualityModel.qualitySliderAvailableMin = availableMin + qualityModel.qualitySliderAvailableMax = availableMax + } + + function calculateSliderStepWidth (totalTicks) + { + qualityModel.qualitySliderStepWidth = totalTicks != 0 ? Math.round((settingsColumnWidth) / (totalTicks)) : 0 + } + + function calculateSliderMargins (availableMin, availableMax, totalTicks) + { + if (availableMin == -1 || (availableMin == 0 && availableMax == 0)) + { + qualityModel.qualitySliderMarginRight = Math.round(settingsColumnWidth) + } + else if (availableMin == availableMax) + { + qualityModel.qualitySliderMarginRight = Math.round((totalTicks - availableMin) * qualitySliderStepWidth) + } + else + { + qualityModel.qualitySliderMarginRight = Math.round((totalTicks - availableMax) * qualitySliderStepWidth) + } + } + + function reset () { + qualityModel.clear() + qualityModel.availableTotalTicks = 0 + qualityModel.existingQualityProfile = 0 + + // check, the ticks count cannot be less than zero + qualityModel.totalTicks = Math.max(0, Cura.QualityProfilesDropDownMenuModel.rowCount() - 1) + } + } + + Cura.IconWithText + { + id: qualityRowTitle + source: UM.Theme.getIcon("category_layer_height") + text: catalog.i18nc("@label", "Layer Height") +// anchors.bottom: speedSlider.bottom + width: labelColumnWidth + } + + //Print speed slider + Rectangle + { + id: speedSlider + + anchors + { + left: qualityRowTitle.right + right: parent.right + } + + color: "green" + height: 20 + } +// +// // Show titles for the each quality slider ticks +// Item +// { +// anchors.left: speedSlider.left +// anchors.top: speedSlider.bottom +// +// Repeater +// { +// model: qualityModel +// +// Label +// { +// anchors.verticalCenter: parent.verticalCenter +// anchors.top: parent.top +// color: (Cura.MachineManager.activeMachine != null && Cura.QualityProfilesDropDownMenuModel.getItem(index).available) ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") +// text: +// { +// var result = "" +// if(Cura.MachineManager.activeMachine != null) +// { +// result = Cura.QualityProfilesDropDownMenuModel.getItem(index).layer_height +// +// if(result == undefined) +// { +// result = ""; +// } +// else +// { +// result = Number(Math.round(result + "e+2") + "e-2"); //Round to 2 decimals. Javascript makes this difficult... +// if (result == undefined || result != result) //Parse failure. +// { +// result = ""; +// } +// } +// } +// return result +// } +// +// x: +// { +// // Make sure the text aligns correctly with each tick +// if (qualityModel.totalTicks == 0) +// { +// // If there is only one tick, align it centrally +// return Math.round(((settingsColumnWidth) - width) / 2) +// } +// else if (index == 0) +// { +// return Math.round(settingsColumnWidth / qualityModel.totalTicks) * index +// } +// else if (index == qualityModel.totalTicks) +// { +// return Math.round(settingsColumnWidth / qualityModel.totalTicks) * index - width +// } +// else +// { +// return Math.round((settingsColumnWidth / qualityModel.totalTicks) * index - (width / 2)) +// } +// } +// } +// } +// } +// +// //Print speed slider +// Rectangle +// { +// id: speedSlider +// +// anchors +// { +// left: qualityRowTitle.right +// right: parent.right +// } +// +// // This Item is used only for tooltip, for slider area which is unavailable +//// Item +//// { +//// function showTooltip (showTooltip) +//// { +//// if (showTooltip) +//// { +//// var content = catalog.i18nc("@tooltip", "This quality profile is not available for you current material and nozzle configuration. Please change these to enable this quality profile") +//// base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), content) +//// } +//// else +//// { +//// base.hideTooltip() +//// } +//// } +//// +//// id: unavailableLineToolTip +//// height: 20 * screenScaleFactor // hovered area height +//// z: parent.z + 1 // should be higher, otherwise the area can be hovered +//// x: 0 +//// anchors.verticalCenter: qualitySlider.verticalCenter +//// +//// Rectangle +//// { +//// id: leftArea +//// width: +//// { +//// if (qualityModel.availableTotalTicks == 0) +//// { +//// return qualityModel.qualitySliderStepWidth * qualityModel.totalTicks +//// } +//// return qualityModel.qualitySliderStepWidth * qualityModel.qualitySliderAvailableMin - 10 +//// } +//// height: parent.height +//// color: "transparent" +//// +//// MouseArea +//// { +//// anchors.fill: parent +//// hoverEnabled: true +//// enabled: Cura.SimpleModeSettingsManager.isProfileUserCreated == false +//// onEntered: unavailableLineToolTip.showTooltip(true) +//// onExited: unavailableLineToolTip.showTooltip(false) +//// } +//// } +//// +//// Item +//// { +//// id: rightArea +//// width: +//// { +//// if(qualityModel.availableTotalTicks == 0) +//// return 0 +//// +//// return qualityModel.qualitySliderMarginRight - 10 +//// } +//// height: parent.height +//// x: +//// { +//// if (qualityModel.availableTotalTicks == 0) +//// { +//// return 0 +//// } +//// +//// var leftUnavailableArea = qualityModel.qualitySliderStepWidth * qualityModel.qualitySliderAvailableMin +//// var totalGap = qualityModel.qualitySliderStepWidth * (qualityModel.availableTotalTicks -1) + leftUnavailableArea + 10 +//// +//// return totalGap +//// } +//// +//// MouseArea +//// { +//// anchors.fill: parent +//// hoverEnabled: true +//// enabled: Cura.SimpleModeSettingsManager.isProfileUserCreated == false +//// onEntered: unavailableLineToolTip.showTooltip(true) +//// onExited: unavailableLineToolTip.showTooltip(false) +//// } +//// } +//// } +// +// // Draw Unavailable line +// Rectangle +// { +// id: groovechildrect +// width: parent.width +// height: 2 * screenScaleFactor +// color: UM.Theme.getColor("quality_slider_unavailable") +// anchors.verticalCenter: qualitySlider.verticalCenter +// +// // Draw ticks +// Repeater +// { +// id: qualityRepeater +// model: qualityModel.totalTicks > 0 ? qualityModel : 0 +// +// Rectangle +// { +// color: Cura.QualityProfilesDropDownMenuModel.getItem(index).available ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") +// implicitWidth: 4 * screenScaleFactor +// implicitHeight: implicitWidth +// anchors.verticalCenter: parent.verticalCenter +// x: Math.round(qualityModel.qualitySliderStepWidth * index) +// radius: Math.round(implicitWidth / 2) +// } +// } +// } +// +// // Draw available slider +// Slider +// { +// id: qualitySlider +// height: UM.Theme.getSize("thick_margin").height +// anchors.bottom: parent.bottom +// enabled: qualityModel.totalTicks > 0 && !Cura.SimpleModeSettingsManager.isProfileCustomized +// visible: qualityModel.availableTotalTicks > 0 +// updateValueWhileDragging : false +// +// minimumValue: qualityModel.qualitySliderAvailableMin >= 0 ? qualityModel.qualitySliderAvailableMin : 0 +// // maximumValue must be greater than minimumValue to be able to see the handle. While the value is strictly +// // speaking not always correct, it seems to have the correct behavior (switching from 0 available to 1 available) +// maximumValue: qualityModel.qualitySliderAvailableMax >= 1 ? qualityModel.qualitySliderAvailableMax : 1 +// stepSize: 1 +// +// value: qualityModel.qualitySliderActiveIndex +// +// width: qualityModel.qualitySliderStepWidth * (qualityModel.availableTotalTicks - 1) +// +// anchors.right: parent.right +// anchors.rightMargin: qualityModel.qualitySliderMarginRight +// +// style: SliderStyle +// { +// //Draw Available line +// groove: Rectangle +// { +// implicitHeight: 2 * screenScaleFactor +// color: UM.Theme.getColor("quality_slider_available") +// radius: Math.round(height / 2) +// } +// +// handle: Rectangle +// { +// id: qualityhandleButton +// color: UM.Theme.getColor("quality_slider_available") +// implicitWidth: 12 * screenScaleFactor +// implicitHeight: implicitWidth +// radius: Math.round(implicitWidth / 2) +// visible: !Cura.SimpleModeSettingsManager.isProfileCustomized && !Cura.SimpleModeSettingsManager.isProfileUserCreated && qualityModel.existingQualityProfile +// } +// } +// +// onValueChanged: +// { +// // only change if an active machine is set and the slider is visible at all. +// if (Cura.MachineManager.activeMachine != null && visible) +// { +// // prevent updating during view initializing. Trigger only if the value changed by user +// if (qualitySlider.value != qualityModel.qualitySliderActiveIndex && qualityModel.qualitySliderActiveIndex != -1) +// { +// // start updating with short delay +// qualitySliderChangeTimer.start() +// } +// } +// } +// } +// +// MouseArea +// { +// id: speedSliderMouseArea +// anchors.fill: parent +// hoverEnabled: true +// enabled: Cura.SimpleModeSettingsManager.isProfileUserCreated +// +// onEntered: +// { +// var content = catalog.i18nc("@tooltip", "A custom profile is currently active. To enable the quality slider, choose a default quality profile in Custom tab") +// base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), content) +// } +// onExited: base.hideTooltip() +// } +// } +// +// UM.SimpleButton +// { +// id: customisedSettings +// +// visible: Cura.SimpleModeSettingsManager.isProfileCustomized || Cura.SimpleModeSettingsManager.isProfileUserCreated +// height: Math.round(speedSlider.height * 0.8) +// width: Math.round(speedSlider.height * 0.8) +// +// anchors.verticalCenter: speedSlider.verticalCenter +// anchors.right: speedSlider.left +// anchors.rightMargin: Math.round(UM.Theme.getSize("thick_margin").width / 2) +// +// color: hovered ? UM.Theme.getColor("setting_control_button_hover") : UM.Theme.getColor("setting_control_button"); +// iconSource: UM.Theme.getIcon("reset"); +// +// onClicked: +// { +// // if the current profile is user-created, switch to a built-in quality +// Cura.MachineManager.resetToUseDefaultQuality() +// } +// onEntered: +// { +// var content = catalog.i18nc("@tooltip","You have modified some profile settings. If you want to change these go to custom mode.") +// base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), content) +// } +// onExited: base.hideTooltip() +// } +} \ No newline at end of file diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml new file mode 100644 index 0000000000..9c4e5ed576 --- /dev/null +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml @@ -0,0 +1,175 @@ +// Copyright (c) 2018 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.7 +import QtQuick.Controls 1.4 +import QtQuick.Controls.Styles 1.4 + +import UM 1.2 as UM +import Cura 1.0 as Cura + +// +// Enable support +// +Row +{ + + Cura.IconWithText + { + id: enableSupportLabel + visible: enableSupportCheckBox.visible + source: UM.Theme.getIcon("category_support") + text: catalog.i18nc("@label", "Support") + width: labelColumnWidth + } + + CheckBox + { + id: enableSupportCheckBox + property alias _hovered: enableSupportMouseArea.containsMouse + + style: UM.Theme.styles.checkbox + enabled: base.settingsEnabled + + visible: supportEnabled.properties.enabled == "True" + checked: supportEnabled.properties.value == "True" + + MouseArea + { + id: enableSupportMouseArea + anchors.fill: parent + hoverEnabled: true + onClicked: supportEnabled.setPropertyValue("value", supportEnabled.properties.value != "True") + + onEntered: base.showTooltip(enableSupportCheckBox, Qt.point(-enableSupportCheckBox.x, 0), + catalog.i18nc("@label", "Generate structures to support parts of the model which have overhangs. Without these structures, such parts would collapse during printing.")) + + onExited: base.hideTooltip() + + } + } + + ComboBox + { + id: supportExtruderCombobox + visible: enableSupportCheckBox.visible && (supportEnabled.properties.value == "True") && (extrudersEnabledCount.properties.value > 1) + model: extruderModel + + property string color_override: "" // for manually setting values + property string color: // is evaluated automatically, but the first time is before extruderModel being filled + { + var current_extruder = extruderModel.get(currentIndex); + color_override = ""; + if (current_extruder === undefined) return "" + return (current_extruder.color) ? current_extruder.color : ""; + } + + textRole: "text" // this solves that the combobox isn't populated in the first time Cura is started + + width: Math.round(UM.Theme.getSize("print_setup_widget").width * .55) - Math.round(UM.Theme.getSize("thick_margin").width / 2) - enableSupportCheckBox.width + height: ((supportEnabled.properties.value == "True") && (machineExtruderCount.properties.value > 1)) ? UM.Theme.getSize("setting_control").height : 0 + + Behavior on height { NumberAnimation { duration: 100 } } + + style: UM.Theme.styles.combobox_color + enabled: base.settingsEnabled + property alias _hovered: supportExtruderMouseArea.containsMouse + + currentIndex: + { + if (supportExtruderNr.properties == null) + { + return Cura.MachineManager.defaultExtruderPosition + } + else + { + var extruder = parseInt(supportExtruderNr.properties.value) + if ( extruder === -1) + { + return Cura.MachineManager.defaultExtruderPosition + } + return extruder; + } + } + + onActivated: supportExtruderNr.setPropertyValue("value", String(index)) + + MouseArea + { + id: supportExtruderMouseArea + anchors.fill: parent + hoverEnabled: true + enabled: base.settingsEnabled + acceptedButtons: Qt.NoButton + onEntered: + { + base.showTooltip(supportExtruderCombobox, Qt.point(-supportExtruderCombobox.x, 0), + catalog.i18nc("@label", "Select which extruder to use for support. This will build up supporting structures below the model to prevent the model from sagging or printing in mid air.")); + } + onExited: base.hideTooltip() + + } + + function updateCurrentColor() + { + var current_extruder = extruderModel.get(currentIndex) + if (current_extruder !== undefined) + { + supportExtruderCombobox.color_override = current_extruder.color + } + } + } + + ListModel + { + id: extruderModel + Component.onCompleted: populateExtruderModel() + } + + //: Model used to populate the extrudelModel + Cura.ExtrudersModel + { + id: extruders + onModelChanged: populateExtruderModel() + } + + UM.SettingPropertyProvider + { + id: supportEnabled + containerStack: Cura.MachineManager.activeMachine + key: "support_enable" + watchedProperties: [ "value", "enabled", "description" ] + storeIndex: 0 + } + + UM.SettingPropertyProvider + { + id: extrudersEnabledCount + containerStack: Cura.MachineManager.activeMachine + key: "extruders_enabled_count" + watchedProperties: [ "value" ] + storeIndex: 0 + } + + UM.SettingPropertyProvider + { + id: supportExtruderNr + containerStack: Cura.MachineManager.activeMachine + key: "support_extruder_nr" + watchedProperties: [ "value" ] + storeIndex: 0 + } + + function populateExtruderModel() + { + extruderModel.clear() + for (var extruderNumber = 0; extruderNumber < extruders.rowCount(); extruderNumber++) + { + extruderModel.append({ + text: extruders.getItem(extruderNumber).name, + color: extruders.getItem(extruderNumber).color + }) + } + supportExtruderCombobox.updateCurrentColor() + } +} \ No newline at end of file diff --git a/resources/qml/PrintSetupSelector/RecommendedPrintSetup.qml b/resources/qml/PrintSetupSelector/RecommendedPrintSetup.qml deleted file mode 100644 index b48282135b..0000000000 --- a/resources/qml/PrintSetupSelector/RecommendedPrintSetup.qml +++ /dev/null @@ -1,1064 +0,0 @@ -// Copyright (c) 2018 Ultimaker B.V. -// Cura is released under the terms of the LGPLv3 or higher. - -import QtQuick 2.7 -import QtQuick.Controls 1.4 -import QtQuick.Controls.Styles 1.4 - -import UM 1.2 as UM -import Cura 1.0 as Cura - -Column -{ - id: base - - signal showTooltip(Item item, point location, string text) - signal hideTooltip() - height: childrenRect.height + 2 * padding - - padding: UM.Theme.getSize("thick_margin").width - spacing: UM.Theme.getSize("default_margin").height - - property Action configureSettings - - property bool settingsEnabled: Cura.ExtruderManager.activeExtruderStackId || extrudersEnabledCount.properties.value == 1 - property real labelColumnWidth: Math.round(width / 3) - property real settingsColumnWidth: width - labelColumnWidth - - UM.I18nCatalog - { - id: catalog - name: "cura" - } - - // - // Quality profile - // - Item - { - id: qualityRow - - anchors.left: parent.left - anchors.right: parent.right - height: childrenRect.height - - Timer - { - id: qualitySliderChangeTimer - interval: 50 - running: false - repeat: false - onTriggered: - { - var item = Cura.QualityProfilesDropDownMenuModel.getItem(qualitySlider.value); - Cura.MachineManager.activeQualityGroup = item.quality_group; - } - } - - Component.onCompleted: qualityModel.update() - - Connections - { - target: Cura.QualityProfilesDropDownMenuModel - onItemsChanged: qualityModel.update() - } - - Connections { - target: base - onVisibleChanged: - { - // update needs to be called when the widgets are visible, otherwise the step width calculation - // will fail because the width of an invisible item is 0. - if (visible) - { - qualityModel.update(); - } - } - } - - ListModel - { - id: qualityModel - - property var totalTicks: 0 - property var availableTotalTicks: 0 - property var existingQualityProfile: 0 - - property var qualitySliderActiveIndex: 0 - property var qualitySliderStepWidth: 0 - property var qualitySliderAvailableMin: 0 - property var qualitySliderAvailableMax: 0 - property var qualitySliderMarginRight: 0 - - function update () - { - reset() - - var availableMin = -1 - var availableMax = -1 - - for (var i = 0; i < Cura.QualityProfilesDropDownMenuModel.rowCount(); i++) - { - var qualityItem = Cura.QualityProfilesDropDownMenuModel.getItem(i) - - // Add each quality item to the UI quality model - qualityModel.append(qualityItem) - - // Set selected value - if (Cura.MachineManager.activeQualityType == qualityItem.quality_type) - { - // set to -1 when switching to user created profile so all ticks are clickable - if (Cura.SimpleModeSettingsManager.isProfileUserCreated) - { - qualityModel.qualitySliderActiveIndex = -1 - } - else - { - qualityModel.qualitySliderActiveIndex = i - } - - qualityModel.existingQualityProfile = 1 - } - - // Set min available - if (qualityItem.available && availableMin == -1) - { - availableMin = i - } - - // Set max available - if (qualityItem.available) - { - availableMax = i - } - } - - // Set total available ticks for active slider part - if (availableMin != -1) - { - qualityModel.availableTotalTicks = availableMax - availableMin + 1 - } - - // Calculate slider values - calculateSliderStepWidth(qualityModel.totalTicks) - calculateSliderMargins(availableMin, availableMax, qualityModel.totalTicks) - - qualityModel.qualitySliderAvailableMin = availableMin - qualityModel.qualitySliderAvailableMax = availableMax - } - - function calculateSliderStepWidth (totalTicks) - { - qualityModel.qualitySliderStepWidth = totalTicks != 0 ? Math.round((settingsColumnWidth) / (totalTicks)) : 0 - } - - function calculateSliderMargins (availableMin, availableMax, totalTicks) - { - if (availableMin == -1 || (availableMin == 0 && availableMax == 0)) - { - qualityModel.qualitySliderMarginRight = Math.round(settingsColumnWidth) - } - else if (availableMin == availableMax) - { - qualityModel.qualitySliderMarginRight = Math.round((totalTicks - availableMin) * qualitySliderStepWidth) - } - else - { - qualityModel.qualitySliderMarginRight = Math.round((totalTicks - availableMax) * qualitySliderStepWidth) - } - } - - function reset () { - qualityModel.clear() - qualityModel.availableTotalTicks = 0 - qualityModel.existingQualityProfile = 0 - - // check, the ticks count cannot be less than zero - qualityModel.totalTicks = Math.max(0, Cura.QualityProfilesDropDownMenuModel.rowCount() - 1) - } - } - - Cura.IconWithText - { - id: qualityRowTitle - source: UM.Theme.getIcon("category_layer_height") - text: catalog.i18nc("@label", "Layer Height") - anchors.bottom: speedSlider.bottom - width: labelColumnWidth - } - - // Show titles for the each quality slider ticks - Item - { - anchors.left: speedSlider.left - anchors.top: speedSlider.bottom - - Repeater - { - model: qualityModel - - Label - { - anchors.verticalCenter: parent.verticalCenter - anchors.top: parent.top - color: (Cura.MachineManager.activeMachine != null && Cura.QualityProfilesDropDownMenuModel.getItem(index).available) ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") - text: - { - var result = "" - if(Cura.MachineManager.activeMachine != null) - { - result = Cura.QualityProfilesDropDownMenuModel.getItem(index).layer_height - - if(result == undefined) - { - result = ""; - } - else - { - result = Number(Math.round(result + "e+2") + "e-2"); //Round to 2 decimals. Javascript makes this difficult... - if (result == undefined || result != result) //Parse failure. - { - result = ""; - } - } - } - return result - } - - x: - { - // Make sure the text aligns correctly with each tick - if (qualityModel.totalTicks == 0) - { - // If there is only one tick, align it centrally - return Math.round(((settingsColumnWidth) - width) / 2) - } - else if (index == 0) - { - return Math.round(settingsColumnWidth / qualityModel.totalTicks) * index - } - else if (index == qualityModel.totalTicks) - { - return Math.round(settingsColumnWidth / qualityModel.totalTicks) * index - width - } - else - { - return Math.round((settingsColumnWidth / qualityModel.totalTicks) * index - (width / 2)) - } - } - } - } - } - - //Print speed slider - Rectangle - { - id: speedSlider - - anchors - { - left: qualityRowTitle.right - right: parent.right - } - - // This Item is used only for tooltip, for slider area which is unavailable -// Item -// { -// function showTooltip (showTooltip) -// { -// if (showTooltip) -// { -// var content = catalog.i18nc("@tooltip", "This quality profile is not available for you current material and nozzle configuration. Please change these to enable this quality profile") -// base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), content) -// } -// else -// { -// base.hideTooltip() -// } -// } -// -// id: unavailableLineToolTip -// height: 20 * screenScaleFactor // hovered area height -// z: parent.z + 1 // should be higher, otherwise the area can be hovered -// x: 0 -// anchors.verticalCenter: qualitySlider.verticalCenter -// -// Rectangle -// { -// id: leftArea -// width: -// { -// if (qualityModel.availableTotalTicks == 0) -// { -// return qualityModel.qualitySliderStepWidth * qualityModel.totalTicks -// } -// return qualityModel.qualitySliderStepWidth * qualityModel.qualitySliderAvailableMin - 10 -// } -// height: parent.height -// color: "transparent" -// -// MouseArea -// { -// anchors.fill: parent -// hoverEnabled: true -// enabled: Cura.SimpleModeSettingsManager.isProfileUserCreated == false -// onEntered: unavailableLineToolTip.showTooltip(true) -// onExited: unavailableLineToolTip.showTooltip(false) -// } -// } -// -// Item -// { -// id: rightArea -// width: -// { -// if(qualityModel.availableTotalTicks == 0) -// return 0 -// -// return qualityModel.qualitySliderMarginRight - 10 -// } -// height: parent.height -// x: -// { -// if (qualityModel.availableTotalTicks == 0) -// { -// return 0 -// } -// -// var leftUnavailableArea = qualityModel.qualitySliderStepWidth * qualityModel.qualitySliderAvailableMin -// var totalGap = qualityModel.qualitySliderStepWidth * (qualityModel.availableTotalTicks -1) + leftUnavailableArea + 10 -// -// return totalGap -// } -// -// MouseArea -// { -// anchors.fill: parent -// hoverEnabled: true -// enabled: Cura.SimpleModeSettingsManager.isProfileUserCreated == false -// onEntered: unavailableLineToolTip.showTooltip(true) -// onExited: unavailableLineToolTip.showTooltip(false) -// } -// } -// } - - // Draw Unavailable line - Rectangle - { - id: groovechildrect - width: parent.width - height: 2 * screenScaleFactor - color: UM.Theme.getColor("quality_slider_unavailable") - anchors.verticalCenter: qualitySlider.verticalCenter - - // Draw ticks - Repeater - { - id: qualityRepeater - model: qualityModel.totalTicks > 0 ? qualityModel : 0 - - Rectangle - { - color: Cura.QualityProfilesDropDownMenuModel.getItem(index).available ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") - implicitWidth: 4 * screenScaleFactor - implicitHeight: implicitWidth - anchors.verticalCenter: parent.verticalCenter - x: Math.round(qualityModel.qualitySliderStepWidth * index) - radius: Math.round(implicitWidth / 2) - } - } - } - - // Draw available slider - Slider - { - id: qualitySlider - height: UM.Theme.getSize("thick_margin").height - anchors.bottom: parent.bottom - enabled: qualityModel.totalTicks > 0 && !Cura.SimpleModeSettingsManager.isProfileCustomized - visible: qualityModel.availableTotalTicks > 0 - updateValueWhileDragging : false - - minimumValue: qualityModel.qualitySliderAvailableMin >= 0 ? qualityModel.qualitySliderAvailableMin : 0 - // maximumValue must be greater than minimumValue to be able to see the handle. While the value is strictly - // speaking not always correct, it seems to have the correct behavior (switching from 0 available to 1 available) - maximumValue: qualityModel.qualitySliderAvailableMax >= 1 ? qualityModel.qualitySliderAvailableMax : 1 - stepSize: 1 - - value: qualityModel.qualitySliderActiveIndex - - width: qualityModel.qualitySliderStepWidth * (qualityModel.availableTotalTicks - 1) - - anchors.right: parent.right - anchors.rightMargin: qualityModel.qualitySliderMarginRight - - style: SliderStyle - { - //Draw Available line - groove: Rectangle - { - implicitHeight: 2 * screenScaleFactor - color: UM.Theme.getColor("quality_slider_available") - radius: Math.round(height / 2) - } - - handle: Rectangle - { - id: qualityhandleButton - color: UM.Theme.getColor("quality_slider_available") - implicitWidth: 12 * screenScaleFactor - implicitHeight: implicitWidth - radius: Math.round(implicitWidth / 2) - visible: !Cura.SimpleModeSettingsManager.isProfileCustomized && !Cura.SimpleModeSettingsManager.isProfileUserCreated && qualityModel.existingQualityProfile - } - } - - onValueChanged: - { - // only change if an active machine is set and the slider is visible at all. - if (Cura.MachineManager.activeMachine != null && visible) - { - // prevent updating during view initializing. Trigger only if the value changed by user - if (qualitySlider.value != qualityModel.qualitySliderActiveIndex && qualityModel.qualitySliderActiveIndex != -1) - { - // start updating with short delay - qualitySliderChangeTimer.start() - } - } - } - } - - MouseArea - { - id: speedSliderMouseArea - anchors.fill: parent - hoverEnabled: true - enabled: Cura.SimpleModeSettingsManager.isProfileUserCreated - - onEntered: - { - var content = catalog.i18nc("@tooltip", "A custom profile is currently active. To enable the quality slider, choose a default quality profile in Custom tab") - base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), content) - } - onExited: base.hideTooltip() - } - } - - UM.SimpleButton - { - id: customisedSettings - - visible: Cura.SimpleModeSettingsManager.isProfileCustomized || Cura.SimpleModeSettingsManager.isProfileUserCreated - height: Math.round(speedSlider.height * 0.8) - width: Math.round(speedSlider.height * 0.8) - - anchors.verticalCenter: speedSlider.verticalCenter - anchors.right: speedSlider.left - anchors.rightMargin: Math.round(UM.Theme.getSize("thick_margin").width / 2) - - color: hovered ? UM.Theme.getColor("setting_control_button_hover") : UM.Theme.getColor("setting_control_button"); - iconSource: UM.Theme.getIcon("reset"); - - onClicked: - { - // if the current profile is user-created, switch to a built-in quality - Cura.MachineManager.resetToUseDefaultQuality() - } - onEntered: - { - var content = catalog.i18nc("@tooltip","You have modified some profile settings. If you want to change these go to custom mode.") - base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), content) - } - onExited: base.hideTooltip() - } - } - - // - // Infill - // - Item - { - anchors.left: parent.left - anchors.right: parent.right - height: childrenRect.height - - Cura.IconWithText - { - id: infillRowTitle - source: UM.Theme.getIcon("category_infill") - text: catalog.i18nc("@label", "Infill") + " (%)" - anchors.bottom: parent.bottom - width: labelColumnWidth - } - - Item - { - id: infillCellRight - - height: infillSlider.height + UM.Theme.getSize("thick_margin").height + enableGradualInfillCheckBox.visible * (enableGradualInfillCheckBox.height + UM.Theme.getSize("thick_margin").height) - - anchors.left: infillRowTitle.right - anchors.right: parent.right - - Label - { - id: selectedInfillRateText - - anchors.left: infillSlider.left - anchors.right: parent.right - - text: parseInt(infillDensity.properties.value) + "%" - horizontalAlignment: Text.AlignLeft - - color: infillSlider.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") - } - - // We use a binding to make sure that after manually setting infillSlider.value it is still bound to the property provider - Binding - { - target: infillSlider - property: "value" - value: parseInt(infillDensity.properties.value) - } - - Slider - { - id: infillSlider - - anchors.top: selectedInfillRateText.bottom - anchors.left: parent.left - anchors.right: infillIcon.left - anchors.rightMargin: UM.Theme.getSize("thick_margin").width - - height: UM.Theme.getSize("thick_margin").height - width: parseInt(infillCellRight.width - UM.Theme.getSize("thick_margin").width - style.handleWidth) - - minimumValue: 0 - maximumValue: 100 - stepSize: 1 - tickmarksEnabled: true - - // disable slider when gradual support is enabled - enabled: parseInt(infillSteps.properties.value) == 0 - - // set initial value from stack - value: parseInt(infillDensity.properties.value) - - onValueChanged: - { - - // Don't round the value if it's already the same - if (parseInt(infillDensity.properties.value) == infillSlider.value) - { - return - } - - // Round the slider value to the nearest multiple of 10 (simulate step size of 10) - var roundedSliderValue = Math.round(infillSlider.value / 10) * 10 - - // Update the slider value to represent the rounded value - infillSlider.value = roundedSliderValue - - // Update value only if the Recomended mode is Active, - // Otherwise if I change the value in the Custom mode the Recomended view will try to repeat - // same operation - var active_mode = UM.Preferences.getValue("cura/active_mode") - - if (active_mode == 0 || active_mode == "simple") - { - Cura.MachineManager.setSettingForAllExtruders("infill_sparse_density", "value", roundedSliderValue) - Cura.MachineManager.resetSettingForAllExtruders("infill_line_distance") - } - } - - style: SliderStyle - { - groove: Rectangle - { - id: groove - implicitWidth: 200 * screenScaleFactor - implicitHeight: 2 * screenScaleFactor - color: control.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") - radius: 1 - } - - handle: Item - { - Rectangle - { - id: handleButton - anchors.centerIn: parent - color: control.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") - implicitWidth: 10 * screenScaleFactor - implicitHeight: 10 * screenScaleFactor - radius: 10 * screenScaleFactor - } - } - - tickmarks: Repeater - { - id: repeater - model: control.maximumValue / control.stepSize + 1 - - // check if a tick should be shown based on it's index and wether the infill density is a multiple of 10 (slider step size) - function shouldShowTick (index) - { - if (index % 10 == 0) - { - return true - } - return false - } - - Rectangle - { - anchors.verticalCenter: parent.verticalCenter - color: control.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") - width: 1 * screenScaleFactor - height: 6 * screenScaleFactor - x: Math.round(styleData.handleWidth / 2 + index * ((repeater.width - styleData.handleWidth) / (repeater.count-1))) - visible: shouldShowTick(index) - } - } - } - } - - Rectangle - { - id: infillIcon - - width: Math.round((parent.width / 5) - (UM.Theme.getSize("thick_margin").width)) - height: width - - anchors.right: parent.right - anchors.top: parent.top - anchors.topMargin: Math.round(UM.Theme.getSize("thick_margin").height / 2) - - // we loop over all density icons and only show the one that has the current density and steps - Repeater - { - id: infillIconList - model: infillModel - anchors.fill: parent - - function activeIndex () - { - for (var i = 0; i < infillModel.count; i++) - { - var density = Math.round(infillDensity.properties.value) - var steps = Math.round(infillSteps.properties.value) - var infillModelItem = infillModel.get(i) - - if (infillModelItem != "undefined" - && density >= infillModelItem.percentageMin - && density <= infillModelItem.percentageMax - && steps >= infillModelItem.stepsMin - && steps <= infillModelItem.stepsMax) - { - return i - } - } - return -1 - } - - Rectangle - { - anchors.fill: parent - visible: infillIconList.activeIndex() == index - - border.width: UM.Theme.getSize("default_lining").width - border.color: UM.Theme.getColor("quality_slider_unavailable") - - UM.RecolorImage - { - anchors.fill: parent - anchors.margins: 2 * screenScaleFactor - sourceSize.width: width - sourceSize.height: width - source: UM.Theme.getIcon(model.icon) - color: UM.Theme.getColor("quality_slider_unavailable") - } - } - } - } - - // Gradual Support Infill Checkbox - CheckBox - { - id: enableGradualInfillCheckBox - property alias _hovered: enableGradualInfillMouseArea.containsMouse - - anchors.top: infillSlider.bottom - anchors.topMargin: Math.round(UM.Theme.getSize("thick_margin").height / 2) // closer to slider since it belongs to the same category - anchors.left: infillCellRight.left - - style: UM.Theme.styles.checkbox - enabled: base.settingsEnabled - visible: infillSteps.properties.enabled == "True" - checked: parseInt(infillSteps.properties.value) > 0 - - MouseArea - { - id: enableGradualInfillMouseArea - - anchors.fill: parent - hoverEnabled: true - enabled: true - - property var previousInfillDensity: parseInt(infillDensity.properties.value) - - onClicked: - { - // Set to 90% only when enabling gradual infill - var newInfillDensity; - if (parseInt(infillSteps.properties.value) == 0) - { - previousInfillDensity = parseInt(infillDensity.properties.value) - newInfillDensity = 90 - } else { - newInfillDensity = previousInfillDensity - } - Cura.MachineManager.setSettingForAllExtruders("infill_sparse_density", "value", String(newInfillDensity)) - - var infill_steps_value = 0 - if (parseInt(infillSteps.properties.value) == 0) - { - infill_steps_value = 5 - } - - Cura.MachineManager.setSettingForAllExtruders("gradual_infill_steps", "value", infill_steps_value) - } - - onEntered: base.showTooltip(enableGradualInfillCheckBox, Qt.point(-infillCellRight.x, 0), - catalog.i18nc("@label", "Gradual infill will gradually increase the amount of infill towards the top.")) - - onExited: base.hideTooltip() - - } - - Label - { - id: gradualInfillLabel - height: parent.height - anchors.left: enableGradualInfillCheckBox.right - anchors.leftMargin: Math.round(UM.Theme.getSize("thick_margin").width / 2) - verticalAlignment: Text.AlignVCenter; - text: catalog.i18nc("@label", "Enable gradual") - font: UM.Theme.getFont("default") - color: UM.Theme.getColor("text") - } - } - - // Infill list model for mapping icon - ListModel - { - id: infillModel - Component.onCompleted: - { - infillModel.append({ - percentageMin: -1, - percentageMax: 0, - stepsMin: -1, - stepsMax: 0, - icon: "hollow" - }) - infillModel.append({ - percentageMin: 0, - percentageMax: 40, - stepsMin: -1, - stepsMax: 0, - icon: "sparse" - }) - infillModel.append({ - percentageMin: 40, - percentageMax: 89, - stepsMin: -1, - stepsMax: 0, - icon: "dense" - }) - infillModel.append({ - percentageMin: 90, - percentageMax: 9999999999, - stepsMin: -1, - stepsMax: 0, - icon: "solid" - }) - infillModel.append({ - percentageMin: 0, - percentageMax: 9999999999, - stepsMin: 1, - stepsMax: 9999999999, - icon: "gradual" - }) - } - } - } - } - - // - // Enable support - // - Row - { - anchors.left: parent.left - anchors.right: parent.right - height: childrenRect.height - - Cura.IconWithText - { - id: enableSupportLabel - visible: enableSupportCheckBox.visible - source: UM.Theme.getIcon("category_support") - text: catalog.i18nc("@label", "Support") - width: labelColumnWidth - } - - CheckBox - { - id: enableSupportCheckBox - property alias _hovered: enableSupportMouseArea.containsMouse - - style: UM.Theme.styles.checkbox - enabled: base.settingsEnabled - - visible: supportEnabled.properties.enabled == "True" - checked: supportEnabled.properties.value == "True" - - MouseArea - { - id: enableSupportMouseArea - anchors.fill: parent - hoverEnabled: true - onClicked: supportEnabled.setPropertyValue("value", supportEnabled.properties.value != "True") - - onEntered: base.showTooltip(enableSupportCheckBox, Qt.point(-enableSupportCheckBox.x, 0), - catalog.i18nc("@label", "Generate structures to support parts of the model which have overhangs. Without these structures, such parts would collapse during printing.")) - - onExited: base.hideTooltip() - - } - } - - ComboBox - { - id: supportExtruderCombobox - visible: enableSupportCheckBox.visible && (supportEnabled.properties.value == "True") && (extrudersEnabledCount.properties.value > 1) - model: extruderModel - - property string color_override: "" // for manually setting values - property string color: // is evaluated automatically, but the first time is before extruderModel being filled - { - var current_extruder = extruderModel.get(currentIndex); - color_override = ""; - if (current_extruder === undefined) return "" - return (current_extruder.color) ? current_extruder.color : ""; - } - - textRole: "text" // this solves that the combobox isn't populated in the first time Cura is started - - width: Math.round(UM.Theme.getSize("print_setup_widget").width * .55) - Math.round(UM.Theme.getSize("thick_margin").width / 2) - enableSupportCheckBox.width - height: ((supportEnabled.properties.value == "True") && (machineExtruderCount.properties.value > 1)) ? UM.Theme.getSize("setting_control").height : 0 - - Behavior on height { NumberAnimation { duration: 100 } } - - style: UM.Theme.styles.combobox_color - enabled: base.settingsEnabled - property alias _hovered: supportExtruderMouseArea.containsMouse - - currentIndex: - { - if (supportExtruderNr.properties == null) - { - return Cura.MachineManager.defaultExtruderPosition - } - else - { - var extruder = parseInt(supportExtruderNr.properties.value) - if ( extruder === -1) - { - return Cura.MachineManager.defaultExtruderPosition - } - return extruder; - } - } - - onActivated: supportExtruderNr.setPropertyValue("value", String(index)) - - MouseArea - { - id: supportExtruderMouseArea - anchors.fill: parent - hoverEnabled: true - enabled: base.settingsEnabled - acceptedButtons: Qt.NoButton - onEntered: - { - base.showTooltip(supportExtruderCombobox, Qt.point(-supportExtruderCombobox.x, 0), - catalog.i18nc("@label", "Select which extruder to use for support. This will build up supporting structures below the model to prevent the model from sagging or printing in mid air.")); - } - onExited: base.hideTooltip() - - } - - function updateCurrentColor() - { - var current_extruder = extruderModel.get(currentIndex) - if (current_extruder !== undefined) - { - supportExtruderCombobox.color_override = current_extruder.color - } - } - - } - } - - // Adhesion - Row - { - anchors.left: parent.left - anchors.right: parent.right - height: childrenRect.height - - Cura.IconWithText - { - id: adhesionHelperLabel - visible: adhesionCheckBox.visible - source: UM.Theme.getIcon("category_adhesion") - text: catalog.i18nc("@label", "Adhesion") - width: labelColumnWidth - } - - CheckBox - { - id: adhesionCheckBox - property alias _hovered: adhesionMouseArea.containsMouse - - //: Setting enable printing build-plate adhesion helper checkbox - style: UM.Theme.styles.checkbox - enabled: base.settingsEnabled - - visible: platformAdhesionType.properties.enabled == "True" - checked: platformAdhesionType.properties.value != "skirt" && platformAdhesionType.properties.value != "none" - - MouseArea - { - id: adhesionMouseArea - anchors.fill: parent - hoverEnabled: true - enabled: base.settingsEnabled - onClicked: - { - var adhesionType = "skirt" - if(!parent.checked) - { - // Remove the "user" setting to see if the rest of the stack prescribes a brim or a raft - platformAdhesionType.removeFromContainer(0) - adhesionType = platformAdhesionType.properties.value - if(adhesionType == "skirt" || adhesionType == "none") - { - // If the rest of the stack doesn't prescribe an adhesion-type, default to a brim - adhesionType = "brim" - } - } - platformAdhesionType.setPropertyValue("value", adhesionType) - } - onEntered: - { - base.showTooltip(adhesionCheckBox, Qt.point(-adhesionCheckBox.x, 0), - catalog.i18nc("@label", "Enable printing a brim or raft. This will add a flat area around or under your object which is easy to cut off afterwards.")); - } - onExited: base.hideTooltip() - } - } - } - - ListModel - { - id: extruderModel - Component.onCompleted: populateExtruderModel() - } - - //: Model used to populate the extrudelModel - Cura.ExtrudersModel - { - id: extruders - onModelChanged: populateExtruderModel() - } - - UM.SettingPropertyProvider - { - id: infillExtruderNumber - containerStackId: Cura.MachineManager.activeStackId - key: "infill_extruder_nr" - watchedProperties: [ "value" ] - storeIndex: 0 - } - - UM.SettingPropertyProvider - { - id: infillDensity - containerStackId: Cura.MachineManager.activeStackId - key: "infill_sparse_density" - watchedProperties: [ "value" ] - storeIndex: 0 - } - - UM.SettingPropertyProvider - { - id: infillSteps - containerStackId: Cura.MachineManager.activeStackId - key: "gradual_infill_steps" - watchedProperties: ["value", "enabled"] - storeIndex: 0 - } - - UM.SettingPropertyProvider - { - id: platformAdhesionType - containerStack: Cura.MachineManager.activeMachine - removeUnusedValue: false //Doesn't work with settings that are resolved. - key: "adhesion_type" - watchedProperties: [ "value", "enabled" ] - storeIndex: 0 - } - - UM.SettingPropertyProvider - { - id: supportEnabled - containerStack: Cura.MachineManager.activeMachine - key: "support_enable" - watchedProperties: [ "value", "enabled", "description" ] - storeIndex: 0 - } - - UM.SettingPropertyProvider - { - id: extrudersEnabledCount - containerStack: Cura.MachineManager.activeMachine - key: "extruders_enabled_count" - watchedProperties: [ "value" ] - storeIndex: 0 - } - - UM.SettingPropertyProvider - { - id: supportExtruderNr - containerStack: Cura.MachineManager.activeMachine - key: "support_extruder_nr" - watchedProperties: [ "value" ] - storeIndex: 0 - } - - function populateExtruderModel() - { - extruderModel.clear() - for (var extruderNumber = 0; extruderNumber < extruders.rowCount(); extruderNumber++) - { - extruderModel.append({ - text: extruders.getItem(extruderNumber).name, - color: extruders.getItem(extruderNumber).color - }) - } - supportExtruderCombobox.updateCurrentColor() - } -} diff --git a/resources/qml/qmldir b/resources/qml/qmldir index 6db8e0c544..c0a8bac0ae 100644 --- a/resources/qml/qmldir +++ b/resources/qml/qmldir @@ -14,4 +14,5 @@ OutputDevicesActionButton 1.0 OutputDevicesActionButton.qml ExpandableComponent 1.0 ExpandableComponent.qml PrinterTypeLabel 1.0 PrinterTypeLabel.qml ViewsSelector 1.0 ViewsSelector.qml -ToolbarButton 1.0 ToolbarButton.qml \ No newline at end of file +ToolbarButton 1.0 ToolbarButton.qml +SettingView 1.0 SettingView.qml \ No newline at end of file From 1a778b30782f1e6c19aeca2f4882936d98d9c3c6 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Fri, 30 Nov 2018 14:18:07 +0100 Subject: [PATCH 20/70] Fix qualiy slider alignments Contributes to CURA-5941. --- .../qml/MonitorBuildplateConfiguration.qml | 2 +- .../PrintSetupSelectorContents.qml | 27 +- .../RecommendedQualityProfileSelector.qml | 391 ++++++++++-------- resources/themes/cura-light/theme.json | 8 +- 4 files changed, 241 insertions(+), 187 deletions(-) diff --git a/plugins/UM3NetworkPrinting/resources/qml/MonitorBuildplateConfiguration.qml b/plugins/UM3NetworkPrinting/resources/qml/MonitorBuildplateConfiguration.qml index 9ffb1eabb4..75cbf3b11d 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/MonitorBuildplateConfiguration.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/MonitorBuildplateConfiguration.qml @@ -27,7 +27,7 @@ Item Row { height: parent.height - spacing: 12 * screenScaleFactor // TODO: Theme! (Should be same as extruder spacing) + spacing: UM.Theme.getSize("print_setup_slider_handle").width // TODO: Theme! (Should be same as extruder spacing) // This wrapper ensures that the buildplate icon is located centered // below an extruder icon. diff --git a/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml b/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml index f21253acd7..5f22e4c337 100644 --- a/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml +++ b/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml @@ -114,19 +114,20 @@ Item onHideTooltip: base.hideTooltip() visible: currentModeIndex == 0 } -// -// CustomPrintSetup -// { -// anchors -// { -// left: parent.left -// right: parent.right -// top: parent.top -// } -// onShowTooltip: base.showTooltip(item, location, text) -// onHideTooltip: base.hideTooltip() -// visible: currentModeIndex == 1 -// } + + CustomPrintSetup + { + anchors + { + left: parent.left + right: parent.right + top: parent.top + } + height: 500 + onShowTooltip: base.showTooltip(item, location, text) + onHideTooltip: base.hideTooltip() + visible: currentModeIndex == 1 + } } Rectangle diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml index 3bf93c0c07..c7a9439b00 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml @@ -124,22 +124,27 @@ Item function calculateSliderStepWidth (totalTicks) { - qualityModel.qualitySliderStepWidth = totalTicks != 0 ? Math.round((settingsColumnWidth) / (totalTicks)) : 0 + // Do not use Math.round otherwise the tickmarks won't be aligned + qualityModel.qualitySliderStepWidth = totalTicks != 0 ? + ((settingsColumnWidth - UM.Theme.getSize("print_setup_slider_handle").width) / (totalTicks)) : 0 } function calculateSliderMargins (availableMin, availableMax, totalTicks) { if (availableMin == -1 || (availableMin == 0 && availableMax == 0)) { - qualityModel.qualitySliderMarginRight = Math.round(settingsColumnWidth) + // Do not use Math.round otherwise the tickmarks won't be aligned + qualityModel.qualitySliderMarginRight = settingsColumnWidth } else if (availableMin == availableMax) { - qualityModel.qualitySliderMarginRight = Math.round((totalTicks - availableMin) * qualitySliderStepWidth) + // Do not use Math.round otherwise the tickmarks won't be aligned + qualityModel.qualitySliderMarginRight = (totalTicks - availableMin) * qualitySliderStepWidth } else { - qualityModel.qualitySliderMarginRight = Math.round((totalTicks - availableMax) * qualitySliderStepWidth) + // Do not use Math.round otherwise the tickmarks won't be aligned + qualityModel.qualitySliderMarginRight = (totalTicks - availableMax) * qualitySliderStepWidth } } @@ -162,20 +167,6 @@ Item width: labelColumnWidth } - //Print speed slider - Rectangle - { - id: speedSlider - - anchors - { - left: qualityRowTitle.right - right: parent.right - } - - color: "green" - height: 20 - } // // // Show titles for the each quality slider ticks // Item @@ -240,104 +231,107 @@ Item // } // } // -// //Print speed slider -// Rectangle -// { -// id: speedSlider + //Print speed slider + Rectangle + { + id: speedSlider + + anchors + { + left: qualityRowTitle.right + right: parent.right + } + + color: "green" + height: childrenRect.height + + // This Item is used only for tooltip, for slider area which is unavailable +// Item +// { +// function showTooltip (showTooltip) +// { +// if (showTooltip) +// { +// var content = catalog.i18nc("@tooltip", "This quality profile is not available for you current material and nozzle configuration. Please change these to enable this quality profile") +// base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), content) +// } +// else +// { +// base.hideTooltip() +// } +// } // -// anchors -// { -// left: qualityRowTitle.right -// right: parent.right -// } +// id: unavailableLineToolTip +// height: 20 * screenScaleFactor // hovered area height +// z: parent.z + 1 // should be higher, otherwise the area can be hovered +// x: 0 +// anchors.verticalCenter: qualitySlider.verticalCenter // -// // This Item is used only for tooltip, for slider area which is unavailable -//// Item -//// { -//// function showTooltip (showTooltip) -//// { -//// if (showTooltip) -//// { -//// var content = catalog.i18nc("@tooltip", "This quality profile is not available for you current material and nozzle configuration. Please change these to enable this quality profile") -//// base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), content) -//// } -//// else -//// { -//// base.hideTooltip() -//// } -//// } -//// -//// id: unavailableLineToolTip -//// height: 20 * screenScaleFactor // hovered area height -//// z: parent.z + 1 // should be higher, otherwise the area can be hovered -//// x: 0 -//// anchors.verticalCenter: qualitySlider.verticalCenter -//// -//// Rectangle -//// { -//// id: leftArea -//// width: -//// { -//// if (qualityModel.availableTotalTicks == 0) -//// { -//// return qualityModel.qualitySliderStepWidth * qualityModel.totalTicks -//// } -//// return qualityModel.qualitySliderStepWidth * qualityModel.qualitySliderAvailableMin - 10 -//// } -//// height: parent.height -//// color: "transparent" -//// -//// MouseArea -//// { -//// anchors.fill: parent -//// hoverEnabled: true -//// enabled: Cura.SimpleModeSettingsManager.isProfileUserCreated == false -//// onEntered: unavailableLineToolTip.showTooltip(true) -//// onExited: unavailableLineToolTip.showTooltip(false) -//// } -//// } -//// -//// Item -//// { -//// id: rightArea -//// width: -//// { -//// if(qualityModel.availableTotalTicks == 0) -//// return 0 -//// -//// return qualityModel.qualitySliderMarginRight - 10 -//// } -//// height: parent.height -//// x: -//// { -//// if (qualityModel.availableTotalTicks == 0) -//// { -//// return 0 -//// } -//// -//// var leftUnavailableArea = qualityModel.qualitySliderStepWidth * qualityModel.qualitySliderAvailableMin -//// var totalGap = qualityModel.qualitySliderStepWidth * (qualityModel.availableTotalTicks -1) + leftUnavailableArea + 10 -//// -//// return totalGap -//// } -//// -//// MouseArea -//// { -//// anchors.fill: parent -//// hoverEnabled: true -//// enabled: Cura.SimpleModeSettingsManager.isProfileUserCreated == false -//// onEntered: unavailableLineToolTip.showTooltip(true) -//// onExited: unavailableLineToolTip.showTooltip(false) -//// } -//// } -//// } +// Rectangle +// { +// id: leftArea +// width: +// { +// if (qualityModel.availableTotalTicks == 0) +// { +// return qualityModel.qualitySliderStepWidth * qualityModel.totalTicks +// } +// return qualityModel.qualitySliderStepWidth * qualityModel.qualitySliderAvailableMin - 10 +// } +// height: parent.height +// color: "transparent" // +// MouseArea +// { +// anchors.fill: parent +// hoverEnabled: true +// enabled: Cura.SimpleModeSettingsManager.isProfileUserCreated == false +// onEntered: unavailableLineToolTip.showTooltip(true) +// onExited: unavailableLineToolTip.showTooltip(false) +// } +// } +// +// Item +// { +// id: rightArea +// width: +// { +// if(qualityModel.availableTotalTicks == 0) +// return 0 +// +// return qualityModel.qualitySliderMarginRight - 10 +// } +// height: parent.height +// x: +// { +// if (qualityModel.availableTotalTicks == 0) +// { +// return 0 +// } +// +// var leftUnavailableArea = qualityModel.qualitySliderStepWidth * qualityModel.qualitySliderAvailableMin +// var totalGap = qualityModel.qualitySliderStepWidth * (qualityModel.availableTotalTicks -1) + leftUnavailableArea + 10 +// +// return totalGap +// } +// +// MouseArea +// { +// anchors.fill: parent +// hoverEnabled: true +// enabled: Cura.SimpleModeSettingsManager.isProfileUserCreated == false +// onEntered: unavailableLineToolTip.showTooltip(true) +// onExited: unavailableLineToolTip.showTooltip(false) +// } +// } +// } + // // Draw Unavailable line // Rectangle // { // id: groovechildrect // width: parent.width -// height: 2 * screenScaleFactor +// height: 2 * UM.Theme.getSize("default_lining").height // color: UM.Theme.getColor("quality_slider_unavailable") // anchors.verticalCenter: qualitySlider.verticalCenter // @@ -358,66 +352,125 @@ Item // } // } // } -// -// // Draw available slider -// Slider -// { -// id: qualitySlider -// height: UM.Theme.getSize("thick_margin").height -// anchors.bottom: parent.bottom -// enabled: qualityModel.totalTicks > 0 && !Cura.SimpleModeSettingsManager.isProfileCustomized -// visible: qualityModel.availableTotalTicks > 0 -// updateValueWhileDragging : false -// -// minimumValue: qualityModel.qualitySliderAvailableMin >= 0 ? qualityModel.qualitySliderAvailableMin : 0 -// // maximumValue must be greater than minimumValue to be able to see the handle. While the value is strictly -// // speaking not always correct, it seems to have the correct behavior (switching from 0 available to 1 available) -// maximumValue: qualityModel.qualitySliderAvailableMax >= 1 ? qualityModel.qualitySliderAvailableMax : 1 -// stepSize: 1 -// -// value: qualityModel.qualitySliderActiveIndex -// -// width: qualityModel.qualitySliderStepWidth * (qualityModel.availableTotalTicks - 1) -// -// anchors.right: parent.right -// anchors.rightMargin: qualityModel.qualitySliderMarginRight -// -// style: SliderStyle -// { -// //Draw Available line -// groove: Rectangle -// { -// implicitHeight: 2 * screenScaleFactor -// color: UM.Theme.getColor("quality_slider_available") -// radius: Math.round(height / 2) -// } -// -// handle: Rectangle -// { -// id: qualityhandleButton -// color: UM.Theme.getColor("quality_slider_available") -// implicitWidth: 12 * screenScaleFactor -// implicitHeight: implicitWidth -// radius: Math.round(implicitWidth / 2) -// visible: !Cura.SimpleModeSettingsManager.isProfileCustomized && !Cura.SimpleModeSettingsManager.isProfileUserCreated && qualityModel.existingQualityProfile -// } -// } -// -// onValueChanged: -// { -// // only change if an active machine is set and the slider is visible at all. -// if (Cura.MachineManager.activeMachine != null && visible) -// { -// // prevent updating during view initializing. Trigger only if the value changed by user -// if (qualitySlider.value != qualityModel.qualitySliderActiveIndex && qualityModel.qualitySliderActiveIndex != -1) -// { -// // start updating with short delay -// qualitySliderChangeTimer.start() -// } -// } -// } -// } -// + + // Draw unavailable slider + Slider + { + id: unavailableSlider + height: UM.Theme.getSize("thick_margin").height + updateValueWhileDragging : false + tickmarksEnabled: true + + minimumValue: 0 + // maximumValue must be greater than minimumValue to be able to see the handle. While the value is strictly + // speaking not always correct, it seems to have the correct behavior (switching from 0 available to 1 available) + maximumValue: qualityModel.totalTicks + stepSize: 1 + + width: parent.width + + style: SliderStyle + { + //Draw Unvailable line + groove: Item + { + Rectangle + { + height: UM.Theme.getSize("print_setup_slider_groove").height + width: control.width - UM.Theme.getSize("print_setup_slider_handle").width + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + color: UM.Theme.getColor("quality_slider_unavailable") + } + } + + handle: Item {} + + tickmarks: Repeater + { + id: qualityRepeater + model: qualityModel.totalTicks > 0 ? qualityModel : 0 + + Rectangle + { + color: Cura.QualityProfilesDropDownMenuModel.getItem(index).available ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") + implicitWidth: UM.Theme.getSize("print_setup_slider_tickmarks").width + implicitHeight: UM.Theme.getSize("print_setup_slider_tickmarks").height + anchors.verticalCenter: parent.verticalCenter + + // Do not use Math.round otherwise the tickmarks won't be aligned + x: ((UM.Theme.getSize("print_setup_slider_handle").width / 2) - (UM.Theme.getSize("print_setup_slider_tickmarks").width / 2) + (qualityModel.qualitySliderStepWidth * index)) + radius: Math.round(implicitWidth / 2) + } + } + } + } + + // Draw available slider + Slider + { + id: qualitySlider + height: UM.Theme.getSize("thick_margin").height + enabled: qualityModel.totalTicks > 0 && !Cura.SimpleModeSettingsManager.isProfileCustomized + visible: qualityModel.availableTotalTicks > 0 + updateValueWhileDragging : false + + minimumValue: qualityModel.qualitySliderAvailableMin >= 0 ? qualityModel.qualitySliderAvailableMin : 0 + // maximumValue must be greater than minimumValue to be able to see the handle. While the value is strictly + // speaking not always correct, it seems to have the correct behavior (switching from 0 available to 1 available) + maximumValue: qualityModel.qualitySliderAvailableMax >= 1 ? qualityModel.qualitySliderAvailableMax : 1 + stepSize: 1 + + value: qualityModel.qualitySliderActiveIndex + + width: qualityModel.qualitySliderStepWidth * (qualityModel.availableTotalTicks - 1) + UM.Theme.getSize("print_setup_slider_handle").width + + anchors.right: parent.right + anchors.rightMargin: qualityModel.qualitySliderMarginRight + + style: SliderStyle + { + // Draw Available line + groove: Item + { + Rectangle + { + height: UM.Theme.getSize("print_setup_slider_groove").height + width: control.width - UM.Theme.getSize("print_setup_slider_handle").width + anchors.verticalCenter: parent.verticalCenter + + // Do not use Math.round otherwise the tickmarks won't be aligned + x: UM.Theme.getSize("print_setup_slider_handle").width / 2 + color: UM.Theme.getColor("quality_slider_available") + } + } + + handle: Rectangle + { + id: qualityhandleButton + color: UM.Theme.getColor("primary") + implicitWidth: UM.Theme.getSize("print_setup_slider_handle").width + implicitHeight: implicitWidth + radius: Math.round(implicitWidth / 2) + visible: !Cura.SimpleModeSettingsManager.isProfileCustomized && !Cura.SimpleModeSettingsManager.isProfileUserCreated && qualityModel.existingQualityProfile + } + } + + onValueChanged: + { + // only change if an active machine is set and the slider is visible at all. + if (Cura.MachineManager.activeMachine != null && visible) + { + // prevent updating during view initializing. Trigger only if the value changed by user + if (qualitySlider.value != qualityModel.qualitySliderActiveIndex && qualityModel.qualitySliderActiveIndex != -1) + { + // start updating with short delay + qualitySliderChangeTimer.start() + } + } + } + } + // MouseArea // { // id: speedSliderMouseArea @@ -432,7 +485,7 @@ Item // } // onExited: base.hideTooltip() // } -// } + } // // UM.SimpleButton // { diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index dfaa9008f7..9bf0bf19aa 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -373,6 +373,9 @@ "print_setup_item": [0.0, 2.0], "print_setup_extruder_box": [0.0, 6.0], "print_setup_widget_header": [0.0, 3.0], + "print_setup_slider_groove": [0.16, 0.16], + "print_setup_slider_handle": [1.0, 1.0], + "print_setup_slider_tickmarks": [0.32, 0.32], "configuration_selector_mode_tabs": [0.0, 3.0], @@ -521,9 +524,6 @@ "monitor_thick_lining": [0.16, 0.16], "monitor_corner_radius": [0.3, 0.3], "monitor_shadow_radius": [0.4, 0.4], - "monitor_shadow_offset": [0.15, 0.15], - - "print_setup_action_button": [13, 5], - "print_setup_content_top_margin": [3, 3] + "monitor_shadow_offset": [0.15, 0.15] } } From 73568d74737fb32006ece5355c6ef4c13ce97ae7 Mon Sep 17 00:00:00 2001 From: Aleksei S Date: Fri, 30 Nov 2018 14:51:55 +0100 Subject: [PATCH 21/70] Added icon to the search field which filters settings CURA-5941 --- resources/qml/Settings/SettingView.qml | 4 ++-- resources/themes/cura-light/icons/search.svg | 25 ++++++++++++++++---- resources/themes/cura-light/theme.json | 1 + 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/resources/qml/Settings/SettingView.qml b/resources/qml/Settings/SettingView.qml index 8a336a7ed1..0a7102ff45 100644 --- a/resources/qml/Settings/SettingView.qml +++ b/resources/qml/Settings/SettingView.qml @@ -105,12 +105,12 @@ Item anchors.right: clearFilterButton.left anchors.rightMargin: Math.round(UM.Theme.getSize("thick_margin").width) - placeholderText: catalog.i18nc("@label:textbox", "Search...") + placeholderText: "" + "
" + catalog.i18nc("@label:textbox", "search settings") style: TextFieldStyle { textColor: UM.Theme.getColor("setting_control_text"); - placeholderTextColor: UM.Theme.getColor("setting_control_text") + placeholderTextColor: UM.Theme.getColor("setting_filter_field") font: UM.Theme.getFont("default"); background: Item {} } diff --git a/resources/themes/cura-light/icons/search.svg b/resources/themes/cura-light/icons/search.svg index 8272991300..a9ccb612fd 100644 --- a/resources/themes/cura-light/icons/search.svg +++ b/resources/themes/cura-light/icons/search.svg @@ -1,4 +1,21 @@ - - - + + + + Shape + Created with Sketch. + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index dfaa9008f7..4e39ffdf22 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -221,6 +221,7 @@ "setting_validation_warning_background": [255, 145, 62, 255], "setting_validation_warning": [127, 127, 127, 255], "setting_validation_ok": [255, 255, 255, 255], + "setting_filter_field" : [153, 153, 153, 255], "material_compatibility_warning": [0, 0, 0, 255], From 1fbcff2cb9a0df2b35c054ffef638e863eeb54f4 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Fri, 30 Nov 2018 15:06:53 +0100 Subject: [PATCH 22/70] Fix the tooltips in the profile selector in the recommended mode Contributes to CURA-5941. --- .../Recommended/RecommendedPrintSetup.qml | 4 +- .../RecommendedQualityProfileSelector.qml | 226 ++++++------------ 2 files changed, 70 insertions(+), 160 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml index 2d4308c8be..40a1910c69 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml @@ -8,7 +8,7 @@ import QtQuick.Controls.Styles 1.4 import UM 1.2 as UM import Cura 1.0 as Cura -Rectangle +Item { id: base @@ -16,8 +16,6 @@ Rectangle signal hideTooltip() // width: parent.width height: childrenRect.height + 2 * padding - color: "red" - opacity: 0.5 property Action configureSettings diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml index c7a9439b00..755af9311f 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml @@ -163,7 +163,6 @@ Item id: qualityRowTitle source: UM.Theme.getIcon("category_layer_height") text: catalog.i18nc("@label", "Layer Height") -// anchors.bottom: speedSlider.bottom width: labelColumnWidth } @@ -232,9 +231,10 @@ Item // } // //Print speed slider - Rectangle + Item { id: speedSlider + height: childrenRect.height anchors { @@ -242,122 +242,11 @@ Item right: parent.right } - color: "green" - height: childrenRect.height - - // This Item is used only for tooltip, for slider area which is unavailable -// Item -// { -// function showTooltip (showTooltip) -// { -// if (showTooltip) -// { -// var content = catalog.i18nc("@tooltip", "This quality profile is not available for you current material and nozzle configuration. Please change these to enable this quality profile") -// base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), content) -// } -// else -// { -// base.hideTooltip() -// } -// } -// -// id: unavailableLineToolTip -// height: 20 * screenScaleFactor // hovered area height -// z: parent.z + 1 // should be higher, otherwise the area can be hovered -// x: 0 -// anchors.verticalCenter: qualitySlider.verticalCenter -// -// Rectangle -// { -// id: leftArea -// width: -// { -// if (qualityModel.availableTotalTicks == 0) -// { -// return qualityModel.qualitySliderStepWidth * qualityModel.totalTicks -// } -// return qualityModel.qualitySliderStepWidth * qualityModel.qualitySliderAvailableMin - 10 -// } -// height: parent.height -// color: "transparent" -// -// MouseArea -// { -// anchors.fill: parent -// hoverEnabled: true -// enabled: Cura.SimpleModeSettingsManager.isProfileUserCreated == false -// onEntered: unavailableLineToolTip.showTooltip(true) -// onExited: unavailableLineToolTip.showTooltip(false) -// } -// } -// -// Item -// { -// id: rightArea -// width: -// { -// if(qualityModel.availableTotalTicks == 0) -// return 0 -// -// return qualityModel.qualitySliderMarginRight - 10 -// } -// height: parent.height -// x: -// { -// if (qualityModel.availableTotalTicks == 0) -// { -// return 0 -// } -// -// var leftUnavailableArea = qualityModel.qualitySliderStepWidth * qualityModel.qualitySliderAvailableMin -// var totalGap = qualityModel.qualitySliderStepWidth * (qualityModel.availableTotalTicks -1) + leftUnavailableArea + 10 -// -// return totalGap -// } -// -// MouseArea -// { -// anchors.fill: parent -// hoverEnabled: true -// enabled: Cura.SimpleModeSettingsManager.isProfileUserCreated == false -// onEntered: unavailableLineToolTip.showTooltip(true) -// onExited: unavailableLineToolTip.showTooltip(false) -// } -// } -// } - -// // Draw Unavailable line -// Rectangle -// { -// id: groovechildrect -// width: parent.width -// height: 2 * UM.Theme.getSize("default_lining").height -// color: UM.Theme.getColor("quality_slider_unavailable") -// anchors.verticalCenter: qualitySlider.verticalCenter -// -// // Draw ticks -// Repeater -// { -// id: qualityRepeater -// model: qualityModel.totalTicks > 0 ? qualityModel : 0 -// -// Rectangle -// { -// color: Cura.QualityProfilesDropDownMenuModel.getItem(index).available ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") -// implicitWidth: 4 * screenScaleFactor -// implicitHeight: implicitWidth -// anchors.verticalCenter: parent.verticalCenter -// x: Math.round(qualityModel.qualitySliderStepWidth * index) -// radius: Math.round(implicitWidth / 2) -// } -// } -// } - // Draw unavailable slider Slider { id: unavailableSlider - height: UM.Theme.getSize("thick_margin").height + height: qualitySlider.height // Same height as the slider that is on top updateValueWhileDragging : false tickmarksEnabled: true @@ -404,13 +293,27 @@ Item } } } + + // Create a mouse area on top of the unavailable profiles to show a specific tooltip + MouseArea + { + anchors.fill: parent + hoverEnabled: true + enabled: !Cura.SimpleModeSettingsManager.isProfileUserCreated + onEntered: + { + var tooltipContent: catalog.i18nc("@tooltip", "This quality profile is not available for you current material and nozzle configuration. Please change these to enable this quality profile") + base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), unavailableSlider.tooltipContent) + } + onExited: base.hideTooltip() + } } // Draw available slider Slider { id: qualitySlider - height: UM.Theme.getSize("thick_margin").height + height: UM.Theme.getSize("print_setup_slider_handle").height // The handle is the widest element of the slider enabled: qualityModel.totalTicks > 0 && !Cura.SimpleModeSettingsManager.isProfileCustomized visible: qualityModel.availableTotalTicks > 0 updateValueWhileDragging : false @@ -469,49 +372,58 @@ Item } } } + + // This mouse area is only used to capture the onHover state and don't propagate it to the unavailable mouse area + MouseArea + { + anchors.fill: parent + hoverEnabled: true + enabled: !Cura.SimpleModeSettingsManager.isProfileUserCreated + } } -// MouseArea -// { -// id: speedSliderMouseArea -// anchors.fill: parent -// hoverEnabled: true -// enabled: Cura.SimpleModeSettingsManager.isProfileUserCreated -// -// onEntered: -// { -// var content = catalog.i18nc("@tooltip", "A custom profile is currently active. To enable the quality slider, choose a default quality profile in Custom tab") -// base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), content) -// } -// onExited: base.hideTooltip() -// } + // This mouse area will only take the mouse events and show a tooltip when the profile in use is + // a user created profile + MouseArea + { + anchors.fill: parent + hoverEnabled: true + visible: Cura.SimpleModeSettingsManager.isProfileUserCreated + + onEntered: + { + var content = catalog.i18nc("@tooltip", "A custom profile is currently active. To enable the quality slider, choose a default quality profile in Custom tab") + base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), content) + } + onExited: base.hideTooltip() + } + } + + UM.SimpleButton + { + id: customisedSettings + + visible: Cura.SimpleModeSettingsManager.isProfileCustomized || Cura.SimpleModeSettingsManager.isProfileUserCreated + height: Math.round(speedSlider.height * 0.8) + width: Math.round(speedSlider.height * 0.8) + + anchors.verticalCenter: speedSlider.verticalCenter + anchors.right: speedSlider.left + anchors.rightMargin: Math.round(UM.Theme.getSize("thick_margin").width / 2) + + color: hovered ? UM.Theme.getColor("setting_control_button_hover") : UM.Theme.getColor("setting_control_button"); + iconSource: UM.Theme.getIcon("reset"); + + onClicked: + { + // if the current profile is user-created, switch to a built-in quality + Cura.MachineManager.resetToUseDefaultQuality() + } + onEntered: + { + var content = catalog.i18nc("@tooltip","You have modified some profile settings. If you want to change these go to custom mode.") + base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), content) + } + onExited: base.hideTooltip() } -// -// UM.SimpleButton -// { -// id: customisedSettings -// -// visible: Cura.SimpleModeSettingsManager.isProfileCustomized || Cura.SimpleModeSettingsManager.isProfileUserCreated -// height: Math.round(speedSlider.height * 0.8) -// width: Math.round(speedSlider.height * 0.8) -// -// anchors.verticalCenter: speedSlider.verticalCenter -// anchors.right: speedSlider.left -// anchors.rightMargin: Math.round(UM.Theme.getSize("thick_margin").width / 2) -// -// color: hovered ? UM.Theme.getColor("setting_control_button_hover") : UM.Theme.getColor("setting_control_button"); -// iconSource: UM.Theme.getIcon("reset"); -// -// onClicked: -// { -// // if the current profile is user-created, switch to a built-in quality -// Cura.MachineManager.resetToUseDefaultQuality() -// } -// onEntered: -// { -// var content = catalog.i18nc("@tooltip","You have modified some profile settings. If you want to change these go to custom mode.") -// base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), content) -// } -// onExited: base.hideTooltip() -// } } \ No newline at end of file From 47b7d7bed8f1953297a78628ec7571e40c1cef78 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Fri, 30 Nov 2018 15:17:59 +0100 Subject: [PATCH 23/70] Make the slider available for clicking This was accidentally removed in the previous commit. Contributes to CURA-5941. --- .../RecommendedQualityProfileSelector.qml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml index 755af9311f..50da35814c 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml @@ -231,6 +231,8 @@ Item // } // //Print speed slider + // Two sliders are created, one at the bottom with the unavailable qualities + // and the other at the top with the available quality profiles and so the handle to select them. Item { id: speedSlider @@ -302,8 +304,8 @@ Item enabled: !Cura.SimpleModeSettingsManager.isProfileUserCreated onEntered: { - var tooltipContent: catalog.i18nc("@tooltip", "This quality profile is not available for you current material and nozzle configuration. Please change these to enable this quality profile") - base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), unavailableSlider.tooltipContent) + var tooltipContent = catalog.i18nc("@tooltip", "This quality profile is not available for you current material and nozzle configuration. Please change these to enable this quality profile") + base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), tooltipContent) } onExited: base.hideTooltip() } @@ -378,6 +380,7 @@ Item { anchors.fill: parent hoverEnabled: true + acceptedButtons: Qt.NoButton enabled: !Cura.SimpleModeSettingsManager.isProfileUserCreated } } @@ -392,8 +395,8 @@ Item onEntered: { - var content = catalog.i18nc("@tooltip", "A custom profile is currently active. To enable the quality slider, choose a default quality profile in Custom tab") - base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), content) + var tooltipContent = catalog.i18nc("@tooltip", "A custom profile is currently active. To enable the quality slider, choose a default quality profile in Custom tab") + base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), tooltipContent) } onExited: base.hideTooltip() } @@ -421,8 +424,8 @@ Item } onEntered: { - var content = catalog.i18nc("@tooltip","You have modified some profile settings. If you want to change these go to custom mode.") - base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), content) + var tooltipContent = catalog.i18nc("@tooltip","You have modified some profile settings. If you want to change these go to custom mode.") + base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), tooltipContent) } onExited: base.hideTooltip() } From 2c5f5170c2d05f5ffce1da5c471ff14b8289cc5b Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Fri, 30 Nov 2018 15:38:28 +0100 Subject: [PATCH 24/70] Add the labels of the layer height to the slider Contributes to CURA-5941. --- .../RecommendedQualityProfileSelector.qml | 205 +++++++++--------- 1 file changed, 108 insertions(+), 97 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml index 50da35814c..f7e1d870c9 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml @@ -158,78 +158,116 @@ Item } } - Cura.IconWithText + Item { - id: qualityRowTitle - source: UM.Theme.getIcon("category_layer_height") - text: catalog.i18nc("@label", "Layer Height") + id: titleRow width: labelColumnWidth + height: childrenRect.height + + Cura.IconWithText + { + id: qualityRowTitle + source: UM.Theme.getIcon("category_layer_height") + text: catalog.i18nc("@label", "Layer Height") + anchors.left: parent.left + anchors.right: customisedSettings.left + } + + UM.SimpleButton + { + id: customisedSettings + + visible: Cura.SimpleModeSettingsManager.isProfileCustomized || Cura.SimpleModeSettingsManager.isProfileUserCreated + height: visible ? Math.round(0.8 * qualityRowTitle.height) : 0 + width: height + anchors + { + right: parent.right + rightMargin: UM.Theme.getSize("default_margin").width + leftMargin: UM.Theme.getSize("default_margin").width + verticalCenter: parent.verticalCenter + } + + color: hovered ? UM.Theme.getColor("setting_control_button_hover") : UM.Theme.getColor("setting_control_button") + iconSource: UM.Theme.getIcon("reset") + + onClicked: + { + // if the current profile is user-created, switch to a built-in quality + Cura.MachineManager.resetToUseDefaultQuality() + } + onEntered: + { + var tooltipContent = catalog.i18nc("@tooltip","You have modified some profile settings. If you want to change these go to custom mode.") + base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), tooltipContent) + } + onExited: base.hideTooltip() + } + } + + // Show titles for the each quality slider ticks + Item + { + anchors.left: speedSlider.left + anchors.top: speedSlider.bottom + + Repeater + { + model: qualityModel + + Label + { + anchors.verticalCenter: parent.verticalCenter + anchors.top: parent.top + color: (Cura.MachineManager.activeMachine != null && Cura.QualityProfilesDropDownMenuModel.getItem(index).available) ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") + text: + { + var result = "" + if(Cura.MachineManager.activeMachine != null) + { + result = Cura.QualityProfilesDropDownMenuModel.getItem(index).layer_height + + if(result == undefined) + { + result = ""; + } + else + { + result = Number(Math.round(result + "e+2") + "e-2"); //Round to 2 decimals. Javascript makes this difficult... + if (result == undefined || result != result) //Parse failure. + { + result = ""; + } + } + } + return result + } + + x: + { + // Make sure the text aligns correctly with each tick + if (qualityModel.totalTicks == 0) + { + // If there is only one tick, align it centrally + return Math.round(((settingsColumnWidth) - width) / 2) + } + else if (index == 0) + { + return Math.round(settingsColumnWidth / qualityModel.totalTicks) * index + } + else if (index == qualityModel.totalTicks) + { + return Math.round(settingsColumnWidth / qualityModel.totalTicks) * index - width + } + else + { + return Math.round((settingsColumnWidth / qualityModel.totalTicks) * index - (width / 2)) + } + } + } + } } -// -// // Show titles for the each quality slider ticks -// Item -// { -// anchors.left: speedSlider.left -// anchors.top: speedSlider.bottom -// -// Repeater -// { -// model: qualityModel -// -// Label -// { -// anchors.verticalCenter: parent.verticalCenter -// anchors.top: parent.top -// color: (Cura.MachineManager.activeMachine != null && Cura.QualityProfilesDropDownMenuModel.getItem(index).available) ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") -// text: -// { -// var result = "" -// if(Cura.MachineManager.activeMachine != null) -// { -// result = Cura.QualityProfilesDropDownMenuModel.getItem(index).layer_height -// -// if(result == undefined) -// { -// result = ""; -// } -// else -// { -// result = Number(Math.round(result + "e+2") + "e-2"); //Round to 2 decimals. Javascript makes this difficult... -// if (result == undefined || result != result) //Parse failure. -// { -// result = ""; -// } -// } -// } -// return result -// } -// -// x: -// { -// // Make sure the text aligns correctly with each tick -// if (qualityModel.totalTicks == 0) -// { -// // If there is only one tick, align it centrally -// return Math.round(((settingsColumnWidth) - width) / 2) -// } -// else if (index == 0) -// { -// return Math.round(settingsColumnWidth / qualityModel.totalTicks) * index -// } -// else if (index == qualityModel.totalTicks) -// { -// return Math.round(settingsColumnWidth / qualityModel.totalTicks) * index - width -// } -// else -// { -// return Math.round((settingsColumnWidth / qualityModel.totalTicks) * index - (width / 2)) -// } -// } -// } -// } -// } -// //Print speed slider // Two sliders are created, one at the bottom with the unavailable qualities // and the other at the top with the available quality profiles and so the handle to select them. @@ -240,8 +278,9 @@ Item anchors { - left: qualityRowTitle.right + left: titleRow.right right: parent.right + verticalCenter: titleRow.verticalCenter } // Draw unavailable slider @@ -401,32 +440,4 @@ Item onExited: base.hideTooltip() } } - - UM.SimpleButton - { - id: customisedSettings - - visible: Cura.SimpleModeSettingsManager.isProfileCustomized || Cura.SimpleModeSettingsManager.isProfileUserCreated - height: Math.round(speedSlider.height * 0.8) - width: Math.round(speedSlider.height * 0.8) - - anchors.verticalCenter: speedSlider.verticalCenter - anchors.right: speedSlider.left - anchors.rightMargin: Math.round(UM.Theme.getSize("thick_margin").width / 2) - - color: hovered ? UM.Theme.getColor("setting_control_button_hover") : UM.Theme.getColor("setting_control_button"); - iconSource: UM.Theme.getIcon("reset"); - - onClicked: - { - // if the current profile is user-created, switch to a built-in quality - Cura.MachineManager.resetToUseDefaultQuality() - } - onEntered: - { - var tooltipContent = catalog.i18nc("@tooltip","You have modified some profile settings. If you want to change these go to custom mode.") - base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), tooltipContent) - } - onExited: base.hideTooltip() - } } \ No newline at end of file From 29b7f42e0e2cb15df004fcbf5df023fbf17b9b0c Mon Sep 17 00:00:00 2001 From: Aleksei S Date: Fri, 30 Nov 2018 18:33:53 +0100 Subject: [PATCH 25/70] Chaged settings visibility icon CURA-5941 --- resources/qml/Settings/SettingView.qml | 30 ++++++++++++++++++-------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/resources/qml/Settings/SettingView.qml b/resources/qml/Settings/SettingView.qml index 0a7102ff45..28a64f3346 100644 --- a/resources/qml/Settings/SettingView.qml +++ b/resources/qml/Settings/SettingView.qml @@ -1,4 +1,4 @@ -// Copyright (c) 2017 Ultimaker B.V. +// Copyright (c) 2018 Ultimaker B.V. // Uranium is released under the terms of the LGPLv3 or higher. import QtQuick 2.7 @@ -25,13 +25,15 @@ Item { id: settingVisibilityMenu + property var toolButtonIconColor: UM.Theme.getColor("setting_category_text") + width: height height: UM.Theme.getSize("setting_control").height anchors { topMargin: UM.Theme.getSize("thick_margin").height - right: parent.right - rightMargin: UM.Theme.getSize("thick_margin").width + left: filterContainer.right + leftMargin: UM.Theme.getSize("default_margin").width } style: ButtonStyle { @@ -39,12 +41,12 @@ Item UM.RecolorImage { anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter - width: UM.Theme.getSize("standard_arrow").width - height: UM.Theme.getSize("standard_arrow").height + width: Math.round(parent.width * 0.6) + height: Math.round(parent.height * 0.6) sourceSize.width: width sourceSize.height: width - color: control.enabled ? UM.Theme.getColor("setting_category_text") : UM.Theme.getColor("setting_category_disabled_text") - source: UM.Theme.getIcon("menu") + color: settingVisibilityMenu.toolButtonIconColor + source: UM.Theme.getIcon("settings") } } label: Label{} @@ -57,6 +59,15 @@ Item filter.updateDefinitionModel(); } } + + MouseArea + { + anchors.fill: parent + hoverEnabled: true + acceptedButtons: Qt.RightButton + onEntered: settingVisibilityMenu.toolButtonIconColor = UM.Theme.getColor("setting_control_button_hover") + onExited: settingVisibilityMenu.toolButtonIconColor = UM.Theme.getColor("setting_category_text") + } } Rectangle @@ -84,8 +95,8 @@ Item topMargin: UM.Theme.getSize("thick_margin").height left: parent.left leftMargin: UM.Theme.getSize("default_margin").width - right: settingVisibilityMenu.left - rightMargin: Math.floor(UM.Theme.getSize("default_margin").width / 2) + right: scrollView.right + rightMargin: Math.floor(UM.Theme.getSize("wide_margin").width * 2) } height: UM.Theme.getSize("setting_control").height Timer @@ -196,6 +207,7 @@ Item ScrollView { + id: scrollView anchors.top: filterContainer.bottom; anchors.bottom: parent.bottom; anchors.right: parent.right; From 1238aa7304c24e3c7a706fdcceae09c14791409c Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Sun, 2 Dec 2018 12:03:58 +0100 Subject: [PATCH 26/70] Format the slider for the infill in the recommended mode Contributes to CURA-5941 --- .../PrintSetupSelectorContents.qml | 2 +- .../RecommendedInfillDensitySelector.qml | 488 +++++++++--------- .../Recommended/RecommendedPrintSetup.qml | 45 +- .../RecommendedQualityProfileSelector.qml | 28 +- 4 files changed, 268 insertions(+), 295 deletions(-) diff --git a/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml b/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml index 5f22e4c337..0210ece977 100644 --- a/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml +++ b/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml @@ -25,7 +25,7 @@ Item { id: header height: UM.Theme.getSize("print_setup_widget_header").height - color: "transparent" //UM.Theme.getColor("action_button_hovered") // TODO: It's not clear the color that we need to use here + color: UM.Theme.getColor("action_button_hovered") // TODO: It's not clear the color that we need to use here anchors { diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedInfillDensitySelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedInfillDensitySelector.qml index 34cb8f2f20..8b0b87d997 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedInfillDensitySelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedInfillDensitySelector.qml @@ -15,57 +15,37 @@ import Cura 1.0 as Cura Item { id: infillRow + height: childrenRect.height + property real labelColumnWidth: Math.round(width / 3) + + // Here are the elements that are shown in the left column Cura.IconWithText { id: infillRowTitle source: UM.Theme.getIcon("category_infill") text: catalog.i18nc("@label", "Infill") + " (%)" - anchors.bottom: parent.bottom width: labelColumnWidth } Item { - id: infillCellRight + id: infillSliderContainer + height: childrenRect.height - height: infillSlider.height + UM.Theme.getSize("thick_margin").height + enableGradualInfillCheckBox.visible * (enableGradualInfillCheckBox.height + UM.Theme.getSize("thick_margin").height) - - anchors.left: infillRowTitle.right - anchors.right: parent.right - - Label + anchors { - id: selectedInfillRateText - - anchors.left: infillSlider.left - anchors.right: parent.right - - text: parseInt(infillDensity.properties.value) + "%" - horizontalAlignment: Text.AlignLeft - - color: infillSlider.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") - } - - // We use a binding to make sure that after manually setting infillSlider.value it is still bound to the property provider - Binding - { - target: infillSlider - property: "value" - value: parseInt(infillDensity.properties.value) + left: infillRowTitle.right + right: parent.right + verticalCenter: infillRowTitle.verticalCenter } Slider { id: infillSlider - anchors.top: selectedInfillRateText.bottom - anchors.left: parent.left - anchors.right: infillIcon.left - anchors.rightMargin: UM.Theme.getSize("thick_margin").width - - height: UM.Theme.getSize("thick_margin").height - width: parseInt(infillCellRight.width - UM.Theme.getSize("thick_margin").width - style.handleWidth) + width: parent.width + height: UM.Theme.getSize("print_setup_slider_handle").height // The handle is the widest element of the slider minimumValue: 0 maximumValue: 100 @@ -78,9 +58,62 @@ Item // set initial value from stack value: parseInt(infillDensity.properties.value) + style: SliderStyle + { + //Draw line + groove: Item + { + Rectangle + { + height: UM.Theme.getSize("print_setup_slider_groove").height + width: control.width - UM.Theme.getSize("print_setup_slider_handle").width + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + color: control.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") + } + } + + handle: Rectangle + { + id: handleButton + color: control.enabled ? UM.Theme.getColor("primary") : UM.Theme.getColor("quality_slider_unavailable") + implicitWidth: UM.Theme.getSize("print_setup_slider_handle").width + implicitHeight: implicitWidth + radius: Math.round(implicitWidth / 2) + opacity: 0.5 + } + + tickmarks: Repeater + { + id: repeater + model: control.maximumValue / control.stepSize + 1 + + Rectangle + { + color: control.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") + implicitWidth: UM.Theme.getSize("print_setup_slider_tickmarks").width + implicitHeight: UM.Theme.getSize("print_setup_slider_tickmarks").height + anchors.verticalCenter: parent.verticalCenter + + // Do not use Math.round otherwise the tickmarks won't be aligned + x: ((styleData.handleWidth / 2) - (implicitWidth / 2) + (index * ((repeater.width - styleData.handleWidth) / (repeater.count-1)))) + radius: Math.round(implicitWidth / 2) + visible: (index % 10) == 0 // Only show steps of 10% + + Label + { + text: index + visible: (index % 20) == 0 // Only show steps of 20% + anchors.horizontalCenter: parent.horizontalCenter + y: UM.Theme.getSize("thin_margin").height + renderType: Text.NativeRendering + } + } + } + } + onValueChanged: { - // Don't round the value if it's already the same if (parseInt(infillDensity.properties.value) == infillSlider.value) { @@ -104,228 +137,177 @@ Item Cura.MachineManager.resetSettingForAllExtruders("infill_line_distance") } } - - style: SliderStyle - { - groove: Rectangle - { - id: groove - implicitWidth: 200 * screenScaleFactor - implicitHeight: 2 * screenScaleFactor - color: control.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") - radius: 1 - } - - handle: Item - { - Rectangle - { - id: handleButton - anchors.centerIn: parent - color: control.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") - implicitWidth: 10 * screenScaleFactor - implicitHeight: 10 * screenScaleFactor - radius: 10 * screenScaleFactor - } - } - - tickmarks: Repeater - { - id: repeater - model: control.maximumValue / control.stepSize + 1 - - // check if a tick should be shown based on it's index and wether the infill density is a multiple of 10 (slider step size) - function shouldShowTick (index) - { - if (index % 10 == 0) - { - return true - } - return false - } - - Rectangle - { - anchors.verticalCenter: parent.verticalCenter - color: control.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") - width: 1 * screenScaleFactor - height: 6 * screenScaleFactor - x: Math.round(styleData.handleWidth / 2 + index * ((repeater.width - styleData.handleWidth) / (repeater.count-1))) - visible: shouldShowTick(index) - } - } - } } - Rectangle - { - id: infillIcon - - width: Math.round((parent.width / 5) - (UM.Theme.getSize("thick_margin").width)) - height: width - - anchors.right: parent.right - anchors.top: parent.top - anchors.topMargin: Math.round(UM.Theme.getSize("thick_margin").height / 2) - - // we loop over all density icons and only show the one that has the current density and steps - Repeater - { - id: infillIconList - model: infillModel - anchors.fill: parent - - function activeIndex () - { - for (var i = 0; i < infillModel.count; i++) - { - var density = Math.round(infillDensity.properties.value) - var steps = Math.round(infillSteps.properties.value) - var infillModelItem = infillModel.get(i) - - if (infillModelItem != "undefined" - && density >= infillModelItem.percentageMin - && density <= infillModelItem.percentageMax - && steps >= infillModelItem.stepsMin - && steps <= infillModelItem.stepsMax) - { - return i - } - } - return -1 - } - - Rectangle - { - anchors.fill: parent - visible: infillIconList.activeIndex() == index - - border.width: UM.Theme.getSize("default_lining").width - border.color: UM.Theme.getColor("quality_slider_unavailable") - - UM.RecolorImage - { - anchors.fill: parent - anchors.margins: 2 * screenScaleFactor - sourceSize.width: width - sourceSize.height: width - source: UM.Theme.getIcon(model.icon) - color: UM.Theme.getColor("quality_slider_unavailable") - } - } - } - } - - // Gradual Support Infill Checkbox - CheckBox - { - id: enableGradualInfillCheckBox - property alias _hovered: enableGradualInfillMouseArea.containsMouse - - anchors.top: infillSlider.bottom - anchors.topMargin: Math.round(UM.Theme.getSize("thick_margin").height / 2) // closer to slider since it belongs to the same category - anchors.left: infillCellRight.left - - style: UM.Theme.styles.checkbox - enabled: base.settingsEnabled - visible: infillSteps.properties.enabled == "True" - checked: parseInt(infillSteps.properties.value) > 0 - - MouseArea - { - id: enableGradualInfillMouseArea - - anchors.fill: parent - hoverEnabled: true - enabled: true - - property var previousInfillDensity: parseInt(infillDensity.properties.value) - - onClicked: - { - // Set to 90% only when enabling gradual infill - var newInfillDensity; - if (parseInt(infillSteps.properties.value) == 0) - { - previousInfillDensity = parseInt(infillDensity.properties.value) - newInfillDensity = 90 - } else { - newInfillDensity = previousInfillDensity - } - Cura.MachineManager.setSettingForAllExtruders("infill_sparse_density", "value", String(newInfillDensity)) - - var infill_steps_value = 0 - if (parseInt(infillSteps.properties.value) == 0) - { - infill_steps_value = 5 - } - - Cura.MachineManager.setSettingForAllExtruders("gradual_infill_steps", "value", infill_steps_value) - } - - onEntered: base.showTooltip(enableGradualInfillCheckBox, Qt.point(-infillCellRight.x, 0), - catalog.i18nc("@label", "Gradual infill will gradually increase the amount of infill towards the top.")) - - onExited: base.hideTooltip() - - } - - Label - { - id: gradualInfillLabel - height: parent.height - anchors.left: enableGradualInfillCheckBox.right - anchors.leftMargin: Math.round(UM.Theme.getSize("thick_margin").width / 2) - verticalAlignment: Text.AlignVCenter; - text: catalog.i18nc("@label", "Enable gradual") - font: UM.Theme.getFont("default") - color: UM.Theme.getColor("text") - } - } - - // Infill list model for mapping icon - ListModel - { - id: infillModel - Component.onCompleted: - { - infillModel.append({ - percentageMin: -1, - percentageMax: 0, - stepsMin: -1, - stepsMax: 0, - icon: "hollow" - }) - infillModel.append({ - percentageMin: 0, - percentageMax: 40, - stepsMin: -1, - stepsMax: 0, - icon: "sparse" - }) - infillModel.append({ - percentageMin: 40, - percentageMax: 89, - stepsMin: -1, - stepsMax: 0, - icon: "dense" - }) - infillModel.append({ - percentageMin: 90, - percentageMax: 9999999999, - stepsMin: -1, - stepsMax: 0, - icon: "solid" - }) - infillModel.append({ - percentageMin: 0, - percentageMax: 9999999999, - stepsMin: 1, - stepsMax: 9999999999, - icon: "gradual" - }) - } - } +// Rectangle +// { +// id: infillIcon +// +// width: Math.round((parent.width / 5) - (UM.Theme.getSize("thick_margin").width)) +// height: width +// +// anchors.right: parent.right +// anchors.top: parent.top +// anchors.topMargin: Math.round(UM.Theme.getSize("thick_margin").height / 2) +// +// // we loop over all density icons and only show the one that has the current density and steps +// Repeater +// { +// id: infillIconList +// model: infillModel +// anchors.fill: parent +// +// function activeIndex () +// { +// for (var i = 0; i < infillModel.count; i++) +// { +// var density = Math.round(infillDensity.properties.value) +// var steps = Math.round(infillSteps.properties.value) +// var infillModelItem = infillModel.get(i) +// +// if (infillModelItem != "undefined" +// && density >= infillModelItem.percentageMin +// && density <= infillModelItem.percentageMax +// && steps >= infillModelItem.stepsMin +// && steps <= infillModelItem.stepsMax) +// { +// return i +// } +// } +// return -1 +// } +// +// Rectangle +// { +// anchors.fill: parent +// visible: infillIconList.activeIndex() == index +// +// border.width: UM.Theme.getSize("default_lining").width +// border.color: UM.Theme.getColor("quality_slider_unavailable") +// +// UM.RecolorImage +// { +// anchors.fill: parent +// anchors.margins: 2 * screenScaleFactor +// sourceSize.width: width +// sourceSize.height: width +// source: UM.Theme.getIcon(model.icon) +// color: UM.Theme.getColor("quality_slider_unavailable") +// } +// } +// } +// } +// +// // Gradual Support Infill Checkbox +// CheckBox +// { +// id: enableGradualInfillCheckBox +// property alias _hovered: enableGradualInfillMouseArea.containsMouse +// +// anchors.top: infillSlider.bottom +// anchors.topMargin: Math.round(UM.Theme.getSize("thick_margin").height / 2) // closer to slider since it belongs to the same category +// anchors.left: infillSliderContainer.left +// +// style: UM.Theme.styles.checkbox +// enabled: base.settingsEnabled +// visible: infillSteps.properties.enabled == "True" +// checked: parseInt(infillSteps.properties.value) > 0 +// +// MouseArea +// { +// id: enableGradualInfillMouseArea +// +// anchors.fill: parent +// hoverEnabled: true +// enabled: true +// +// property var previousInfillDensity: parseInt(infillDensity.properties.value) +// +// onClicked: +// { +// // Set to 90% only when enabling gradual infill +// var newInfillDensity; +// if (parseInt(infillSteps.properties.value) == 0) +// { +// previousInfillDensity = parseInt(infillDensity.properties.value) +// newInfillDensity = 90 +// } else { +// newInfillDensity = previousInfillDensity +// } +// Cura.MachineManager.setSettingForAllExtruders("infill_sparse_density", "value", String(newInfillDensity)) +// +// var infill_steps_value = 0 +// if (parseInt(infillSteps.properties.value) == 0) +// { +// infill_steps_value = 5 +// } +// +// Cura.MachineManager.setSettingForAllExtruders("gradual_infill_steps", "value", infill_steps_value) +// } +// +// onEntered: base.showTooltip(enableGradualInfillCheckBox, Qt.point(-infillSliderContainer.x, 0), +// catalog.i18nc("@label", "Gradual infill will gradually increase the amount of infill towards the top.")) +// +// onExited: base.hideTooltip() +// +// } +// +// Label +// { +// id: gradualInfillLabel +// height: parent.height +// anchors.left: enableGradualInfillCheckBox.right +// anchors.leftMargin: Math.round(UM.Theme.getSize("thick_margin").width / 2) +// verticalAlignment: Text.AlignVCenter; +// text: catalog.i18nc("@label", "Enable gradual") +// font: UM.Theme.getFont("default") +// color: UM.Theme.getColor("text") +// } +// } +// +// // Infill list model for mapping icon +// ListModel +// { +// id: infillModel +// Component.onCompleted: +// { +// infillModel.append({ +// percentageMin: -1, +// percentageMax: 0, +// stepsMin: -1, +// stepsMax: 0, +// icon: "hollow" +// }) +// infillModel.append({ +// percentageMin: 0, +// percentageMax: 40, +// stepsMin: -1, +// stepsMax: 0, +// icon: "sparse" +// }) +// infillModel.append({ +// percentageMin: 40, +// percentageMax: 89, +// stepsMin: -1, +// stepsMax: 0, +// icon: "dense" +// }) +// infillModel.append({ +// percentageMin: 90, +// percentageMax: 9999999999, +// stepsMin: -1, +// stepsMax: 0, +// icon: "solid" +// }) +// infillModel.append({ +// percentageMin: 0, +// percentageMax: 9999999999, +// stepsMin: 1, +// stepsMax: 9999999999, +// icon: "gradual" +// }) +// } +// } } UM.SettingPropertyProvider diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml index 40a1910c69..0dabc3ea1e 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml @@ -12,10 +12,10 @@ Item { id: base + height: childrenRect.height + 2 * padding + signal showTooltip(Item item, point location, string text) signal hideTooltip() -// width: parent.width - height: childrenRect.height + 2 * padding property Action configureSettings @@ -28,24 +28,11 @@ Item name: "cura" } -// Rectangle -// { -// width: parent.width - 2 * parent.padding -// anchors -// { -// left: parent.left -// right: parent.right -// top: parent.top -// margins: parent.padding -// } -// color: "blue" -// height: 50 -// } - Column { width: parent.width - 2 * parent.padding - spacing: UM.Theme.getSize("default_margin").height + spacing: UM.Theme.getSize("wide_margin").height + anchors { left: parent.left @@ -55,33 +42,27 @@ Item } // TODO - property real labelColumnWidth: Math.round(width / 3) - property real settingsColumnWidth: width - labelColumnWidth + property real firstColumnWidth: Math.round(width / 3) RecommendedQualityProfileSelector { width: parent.width // TODO Create a reusable component with these properties to not define them separately for each component - property real labelColumnWidth: parent.labelColumnWidth - property real settingsColumnWidth: parent.settingsColumnWidth + labelColumnWidth: parent.firstColumnWidth } -// RecommendedInfillDensitySelector -// { -// width: parent.width -// height: childrenRect.height -// // TODO Create a reusable component with these properties to not define them separately for each component -// property real labelColumnWidth: parent.labelColumnWidth -// property real settingsColumnWidth: parent.settingsColumnWidth -// } + RecommendedInfillDensitySelector + { + width: parent.width + // TODO Create a reusable component with these properties to not define them separately for each component + labelColumnWidth: parent.firstColumnWidth + } // // RecommendedSupportSelector // { // width: parent.width -// height: childrenRect.height // // TODO Create a reusable component with these properties to not define them separately for each component -// property real labelColumnWidth: parent.labelColumnWidth -// property real settingsColumnWidth: parent.settingsColumnWidth +// property real firstColumnWidth: parent.labelColumnWidth // } diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml index f7e1d870c9..cddf01a4dc 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml @@ -17,6 +17,9 @@ Item id: qualityRow height: childrenRect.height + property real labelColumnWidth: Math.round(width / 3) + property real settingsColumnWidth: width - labelColumnWidth + Timer { id: qualitySliderChangeTimer @@ -158,6 +161,7 @@ Item } } + // Here are the elements that are shown in the left column Item { id: titleRow @@ -210,6 +214,7 @@ Item { anchors.left: speedSlider.left anchors.top: speedSlider.bottom + height: childrenRect.height Repeater { @@ -219,6 +224,8 @@ Item { anchors.verticalCenter: parent.verticalCenter anchors.top: parent.top + // The height has to be set manually, otherwise it's not automatically calculated in the repeater + height: UM.Theme.getSize("default_margin").height color: (Cura.MachineManager.activeMachine != null && Cura.QualityProfilesDropDownMenuModel.getItem(index).available) ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable") text: { @@ -268,7 +275,7 @@ Item } } - //Print speed slider + // Print speed slider // Two sliders are created, one at the bottom with the unavailable qualities // and the other at the top with the available quality profiles and so the handle to select them. Item @@ -287,6 +294,8 @@ Item Slider { id: unavailableSlider + + width: parent.width height: qualitySlider.height // Same height as the slider that is on top updateValueWhileDragging : false tickmarksEnabled: true @@ -297,8 +306,6 @@ Item maximumValue: qualityModel.totalTicks stepSize: 1 - width: parent.width - style: SliderStyle { //Draw Unvailable line @@ -329,7 +336,7 @@ Item anchors.verticalCenter: parent.verticalCenter // Do not use Math.round otherwise the tickmarks won't be aligned - x: ((UM.Theme.getSize("print_setup_slider_handle").width / 2) - (UM.Theme.getSize("print_setup_slider_tickmarks").width / 2) + (qualityModel.qualitySliderStepWidth * index)) + x: ((UM.Theme.getSize("print_setup_slider_handle").width / 2) - (implicitWidth / 2) + (qualityModel.qualitySliderStepWidth * index)) radius: Math.round(implicitWidth / 2) } } @@ -354,11 +361,19 @@ Item Slider { id: qualitySlider + + width: qualityModel.qualitySliderStepWidth * (qualityModel.availableTotalTicks - 1) + UM.Theme.getSize("print_setup_slider_handle").width height: UM.Theme.getSize("print_setup_slider_handle").height // The handle is the widest element of the slider enabled: qualityModel.totalTicks > 0 && !Cura.SimpleModeSettingsManager.isProfileCustomized visible: qualityModel.availableTotalTicks > 0 updateValueWhileDragging : false + anchors + { + right: parent.right + rightMargin: qualityModel.qualitySliderMarginRight + } + minimumValue: qualityModel.qualitySliderAvailableMin >= 0 ? qualityModel.qualitySliderAvailableMin : 0 // maximumValue must be greater than minimumValue to be able to see the handle. While the value is strictly // speaking not always correct, it seems to have the correct behavior (switching from 0 available to 1 available) @@ -367,11 +382,6 @@ Item value: qualityModel.qualitySliderActiveIndex - width: qualityModel.qualitySliderStepWidth * (qualityModel.availableTotalTicks - 1) + UM.Theme.getSize("print_setup_slider_handle").width - - anchors.right: parent.right - anchors.rightMargin: qualityModel.qualitySliderMarginRight - style: SliderStyle { // Draw Available line From 4154ec2fe82a79334a2d1b10d2de745a1aa38b19 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Sun, 2 Dec 2018 12:39:52 +0100 Subject: [PATCH 27/70] Add enable gradual checkbox to the infill panel Contributes to CURA-5941. --- .../RecommendedInfillDensitySelector.qml | 146 +++++++++--------- 1 file changed, 77 insertions(+), 69 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedInfillDensitySelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedInfillDensitySelector.qml index 8b0b87d997..4226acb790 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedInfillDensitySelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedInfillDensitySelector.qml @@ -23,11 +23,20 @@ Item Cura.IconWithText { id: infillRowTitle + anchors.top: parent.top + anchors.left: parent.left source: UM.Theme.getIcon("category_infill") text: catalog.i18nc("@label", "Infill") + " (%)" width: labelColumnWidth } + Rectangle + { + anchors.fill: infillSliderContainer + color: "red" + opacity: 0.5 + } + Item { id: infillSliderContainer @@ -80,7 +89,6 @@ Item implicitWidth: UM.Theme.getSize("print_setup_slider_handle").width implicitHeight: implicitWidth radius: Math.round(implicitWidth / 2) - opacity: 0.5 } tickmarks: Repeater @@ -138,6 +146,74 @@ Item } } } + } + + // Gradual Support Infill Checkbox + CheckBox + { + id: enableGradualInfillCheckBox + property alias _hovered: enableGradualInfillMouseArea.containsMouse + + anchors.top: infillSliderContainer.bottom + anchors.topMargin: UM.Theme.getSize("wide_margin").height + anchors.left: infillSliderContainer.left + + style: UM.Theme.styles.checkbox + enabled: base.settingsEnabled + visible: infillSteps.properties.enabled == "True" + checked: parseInt(infillSteps.properties.value) > 0 + + MouseArea + { + id: enableGradualInfillMouseArea + + anchors.fill: parent + hoverEnabled: true + enabled: true + + property var previousInfillDensity: parseInt(infillDensity.properties.value) + + onClicked: + { + // Set to 90% only when enabling gradual infill + var newInfillDensity; + if (parseInt(infillSteps.properties.value) == 0) + { + previousInfillDensity = parseInt(infillDensity.properties.value) + newInfillDensity = 90 + } else { + newInfillDensity = previousInfillDensity + } + Cura.MachineManager.setSettingForAllExtruders("infill_sparse_density", "value", String(newInfillDensity)) + + var infill_steps_value = 0 + if (parseInt(infillSteps.properties.value) == 0) + { + infill_steps_value = 5 + } + + Cura.MachineManager.setSettingForAllExtruders("gradual_infill_steps", "value", infill_steps_value) + } + + onEntered: base.showTooltip(enableGradualInfillCheckBox, Qt.point(-infillSliderContainer.x - UM.Theme.getSize("thick_margin").width, 0), + catalog.i18nc("@label", "Gradual infill will gradually increase the amount of infill towards the top.")) + + onExited: base.hideTooltip() + } + + Label + { + id: gradualInfillLabel + height: parent.height + anchors.left: enableGradualInfillCheckBox.right + anchors.leftMargin: UM.Theme.getSize("default_margin").width + verticalAlignment: Text.AlignVCenter + text: catalog.i18nc("@label", "Enable gradual") + font: UM.Theme.getFont("default") + color: UM.Theme.getColor("text") + renderType: Text.NativeRendering + } + } // Rectangle // { @@ -198,73 +274,6 @@ Item // } // } // -// // Gradual Support Infill Checkbox -// CheckBox -// { -// id: enableGradualInfillCheckBox -// property alias _hovered: enableGradualInfillMouseArea.containsMouse -// -// anchors.top: infillSlider.bottom -// anchors.topMargin: Math.round(UM.Theme.getSize("thick_margin").height / 2) // closer to slider since it belongs to the same category -// anchors.left: infillSliderContainer.left -// -// style: UM.Theme.styles.checkbox -// enabled: base.settingsEnabled -// visible: infillSteps.properties.enabled == "True" -// checked: parseInt(infillSteps.properties.value) > 0 -// -// MouseArea -// { -// id: enableGradualInfillMouseArea -// -// anchors.fill: parent -// hoverEnabled: true -// enabled: true -// -// property var previousInfillDensity: parseInt(infillDensity.properties.value) -// -// onClicked: -// { -// // Set to 90% only when enabling gradual infill -// var newInfillDensity; -// if (parseInt(infillSteps.properties.value) == 0) -// { -// previousInfillDensity = parseInt(infillDensity.properties.value) -// newInfillDensity = 90 -// } else { -// newInfillDensity = previousInfillDensity -// } -// Cura.MachineManager.setSettingForAllExtruders("infill_sparse_density", "value", String(newInfillDensity)) -// -// var infill_steps_value = 0 -// if (parseInt(infillSteps.properties.value) == 0) -// { -// infill_steps_value = 5 -// } -// -// Cura.MachineManager.setSettingForAllExtruders("gradual_infill_steps", "value", infill_steps_value) -// } -// -// onEntered: base.showTooltip(enableGradualInfillCheckBox, Qt.point(-infillSliderContainer.x, 0), -// catalog.i18nc("@label", "Gradual infill will gradually increase the amount of infill towards the top.")) -// -// onExited: base.hideTooltip() -// -// } -// -// Label -// { -// id: gradualInfillLabel -// height: parent.height -// anchors.left: enableGradualInfillCheckBox.right -// anchors.leftMargin: Math.round(UM.Theme.getSize("thick_margin").width / 2) -// verticalAlignment: Text.AlignVCenter; -// text: catalog.i18nc("@label", "Enable gradual") -// font: UM.Theme.getFont("default") -// color: UM.Theme.getColor("text") -// } -// } -// // // Infill list model for mapping icon // ListModel // { @@ -308,7 +317,6 @@ Item // }) // } // } - } UM.SettingPropertyProvider { From 1caccfb57705ed75dc49d0d257a71204d9210827 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Sun, 2 Dec 2018 13:40:41 +0100 Subject: [PATCH 28/70] Add a binding to react when the infill density changes in the custom panel Also make the icon dinamic, that will change when the infill density changes. Contributes to CURA-5941. --- .../RecommendedInfillDensitySelector.qml | 160 ++++-------------- resources/themes/cura-light/styles.qml | 3 +- resources/themes/cura-light/theme.json | 9 +- 3 files changed, 44 insertions(+), 128 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedInfillDensitySelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedInfillDensitySelector.qml index 4226acb790..0dd594176c 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedInfillDensitySelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedInfillDensitySelector.qml @@ -19,6 +19,42 @@ Item property real labelColumnWidth: Math.round(width / 3) + // Create a binding to update the icon when the infill density changes + Binding + { + target: infillRowTitle + property: "source" + value: + { + var density = parseInt(infillDensity.properties.value) + if (parseInt(infillSteps.properties.value) != 0) + { + return UM.Theme.getIcon("gradual") + } + if (density <= 0) + { + return UM.Theme.getIcon("hollow") + } + if (density < 40) + { + return UM.Theme.getIcon("sparse") + } + if (density < 90) + { + return UM.Theme.getIcon("dense") + } + return UM.Theme.getIcon("solid") + } + } + + // We use a binding to make sure that after manually setting infillSlider.value it is still bound to the property provider + Binding + { + target: infillSlider + property: "value" + value: parseInt(infillDensity.properties.value) + } + // Here are the elements that are shown in the left column Cura.IconWithText { @@ -30,13 +66,6 @@ Item width: labelColumnWidth } - Rectangle - { - anchors.fill: infillSliderContainer - color: "red" - opacity: 0.5 - } - Item { id: infillSliderContainer @@ -158,6 +187,7 @@ Item anchors.topMargin: UM.Theme.getSize("wide_margin").height anchors.left: infillSliderContainer.left + text: catalog.i18nc("@label", "Gradual infill") style: UM.Theme.styles.checkbox enabled: base.settingsEnabled visible: infillSteps.properties.enabled == "True" @@ -200,124 +230,8 @@ Item onExited: base.hideTooltip() } - - Label - { - id: gradualInfillLabel - height: parent.height - anchors.left: enableGradualInfillCheckBox.right - anchors.leftMargin: UM.Theme.getSize("default_margin").width - verticalAlignment: Text.AlignVCenter - text: catalog.i18nc("@label", "Enable gradual") - font: UM.Theme.getFont("default") - color: UM.Theme.getColor("text") - renderType: Text.NativeRendering - } } -// Rectangle -// { -// id: infillIcon -// -// width: Math.round((parent.width / 5) - (UM.Theme.getSize("thick_margin").width)) -// height: width -// -// anchors.right: parent.right -// anchors.top: parent.top -// anchors.topMargin: Math.round(UM.Theme.getSize("thick_margin").height / 2) -// -// // we loop over all density icons and only show the one that has the current density and steps -// Repeater -// { -// id: infillIconList -// model: infillModel -// anchors.fill: parent -// -// function activeIndex () -// { -// for (var i = 0; i < infillModel.count; i++) -// { -// var density = Math.round(infillDensity.properties.value) -// var steps = Math.round(infillSteps.properties.value) -// var infillModelItem = infillModel.get(i) -// -// if (infillModelItem != "undefined" -// && density >= infillModelItem.percentageMin -// && density <= infillModelItem.percentageMax -// && steps >= infillModelItem.stepsMin -// && steps <= infillModelItem.stepsMax) -// { -// return i -// } -// } -// return -1 -// } -// -// Rectangle -// { -// anchors.fill: parent -// visible: infillIconList.activeIndex() == index -// -// border.width: UM.Theme.getSize("default_lining").width -// border.color: UM.Theme.getColor("quality_slider_unavailable") -// -// UM.RecolorImage -// { -// anchors.fill: parent -// anchors.margins: 2 * screenScaleFactor -// sourceSize.width: width -// sourceSize.height: width -// source: UM.Theme.getIcon(model.icon) -// color: UM.Theme.getColor("quality_slider_unavailable") -// } -// } -// } -// } -// -// // Infill list model for mapping icon -// ListModel -// { -// id: infillModel -// Component.onCompleted: -// { -// infillModel.append({ -// percentageMin: -1, -// percentageMax: 0, -// stepsMin: -1, -// stepsMax: 0, -// icon: "hollow" -// }) -// infillModel.append({ -// percentageMin: 0, -// percentageMax: 40, -// stepsMin: -1, -// stepsMax: 0, -// icon: "sparse" -// }) -// infillModel.append({ -// percentageMin: 40, -// percentageMax: 89, -// stepsMin: -1, -// stepsMax: 0, -// icon: "dense" -// }) -// infillModel.append({ -// percentageMin: 90, -// percentageMax: 9999999999, -// stepsMin: -1, -// stepsMax: 0, -// icon: "solid" -// }) -// infillModel.append({ -// percentageMin: 0, -// percentageMax: 9999999999, -// stepsMin: 1, -// stepsMax: 9999999999, -// icon: "gradual" -// }) -// } -// } - UM.SettingPropertyProvider { id: infillDensity diff --git a/resources/themes/cura-light/styles.qml b/resources/themes/cura-light/styles.qml index e040d91df9..96bf334c43 100755 --- a/resources/themes/cura-light/styles.qml +++ b/resources/themes/cura-light/styles.qml @@ -532,7 +532,7 @@ QtObject color: (control.hovered || control._hovered) ? Theme.getColor("checkbox_hover") : Theme.getColor("checkbox") Behavior on color { ColorAnimation { duration: 50; } } - radius: control.exclusiveGroup ? Math.round(Theme.getSize("checkbox").width / 2) : 0 + radius: control.exclusiveGroup ? Math.round(Theme.getSize("checkbox").width / 2) : UM.Theme.getSize("checkbox_radius").width border.width: Theme.getSize("default_lining").width border.color: (control.hovered || control._hovered) ? Theme.getColor("checkbox_border_hover") : Theme.getColor("checkbox_border") @@ -557,6 +557,7 @@ QtObject color: Theme.getColor("checkbox_text") font: Theme.getFont("default") elide: Text.ElideRight + renderType: Text.NativeRendering } } } diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index 7cfd7b93e1..392b09303d 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -239,10 +239,10 @@ "checkbox": [255, 255, 255, 255], "checkbox_hover": [255, 255, 255, 255], - "checkbox_border": [64, 69, 72, 255], + "checkbox_border": [199, 199, 199, 255], "checkbox_border_hover": [50, 130, 255, 255], - "checkbox_mark": [119, 122, 124, 255], - "checkbox_text": [27, 27, 27, 255], + "checkbox_mark": [50, 130, 255, 255], + "checkbox_text": [35, 35, 35, 255], "tooltip": [68, 192, 255, 255], "tooltip_text": [255, 255, 255, 255], @@ -459,7 +459,8 @@ "layerview_row": [11.0, 1.5], "layerview_row_spacing": [0.0, 0.5], - "checkbox": [2.0, 2.0], + "checkbox": [1.5, 1.5], + "checkbox_radius": [0.08, 0.08], "tooltip": [20.0, 10.0], "tooltip_margins": [1.0, 1.0], From 1cea36b08a5f6f1a8899667a39ec87285abab9c6 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Sun, 2 Dec 2018 19:01:54 +0100 Subject: [PATCH 29/70] Add the row for the support selection in the recommended mode Contributes to CURA-5941. --- .../Recommended/RecommendedPrintSetup.qml | 15 +- .../RecommendedSupportSelector.qml | 189 +++++++++++------- resources/themes/cura-light/styles.qml | 15 +- resources/themes/cura-light/theme.json | 10 +- 4 files changed, 134 insertions(+), 95 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml index 0dabc3ea1e..d246be560e 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml @@ -57,13 +57,13 @@ Item // TODO Create a reusable component with these properties to not define them separately for each component labelColumnWidth: parent.firstColumnWidth } -// -// RecommendedSupportSelector -// { -// width: parent.width -// // TODO Create a reusable component with these properties to not define them separately for each component -// property real firstColumnWidth: parent.labelColumnWidth -// } + + RecommendedSupportSelector + { + width: parent.width + // TODO Create a reusable component with these properties to not define them separately for each component + labelColumnWidth: parent.firstColumnWidth + } // @@ -128,7 +128,6 @@ Item // } } - UM.SettingPropertyProvider { id: platformAdhesionType diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml index 9c4e5ed576..2407b746b2 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml @@ -8,114 +8,142 @@ import QtQuick.Controls.Styles 1.4 import UM 1.2 as UM import Cura 1.0 as Cura + // // Enable support // -Row +Item { + id: enableSupportRow + height: childrenRect.height + + property real labelColumnWidth: Math.round(width / 3) Cura.IconWithText { - id: enableSupportLabel + id: enableSupportRowTitle + anchors.top: parent.top + anchors.left: parent.left visible: enableSupportCheckBox.visible source: UM.Theme.getIcon("category_support") text: catalog.i18nc("@label", "Support") width: labelColumnWidth } - CheckBox + Item { - id: enableSupportCheckBox - property alias _hovered: enableSupportMouseArea.containsMouse + id: enableSupportContainer + height: childrenRect.height - style: UM.Theme.styles.checkbox - enabled: base.settingsEnabled - - visible: supportEnabled.properties.enabled == "True" - checked: supportEnabled.properties.value == "True" - - MouseArea + anchors { - id: enableSupportMouseArea - anchors.fill: parent - hoverEnabled: true - onClicked: supportEnabled.setPropertyValue("value", supportEnabled.properties.value != "True") - - onEntered: base.showTooltip(enableSupportCheckBox, Qt.point(-enableSupportCheckBox.x, 0), - catalog.i18nc("@label", "Generate structures to support parts of the model which have overhangs. Without these structures, such parts would collapse during printing.")) - - onExited: base.hideTooltip() - - } - } - - ComboBox - { - id: supportExtruderCombobox - visible: enableSupportCheckBox.visible && (supportEnabled.properties.value == "True") && (extrudersEnabledCount.properties.value > 1) - model: extruderModel - - property string color_override: "" // for manually setting values - property string color: // is evaluated automatically, but the first time is before extruderModel being filled - { - var current_extruder = extruderModel.get(currentIndex); - color_override = ""; - if (current_extruder === undefined) return "" - return (current_extruder.color) ? current_extruder.color : ""; + left: enableSupportRowTitle.right + right: parent.right + verticalCenter: enableSupportRowTitle.verticalCenter } - textRole: "text" // this solves that the combobox isn't populated in the first time Cura is started - - width: Math.round(UM.Theme.getSize("print_setup_widget").width * .55) - Math.round(UM.Theme.getSize("thick_margin").width / 2) - enableSupportCheckBox.width - height: ((supportEnabled.properties.value == "True") && (machineExtruderCount.properties.value > 1)) ? UM.Theme.getSize("setting_control").height : 0 - - Behavior on height { NumberAnimation { duration: 100 } } - - style: UM.Theme.styles.combobox_color - enabled: base.settingsEnabled - property alias _hovered: supportExtruderMouseArea.containsMouse - - currentIndex: + CheckBox { - if (supportExtruderNr.properties == null) + id: enableSupportCheckBox + anchors.verticalCenter: parent.verticalCenter + + property alias _hovered: enableSupportMouseArea.containsMouse + + style: UM.Theme.styles.checkbox + enabled: base.settingsEnabled + + visible: supportEnabled.properties.enabled == "True" + checked: supportEnabled.properties.value == "True" + + MouseArea { - return Cura.MachineManager.defaultExtruderPosition + id: enableSupportMouseArea + anchors.fill: parent + hoverEnabled: true + onClicked: supportEnabled.setPropertyValue("value", supportEnabled.properties.value != "True") + + onEntered: + { + base.showTooltip(enableSupportCheckBox, Qt.point(-enableSupportContainer.x - UM.Theme.getSize("thick_margin").width, 0), + catalog.i18nc("@label", "Generate structures to support parts of the model which have overhangs. Without these structures, such parts would collapse during printing.")) + } + onExited: base.hideTooltip() } - else + } + + ComboBox + { + id: supportExtruderCombobox + + height: UM.Theme.getSize("print_setup_support_extruder_selector").height + anchors { - var extruder = parseInt(supportExtruderNr.properties.value) - if ( extruder === -1) + left: enableSupportCheckBox.right + right: parent.right + leftMargin: UM.Theme.getSize("thick_margin").width + rightMargin: UM.Theme.getSize("thick_margin").width + verticalCenter: parent.verticalCenter + } + + style: UM.Theme.styles.combobox_color + enabled: base.settingsEnabled + visible: enableSupportCheckBox.visible && (supportEnabled.properties.value == "True") && (extrudersEnabledCount.properties.value > 1) + textRole: "text" // this solves that the combobox isn't populated in the first time Cura is started + + model: extruderModel + + property alias _hovered: supportExtruderMouseArea.containsMouse + property string color_override: "" // for manually setting values + property string color: // is evaluated automatically, but the first time is before extruderModel being filled + { + var current_extruder = extruderModel.get(currentIndex); + color_override = ""; + if (current_extruder === undefined) return "" + return (current_extruder.color) ? current_extruder.color : ""; + } + + currentIndex: + { + if (supportExtruderNr.properties == null) { return Cura.MachineManager.defaultExtruderPosition } - return extruder; + else + { + var extruder = parseInt(supportExtruderNr.properties.value) + if ( extruder === -1) + { + return Cura.MachineManager.defaultExtruderPosition + } + return extruder; + } } - } - onActivated: supportExtruderNr.setPropertyValue("value", String(index)) + onActivated: supportExtruderNr.setPropertyValue("value", String(index)) - MouseArea - { - id: supportExtruderMouseArea - anchors.fill: parent - hoverEnabled: true - enabled: base.settingsEnabled - acceptedButtons: Qt.NoButton - onEntered: + MouseArea { - base.showTooltip(supportExtruderCombobox, Qt.point(-supportExtruderCombobox.x, 0), - catalog.i18nc("@label", "Select which extruder to use for support. This will build up supporting structures below the model to prevent the model from sagging or printing in mid air.")); + id: supportExtruderMouseArea + anchors.fill: parent + hoverEnabled: true + enabled: base.settingsEnabled + acceptedButtons: Qt.NoButton + onEntered: + { + base.showTooltip(supportExtruderCombobox, Qt.point(-enableSupportContainer.x - supportExtruderCombobox.x - UM.Theme.getSize("thick_margin").width, 0), + catalog.i18nc("@label", "Select which extruder to use for support. This will build up supporting structures below the model to prevent the model from sagging or printing in mid air.")); + } + onExited: base.hideTooltip() + } - onExited: base.hideTooltip() - } - - function updateCurrentColor() - { - var current_extruder = extruderModel.get(currentIndex) - if (current_extruder !== undefined) + function updateCurrentColor() { - supportExtruderCombobox.color_override = current_extruder.color + var current_extruder = extruderModel.get(currentIndex) + if (current_extruder !== undefined) + { + supportExtruderCombobox.color_override = current_extruder.color + } } } } @@ -160,6 +188,15 @@ Row storeIndex: 0 } + UM.SettingPropertyProvider + { + id: machineExtruderCount + containerStack: Cura.MachineManager.activeMachine + key: "machine_extruder_count" + watchedProperties: ["value"] + storeIndex: 0 + } + function populateExtruderModel() { extruderModel.clear() diff --git a/resources/themes/cura-light/styles.qml b/resources/themes/cura-light/styles.qml index 96bf334c43..5203cb0b0b 100755 --- a/resources/themes/cura-light/styles.qml +++ b/resources/themes/cura-light/styles.qml @@ -413,11 +413,11 @@ QtObject border.width: Theme.getSize("default_lining").width; border.color: control.hovered ? Theme.getColor("setting_control_border_highlight") : Theme.getColor("setting_control_border"); + radius: UM.Theme.getSize("setting_control_radius").width } label: Item { - Label { anchors.left: parent.left @@ -465,11 +465,11 @@ QtObject color: !enabled ? UM.Theme.getColor("setting_control_disabled") : control._hovered ? UM.Theme.getColor("setting_control_highlight") : UM.Theme.getColor("setting_control") border.width: UM.Theme.getSize("default_lining").width border.color: !enabled ? UM.Theme.getColor("setting_control_disabled_border") : control._hovered ? UM.Theme.getColor("setting_control_border_highlight") : UM.Theme.getColor("setting_control_border") + radius: UM.Theme.getSize("setting_control_radius").width } label: Item { - Label { anchors.left: parent.left @@ -486,7 +486,7 @@ QtObject verticalAlignment: Text.AlignVCenter } - Rectangle + UM.RecolorImage { id: swatch height: Math.round(UM.Theme.getSize("setting_control").height / 2) @@ -494,9 +494,9 @@ QtObject anchors.right: downArrow.left anchors.verticalCenter: parent.verticalCenter anchors.margins: Math.round(UM.Theme.getSize("default_margin").width / 4) - radius: Math.round(width / 2) - border.width: UM.Theme.getSize("default_lining").width - border.color: UM.Theme.getColor("lining") + sourceSize.width: width + sourceSize.height: height + source: UM.Theme.getIcon("extruder_button") color: (control.color_override !== "") ? control.color_override : control.color } @@ -575,7 +575,7 @@ QtObject color: (control.hovered || control._hovered) ? Theme.getColor("checkbox_hover") : Theme.getColor("checkbox"); Behavior on color { ColorAnimation { duration: 50; } } - radius: control.exclusiveGroup ? Math.round(Theme.getSize("checkbox").width / 2) : 0 + radius: control.exclusiveGroup ? Math.round(Theme.getSize("checkbox").width / 2) : UM.Theme.getSize("checkbox_radius").width border.width: Theme.getSize("default_lining").width; border.color: (control.hovered || control._hovered) ? Theme.getColor("checkbox_border_hover") : Theme.getColor("checkbox_border"); @@ -628,6 +628,7 @@ QtObject border.width: Theme.getSize("default_lining").width; border.color: control.hovered ? Theme.getColor("setting_control_border_highlight") : Theme.getColor("setting_control_border"); + radius: UM.Theme.getSize("setting_control_radius").width color: Theme.getColor("setting_validation_ok"); diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index 392b09303d..afe40007f4 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -206,11 +206,11 @@ "setting_control": [255, 255, 255, 255], "setting_control_selected": [31, 36, 39, 255], "setting_control_highlight": [255, 255, 255, 255], - "setting_control_border": [127, 127, 127, 255], + "setting_control_border": [199, 199, 199, 255], "setting_control_border_highlight": [50, 130, 255, 255], - "setting_control_text": [27, 27, 27, 255], - "setting_control_depth_line": [127, 127, 127, 255], - "setting_control_button": [127, 127, 127, 255], + "setting_control_text": [35, 35, 35, 255], + "setting_control_depth_line": [199, 199, 199, 255], + "setting_control_button": [199, 199, 199, 255], "setting_control_button_hover": [70, 84, 113, 255], "setting_control_disabled": [245, 245, 245, 255], "setting_control_disabled_text": [127, 127, 127, 255], @@ -377,6 +377,7 @@ "print_setup_slider_groove": [0.16, 0.16], "print_setup_slider_handle": [1.0, 1.0], "print_setup_slider_tickmarks": [0.32, 0.32], + "print_setup_support_extruder_selector": [18.2, 2.5], "configuration_selector_mode_tabs": [0.0, 3.0], @@ -415,6 +416,7 @@ "setting": [25.0, 1.8], "setting_control": [10.0, 2.0], + "setting_control_radius": [0.15, 0.15], "setting_control_depth_margin": [1.4, 0.0], "setting_preferences_button_margin": [4, 0.0], "setting_control_margin": [0.0, 0.0], From adabb833e0b6dbc978bfb96f8b42004f03e28a84 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Sun, 2 Dec 2018 19:14:34 +0100 Subject: [PATCH 30/70] Add row for the adhesion setting in the recommended mode Contributes to CURA-5941. --- .../RecommendedAdhesionSelector.qml | 99 +++++++++++++++++++ .../Recommended/RecommendedPrintSetup.qml | 77 ++------------- .../RecommendedSupportSelector.qml | 2 +- 3 files changed, 106 insertions(+), 72 deletions(-) create mode 100644 resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml new file mode 100644 index 0000000000..a7e8b3ea75 --- /dev/null +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml @@ -0,0 +1,99 @@ +// Copyright (c) 2018 Ultimaker B.V. +// Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.7 +import QtQuick.Controls 1.4 +import QtQuick.Controls.Styles 1.4 + +import UM 1.2 as UM +import Cura 1.0 as Cura + + +// +// Adhesion +// +Item +{ + id: enableAdhesionRow + height: childrenRect.height + + property real labelColumnWidth: Math.round(width / 3) + + Cura.IconWithText + { + id: enableAdhesionRowTitle + anchors.top: parent.top + anchors.left: parent.left + source: UM.Theme.getIcon("category_adhesion") + text: catalog.i18nc("@label", "Adhesion") + width: labelColumnWidth + } + + Item + { + id: enableAdhesionContainer + height: childrenRect.height + + anchors + { + left: enableAdhesionRowTitle.right + right: parent.right + verticalCenter: enableAdhesionRowTitle.verticalCenter + } + + CheckBox + { + id: enableAdhesionCheckBox + anchors.verticalCenter: parent.verticalCenter + + //: Setting enable printing build-plate adhesion helper checkbox + style: UM.Theme.styles.checkbox + enabled: base.settingsEnabled + + visible: platformAdhesionType.properties.enabled == "True" + checked: platformAdhesionType.properties.value != "skirt" && platformAdhesionType.properties.value != "none" + + MouseArea + { + id: adhesionMouseArea + anchors.fill: parent + hoverEnabled: true + enabled: base.settingsEnabled + + onClicked: + { + var adhesionType = "skirt" + if (!parent.checked) + { + // Remove the "user" setting to see if the rest of the stack prescribes a brim or a raft + platformAdhesionType.removeFromContainer(0) + adhesionType = platformAdhesionType.properties.value + if(adhesionType == "skirt" || adhesionType == "none") + { + // If the rest of the stack doesn't prescribe an adhesion-type, default to a brim + adhesionType = "brim" + } + } + platformAdhesionType.setPropertyValue("value", adhesionType) + } + + onEntered: + { + base.showTooltip(enableAdhesionCheckBox, Qt.point(-enableAdhesionContainer.x - UM.Theme.getSize("thick_margin").width, 0), + catalog.i18nc("@label", "Enable printing a brim or raft. This will add a flat area around or under your object which is easy to cut off afterwards.")); + } + onExited: base.hideTooltip() + } + } + } + + UM.SettingPropertyProvider + { + id: platformAdhesionType + containerStack: Cura.MachineManager.activeMachine + removeUnusedValue: false //Doesn't work with settings that are resolved. + key: "adhesion_type" + watchedProperties: [ "value", "enabled" ] + storeIndex: 0 + } +} \ No newline at end of file diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml index d246be560e..a8fca47d6c 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml @@ -65,76 +65,11 @@ Item labelColumnWidth: parent.firstColumnWidth } - -// -// // Adhesion -// Row -// { -// anchors.left: parent.left -// anchors.right: parent.right -// height: childrenRect.height -// -// Cura.IconWithText -// { -// id: adhesionHelperLabel -// visible: adhesionCheckBox.visible -// source: UM.Theme.getIcon("category_adhesion") -// text: catalog.i18nc("@label", "Adhesion") -// width: labelColumnWidth -// } -// -// CheckBox -// { -// id: adhesionCheckBox -// property alias _hovered: adhesionMouseArea.containsMouse -// -// //: Setting enable printing build-plate adhesion helper checkbox -// style: UM.Theme.styles.checkbox -// enabled: base.settingsEnabled -// -// visible: platformAdhesionType.properties.enabled == "True" -// checked: platformAdhesionType.properties.value != "skirt" && platformAdhesionType.properties.value != "none" -// -// MouseArea -// { -// id: adhesionMouseArea -// anchors.fill: parent -// hoverEnabled: true -// enabled: base.settingsEnabled -// onClicked: -// { -// var adhesionType = "skirt" -// if(!parent.checked) -// { -// // Remove the "user" setting to see if the rest of the stack prescribes a brim or a raft -// platformAdhesionType.removeFromContainer(0) -// adhesionType = platformAdhesionType.properties.value -// if(adhesionType == "skirt" || adhesionType == "none") -// { -// // If the rest of the stack doesn't prescribe an adhesion-type, default to a brim -// adhesionType = "brim" -// } -// } -// platformAdhesionType.setPropertyValue("value", adhesionType) -// } -// onEntered: -// { -// base.showTooltip(adhesionCheckBox, Qt.point(-adhesionCheckBox.x, 0), -// catalog.i18nc("@label", "Enable printing a brim or raft. This will add a flat area around or under your object which is easy to cut off afterwards.")); -// } -// onExited: base.hideTooltip() -// } -// } -// } - } - - UM.SettingPropertyProvider - { - id: platformAdhesionType - containerStack: Cura.MachineManager.activeMachine - removeUnusedValue: false //Doesn't work with settings that are resolved. - key: "adhesion_type" - watchedProperties: [ "value", "enabled" ] - storeIndex: 0 + RecommendedAdhesionSelector + { + width: parent.width + // TODO Create a reusable component with these properties to not define them separately for each component + labelColumnWidth: parent.firstColumnWidth + } } } diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml index 2407b746b2..4e63242f05 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml @@ -33,7 +33,7 @@ Item Item { id: enableSupportContainer - height: childrenRect.height + height: enableSupportCheckBox.height anchors { From 7dc3320b0648142719b59c7a73dcf66da373335c Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Sun, 2 Dec 2018 20:32:55 +0100 Subject: [PATCH 31/70] Remove all the signal propagation for the tooltip and allow only Cura.qml to handle them Contributes to CURA-5941. --- plugins/PrepareStage/PrepareMenu.qml | 4 ---- plugins/PreviewStage/PreviewMenu.qml | 3 --- resources/qml/Cura.qml | 9 --------- .../Custom/CustomPrintSetup.qml | 13 ++++++++++++- .../PrintSetupSelector/PrintSetupSelector.qml | 17 +---------------- .../PrintSetupSelectorContents.qml | 9 +++------ .../Recommended/RecommendedAdhesionSelector.qml | 7 ++++--- .../RecommendedInfillDensitySelector.qml | 2 +- .../Recommended/RecommendedPrintSetup.qml | 5 +---- .../Recommended/RecommendedSupportSelector.qml | 7 ++++--- resources/qml/Settings/SettingView.qml | 6 ++---- 11 files changed, 28 insertions(+), 54 deletions(-) diff --git a/plugins/PrepareStage/PrepareMenu.qml b/plugins/PrepareStage/PrepareMenu.qml index 7c01b1f8b0..0191396e7b 100644 --- a/plugins/PrepareStage/PrepareMenu.qml +++ b/plugins/PrepareStage/PrepareMenu.qml @@ -13,10 +13,6 @@ import QtGraphicalEffects 1.0 // For the dropshadow Item { id: prepareMenu - // This widget doesn't show tooltips by itself. Instead it emits signals so others can do something with it. - signal showTooltip(Item item, point location, string text) - signal hideTooltip() - UM.I18nCatalog { diff --git a/plugins/PreviewStage/PreviewMenu.qml b/plugins/PreviewStage/PreviewMenu.qml index a1f59cd4ca..1543536160 100644 --- a/plugins/PreviewStage/PreviewMenu.qml +++ b/plugins/PreviewStage/PreviewMenu.qml @@ -10,9 +10,6 @@ import Cura 1.1 as Cura Item { id: previewMenu - // This widget doesn't show tooltips by itself. Instead it emits signals so others can do something with it. - signal showTooltip(Item item, point location, string text) - signal hideTooltip() property real itemHeight: height - 2 * UM.Theme.getSize("default_lining").width diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index 36f5758fa3..4effea5ba7 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -181,13 +181,6 @@ UM.MainWindow } } - Connections - { - target: stageMenu.item - onShowTooltip: base.showTooltip(item, location, text) - onHideTooltip: base.hideTooltip() - } - JobSpecs { id: jobSpecs @@ -280,8 +273,6 @@ UM.MainWindow // Every time the stage is changed. property var printSetupSelector: Cura.PrintSetupSelector { - onShowTooltip: base.showTooltip(item, location, text) - onHideTooltip: base.hideTooltip() width: UM.Theme.getSize("print_setup_widget").width height: UM.Theme.getSize("stage_menu").height headerCornerSide: RoundedRectangle.Direction.Right diff --git a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml index 51cd8eff0d..ea56a4471e 100644 --- a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml @@ -6,5 +6,16 @@ import QtQuick.Controls 2.0 import Cura 1.0 as Cura -Cura.SettingView { + +Item +{ + id: customPrintSetup + + // TODO: Hardcoded now but UX has to decide about the height of this item + height: 500 + + Cura.SettingView + { + anchors.fill: parent + } } diff --git a/resources/qml/PrintSetupSelector/PrintSetupSelector.qml b/resources/qml/PrintSetupSelector/PrintSetupSelector.qml index 1794a54cdf..5518ac6b60 100644 --- a/resources/qml/PrintSetupSelector/PrintSetupSelector.qml +++ b/resources/qml/PrintSetupSelector/PrintSetupSelector.qml @@ -9,17 +9,13 @@ import Cura 1.0 as Cura Cura.ExpandableComponent { - id: base + id: printSetupSelector property bool hideSettings: PrintInformation.preSliced property string enabledText: catalog.i18nc("@label:Should be short", "On") property string disabledText: catalog.i18nc("@label:Should be short", "Off") - // This widget doesn't show tooltips by itself. Instead it emits signals so others can do something with it. - signal showTooltip(Item item, point location, string text) - signal hideTooltip() - iconSource: UM.Theme.getIcon("pencil") popupPadding: UM.Theme.getSize("default_lining").width popupSpacingY: UM.Theme.getSize("narrow_margin").width @@ -32,17 +28,6 @@ Cura.ExpandableComponent name: "cura" } - Timer - { - id: tooltipDelayTimer - interval: 500 - repeat: false - property var item - property string text - - onTriggered: base.showTooltip(base, {x: 0, y: item.y}, text) - } - headerItem: PrintSetupSelectorHeader { anchors.fill: parent diff --git a/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml b/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml index 0210ece977..77d1b59f4c 100644 --- a/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml +++ b/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml @@ -93,7 +93,7 @@ Item Item { id: contents - height: childrenRect.height + height: currentModeIndex == 0 ? recommendedPrintSetup.height : customPrintSetup.height anchors { @@ -104,28 +104,25 @@ Item RecommendedPrintSetup { + id: recommendedPrintSetup anchors { left: parent.left right: parent.right top: parent.top } - onShowTooltip: base.showTooltip(item, location, text) - onHideTooltip: base.hideTooltip() visible: currentModeIndex == 0 } CustomPrintSetup { + id: customPrintSetup anchors { left: parent.left right: parent.right top: parent.top } - height: 500 - onShowTooltip: base.showTooltip(item, location, text) - onHideTooltip: base.hideTooltip() visible: currentModeIndex == 1 } } diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml index a7e8b3ea75..3092644d4e 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml @@ -32,7 +32,7 @@ Item Item { id: enableAdhesionContainer - height: childrenRect.height + height: enableAdhesionCheckBox.height anchors { @@ -46,9 +46,11 @@ Item id: enableAdhesionCheckBox anchors.verticalCenter: parent.verticalCenter + property alias _hovered: adhesionMouseArea.containsMouse + //: Setting enable printing build-plate adhesion helper checkbox style: UM.Theme.styles.checkbox - enabled: base.settingsEnabled + enabled: recommendedPrintSettup.settingsEnabled visible: platformAdhesionType.properties.enabled == "True" checked: platformAdhesionType.properties.value != "skirt" && platformAdhesionType.properties.value != "none" @@ -58,7 +60,6 @@ Item id: adhesionMouseArea anchors.fill: parent hoverEnabled: true - enabled: base.settingsEnabled onClicked: { diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedInfillDensitySelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedInfillDensitySelector.qml index 0dd594176c..7c026ac9de 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedInfillDensitySelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedInfillDensitySelector.qml @@ -189,7 +189,7 @@ Item text: catalog.i18nc("@label", "Gradual infill") style: UM.Theme.styles.checkbox - enabled: base.settingsEnabled + enabled: recommendedPrintSettup.settingsEnabled visible: infillSteps.properties.enabled == "True" checked: parseInt(infillSteps.properties.value) > 0 diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml index a8fca47d6c..194747271e 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml @@ -10,13 +10,10 @@ import Cura 1.0 as Cura Item { - id: base + id: recommendedPrintSettup height: childrenRect.height + 2 * padding - signal showTooltip(Item item, point location, string text) - signal hideTooltip() - property Action configureSettings property bool settingsEnabled: Cura.ExtruderManager.activeExtruderStackId || extrudersEnabledCount.properties.value == 1 diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml index 4e63242f05..25a5574a39 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml @@ -50,7 +50,7 @@ Item property alias _hovered: enableSupportMouseArea.containsMouse style: UM.Theme.styles.checkbox - enabled: base.settingsEnabled + enabled: recommendedPrintSettup.settingsEnabled visible: supportEnabled.properties.enabled == "True" checked: supportEnabled.properties.value == "True" @@ -60,6 +60,7 @@ Item id: enableSupportMouseArea anchors.fill: parent hoverEnabled: true + onClicked: supportEnabled.setPropertyValue("value", supportEnabled.properties.value != "True") onEntered: @@ -86,7 +87,7 @@ Item } style: UM.Theme.styles.combobox_color - enabled: base.settingsEnabled + enabled: recommendedPrintSettup.settingsEnabled visible: enableSupportCheckBox.visible && (supportEnabled.properties.value == "True") && (extrudersEnabledCount.properties.value > 1) textRole: "text" // this solves that the combobox isn't populated in the first time Cura is started @@ -126,7 +127,7 @@ Item id: supportExtruderMouseArea anchors.fill: parent hoverEnabled: true - enabled: base.settingsEnabled + enabled: recommendedPrintSettup.settingsEnabled acceptedButtons: Qt.NoButton onEntered: { diff --git a/resources/qml/Settings/SettingView.qml b/resources/qml/Settings/SettingView.qml index 0a7102ff45..270f04e70f 100644 --- a/resources/qml/Settings/SettingView.qml +++ b/resources/qml/Settings/SettingView.qml @@ -13,13 +13,11 @@ import "../Menus" Item { - id: base; + id: settingsView property QtObject settingVisibilityPresetsModel: CuraApplication.getSettingVisibilityPresetsModel() property Action configureSettings property bool findingSettings - signal showTooltip(Item item, point location, string text) - signal hideTooltip() ToolButton { @@ -359,7 +357,7 @@ Item contextMenu.provider = provider contextMenu.popup(); } - onShowTooltip: base.showTooltip(delegate, { x: -UM.Theme.getSize("default_arrow").width, y: Math.round(delegate.height / 2) }, text) + onShowTooltip: base.showTooltip(delegate, Qt.point(- UM.Theme.getSize("default_arrow").width, 0), text) onHideTooltip: base.hideTooltip() onShowAllHiddenInheritedSettings: { From 90281c455b74a56fc49c45724fee3e4b3aa88f85 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Mon, 3 Dec 2018 09:45:49 +0100 Subject: [PATCH 32/70] Add global profile selector to the custom print setup panel Also modify some styles to adjust to the designs. Contributes to CURA-5941. --- .../Custom/CustomPrintSetup.qml | 29 +++++++++- .../Custom/GlobalProfileSelector.qml} | 53 +++++++++++-------- .../PrintSetupSelector/PrintSetupSelector.qml | 2 - .../RecommendedQualityProfileSelector.qml | 4 +- .../RecommendedSupportSelector.qml | 2 +- resources/qml/qmldir | 3 +- resources/themes/cura-light/styles.qml | 6 ++- resources/themes/cura-light/theme.json | 3 +- 8 files changed, 71 insertions(+), 31 deletions(-) rename resources/qml/{GlobalProfileButton.qml => PrintSetupSelector/Custom/GlobalProfileSelector.qml} (67%) diff --git a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml index ea56a4471e..e0f0827b17 100644 --- a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml @@ -4,6 +4,7 @@ import QtQuick 2.7 import QtQuick.Controls 2.0 +import UM 1.3 as UM import Cura 1.0 as Cura @@ -14,8 +15,34 @@ Item // TODO: Hardcoded now but UX has to decide about the height of this item height: 500 + property real padding: UM.Theme.getSize("default_margin").width + + // Profile selector row + GlobalProfileSelector + { + id: globalProfileRow + anchors + { + top: parent.top + topMargin: parent.padding + left: parent.left + leftMargin: parent.padding + right: parent.right + rightMargin: parent.padding + } + } + Cura.SettingView { - anchors.fill: parent + anchors + { + top: globalProfileRow.bottom + topMargin: UM.Theme.getSize("default_margin").height + left: parent.left + leftMargin: parent.padding + right: parent.right + rightMargin: parent.padding + bottom: parent.bottom + } } } diff --git a/resources/qml/GlobalProfileButton.qml b/resources/qml/PrintSetupSelector/Custom/GlobalProfileSelector.qml similarity index 67% rename from resources/qml/GlobalProfileButton.qml rename to resources/qml/PrintSetupSelector/Custom/GlobalProfileSelector.qml index bac2732037..91525d0f9e 100644 --- a/resources/qml/GlobalProfileButton.qml +++ b/resources/qml/PrintSetupSelector/Custom/GlobalProfileSelector.qml @@ -9,24 +9,25 @@ import QtQuick.Layouts 1.2 import UM 1.2 as UM import Cura 1.0 as Cura -import "Menus" - Item { id: globalProfileRow - height: UM.Theme.getSize("print_setup_item").height + height: childrenRect.height Label { id: globalProfileLabel - text: catalog.i18nc("@label","Profile:") - textFormat: Text.PlainText - width: Math.round(parent.width * 0.45 - UM.Theme.getSize("thick_margin").width - 2) + anchors + { + top: parent.top + bottom: parent.bottom + left: parent.left + right: globalProfileSelection.left + } + text: catalog.i18nc("@label", "Profile") font: UM.Theme.getFont("default") color: UM.Theme.getColor("text") verticalAlignment: Text.AlignVCenter - anchors.top: parent.top - anchors.bottom: parent.bottom } ToolButton @@ -34,20 +35,30 @@ Item id: globalProfileSelection text: generateActiveQualityText() - width: Math.round(parent.width * 0.55) - height: UM.Theme.getSize("setting_control").height - anchors.left: globalProfileLabel.right - anchors.right: parent.right + width: UM.Theme.getSize("print_setup_big_dropdown").width + height: UM.Theme.getSize("print_setup_big_dropdown").height + anchors + { + top: parent.top + right: parent.right + } tooltip: Cura.MachineManager.activeQualityOrQualityChangesName style: UM.Theme.styles.sidebar_header_button activeFocusOnPress: true - menu: ProfileMenu { } + menu: Cura.ProfileMenu { } - function generateActiveQualityText () { - var result = Cura.MachineManager.activeQualityOrQualityChangesName; + function generateActiveQualityText() + { + var result = Cura.MachineManager.activeQualityOrQualityChangesName + if (Cura.MachineManager.isActiveQualityExperimental) + { + result += " (Experimental)" + } - if (Cura.MachineManager.isActiveQualitySupported) { - if (Cura.MachineManager.activeQualityLayerHeight > 0) { + if (Cura.MachineManager.isActiveQualitySupported) + { + if (Cura.MachineManager.activeQualityLayerHeight > 0) + { result += " " result += " - " result += Cura.MachineManager.activeQualityLayerHeight + "mm" @@ -63,15 +74,15 @@ Item id: customisedSettings visible: Cura.MachineManager.hasUserSettings - height: Math.round(parent.height * 0.6) - width: Math.round(parent.height * 0.6) + width: UM.Theme.getSize("print_setup_icon").width + height: UM.Theme.getSize("print_setup_icon").height anchors.verticalCenter: parent.verticalCenter anchors.right: parent.right anchors.rightMargin: Math.round(UM.Theme.getSize("setting_preferences_button_margin").width - UM.Theme.getSize("thick_margin").width) color: hovered ? UM.Theme.getColor("setting_control_button_hover") : UM.Theme.getColor("setting_control_button"); - iconSource: UM.Theme.getIcon("star"); + iconSource: UM.Theme.getIcon("star") onClicked: { @@ -81,7 +92,7 @@ Item onEntered: { var content = catalog.i18nc("@tooltip","Some setting/override values are different from the values stored in the profile.\n\nClick to open the profile manager.") - base.showTooltip(globalProfileRow, Qt.point(-UM.Theme.getSize("thick_margin").width, 0), content) + base.showTooltip(globalProfileRow, Qt.point(-UM.Theme.getSize("default_margin").width, 0), content) } onExited: base.hideTooltip() } diff --git a/resources/qml/PrintSetupSelector/PrintSetupSelector.qml b/resources/qml/PrintSetupSelector/PrintSetupSelector.qml index 5518ac6b60..f1b424f7f2 100644 --- a/resources/qml/PrintSetupSelector/PrintSetupSelector.qml +++ b/resources/qml/PrintSetupSelector/PrintSetupSelector.qml @@ -11,8 +11,6 @@ Cura.ExpandableComponent { id: printSetupSelector - property bool hideSettings: PrintInformation.preSliced - property string enabledText: catalog.i18nc("@label:Should be short", "On") property string disabledText: catalog.i18nc("@label:Should be short", "Off") diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml index cddf01a4dc..4963f10792 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml @@ -182,7 +182,7 @@ Item id: customisedSettings visible: Cura.SimpleModeSettingsManager.isProfileCustomized || Cura.SimpleModeSettingsManager.isProfileUserCreated - height: visible ? Math.round(0.8 * qualityRowTitle.height) : 0 + height: visible ? UM.Theme.getSize("print_setup_icon").height : 0 width: height anchors { @@ -203,7 +203,7 @@ Item onEntered: { var tooltipContent = catalog.i18nc("@tooltip","You have modified some profile settings. If you want to change these go to custom mode.") - base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), tooltipContent) + base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, 0), tooltipContent) } onExited: base.hideTooltip() } diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml index 25a5574a39..d367510ef6 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml @@ -76,7 +76,7 @@ Item { id: supportExtruderCombobox - height: UM.Theme.getSize("print_setup_support_extruder_selector").height + height: UM.Theme.getSize("print_setup_big_dropdown").height anchors { left: enableSupportCheckBox.right diff --git a/resources/qml/qmldir b/resources/qml/qmldir index c0a8bac0ae..4dc9a34894 100644 --- a/resources/qml/qmldir +++ b/resources/qml/qmldir @@ -15,4 +15,5 @@ ExpandableComponent 1.0 ExpandableComponent.qml PrinterTypeLabel 1.0 PrinterTypeLabel.qml ViewsSelector 1.0 ViewsSelector.qml ToolbarButton 1.0 ToolbarButton.qml -SettingView 1.0 SettingView.qml \ No newline at end of file +SettingView 1.0 SettingView.qml +ProfileMenu 1.0 ProfileMenu.qml \ No newline at end of file diff --git a/resources/themes/cura-light/styles.qml b/resources/themes/cura-light/styles.qml index 5203cb0b0b..e6144bb6ec 100755 --- a/resources/themes/cura-light/styles.qml +++ b/resources/themes/cura-light/styles.qml @@ -38,6 +38,7 @@ QtObject } } + radius: UM.Theme.getSize("setting_control_radius").width border.width: Theme.getSize("default_lining").width border.color: { @@ -489,11 +490,12 @@ QtObject UM.RecolorImage { id: swatch - height: Math.round(UM.Theme.getSize("setting_control").height / 2) + height: Math.round(control.height / 2) width: height anchors.right: downArrow.left anchors.verticalCenter: parent.verticalCenter - anchors.margins: Math.round(UM.Theme.getSize("default_margin").width / 4) + anchors.rightMargin: UM.Theme.getSize("default_margin").width +// anchors.margins: Math.round(UM.Theme.getSize("default_margin").width / 4) sourceSize.width: width sourceSize.height: height source: UM.Theme.getIcon("extruder_button") diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index afe40007f4..2c5c7a360a 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -377,7 +377,8 @@ "print_setup_slider_groove": [0.16, 0.16], "print_setup_slider_handle": [1.0, 1.0], "print_setup_slider_tickmarks": [0.32, 0.32], - "print_setup_support_extruder_selector": [18.2, 2.5], + "print_setup_big_dropdown": [28, 2.5], + "print_setup_icon": [1.2, 1.2], "configuration_selector_mode_tabs": [0.0, 3.0], From 4c468831f06fcc33de6b657985aed22907c2796c Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Mon, 3 Dec 2018 13:58:13 +0100 Subject: [PATCH 33/70] Add tabs for select the extruder in the custom print setup. Align some elements beneath the tabs. Contributes to CURA-5941. --- .../Custom/CustomPrintSetup.qml | 63 +++++- .../Custom/GlobalProfileSelector.qml | 4 +- .../Recommended/RecommendedPrintSetup.qml | 9 + .../RecommendedSupportSelector.qml | 11 +- resources/qml/Settings/SettingView.qml | 186 +++++++++--------- resources/themes/cura-light/styles.qml | 2 +- resources/themes/cura-light/theme.json | 4 +- 7 files changed, 164 insertions(+), 115 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml index e0f0827b17..ae31976a34 100644 --- a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml @@ -13,9 +13,15 @@ Item id: customPrintSetup // TODO: Hardcoded now but UX has to decide about the height of this item - height: 500 + height: 480 property real padding: UM.Theme.getSize("default_margin").width + property bool multipleExtruders: extrudersModel.count > 1 + + Cura.ExtrudersModel + { + id: extrudersModel + } // Profile selector row GlobalProfileSelector @@ -32,11 +38,64 @@ Item } } + UM.TabRow + { + id: tabBar + + visible: multipleExtruders // The tab row is only visible when there are more than 1 extruder + + anchors + { + top: globalProfileRow.bottom + topMargin: UM.Theme.getSize("default_margin").height + left: parent.left + leftMargin: parent.padding + right: parent.right + rightMargin: parent.padding + } + + currentIndex: Math.max(Cura.ExtruderManager.activeExtruderIndex, 0) + + Repeater + { + id: repeater + model: extrudersModel + delegate: UM.TabRowButton + { + contentItem: Item + { + Cura.ExtruderIcon + { + anchors.horizontalCenter: parent.horizontalCenter + materialColor: model.color + extruderEnabled: model.enabled + } + } + onClicked: + { + Cura.ExtruderManager.setActiveExtruderIndex(tabBar.currentIndex) + } + } + } + + // When the model of the extruders is rebuilt, the list of extruders is briefly emptied and rebuilt. + // This causes the currentIndex of the tab to be in an invalid position which resets it to 0. + // Therefore we need to change it back to what it was: The active extruder index. + Connections + { + target: repeater.model + onModelChanged: + { + tabBar.currentIndex = Math.max(Cura.ExtruderManager.activeExtruderIndex, 0) + } + } + } + Cura.SettingView { anchors { - top: globalProfileRow.bottom + top: tabBar.visible ? tabBar.bottom : globalProfileRow.bottom topMargin: UM.Theme.getSize("default_margin").height left: parent.left leftMargin: parent.padding diff --git a/resources/qml/PrintSetupSelector/Custom/GlobalProfileSelector.qml b/resources/qml/PrintSetupSelector/Custom/GlobalProfileSelector.qml index 91525d0f9e..11b2d3608b 100644 --- a/resources/qml/PrintSetupSelector/Custom/GlobalProfileSelector.qml +++ b/resources/qml/PrintSetupSelector/Custom/GlobalProfileSelector.qml @@ -35,8 +35,8 @@ Item id: globalProfileSelection text: generateActiveQualityText() - width: UM.Theme.getSize("print_setup_big_dropdown").width - height: UM.Theme.getSize("print_setup_big_dropdown").height + width: UM.Theme.getSize("print_setup_big_item").width + height: UM.Theme.getSize("print_setup_big_item").height anchors { top: parent.top diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml index 194747271e..618c519d31 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml @@ -69,4 +69,13 @@ Item labelColumnWidth: parent.firstColumnWidth } } + + UM.SettingPropertyProvider + { + id: extrudersEnabledCount + containerStack: Cura.MachineManager.activeMachine + key: "extruders_enabled_count" + watchedProperties: [ "value" ] + storeIndex: 0 + } } diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml index d367510ef6..ce4aa6c195 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml @@ -76,7 +76,7 @@ Item { id: supportExtruderCombobox - height: UM.Theme.getSize("print_setup_big_dropdown").height + height: UM.Theme.getSize("print_setup_big_item").height anchors { left: enableSupportCheckBox.right @@ -171,15 +171,6 @@ Item storeIndex: 0 } - UM.SettingPropertyProvider - { - id: extrudersEnabledCount - containerStack: Cura.MachineManager.activeMachine - key: "extruders_enabled_count" - watchedProperties: [ "value" ] - storeIndex: 0 - } - UM.SettingPropertyProvider { id: supportExtruderNr diff --git a/resources/qml/Settings/SettingView.qml b/resources/qml/Settings/SettingView.qml index 2c42d222ce..3250e847a3 100644 --- a/resources/qml/Settings/SettingView.qml +++ b/resources/qml/Settings/SettingView.qml @@ -19,70 +19,22 @@ Item property Action configureSettings property bool findingSettings - ToolButton - { - id: settingVisibilityMenu - - property var toolButtonIconColor: UM.Theme.getColor("setting_category_text") - - width: height - height: UM.Theme.getSize("setting_control").height - anchors - { - topMargin: UM.Theme.getSize("thick_margin").height - left: filterContainer.right - leftMargin: UM.Theme.getSize("default_margin").width - } - style: ButtonStyle - { - background: Item { - UM.RecolorImage { - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - width: Math.round(parent.width * 0.6) - height: Math.round(parent.height * 0.6) - sourceSize.width: width - sourceSize.height: width - color: settingVisibilityMenu.toolButtonIconColor - source: UM.Theme.getIcon("settings") - } - } - label: Label{} - } - menu: SettingVisibilityPresetsMenu - { - onShowAllSettings: - { - definitionsModel.setAllVisible(true); - filter.updateDefinitionModel(); - } - } - - MouseArea - { - anchors.fill: parent - hoverEnabled: true - acceptedButtons: Qt.RightButton - onEntered: settingVisibilityMenu.toolButtonIconColor = UM.Theme.getColor("setting_control_button_hover") - onExited: settingVisibilityMenu.toolButtonIconColor = UM.Theme.getColor("setting_category_text") - } - } - Rectangle { id: filterContainer visible: true + radius: UM.Theme.getSize("setting_control_radius").width border.width: Math.round(UM.Theme.getSize("default_lining").width) border.color: { - if(hoverMouseArea.containsMouse || clearFilterButton.containsMouse) + if (hoverMouseArea.containsMouse || clearFilterButton.containsMouse) { - return UM.Theme.getColor("setting_control_border_highlight"); + return UM.Theme.getColor("setting_control_border_highlight") } else { - return UM.Theme.getColor("setting_control_border"); + return UM.Theme.getColor("setting_control_border") } } @@ -90,13 +42,12 @@ Item anchors { - topMargin: UM.Theme.getSize("thick_margin").height + top: parent.top left: parent.left - leftMargin: UM.Theme.getSize("default_margin").width - right: scrollView.right - rightMargin: Math.floor(UM.Theme.getSize("wide_margin").width * 2) + right: settingVisibilityMenu.left + rightMargin: UM.Theme.getSize("default_margin").width } - height: UM.Theme.getSize("setting_control").height + height: UM.Theme.getSize("print_setup_big_item").height Timer { id: settingsSearchTimer @@ -108,7 +59,7 @@ Item TextField { - id: filter; + id: filter height: parent.height anchors.left: parent.left anchors.right: clearFilterButton.left @@ -118,9 +69,9 @@ Item style: TextFieldStyle { - textColor: UM.Theme.getColor("setting_control_text"); + textColor: UM.Theme.getColor("setting_control_text") placeholderTextColor: UM.Theme.getColor("setting_filter_field") - font: UM.Theme.getFont("default"); + font: UM.Theme.getFont("default_italic") background: Item {} } @@ -134,38 +85,38 @@ Item onEditingFinished: { - definitionsModel.filter = {"i18n_label": "*" + text}; - findingSettings = (text.length > 0); - if(findingSettings != lastFindingSettings) + definitionsModel.filter = {"i18n_label": "*" + text} + findingSettings = (text.length > 0) + if (findingSettings != lastFindingSettings) { - updateDefinitionModel(); - lastFindingSettings = findingSettings; + updateDefinitionModel() + lastFindingSettings = findingSettings } } Keys.onEscapePressed: { - filter.text = ""; + filter.text = "" } function updateDefinitionModel() { - if(findingSettings) + if (findingSettings) { - expandedCategories = definitionsModel.expanded.slice(); - definitionsModel.expanded = [""]; // keep categories closed while to prevent render while making settings visible one by one - definitionsModel.showAncestors = true; - definitionsModel.showAll = true; - definitionsModel.expanded = ["*"]; + expandedCategories = definitionsModel.expanded.slice() + definitionsModel.expanded = [""] // keep categories closed while to prevent render while making settings visible one by one + definitionsModel.showAncestors = true + definitionsModel.showAll = true + definitionsModel.expanded = ["*"] } else { - if(expandedCategories) + if (expandedCategories) { - definitionsModel.expanded = expandedCategories; + definitionsModel.expanded = expandedCategories } - definitionsModel.showAncestors = false; - definitionsModel.showAll = false; + definitionsModel.showAncestors = false + definitionsModel.showAll = false } } } @@ -197,8 +148,45 @@ Item onClicked: { - filter.text = ""; - filter.forceActiveFocus(); + filter.text = "" + filter.forceActiveFocus() + } + } + } + + ToolButton + { + id: settingVisibilityMenu + + anchors + { + top: filterContainer.top + bottom: filterContainer.bottom + right: parent.right + } + + style: ButtonStyle + { + background: Item { + UM.RecolorImage { + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + width: UM.Theme.getSize("standard_arrow").width + height: UM.Theme.getSize("standard_arrow").height + sourceSize.width: width + sourceSize.height: height + color: control.enabled ? UM.Theme.getColor("setting_category_text") : UM.Theme.getColor("setting_category_disabled_text") + source: UM.Theme.getIcon("menu") + } + } + label: Label{} + } + menu: SettingVisibilityPresetsMenu + { + onShowAllSettings: + { + definitionsModel.setAllVisible(true) + filter.updateDefinitionModel() } } } @@ -206,33 +194,35 @@ Item ScrollView { id: scrollView - anchors.top: filterContainer.bottom; - anchors.bottom: parent.bottom; - anchors.right: parent.right; - anchors.left: parent.left; - anchors.topMargin: UM.Theme.getSize("thick_margin").height - anchors.rightMargin: UM.Theme.getSize("narrow_margin").height / 3 + anchors + { + top: filterContainer.bottom + topMargin: UM.Theme.getSize("default_margin").height + bottom: parent.bottom + right: parent.right + left: parent.left + } - style: UM.Theme.styles.scrollview; - flickableItem.flickableDirection: Flickable.VerticalFlick; - __wheelAreaScrollSpeed: 75; // Scroll three lines in one scroll event + style: UM.Theme.styles.scrollview + flickableItem.flickableDirection: Flickable.VerticalFlick + __wheelAreaScrollSpeed: 75 // Scroll three lines in one scroll event ListView { id: contents - spacing: Math.round(UM.Theme.getSize("default_lining").height); - cacheBuffer: 1000000; // Set a large cache to effectively just cache every list item. + spacing: Math.round(UM.Theme.getSize("default_lining").height) + cacheBuffer: 1000000 // Set a large cache to effectively just cache every list item. model: UM.SettingDefinitionsModel { - id: definitionsModel; + id: definitionsModel containerId: Cura.MachineManager.activeDefinitionId visibilityHandler: UM.SettingPreferenceVisibilityHandler { } exclude: ["machine_settings", "command_line_settings", "infill_mesh", "infill_mesh_order", "cutting_mesh", "support_mesh", "anti_overhang_mesh"] // TODO: infill_mesh settigns are excluded hardcoded, but should be based on the fact that settable_globally, settable_per_meshgroup and settable_per_extruder are false. expanded: CuraApplication.expandedCategories onExpandedChanged: { - if(!findingSettings) + if (!findingSettings) { // Do not change expandedCategories preference while filtering settings // because all categories are expanded while filtering @@ -248,7 +238,7 @@ Item { id: delegate - width: Math.round(UM.Theme.getSize("print_setup_widget").width); + width: scrollView.width height: provider.properties.enabled == "True" ? UM.Theme.getSize("section").height : - contents.spacing Behavior on height { NumberAnimation { duration: 100 } } opacity: provider.properties.enabled == "True" ? 1 : 0 @@ -318,17 +308,17 @@ Item // machine gets changed. var activeMachineId = Cura.MachineManager.activeMachineId; - if(!model.settable_per_extruder) + if (!model.settable_per_extruder) { //Not settable per extruder or there only is global, so we must pick global. return activeMachineId; } - if(inheritStackProvider.properties.limit_to_extruder != null && inheritStackProvider.properties.limit_to_extruder >= 0) + if (inheritStackProvider.properties.limit_to_extruder != null && inheritStackProvider.properties.limit_to_extruder >= 0) { //We have limit_to_extruder, so pick that stack. return Cura.ExtruderManager.extruderIds[String(inheritStackProvider.properties.limit_to_extruder)]; } - if(Cura.ExtruderManager.activeExtruderStackId) + if (Cura.ExtruderManager.activeExtruderStackId) { //We're on an extruder tab. Pick the current extruder. return Cura.ExtruderManager.activeExtruderStackId; @@ -390,14 +380,14 @@ Item } onSetActiveFocusToNextSetting: { - if(forward == undefined || forward) + if (forward == undefined || forward) { contents.currentIndex = contents.indexWithFocus + 1; while(contents.currentItem && contents.currentItem.height <= 0) { contents.currentIndex++; } - if(contents.currentItem) + if (contents.currentItem) { contents.currentItem.item.focusItem.forceActiveFocus(); } @@ -409,7 +399,7 @@ Item { contents.currentIndex--; } - if(contents.currentItem) + if (contents.currentItem) { contents.currentItem.item.focusItem.forceActiveFocus(); } diff --git a/resources/themes/cura-light/styles.qml b/resources/themes/cura-light/styles.qml index e6144bb6ec..ca95b6d373 100755 --- a/resources/themes/cura-light/styles.qml +++ b/resources/themes/cura-light/styles.qml @@ -495,7 +495,7 @@ QtObject anchors.right: downArrow.left anchors.verticalCenter: parent.verticalCenter anchors.rightMargin: UM.Theme.getSize("default_margin").width -// anchors.margins: Math.round(UM.Theme.getSize("default_margin").width / 4) + sourceSize.width: width sourceSize.height: height source: UM.Theme.getIcon("extruder_button") diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index 2c5c7a360a..5af77d59c3 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -377,7 +377,7 @@ "print_setup_slider_groove": [0.16, 0.16], "print_setup_slider_handle": [1.0, 1.0], "print_setup_slider_tickmarks": [0.32, 0.32], - "print_setup_big_dropdown": [28, 2.5], + "print_setup_big_item": [28, 2.5], "print_setup_icon": [1.2, 1.2], "configuration_selector_mode_tabs": [0.0, 3.0], @@ -425,7 +425,7 @@ "setting_text_maxwidth": [40.0, 0.0], "standard_list_lineheight": [1.5, 1.5], - "standard_arrow": [0.8, 0.8], + "standard_arrow": [1.0, 1.0], "button": [4, 4], "button_icon": [2.5, 2.5], From ce6a0676dd029a8e4b6ce7d5e2640c8114505fa5 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Mon, 3 Dec 2018 14:43:35 +0100 Subject: [PATCH 34/70] Add a rectangle surrounding the settings listview Contributes to CURA-5941. --- .../Custom/CustomPrintSetup.qml | 23 +++++++++++++++++-- resources/qml/Settings/SettingCategory.qml | 20 ++++++++-------- resources/qml/Settings/SettingItem.qml | 11 +++++---- resources/qml/Settings/SettingView.qml | 3 ++- resources/themes/cura-light/styles.qml | 4 ++-- resources/themes/cura-light/theme.json | 2 +- 6 files changed, 43 insertions(+), 20 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml index ae31976a34..b524bb5926 100644 --- a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml @@ -91,17 +91,36 @@ Item } } - Cura.SettingView + Rectangle { anchors { top: tabBar.visible ? tabBar.bottom : globalProfileRow.bottom - topMargin: UM.Theme.getSize("default_margin").height left: parent.left leftMargin: parent.padding right: parent.right rightMargin: parent.padding bottom: parent.bottom + topMargin: -UM.Theme.getSize("default_lining").width + bottomMargin: -UM.Theme.getSize("default_lining").width + } + z: tabBar.z - 1 + // Don't show the border when only one extruder + border.color: tabBar.visible ? UM.Theme.getColor("lining") : "transparent" + border.width: UM.Theme.getSize("default_lining").width + + Cura.SettingView + { + anchors + { + fill: parent + topMargin: UM.Theme.getSize("default_margin").height + leftMargin: UM.Theme.getSize("default_margin").width + // Small space for the scrollbar + rightMargin: UM.Theme.getSize("narrow_margin").width + // Compensate for the negative margin in the parent + bottomMargin: UM.Theme.getSize("default_lining").width + } } } } diff --git a/resources/qml/Settings/SettingCategory.qml b/resources/qml/Settings/SettingCategory.qml index 4ec6294d61..9a061304d4 100644 --- a/resources/qml/Settings/SettingCategory.qml +++ b/resources/qml/Settings/SettingCategory.qml @@ -12,8 +12,8 @@ Button id: base anchors.left: parent.left anchors.right: parent.right - anchors.leftMargin: UM.Theme.getSize("default_margin").width - anchors.rightMargin: UM.Theme.getSize("default_margin").width * 3 + // To avoid overlaping with the scrollBars + anchors.rightMargin: 2 * UM.Theme.getSize("thin_margin").width hoverEnabled: true background: Rectangle @@ -25,22 +25,24 @@ Button if (base.color) { return base.color - } else if (!base.enabled) + } + else if (!base.enabled) { return UM.Theme.getColor("setting_category_disabled") - } else if (base.hovered && base.checkable && base.checked) + } + else if (base.hovered && base.checkable && base.checked) { return UM.Theme.getColor("setting_category_active_hover") - } else if (base.pressed || (base.checkable && base.checked)) + } + else if (base.pressed || (base.checkable && base.checked)) { return UM.Theme.getColor("setting_category_active") - } else if (base.hovered) + } + else if (base.hovered) { return UM.Theme.getColor("setting_category_hover") - } else - { - return UM.Theme.getColor("setting_category") } + return UM.Theme.getColor("setting_category") } Behavior on color { ColorAnimation { duration: 50; } } Rectangle diff --git a/resources/qml/Settings/SettingItem.qml b/resources/qml/Settings/SettingItem.qml index 036dcfeba4..df90cffdf3 100644 --- a/resources/qml/Settings/SettingItem.qml +++ b/resources/qml/Settings/SettingItem.qml @@ -10,8 +10,9 @@ import Cura 1.0 as Cura import "." -Item { - id: base; +Item +{ + id: base height: UM.Theme.getSize("section").height @@ -105,11 +106,11 @@ Item { Label { - id: label; + id: label - anchors.left: parent.left; + anchors.left: parent.left anchors.leftMargin: doDepthIndentation ? Math.round((UM.Theme.getSize("section_icon_column").width / 1.2) + ((definition.depth - 1) * UM.Theme.getSize("setting_control_depth_margin").width)) : 0 - anchors.right: settingControls.left; + anchors.right: settingControls.left anchors.verticalCenter: parent.verticalCenter text: definition.label diff --git a/resources/qml/Settings/SettingView.qml b/resources/qml/Settings/SettingView.qml index 3250e847a3..ff94c9168f 100644 --- a/resources/qml/Settings/SettingView.qml +++ b/resources/qml/Settings/SettingView.qml @@ -163,6 +163,7 @@ Item top: filterContainer.top bottom: filterContainer.bottom right: parent.right + rightMargin: UM.Theme.getSize("wide_margin").width } style: ButtonStyle @@ -210,7 +211,7 @@ Item ListView { id: contents - spacing: Math.round(UM.Theme.getSize("default_lining").height) + spacing: UM.Theme.getSize("default_lining").height cacheBuffer: 1000000 // Set a large cache to effectively just cache every list item. model: UM.SettingDefinitionsModel diff --git a/resources/themes/cura-light/styles.qml b/resources/themes/cura-light/styles.qml index ca95b6d373..eed5393a0b 100755 --- a/resources/themes/cura-light/styles.qml +++ b/resources/themes/cura-light/styles.qml @@ -384,13 +384,13 @@ QtObject { implicitWidth: Theme.getSize("scrollbar").width radius: Math.round(implicitWidth / 2) - color: Theme.getColor("scrollbar_background"); + color: Theme.getColor("scrollbar_background") } handle: Rectangle { id: scrollViewHandle - implicitWidth: Theme.getSize("scrollbar").width; + implicitWidth: Theme.getSize("scrollbar").width radius: Math.round(implicitWidth / 2) color: styleData.pressed ? Theme.getColor("scrollbar_handle_down") : styleData.hovered ? Theme.getColor("scrollbar_handle_hover") : Theme.getColor("scrollbar_handle"); diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index 5af77d59c3..dbe5e7196e 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -411,7 +411,7 @@ "extruder_icon": [2.33, 2.33], - "section": [0.0, 2.2], + "section": [0.0, 2], "section_icon": [1.6, 1.6], "section_icon_column": [2.8, 0.0], From 4e9c595bdd3dec5ac4f3688a4a25554fcf6f980d Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Mon, 3 Dec 2018 15:34:33 +0100 Subject: [PATCH 35/70] Restyle the settings list Be sure that the alignments and the margins are corrects according to the designs. Contributes to CURA-5941. --- resources/qml/Settings/SettingCategory.qml | 34 ++--- resources/qml/Settings/SettingItem.qml | 149 ++++++++++++--------- resources/themes/cura-light/theme.json | 2 +- 3 files changed, 104 insertions(+), 81 deletions(-) diff --git a/resources/qml/Settings/SettingCategory.qml b/resources/qml/Settings/SettingCategory.qml index 9a061304d4..9b78683e14 100644 --- a/resources/qml/Settings/SettingCategory.qml +++ b/resources/qml/Settings/SettingCategory.qml @@ -138,19 +138,20 @@ Button if (!base.enabled) { return UM.Theme.getColor("setting_category_disabled_text") - } else if ((base.hovered || base.activeFocus) && base.checkable && base.checked) + } + else if ((base.hovered || base.activeFocus) && base.checkable && base.checked) { return UM.Theme.getColor("setting_category_active_hover_text") - } else if (base.pressed || (base.checkable && base.checked)) + } + else if (base.pressed || (base.checkable && base.checked)) { return UM.Theme.getColor("setting_category_active_text") - } else if (base.hovered || base.activeFocus) + } + else if (base.hovered || base.activeFocus) { return UM.Theme.getColor("setting_category_hover_text") - } else - { - return UM.Theme.getColor("setting_category_text") } + return UM.Theme.getColor("setting_category_text") } source: base.checked ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_left") } @@ -161,25 +162,26 @@ Button id: icon anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left - anchors.leftMargin: UM.Theme.getSize("default_margin").width + anchors.leftMargin: UM.Theme.getSize("thin_margin").width color: { if (!base.enabled) { return UM.Theme.getColor("setting_category_disabled_text") - } else if((base.hovered || base.activeFocus) && base.checkable && base.checked) + } + else if((base.hovered || base.activeFocus) && base.checkable && base.checked) { return UM.Theme.getColor("setting_category_active_hover_text") - } else if(base.pressed || (base.checkable && base.checked)) + } + else if(base.pressed || (base.checkable && base.checked)) { return UM.Theme.getColor("setting_category_active_text") - } else if(base.hovered || base.activeFocus) + } + else if(base.hovered || base.activeFocus) { return UM.Theme.getColor("setting_category_hover_text") - } else - { - return UM.Theme.getColor("setting_category_text") } + return UM.Theme.getColor("setting_category_text") } source: UM.Theme.getIcon(definition.icon) width: UM.Theme.getSize("section_icon").width @@ -196,7 +198,9 @@ Button if (definition.expanded) { settingDefinitionsModel.collapse(definition.key) - } else { + } + else + { settingDefinitionsModel.expandRecursive(definition.key) } //Set focus so that tab navigation continues from this point on. @@ -205,7 +209,7 @@ Button } onActiveFocusChanged: { - if(activeFocus) + if (activeFocus) { base.focusReceived() } diff --git a/resources/qml/Settings/SettingItem.qml b/resources/qml/Settings/SettingItem.qml index df90cffdf3..4dd53f8663 100644 --- a/resources/qml/Settings/SettingItem.qml +++ b/resources/qml/Settings/SettingItem.qml @@ -15,6 +15,10 @@ Item id: base height: UM.Theme.getSize("section").height + anchors.left: parent.left + anchors.right: parent.right + // To avoid overlaping with the scrollBars + anchors.rightMargin: 2 * UM.Theme.getSize("thin_margin").width property alias contents: controlContainer.children property alias hovered: mouse.containsMouse @@ -44,25 +48,25 @@ Item var affected_by = settingDefinitionsModel.getRequires(definition.key, "value") var affected_by_list = "" - for(var i in affected_by) + for (var i in affected_by) { affected_by_list += "
  • %1
  • \n".arg(affected_by[i].label) } var affects_list = "" - for(var i in affects) + for (var i in affects) { affects_list += "
  • %1
  • \n".arg(affects[i].label) } var tooltip = "%1\n

    %2

    ".arg(definition.label).arg(definition.description) - if(affects_list != "") + if (affects_list != "") { tooltip += "
    %1\n
      \n%2
    ".arg(catalog.i18nc("@label Header for list of settings.", "Affects")).arg(affects_list) } - if(affected_by_list != "") + if (affected_by_list != "") { tooltip += "
    %1\n
      \n%2
    ".arg(catalog.i18nc("@label Header for list of settings.", "Affected By")).arg(affected_by_list) } @@ -72,35 +76,39 @@ Item MouseArea { - id: mouse; + id: mouse - anchors.fill: parent; + anchors.fill: parent - acceptedButtons: Qt.RightButton; + acceptedButtons: Qt.RightButton hoverEnabled: true; - onClicked: base.contextMenuRequested(); + onClicked: base.contextMenuRequested() - onEntered: { - hoverTimer.start(); + onEntered: + { + hoverTimer.start() } - onExited: { - if(controlContainer.item && controlContainer.item.hovered) { - return; + onExited: + { + if (controlContainer.item && controlContainer.item.hovered) + { + return } - hoverTimer.stop(); - base.hideTooltip(); + hoverTimer.stop() + base.hideTooltip() } - Timer { - id: hoverTimer; - interval: 500; - repeat: false; + Timer + { + id: hoverTimer + interval: 500 + repeat: false onTriggered: { - base.showTooltip(base.tooltipText); + base.showTooltip(base.tooltipText) } } @@ -109,16 +117,16 @@ Item id: label anchors.left: parent.left - anchors.leftMargin: doDepthIndentation ? Math.round((UM.Theme.getSize("section_icon_column").width / 1.2) + ((definition.depth - 1) * UM.Theme.getSize("setting_control_depth_margin").width)) : 0 + anchors.leftMargin: doDepthIndentation ? Math.round(UM.Theme.getSize("thin_margin").width + ((definition.depth - 1) * UM.Theme.getSize("setting_control_depth_margin").width)) : 0 anchors.right: settingControls.left anchors.verticalCenter: parent.verticalCenter text: definition.label - elide: Text.ElideMiddle; + elide: Text.ElideMiddle renderType: Text.NativeRendering textFormat: Text.PlainText - color: UM.Theme.getColor("setting_control_text"); + color: UM.Theme.getColor("setting_control_text") opacity: (definition.visible) ? 1 : 0.5 // emphasize the setting if it has a value in the user or quality profile font: base.doQualityUserSettingEmphasis && base.stackLevel != undefined && base.stackLevel <= 1 ? UM.Theme.getFont("default_italic") : UM.Theme.getFont("default") @@ -131,7 +139,8 @@ Item height: Math.round(parent.height / 2) spacing: Math.round(UM.Theme.getSize("thick_margin").height / 2) - anchors { + anchors + { right: controlContainer.left rightMargin: Math.round(UM.Theme.getSize("thick_margin").width / 2) verticalCenter: parent.verticalCenter @@ -151,112 +160,123 @@ Item iconSource: UM.Theme.getIcon("link") - onEntered: { - hoverTimer.stop(); - var tooltipText = catalog.i18nc("@label", "This setting is always shared between all extruders. Changing it here will change the value for all extruders."); - if ((resolve != "None") && (stackLevel != 0)) { + onEntered: + { + hoverTimer.stop() + var tooltipText = catalog.i18nc("@label", "This setting is always shared between all extruders. Changing it here will change the value for all extruders.") + if ((resolve != "None") && (stackLevel != 0)) + { // We come here if a setting has a resolve and the setting is not manually edited. - tooltipText += " " + catalog.i18nc("@label", "The value is resolved from per-extruder values ") + "[" + Cura.ExtruderManager.getInstanceExtruderValues(definition.key) + "]."; + tooltipText += " " + catalog.i18nc("@label", "The value is resolved from per-extruder values ") + "[" + Cura.ExtruderManager.getInstanceExtruderValues(definition.key) + "]." } - base.showTooltip(tooltipText); + base.showTooltip(tooltipText) } - onExited: base.showTooltip(base.tooltipText); + onExited: base.showTooltip(base.tooltipText) } UM.SimpleButton { - id: revertButton; + id: revertButton visible: base.stackLevel == 0 && base.showRevertButton - height: parent.height; - width: height; + height: parent.height + width: height color: UM.Theme.getColor("setting_control_button") hoverColor: UM.Theme.getColor("setting_control_button_hover") iconSource: UM.Theme.getIcon("reset") - onClicked: { + onClicked: + { revertButton.focus = true - if (externalResetHandler) { + if (externalResetHandler) + { externalResetHandler(propertyProvider.key) - } else { + } + else + { Cura.MachineManager.clearUserSettingAllCurrentStacks(propertyProvider.key) } } - onEntered: { hoverTimer.stop(); base.showTooltip(catalog.i18nc("@label", "This setting has a value that is different from the profile.\n\nClick to restore the value of the profile.")) } - onExited: base.showTooltip(base.tooltipText); + onEntered: + { + hoverTimer.stop() + base.showTooltip(catalog.i18nc("@label", "This setting has a value that is different from the profile.\n\nClick to restore the value of the profile.")) + } + onExited: base.showTooltip(base.tooltipText) } UM.SimpleButton { // This button shows when the setting has an inherited function, but is overriden by profile. - id: inheritButton; + id: inheritButton // Inherit button needs to be visible if; // - User made changes that override any loaded settings // - This setting item uses inherit button at all // - The type of the value of any deeper container is an "object" (eg; is a function) visible: { - if(!base.showInheritButton) + if (!base.showInheritButton) { - return false; + return false } - if(!propertyProvider.properties.enabled) + if (!propertyProvider.properties.enabled) { // Note: This is not strictly necessary since a disabled setting is hidden anyway. // But this will cause the binding to be re-evaluated when the enabled property changes. - return false; + return false } // There are no settings with any warning. - if(Cura.SettingInheritanceManager.settingsWithInheritanceWarning.length == 0) + if (Cura.SettingInheritanceManager.settingsWithInheritanceWarning.length == 0) { - return false; + return false } // This setting has a resolve value, so an inheritance warning doesn't do anything. - if(resolve != "None") + if (resolve != "None") { return false } // If the setting does not have a limit_to_extruder property (or is -1), use the active stack. - if(globalPropertyProvider.properties.limit_to_extruder == null || String(globalPropertyProvider.properties.limit_to_extruder) == "-1") + if (globalPropertyProvider.properties.limit_to_extruder == null || String(globalPropertyProvider.properties.limit_to_extruder) == "-1") { - return Cura.SettingInheritanceManager.settingsWithInheritanceWarning.indexOf(definition.key) >= 0; + return Cura.SettingInheritanceManager.settingsWithInheritanceWarning.indexOf(definition.key) >= 0 } // Setting does have a limit_to_extruder property, so use that one instead. if (definition.key === undefined) { // Observed when loading workspace, probably when SettingItems are removed. - return false; + return false } - return Cura.SettingInheritanceManager.getOverridesForExtruder(definition.key, String(globalPropertyProvider.properties.limit_to_extruder)).indexOf(definition.key) >= 0; + return Cura.SettingInheritanceManager.getOverridesForExtruder(definition.key, String(globalPropertyProvider.properties.limit_to_extruder)).indexOf(definition.key) >= 0 } - height: parent.height; - width: height; + height: parent.height + width: height - onClicked: { - focus = true; + onClicked: + { + focus = true // Get the most shallow function value (eg not a number) that we can find. var last_entry = propertyProvider.stackLevels[propertyProvider.stackLevels.length - 1] for (var i = 1; i < base.stackLevels.length; i++) { - var has_setting_function = typeof(propertyProvider.getPropertyValue("value", base.stackLevels[i])) == "object"; + var has_setting_function = typeof(propertyProvider.getPropertyValue("value", base.stackLevels[i])) == "object" if(has_setting_function) { last_entry = propertyProvider.stackLevels[i] - break; + break } } - if((last_entry == 4 || last_entry == 11) && base.stackLevel == 0 && base.stackLevels.length == 2) + if ((last_entry == 4 || last_entry == 11) && base.stackLevel == 0 && base.stackLevels.length == 2) { // Special case of the inherit reset. If only the definition (4th or 11th) container) and the first // entry (user container) are set, we can simply remove the container. @@ -277,23 +297,22 @@ Item color: UM.Theme.getColor("setting_control_button") hoverColor: UM.Theme.getColor("setting_control_button_hover") - iconSource: UM.Theme.getIcon("formula"); + iconSource: UM.Theme.getIcon("formula") onEntered: { hoverTimer.stop(); base.showTooltip(catalog.i18nc("@label", "This setting is normally calculated, but it currently has an absolute value set.\n\nClick to restore the calculated value.")) } - onExited: base.showTooltip(base.tooltipText); + onExited: base.showTooltip(base.tooltipText) } } Item { - id: controlContainer; + id: controlContainer enabled: propertyProvider.isValueUsed - anchors.right: parent.right; - anchors.rightMargin: UM.Theme.getSize("default_margin").width * 3 - anchors.verticalCenter: parent.verticalCenter; - width: UM.Theme.getSize("setting_control").width; + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + width: UM.Theme.getSize("setting_control").width height: UM.Theme.getSize("setting_control").height } } diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index dbe5e7196e..57532d91e5 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -416,7 +416,7 @@ "section_icon_column": [2.8, 0.0], "setting": [25.0, 1.8], - "setting_control": [10.0, 2.0], + "setting_control": [11.0, 2.0], "setting_control_radius": [0.15, 0.15], "setting_control_depth_margin": [1.4, 0.0], "setting_preferences_button_margin": [4, 0.0], From d3b5b2717d726ff99e22c372e1eaf2da48b2a73b Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Mon, 3 Dec 2018 15:56:21 +0100 Subject: [PATCH 36/70] Add rounded corners to the settings Contributes to CURA-5941 --- .../RecommendedSupportSelector.qml | 6 +-- resources/qml/Settings/SettingCheckBox.qml | 43 +++++++++++-------- resources/qml/Settings/SettingComboBox.qml | 1 + resources/qml/Settings/SettingExtruder.qml | 40 ++++++++--------- .../qml/Settings/SettingOptionalExtruder.qml | 29 ++++++------- resources/qml/Settings/SettingTextField.qml | 37 +++++++++------- 6 files changed, 81 insertions(+), 75 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml index ce4aa6c195..da46f2a735 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml @@ -97,10 +97,10 @@ Item property string color_override: "" // for manually setting values property string color: // is evaluated automatically, but the first time is before extruderModel being filled { - var current_extruder = extruderModel.get(currentIndex); - color_override = ""; + var current_extruder = extruderModel.get(currentIndex) + color_override = "" if (current_extruder === undefined) return "" - return (current_extruder.color) ? current_extruder.color : ""; + return (current_extruder.color) ? current_extruder.color : "" } currentIndex: diff --git a/resources/qml/Settings/SettingCheckBox.qml b/resources/qml/Settings/SettingCheckBox.qml index d37754d27c..f53a696343 100644 --- a/resources/qml/Settings/SettingCheckBox.qml +++ b/resources/qml/Settings/SettingCheckBox.qml @@ -28,37 +28,40 @@ SettingItem // 3: material -> user changed material in materials page // 4: variant // 5: machine - var value; - if ((base.resolve != "None") && (stackLevel != 0) && (stackLevel != 1)) { + var value + if ((base.resolve != "None") && (stackLevel != 0) && (stackLevel != 1)) + { // We have a resolve function. Indicates that the setting is not settable per extruder and that // we have to choose between the resolved value (default) and the global value // (if user has explicitly set this). - value = base.resolve; - } else { - value = propertyProvider.properties.value; + value = base.resolve + } + else + { + value = propertyProvider.properties.value } switch(value) { case "True": - return true; + return true case "False": - return false; + return false default: - return value; + return value } } Keys.onSpacePressed: { - forceActiveFocus(); - propertyProvider.setPropertyValue("value", !checked); + forceActiveFocus() + propertyProvider.setPropertyValue("value", !checked) } onClicked: { - forceActiveFocus(); - propertyProvider.setPropertyValue("value", !checked); + forceActiveFocus() + propertyProvider.setPropertyValue("value", !checked) } Keys.onTabPressed: @@ -72,9 +75,9 @@ SettingItem onActiveFocusChanged: { - if(activeFocus) + if (activeFocus) { - base.focusReceived(); + base.focusReceived() } } @@ -90,32 +93,34 @@ SettingItem color: { - if(!enabled) + if (!enabled) { return UM.Theme.getColor("setting_control_disabled") } - if(control.containsMouse || control.activeFocus) + if (control.containsMouse || control.activeFocus) { return UM.Theme.getColor("setting_control_highlight") } return UM.Theme.getColor("setting_control") } + radius: UM.Theme.getSize("setting_control_radius").width border.width: UM.Theme.getSize("default_lining").width border.color: { - if(!enabled) + if (!enabled) { return UM.Theme.getColor("setting_control_disabled_border") } - if(control.containsMouse || control.activeFocus) + if (control.containsMouse || control.activeFocus) { return UM.Theme.getColor("setting_control_border_highlight") } return UM.Theme.getColor("setting_control_border") } - UM.RecolorImage { + UM.RecolorImage + { anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter width: Math.round(parent.width / 2.5) diff --git a/resources/qml/Settings/SettingComboBox.qml b/resources/qml/Settings/SettingComboBox.qml index 76d458e427..13d2a0eb8f 100644 --- a/resources/qml/Settings/SettingComboBox.qml +++ b/resources/qml/Settings/SettingComboBox.qml @@ -35,6 +35,7 @@ SettingItem return UM.Theme.getColor("setting_control") } + radius: UM.Theme.getSize("setting_control_radius").width border.width: UM.Theme.getSize("default_lining").width border.color: { diff --git a/resources/qml/Settings/SettingExtruder.qml b/resources/qml/Settings/SettingExtruder.qml index a9427f863a..e1fedd9274 100644 --- a/resources/qml/Settings/SettingExtruder.qml +++ b/resources/qml/Settings/SettingExtruder.qml @@ -19,8 +19,9 @@ SettingItem model: Cura.ExtrudersModel { - onModelChanged: { - control.color = getItem(control.currentIndex).color; + onModelChanged: + { + control.color = getItem(control.currentIndex).color } } @@ -113,14 +114,15 @@ SettingItem { if (!enabled) { - return UM.Theme.getColor("setting_control_disabled"); + return UM.Theme.getColor("setting_control_disabled") } if (control.hovered || base.activeFocus) { - return UM.Theme.getColor("setting_control_highlight"); + return UM.Theme.getColor("setting_control_highlight") } - return UM.Theme.getColor("setting_control"); + return UM.Theme.getColor("setting_control") } + radius: UM.Theme.getSize("setting_control_radius").width border.width: UM.Theme.getSize("default_lining").width border.color: { @@ -153,20 +155,18 @@ SettingItem elide: Text.ElideLeft verticalAlignment: Text.AlignVCenter - background: Rectangle + background: UM.RecolorImage { id: swatch - height: Math.round(UM.Theme.getSize("setting_control").height / 2) + height: Math.round(parent.height / 2) width: height - anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter - anchors.margins: Math.round(UM.Theme.getSize("default_margin").width / 4) - - border.width: UM.Theme.getSize("default_lining").width - border.color: enabled ? UM.Theme.getColor("setting_control_border") : UM.Theme.getColor("setting_control_disabled_border") - radius: Math.round(width / 2) + anchors.rightMargin: UM.Theme.getSize("thin_margin").width + sourceSize.width: width + sourceSize.height: height + source: UM.Theme.getIcon("extruder_button") color: control.color } } @@ -219,20 +219,18 @@ SettingItem verticalAlignment: Text.AlignVCenter rightPadding: swatch.width + UM.Theme.getSize("setting_unit_margin").width - background: Rectangle + background: UM.RecolorImage { id: swatch - height: Math.round(UM.Theme.getSize("setting_control").height / 2) + height: Math.round(parent.height / 2) width: height - anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter - anchors.margins: Math.round(UM.Theme.getSize("default_margin").width / 4) - - border.width: UM.Theme.getSize("default_lining").width - border.color: enabled ? UM.Theme.getColor("setting_control_border") : UM.Theme.getColor("setting_control_disabled_border") - radius: Math.round(width / 2) + anchors.rightMargin: UM.Theme.getSize("thin_margin").width + sourceSize.width: width + sourceSize.height: height + source: UM.Theme.getIcon("extruder_button") color: control.model.getItem(index).color } } diff --git a/resources/qml/Settings/SettingOptionalExtruder.qml b/resources/qml/Settings/SettingOptionalExtruder.qml index a3c1422b30..53044b0f82 100644 --- a/resources/qml/Settings/SettingOptionalExtruder.qml +++ b/resources/qml/Settings/SettingOptionalExtruder.qml @@ -116,6 +116,7 @@ SettingItem } return UM.Theme.getColor("setting_control"); } + radius: UM.Theme.getSize("setting_control_radius").width border.width: UM.Theme.getSize("default_lining").width border.color: { @@ -148,20 +149,18 @@ SettingItem elide: Text.ElideRight verticalAlignment: Text.AlignVCenter - background: Rectangle + background: UM.RecolorImage { id: swatch - height: Math.round(UM.Theme.getSize("setting_control").height / 2) + height: Math.round(parent.height / 2) width: height - anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter - anchors.margins: Math.round(UM.Theme.getSize("default_margin").width / 4) - - border.width: UM.Theme.getSize("default_lining").width - border.color: enabled ? UM.Theme.getColor("setting_control_border") : UM.Theme.getColor("setting_control_disabled_border") - radius: Math.round(width / 2) + anchors.rightMargin: UM.Theme.getSize("thin_margin").width + sourceSize.width: width + sourceSize.height: height + source: UM.Theme.getIcon("extruder_button") color: control.color } } @@ -215,20 +214,18 @@ SettingItem verticalAlignment: Text.AlignVCenter rightPadding: swatch.width + UM.Theme.getSize("setting_unit_margin").width - background: Rectangle + background: UM.RecolorImage { id: swatch - height: Math.round(UM.Theme.getSize("setting_control").height / 2) + height: Math.round(parent.height / 2) width: height - anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter - anchors.margins: Math.round(UM.Theme.getSize("default_margin").width / 4) - - border.width: UM.Theme.getSize("default_lining").width - border.color: enabled ? UM.Theme.getColor("setting_control_border") : UM.Theme.getColor("setting_control_disabled_border") - radius: Math.round(width / 2) + anchors.rightMargin: UM.Theme.getSize("thin_margin").width + sourceSize.width: width + sourceSize.height: height + source: UM.Theme.getIcon("extruder_button") color: control.model.getItem(index).color } } diff --git a/resources/qml/Settings/SettingTextField.qml b/resources/qml/Settings/SettingTextField.qml index 9ec9338316..770ef53900 100644 --- a/resources/qml/Settings/SettingTextField.qml +++ b/resources/qml/Settings/SettingTextField.qml @@ -32,6 +32,7 @@ SettingItem anchors.fill: parent + radius: UM.Theme.getSize("setting_control_radius").width border.width: Math.round(UM.Theme.getSize("default_lining").width) border.color: { @@ -81,10 +82,10 @@ SettingItem Rectangle { - anchors.fill: parent; - anchors.margins: Math.round(UM.Theme.getSize("default_lining").width); + anchors.fill: parent + anchors.margins: Math.round(UM.Theme.getSize("default_lining").width) color: UM.Theme.getColor("setting_control_highlight") - opacity: !control.hovered ? 0 : propertyProvider.properties.validationState == "ValidatorState.Valid" ? 1.0 : 0.35; + opacity: !control.hovered ? 0 : propertyProvider.properties.validationState == "ValidatorState.Valid" ? 1.0 : 0.35 } Label @@ -145,11 +146,11 @@ SettingItem } color: !enabled ? UM.Theme.getColor("setting_control_disabled_text") : UM.Theme.getColor("setting_control_text") - font: UM.Theme.getFont("default"); + font: UM.Theme.getFont("default") - selectByMouse: true; + selectByMouse: true - maximumLength: (definition.type == "str" || definition.type == "[int]") ? -1 : 10; + maximumLength: (definition.type == "str" || definition.type == "[int]") ? -1 : 10 clip: true; //Hide any text that exceeds the width of the text box. validator: RegExpValidator { regExp: (definition.type == "[int]") ? /^\[?(\s*-?[0-9]{0,9}\s*,)*(\s*-?[0-9]{0,9})\s*\]?$/ : (definition.type == "int") ? /^-?[0-9]{0,10}$/ : (definition.type == "float") ? /^-?[0-9]{0,9}[.,]?[0-9]{0,3}$/ : /^.*$/ } // definition.type property from parent loader used to disallow fractional number entry @@ -158,7 +159,8 @@ SettingItem { target: input property: "text" - value: { + value: + { // Stacklevels // 0: user -> unsaved change // 1: quality changes -> saved change @@ -167,13 +169,15 @@ SettingItem // 4: variant // 5: machine_changes // 6: machine - if ((base.resolve != "None" && base.resolve) && (stackLevel != 0) && (stackLevel != 1)) { + if ((base.resolve != "None" && base.resolve) && (stackLevel != 0) && (stackLevel != 1)) + { // We have a resolve function. Indicates that the setting is not settable per extruder and that // we have to choose between the resolved value (default) and the global value // (if user has explicitly set this). - return base.resolve; - } else { - return propertyProvider.properties.value; + return base.resolve + } + else { + return propertyProvider.properties.value } } when: !input.activeFocus @@ -182,16 +186,17 @@ SettingItem MouseArea { id: mouseArea - anchors.fill: parent; + anchors.fill: parent cursorShape: Qt.IBeamCursor onPressed: { - if(!input.activeFocus) { - base.focusGainedByClick = true; - input.forceActiveFocus(); + if (!input.activeFocus) + { + base.focusGainedByClick = true + input.forceActiveFocus() } - mouse.accepted = false; + mouse.accepted = false } } } From 15415dc3b98e70a2dd299c4d2cdef1a2065c1185 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Mon, 3 Dec 2018 16:53:52 +0100 Subject: [PATCH 37/70] Fix position of the tooltips for the settings Contributes to CURA-5941 --- resources/qml/Settings/SettingView.qml | 2 +- resources/themes/cura-light/theme.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/qml/Settings/SettingView.qml b/resources/qml/Settings/SettingView.qml index ff94c9168f..867d662edc 100644 --- a/resources/qml/Settings/SettingView.qml +++ b/resources/qml/Settings/SettingView.qml @@ -360,7 +360,7 @@ Item contextMenu.provider = provider contextMenu.popup(); } - onShowTooltip: base.showTooltip(delegate, Qt.point(- UM.Theme.getSize("default_arrow").width, 0), text) + onShowTooltip: base.showTooltip(delegate, Qt.point(- settingsView.x - UM.Theme.getSize("default_margin").width, 0), text) onHideTooltip: base.hideTooltip() onShowAllHiddenInheritedSettings: { diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index 57532d91e5..3d0169dac9 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -35,7 +35,7 @@ "family": "Noto Sans" }, "default_italic": { - "size": 1.15, + "size": 1.0, "weight": 50, "italic": true, "family": "Noto Sans" From 004405e5f97337c5acfafda2da0c75bc4a9e7004 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Mon, 3 Dec 2018 17:25:07 +0100 Subject: [PATCH 38/70] Change the colors to match the designs. Contributes to CURA-5941. --- .../PrintSetupSelectorContents.qml | 6 +-- resources/qml/Settings/SettingCategory.qml | 26 ----------- resources/themes/cura-light/styles.qml | 2 +- resources/themes/cura-light/theme.json | 46 +++++++++---------- 4 files changed, 27 insertions(+), 53 deletions(-) diff --git a/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml b/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml index 77d1b59f4c..358cba8ad0 100644 --- a/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml +++ b/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml @@ -25,7 +25,7 @@ Item { id: header height: UM.Theme.getSize("print_setup_widget_header").height - color: UM.Theme.getColor("action_button_hovered") // TODO: It's not clear the color that we need to use here + color: UM.Theme.getColor("secondary") anchors { @@ -46,9 +46,9 @@ Item anchors { - topMargin: UM.Theme.getSize("sidebar_margin").height + topMargin: UM.Theme.getSize("default_margin").height left: parent.left - leftMargin: UM.Theme.getSize("narrow_margin").height + leftMargin: UM.Theme.getSize("default_margin").height } } diff --git a/resources/qml/Settings/SettingCategory.qml b/resources/qml/Settings/SettingCategory.qml index 9b78683e14..be93f8ffab 100644 --- a/resources/qml/Settings/SettingCategory.qml +++ b/resources/qml/Settings/SettingCategory.qml @@ -45,32 +45,6 @@ Button return UM.Theme.getColor("setting_category") } Behavior on color { ColorAnimation { duration: 50; } } - Rectangle - { - id: backgroundLiningRectangle - height: UM.Theme.getSize("default_lining").height - width: parent.width - anchors.bottom: parent.bottom - color: - { - if (!base.enabled) - { - return UM.Theme.getColor("setting_category_disabled_border") - } else if ((base.hovered || base.activeFocus) && base.checkable && base.checked) - { - return UM.Theme.getColor("setting_category_active_hover_border") - } else if (base.pressed || (base.checkable && base.checked)) - { - return UM.Theme.getColor("setting_category_active_border") - } else if (base.hovered || base.activeFocus) - { - return UM.Theme.getColor("setting_category_hover_border") - } else - { - return UM.Theme.getColor("setting_category_border") - } - } - } } signal showTooltip(string text) diff --git a/resources/themes/cura-light/styles.qml b/resources/themes/cura-light/styles.qml index eed5393a0b..66c000af62 100755 --- a/resources/themes/cura-light/styles.qml +++ b/resources/themes/cura-light/styles.qml @@ -393,7 +393,7 @@ QtObject implicitWidth: Theme.getSize("scrollbar").width radius: Math.round(implicitWidth / 2) - color: styleData.pressed ? Theme.getColor("scrollbar_handle_down") : styleData.hovered ? Theme.getColor("scrollbar_handle_hover") : Theme.getColor("scrollbar_handle"); + color: styleData.pressed ? Theme.getColor("scrollbar_handle_down") : styleData.hovered ? Theme.getColor("scrollbar_handle_hover") : Theme.getColor("scrollbar_handle") Behavior on color { ColorAnimation { duration: 50; } } } } diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index 3d0169dac9..8e440757aa 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -86,7 +86,7 @@ "primary_hover": [48, 182, 231, 255], "primary_text": [255, 255, 255, 255], "border": [127, 127, 127, 255], - "secondary": [240, 240, 240, 255], + "secondary": [245, 245, 245, 255], "secondary_shadow": [216, 216, 216, 255], "primary_button": [38, 113, 231, 255], @@ -183,25 +183,25 @@ "action_button_disabled_shadow": [228, 228, 228, 255], "scrollbar_background": [255, 255, 255, 255], - "scrollbar_handle": [31, 36, 39, 255], - "scrollbar_handle_hover": [12, 159, 227, 255], - "scrollbar_handle_down": [12, 159, 227, 255], + "scrollbar_handle": [10, 8, 80, 255], + "scrollbar_handle_hover": [50, 130, 255, 255], + "scrollbar_handle_down": [50, 130, 255, 255], "setting_category": [245, 245, 245, 255], "setting_category_disabled": [255, 255, 255, 255], - "setting_category_hover": [245, 245, 245, 255], + "setting_category_hover": [232, 242, 252, 255], "setting_category_active": [245, 245, 245, 255], - "setting_category_active_hover": [245, 245, 245, 255], - "setting_category_text": [31, 36, 39, 255], + "setting_category_active_hover": [232, 242, 252, 255], + "setting_category_text": [35, 35, 35, 255], "setting_category_disabled_text": [24, 41, 77, 101], - "setting_category_hover_text": [31, 36, 39, 255], - "setting_category_active_text": [31, 36, 39, 255], - "setting_category_active_hover_text": [31, 36, 39, 255], + "setting_category_hover_text": [35, 35, 35, 255], + "setting_category_active_text": [35, 35, 35, 255], + "setting_category_active_hover_text": [35, 35, 35, 255], "setting_category_border": [245, 245, 245, 255], "setting_category_disabled_border": [245, 245, 245, 255], - "setting_category_hover_border": [12, 159, 227, 255], - "setting_category_active_border": [245, 245, 245, 255], - "setting_category_active_hover_border": [12, 159, 227, 255], + "setting_category_hover_border": [50, 130, 255, 255], + "setting_category_active_border": [50, 130, 255, 255], + "setting_category_active_hover_border": [50, 130, 255, 255], "setting_control": [255, 255, 255, 255], "setting_control_selected": [31, 36, 39, 255], @@ -298,16 +298,16 @@ "xray_error": [255, 0, 0, 255], "layerview_ghost": [32, 32, 32, 96], - "layerview_none": [255, 255, 255, 255], - "layerview_inset_0": [255, 0, 0, 255], - "layerview_inset_x": [0, 255, 0, 255], - "layerview_skin": [255, 255, 0, 255], - "layerview_support": [0, 255, 255, 255], - "layerview_skirt": [0, 255, 255, 255], - "layerview_infill": [255, 192, 0, 255], - "layerview_support_infill": [0, 255, 255, 255], - "layerview_move_combing": [0, 0, 255, 255], - "layerview_move_retraction": [128, 128, 255, 255], + "layerview_none": [255, 255, 255, 255], + "layerview_inset_0": [255, 0, 0, 255], + "layerview_inset_x": [0, 255, 0, 255], + "layerview_skin": [255, 255, 0, 255], + "layerview_support": [0, 255, 255, 255], + "layerview_skirt": [0, 255, 255, 255], + "layerview_infill": [255, 192, 0, 255], + "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_nozzle": [181, 166, 66, 50], From 692686597cf9204748a25c38fc11392712e74ae4 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Tue, 4 Dec 2018 12:07:31 +0100 Subject: [PATCH 39/70] Fix an issues that didn't calculate the correct height of the popup when the custom mode was selected from previous runs. Contributes to CURA-5941. --- resources/qml/ExpandableComponent.qml | 42 ++++++++-------- .../PrintSetupSelectorContents.qml | 49 ++++++++++--------- 2 files changed, 48 insertions(+), 43 deletions(-) diff --git a/resources/qml/ExpandableComponent.qml b/resources/qml/ExpandableComponent.qml index 82747d1c5b..df7604015e 100644 --- a/resources/qml/ExpandableComponent.qml +++ b/resources/qml/ExpandableComponent.qml @@ -25,10 +25,7 @@ Item property alias headerItem: headerItemLoader.sourceComponent // The popupItem holds the QML item that is shown when the "open" button is pressed - property var popupItem - - // The popupItem holds the QML item that is shown when the "open" button is pressed - property var componentItem + property alias popupItem: popup.contentItem property color popupBackgroundColor: UM.Theme.getColor("action_button") @@ -87,23 +84,6 @@ Item } } - onPopupItemChanged: - { - // Since we want the size of the popup to be set by the size of the content, - // we need to do it like this. - popup.width = popupItem.width + 2 * popup.padding - popup.height = popupItem.height + 2 * popup.padding - popup.contentItem = popupItem - } - - Connections - { - // Since it could be that the popup is dynamically populated, we should also take these changes into account. - target: popupItem - onWidthChanged: popup.width = popupItem.width + 2 * popup.padding - onHeightChanged: popup.height = popupItem.height + 2 * popup.padding - } - implicitHeight: 100 * screenScaleFactor implicitWidth: 400 * screenScaleFactor @@ -202,5 +182,25 @@ Item border.color: UM.Theme.getColor("lining") radius: UM.Theme.getSize("default_radius").width } + + contentItem: Item { } + + onContentItemChanged: + { + // Since we want the size of the popup to be set by the size of the content, + // we need to do it like this. + popup.width = contentItem.width + 2 * popup.padding + popup.height = contentItem.height + 2 * popup.padding + } + } + + // DO NOT MOVE UP IN THE CODE: This connection has to be here, after the definition of the Popup item. + // Apparently the order in which these are handled matters and so the height is correctly updated if this is here. + Connections + { + // Since it could be that the popup is dynamically populated, we should also take these changes into account. + target: popup.contentItem + onWidthChanged: popup.width = popup.contentItem.width + 2 * popup.padding + onHeightChanged: popup.height = popup.contentItem.height + 2 * popup.padding } } diff --git a/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml b/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml index 358cba8ad0..a2856e1fe5 100644 --- a/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml +++ b/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml @@ -17,9 +17,26 @@ Item width: UM.Theme.getSize("print_setup_widget").width - 2 * UM.Theme.getSize("default_margin").width height: childrenRect.height - property int currentModeIndex: -1 + enum Mode + { + Recommended = 0, + Custom = 1 + } + + // Set the current mode index to the value that is stored in the preferences or Recommended mode otherwise. + property int currentModeIndex: + { + var index = Math.round(UM.Preferences.getValue("cura/active_mode")) + + if(index != null && !isNaN(index)) + { + return index + } + return PrintSetupSelectorContents.Mode.Recommended + } onCurrentModeIndexChanged: UM.Preferences.setValue("cura/active_mode", currentModeIndex) + // Header of the popup Rectangle { @@ -93,7 +110,9 @@ Item Item { id: contents - height: currentModeIndex == 0 ? recommendedPrintSetup.height : customPrintSetup.height + // Use the visible property instead of checking the currentModeIndex. That creates a binding that + // evaluates the new height every time the visible property changes. + height: recommendedPrintSetup.visible ? recommendedPrintSetup.height : customPrintSetup.height anchors { @@ -111,7 +130,7 @@ Item right: parent.right top: parent.top } - visible: currentModeIndex == 0 + visible: currentModeIndex == PrintSetupSelectorContents.Mode.Recommended } CustomPrintSetup @@ -123,7 +142,7 @@ Item right: parent.right top: parent.top } - visible: currentModeIndex == 1 + visible: currentModeIndex == PrintSetupSelectorContents.Mode.Custom } } @@ -160,8 +179,8 @@ Item rightPadding: UM.Theme.getSize("default_margin").width text: catalog.i18nc("@button", "Recommended") iconSource: UM.Theme.getIcon("arrow_left") - visible: currentModeIndex == 1 - onClicked: currentModeIndex = 0 + visible: currentModeIndex == PrintSetupSelectorContents.Mode.Custom + onClicked: currentModeIndex = PrintSetupSelectorContents.Mode.Recommended } Cura.SecondaryButton @@ -174,22 +193,8 @@ Item text: catalog.i18nc("@button", "Custom") iconSource: UM.Theme.getIcon("arrow_right") iconOnRightSide: true - visible: currentModeIndex == 0 - onClicked: currentModeIndex = 1 - } - } - - Component.onCompleted: - { - var index = Math.round(UM.Preferences.getValue("cura/active_mode")) - - if(index != null && !isNaN(index)) - { - currentModeIndex = index - } - else - { - currentModeIndex = 0 + visible: currentModeIndex == PrintSetupSelectorContents.Mode.Recommended + onClicked: currentModeIndex = PrintSetupSelectorContents.Mode.Custom } } } \ No newline at end of file From e159cbdb1a8124ceac8c897d39a96556ba35da5a Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Tue, 4 Dec 2018 13:14:12 +0100 Subject: [PATCH 40/70] Rename all the references from 'popup' to 'content' Contributes to CURA-5941. --- .../SimulationViewMenuComponent.qml | 2 +- resources/qml/ExpandableComponent.qml | 82 ++++++++++--------- .../QuickConfigurationSelector.qml | 2 +- .../PrintSetupSelector/PrintSetupSelector.qml | 8 +- .../qml/PrinterSelector/MachineSelector.qml | 6 +- resources/qml/ViewsSelector.qml | 6 +- 6 files changed, 57 insertions(+), 49 deletions(-) diff --git a/plugins/SimulationView/SimulationViewMenuComponent.qml b/plugins/SimulationView/SimulationViewMenuComponent.qml index 53b64afb47..a9eb157f48 100644 --- a/plugins/SimulationView/SimulationViewMenuComponent.qml +++ b/plugins/SimulationView/SimulationViewMenuComponent.qml @@ -45,7 +45,7 @@ Cura.ExpandableComponent verticalAlignment: Text.AlignVCenter } - popupItem: Column + contentItem: Column { id: viewSettings diff --git a/resources/qml/ExpandableComponent.qml b/resources/qml/ExpandableComponent.qml index df7604015e..0b4076c04a 100644 --- a/resources/qml/ExpandableComponent.qml +++ b/resources/qml/ExpandableComponent.qml @@ -6,40 +6,48 @@ import Cura 1.0 as Cura import QtGraphicalEffects 1.0 // For the dropshadow -// The expandable component has 3 major sub components: +// The expandable component has 2 major sub components: // * The headerItem; Always visible and should hold some info about what happens if the component is expanded -// * The popupItem; The content that needs to be shown if the component is expanded. -// * The icon; An icon that is displayed on the right of the drawer. +// * The contentItem; The content that needs to be shown if the component is expanded. Item { id: base - // Enumeration with the different possible alignments of the popup with respect of the headerItem - enum PopupAlignment + // Enumeration with the different possible alignments of the content with respect of the headerItem + enum ContentAlignment { AlignLeft, AlignRight } + enum ContentType + { + Floating, + Fixed + } + // The headerItem holds the QML item that is always displayed. property alias headerItem: headerItemLoader.sourceComponent - // The popupItem holds the QML item that is shown when the "open" button is pressed - property alias popupItem: popup.contentItem + // The contentItem holds the QML item that is shown when the "open" button is pressed + property alias contentItem: content.contentItem - property color popupBackgroundColor: UM.Theme.getColor("action_button") + // Defines the type of the contents + property int contentType: ExpandableComponent.ContentType.Floating + + property color contentBackgroundColor: UM.Theme.getColor("action_button") property color headerBackgroundColor: UM.Theme.getColor("action_button") property color headerHoverColor: UM.Theme.getColor("action_button_hovered") - // Defines the alignment of the popup with respect of the headerItem, by default to the right - property int popupAlignment: ExpandableComponent.PopupAlignment.AlignRight + // Defines the alignment of the content with respect of the headerItem, by default to the right + property int contentAlignment: ExpandableComponent.ContentAlignment.AlignRight - // How much spacing is needed around the popupItem - property alias popupPadding: popup.padding + // How much spacing is needed around the contentItem + property alias contentPadding: content.padding - // How much spacing is needed for the popupItem by Y coordinate - property var popupSpacingY: 0 + // How much spacing is needed for the contentItem by Y coordinate + property var contentSpacingY: 0 // How much padding is needed around the header & button property alias headerPadding: background.padding @@ -53,7 +61,7 @@ Item property alias iconSize: collapseButton.height // Is the "drawer" open? - readonly property alias expanded: popup.visible + readonly property alias expanded: content.visible property alias expandedHighlightColor: expandedHighlight.color @@ -63,8 +71,8 @@ Item // On what side should the header corners be shown? 1 is down, 2 is left, 3 is up and 4 is right. property alias headerCornerSide: background.cornerSide - // Change the popupItem close behaviour - property alias popupClosePolicy : popup.closePolicy + // Change the contentItem close behaviour + property alias contentClosePolicy : content.closePolicy property alias headerShadowColor: shadow.color @@ -72,15 +80,15 @@ Item property int shadowOffset: 2 - function togglePopup() + function toggleContent() { - if (popup.visible) + if (content.visible) { - popup.close() + content.close() } else { - popup.open() + content.open() } } @@ -108,7 +116,7 @@ Item } } - // A highlight that is shown when the popup is expanded + // A highlight that is shown when the content is expanded Rectangle { id: expandedHighlight @@ -140,7 +148,7 @@ Item { id: mouseArea anchors.fill: parent - onClicked: togglePopup() + onClicked: toggleContent() hoverEnabled: true onEntered: background.color = headerHoverColor onExited: background.color = headerBackgroundColor @@ -163,21 +171,21 @@ Item Popup { - id: popup + id: content - // Ensure that the popup is located directly below the headerItem - y: background.height + base.shadowOffset + popupSpacingY + // Ensure that the content is located directly below the headerItem + y: background.height + base.shadowOffset + base.contentSpacingY - // Make the popup aligned with the rest, using the property popupAlignment to decide whether is right or left. + // Make the content aligned with the rest, using the property contentAlignment to decide whether is right or left. // In case of right alignment, the 3x padding is due to left, right and padding between the button & text. - x: popupAlignment == ExpandableComponent.PopupAlignment.AlignRight ? -width + collapseButton.width + headerItemLoader.width + 3 * background.padding : 0 + x: contentAlignment == ExpandableComponent.ContentAlignment.AlignRight ? -width + collapseButton.width + headerItemLoader.width + 3 * background.padding : 0 padding: UM.Theme.getSize("default_margin").width closePolicy: Popup.CloseOnPressOutsideParent background: Cura.RoundedRectangle { cornerSide: Cura.RoundedRectangle.Direction.Down - color: popupBackgroundColor + color: contentBackgroundColor border.width: UM.Theme.getSize("default_lining").width border.color: UM.Theme.getColor("lining") radius: UM.Theme.getSize("default_radius").width @@ -187,20 +195,20 @@ Item onContentItemChanged: { - // Since we want the size of the popup to be set by the size of the content, + // Since we want the size of the content to be set by the size of the content, // we need to do it like this. - popup.width = contentItem.width + 2 * popup.padding - popup.height = contentItem.height + 2 * popup.padding + content.width = contentItem.width + 2 * content.padding + content.height = contentItem.height + 2 * content.padding } } - // DO NOT MOVE UP IN THE CODE: This connection has to be here, after the definition of the Popup item. + // DO NOT MOVE UP IN THE CODE: This connection has to be here, after the definition of the content item. // Apparently the order in which these are handled matters and so the height is correctly updated if this is here. Connections { - // Since it could be that the popup is dynamically populated, we should also take these changes into account. - target: popup.contentItem - onWidthChanged: popup.width = popup.contentItem.width + 2 * popup.padding - onHeightChanged: popup.height = popup.contentItem.height + 2 * popup.padding + // Since it could be that the content is dynamically populated, we should also take these changes into account. + target: content.contentItem + onWidthChanged: content.width = content.contentItem.width + 2 * content.padding + onHeightChanged: content.height = content.contentItem.height + 2 * content.padding } } diff --git a/resources/qml/Menus/ConfigurationMenu/QuickConfigurationSelector.qml b/resources/qml/Menus/ConfigurationMenu/QuickConfigurationSelector.qml index eb6800cb36..de92161bbb 100644 --- a/resources/qml/Menus/ConfigurationMenu/QuickConfigurationSelector.qml +++ b/resources/qml/Menus/ConfigurationMenu/QuickConfigurationSelector.qml @@ -93,7 +93,7 @@ Cura.ExpandableComponent } } - popupItem: Item + contentItem: Item { width: base.width - 2 * UM.Theme.getSize("default_margin").width height: 200 diff --git a/resources/qml/PrintSetupSelector/PrintSetupSelector.qml b/resources/qml/PrintSetupSelector/PrintSetupSelector.qml index f1b424f7f2..78bdbde542 100644 --- a/resources/qml/PrintSetupSelector/PrintSetupSelector.qml +++ b/resources/qml/PrintSetupSelector/PrintSetupSelector.qml @@ -15,10 +15,10 @@ Cura.ExpandableComponent property string disabledText: catalog.i18nc("@label:Should be short", "Off") iconSource: UM.Theme.getIcon("pencil") - popupPadding: UM.Theme.getSize("default_lining").width - popupSpacingY: UM.Theme.getSize("narrow_margin").width + contentPadding: UM.Theme.getSize("default_lining").width + contentSpacingY: UM.Theme.getSize("narrow_margin").width - popupClosePolicy: Popup.CloseOnEscape + contentClosePolicy: Popup.CloseOnEscape UM.I18nCatalog { @@ -36,5 +36,5 @@ Cura.ExpandableComponent id: extrudersModel } - popupItem: PrintSetupSelectorContents {} + contentItem: PrintSetupSelectorContents {} } \ No newline at end of file diff --git a/resources/qml/PrinterSelector/MachineSelector.qml b/resources/qml/PrinterSelector/MachineSelector.qml index 15cd773c90..f742d0bef3 100644 --- a/resources/qml/PrinterSelector/MachineSelector.qml +++ b/resources/qml/PrinterSelector/MachineSelector.qml @@ -15,8 +15,8 @@ Cura.ExpandableComponent property bool isPrinterConnected: Cura.MachineManager.printerConnected property var outputDevice: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null - popupPadding: UM.Theme.getSize("default_lining").width - popupAlignment: Cura.ExpandableComponent.PopupAlignment.AlignLeft + contentPadding: UM.Theme.getSize("default_lining").width + contentAlignment: Cura.ExpandableComponent.ContentAlignment.AlignLeft iconSource: expanded ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_left") UM.I18nCatalog @@ -80,7 +80,7 @@ Cura.ExpandableComponent } } - popupItem: Item + contentItem: Item { id: popup width: UM.Theme.getSize("machine_selector_widget_content").width diff --git a/resources/qml/ViewsSelector.qml b/resources/qml/ViewsSelector.qml index e9fdd57177..97de60689b 100644 --- a/resources/qml/ViewsSelector.qml +++ b/resources/qml/ViewsSelector.qml @@ -11,8 +11,8 @@ Cura.ExpandableComponent { id: viewSelector - popupPadding: UM.Theme.getSize("default_lining").width - popupAlignment: Cura.ExpandableComponent.PopupAlignment.AlignLeft + contentPadding: UM.Theme.getSize("default_lining").width + contentAlignment: Cura.ExpandableComponent.ContentAlignment.AlignLeft iconSource: expanded ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_left") property var viewModel: UM.ViewModel { } @@ -70,7 +70,7 @@ Cura.ExpandableComponent } } - popupItem: Column + contentItem: Column { id: viewSelectorPopup width: viewSelector.width - 2 * viewSelector.popupPadding From 4dcce7616bb8286c265a392ed21d62fabd10e6a7 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Tue, 4 Dec 2018 13:21:26 +0100 Subject: [PATCH 41/70] Fix some leftover renamings Contributes to CURA-5941 --- resources/qml/Account/AccountDetails.qml | 4 ++-- resources/qml/ExpandableComponent.qml | 4 ++-- .../qml/PrintSetupSelector/PrintSetupSelectorContents.qml | 2 +- resources/qml/PrinterSelector/MachineSelector.qml | 4 ++-- resources/qml/PrinterSelector/MachineSelectorButton.qml | 2 +- resources/qml/ViewsSelector.qml | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/resources/qml/Account/AccountDetails.qml b/resources/qml/Account/AccountDetails.qml index a288426e0c..bfb23930c6 100644 --- a/resources/qml/Account/AccountDetails.qml +++ b/resources/qml/Account/AccountDetails.qml @@ -13,8 +13,8 @@ Column property var loggedIn: false property var profileImage: "" - padding: 2 * UM.Theme.getSize("default_margin").height - spacing: 2 * UM.Theme.getSize("default_margin").height + padding: UM.Theme.getSize("wide_margin").height + spacing: UM.Theme.getSize("wide_margin").height AvatarImage { diff --git a/resources/qml/ExpandableComponent.qml b/resources/qml/ExpandableComponent.qml index 0b4076c04a..89f6cf9f25 100644 --- a/resources/qml/ExpandableComponent.qml +++ b/resources/qml/ExpandableComponent.qml @@ -139,8 +139,8 @@ Item sourceSize.width: width sourceSize.height: height visible: source != "" - width: height - height: Math.round(0.2 * base.height) + width: UM.Theme.getSize("standard_arrow").width + height: UM.Theme.getSize("standard_arrow").height color: UM.Theme.getColor("text") } diff --git a/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml b/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml index a2856e1fe5..0524a6de9e 100644 --- a/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml +++ b/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml @@ -93,7 +93,7 @@ Item background: Item {} - onClicked: togglePopup() // Will hide the popup item + onClicked: toggleContent() // Will hide the popup item } } diff --git a/resources/qml/PrinterSelector/MachineSelector.qml b/resources/qml/PrinterSelector/MachineSelector.qml index f742d0bef3..49b4f87267 100644 --- a/resources/qml/PrinterSelector/MachineSelector.qml +++ b/resources/qml/PrinterSelector/MachineSelector.qml @@ -134,7 +134,7 @@ Cura.ExpandableComponent text: catalog.i18nc("@button", "Add printer") onClicked: { - togglePopup() + toggleContent() Cura.Actions.addMachine.trigger() } } @@ -146,7 +146,7 @@ Cura.ExpandableComponent text: catalog.i18nc("@button", "Manage printers") onClicked: { - togglePopup() + toggleContent() Cura.Actions.configureMachines.trigger() } } diff --git a/resources/qml/PrinterSelector/MachineSelectorButton.qml b/resources/qml/PrinterSelector/MachineSelectorButton.qml index 369e75cede..b88af35f82 100644 --- a/resources/qml/PrinterSelector/MachineSelectorButton.qml +++ b/resources/qml/PrinterSelector/MachineSelectorButton.qml @@ -83,7 +83,7 @@ Button onClicked: { - togglePopup() + toggleContent() Cura.MachineManager.setActiveMachine(model.id) } diff --git a/resources/qml/ViewsSelector.qml b/resources/qml/ViewsSelector.qml index 97de60689b..71a29e4949 100644 --- a/resources/qml/ViewsSelector.qml +++ b/resources/qml/ViewsSelector.qml @@ -120,7 +120,7 @@ Cura.ExpandableComponent onClicked: { - viewSelector.togglePopup() + toggleContent() UM.Controller.setActiveView(id) } } From 47ff95b1f3cfb793b2b4af6114aa1688e864d8a3 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Tue, 4 Dec 2018 13:53:11 +0100 Subject: [PATCH 42/70] Set contentType to the different expandable components. Also add a color for the active state when the contentType is 'Fixed'. Contributes to CURA-5941. --- .../SimulationViewMenuComponent.qml | 2 +- resources/qml/ExpandableComponent.qml | 28 +++++++++++-------- .../QuickConfigurationSelector.qml | 1 - .../PrintSetupSelector/PrintSetupSelector.qml | 2 +- .../qml/PrinterSelector/MachineSelector.qml | 1 - resources/qml/ViewsSelector.qml | 1 - 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/plugins/SimulationView/SimulationViewMenuComponent.qml b/plugins/SimulationView/SimulationViewMenuComponent.qml index a9eb157f48..9dc3b67658 100644 --- a/plugins/SimulationView/SimulationViewMenuComponent.qml +++ b/plugins/SimulationView/SimulationViewMenuComponent.qml @@ -16,7 +16,7 @@ Cura.ExpandableComponent id: base width: UM.Theme.getSize("layerview_menu_size").width - iconSource: UM.Theme.getIcon("pencil") + contentType: Cura.ExpandableComponent.ContentType.Fixed Connections { diff --git a/resources/qml/ExpandableComponent.qml b/resources/qml/ExpandableComponent.qml index 89f6cf9f25..f6e340c4ea 100644 --- a/resources/qml/ExpandableComponent.qml +++ b/resources/qml/ExpandableComponent.qml @@ -30,7 +30,7 @@ Item property alias headerItem: headerItemLoader.sourceComponent // The contentItem holds the QML item that is shown when the "open" button is pressed - property alias contentItem: content.contentItem + property var contentItem: content.contentItem // Defines the type of the contents property int contentType: ExpandableComponent.ContentType.Floating @@ -38,6 +38,7 @@ Item property color contentBackgroundColor: UM.Theme.getColor("action_button") property color headerBackgroundColor: UM.Theme.getColor("action_button") + property color headerActiveColor: UM.Theme.getColor("secondary") property color headerHoverColor: UM.Theme.getColor("action_button_hovered") // Defines the alignment of the content with respect of the headerItem, by default to the right @@ -123,7 +124,7 @@ Item width: parent.width height: UM.Theme.getSize("thick_lining").height color: UM.Theme.getColor("primary") - visible: expanded + visible: contentType == ExpandableComponent.ContentType.Floating && expanded anchors.bottom: parent.bottom } @@ -138,6 +139,9 @@ Item } sourceSize.width: width sourceSize.height: height + source: contentType == ExpandableComponent.ContentType.Floating ? + (expanded ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_left")) : + UM.Theme.getIcon("pencil") visible: source != "" width: UM.Theme.getSize("standard_arrow").width height: UM.Theme.getSize("standard_arrow").height @@ -151,7 +155,8 @@ Item onClicked: toggleContent() hoverEnabled: true onEntered: background.color = headerHoverColor - onExited: background.color = headerBackgroundColor + onExited: background.color = (contentType == ExpandableComponent.ContentType.Fixed && expanded) ? + headerActiveColor : headerBackgroundColor } } @@ -190,16 +195,15 @@ Item border.color: UM.Theme.getColor("lining") radius: UM.Theme.getSize("default_radius").width } + } - contentItem: Item { } - - onContentItemChanged: - { - // Since we want the size of the content to be set by the size of the content, - // we need to do it like this. - content.width = contentItem.width + 2 * content.padding - content.height = contentItem.height + 2 * content.padding - } + onContentItemChanged: + { + // Since we want the size of the content to be set by the size of the content, + // we need to do it like this. + content.width = contentItem.width + 2 * content.padding + content.height = contentItem.height + 2 * content.padding + content.contentItem = contentItem } // DO NOT MOVE UP IN THE CODE: This connection has to be here, after the definition of the content item. diff --git a/resources/qml/Menus/ConfigurationMenu/QuickConfigurationSelector.qml b/resources/qml/Menus/ConfigurationMenu/QuickConfigurationSelector.qml index de92161bbb..ea82f4fe13 100644 --- a/resources/qml/Menus/ConfigurationMenu/QuickConfigurationSelector.qml +++ b/resources/qml/Menus/ConfigurationMenu/QuickConfigurationSelector.qml @@ -27,7 +27,6 @@ Cura.ExpandableComponent name: "cura" } - iconSource: expanded ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_left") headerItem: Item { // Horizontal list that shows the extruders diff --git a/resources/qml/PrintSetupSelector/PrintSetupSelector.qml b/resources/qml/PrintSetupSelector/PrintSetupSelector.qml index 78bdbde542..0eea697950 100644 --- a/resources/qml/PrintSetupSelector/PrintSetupSelector.qml +++ b/resources/qml/PrintSetupSelector/PrintSetupSelector.qml @@ -14,7 +14,7 @@ Cura.ExpandableComponent property string enabledText: catalog.i18nc("@label:Should be short", "On") property string disabledText: catalog.i18nc("@label:Should be short", "Off") - iconSource: UM.Theme.getIcon("pencil") + contentType: Cura.ExpandableComponent.ContentType.Fixed contentPadding: UM.Theme.getSize("default_lining").width contentSpacingY: UM.Theme.getSize("narrow_margin").width diff --git a/resources/qml/PrinterSelector/MachineSelector.qml b/resources/qml/PrinterSelector/MachineSelector.qml index 49b4f87267..69a1ac899c 100644 --- a/resources/qml/PrinterSelector/MachineSelector.qml +++ b/resources/qml/PrinterSelector/MachineSelector.qml @@ -17,7 +17,6 @@ Cura.ExpandableComponent contentPadding: UM.Theme.getSize("default_lining").width contentAlignment: Cura.ExpandableComponent.ContentAlignment.AlignLeft - iconSource: expanded ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_left") UM.I18nCatalog { diff --git a/resources/qml/ViewsSelector.qml b/resources/qml/ViewsSelector.qml index 71a29e4949..d469202606 100644 --- a/resources/qml/ViewsSelector.qml +++ b/resources/qml/ViewsSelector.qml @@ -13,7 +13,6 @@ Cura.ExpandableComponent contentPadding: UM.Theme.getSize("default_lining").width contentAlignment: Cura.ExpandableComponent.ContentAlignment.AlignLeft - iconSource: expanded ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_left") property var viewModel: UM.ViewModel { } From cdb8020029bec6ee1c6c4224ff5cb02159dd810e Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Wed, 5 Dec 2018 09:39:04 +0100 Subject: [PATCH 43/70] Add another expandable component Use one of them if the drop-panel has to act as a Popup and the other if it has to act as a standard component. Contributes to CURA-5941. --- .../SimulationViewMenuComponent.qml | 1 - resources/qml/ExpandableComponent.qml | 66 ++---- resources/qml/ExpandablePopup.qml | 204 ++++++++++++++++++ .../QuickConfigurationSelector.qml | 2 +- .../PrintSetupSelector/PrintSetupSelector.qml | 4 - .../qml/PrinterSelector/MachineSelector.qml | 4 +- resources/qml/ViewsSelector.qml | 8 +- 7 files changed, 227 insertions(+), 62 deletions(-) create mode 100644 resources/qml/ExpandablePopup.qml diff --git a/plugins/SimulationView/SimulationViewMenuComponent.qml b/plugins/SimulationView/SimulationViewMenuComponent.qml index 9dc3b67658..76875a035d 100644 --- a/plugins/SimulationView/SimulationViewMenuComponent.qml +++ b/plugins/SimulationView/SimulationViewMenuComponent.qml @@ -16,7 +16,6 @@ Cura.ExpandableComponent id: base width: UM.Theme.getSize("layerview_menu_size").width - contentType: Cura.ExpandableComponent.ContentType.Fixed Connections { diff --git a/resources/qml/ExpandableComponent.qml b/resources/qml/ExpandableComponent.qml index f6e340c4ea..4f4848ea8b 100644 --- a/resources/qml/ExpandableComponent.qml +++ b/resources/qml/ExpandableComponent.qml @@ -20,20 +20,11 @@ Item AlignRight } - enum ContentType - { - Floating, - Fixed - } - // The headerItem holds the QML item that is always displayed. property alias headerItem: headerItemLoader.sourceComponent // The contentItem holds the QML item that is shown when the "open" button is pressed - property var contentItem: content.contentItem - - // Defines the type of the contents - property int contentType: ExpandableComponent.ContentType.Floating + property alias contentItem: content.contentItem property color contentBackgroundColor: UM.Theme.getColor("action_button") @@ -48,7 +39,7 @@ Item property alias contentPadding: content.padding // How much spacing is needed for the contentItem by Y coordinate - property var contentSpacingY: 0 + property var contentSpacingY: UM.Theme.getSize("narrow_margin").width // How much padding is needed around the header & button property alias headerPadding: background.padding @@ -64,17 +55,12 @@ Item // Is the "drawer" open? readonly property alias expanded: content.visible - property alias expandedHighlightColor: expandedHighlight.color - // What should the radius of the header be. This is also influenced by the headerCornerSide property alias headerRadius: background.radius // On what side should the header corners be shown? 1 is down, 2 is left, 3 is up and 4 is right. property alias headerCornerSide: background.cornerSide - // Change the contentItem close behaviour - property alias contentClosePolicy : content.closePolicy - property alias headerShadowColor: shadow.color property alias enableHeaderShadow: shadow.visible @@ -83,14 +69,7 @@ Item function toggleContent() { - if (content.visible) - { - content.close() - } - else - { - content.open() - } + content.visible = !content.visible } implicitHeight: 100 * screenScaleFactor @@ -117,17 +96,6 @@ Item } } - // A highlight that is shown when the content is expanded - Rectangle - { - id: expandedHighlight - width: parent.width - height: UM.Theme.getSize("thick_lining").height - color: UM.Theme.getColor("primary") - visible: contentType == ExpandableComponent.ContentType.Floating && expanded - anchors.bottom: parent.bottom - } - UM.RecolorImage { id: collapseButton @@ -139,9 +107,7 @@ Item } sourceSize.width: width sourceSize.height: height - source: contentType == ExpandableComponent.ContentType.Floating ? - (expanded ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_left")) : - UM.Theme.getIcon("pencil") + source: UM.Theme.getIcon("pencil") visible: source != "" width: UM.Theme.getSize("standard_arrow").width height: UM.Theme.getSize("standard_arrow").height @@ -155,8 +121,7 @@ Item onClicked: toggleContent() hoverEnabled: true onEntered: background.color = headerHoverColor - onExited: background.color = (contentType == ExpandableComponent.ContentType.Fixed && expanded) ? - headerActiveColor : headerBackgroundColor + onExited: background.color = expanded ? headerActiveColor : headerBackgroundColor } } @@ -174,9 +139,10 @@ Item z: background.z - 1 } - Popup + Control { id: content + visible: false // Ensure that the content is located directly below the headerItem y: background.height + base.shadowOffset + base.contentSpacingY @@ -185,7 +151,6 @@ Item // In case of right alignment, the 3x padding is due to left, right and padding between the button & text. x: contentAlignment == ExpandableComponent.ContentAlignment.AlignRight ? -width + collapseButton.width + headerItemLoader.width + 3 * background.padding : 0 padding: UM.Theme.getSize("default_margin").width - closePolicy: Popup.CloseOnPressOutsideParent background: Cura.RoundedRectangle { @@ -195,15 +160,16 @@ Item border.color: UM.Theme.getColor("lining") radius: UM.Theme.getSize("default_radius").width } - } - onContentItemChanged: - { - // Since we want the size of the content to be set by the size of the content, - // we need to do it like this. - content.width = contentItem.width + 2 * content.padding - content.height = contentItem.height + 2 * content.padding - content.contentItem = contentItem + contentItem: Item {} + + onContentItemChanged: + { + // Since we want the size of the content to be set by the size of the content, + // we need to do it like this. + content.width = contentItem.width + 2 * content.padding + content.height = contentItem.height + 2 * content.padding + } } // DO NOT MOVE UP IN THE CODE: This connection has to be here, after the definition of the content item. diff --git a/resources/qml/ExpandablePopup.qml b/resources/qml/ExpandablePopup.qml new file mode 100644 index 0000000000..da79d9b77b --- /dev/null +++ b/resources/qml/ExpandablePopup.qml @@ -0,0 +1,204 @@ +import QtQuick 2.7 +import QtQuick.Controls 2.3 + +import UM 1.2 as UM +import Cura 1.0 as Cura + +import QtGraphicalEffects 1.0 // For the dropshadow + +// The expandable component has 2 major sub components: +// * The headerItem; Always visible and should hold some info about what happens if the component is expanded +// * The contentItem; The content that needs to be shown if the component is expanded. +Item +{ + id: base + + // Enumeration with the different possible alignments of the content with respect of the headerItem + enum ContentAlignment + { + AlignLeft, + AlignRight + } + + // The headerItem holds the QML item that is always displayed. + property alias headerItem: headerItemLoader.sourceComponent + + // The contentItem holds the QML item that is shown when the "open" button is pressed + property alias contentItem: content.contentItem + + property color contentBackgroundColor: UM.Theme.getColor("action_button") + + property color headerBackgroundColor: UM.Theme.getColor("action_button") + property color headerActiveColor: UM.Theme.getColor("secondary") + property color headerHoverColor: UM.Theme.getColor("action_button_hovered") + + // Defines the alignment of the content with respect of the headerItem, by default to the right + property int contentAlignment: ExpandablePopup.ContentAlignment.AlignRight + + // How much spacing is needed around the contentItem + property alias contentPadding: content.padding + + // How much padding is needed around the header & button + property alias headerPadding: background.padding + + // What icon should be displayed on the right. + property alias iconSource: collapseButton.source + + property alias iconColor: collapseButton.color + + // The icon size (it's always drawn as a square) + property alias iconSize: collapseButton.height + + // Is the "drawer" open? + readonly property alias expanded: content.visible + + property alias expandedHighlightColor: expandedHighlight.color + + // What should the radius of the header be. This is also influenced by the headerCornerSide + property alias headerRadius: background.radius + + // On what side should the header corners be shown? 1 is down, 2 is left, 3 is up and 4 is right. + property alias headerCornerSide: background.cornerSide + + // Change the contentItem close behaviour + property alias contentClosePolicy : content.closePolicy + + property alias headerShadowColor: shadow.color + + property alias enableHeaderShadow: shadow.visible + + property int shadowOffset: 2 + + function toggleContent() + { + if (content.visible) + { + content.close() + } + else + { + content.open() + } + } + + implicitHeight: 100 * screenScaleFactor + implicitWidth: 400 * screenScaleFactor + + RoundedRectangle + { + id: background + property real padding: UM.Theme.getSize("default_margin").width + + color: headerBackgroundColor + anchors.fill: parent + + Loader + { + id: headerItemLoader + anchors + { + left: parent.left + right: collapseButton.visible ? collapseButton.left : parent.right + top: parent.top + bottom: parent.bottom + margins: background.padding + } + } + + // A highlight that is shown when the content is expanded + Rectangle + { + id: expandedHighlight + width: parent.width + height: UM.Theme.getSize("thick_lining").height + color: UM.Theme.getColor("primary") + visible: expanded + anchors.bottom: parent.bottom + } + + UM.RecolorImage + { + id: collapseButton + anchors + { + right: parent.right + verticalCenter: parent.verticalCenter + margins: background.padding + } + sourceSize.width: width + sourceSize.height: height + source: expanded ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_left") + visible: source != "" + width: UM.Theme.getSize("standard_arrow").width + height: UM.Theme.getSize("standard_arrow").height + color: UM.Theme.getColor("text") + } + + MouseArea + { + id: mouseArea + anchors.fill: parent + onClicked: toggleContent() + hoverEnabled: true + onEntered: background.color = headerHoverColor + onExited: background.color = headerBackgroundColor + } + } + + DropShadow + { + id: shadow + // Don't blur the shadow + radius: 0 + anchors.fill: background + source: background + verticalOffset: base.shadowOffset + visible: true + color: UM.Theme.getColor("action_button_shadow") + // Should always be drawn behind the background. + z: background.z - 1 + } + + Popup + { + id: content + + // Ensure that the content is located directly below the headerItem + y: background.height + base.shadowOffset + + // Make the content aligned with the rest, using the property contentAlignment to decide whether is right or left. + // In case of right alignment, the 3x padding is due to left, right and padding between the button & text. + x: contentAlignment == ExpandablePopup.ContentAlignment.AlignRight ? -width + collapseButton.width + headerItemLoader.width + 3 * background.padding : 0 + padding: UM.Theme.getSize("default_margin").width + closePolicy: Popup.CloseOnPressOutsideParent + + background: Cura.RoundedRectangle + { + cornerSide: Cura.RoundedRectangle.Direction.Down + color: contentBackgroundColor + border.width: UM.Theme.getSize("default_lining").width + border.color: UM.Theme.getColor("lining") + radius: UM.Theme.getSize("default_radius").width + } + + contentItem: Item {} + + onContentItemChanged: + { + // Since we want the size of the content to be set by the size of the content, + // we need to do it like this. + content.width = contentItem.width + 2 * content.padding + content.height = contentItem.height + 2 * content.padding + } + } + + // DO NOT MOVE UP IN THE CODE: This connection has to be here, after the definition of the content item. + // Apparently the order in which these are handled matters and so the height is correctly updated if this is here. + Connections + { + // Since it could be that the content is dynamically populated, we should also take these changes into account. + target: content.contentItem + onWidthChanged: content.width = content.contentItem.width + 2 * content.padding + onHeightChanged: content.height = content.contentItem.height + 2 * content.padding + } +} diff --git a/resources/qml/Menus/ConfigurationMenu/QuickConfigurationSelector.qml b/resources/qml/Menus/ConfigurationMenu/QuickConfigurationSelector.qml index ea82f4fe13..138a1d6669 100644 --- a/resources/qml/Menus/ConfigurationMenu/QuickConfigurationSelector.qml +++ b/resources/qml/Menus/ConfigurationMenu/QuickConfigurationSelector.qml @@ -12,7 +12,7 @@ import UM 1.2 as UM import Cura 1.0 as Cura -Cura.ExpandableComponent +Cura.ExpandablePopup { id: base diff --git a/resources/qml/PrintSetupSelector/PrintSetupSelector.qml b/resources/qml/PrintSetupSelector/PrintSetupSelector.qml index 0eea697950..19c8067683 100644 --- a/resources/qml/PrintSetupSelector/PrintSetupSelector.qml +++ b/resources/qml/PrintSetupSelector/PrintSetupSelector.qml @@ -14,11 +14,7 @@ Cura.ExpandableComponent property string enabledText: catalog.i18nc("@label:Should be short", "On") property string disabledText: catalog.i18nc("@label:Should be short", "Off") - contentType: Cura.ExpandableComponent.ContentType.Fixed contentPadding: UM.Theme.getSize("default_lining").width - contentSpacingY: UM.Theme.getSize("narrow_margin").width - - contentClosePolicy: Popup.CloseOnEscape UM.I18nCatalog { diff --git a/resources/qml/PrinterSelector/MachineSelector.qml b/resources/qml/PrinterSelector/MachineSelector.qml index 69a1ac899c..ef766b6030 100644 --- a/resources/qml/PrinterSelector/MachineSelector.qml +++ b/resources/qml/PrinterSelector/MachineSelector.qml @@ -7,7 +7,7 @@ import QtQuick.Controls 2.3 import UM 1.2 as UM import Cura 1.0 as Cura -Cura.ExpandableComponent +Cura.ExpandablePopup { id: machineSelector @@ -16,7 +16,7 @@ Cura.ExpandableComponent property var outputDevice: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null contentPadding: UM.Theme.getSize("default_lining").width - contentAlignment: Cura.ExpandableComponent.ContentAlignment.AlignLeft + contentAlignment: Cura.ExpandablePopup.ContentAlignment.AlignLeft UM.I18nCatalog { diff --git a/resources/qml/ViewsSelector.qml b/resources/qml/ViewsSelector.qml index d469202606..18d1f66759 100644 --- a/resources/qml/ViewsSelector.qml +++ b/resources/qml/ViewsSelector.qml @@ -7,12 +7,12 @@ import QtQuick.Controls 2.3 import UM 1.2 as UM import Cura 1.0 as Cura -Cura.ExpandableComponent +Cura.ExpandablePopup { id: viewSelector contentPadding: UM.Theme.getSize("default_lining").width - contentAlignment: Cura.ExpandableComponent.ContentAlignment.AlignLeft + contentAlignment: Cura.ExpandablePopup.ContentAlignment.AlignLeft property var viewModel: UM.ViewModel { } @@ -72,13 +72,13 @@ Cura.ExpandableComponent contentItem: Column { id: viewSelectorPopup - width: viewSelector.width - 2 * viewSelector.popupPadding + width: viewSelector.width - 2 * viewSelector.contentPadding // For some reason the height/width of the column gets set to 0 if this is not set... Component.onCompleted: { height = implicitHeight - width = viewSelector.width - 2 * viewSelector.popupPadding + width = viewSelector.width - 2 * viewSelector.contentPadding } Repeater From 034b1660f766211bd658127e28f0dd35809c2f6b Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Wed, 5 Dec 2018 13:05:22 +0100 Subject: [PATCH 44/70] Adjust sizes in the custom print setup mode Contributes to CURA-5941. --- .../qml/PrintSetupSelector/Custom/CustomPrintSetup.qml | 9 +++------ .../PrintSetupSelector/PrintSetupSelectorContents.qml | 8 ++++---- resources/themes/cura-light/theme.json | 2 +- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml index b524bb5926..8b0f3524d7 100644 --- a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml @@ -11,9 +11,7 @@ import Cura 1.0 as Cura Item { id: customPrintSetup - - // TODO: Hardcoded now but UX has to decide about the height of this item - height: 480 + height: childrenRect.height + padding property real padding: UM.Theme.getSize("default_margin").width property bool multipleExtruders: extrudersModel.count > 1 @@ -93,16 +91,15 @@ Item Rectangle { + height: UM.Theme.getSize("print_setup_widget").height anchors { - top: tabBar.visible ? tabBar.bottom : globalProfileRow.bottom + top: tabBar.bottom left: parent.left leftMargin: parent.padding right: parent.right rightMargin: parent.padding - bottom: parent.bottom topMargin: -UM.Theme.getSize("default_lining").width - bottomMargin: -UM.Theme.getSize("default_lining").width } z: tabBar.z - 1 // Don't show the border when only one extruder diff --git a/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml b/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml index 0524a6de9e..522b038423 100644 --- a/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml +++ b/resources/qml/PrintSetupSelector/PrintSetupSelectorContents.qml @@ -28,7 +28,7 @@ Item { var index = Math.round(UM.Preferences.getValue("cura/active_mode")) - if(index != null && !isNaN(index)) + if (index != null && !isNaN(index)) { return index } @@ -150,7 +150,8 @@ Item { id: buttonsSeparator - anchors.top: contents.bottom + // The buttonsSeparator is inside the contents. This is to avoid a double line in the bottom + anchors.bottom: contents.bottom width: parent.width height: UM.Theme.getSize("default_lining").height color: UM.Theme.getColor("lining") @@ -162,10 +163,9 @@ Item property real padding: UM.Theme.getSize("default_margin").width height: childrenRect.height + 2 * padding - // The buttonsSeparator is inside the buttonRow. This is to avoid some weird behaviours with the scroll bar. anchors { - top: buttonsSeparator.top + top: buttonsSeparator.bottom left: parent.left right: parent.right } diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index 8e440757aa..f383a570a2 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -369,7 +369,7 @@ "account_button": [12, 3], - "print_setup_widget": [38.0, 42.0], + "print_setup_widget": [38.0, 30.0], "print_setup_mode_toggle": [0.0, 2.0], "print_setup_item": [0.0, 2.0], "print_setup_extruder_box": [0.0, 6.0], From 5b57e6bf307eb2060b6c386c054401ab0625a779 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Wed, 5 Dec 2018 13:24:34 +0100 Subject: [PATCH 45/70] Code style in JobSpecs --- resources/qml/JobSpecs.qml | 82 +++++++++++++++++++++++--------------- 1 file changed, 49 insertions(+), 33 deletions(-) diff --git a/resources/qml/JobSpecs.qml b/resources/qml/JobSpecs.qml index 45111992c1..5f773f9b25 100644 --- a/resources/qml/JobSpecs.qml +++ b/resources/qml/JobSpecs.qml @@ -9,20 +9,27 @@ import QtQuick.Layouts 1.1 import UM 1.1 as UM import Cura 1.0 as Cura -Item { +Item +{ id: base property bool activity: CuraApplication.platformActivity property string fileBaseName: PrintInformation.baseName - UM.I18nCatalog { id: catalog; name: "cura"} + UM.I18nCatalog + { + id: catalog + name:"cura" + } height: childrenRect.height - onActivityChanged: { - if (activity == false) { + onActivityChanged: + { + if (!activity) + { //When there is no mesh in the buildplate; the printJobTextField is set to an empty string so it doesn't set an empty string as a jobName (which is later used for saving the file) - PrintInformation.baseName = '' + PrintInformation.baseName = "" } } @@ -49,21 +56,22 @@ Item { onClicked: { - printJobTextfield.selectAll(); - printJobTextfield.focus = true; + printJobTextfield.selectAll() + printJobTextfield.focus = true } + style: ButtonStyle { background: Item { UM.RecolorImage { - width: UM.Theme.getSize("save_button_specs_icons").width; - height: UM.Theme.getSize("save_button_specs_icons").height; - sourceSize.width: width; - sourceSize.height: width; - color: control.hovered ? UM.Theme.getColor("text_scene_hover") : UM.Theme.getColor("text_scene"); - source: UM.Theme.getIcon("pencil"); + width: UM.Theme.getSize("save_button_specs_icons").width + height: UM.Theme.getSize("save_button_specs_icons").height + sourceSize.width: width + sourceSize.height: width + color: control.hovered ? UM.Theme.getColor("text_scene_hover") : UM.Theme.getColor("text_scene") + source: UM.Theme.getIcon("pencil") } } } @@ -73,25 +81,31 @@ Item { { id: printJobTextfield anchors.right: printJobPencilIcon.left - anchors.rightMargin: Math.round(UM.Theme.getSize("default_margin").width / 2) + anchors.rightMargin: UM.Theme.getSize("narrow_margin").width height: UM.Theme.getSize("jobspecs_line").height width: Math.max(__contentWidth + UM.Theme.getSize("default_margin").width, 50) maximumLength: 120 property int unremovableSpacing: 5 text: PrintInformation.jobName horizontalAlignment: TextInput.AlignRight - onEditingFinished: { - var new_name = text == "" ? catalog.i18nc("@text Print job name", "Untitled") : text; - PrintInformation.setJobName(new_name, true); - printJobTextfield.focus = false; + + onEditingFinished: + { + var new_name = text == "" ? catalog.i18nc("@text Print job name", "Untitled") : text + PrintInformation.setJobName(new_name, true) + printJobTextfield.focus = false } + validator: RegExpValidator { regExp: /^[^\\\/\*\?\|\[\]]*$/ } - style: TextFieldStyle{ - textColor: UM.Theme.getColor("text_scene"); - font: UM.Theme.getFont("default_bold"); - background: Rectangle { + + style: TextFieldStyle + { + textColor: UM.Theme.getColor("text_scene") + font: UM.Theme.getFont("default_bold") + background: Rectangle + { opacity: 0 border.width: 0 } @@ -100,7 +114,8 @@ Item { } } - Row { + Row + { id: additionalComponentsRow anchors.top: jobNameRow.bottom anchors.right: parent.right @@ -117,10 +132,7 @@ Item { { return UM.Theme.getSize("default_margin").width } - else - { - return 0; - } + return 0 } height: UM.Theme.getSize("jobspecs_line").height verticalAlignment: Text.AlignVCenter @@ -129,21 +141,25 @@ Item { text: CuraApplication.getSceneBoundingBoxString } - Component.onCompleted: { + Component.onCompleted: + { base.addAdditionalComponents("jobSpecsButton") } - Connections { + Connections + { target: CuraApplication onAdditionalComponentsChanged: base.addAdditionalComponents("jobSpecsButton") } - function addAdditionalComponents (areaId) { - if(areaId == "jobSpecsButton") { - for (var component in CuraApplication.additionalComponents["jobSpecsButton"]) { + function addAdditionalComponents (areaId) + { + if (areaId == "jobSpecsButton") + { + for (var component in CuraApplication.additionalComponents["jobSpecsButton"]) + { CuraApplication.additionalComponents["jobSpecsButton"][component].parent = additionalComponentsRow } } } - } From 0e22f6b672a29c8b57309332a1f77355f151f870 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Wed, 5 Dec 2018 13:30:01 +0100 Subject: [PATCH 46/70] Fix an issue that caused a non-deterministic segfault Also add a topMargin only when there are tabs in the custom print setup. Contributes to CURA-5941. --- .../Custom/CustomPrintSetup.qml | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml index 8b0f3524d7..b28c9ceb46 100644 --- a/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml @@ -52,8 +52,6 @@ Item rightMargin: parent.padding } - currentIndex: Math.max(Cura.ExtruderManager.activeExtruderIndex, 0) - Repeater { id: repeater @@ -76,15 +74,27 @@ Item } } - // When the model of the extruders is rebuilt, the list of extruders is briefly emptied and rebuilt. - // This causes the currentIndex of the tab to be in an invalid position which resets it to 0. - // Therefore we need to change it back to what it was: The active extruder index. + //When active extruder changes for some other reason, switch tabs. + //Don't directly link currentIndex to Cura.ExtruderManager.activeExtruderIndex! + //This causes a segfault in Qt 5.11. Something with VisualItemModel removing index -1. We have to use setCurrentIndex instead. + Connections + { + target: Cura.ExtruderManager + onActiveExtruderChanged: + { + tabBar.setCurrentIndex(Cura.ExtruderManager.activeExtruderIndex); + } + } + + //When the model of the extruders is rebuilt, the list of extruders is briefly emptied and rebuilt. + //This causes the currentIndex of the tab to be in an invalid position which resets it to 0. + //Therefore we need to change it back to what it was: The active extruder index. Connections { target: repeater.model onModelChanged: { - tabBar.currentIndex = Math.max(Cura.ExtruderManager.activeExtruderIndex, 0) + tabBar.setCurrentIndex(Cura.ExtruderManager.activeExtruderIndex) } } } @@ -94,7 +104,7 @@ Item height: UM.Theme.getSize("print_setup_widget").height anchors { - top: tabBar.bottom + top: tabBar.visible ? tabBar.bottom : globalProfileRow.bottom left: parent.left leftMargin: parent.padding right: parent.right From 218fa3aded7ed4e4fb77bd092ca7e798ca948dae Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Wed, 5 Dec 2018 14:22:04 +0100 Subject: [PATCH 47/70] Align the print info to the left --- resources/qml/Cura.qml | 26 ++++---- resources/qml/JobSpecs.qml | 126 +++++++++++++++++-------------------- 2 files changed, 71 insertions(+), 81 deletions(-) diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index 3578888886..6559fafa12 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -189,16 +189,6 @@ UM.MainWindow onHideTooltip: base.hideTooltip() } - JobSpecs - { - id: jobSpecs - anchors - { - bottom: parent.bottom - bottomMargin: UM.Theme.getSize("default_margin").height - } - } - Toolbar { // The toolbar is the left bar that is populated by all the tools (which are dynamicly populated by @@ -228,6 +218,19 @@ UM.MainWindow } } + JobSpecs + { + id: jobSpecs + visible: CuraApplication.platformActivity + anchors + { + left: parent.left + bottom: viewOrientationControls.top + margins: UM.Theme.getSize("wide_margin").width + bottomMargin: UM.Theme.getSize("default_margin").width + } + } + ViewOrientationControls { id: viewOrientationControls @@ -235,9 +238,8 @@ UM.MainWindow anchors { left: parent.left - margins: UM.Theme.getSize("default_margin").width - bottom: parent.bottom + margins: UM.Theme.getSize("wide_margin").width } } diff --git a/resources/qml/JobSpecs.qml b/resources/qml/JobSpecs.qml index 19b5b3f2de..97e12e15a3 100644 --- a/resources/qml/JobSpecs.qml +++ b/resources/qml/JobSpecs.qml @@ -19,9 +19,10 @@ Item UM.I18nCatalog { id: catalog - name:"cura" + name: "cura" } + width: childrenRect.width height: childrenRect.height onActivityChanged: @@ -33,82 +34,75 @@ Item } } - Rectangle + Item { id: jobNameRow anchors.top: parent.top - anchors.right: parent.right + anchors.left: parent.left height: UM.Theme.getSize("jobspecs_line").height - visible: base.activity - Item + Button { - width: parent.width - height: parent.height + id: printJobPencilIcon + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter + width: UM.Theme.getSize("save_button_specs_icons").width + height: UM.Theme.getSize("save_button_specs_icons").height - Button + onClicked: { - id: printJobPencilIcon - anchors.right: parent.right - anchors.verticalCenter: parent.verticalCenter - width: UM.Theme.getSize("save_button_specs_icons").width - height: UM.Theme.getSize("save_button_specs_icons").height + printJobTextfield.selectAll() + printJobTextfield.focus = true + } - onClicked: + style: ButtonStyle + { + background: Item { - printJobTextfield.selectAll() - printJobTextfield.focus = true - } - - style: ButtonStyle - { - background: Item + UM.RecolorImage { - UM.RecolorImage - { - width: UM.Theme.getSize("save_button_specs_icons").width - height: UM.Theme.getSize("save_button_specs_icons").height - sourceSize.width: width - sourceSize.height: width - color: control.hovered ? UM.Theme.getColor("text_scene_hover") : UM.Theme.getColor("text_scene") - source: UM.Theme.getIcon("pencil") - } + width: UM.Theme.getSize("save_button_specs_icons").width + height: UM.Theme.getSize("save_button_specs_icons").height + sourceSize.width: width + sourceSize.height: width + color: control.hovered ? UM.Theme.getColor("text_scene_hover") : UM.Theme.getColor("text_scene") + source: UM.Theme.getIcon("pencil") } } } + } - TextField + TextField + { + id: printJobTextfield + anchors.left: printJobPencilIcon.right + anchors.leftMargin: UM.Theme.getSize("narrow_margin").width + height: UM.Theme.getSize("jobspecs_line").height + width: Math.max(__contentWidth + UM.Theme.getSize("default_margin").width, 50) + maximumLength: 120 + property int unremovableSpacing: 5 + text: PrintInformation.jobName + horizontalAlignment: TextInput.AlignLeft + + onEditingFinished: { - id: printJobTextfield - anchors.right: printJobPencilIcon.left - anchors.rightMargin: UM.Theme.getSize("narrow_margin").width - height: UM.Theme.getSize("jobspecs_line").height - width: Math.max(__contentWidth + UM.Theme.getSize("default_margin").width, 50) - maximumLength: 120 - property int unremovableSpacing: 5 - text: PrintInformation.jobName - horizontalAlignment: TextInput.AlignRight + var new_name = text == "" ? catalog.i18nc("@text Print job name", "Untitled") : text + PrintInformation.setJobName(new_name, true) + printJobTextfield.focus = false + } - onEditingFinished: + validator: RegExpValidator { + regExp: /^[^\\\/\*\?\|\[\]]*$/ + } + + style: TextFieldStyle + { + textColor: UM.Theme.getColor("text_scene") + font: UM.Theme.getFont("default_bold") + background: Rectangle { - var new_name = text == "" ? catalog.i18nc("@text Print job name", "Untitled") : text - PrintInformation.setJobName(new_name, true) - printJobTextfield.focus = false - } - - validator: RegExpValidator { - regExp: /^[^\\\/\*\?\|\[\]]*$/ - } - - style: TextFieldStyle - { - textColor: UM.Theme.getColor("text_scene") - font: UM.Theme.getFont("default_bold") - background: Rectangle - { - opacity: 0 - border.width: 0 - } + opacity: 0 + border.width: 0 } } } @@ -118,22 +112,16 @@ Item { id: additionalComponentsRow anchors.top: jobNameRow.bottom - anchors.right: parent.right + anchors.left: parent.left } Label { id: boundingSpec anchors.top: jobNameRow.bottom - anchors.right: additionalComponentsRow.left - anchors.rightMargin: - { - if (additionalComponentsRow.width > 0) - { - return UM.Theme.getSize("default_margin").width - } - return 0 - } + anchors.left: additionalComponentsRow.right + anchors.leftMargin: additionalComponentsRow.width > 0 ? UM.Theme.getSize("default_margin").width : 0 + height: UM.Theme.getSize("jobspecs_line").height verticalAlignment: Text.AlignVCenter font: UM.Theme.getFont("default_bold") From c757bf128e9fae8895973956a671fc0bcc430b31 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Thu, 6 Dec 2018 09:12:43 +0100 Subject: [PATCH 48/70] Adjust colors and alignments in the print info panel --- resources/qml/Cura.qml | 6 +++--- resources/qml/ExpandableComponent.qml | 2 +- resources/themes/cura-light/theme.json | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index 6559fafa12..ba1230f37d 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -226,8 +226,8 @@ UM.MainWindow { left: parent.left bottom: viewOrientationControls.top - margins: UM.Theme.getSize("wide_margin").width - bottomMargin: UM.Theme.getSize("default_margin").width + margins: UM.Theme.getSize("default_margin").width + bottomMargin: UM.Theme.getSize("thin_margin").width } } @@ -239,7 +239,7 @@ UM.MainWindow { left: parent.left bottom: parent.bottom - margins: UM.Theme.getSize("wide_margin").width + margins: UM.Theme.getSize("default_margin").width } } diff --git a/resources/qml/ExpandableComponent.qml b/resources/qml/ExpandableComponent.qml index 9bedaa940c..3991ed74ba 100644 --- a/resources/qml/ExpandableComponent.qml +++ b/resources/qml/ExpandableComponent.qml @@ -142,7 +142,7 @@ Item visible: source != "" width: height height: Math.round(0.2 * base.height) - color: UM.Theme.getColor("text") + color: UM.Theme.getColor("small_button_text") } MouseArea diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index 767b6eaccd..3cea54ac77 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -123,8 +123,8 @@ "text_subtext": [0, 0, 0, 255], "text_medium": [128, 128, 128, 255], "text_emphasis": [255, 255, 255, 255], - "text_scene": [31, 36, 39, 255], - "text_scene_hover": [70, 84, 113, 255], + "text_scene": [102, 102, 102, 255], + "text_scene_hover": [123, 123, 113, 255], "error": [255, 140, 0, 255], "warning": [255, 190, 35, 255], @@ -144,10 +144,10 @@ "button_text_active_hover": [255, 255, 255, 255], "small_button": [0, 0, 0, 0], - "small_button_hover": [10, 8, 80, 255], + "small_button_hover": [102, 102, 102, 255], "small_button_active": [10, 8, 80, 255], "small_button_active_hover": [10, 8, 80, 255], - "small_button_text": [171, 171, 191, 255], + "small_button_text": [102, 102, 102, 255], "small_button_text_hover": [255, 255, 255, 255], "small_button_text_active": [255, 255, 255, 255], "small_button_text_active_hover": [255, 255, 255, 255], From b0c3a4e17a558154807a7807218367cb1b158a64 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Thu, 6 Dec 2018 09:25:31 +0100 Subject: [PATCH 49/70] Align the additional components to the right of the job specs The model checker now shows centered --- plugins/ModelChecker/ModelChecker.qml | 12 +++++++----- resources/qml/JobSpecs.qml | 21 +++++++++++---------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/plugins/ModelChecker/ModelChecker.qml b/plugins/ModelChecker/ModelChecker.qml index 437df29516..ddeed063b1 100644 --- a/plugins/ModelChecker/ModelChecker.qml +++ b/plugins/ModelChecker/ModelChecker.qml @@ -4,19 +4,19 @@ import QtQuick 2.2 import QtQuick.Controls 1.1 import QtQuick.Controls.Styles 1.1 -import QtQuick.Layouts 1.1 -import QtQuick.Dialogs 1.1 -import QtQuick.Window 2.2 import UM 1.2 as UM -import Cura 1.0 as Cura Button { id: modelCheckerButton - UM.I18nCatalog{id: catalog; name: "cura"} + UM.I18nCatalog + { + id: catalog + name: "cura" + } visible: manager.hasWarnings tooltip: catalog.i18nc("@info:tooltip", "Some things could be problematic in this print. Click to see tips for adjustment.") @@ -25,6 +25,8 @@ Button width: UM.Theme.getSize("save_button_specs_icons").width height: UM.Theme.getSize("save_button_specs_icons").height + anchors.verticalCenter: parent ? parent.verticalCenter : undefined + style: ButtonStyle { background: Item diff --git a/resources/qml/JobSpecs.qml b/resources/qml/JobSpecs.qml index 97e12e15a3..8b06ab06db 100644 --- a/resources/qml/JobSpecs.qml +++ b/resources/qml/JobSpecs.qml @@ -108,19 +108,11 @@ Item } } - Row - { - id: additionalComponentsRow - anchors.top: jobNameRow.bottom - anchors.left: parent.left - } - Label { id: boundingSpec anchors.top: jobNameRow.bottom - anchors.left: additionalComponentsRow.right - anchors.leftMargin: additionalComponentsRow.width > 0 ? UM.Theme.getSize("default_margin").width : 0 + anchors.left: parent.left height: UM.Theme.getSize("jobspecs_line").height verticalAlignment: Text.AlignVCenter @@ -129,6 +121,15 @@ Item text: CuraApplication.getSceneBoundingBoxString } + Row + { + id: additionalComponentsRow + anchors.top: boundingSpec.top + anchors.bottom: boundingSpec.bottom + anchors.left: boundingSpec.right + anchors.leftMargin: UM.Theme.getSize("default_margin").width + } + Component.onCompleted: { base.addAdditionalComponents("jobSpecsButton") @@ -140,7 +141,7 @@ Item onAdditionalComponentsChanged: base.addAdditionalComponents("jobSpecsButton") } - function addAdditionalComponents (areaId) + function addAdditionalComponents(areaId) { if (areaId == "jobSpecsButton") { From f7f3c96f81d82cead247c3ecd0d3925d79047a48 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Thu, 6 Dec 2018 10:53:40 +0100 Subject: [PATCH 50/70] Fix typo CURA-5941 --- .../Recommended/RecommendedAdhesionSelector.qml | 2 +- .../Recommended/RecommendedInfillDensitySelector.qml | 2 +- .../Recommended/RecommendedPrintSetup.qml | 2 +- .../Recommended/RecommendedSupportSelector.qml | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml index 3092644d4e..a5f35f333b 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedAdhesionSelector.qml @@ -50,7 +50,7 @@ Item //: Setting enable printing build-plate adhesion helper checkbox style: UM.Theme.styles.checkbox - enabled: recommendedPrintSettup.settingsEnabled + enabled: recommendedPrintSetup.settingsEnabled visible: platformAdhesionType.properties.enabled == "True" checked: platformAdhesionType.properties.value != "skirt" && platformAdhesionType.properties.value != "none" diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedInfillDensitySelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedInfillDensitySelector.qml index 7c026ac9de..2971415948 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedInfillDensitySelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedInfillDensitySelector.qml @@ -189,7 +189,7 @@ Item text: catalog.i18nc("@label", "Gradual infill") style: UM.Theme.styles.checkbox - enabled: recommendedPrintSettup.settingsEnabled + enabled: recommendedPrintSetup.settingsEnabled visible: infillSteps.properties.enabled == "True" checked: parseInt(infillSteps.properties.value) > 0 diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml index 618c519d31..6885f8c041 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedPrintSetup.qml @@ -10,7 +10,7 @@ import Cura 1.0 as Cura Item { - id: recommendedPrintSettup + id: recommendedPrintSetup height: childrenRect.height + 2 * padding diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml index da46f2a735..57e0c8ce6b 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedSupportSelector.qml @@ -50,7 +50,7 @@ Item property alias _hovered: enableSupportMouseArea.containsMouse style: UM.Theme.styles.checkbox - enabled: recommendedPrintSettup.settingsEnabled + enabled: recommendedPrintSetup.settingsEnabled visible: supportEnabled.properties.enabled == "True" checked: supportEnabled.properties.value == "True" @@ -87,7 +87,7 @@ Item } style: UM.Theme.styles.combobox_color - enabled: recommendedPrintSettup.settingsEnabled + enabled: recommendedPrintSetup.settingsEnabled visible: enableSupportCheckBox.visible && (supportEnabled.properties.value == "True") && (extrudersEnabledCount.properties.value > 1) textRole: "text" // this solves that the combobox isn't populated in the first time Cura is started @@ -127,7 +127,7 @@ Item id: supportExtruderMouseArea anchors.fill: parent hoverEnabled: true - enabled: recommendedPrintSettup.settingsEnabled + enabled: recommendedPrintSetup.settingsEnabled acceptedButtons: Qt.NoButton onEntered: { From 85f2a7e8f692e5202f4821e25ea9a9a7d79d7501 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Thu, 6 Dec 2018 14:04:21 +0100 Subject: [PATCH 51/70] Move visible to Rows for extruder configs CURA-5941 So the whole row, such as "material", will be shown/hiden based on whether the machine has materials. --- .../Menus/ConfigurationMenu/CustomConfiguration.qml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/resources/qml/Menus/ConfigurationMenu/CustomConfiguration.qml b/resources/qml/Menus/ConfigurationMenu/CustomConfiguration.qml index 19b7158929..ac40958a29 100644 --- a/resources/qml/Menus/ConfigurationMenu/CustomConfiguration.qml +++ b/resources/qml/Menus/ConfigurationMenu/CustomConfiguration.qml @@ -140,6 +140,7 @@ Item Row { height: UM.Theme.getSize("print_setup_item").height + visible: extrudersModel.count > 1 // If there is only one extruder, there is no point to enable/disable that. Label { @@ -149,7 +150,6 @@ Item color: UM.Theme.getColor("text") height: parent.height width: selectors.textWidth - visible: extrudersModel.count > 1 } OldControls.CheckBox @@ -158,7 +158,6 @@ Item enabled: !checked || Cura.MachineManager.numberExtrudersEnabled > 1 //Disable if it's the last enabled extruder. height: UM.Theme.getSize("setting_control").height style: UM.Theme.styles.checkbox - visible: extrudersModel.count > 1 /* Use a MouseArea to process the click on this checkbox. This is necessary because actually clicking the checkbox @@ -177,6 +176,8 @@ Item Row { height: UM.Theme.getSize("print_setup_item").height + visible: Cura.MachineManager.hasMaterials + Label { text: catalog.i18nc("@label", "Material") @@ -185,7 +186,6 @@ Item color: UM.Theme.getColor("text") height: parent.height width: selectors.textWidth - visible: materialSelection.visible } OldControls.ToolButton @@ -197,7 +197,6 @@ Item text: Cura.MachineManager.activeStack != null ? Cura.MachineManager.activeStack.material.name : "" tooltip: text - visible: Cura.MachineManager.hasMaterials height: UM.Theme.getSize("setting_control").height width: selectors.controlWidth @@ -214,6 +213,7 @@ Item Row { height: UM.Theme.getSize("print_setup_item").height + visible: Cura.MachineManager.hasVariants Label { @@ -223,15 +223,13 @@ Item color: UM.Theme.getColor("text") height: parent.height width: selectors.textWidth - visible: variantSelection.visible } OldControls.ToolButton { id: variantSelection text: Cura.MachineManager.activeVariantName - tooltip: Cura.MachineManager.activeVariantName; - visible: Cura.MachineManager.hasVariants + tooltip: Cura.MachineManager.activeVariantName height: UM.Theme.getSize("setting_control").height width: selectors.controlWidth From c39674cd0cbbc3cb8e71bd9ece5a72d0c4eefcd0 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Thu, 6 Dec 2018 16:22:26 +0100 Subject: [PATCH 52/70] Use upper camel case for enum options Contributes to issue CURA-5876. --- .../ConfigurationMenu/ConfigurationMenu.qml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml b/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml index 1d086acc67..9bef2ca0be 100644 --- a/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml +++ b/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml @@ -30,8 +30,8 @@ Cura.ExpandableComponent enum ConfigurationMethod { - AUTO, - CUSTOM + Auto, + Custom } iconSource: expanded ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_left") @@ -134,7 +134,7 @@ Cura.ExpandableComponent is_connected = Cura.MachineManager.activeMachineNetworkKey !== "" && Cura.MachineManager.printerConnected //Re-evaluate. } - property int configuration_method: is_connected ? ConfigurationMenu.ConfigurationMethod.AUTO : ConfigurationMenu.ConfigurationMethod.CUSTOM //Auto if connected to a printer at start-up, or Custom if not. + property int configuration_method: is_connected ? ConfigurationMenu.ConfigurationMethod.Auto : ConfigurationMenu.ConfigurationMethod.Custom //Auto if connected to a printer at start-up, or Custom if not. Item { @@ -143,13 +143,13 @@ Cura.ExpandableComponent AutoConfiguration { id: autoConfiguration - visible: popupItem.configuration_method == ConfigurationMenu.ConfigurationMethod.AUTO + visible: popupItem.configuration_method == ConfigurationMenu.ConfigurationMethod.Auto } CustomConfiguration { id: customConfiguration - visible: popupItem.configuration_method == ConfigurationMenu.ConfigurationMethod.CUSTOM + visible: popupItem.configuration_method == ConfigurationMenu.ConfigurationMethod.Custom } } @@ -177,7 +177,7 @@ Cura.ExpandableComponent Cura.SecondaryButton { id: goToCustom - visible: popupItem.configuration_method == ConfigurationMenu.ConfigurationMethod.AUTO + visible: popupItem.configuration_method == ConfigurationMenu.ConfigurationMethod.Auto text: catalog.i18nc("@label", "Custom") anchors.right: parent.right @@ -185,18 +185,18 @@ Cura.ExpandableComponent iconSource: UM.Theme.getIcon("arrow_right") isIconOnRightSide: true - onClicked: popupItem.configuration_method = ConfigurationMenu.ConfigurationMethod.CUSTOM + onClicked: popupItem.configuration_method = ConfigurationMenu.ConfigurationMethod.Custom } Cura.SecondaryButton { id: goToAuto - visible: popupItem.configuration_method == ConfigurationMenu.ConfigurationMethod.CUSTOM + visible: popupItem.configuration_method == ConfigurationMenu.ConfigurationMethod.Custom text: catalog.i18nc("@label", "Configurations") iconSource: UM.Theme.getIcon("arrow_left") - onClicked: popupItem.configuration_method = ConfigurationMenu.ConfigurationMethod.AUTO + onClicked: popupItem.configuration_method = ConfigurationMenu.ConfigurationMethod.Auto } } } From 05b32548f38b279da211279d753016ac19ef74dd Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Thu, 6 Dec 2018 16:27:56 +0100 Subject: [PATCH 53/70] Code style: Start comments with a space Contributes to issue CURA-5876. --- cura/Settings/ExtruderStack.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cura/Settings/ExtruderStack.py b/cura/Settings/ExtruderStack.py index d626ef06da..edb0e7d41f 100644 --- a/cura/Settings/ExtruderStack.py +++ b/cura/Settings/ExtruderStack.py @@ -52,8 +52,8 @@ class ExtruderStack(CuraContainerStack): return super().getNextStack() def setEnabled(self, enabled: bool) -> None: - if self.getMetaDataEntry("enabled", True) == enabled: #No change. - return #Don't emit a signal then. + if self.getMetaDataEntry("enabled", True) == enabled: # No change. + return # Don't emit a signal then. self.setMetaDataEntry("enabled", str(enabled)) self.enabledChanged.emit() From 677edd51eea2ba87392851b2a5d01402e133e459 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Fri, 7 Dec 2018 10:55:20 +0100 Subject: [PATCH 54/70] Remove unnecessary visibles CURA-5941 Because the parent Rows already have it set. --- resources/qml/Menus/ConfigurationMenu/CustomConfiguration.qml | 3 --- 1 file changed, 3 deletions(-) diff --git a/resources/qml/Menus/ConfigurationMenu/CustomConfiguration.qml b/resources/qml/Menus/ConfigurationMenu/CustomConfiguration.qml index eb8c81f228..ec9c5d0e38 100644 --- a/resources/qml/Menus/ConfigurationMenu/CustomConfiguration.qml +++ b/resources/qml/Menus/ConfigurationMenu/CustomConfiguration.qml @@ -151,7 +151,6 @@ Item color: UM.Theme.getColor("text") height: parent.height width: selectors.textWidth - visible: extrudersModel.count > 1 renderType: Text.NativeRendering } @@ -189,7 +188,6 @@ Item color: UM.Theme.getColor("text") height: parent.height width: selectors.textWidth - visible: materialSelection.visible renderType: Text.NativeRendering } @@ -228,7 +226,6 @@ Item color: UM.Theme.getColor("text") height: parent.height width: selectors.textWidth - visible: variantSelection.visible renderType: Text.NativeRendering } From da052fbe81eb8fc5c03049e867d0d8417146aff9 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Fri, 7 Dec 2018 11:21:25 +0100 Subject: [PATCH 55/70] Not show a tooltip in the output device selector when the popup shows up --- resources/qml/ActionPanel/OutputDevicesActionButton.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/ActionPanel/OutputDevicesActionButton.qml b/resources/qml/ActionPanel/OutputDevicesActionButton.qml index 95750e6d11..9a6c97bcff 100644 --- a/resources/qml/ActionPanel/OutputDevicesActionButton.qml +++ b/resources/qml/ActionPanel/OutputDevicesActionButton.qml @@ -55,7 +55,7 @@ Item leftPadding: UM.Theme.getSize("narrow_margin").width //Need more space than usual here for wide text. rightPadding: UM.Theme.getSize("narrow_margin").width - tooltip: catalog.i18nc("@info:tooltip", "Select the active output device") + tooltip: popup.opened ? "" : catalog.i18nc("@info:tooltip", "Select the active output device") iconSource: popup.opened ? UM.Theme.getIcon("arrow_top") : UM.Theme.getIcon("arrow_bottom") color: UM.Theme.getColor("action_panel_secondary") visible: (devicesModel.deviceCount > 1) From 898fd25ddb456a3dcfba6900e2ff03d5843fb5f9 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Fri, 7 Dec 2018 11:43:41 +0100 Subject: [PATCH 56/70] Remove the component IconLabel since we have a similar one in IconWithText Contributes to CURA-5941. --- .../qml/ActionPanel/OutputProcessWidget.qml | 5 +- .../qml/ActionPanel/SliceProcessWidget.qml | 3 +- resources/qml/IconLabel.qml | 50 ------------------- resources/qml/IconWithText.qml | 6 ++- .../PrintSetupSelectorHeader.qml | 1 - resources/qml/qmldir | 1 - 6 files changed, 7 insertions(+), 59 deletions(-) delete mode 100644 resources/qml/IconLabel.qml diff --git a/resources/qml/ActionPanel/OutputProcessWidget.qml b/resources/qml/ActionPanel/OutputProcessWidget.qml index 1d1a1e44e1..3f53abf28f 100644 --- a/resources/qml/ActionPanel/OutputProcessWidget.qml +++ b/resources/qml/ActionPanel/OutputProcessWidget.qml @@ -44,7 +44,7 @@ Column rightMargin: UM.Theme.getSize("thin_margin").height } - Cura.IconLabel + Cura.IconWithText { id: estimatedTime width: parent.width @@ -54,7 +54,7 @@ Column font: UM.Theme.getFont("default_bold") } - Cura.IconLabel + Cura.IconWithText { id: estimatedCosts width: parent.width @@ -84,7 +84,6 @@ Column return totalWeights + "g ยท " + totalLengths.toFixed(2) + "m" } source: UM.Theme.getIcon("spool") - font: UM.Theme.getFont("default") } } diff --git a/resources/qml/ActionPanel/SliceProcessWidget.qml b/resources/qml/ActionPanel/SliceProcessWidget.qml index 8f6608e15c..18caeafb40 100644 --- a/resources/qml/ActionPanel/SliceProcessWidget.qml +++ b/resources/qml/ActionPanel/SliceProcessWidget.qml @@ -52,7 +52,7 @@ Column renderType: Text.NativeRendering } - Cura.IconLabel + Cura.IconWithText { id: unableToSliceMessage width: parent.width @@ -61,7 +61,6 @@ Column text: catalog.i18nc("@label:PrintjobStatus", "Unable to Slice") source: UM.Theme.getIcon("warning") color: UM.Theme.getColor("warning") - font: UM.Theme.getFont("default") } // Progress bar, only visible when the backend is in the process of slice the printjob diff --git a/resources/qml/IconLabel.qml b/resources/qml/IconLabel.qml deleted file mode 100644 index ed41fba499..0000000000 --- a/resources/qml/IconLabel.qml +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) 2018 Ultimaker B.V. -// Cura is released under the terms of the LGPLv3 or higher. - -import QtQuick 2.7 -import QtQuick.Controls 2.3 - -import UM 1.1 as UM - -// This item will show a label with a squared icon in the left -Item -{ - id: container - - property alias text: label.text - property alias source: icon.source - property alias color: label.color - property alias font: label.font - property alias iconSize: icon.width - - implicitHeight: icon.height - - UM.RecolorImage - { - id: icon - - anchors.left: parent.left - anchors.verticalCenter: parent.verticalCenter - - source: "" - width: UM.Theme.getSize("section_icon").width - height: width - - color: label.color - visible: source != "" - } - - Label - { - id: label - anchors.left: icon.visible ? icon.right : parent.left - anchors.right: parent.right - anchors.leftMargin: UM.Theme.getSize("thin_margin").width - anchors.verticalCenter: icon.verticalCenter - text: "Empty label" - elide: Text.ElideRight - color: UM.Theme.getColor("text") - font: UM.Theme.getFont("default") - renderType: Text.NativeRendering - } -} \ No newline at end of file diff --git a/resources/qml/IconWithText.qml b/resources/qml/IconWithText.qml index 22599b3aed..5530740040 100644 --- a/resources/qml/IconWithText.qml +++ b/resources/qml/IconWithText.qml @@ -13,9 +13,11 @@ import Cura 1.0 as Cura // It sets the icon size + half of the content as its minium width (in which case it will elide the text) Item { - property alias iconColor: icon.color property alias source: icon.source + property alias iconSize: icon.width + property alias color: label.color property alias text: label.text + property alias font: label.font property real margin: UM.Theme.getSize("narrow_margin").width @@ -37,7 +39,7 @@ Item width: UM.Theme.getSize("section_icon").width height: UM.Theme.getSize("section_icon").height - color: "black" + color: label.color anchors { diff --git a/resources/qml/PrintSetupSelector/PrintSetupSelectorHeader.qml b/resources/qml/PrintSetupSelector/PrintSetupSelectorHeader.qml index d4057289f6..518f3d49eb 100644 --- a/resources/qml/PrintSetupSelector/PrintSetupSelectorHeader.qml +++ b/resources/qml/PrintSetupSelector/PrintSetupSelectorHeader.qml @@ -43,7 +43,6 @@ RowLayout source: UM.Theme.getIcon("category_support") text: supportEnabled.properties.value == "True" ? enabledText : disabledText - UM.SettingPropertyProvider { id: supportEnabled diff --git a/resources/qml/qmldir b/resources/qml/qmldir index c19b982318..1dc21150ce 100644 --- a/resources/qml/qmldir +++ b/resources/qml/qmldir @@ -7,7 +7,6 @@ ActionButton 1.0 ActionButton.qml MaterialMenu 1.0 MaterialMenu.qml NozzleMenu 1.0 NozzleMenu.qml ActionPanelWidget 1.0 ActionPanelWidget.qml -IconLabel 1.0 IconLabel.qml IconWithText 1.0 IconWithText.qml OutputDevicesActionButton 1.0 OutputDevicesActionButton.qml ExpandableComponent 1.0 ExpandableComponent.qml From 1d33fe081fd30e257d9b0f5443288ad069b5f73c Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Fri, 7 Dec 2018 12:07:41 +0100 Subject: [PATCH 57/70] Clean up the code Remove all the references to the sidebar and use the term print_setup instead. Contributes to CURA-5941. --- .../PostProcessingPlugin.qml | 2 +- .../resources/qml/UM3InfoComponents.qml | 4 +- resources/qml/Cura.qml | 2 +- .../ConfigurationMenu/CustomConfiguration.qml | 4 +- resources/qml/MonitorButton.qml | 4 +- resources/qml/MonitorSidebar.qml | 2 +- resources/qml/ObjectsList.qml | 4 +- resources/qml/PrintMonitor.qml | 2 +- .../Custom/GlobalProfileSelector.qml | 2 +- ...debarTooltip.qml => PrintSetupTooltip.qml} | 0 resources/qml/SidebarContents.qml | 43 ------------------- resources/themes/cura-light/styles.qml | 6 +-- 12 files changed, 16 insertions(+), 59 deletions(-) rename resources/qml/{SidebarTooltip.qml => PrintSetupTooltip.qml} (100%) delete mode 100644 resources/qml/SidebarContents.qml diff --git a/plugins/PostProcessingPlugin/PostProcessingPlugin.qml b/plugins/PostProcessingPlugin/PostProcessingPlugin.qml index 3fa10c23b9..b962f4d53b 100644 --- a/plugins/PostProcessingPlugin/PostProcessingPlugin.qml +++ b/plugins/PostProcessingPlugin/PostProcessingPlugin.qml @@ -412,7 +412,7 @@ UM.Dialog } } - Cura.SidebarTooltip + Cura.PrintSetupTooltip { id: tooltip } diff --git a/plugins/UM3NetworkPrinting/resources/qml/UM3InfoComponents.qml b/plugins/UM3NetworkPrinting/resources/qml/UM3InfoComponents.qml index 105143c851..643c8164a7 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/UM3InfoComponents.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/UM3InfoComponents.qml @@ -29,7 +29,7 @@ Item { Button { height: UM.Theme.getSize("save_button_save_to_button").height; onClicked: Cura.MachineManager.printerOutputDevices[0].requestAuthentication(); - style: UM.Theme.styles.sidebar_action_button; + style: UM.Theme.styles.print_setup_action_button; text: catalog.i18nc("@action:button", "Request Access"); tooltip: catalog.i18nc("@info:tooltip", "Send access request to the printer"); visible: printerConnected && !printerAcceptsCommands && !authenticationRequested; @@ -38,7 +38,7 @@ Item { Button { height: UM.Theme.getSize("save_button_save_to_button").height; onClicked: connectActionDialog.show(); - style: UM.Theme.styles.sidebar_action_button; + style: UM.Theme.styles.print_setup_action_button; text: catalog.i18nc("@action:button", "Connect"); tooltip: catalog.i18nc("@info:tooltip", "Connect to a printer"); visible: !printerConnected; diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index 4e609ccbed..2df79d63c9 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -309,7 +309,7 @@ UM.MainWindow } } - SidebarTooltip + PrintSetupTooltip { id: tooltip } diff --git a/resources/qml/Menus/ConfigurationMenu/CustomConfiguration.qml b/resources/qml/Menus/ConfigurationMenu/CustomConfiguration.qml index ec9c5d0e38..78f6864c97 100644 --- a/resources/qml/Menus/ConfigurationMenu/CustomConfiguration.qml +++ b/resources/qml/Menus/ConfigurationMenu/CustomConfiguration.qml @@ -204,7 +204,7 @@ Item height: UM.Theme.getSize("setting_control").height width: selectors.controlWidth - style: UM.Theme.styles.sidebar_header_button + style: UM.Theme.styles.print_setup_header_button activeFocusOnPress: true menu: Cura.MaterialMenu { @@ -237,7 +237,7 @@ Item height: UM.Theme.getSize("setting_control").height width: selectors.controlWidth - style: UM.Theme.styles.sidebar_header_button + style: UM.Theme.styles.print_setup_header_button activeFocusOnPress: true; menu: Cura.NozzleMenu { extruderIndex: Cura.ExtruderManager.activeExtruderIndex } diff --git a/resources/qml/MonitorButton.qml b/resources/qml/MonitorButton.qml index eef76bcb09..fd7d2287c4 100644 --- a/resources/qml/MonitorButton.qml +++ b/resources/qml/MonitorButton.qml @@ -309,7 +309,7 @@ Item } } - style: UM.Theme.styles.sidebar_action_button + style: UM.Theme.styles.print_setup_action_button } Button @@ -325,7 +325,7 @@ Item text: catalog.i18nc("@label", "Abort Print") onClicked: confirmationDialog.visible = true - style: UM.Theme.styles.sidebar_action_button + style: UM.Theme.styles.print_setup_action_button } MessageDialog diff --git a/resources/qml/MonitorSidebar.qml b/resources/qml/MonitorSidebar.qml index 50416e34ab..669bdbfb8f 100644 --- a/resources/qml/MonitorSidebar.qml +++ b/resources/qml/MonitorSidebar.qml @@ -173,7 +173,7 @@ Rectangle anchors.bottom: parent.bottom } - SidebarTooltip + PrintSetupTooltip { id: tooltip } diff --git a/resources/qml/ObjectsList.qml b/resources/qml/ObjectsList.qml index 8f45b3744f..fd5175fce2 100644 --- a/resources/qml/ObjectsList.qml +++ b/resources/qml/ObjectsList.qml @@ -224,7 +224,7 @@ Rectangle { id: arrangeAllBuildPlatesButton; text: catalog.i18nc("@action:button","Arrange to all build plates"); - style: UM.Theme.styles.sidebar_action_button + style: UM.Theme.styles.print_setup_action_button height: UM.Theme.getSize("objects_menu_button").height; tooltip: ''; anchors @@ -244,7 +244,7 @@ Rectangle { id: arrangeBuildPlateButton; text: catalog.i18nc("@action:button","Arrange current build plate"); - style: UM.Theme.styles.sidebar_action_button + style: UM.Theme.styles.print_setup_action_button height: UM.Theme.getSize("objects_menu_button").height; tooltip: ''; anchors diff --git a/resources/qml/PrintMonitor.qml b/resources/qml/PrintMonitor.qml index 3cc161cbe7..4ed8daa55c 100644 --- a/resources/qml/PrintMonitor.qml +++ b/resources/qml/PrintMonitor.qml @@ -49,7 +49,7 @@ Rectangle property var activePrinter: connectedDevice != null ? connectedDevice.activePrinter : null property var activePrintJob: activePrinter != null ? activePrinter.activePrintJob: null - SidebarTooltip + PrintSetupTooltip { id: tooltip } diff --git a/resources/qml/PrintSetupSelector/Custom/GlobalProfileSelector.qml b/resources/qml/PrintSetupSelector/Custom/GlobalProfileSelector.qml index 11b2d3608b..8baaf9a7ae 100644 --- a/resources/qml/PrintSetupSelector/Custom/GlobalProfileSelector.qml +++ b/resources/qml/PrintSetupSelector/Custom/GlobalProfileSelector.qml @@ -43,7 +43,7 @@ Item right: parent.right } tooltip: Cura.MachineManager.activeQualityOrQualityChangesName - style: UM.Theme.styles.sidebar_header_button + style: UM.Theme.styles.print_setup_header_button activeFocusOnPress: true menu: Cura.ProfileMenu { } diff --git a/resources/qml/SidebarTooltip.qml b/resources/qml/PrintSetupTooltip.qml similarity index 100% rename from resources/qml/SidebarTooltip.qml rename to resources/qml/PrintSetupTooltip.qml diff --git a/resources/qml/SidebarContents.qml b/resources/qml/SidebarContents.qml deleted file mode 100644 index 0b19bfe3c1..0000000000 --- a/resources/qml/SidebarContents.qml +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) 2016 Ultimaker B.V. -// Cura is released under the terms of the LGPLv3 or higher. - -import QtQuick 2.7 -import QtQuick.Controls 1.1 -import QtQuick.Controls.Styles 1.1 -import QtQuick.Layouts 1.1 - -import UM 1.2 as UM -import Cura 1.0 as Cura - -StackView -{ - id: sidebarContents - - delegate: StackViewDelegate - { - function transitionFinished(properties) - { - properties.exitItem.opacity = 1 - } - - pushTransition: StackViewTransition - { - PropertyAnimation - { - target: enterItem - property: "opacity" - from: 0 - to: 1 - duration: 100 - } - PropertyAnimation - { - target: exitItem - property: "opacity" - from: 1 - to: 0 - duration: 100 - } - } - } -} \ No newline at end of file diff --git a/resources/themes/cura-light/styles.qml b/resources/themes/cura-light/styles.qml index 18fce7f319..bcc754f4ca 100755 --- a/resources/themes/cura-light/styles.qml +++ b/resources/themes/cura-light/styles.qml @@ -9,7 +9,7 @@ import UM 1.1 as UM QtObject { - property Component sidebar_header_button: Component + property Component print_setup_header_button: Component { ButtonStyle { @@ -80,7 +80,7 @@ QtObject } Label { - id: sidebarComboBoxLabel + id: printSetupComboBoxLabel color: control.enabled ? Theme.getColor("setting_control_text") : Theme.getColor("setting_control_disabled_text") text: control.text; elide: Text.ElideRight; @@ -644,7 +644,7 @@ QtObject } } - property Component sidebar_action_button: Component + property Component print_setup_action_button: Component { ButtonStyle { From dfe55b8f23b90fcdac812fc97a62e22bfcf6eea9 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 7 Dec 2018 12:59:51 +0100 Subject: [PATCH 58/70] Fix height of expandable component adapting to contents Since the children don't adjust their height based on if they are visible (which would cause a binding loop) we just need to adjust the height of the total menu based on which children are visible. Easy enough. Contributes to issue CURA-5876. --- .../Menus/ConfigurationMenu/ConfigurationMenu.qml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml b/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml index 9bef2ca0be..5780649423 100644 --- a/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml +++ b/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml @@ -139,7 +139,19 @@ Cura.ExpandableComponent Item { width: parent.width - height: childrenRect.height + height: + { + var height = 0; + if(autoConfiguration.visible) + { + height += autoConfiguration.height; + } + if(customConfiguration.visible) + { + height += customConfiguration.height; + } + return height; + } AutoConfiguration { id: autoConfiguration From 6a696a57f25e0ac41091320a9abb64a3ccce37c6 Mon Sep 17 00:00:00 2001 From: Aleksei S Date: Fri, 7 Dec 2018 13:01:49 +0100 Subject: [PATCH 59/70] Removed unused property --- resources/qml/JobSpecs.qml | 1 - 1 file changed, 1 deletion(-) diff --git a/resources/qml/JobSpecs.qml b/resources/qml/JobSpecs.qml index 8b06ab06db..c7f82b8876 100644 --- a/resources/qml/JobSpecs.qml +++ b/resources/qml/JobSpecs.qml @@ -80,7 +80,6 @@ Item height: UM.Theme.getSize("jobspecs_line").height width: Math.max(__contentWidth + UM.Theme.getSize("default_margin").width, 50) maximumLength: 120 - property int unremovableSpacing: 5 text: PrintInformation.jobName horizontalAlignment: TextInput.AlignLeft From 26be65e405f42ea806c10501a8c09793fe58a896 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Fri, 7 Dec 2018 13:29:16 +0100 Subject: [PATCH 60/70] Fix some other merge conflicts Contributes to CURA-6008. --- resources/qml/ExpandableComponent.qml | 3 +- resources/qml/ExpandablePopup.qml | 2 +- resources/qml/JobSpecs.qml | 1 - resources/themes/cura-light/theme.json | 81 ++++++++++++++------------ 4 files changed, 47 insertions(+), 40 deletions(-) diff --git a/resources/qml/ExpandableComponent.qml b/resources/qml/ExpandableComponent.qml index 3f30f8f386..3a03740251 100644 --- a/resources/qml/ExpandableComponent.qml +++ b/resources/qml/ExpandableComponent.qml @@ -109,10 +109,9 @@ Item } source: UM.Theme.getIcon("pencil") visible: source != "" && base.enabled -// color: UM.Theme.getColor("small_button_text") width: UM.Theme.getSize("standard_arrow").width height: UM.Theme.getSize("standard_arrow").height - color: UM.Theme.getColor("text") + color: UM.Theme.getColor("small_button_text") } MouseArea diff --git a/resources/qml/ExpandablePopup.qml b/resources/qml/ExpandablePopup.qml index a1e2fb0fea..c15310f803 100644 --- a/resources/qml/ExpandablePopup.qml +++ b/resources/qml/ExpandablePopup.qml @@ -131,7 +131,7 @@ Item visible: source != "" && base.enabled width: UM.Theme.getSize("standard_arrow").width height: UM.Theme.getSize("standard_arrow").height - color: UM.Theme.getColor("text") + color: UM.Theme.getColor("small_button_text") } MouseArea diff --git a/resources/qml/JobSpecs.qml b/resources/qml/JobSpecs.qml index 8b06ab06db..c7f82b8876 100644 --- a/resources/qml/JobSpecs.qml +++ b/resources/qml/JobSpecs.qml @@ -80,7 +80,6 @@ Item height: UM.Theme.getSize("jobspecs_line").height width: Math.max(__contentWidth + UM.Theme.getSize("default_margin").width, 50) maximumLength: 120 - property int unremovableSpacing: 5 text: PrintInformation.jobName horizontalAlignment: TextInput.AlignLeft diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index f96a785f11..16d13b9652 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -35,7 +35,7 @@ "family": "Noto Sans" }, "default_italic": { - "size": 1.15, + "size": 1.0, "weight": 50, "italic": true, "family": "Noto Sans" @@ -80,7 +80,7 @@ "primary_hover": [48, 182, 231, 255], "primary_text": [255, 255, 255, 255], "border": [127, 127, 127, 255], - "secondary": [240, 240, 240, 255], + "secondary": [245, 245, 245, 255], "secondary_shadow": [216, 216, 216, 255], "primary_button": [38, 113, 231, 255], @@ -178,34 +178,34 @@ "action_button_disabled_shadow": [228, 228, 228, 255], "scrollbar_background": [255, 255, 255, 255], - "scrollbar_handle": [31, 36, 39, 255], - "scrollbar_handle_hover": [12, 159, 227, 255], - "scrollbar_handle_down": [12, 159, 227, 255], + "scrollbar_handle": [10, 8, 80, 255], + "scrollbar_handle_hover": [50, 130, 255, 255], + "scrollbar_handle_down": [50, 130, 255, 255], "setting_category": [245, 245, 245, 255], "setting_category_disabled": [255, 255, 255, 255], - "setting_category_hover": [245, 245, 245, 255], + "setting_category_hover": [232, 242, 252, 255], "setting_category_active": [245, 245, 245, 255], - "setting_category_active_hover": [245, 245, 245, 255], - "setting_category_text": [31, 36, 39, 255], + "setting_category_active_hover": [232, 242, 252, 255], + "setting_category_text": [35, 35, 35, 255], "setting_category_disabled_text": [24, 41, 77, 101], - "setting_category_hover_text": [31, 36, 39, 255], - "setting_category_active_text": [31, 36, 39, 255], - "setting_category_active_hover_text": [31, 36, 39, 255], + "setting_category_hover_text": [35, 35, 35, 255], + "setting_category_active_text": [35, 35, 35, 255], + "setting_category_active_hover_text": [35, 35, 35, 255], "setting_category_border": [245, 245, 245, 255], "setting_category_disabled_border": [245, 245, 245, 255], - "setting_category_hover_border": [12, 159, 227, 255], - "setting_category_active_border": [245, 245, 245, 255], - "setting_category_active_hover_border": [12, 159, 227, 255], + "setting_category_hover_border": [50, 130, 255, 255], + "setting_category_active_border": [50, 130, 255, 255], + "setting_category_active_hover_border": [50, 130, 255, 255], "setting_control": [255, 255, 255, 255], "setting_control_selected": [31, 36, 39, 255], "setting_control_highlight": [255, 255, 255, 255], - "setting_control_border": [127, 127, 127, 255], + "setting_control_border": [199, 199, 199, 255], "setting_control_border_highlight": [50, 130, 255, 255], - "setting_control_text": [27, 27, 27, 255], - "setting_control_depth_line": [127, 127, 127, 255], - "setting_control_button": [127, 127, 127, 255], + "setting_control_text": [35, 35, 35, 255], + "setting_control_depth_line": [199, 199, 199, 255], + "setting_control_button": [199, 199, 199, 255], "setting_control_button_hover": [70, 84, 113, 255], "setting_control_disabled": [245, 245, 245, 255], "setting_control_disabled_text": [127, 127, 127, 255], @@ -216,6 +216,7 @@ "setting_validation_warning_background": [255, 145, 62, 255], "setting_validation_warning": [127, 127, 127, 255], "setting_validation_ok": [255, 255, 255, 255], + "setting_filter_field" : [153, 153, 153, 255], "material_compatibility_warning": [0, 0, 0, 255], @@ -233,11 +234,11 @@ "checkbox": [255, 255, 255, 255], "checkbox_hover": [255, 255, 255, 255], - "checkbox_border": [64, 69, 72, 255], + "checkbox_border": [199, 199, 199, 255], "checkbox_border_hover": [50, 130, 255, 255], - "checkbox_mark": [119, 122, 124, 255], + "checkbox_mark": [50, 130, 255, 255], "checkbox_disabled": [223, 223, 223, 255], - "checkbox_text": [27, 27, 27, 255], + "checkbox_text": [35, 35, 35, 255], "tooltip": [68, 192, 255, 255], "tooltip_text": [255, 255, 255, 255], @@ -293,16 +294,16 @@ "xray_error": [255, 0, 0, 255], "layerview_ghost": [32, 32, 32, 96], - "layerview_none": [255, 255, 255, 255], - "layerview_inset_0": [255, 0, 0, 255], - "layerview_inset_x": [0, 255, 0, 255], - "layerview_skin": [255, 255, 0, 255], - "layerview_support": [0, 255, 255, 255], - "layerview_skirt": [0, 255, 255, 255], - "layerview_infill": [255, 192, 0, 255], - "layerview_support_infill": [0, 255, 255, 255], - "layerview_move_combing": [0, 0, 255, 255], - "layerview_move_retraction": [128, 128, 255, 255], + "layerview_none": [255, 255, 255, 255], + "layerview_inset_0": [255, 0, 0, 255], + "layerview_inset_x": [0, 255, 0, 255], + "layerview_skin": [255, 255, 0, 255], + "layerview_support": [0, 255, 255, 255], + "layerview_skirt": [0, 255, 255, 255], + "layerview_infill": [255, 192, 0, 255], + "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_nozzle": [181, 166, 66, 50], @@ -356,10 +357,16 @@ "account_button": [12, 3], - "print_setup_widget": [30.0, 42.0], + "print_setup_widget": [38.0, 30.0], "print_setup_mode_toggle": [0.0, 2.0], "print_setup_item": [0.0, 2.0], "print_setup_extruder_box": [0.0, 6.0], + "print_setup_widget_header": [0.0, 3.0], + "print_setup_slider_groove": [0.16, 0.16], + "print_setup_slider_handle": [1.0, 1.0], + "print_setup_slider_tickmarks": [0.32, 0.32], + "print_setup_big_item": [28, 2.5], + "print_setup_icon": [1.2, 1.2], "configuration_selector_mode_tabs": [0.0, 3.0], @@ -391,12 +398,13 @@ "extruder_icon": [2.33, 2.33], - "section": [0.0, 2.2], + "section": [0.0, 2], "section_icon": [1.6, 1.6], "section_icon_column": [2.8, 0.0], "setting": [25.0, 1.8], - "setting_control": [10.0, 2.0], + "setting_control": [11.0, 2.0], + "setting_control_radius": [0.15, 0.15], "setting_control_depth_margin": [1.4, 0.0], "setting_preferences_button_margin": [4, 0.0], "setting_control_margin": [0.0, 0.0], @@ -404,7 +412,7 @@ "setting_text_maxwidth": [40.0, 0.0], "standard_list_lineheight": [1.5, 1.5], - "standard_arrow": [0.8, 0.8], + "standard_arrow": [1.0, 1.0], "button": [4, 4], "button_icon": [2.5, 2.5], @@ -444,7 +452,8 @@ "layerview_row": [11.0, 1.5], "layerview_row_spacing": [0.0, 0.5], - "checkbox": [2.0, 2.0], + "checkbox": [1.5, 1.5], + "checkbox_radius": [0.08, 0.08], "tooltip": [20.0, 10.0], "tooltip_margins": [1.0, 1.0], From e74258c26bd1917d87e5fd4bbb1f77719eb947f8 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 7 Dec 2018 13:39:42 +0100 Subject: [PATCH 61/70] Don't show materials if printer has no materials But if the printer does have other configurations to change, do show a placeholder text to indicate that the configuration can be selected here. This also simplifies a bit of code where it would need to call an updateEnabled() function, since it turns out that these properties in Cura.MachineManager have proper signals (contrary to what was previously used, the metadata entry stuff). Contributes to issue UCRA-5876. --- .../ConfigurationMenu/ConfigurationMenu.qml | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml b/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml index c282975cd3..33a317b42b 100644 --- a/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml +++ b/resources/qml/Menus/ConfigurationMenu/ConfigurationMenu.qml @@ -34,9 +34,11 @@ Cura.ExpandablePopup Custom } + enabled: Cura.MachineManager.hasMaterials || Cura.MachineManager.hasVariants || Cura.MachineManager.hasVariantBuildplates; //Only let it drop down if there is any configuration that you could change. + headerItem: Item { - // Horizontal list that shows the extruders + // Horizontal list that shows the extruders and their materials ListView { id: extrudersList @@ -44,7 +46,7 @@ Cura.ExpandablePopup orientation: ListView.Horizontal anchors.fill: parent model: extrudersModel - visible: base.enabled + visible: Cura.MachineManager.hasMaterials delegate: Item { @@ -101,24 +103,26 @@ Cura.ExpandablePopup } } } - } - //Disable the menu if there are no materials, variants or build plates to change. - function updateEnabled() - { - var active_definition_id = Cura.MachineManager.activeMachine.definition.id; - var has_materials = Cura.ContainerManager.getContainerMetaDataEntry(active_definition_id, "has_materials"); - var has_variants = Cura.ContainerManager.getContainerMetaDataEntry(active_definition_id, "has_variants"); - var has_buildplates = Cura.ContainerManager.getContainerMetaDataEntry(active_definition_id, "has_variant_buildplates"); - base.enabled = has_materials || has_variants || has_buildplates; //Only let it drop down if there is any configuration that you could change. - } + //Placeholder text if there is a configuration to select but no materials (so we can't show the materials per extruder). + Label + { + text: catalog.i18nc("@label", "Select configuration") + elide: Text.ElideRight + font: UM.Theme.getFont("default") + color: UM.Theme.getColor("text") + renderType: Text.NativeRendering - Connections - { - target: Cura.MachineManager - onGlobalContainerChanged: base.updateEnabled(); + visible: !Cura.MachineManager.hasMaterials && (Cura.MachineManager.hasVariants || Cura.MachineManager.hasVariantBuildplates) + + anchors + { + left: parent.left + leftMargin: UM.Theme.getSize("default_margin").width + verticalCenter: parent.verticalCenter + } + } } - Component.onCompleted: updateEnabled(); contentItem: Column { From 15f81da95b40e1cb27a73b9f13562bc6f525f296 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Fri, 7 Dec 2018 13:47:58 +0100 Subject: [PATCH 62/70] Do not show the layer height in the header panel when the profile is not supported --- cura/Settings/MachineManager.py | 4 ++++ .../PrintSetupSelectorHeader.qml | 14 +++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index a472cc7f09..c375ce01d1 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -1536,6 +1536,10 @@ class MachineManager(QObject): name = self._current_quality_group.name return name + @pyqtProperty(bool, notify = activeQualityGroupChanged) + def hasNotSupportedQuality(self) -> bool: + return self._current_quality_group is None and self._current_quality_changes_group is None + def _updateUponMaterialMetadataChange(self) -> None: if self._global_container_stack is None: return diff --git a/resources/qml/PrintSetupSelector/PrintSetupSelectorHeader.qml b/resources/qml/PrintSetupSelector/PrintSetupSelectorHeader.qml index 518f3d49eb..d4287045b8 100644 --- a/resources/qml/PrintSetupSelector/PrintSetupSelectorHeader.qml +++ b/resources/qml/PrintSetupSelector/PrintSetupSelectorHeader.qml @@ -13,7 +13,19 @@ RowLayout Cura.IconWithText { source: UM.Theme.getIcon("category_layer_height") - text: Cura.MachineManager.activeStack ? Cura.MachineManager.activeQualityOrQualityChangesName + " " + layerHeight.properties.value + "mm" : "" + text: + { + if (Cura.MachineManager.activeStack) + { + var text = Cura.MachineManager.activeQualityOrQualityChangesName + if (!Cura.MachineManager.hasNotSupportedQuality) + { + text += " " + layerHeight.properties.value + "mm" + } + return text + } + return "" + } UM.SettingPropertyProvider { From 43a06fdc3d85e618534297d967c560cdc9783c08 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 7 Dec 2018 13:49:17 +0100 Subject: [PATCH 63/70] Add more margin above printer type labels A bit of Gestalt. Contributes to issue CURA-5876. --- .../qml/Menus/ConfigurationMenu/ConfigurationListView.qml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/resources/qml/Menus/ConfigurationMenu/ConfigurationListView.qml b/resources/qml/Menus/ConfigurationMenu/ConfigurationListView.qml index e7936b69d2..53969a0370 100644 --- a/resources/qml/Menus/ConfigurationMenu/ConfigurationListView.qml +++ b/resources/qml/Menus/ConfigurationMenu/ConfigurationListView.qml @@ -64,11 +64,12 @@ Column section.criteria: ViewSection.FullString section.delegate: Item { - height: printerTypeLabel.height + UM.Theme.getSize("default_margin").height + height: printerTypeLabel.height + UM.Theme.getSize("default_margin").height * 2 //Causes a default margin above the label and a default margin below the label. Cura.PrinterTypeLabel { id: printerTypeLabel text: Cura.MachineManager.getAbbreviatedMachineName(section) + anchors.verticalCenter: parent.verticalCenter //One default margin above and one below. } } From 8e2c130416ecdf1adf21bc8d5388588442f6f6c7 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 7 Dec 2018 14:31:06 +0100 Subject: [PATCH 64/70] Use default lining style as separator for buildplate Normal colour, normal thickness. Contributes to issue CURA-5876. --- resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml b/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml index 6ac1e6a2ad..05cac16e29 100644 --- a/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml +++ b/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml @@ -72,8 +72,8 @@ Button right: parent.right rightMargin: parent.padding } - height: visible ? Math.round(UM.Theme.getSize("thick_lining").height / 2) : 0 - color: UM.Theme.getColor("text") + height: visible ? Math.round(UM.Theme.getSize("default_lining").height / 2) : 0 + color: UM.Theme.getColor("lining") } Item From c663681e66a42b63b1e831a1dbf967e6043f563b Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 7 Dec 2018 14:39:43 +0100 Subject: [PATCH 65/70] Simplify buildplate icon Removed all unnecessary crap added by Sketch. Contributes to issue CURA-5876. --- .../themes/cura-light/icons/buildplate.svg | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/resources/themes/cura-light/icons/buildplate.svg b/resources/themes/cura-light/icons/buildplate.svg index 9e61296958..d844b91a28 100644 --- a/resources/themes/cura-light/icons/buildplate.svg +++ b/resources/themes/cura-light/icons/buildplate.svg @@ -1,17 +1,9 @@ - - - icn_buildplate - Created with Sketch. - - - - - - - - - - + + + + + + \ No newline at end of file From 78df27369f1cc423fc3e369d22da6115fba43560 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 7 Dec 2018 14:41:30 +0100 Subject: [PATCH 66/70] Fill buildplate icon This is according to our newest designs. Contributes to issue CURA-5876. --- resources/themes/cura-light/icons/buildplate.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/themes/cura-light/icons/buildplate.svg b/resources/themes/cura-light/icons/buildplate.svg index d844b91a28..7505c8204e 100644 --- a/resources/themes/cura-light/icons/buildplate.svg +++ b/resources/themes/cura-light/icons/buildplate.svg @@ -4,6 +4,6 @@ - + \ No newline at end of file From ffcac04f9e1bb595bc30a33ba0d9aeb327b7c45d Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 7 Dec 2018 15:21:53 +0100 Subject: [PATCH 67/70] Add printer type selector if connected to cluster If there are 2 or more printer types in your connected cluster, you can switch the printer type here. Contributes to issue CURA-5876. --- .../ConfigurationMenu/CustomConfiguration.qml | 49 ++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/resources/qml/Menus/ConfigurationMenu/CustomConfiguration.qml b/resources/qml/Menus/ConfigurationMenu/CustomConfiguration.qml index 78f6864c97..8429e2c093 100644 --- a/resources/qml/Menus/ConfigurationMenu/CustomConfiguration.qml +++ b/resources/qml/Menus/ConfigurationMenu/CustomConfiguration.qml @@ -36,10 +36,57 @@ Item } } + //Printer type selector. + Item + { + id: printerTypeSelectorRow + visible: + { + return Cura.MachineManager.printerOutputDevices.length >= 1 //If connected... + && Cura.MachineManager.printerOutputDevices[0].connectedPrintersTypeCount != null //...and we have configuration information... + && Cura.MachineManager.printerOutputDevices[0].connectedPrintersTypeCount.length > 1; //...and there is more than one type of printer in the configuration list. + } + height: visible ? childrenRect.height : 0 + + anchors + { + left: parent.left + leftMargin: UM.Theme.getSize("default_margin").width + right: parent.right + rightMargin: UM.Theme.getSize("default_margin").width + top: header.bottom + topMargin: visible ? UM.Theme.getSize("default_margin").height : 0 + } + + Label + { + text: catalog.i18nc("@label", "Printer") + width: Math.round(parent.width * 0.3) - UM.Theme.getSize("default_margin").width + height: contentHeight + font: UM.Theme.getFont("default") + color: UM.Theme.getColor("text") + anchors.verticalCenter: printerTypeSelector.verticalCenter + anchors.left: parent.left + } + + OldControls.ToolButton + { + id: printerTypeSelector + text: Cura.MachineManager.activeMachineDefinitionName + tooltip: Cura.MachineManager.activeMachineDefinitionName + height: UM.Theme.getSize("setting_control").height + width: Math.round(parent.width * 0.7) + UM.Theme.getSize("default_margin").width + anchors.right: parent.right + style: UM.Theme.styles.print_setup_header_button + + menu: Cura.PrinterTypeMenu { } + } + } + UM.TabRow { id: tabBar - anchors.top: header.bottom + anchors.top: printerTypeSelectorRow.bottom anchors.topMargin: UM.Theme.getSize("default_margin").height visible: extrudersModel.count > 1 From 6a7bbe5bdb46c3f6db301097d30e472f3b45702e Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 7 Dec 2018 15:31:12 +0100 Subject: [PATCH 68/70] Fix hiding materials if material is empty Because the loaded material profile has the name 'Empty' then. Contributes to issue CURA-5876. --- .../qml/Menus/ConfigurationMenu/PrintCoreConfiguration.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/qml/Menus/ConfigurationMenu/PrintCoreConfiguration.qml b/resources/qml/Menus/ConfigurationMenu/PrintCoreConfiguration.qml index 885f02d740..a344e31d4f 100644 --- a/resources/qml/Menus/ConfigurationMenu/PrintCoreConfiguration.qml +++ b/resources/qml/Menus/ConfigurationMenu/PrintCoreConfiguration.qml @@ -20,7 +20,7 @@ Row { materialColor: printCoreConfiguration.material.color anchors.verticalCenter: parent.verticalCenter - extruderEnabled: printCoreConfiguration.material.name !== "" && printCoreConfiguration.hotendID !== "" + extruderEnabled: printCoreConfiguration.material.brand !== "" && printCoreConfiguration.hotendID !== "" } Column @@ -36,7 +36,7 @@ Row } Label { - text: printCoreConfiguration.material.name ? printCoreConfiguration.material.name : " " //Use space so that the height is still correct. + text: printCoreConfiguration.material.brand ? printCoreConfiguration.material.name : " " //Use space so that the height is still correct. renderType: Text.NativeRendering elide: Text.ElideRight font: UM.Theme.getFont("default") From b565b111c873dd3804f2ce50193c5836850c7fe9 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 7 Dec 2018 15:38:08 +0100 Subject: [PATCH 69/70] Adjust disabled extruder colour This also introduces a more global 'disabled' colour as defined by the style guide. I hope that we can gradually transition to this one, but we'll have to adjust some colours here and there. Contributes to issue CURA-5876. --- resources/qml/ExtruderIcon.qml | 2 +- resources/themes/cura-dark/theme.json | 1 + resources/themes/cura-light/theme.json | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/resources/qml/ExtruderIcon.qml b/resources/qml/ExtruderIcon.qml index 49ad73a32e..bb0b347b7e 100644 --- a/resources/qml/ExtruderIcon.qml +++ b/resources/qml/ExtruderIcon.qml @@ -23,7 +23,7 @@ Item anchors.fill: parent source: UM.Theme.getIcon("extruder_button") - color: extruderEnabled ? materialColor: "gray" + color: extruderEnabled ? materialColor: UM.Theme.getColor("disabled") } Rectangle diff --git a/resources/themes/cura-dark/theme.json b/resources/themes/cura-dark/theme.json index d9ef74ebb9..8540abf61a 100644 --- a/resources/themes/cura-dark/theme.json +++ b/resources/themes/cura-dark/theme.json @@ -35,6 +35,7 @@ "text_scene_hover": [255, 255, 255, 204], "error": [212, 31, 53, 255], + "disabled": [32, 32, 32, 255], "button": [39, 44, 48, 255], "button_hover": [39, 44, 48, 255], diff --git a/resources/themes/cura-light/theme.json b/resources/themes/cura-light/theme.json index 16d13b9652..d4fb59b7a1 100644 --- a/resources/themes/cura-light/theme.json +++ b/resources/themes/cura-light/theme.json @@ -129,6 +129,7 @@ "error": [255, 140, 0, 255], "warning": [245, 166, 35, 255], + "disabled": [229, 229, 229, 255], "toolbar_button_text": [8, 7, 63, 255], "toolbar_button_hover": [232, 242, 252, 255], From 9dc8450db0aa3ba21b969f787a29a6fe775058f2 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Fri, 7 Dec 2018 17:37:10 +0100 Subject: [PATCH 70/70] Fix typo --- .../Recommended/RecommendedQualityProfileSelector.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml index 4963f10792..15d40f545a 100644 --- a/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml +++ b/resources/qml/PrintSetupSelector/Recommended/RecommendedQualityProfileSelector.qml @@ -350,7 +350,7 @@ Item enabled: !Cura.SimpleModeSettingsManager.isProfileUserCreated onEntered: { - var tooltipContent = catalog.i18nc("@tooltip", "This quality profile is not available for you current material and nozzle configuration. Please change these to enable this quality profile") + var tooltipContent = catalog.i18nc("@tooltip", "This quality profile is not available for your current material and nozzle configuration. Please change these to enable this quality profile") base.showTooltip(qualityRow, Qt.point(-UM.Theme.getSize("thick_margin").width, customisedSettings.height), tooltipContent) } onExited: base.hideTooltip()