From 829f8893e2d682d19d0c1739beab05d273631ee1 Mon Sep 17 00:00:00 2001 From: Victor Larchenko Date: Fri, 11 Nov 2016 13:28:00 +0600 Subject: [PATCH 01/12] T562: Added searching of settings # Conflicts: # resources/qml/Settings/SettingView.qml --- resources/qml/Settings/SettingView.qml | 452 +++++++++++++------------ 1 file changed, 241 insertions(+), 211 deletions(-) diff --git a/resources/qml/Settings/SettingView.qml b/resources/qml/Settings/SettingView.qml index c47abf3ee2..d47c06053c 100644 --- a/resources/qml/Settings/SettingView.qml +++ b/resources/qml/Settings/SettingView.qml @@ -9,229 +9,259 @@ import QtQuick.Layouts 1.1 import UM 1.2 as UM import Cura 1.0 as Cura -ScrollView +Item { id: base; - style: UM.Theme.styles.scrollview; - flickableItem.flickableDirection: Flickable.VerticalFlick; - property Action configureSettings; signal showTooltip(Item item, point location, string text); signal hideTooltip(); - ListView + TextField { - id: contents - spacing: UM.Theme.getSize("default_lining").height; - cacheBuffer: 1000000; // Set a large cache to effectively just cache every list item. + id: filter; + visible: !monitoringPrint - model: UM.SettingDefinitionsModel { - id: definitionsModel; - containerId: Cura.MachineManager.activeDefinitionId - visibilityHandler: UM.SettingPreferenceVisibilityHandler { } - exclude: ["machine_settings", "command_line_settings", "infill_mesh", "infill_mesh_order"] // 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: Printer.expandedCategories - onExpandedChanged: Printer.setExpandedCategories(expanded) - onVisibilityChanged: Cura.SettingInheritanceManager.forceUpdate() - } - - delegate: Loader + anchors { - id: delegate - - width: UM.Theme.getSize("sidebar").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 - Behavior on opacity { NumberAnimation { duration: 100 } } - enabled: - { - if(!ExtruderManager.activeExtruderStackId && ExtruderManager.extruderCount > 0) - { - // disable all controls on the global tab, except categories - return model.type == "category" - } - return provider.properties.enabled == "True" - } - - property var definition: model - property var settingDefinitionsModel: definitionsModel - property var propertyProvider: provider - property var globalPropertyProvider: inheritStackProvider - - //Qt5.4.2 and earlier has a bug where this causes a crash: https://bugreports.qt.io/browse/QTBUG-35989 - //In addition, while it works for 5.5 and higher, the ordering of the actual combo box drop down changes, - //causing nasty issues when selecting different options. So disable asynchronous loading of enum type completely. - asynchronous: model.type != "enum" && model.type != "extruder" - active: model.type != undefined - - source: - { - switch(model.type) - { - case "int": - return "SettingTextField.qml" - case "float": - return "SettingTextField.qml" - case "enum": - return "SettingComboBox.qml" - case "extruder": - return "SettingExtruder.qml" - case "bool": - return "SettingCheckBox.qml" - case "str": - return "SettingTextField.qml" - case "category": - return "SettingCategory.qml" - default: - return "SettingUnknown.qml" - } - } - - // Binding to ensure that the right containerstack ID is set for the provider. - // This ensures that if a setting has a limit_to_extruder id (for instance; Support speed points to the - // extruder that actually prints the support, as that is the setting we need to use to calculate the value) - Binding - { - target: provider - property: "containerStackId" - when: model.settable_per_extruder || (inheritStackProvider.properties.limit_to_extruder != null && inheritStackProvider.properties.limit_to_extruder >= 0); - value: - { - if(!model.settable_per_extruder || machineExtruderCount.properties.value == 1) - { - //Not settable per extruder or there only is global, so we must pick global. - return Cura.MachineManager.activeMachineId; - } - if(inheritStackProvider.properties.limit_to_extruder != null && inheritStackProvider.properties.limit_to_extruder >= 0) - { - //We have limit_to_extruder, so pick that stack. - return ExtruderManager.extruderIds[String(inheritStackProvider.properties.limit_to_extruder)]; - } - if(ExtruderManager.activeExtruderStackId) - { - //We're on an extruder tab. Pick the current extruder. - return ExtruderManager.activeExtruderStackId; - } - //No extruder tab is selected. Pick the global stack. Shouldn't happen any more since we removed the global tab. - return Cura.MachineManager.activeMachineId; - } - } - - // Specialty provider that only watches global_inherits (we cant filter on what property changed we get events - // so we bypass that to make a dedicated provider). - UM.SettingPropertyProvider - { - id: inheritStackProvider - containerStackId: Cura.MachineManager.activeMachineId - key: model.key - watchedProperties: [ "limit_to_extruder" ] - } - - UM.SettingPropertyProvider - { - id: provider - - containerStackId: Cura.MachineManager.activeMachineId - key: model.key ? model.key : "" - watchedProperties: [ "value", "enabled", "state", "validationState", "settable_per_extruder", "resolve" ] - storeIndex: 0 - // Due to the way setPropertyValue works, removeUnusedValue gives the correct output in case of resolve - removeUnusedValue: model.resolve == undefined - } - - Connections - { - target: item - onContextMenuRequested: - { - contextMenu.key = model.key; - contextMenu.provider = provider - contextMenu.popup(); - } - onShowTooltip: base.showTooltip(delegate, { x: 0, y: delegate.height / 2 }, text) - onHideTooltip: base.hideTooltip() - onShowAllHiddenInheritedSettings: - { - var children_with_override = Cura.SettingInheritanceManager.getChildrenKeysWithOverride(category_id) - for(var i = 0; i < children_with_override.length; i++) - { - definitionsModel.setVisible(children_with_override[i], true) - } - Cura.SettingInheritanceManager.manualRemoveOverride(category_id) - } - } + top: parent.top + left: parent.left + leftMargin: UM.Theme.getSize("default_margin").width + //right: parent.right } - UM.I18nCatalog { id: catalog; name: "uranium"; } + placeholderText: catalog.i18nc("@label:textbox", "Filter...") - add: Transition { - SequentialAnimation { - NumberAnimation { properties: "height"; from: 0; duration: 100 } - NumberAnimation { properties: "opacity"; from: 0; duration: 100 } - } - } - remove: Transition { - SequentialAnimation { - NumberAnimation { properties: "opacity"; to: 0; duration: 100 } - NumberAnimation { properties: "height"; to: 0; duration: 100 } - } - } - addDisplaced: Transition { - NumberAnimation { properties: "x,y"; duration: 100 } - } - removeDisplaced: Transition { - SequentialAnimation { - PauseAnimation { duration: 100; } - NumberAnimation { properties: "x,y"; duration: 100 } - } - } - - Menu - { - id: contextMenu - - property string key - property var provider - - MenuItem - { - //: Settings context menu action - text: catalog.i18nc("@action:menu", "Copy value to all extruders") - visible: machineExtruderCount.properties.value > 1 - enabled: contextMenu.provider != undefined && contextMenu.provider.properties.settable_per_extruder != "False" - onTriggered: Cura.MachineManager.copyValueToExtruders(contextMenu.key) - } - - MenuSeparator - { - visible: machineExtruderCount.properties.value > 1 - } - - MenuItem - { - //: Settings context menu action - text: catalog.i18nc("@action:menu", "Hide this setting"); - onTriggered: definitionsModel.hide(contextMenu.key); - } - MenuItem - { - //: Settings context menu action - text: catalog.i18nc("@action:menu", "Configure setting visiblity..."); - - onTriggered: Cura.Actions.configureSettingVisibility.trigger(contextMenu); - } - } - - UM.SettingPropertyProvider - { - id: machineExtruderCount - - containerStackId: Cura.MachineManager.activeMachineId - key: "machine_extruder_count" - watchedProperties: [ "value" ] - storeIndex: 0 + onTextChanged: { + definitionsModel.filter = {"label": "*" + text}; + definitionsModel.expanded = text.length > 0 ? ["*"] : [""] } } -} + + ScrollView + { + anchors.top: filter.bottom; + anchors.bottom: parent.bottom; + anchors.right: parent.right; + anchors.left: parent.left; + anchors.topMargin: UM.Theme.getSize("default_margin").width + + style: UM.Theme.styles.scrollview; + flickableItem.flickableDirection: Flickable.VerticalFlick; + + ListView + { + id: contents + spacing: UM.Theme.getSize("default_lining").height; + cacheBuffer: 1000000; // Set a large cache to effectively just cache every list item. + + model: UM.SettingDefinitionsModel { + id: definitionsModel; + containerId: Cura.MachineManager.activeDefinitionId + visibilityHandler: UM.SettingPreferenceVisibilityHandler { } + exclude: ["machine_settings", "command_line_settings", "infill_mesh", "infill_mesh_order"] // 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: Printer.expandedCategories + onExpandedChanged: Printer.setExpandedCategories(expanded) + onVisibilityChanged: Cura.SettingInheritanceManager.forceUpdate() + } + + delegate: Loader + { + id: delegate + + width: UM.Theme.getSize("sidebar").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 + Behavior on opacity { NumberAnimation { duration: 100 } } + enabled: + { + if(!ExtruderManager.activeExtruderStackId && ExtruderManager.extruderCount > 0) + { + // disable all controls on the global tab, except categories + return model.type == "category" + } + return provider.properties.enabled == "True" + } + + property var definition: model + property var settingDefinitionsModel: definitionsModel + property var propertyProvider: provider + property var globalPropertyProvider: inheritStackProvider + + //Qt5.4.2 and earlier has a bug where this causes a crash: https://bugreports.qt.io/browse/QTBUG-35989 + //In addition, while it works for 5.5 and higher, the ordering of the actual combo box drop down changes, + //causing nasty issues when selecting different options. So disable asynchronous loading of enum type completely. + asynchronous: model.type != "enum" && model.type != "extruder" + active: model.type != undefined + + source: + { + switch(model.type) + { + case "int": + return "SettingTextField.qml" + case "float": + return "SettingTextField.qml" + case "enum": + return "SettingComboBox.qml" + case "extruder": + return "SettingExtruder.qml" + case "bool": + return "SettingCheckBox.qml" + case "str": + return "SettingTextField.qml" + case "category": + return "SettingCategory.qml" + default: + return "SettingUnknown.qml" + } + } + + // Binding to ensure that the right containerstack ID is set for the provider. + // This ensures that if a setting has a limit_to_extruder id (for instance; Support speed points to the + // extruder that actually prints the support, as that is the setting we need to use to calculate the value) + Binding + { + target: provider + property: "containerStackId" + when: model.settable_per_extruder || (inheritStackProvider.properties.limit_to_extruder != null && inheritStackProvider.properties.limit_to_extruder >= 0); + value: + { + if(!model.settable_per_extruder || machineExtruderCount.properties.value == 1) + { + //Not settable per extruder or there only is global, so we must pick global. + return Cura.MachineManager.activeMachineId; + } + if(inheritStackProvider.properties.limit_to_extruder != null && inheritStackProvider.properties.limit_to_extruder >= 0) + { + //We have limit_to_extruder, so pick that stack. + return ExtruderManager.extruderIds[String(inheritStackProvider.properties.limit_to_extruder)]; + } + if(ExtruderManager.activeExtruderStackId) + { + //We're on an extruder tab. Pick the current extruder. + return ExtruderManager.activeExtruderStackId; + } + //No extruder tab is selected. Pick the global stack. Shouldn't happen any more since we removed the global tab. + return Cura.MachineManager.activeMachineId; + } + } + + // Specialty provider that only watches global_inherits (we cant filter on what property changed we get events + // so we bypass that to make a dedicated provider). + UM.SettingPropertyProvider + { + id: inheritStackProvider + containerStackId: Cura.MachineManager.activeMachineId + key: model.key + watchedProperties: [ "limit_to_extruder" ] + } + + UM.SettingPropertyProvider + { + id: provider + + containerStackId: Cura.MachineManager.activeMachineId + key: model.key ? model.key : "" + watchedProperties: [ "value", "enabled", "state", "validationState", "settable_per_extruder", "resolve" ] + storeIndex: 0 + // Due to the way setPropertyValue works, removeUnusedValue gives the correct output in case of resolve + removeUnusedValue: model.resolve == undefined + } + + Connections + { + target: item + onContextMenuRequested: + { + contextMenu.key = model.key; + contextMenu.provider = provider + contextMenu.popup(); + } + onShowTooltip: base.showTooltip(delegate, { x: 0, y: delegate.height / 2 }, text) + onHideTooltip: base.hideTooltip() + onShowAllHiddenInheritedSettings: + { + var children_with_override = Cura.SettingInheritanceManager.getChildrenKeysWithOverride(category_id) + for(var i = 0; i < children_with_override.length; i++) + { + definitionsModel.setVisible(children_with_override[i], true) + } + Cura.SettingInheritanceManager.manualRemoveOverride(category_id) + } + } + } + + UM.I18nCatalog { id: catalog; name: "uranium"; } + + add: Transition { + SequentialAnimation { + NumberAnimation { properties: "height"; from: 0; duration: 100 } + NumberAnimation { properties: "opacity"; from: 0; duration: 100 } + } + } + remove: Transition { + SequentialAnimation { + NumberAnimation { properties: "opacity"; to: 0; duration: 100 } + NumberAnimation { properties: "height"; to: 0; duration: 100 } + } + } + addDisplaced: Transition { + NumberAnimation { properties: "x,y"; duration: 100 } + } + removeDisplaced: Transition { + SequentialAnimation { + PauseAnimation { duration: 100; } + NumberAnimation { properties: "x,y"; duration: 100 } + } + } + + Menu + { + id: contextMenu + + property string key + property var provider + + MenuItem + { + //: Settings context menu action + text: catalog.i18nc("@action:menu", "Copy value to all extruders") + visible: machineExtruderCount.properties.value > 1 + enabled: contextMenu.provider != undefined && contextMenu.provider.properties.settable_per_extruder != "False" + onTriggered: Cura.MachineManager.copyValueToExtruders(contextMenu.key) + } + + MenuSeparator + { + visible: machineExtruderCount.properties.value > 1 + } + + MenuItem + { + //: Settings context menu action + text: catalog.i18nc("@action:menu", "Hide this setting"); + onTriggered: definitionsModel.hide(contextMenu.key); + } + MenuItem + { + //: Settings context menu action + text: catalog.i18nc("@action:menu", "Configure setting visiblity..."); + + onTriggered: Cura.Actions.configureSettingVisibility.trigger(contextMenu); + } + } + + UM.SettingPropertyProvider + { + id: machineExtruderCount + + containerStackId: Cura.MachineManager.activeMachineId + key: "machine_extruder_count" + watchedProperties: [ "value" ] + storeIndex: 0 + } + } + } +} \ No newline at end of file From f7854225fa232d592f23a40cb259122d8f9211bc Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Mon, 14 Nov 2016 10:21:15 +0100 Subject: [PATCH 02/12] Restore expanded categories when clearing filter --- resources/qml/Settings/SettingView.qml | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/resources/qml/Settings/SettingView.qml b/resources/qml/Settings/SettingView.qml index d47c06053c..3c94d87034 100644 --- a/resources/qml/Settings/SettingView.qml +++ b/resources/qml/Settings/SettingView.qml @@ -32,9 +32,25 @@ Item placeholderText: catalog.i18nc("@label:textbox", "Filter...") + property var expandedCategories + property bool lastFilterEmpty: true + onTextChanged: { definitionsModel.filter = {"label": "*" + text}; - definitionsModel.expanded = text.length > 0 ? ["*"] : [""] + var _filterEmpty = (text.length == 0); + if(_filterEmpty != lastFilterEmpty) + { + if(!_filterEmpty) + { + expandedCategories = definitionsModel.expanded.slice(); + definitionsModel.expanded = ["*"]; + } + else + { + definitionsModel.expanded = expandedCategories; + } + lastFilterEmpty = _filterEmpty; + } } } @@ -55,7 +71,8 @@ Item spacing: UM.Theme.getSize("default_lining").height; cacheBuffer: 1000000; // Set a large cache to effectively just cache every list item. - model: UM.SettingDefinitionsModel { + model: UM.SettingDefinitionsModel + { id: definitionsModel; containerId: Cura.MachineManager.activeDefinitionId visibilityHandler: UM.SettingPreferenceVisibilityHandler { } From 479056efef2cbd0b39ad49e86aa400e0fa1d0ec0 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Mon, 14 Nov 2016 10:34:55 +0100 Subject: [PATCH 03/12] Always show categories when filtering --- resources/qml/Settings/SettingView.qml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/resources/qml/Settings/SettingView.qml b/resources/qml/Settings/SettingView.qml index 3c94d87034..fc7563399e 100644 --- a/resources/qml/Settings/SettingView.qml +++ b/resources/qml/Settings/SettingView.qml @@ -44,10 +44,12 @@ Item { expandedCategories = definitionsModel.expanded.slice(); definitionsModel.expanded = ["*"]; + definitionsModel.showAncestors = true } else { definitionsModel.expanded = expandedCategories; + definitionsModel.showAncestors = false } lastFilterEmpty = _filterEmpty; } From e450d10ddb13fe7842bb7214bb521345df943676 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Mon, 14 Nov 2016 11:57:49 +0100 Subject: [PATCH 04/12] Apply styling to filter field --- resources/qml/Settings/SettingView.qml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/resources/qml/Settings/SettingView.qml b/resources/qml/Settings/SettingView.qml index fc7563399e..bc50e63b5d 100644 --- a/resources/qml/Settings/SettingView.qml +++ b/resources/qml/Settings/SettingView.qml @@ -32,6 +32,19 @@ Item placeholderText: catalog.i18nc("@label:textbox", "Filter...") + style: TextFieldStyle + { + textColor: UM.Theme.getColor("setting_control_text"); + font: UM.Theme.getFont("default"); + background: Rectangle + { + border.width: UM.Theme.getSize("default_lining").width + border.color: control.hovered ? UM.Theme.getColor("setting_control_border_highlight") : UM.Theme.getColor("setting_control_border") + + color: UM.Theme.getColor("setting_control") + } + } + property var expandedCategories property bool lastFilterEmpty: true From b63f4e0bee831eee5f3f9019215ec725612b961e Mon Sep 17 00:00:00 2001 From: Victor Larchenko Date: Mon, 14 Nov 2016 13:36:07 +0600 Subject: [PATCH 05/12] T562: Text box expanded and all settings visible while filtering # Conflicts: # resources/qml/Settings/SettingView.qml --- resources/qml/Settings/SettingView.qml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/resources/qml/Settings/SettingView.qml b/resources/qml/Settings/SettingView.qml index bc50e63b5d..96fcb6513b 100644 --- a/resources/qml/Settings/SettingView.qml +++ b/resources/qml/Settings/SettingView.qml @@ -27,7 +27,8 @@ Item top: parent.top left: parent.left leftMargin: UM.Theme.getSize("default_margin").width - //right: parent.right + right: parent.right + rightMargin: UM.Theme.getSize("default_margin").width } placeholderText: catalog.i18nc("@label:textbox", "Filter...") @@ -57,12 +58,14 @@ Item { expandedCategories = definitionsModel.expanded.slice(); definitionsModel.expanded = ["*"]; - definitionsModel.showAncestors = true + definitionsModel.showAncestors = true; + definitionsModel.showAll = true; } else { definitionsModel.expanded = expandedCategories; - definitionsModel.showAncestors = false + definitionsModel.showAncestors = false; + definitionsModel.showAll = false; } lastFilterEmpty = _filterEmpty; } From 7fafcef40b3f3b9f371d60f27d87910294b47730 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Tue, 15 Nov 2016 11:09:58 +0100 Subject: [PATCH 06/12] Allow making settings visible from the sidebar --- resources/qml/Settings/SettingItem.qml | 1 + resources/qml/Settings/SettingView.qml | 41 ++++++++++++++++++++++---- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/resources/qml/Settings/SettingItem.qml b/resources/qml/Settings/SettingItem.qml index 7fa2856e27..c32247e925 100644 --- a/resources/qml/Settings/SettingItem.qml +++ b/resources/qml/Settings/SettingItem.qml @@ -117,6 +117,7 @@ Item { elide: Text.ElideMiddle; 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") } diff --git a/resources/qml/Settings/SettingView.qml b/resources/qml/Settings/SettingView.qml index 96fcb6513b..0058b6d359 100644 --- a/resources/qml/Settings/SettingView.qml +++ b/resources/qml/Settings/SettingView.qml @@ -14,6 +14,7 @@ Item id: base; property Action configureSettings; + property bool findingSettings; signal showTooltip(Item item, point location, string text); signal hideTooltip(); @@ -47,14 +48,14 @@ Item } property var expandedCategories - property bool lastFilterEmpty: true + property bool lastFindingSettings: false onTextChanged: { definitionsModel.filter = {"label": "*" + text}; - var _filterEmpty = (text.length == 0); - if(_filterEmpty != lastFilterEmpty) + findingSettings = (text.length > 0); + if(findingSettings != lastFindingSettings) { - if(!_filterEmpty) + if(findingSettings) { expandedCategories = definitionsModel.expanded.slice(); definitionsModel.expanded = ["*"]; @@ -67,7 +68,7 @@ Item definitionsModel.showAncestors = false; definitionsModel.showAll = false; } - lastFilterEmpty = _filterEmpty; + lastFindingSettings = findingSettings; } } } @@ -211,6 +212,7 @@ Item onContextMenuRequested: { contextMenu.key = model.key; + contextMenu.settingVisible = model.visible; contextMenu.provider = provider contextMenu.popup(); } @@ -258,6 +260,7 @@ Item property string key property var provider + property bool settingVisible MenuItem { @@ -276,10 +279,38 @@ Item MenuItem { //: Settings context menu action + visible: !findingSettings; text: catalog.i18nc("@action:menu", "Hide this setting"); onTriggered: definitionsModel.hide(contextMenu.key); } MenuItem + { + //: Settings context menu action + text: + { + if (contextMenu.settingVisible) + { + return catalog.i18nc("@action:menu", "Don't show this setting"); + } + else + { + return catalog.i18nc("@action:menu", "Keep this setting visible"); + } + } + visible: findingSettings; + onTriggered: + { + if (contextMenu.settingVisible) + { + definitionsModel.hide(contextMenu.key); + } + else + { + definitionsModel.show(contextMenu.key); + } + } + } + MenuItem { //: Settings context menu action text: catalog.i18nc("@action:menu", "Configure setting visiblity..."); From 1c92b9ee0e9ed29a5add6f61ec42bd9b5c052c99 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Tue, 15 Nov 2016 16:25:39 +0100 Subject: [PATCH 07/12] Don't update expandedCategories preference while filtering settings --- resources/qml/Settings/SettingView.qml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/resources/qml/Settings/SettingView.qml b/resources/qml/Settings/SettingView.qml index 0058b6d359..146049d814 100644 --- a/resources/qml/Settings/SettingView.qml +++ b/resources/qml/Settings/SettingView.qml @@ -97,7 +97,15 @@ Item visibilityHandler: UM.SettingPreferenceVisibilityHandler { } exclude: ["machine_settings", "command_line_settings", "infill_mesh", "infill_mesh_order"] // 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: Printer.expandedCategories - onExpandedChanged: Printer.setExpandedCategories(expanded) + onExpandedChanged: + { + if(!findingSettings) + { + // Do not change expandedCategories preference while filtering settings + // because all categories are expanded while filtering + Printer.setExpandedCategories(expanded) + } + } onVisibilityChanged: Cura.SettingInheritanceManager.forceUpdate() } From 3da5e9de4e34ad39d5ad6d970888012e7ccd7b39 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Wed, 16 Nov 2016 23:21:20 +0100 Subject: [PATCH 08/12] Add a "clear filter" button --- resources/qml/Settings/SettingView.qml | 125 ++++++++++++++++++------- 1 file changed, 91 insertions(+), 34 deletions(-) diff --git a/resources/qml/Settings/SettingView.qml b/resources/qml/Settings/SettingView.qml index 146049d814..70fd08b4bf 100644 --- a/resources/qml/Settings/SettingView.qml +++ b/resources/qml/Settings/SettingView.qml @@ -18,10 +18,24 @@ Item signal showTooltip(Item item, point location, string text); signal hideTooltip(); - TextField + Rectangle { - id: filter; - visible: !monitoringPrint + id: filterContainer + + border.width: UM.Theme.getSize("default_lining").width + border.color: + { + if(mouseArea.containsMouse || clearFilterButton.containsMouse) + { + return UM.Theme.getColor("setting_control_border_highlight"); + } + else + { + return UM.Theme.getColor("setting_control_border"); + } + } + + color: UM.Theme.getColor("setting_control") anchors { @@ -31,51 +45,94 @@ Item right: parent.right rightMargin: UM.Theme.getSize("default_margin").width } + height: UM.Theme.getSize("setting_control").height - placeholderText: catalog.i18nc("@label:textbox", "Filter...") - - style: TextFieldStyle + TextField { - textColor: UM.Theme.getColor("setting_control_text"); - font: UM.Theme.getFont("default"); - background: Rectangle - { - border.width: UM.Theme.getSize("default_lining").width - border.color: control.hovered ? UM.Theme.getColor("setting_control_border_highlight") : UM.Theme.getColor("setting_control_border") + id: filter; + visible: !monitoringPrint - color: UM.Theme.getColor("setting_control") + anchors.left: parent.left + anchors.right: clearFilterButton.left + anchors.rightMargin: UM.Theme.getSize("default_margin").width + + placeholderText: catalog.i18nc("@label:textbox", "Filter...") + + style: TextFieldStyle + { + textColor: UM.Theme.getColor("setting_control_text"); + font: UM.Theme.getFont("default"); + background: Item {} + } + + property var expandedCategories + property bool lastFindingSettings: false + + onTextChanged: + { + definitionsModel.filter = {"label": "*" + text}; + findingSettings = (text.length > 0); + if(findingSettings != lastFindingSettings) + { + if(findingSettings) + { + expandedCategories = definitionsModel.expanded.slice(); + definitionsModel.expanded = ["*"]; + definitionsModel.showAncestors = true; + definitionsModel.showAll = true; + } + else + { + definitionsModel.expanded = expandedCategories; + definitionsModel.showAncestors = false; + definitionsModel.showAll = false; + } + lastFindingSettings = findingSettings; + } + } + + Keys.onEscapePressed: + { + filter.text = ""; } } - property var expandedCategories - property bool lastFindingSettings: false + MouseArea + { + id: mouseArea + anchors.fill: parent + hoverEnabled: true + acceptedButtons: Qt.NoButton + cursorShape: Qt.IBeamCursor + } - onTextChanged: { - definitionsModel.filter = {"label": "*" + text}; - findingSettings = (text.length > 0); - if(findingSettings != lastFindingSettings) + UM.SimpleButton + { + id: clearFilterButton + iconSource: UM.Theme.getIcon("cross1") + visible: findingSettings + + height: parent.height * 0.4 + width: visible ? height : 0 + + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.right + anchors.rightMargin: UM.Theme.getSize("default_margin").width + + color: UM.Theme.getColor("setting_control_button") + hoverColor: UM.Theme.getColor("setting_control_button_hover") + + onClicked: { - if(findingSettings) - { - expandedCategories = definitionsModel.expanded.slice(); - definitionsModel.expanded = ["*"]; - definitionsModel.showAncestors = true; - definitionsModel.showAll = true; - } - else - { - definitionsModel.expanded = expandedCategories; - definitionsModel.showAncestors = false; - definitionsModel.showAll = false; - } - lastFindingSettings = findingSettings; + filter.text = ""; + filter.setActiveFocus(); } } } ScrollView { - anchors.top: filter.bottom; + anchors.top: filterContainer.bottom; anchors.bottom: parent.bottom; anchors.right: parent.right; anchors.left: parent.left; From 7e4f1dce7bf030e4118cd29fefa1854c3e2a859b Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Mon, 21 Nov 2016 23:29:18 +0100 Subject: [PATCH 09/12] Add button for toggling the find settings textbox The toggle is only shown when advanced mode is selected. --- resources/qml/Sidebar.qml | 38 +++++++++++++++++++++++++- resources/themes/cura/icons/search.svg | 4 +++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 resources/themes/cura/icons/search.svg diff --git a/resources/qml/Sidebar.qml b/resources/qml/Sidebar.qml index 1c1eb5e5a0..a74b684213 100644 --- a/resources/qml/Sidebar.qml +++ b/resources/qml/Sidebar.qml @@ -214,7 +214,7 @@ Rectangle anchors.left: parent.left anchors.leftMargin: model.index * (settingsModeSelection.width / 2) anchors.verticalCenter: parent.verticalCenter - width: parent.width / 2 + width: 0.5 * parent.width - (index == 1 ? toggleFilterButton.width : 0) text: model.text exclusiveGroup: modeMenuGroup; checkable: true; @@ -256,6 +256,42 @@ Rectangle } } + Button + { + id: toggleFilterButton + + anchors.right: parent.right + anchors.rightMargin: UM.Theme.getSize("default_margin").width + anchors.top: headerSeparator.bottom + anchors.topMargin: UM.Theme.getSize("default_margin").height + + height: settingsModeSelection.height + width: visible ? height : 0 + + visible: !monitoringPrint && base.currentModeIndex == 1 + opacity: visible ? 1 : 0 + + style: ButtonStyle + { + background: Rectangle + { + border.width: UM.Theme.getSize("default_lining").width + border.color: UM.Theme.getColor("toggle_checked_border") + color: visible ? UM.Theme.getColor("toggle_checked") : UM.Theme.getColor("toggle_hovered") + Behavior on color { ColorAnimation { duration: 50; } } + } + label: UM.RecolorImage + { + anchors.verticalCenter: control.verticalCenter + anchors.right: parent.right + anchors.rightMargin: UM.Theme.getSize("default_margin").width / 2 + + source: UM.Theme.getIcon("search") + color: UM.Theme.getColor("toggle_checked_text") + } + } + } + Label { id: monitorLabel text: catalog.i18nc("@label","Printer Monitor"); diff --git a/resources/themes/cura/icons/search.svg b/resources/themes/cura/icons/search.svg new file mode 100644 index 0000000000..8272991300 --- /dev/null +++ b/resources/themes/cura/icons/search.svg @@ -0,0 +1,4 @@ + + + From 933ed5177fec4a900e2813444ab40bf1a26099b5 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Tue, 22 Nov 2016 13:44:41 +0100 Subject: [PATCH 10/12] Toggle visibility of filter field when pressing the "search" icon --- resources/qml/Settings/SettingView.qml | 22 +++++++++++++++++++--- resources/qml/Sidebar.qml | 10 ++++++---- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/resources/qml/Settings/SettingView.qml b/resources/qml/Settings/SettingView.qml index 70fd08b4bf..c3da68bf79 100644 --- a/resources/qml/Settings/SettingView.qml +++ b/resources/qml/Settings/SettingView.qml @@ -18,9 +18,23 @@ Item signal showTooltip(Item item, point location, string text); signal hideTooltip(); + function toggleFilterField() + { + filterContainer.visible = !filterContainer.visible + if(filterContainer.visible) + { + filter.forceActiveFocus(); + } + else + { + filter.text = ""; + } + } + Rectangle { id: filterContainer + visible: false border.width: UM.Theme.getSize("default_lining").width border.color: @@ -45,7 +59,8 @@ Item right: parent.right rightMargin: UM.Theme.getSize("default_margin").width } - height: UM.Theme.getSize("setting_control").height + height: visible ? UM.Theme.getSize("setting_control").height : 0 + Behavior on height { NumberAnimation { duration: 100 } } TextField { @@ -125,7 +140,7 @@ Item onClicked: { filter.text = ""; - filter.setActiveFocus(); + filter.forceActiveFocus(); } } } @@ -136,7 +151,8 @@ Item anchors.bottom: parent.bottom; anchors.right: parent.right; anchors.left: parent.left; - anchors.topMargin: UM.Theme.getSize("default_margin").width + anchors.topMargin: filterContainer.visible ? UM.Theme.getSize("default_margin").width : 0 + Behavior on anchors.topMargin { NumberAnimation { duration: 100 } } style: UM.Theme.styles.scrollview; flickableItem.flickableDirection: Flickable.VerticalFlick; diff --git a/resources/qml/Sidebar.qml b/resources/qml/Sidebar.qml index a74b684213..c2e6737ad4 100644 --- a/resources/qml/Sidebar.qml +++ b/resources/qml/Sidebar.qml @@ -214,7 +214,7 @@ Rectangle anchors.left: parent.left anchors.leftMargin: model.index * (settingsModeSelection.width / 2) anchors.verticalCenter: parent.verticalCenter - width: 0.5 * parent.width - (index == 1 ? toggleFilterButton.width : 0) + width: 0.5 * parent.width - (modesListModel.get(index).showFilterButton ? toggleFilterButton.width : 0) text: model.text exclusiveGroup: modeMenuGroup; checkable: true; @@ -268,9 +268,11 @@ Rectangle height: settingsModeSelection.height width: visible ? height : 0 - visible: !monitoringPrint && base.currentModeIndex == 1 + visible: !monitoringPrint && modesListModel.get(base.currentModeIndex).showFilterButton opacity: visible ? 1 : 0 + onClicked: sidebarContents.currentItem.toggleFilterField() + style: ButtonStyle { background: Rectangle @@ -415,8 +417,8 @@ Rectangle Component.onCompleted: { - modesListModel.append({ text: catalog.i18nc("@title:tab", "Recommended"), item: sidebarSimple }) - modesListModel.append({ text: catalog.i18nc("@title:tab", "Custom"), item: sidebarAdvanced }) + modesListModel.append({ text: catalog.i18nc("@title:tab", "Recommended"), item: sidebarSimple, showFilterButton: false }) + modesListModel.append({ text: catalog.i18nc("@title:tab", "Custom"), item: sidebarAdvanced, showFilterButton: true }) sidebarContents.push({ "item": modesListModel.get(base.currentModeIndex).item, "immediate": true }); } From 9dd8a88602a1bf191c68fba4211846d26a214987 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Thu, 24 Nov 2016 10:12:11 +0100 Subject: [PATCH 11/12] Fix review issues --- resources/qml/Settings/SettingView.qml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/resources/qml/Settings/SettingView.qml b/resources/qml/Settings/SettingView.qml index c3da68bf79..5f20f92b20 100644 --- a/resources/qml/Settings/SettingView.qml +++ b/resources/qml/Settings/SettingView.qml @@ -39,7 +39,7 @@ Item border.width: UM.Theme.getSize("default_lining").width border.color: { - if(mouseArea.containsMouse || clearFilterButton.containsMouse) + if(hoverMouseArea.containsMouse || clearFilterButton.containsMouse) { return UM.Theme.getColor("setting_control_border_highlight"); } @@ -65,7 +65,6 @@ Item TextField { id: filter; - visible: !monitoringPrint anchors.left: parent.left anchors.right: clearFilterButton.left @@ -114,7 +113,7 @@ Item MouseArea { - id: mouseArea + id: hoverMouseArea anchors.fill: parent hoverEnabled: true acceptedButtons: Qt.NoButton From d045738dc86de7821b67f482b5628dc52f88ebc0 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Thu, 24 Nov 2016 11:51:35 +0100 Subject: [PATCH 12/12] Simplify button width logic --- resources/qml/Sidebar.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/Sidebar.qml b/resources/qml/Sidebar.qml index c2e6737ad4..9c0d641d77 100644 --- a/resources/qml/Sidebar.qml +++ b/resources/qml/Sidebar.qml @@ -214,7 +214,7 @@ Rectangle anchors.left: parent.left anchors.leftMargin: model.index * (settingsModeSelection.width / 2) anchors.verticalCenter: parent.verticalCenter - width: 0.5 * parent.width - (modesListModel.get(index).showFilterButton ? toggleFilterButton.width : 0) + width: 0.5 * parent.width - (model.showFilterButton ? toggleFilterButton.width : 0) text: model.text exclusiveGroup: modeMenuGroup; checkable: true;