diff --git a/resources/qml/Settings/SettingCategory.qml b/resources/qml/Settings/SettingCategory.qml index 75514e7c1b..e8c0983398 100644 --- a/resources/qml/Settings/SettingCategory.qml +++ b/resources/qml/Settings/SettingCategory.qml @@ -14,10 +14,14 @@ 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() + signal setActiveFocusToNextSetting(bool forward) + + property var focusItem: base text: definition.label iconSource: UM.Theme.getIcon(definition.icon) @@ -25,7 +29,33 @@ 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(); + } + } + + Keys.onTabPressed: + { + base.setActiveFocusToNextSetting(true) + } + Keys.onBacktabPressed: + { + base.setActiveFocusToNextSetting(false) + } + UM.SimpleButton { id: settingsButton diff --git a/resources/qml/Settings/SettingCheckBox.qml b/resources/qml/Settings/SettingCheckBox.qml index 97a72a026e..4ef7f59a77 100644 --- a/resources/qml/Settings/SettingCheckBox.qml +++ b/resources/qml/Settings/SettingCheckBox.qml @@ -11,6 +11,7 @@ import UM 1.2 as UM SettingItem { id: base + property var focusItem: control contents: MouseArea { @@ -49,12 +50,35 @@ SettingItem } } + Keys.onSpacePressed: + { + forceActiveFocus(); + propertyProvider.setPropertyValue("value", !checked); + } + onClicked: { forceActiveFocus(); propertyProvider.setPropertyValue("value", !checked); } + Keys.onTabPressed: + { + base.setActiveFocusToNextSetting(true) + } + Keys.onBacktabPressed: + { + base.setActiveFocusToNextSetting(false) + } + + onActiveFocusChanged: + { + if(activeFocus) + { + base.focusReceived(); + } + } + Rectangle { anchors @@ -67,7 +91,7 @@ SettingItem color: { - if (!enabled) + if(!enabled) { return UM.Theme.getColor("setting_control_disabled") } @@ -75,14 +99,22 @@ SettingItem { return UM.Theme.getColor("setting_control_highlight") } - else - { - return UM.Theme.getColor("setting_control") - } + return UM.Theme.getColor("setting_control") } border.width: UM.Theme.getSize("default_lining").width - border.color: !enabled ? UM.Theme.getColor("setting_control_disabled_border") : control.containsMouse ? UM.Theme.getColor("setting_control_border_highlight") : UM.Theme.getColor("setting_control_border") + border.color: + { + if(!enabled) + { + return UM.Theme.getColor("setting_control_disabled_border") + } + if(control.containsMouse || control.activeFocus) + { + return UM.Theme.getColor("setting_control_border_highlight") + } + return UM.Theme.getColor("setting_control_border") + } UM.RecolorImage { anchors.verticalCenter: parent.verticalCenter diff --git a/resources/qml/Settings/SettingComboBox.qml b/resources/qml/Settings/SettingComboBox.qml index c655630a8e..c29ac123d6 100644 --- a/resources/qml/Settings/SettingComboBox.qml +++ b/resources/qml/Settings/SettingComboBox.qml @@ -10,6 +10,7 @@ import UM 1.1 as UM SettingItem { id: base + property var focusItem: control contents: ComboBox { @@ -33,21 +34,29 @@ SettingItem { color: { - if (!enabled) + if(!enabled) { return UM.Theme.getColor("setting_control_disabled") } - if(control.hovered || base.activeFocus) + if(control.hovered || control.activeFocus) { return UM.Theme.getColor("setting_control_highlight") } - else - { - return UM.Theme.getColor("setting_control") - } + return UM.Theme.getColor("setting_control") + } + border.width: UM.Theme.getSize("default_lining").width + border.color: + { + if(!enabled) + { + return UM.Theme.getColor("setting_control_disabled_border") + } + if(control.hovered || control.activeFocus) + { + return UM.Theme.getColor("setting_control_border_highlight") + } + return UM.Theme.getColor("setting_control_border") } - 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"); } label: Item { @@ -86,7 +95,28 @@ SettingItem } } - onActivated: { forceActiveFocus(); propertyProvider.setPropertyValue("value", definition.options[index].key) } + onActivated: + { + forceActiveFocus(); + propertyProvider.setPropertyValue("value", definition.options[index].key); + } + + onActiveFocusChanged: + { + if(activeFocus) + { + base.focusReceived(); + } + } + + Keys.onTabPressed: + { + base.setActiveFocusToNextSetting(true) + } + Keys.onBacktabPressed: + { + base.setActiveFocusToNextSetting(false) + } Binding { diff --git a/resources/qml/Settings/SettingExtruder.qml b/resources/qml/Settings/SettingExtruder.qml index 4a946d16f8..15496eaa8b 100644 --- a/resources/qml/Settings/SettingExtruder.qml +++ b/resources/qml/Settings/SettingExtruder.qml @@ -11,6 +11,7 @@ import Cura 1.0 as Cura SettingItem { id: base + property var focusItem: control contents: ComboBox { @@ -27,6 +28,23 @@ SettingItem propertyProvider.setPropertyValue("value", model.getItem(index).index); } + onActiveFocusChanged: + { + if(activeFocus) + { + base.focusReceived(); + } + } + + Keys.onTabPressed: + { + base.setActiveFocusToNextSetting(true) + } + Keys.onBacktabPressed: + { + base.setActiveFocusToNextSetting(false) + } + currentIndex: propertyProvider.properties.value MouseArea @@ -53,7 +71,7 @@ SettingItem { color: { - if (!enabled) + if(!enabled) { return UM.Theme.getColor("setting_control_disabled"); } @@ -61,23 +79,19 @@ SettingItem { return UM.Theme.getColor("setting_control_highlight"); } - else - { - return UM.Theme.getColor("setting_control"); - } + return UM.Theme.getColor("setting_control"); } border.width: UM.Theme.getSize("default_lining").width border.color: { if(!enabled) { - return UM.Theme.getColor("setting_control_disabled_border"); + return UM.Theme.getColor("setting_control_disabled_border") } - if(control.hovered || base.activeFocus) + if(control.hovered || control.activeFocus) { - UM.Theme.getColor("setting_control_border_highlight") + return UM.Theme.getColor("setting_control_border_highlight") } - return UM.Theme.getColor("setting_control_border") } } diff --git a/resources/qml/Settings/SettingItem.qml b/resources/qml/Settings/SettingItem.qml index 7108d2a04c..112edb5049 100644 --- a/resources/qml/Settings/SettingItem.qml +++ b/resources/qml/Settings/SettingItem.qml @@ -32,9 +32,11 @@ Item { property var stackLevels: propertyProvider.stackLevels property var stackLevel: stackLevels[0] + signal focusReceived() + signal setActiveFocusToNextSetting(bool forward) 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 1f546b518c..0fd36564a1 100644 --- a/resources/qml/Settings/SettingOptionalExtruder.qml +++ b/resources/qml/Settings/SettingOptionalExtruder.qml @@ -11,6 +11,7 @@ import Cura 1.0 as Cura SettingItem { id: base + property var focusItem: control contents: ComboBox { @@ -31,6 +32,23 @@ SettingItem propertyProvider.setPropertyValue("value", model.getItem(index).index); } + onActiveFocusChanged: + { + if(activeFocus) + { + base.focusReceived(); + } + } + + Keys.onTabPressed: + { + base.setActiveFocusToNextSetting(true) + } + Keys.onBacktabPressed: + { + base.setActiveFocusToNextSetting(false) + } + Binding { target: control @@ -72,31 +90,27 @@ SettingItem { color: { - if (!enabled) + if(!enabled) { return UM.Theme.getColor("setting_control_disabled"); } - if(control.hovered || base.activeFocus) + if(control.hovered || control.activeFocus) { return UM.Theme.getColor("setting_control_highlight"); } - else - { - return UM.Theme.getColor("setting_control"); - } + return UM.Theme.getColor("setting_control"); } border.width: UM.Theme.getSize("default_lining").width border.color: { if(!enabled) { - return UM.Theme.getColor("setting_control_disabled_border"); + return UM.Theme.getColor("setting_control_disabled_border") } - if(control.hovered || base.activeFocus) + if(control.hovered || control.activeFocus) { - UM.Theme.getColor("setting_control_border_highlight") + return UM.Theme.getColor("setting_control_border_highlight") } - return UM.Theme.getColor("setting_control_border") } } diff --git a/resources/qml/Settings/SettingTextField.qml b/resources/qml/Settings/SettingTextField.qml index 059980bba2..2991c24d57 100644 --- a/resources/qml/Settings/SettingTextField.qml +++ b/resources/qml/Settings/SettingTextField.qml @@ -9,6 +9,7 @@ import UM 1.1 as UM SettingItem { id: base + property var focusItem: input contents: Rectangle { @@ -17,10 +18,21 @@ SettingItem anchors.fill: parent border.width: UM.Theme.getSize("default_lining").width - border.color: !enabled ? UM.Theme.getColor("setting_control_disabled_border") : hovered ? UM.Theme.getColor("setting_control_border_highlight") : UM.Theme.getColor("setting_control_border") + border.color: + { + if(!enabled) + { + return UM.Theme.getColor("setting_control_disabled_border") + } + if(hovered || input.activeFocus) + { + return UM.Theme.getColor("setting_control_border_highlight") + } + return UM.Theme.getColor("setting_control_border") + } color: { - if (!enabled) + if(!enabled) { return UM.Theme.getColor("setting_control_disabled") } @@ -83,6 +95,15 @@ SettingItem verticalCenter: parent.verticalCenter } + Keys.onTabPressed: + { + base.setActiveFocusToNextSetting(true) + } + Keys.onBacktabPressed: + { + base.setActiveFocusToNextSetting(false) + } + Keys.onReleased: { propertyProvider.setPropertyValue("value", text) @@ -93,6 +114,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..06e53cc03b 100644 --- a/resources/qml/Settings/SettingView.qml +++ b/resources/qml/Settings/SettingView.qml @@ -168,6 +168,8 @@ Item onVisibilityChanged: Cura.SettingInheritanceManager.forceUpdate() } + property var indexWithFocus: -1 + delegate: Loader { id: delegate @@ -298,11 +300,53 @@ Item } Cura.SettingInheritanceManager.manualRemoveOverride(category_id) } + onFocusReceived: + { + contents.indexWithFocus = index; + animateContentY.from = contents.contentY; + contents.positionViewAtIndex(index, ListView.Contain); + animateContentY.to = contents.contentY; + animateContentY.running = true; + } + onSetActiveFocusToNextSetting: + { + if(forward == undefined || forward) + { + contents.currentIndex = contents.indexWithFocus + 1; + while(contents.currentItem && contents.currentItem.height <= 0) + { + contents.currentIndex++; + } + if(contents.currentItem) + { + contents.currentItem.item.focusItem.forceActiveFocus(); + } + } + else + { + contents.currentIndex = contents.indexWithFocus - 1; + while(contents.currentItem && contents.currentItem.height <= 0) + { + contents.currentIndex--; + } + if(contents.currentItem) + { + contents.currentItem.item.focusItem.forceActiveFocus(); + } + } + } } } UM.I18nCatalog { id: catalog; name: "cura"; } + NumberAnimation { + id: animateContentY + target: contents + property: "contentY" + duration: 50 + } + add: Transition { SequentialAnimation { NumberAnimation { properties: "height"; from: 0; duration: 100 } diff --git a/resources/themes/cura/styles.qml b/resources/themes/cura/styles.qml index 496cc8e489..c4c441da43 100755 --- a/resources/themes/cura/styles.qml +++ b/resources/themes/cura/styles.qml @@ -368,11 +368,11 @@ QtObject { color: { if(!control.enabled) { return Theme.getColor("setting_category_disabled_border"); - } else if(control.hovered && control.checkable && control.checked) { + } else if((control.hovered || control.activeFocus) && control.checkable && control.checked) { return Theme.getColor("setting_category_active_hover_border"); } else if(control.pressed || (control.checkable && control.checked)) { return Theme.getColor("setting_category_active_border"); - } else if(control.hovered) { + } else if(control.hovered || control.activeFocus) { return Theme.getColor("setting_category_hover_border"); } else { return Theme.getColor("setting_category_border"); @@ -508,7 +508,7 @@ QtObject { { color: { - if (!enabled) + if(!enabled) { return UM.Theme.getColor("setting_control_disabled"); }