Merge branch 'feature_tab_navigation' of https://github.com/fieldOfView/Cura

This commit is contained in:
Jaime van Kessel 2017-06-26 14:39:12 +02:00
commit c36ab386fa
9 changed files with 239 additions and 44 deletions

View File

@ -14,10 +14,14 @@ Button {
style: UM.Theme.styles.sidebar_category; style: UM.Theme.styles.sidebar_category;
signal showTooltip(string text); signal showTooltip(string text)
signal hideTooltip(); signal hideTooltip()
signal contextMenuRequested() signal contextMenuRequested()
signal showAllHiddenInheritedSettings(string category_id) signal showAllHiddenInheritedSettings(string category_id)
signal focusReceived()
signal setActiveFocusToNextSetting(bool forward)
property var focusItem: base
text: definition.label text: definition.label
iconSource: UM.Theme.getIcon(definition.icon) iconSource: UM.Theme.getIcon(definition.icon)
@ -25,7 +29,33 @@ Button {
checkable: true checkable: true
checked: definition.expanded 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 UM.SimpleButton
{ {
id: settingsButton id: settingsButton

View File

@ -11,6 +11,7 @@ import UM 1.2 as UM
SettingItem SettingItem
{ {
id: base id: base
property var focusItem: control
contents: MouseArea contents: MouseArea
{ {
@ -49,12 +50,35 @@ SettingItem
} }
} }
Keys.onSpacePressed:
{
forceActiveFocus();
propertyProvider.setPropertyValue("value", !checked);
}
onClicked: onClicked:
{ {
forceActiveFocus(); forceActiveFocus();
propertyProvider.setPropertyValue("value", !checked); propertyProvider.setPropertyValue("value", !checked);
} }
Keys.onTabPressed:
{
base.setActiveFocusToNextSetting(true)
}
Keys.onBacktabPressed:
{
base.setActiveFocusToNextSetting(false)
}
onActiveFocusChanged:
{
if(activeFocus)
{
base.focusReceived();
}
}
Rectangle Rectangle
{ {
anchors anchors
@ -67,7 +91,7 @@ SettingItem
color: color:
{ {
if (!enabled) if(!enabled)
{ {
return UM.Theme.getColor("setting_control_disabled") return UM.Theme.getColor("setting_control_disabled")
} }
@ -75,14 +99,22 @@ SettingItem
{ {
return UM.Theme.getColor("setting_control_highlight") 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.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 { UM.RecolorImage {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter

View File

@ -10,6 +10,7 @@ import UM 1.1 as UM
SettingItem SettingItem
{ {
id: base id: base
property var focusItem: control
contents: ComboBox contents: ComboBox
{ {
@ -33,21 +34,29 @@ SettingItem
{ {
color: color:
{ {
if (!enabled) if(!enabled)
{ {
return UM.Theme.getColor("setting_control_disabled") return UM.Theme.getColor("setting_control_disabled")
} }
if(control.hovered || base.activeFocus) if(control.hovered || control.activeFocus)
{ {
return UM.Theme.getColor("setting_control_highlight") 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 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 Binding
{ {

View File

@ -11,6 +11,7 @@ import Cura 1.0 as Cura
SettingItem SettingItem
{ {
id: base id: base
property var focusItem: control
contents: ComboBox contents: ComboBox
{ {
@ -27,6 +28,23 @@ SettingItem
propertyProvider.setPropertyValue("value", model.getItem(index).index); 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 currentIndex: propertyProvider.properties.value
MouseArea MouseArea
@ -53,7 +71,7 @@ SettingItem
{ {
color: color:
{ {
if (!enabled) if(!enabled)
{ {
return UM.Theme.getColor("setting_control_disabled"); return UM.Theme.getColor("setting_control_disabled");
} }
@ -61,23 +79,19 @@ SettingItem
{ {
return UM.Theme.getColor("setting_control_highlight"); 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.width: UM.Theme.getSize("default_lining").width
border.color: border.color:
{ {
if(!enabled) 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") return UM.Theme.getColor("setting_control_border")
} }
} }

View File

@ -32,9 +32,11 @@ Item {
property var stackLevels: propertyProvider.stackLevels property var stackLevels: propertyProvider.stackLevels
property var stackLevel: stackLevels[0] property var stackLevel: stackLevels[0]
signal focusReceived()
signal setActiveFocusToNextSetting(bool forward)
signal contextMenuRequested() signal contextMenuRequested()
signal showTooltip(string text); signal showTooltip(string text)
signal hideTooltip(); signal hideTooltip()
signal showAllHiddenInheritedSettings(string category_id) signal showAllHiddenInheritedSettings(string category_id)
property string tooltipText: property string tooltipText:
{ {

View File

@ -11,6 +11,7 @@ import Cura 1.0 as Cura
SettingItem SettingItem
{ {
id: base id: base
property var focusItem: control
contents: ComboBox contents: ComboBox
{ {
@ -31,6 +32,23 @@ SettingItem
propertyProvider.setPropertyValue("value", model.getItem(index).index); propertyProvider.setPropertyValue("value", model.getItem(index).index);
} }
onActiveFocusChanged:
{
if(activeFocus)
{
base.focusReceived();
}
}
Keys.onTabPressed:
{
base.setActiveFocusToNextSetting(true)
}
Keys.onBacktabPressed:
{
base.setActiveFocusToNextSetting(false)
}
Binding Binding
{ {
target: control target: control
@ -72,31 +90,27 @@ SettingItem
{ {
color: color:
{ {
if (!enabled) if(!enabled)
{ {
return UM.Theme.getColor("setting_control_disabled"); return UM.Theme.getColor("setting_control_disabled");
} }
if(control.hovered || base.activeFocus) if(control.hovered || control.activeFocus)
{ {
return UM.Theme.getColor("setting_control_highlight"); 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.width: UM.Theme.getSize("default_lining").width
border.color: border.color:
{ {
if(!enabled) 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") return UM.Theme.getColor("setting_control_border")
} }
} }

View File

@ -9,6 +9,7 @@ import UM 1.1 as UM
SettingItem SettingItem
{ {
id: base id: base
property var focusItem: input
contents: Rectangle contents: Rectangle
{ {
@ -17,10 +18,21 @@ SettingItem
anchors.fill: parent anchors.fill: parent
border.width: UM.Theme.getSize("default_lining").width 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: { color: {
if (!enabled) if(!enabled)
{ {
return UM.Theme.getColor("setting_control_disabled") return UM.Theme.getColor("setting_control_disabled")
} }
@ -83,6 +95,15 @@ SettingItem
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
} }
Keys.onTabPressed:
{
base.setActiveFocusToNextSetting(true)
}
Keys.onBacktabPressed:
{
base.setActiveFocusToNextSetting(false)
}
Keys.onReleased: Keys.onReleased:
{ {
propertyProvider.setPropertyValue("value", text) propertyProvider.setPropertyValue("value", text)
@ -93,6 +114,14 @@ SettingItem
propertyProvider.setPropertyValue("value", text) propertyProvider.setPropertyValue("value", text)
} }
onActiveFocusChanged:
{
if(activeFocus)
{
base.focusReceived();
}
}
color: !enabled ? UM.Theme.getColor("setting_control_disabled_text") : UM.Theme.getColor("setting_control_text") 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");

View File

@ -168,6 +168,8 @@ Item
onVisibilityChanged: Cura.SettingInheritanceManager.forceUpdate() onVisibilityChanged: Cura.SettingInheritanceManager.forceUpdate()
} }
property var indexWithFocus: -1
delegate: Loader delegate: Loader
{ {
id: delegate id: delegate
@ -298,11 +300,53 @@ Item
} }
Cura.SettingInheritanceManager.manualRemoveOverride(category_id) 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"; } UM.I18nCatalog { id: catalog; name: "cura"; }
NumberAnimation {
id: animateContentY
target: contents
property: "contentY"
duration: 50
}
add: Transition { add: Transition {
SequentialAnimation { SequentialAnimation {
NumberAnimation { properties: "height"; from: 0; duration: 100 } NumberAnimation { properties: "height"; from: 0; duration: 100 }

View File

@ -368,11 +368,11 @@ QtObject {
color: { color: {
if(!control.enabled) { if(!control.enabled) {
return Theme.getColor("setting_category_disabled_border"); 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"); return Theme.getColor("setting_category_active_hover_border");
} else if(control.pressed || (control.checkable && control.checked)) { } else if(control.pressed || (control.checkable && control.checked)) {
return Theme.getColor("setting_category_active_border"); return Theme.getColor("setting_category_active_border");
} else if(control.hovered) { } else if(control.hovered || control.activeFocus) {
return Theme.getColor("setting_category_hover_border"); return Theme.getColor("setting_category_hover_border");
} else { } else {
return Theme.getColor("setting_category_border"); return Theme.getColor("setting_category_border");
@ -508,7 +508,7 @@ QtObject {
{ {
color: color:
{ {
if (!enabled) if(!enabled)
{ {
return UM.Theme.getColor("setting_control_disabled"); return UM.Theme.getColor("setting_control_disabled");
} }