From edee53b0b16950436878cc0be994744b9e943ae4 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Mon, 26 Jun 2017 13:00:59 +0200 Subject: [PATCH] Scroll setting with active focus into view --- resources/qml/Settings/SettingCategory.qml | 24 ++++++++++++++++--- resources/qml/Settings/SettingCheckBox.qml | 8 +++++++ resources/qml/Settings/SettingComboBox.qml | 14 ++++++++++- resources/qml/Settings/SettingExtruder.qml | 8 +++++++ resources/qml/Settings/SettingItem.qml | 5 ++-- .../qml/Settings/SettingOptionalExtruder.qml | 8 +++++++ resources/qml/Settings/SettingTextField.qml | 8 +++++++ resources/qml/Settings/SettingView.qml | 4 ++++ 8 files changed, 73 insertions(+), 6 deletions(-) diff --git a/resources/qml/Settings/SettingCategory.qml b/resources/qml/Settings/SettingCategory.qml index 75514e7c1b..6220d6429e 100644 --- a/resources/qml/Settings/SettingCategory.qml +++ b/resources/qml/Settings/SettingCategory.qml @@ -14,10 +14,11 @@ Button { style: UM.Theme.styles.sidebar_category; - signal showTooltip(string text); - signal hideTooltip(); + signal showTooltip(string text) + signal hideTooltip() signal contextMenuRequested() signal showAllHiddenInheritedSettings(string category_id) + signal focusReceived() text: definition.label iconSource: UM.Theme.getIcon(definition.icon) @@ -25,7 +26,24 @@ Button { checkable: true checked: definition.expanded - onClicked: { forceActiveFocus(); definition.expanded ? settingDefinitionsModel.collapse(definition.key) : settingDefinitionsModel.expandAll(definition.key) } + onClicked: + { + forceActiveFocus(); + if(definition.expanded) + { + settingDefinitionsModel.collapse(definition.key); + } else { + settingDefinitionsModel.expandAll(definition.key); + } + } + onActiveFocusChanged: + { + if(activeFocus) + { + base.focusReceived(); + } + } + UM.SimpleButton { id: settingsButton diff --git a/resources/qml/Settings/SettingCheckBox.qml b/resources/qml/Settings/SettingCheckBox.qml index 07b1f865be..8f21e19713 100644 --- a/resources/qml/Settings/SettingCheckBox.qml +++ b/resources/qml/Settings/SettingCheckBox.qml @@ -62,6 +62,14 @@ SettingItem propertyProvider.setPropertyValue("value", !checked); } + onActiveFocusChanged: + { + if(activeFocus) + { + base.focusReceived(); + } + } + Rectangle { anchors diff --git a/resources/qml/Settings/SettingComboBox.qml b/resources/qml/Settings/SettingComboBox.qml index 4c14d2032b..5d1cc287b3 100644 --- a/resources/qml/Settings/SettingComboBox.qml +++ b/resources/qml/Settings/SettingComboBox.qml @@ -94,7 +94,19 @@ SettingItem } } - onActivated: { forceActiveFocus(); propertyProvider.setPropertyValue("value", definition.options[index].key) } + onActivated: + { + forceActiveFocus(); + propertyProvider.setPropertyValue("value", definition.options[index].key); + } + + onActiveFocusChanged: + { + if(activeFocus) + { + base.focusReceived(); + } + } Binding { diff --git a/resources/qml/Settings/SettingExtruder.qml b/resources/qml/Settings/SettingExtruder.qml index b00b6774be..f4b85bdd99 100644 --- a/resources/qml/Settings/SettingExtruder.qml +++ b/resources/qml/Settings/SettingExtruder.qml @@ -27,6 +27,14 @@ SettingItem propertyProvider.setPropertyValue("value", model.getItem(index).index); } + onActiveFocusChanged: + { + if(activeFocus) + { + base.focusReceived(); + } + } + currentIndex: propertyProvider.properties.value MouseArea diff --git a/resources/qml/Settings/SettingItem.qml b/resources/qml/Settings/SettingItem.qml index 7108d2a04c..dca8f63076 100644 --- a/resources/qml/Settings/SettingItem.qml +++ b/resources/qml/Settings/SettingItem.qml @@ -32,9 +32,10 @@ Item { property var stackLevels: propertyProvider.stackLevels property var stackLevel: stackLevels[0] + signal focusReceived() signal contextMenuRequested() - signal showTooltip(string text); - signal hideTooltip(); + signal showTooltip(string text) + signal hideTooltip() signal showAllHiddenInheritedSettings(string category_id) property string tooltipText: { diff --git a/resources/qml/Settings/SettingOptionalExtruder.qml b/resources/qml/Settings/SettingOptionalExtruder.qml index e2ca20571c..f7f86a77c0 100644 --- a/resources/qml/Settings/SettingOptionalExtruder.qml +++ b/resources/qml/Settings/SettingOptionalExtruder.qml @@ -31,6 +31,14 @@ SettingItem propertyProvider.setPropertyValue("value", model.getItem(index).index); } + onActiveFocusChanged: + { + if(activeFocus) + { + base.focusReceived(); + } + } + Binding { target: control diff --git a/resources/qml/Settings/SettingTextField.qml b/resources/qml/Settings/SettingTextField.qml index b9f11ea80d..7f495aea02 100644 --- a/resources/qml/Settings/SettingTextField.qml +++ b/resources/qml/Settings/SettingTextField.qml @@ -105,6 +105,14 @@ SettingItem propertyProvider.setPropertyValue("value", text) } + onActiveFocusChanged: + { + if(activeFocus) + { + base.focusReceived(); + } + } + color: !enabled ? UM.Theme.getColor("setting_control_disabled_text") : UM.Theme.getColor("setting_control_text") font: UM.Theme.getFont("default"); diff --git a/resources/qml/Settings/SettingView.qml b/resources/qml/Settings/SettingView.qml index 7cb45ff75f..752665f2b7 100644 --- a/resources/qml/Settings/SettingView.qml +++ b/resources/qml/Settings/SettingView.qml @@ -298,6 +298,10 @@ Item } Cura.SettingInheritanceManager.manualRemoveOverride(category_id) } + onFocusReceived: + { + contents.positionViewAtIndex(index, ListView.Contain); + } } }