diff --git a/plugins/PerObjectSettingsTool/PerObjectCategory.qml b/plugins/PerObjectSettingsTool/PerObjectCategory.qml index 266e345309..99f0000393 100644 --- a/plugins/PerObjectSettingsTool/PerObjectCategory.qml +++ b/plugins/PerObjectSettingsTool/PerObjectCategory.qml @@ -4,11 +4,11 @@ import QtQuick 2.2 import QtQuick.Controls 2.1 -import UM 1.5 as UM -import Cura 1.0 as Cura +import Cura 1.5 as Cura import ".." -UM.CategoryButton { +Cura.CategoryButton +{ id: base; categoryIcon: definition ? UM.Theme.getIcon(definition.icon) : "" diff --git a/resources/qml/CategoryButton.qml b/resources/qml/CategoryButton.qml new file mode 100644 index 0000000000..dfd9625f6f --- /dev/null +++ b/resources/qml/CategoryButton.qml @@ -0,0 +1,121 @@ +// Copyright (c) 2022 Ultimaker B.V. +// Uranium is released under the terms of the LGPLv3 or higher. + +// Button used to collapse and de-collapse group, or a category, of settings +// the button contains +// - the title of the category, +// - an optional icon and +// - a chevron button to display the colapsetivity of the settings +// Mainly used for the collapsable categories in the settings pannel + +import QtQuick 2.2 +import QtQuick.Controls 2.1 + +import UM 1.5 as UM + +Button +{ + id: base + + height: enabled ? UM.Theme.getSize("section_header").height : 0 + + property var expanded: false + + property alias arrow: categoryArrow + property alias categoryIcon: icon.source + property alias labelText: categoryLabel.text + + states: + [ + State + { + name: "disabled" + when: !base.enabled + PropertyChanges { target: categoryLabel; color: UM.Theme.getColor("setting_category_disabled_text") } + PropertyChanges { target: icon; color: UM.Theme.getColor("setting_category_disabled_text") } + PropertyChanges { target: backgroundRectangle; color: UM.Theme.getColor("setting_category_disabled") } + }, + State + { + name: "hovered" + when: base.hovered + PropertyChanges { target: categoryLabel; color: UM.Theme.getColor("setting_category_active_text") } + PropertyChanges { target: icon; color: UM.Theme.getColor("setting_category_active_text") } + PropertyChanges { target: backgroundRectangle; color: UM.Theme.getColor("setting_category_hover") } + }, + State + { + name: "active" + when: base.pressed || base.activeFocus + PropertyChanges { target: categoryLabel; color: UM.Theme.getColor("setting_category_active_text") } + PropertyChanges { target: icon; color: UM.Theme.getColor("setting_category_active_text") } + PropertyChanges { target: backgroundRectangle; color: UM.Theme.getColor("setting_category") } + } + ] + + background: Rectangle + { + id: backgroundRectangle + height: base.height + + color: UM.Theme.getColor("setting_category") + Behavior on color { ColorAnimation { duration: 50 } } + + Rectangle + { + //Lining on top + anchors.top: parent.top + color: UM.Theme.getColor("border_main") + height: UM.Theme.getSize("default_lining").height + width: parent.width + } + } + + contentItem: Item + { + anchors.fill: parent + + UM.Label + { + id: categoryLabel + anchors + { + left: parent.left + leftMargin: UM.Theme.getSize("default_margin").width + UM.Theme.getSize("section_icon").width + right: parent.right + verticalCenter: parent.verticalCenter + } + textFormat: Text.PlainText + font: UM.Theme.getFont("medium_bold") + color: UM.Theme.getColor("setting_category_text") + fontSizeMode: Text.HorizontalFit + minimumPointSize: 8 + } + + UM.RecolorImage + { + id: categoryArrow + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + anchors.rightMargin: UM.Theme.getSize("narrow_margin").width + width: UM.Theme.getSize("standard_arrow").width + height: UM.Theme.getSize("standard_arrow").height + sourceSize.height: width + color: UM.Theme.getColor("setting_control_button") + source: expanded ? UM.Theme.getIcon("ChevronSingleDown") : UM.Theme.getIcon("ChevronSingleLeft") + } + } + + UM.RecolorImage + { + id: icon + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: UM.Theme.getSize("narrow_margin").width + color: UM.Theme.getColor("setting_category_text") + width: UM.Theme.getSize("section_icon").width + height: UM.Theme.getSize("section_icon").height + sourceSize.width: width + sourceSize.height: width + } +} \ No newline at end of file diff --git a/resources/qml/Preferences/SettingVisibilityCategory.qml b/resources/qml/Preferences/SettingVisibilityCategory.qml new file mode 100644 index 0000000000..f9ed989076 --- /dev/null +++ b/resources/qml/Preferences/SettingVisibilityCategory.qml @@ -0,0 +1,23 @@ +// Copyright (c) 2022 Ultimaker B.V. +// Uranium is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.2 +import QtQuick.Controls 2.1 + +import UM 1.5 as UM +import Cura 1.5 as Cura + +Cura.CategoryButton +{ + id: base + + categoryIcon: definition ? UM.Theme.getIcon(definition.icon) : "" + labelText: definition ? definition.label : "" + expanded: definition ? definition.expanded : false + + signal showTooltip(string text) + signal hideTooltip() + signal contextMenuRequested() + + onClicked: expanded ? settingDefinitionsModel.collapseRecursive(definition.key) : settingDefinitionsModel.expandRecursive(definition.key) +} diff --git a/resources/qml/Preferences/SettingVisibilityItem.qml b/resources/qml/Preferences/SettingVisibilityItem.qml new file mode 100644 index 0000000000..b7edd54c35 --- /dev/null +++ b/resources/qml/Preferences/SettingVisibilityItem.qml @@ -0,0 +1,99 @@ +// Copyright (c) 2022 Ultimaker B.V. +// Uranium is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.1 +import QtQuick.Controls 2.1 + +import UM 1.5 as UM + +Item +{ + // Use the depth of the model to move the item, but also leave space for the visibility / enabled exclamation mark. + + // Align checkbox with SettingVisibilityCategory icon with + 5 + x: definition ? definition.depth * UM.Theme.getSize("narrow_margin").width : UM.Theme.getSize("default_margin").width + + UM.TooltipArea + { + text: definition ? definition.description : "" + + width: childrenRect.width; + height: childrenRect.height; + id: checkboxTooltipArea + UM.CheckBox + { + id: check + + text: definition ? definition.label: "" + checked: definition ? definition.visible: false + enabled: definition ? !definition.prohibited: false + + MouseArea + { + anchors.fill: parent + onClicked: definitionsModel.setVisible(definition.key, !check.checked) + } + } + } + + UM.TooltipArea + { + width: height + height: check.height + anchors.left: checkboxTooltipArea.right + anchors.leftMargin: 2 * screenScaleFactor + + text: + { + if(provider.properties.enabled == "True") + { + return "" + } + var key = definition ? definition.key : "" + var requires = settingDefinitionsModel.getRequires(key, "enabled") + if (requires.length == 0) + { + return catalog.i18nc("@item:tooltip", "This setting has been hidden by the active machine and will not be visible."); + } + else + { + var requires_text = "" + for (var i in requires) + { + if (requires_text == "") + { + requires_text = requires[i].label + } + else + { + requires_text += ", " + requires[i].label + } + } + + return catalog.i18ncp("@item:tooltip %1 is list of setting names", "This setting has been hidden by the value of %1. Change the value of that setting to make this setting visible.", "This setting has been hidden by the values of %1. Change the values of those settings to make this setting visible.", requires.length) .arg(requires_text); + } + } + + UM.RecolorImage + { + anchors.centerIn: parent + width: Math.round(check.height * 0.75) | 0 + height: width + + source: UM.Theme.getIcon("Information") + + color: UM.Theme.getColor("primary_button_text") + } + + visible: provider.properties.enabled == "False" + } + + UM.SettingPropertyProvider + { + id: provider + + containerStackId: "global" + watchedProperties: [ "enabled" ] + key: definition ? definition.key : "" + } +} diff --git a/resources/qml/Preferences/SettingVisibilityPage.qml b/resources/qml/Preferences/SettingVisibilityPage.qml index b82b95e946..035f121537 100644 --- a/resources/qml/Preferences/SettingVisibilityPage.qml +++ b/resources/qml/Preferences/SettingVisibilityPage.qml @@ -163,6 +163,9 @@ UM.PreferencesPage visibilityHandler: UM.SettingPreferenceVisibilityHandler {} } + property Component settingVisibilityCategory: Cura.SettingVisibilityCategory {} + property Component settingVisibilityItem: Cura.SettingVisibilityItem {} + delegate: Loader { id: loader @@ -177,31 +180,15 @@ UM.PreferencesPage active: model.type != undefined sourceComponent: { - switch(model.type) + switch (model.type) { case "category": - return settingVisibilityCategory + return settingsListView.settingVisibilityCategory default: - return settingVisibilityItem + return settingsListView.settingVisibilityItem } } } } - - UM.I18nCatalog { name: "cura" } - - Component - { - id: settingVisibilityCategory; - - UM.SettingVisibilityCategory { } - } - - Component - { - id: settingVisibilityItem; - - UM.SettingVisibilityItem { } - } } } diff --git a/resources/qml/Settings/SettingCategory.qml b/resources/qml/Settings/SettingCategory.qml index 1c046232cb..0619017b2d 100644 --- a/resources/qml/Settings/SettingCategory.qml +++ b/resources/qml/Settings/SettingCategory.qml @@ -1,13 +1,13 @@ -// Copyright (c) 2018 Ultimaker B.V. +// Copyright (c) 2022 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.5 as UM -import Cura 1.0 as Cura +import Cura 1.5 as Cura -UM.CategoryButton +Cura.CategoryButton { id: base anchors.left: parent.left