Layout fixes for controls 2.0

This commit is contained in:
ChrisTerBeke 2018-01-03 11:46:20 +01:00
parent 27ca743e58
commit 77c8ac3950
3 changed files with 44 additions and 25 deletions

View file

@ -16,42 +16,43 @@ SettingItem
id: control id: control
model: definition.options model: definition.options
textRole: "value"; textRole: "value"
anchors.fill: parent anchors.fill: parent
MouseArea MouseArea
{ {
anchors.fill: parent; anchors.fill: parent
acceptedButtons: Qt.NoButton; acceptedButtons: Qt.NoButton
onWheel: wheel.accepted = true; onWheel: wheel.accepted = true
} }
background: Rectangle background: Rectangle
{ {
color: color:
{ {
if(!enabled) if (!enabled) {
{
return UM.Theme.getColor("setting_control_disabled") return UM.Theme.getColor("setting_control_disabled")
} }
if(control.hovered || control.activeFocus)
{ if (control.hovered || control.activeFocus) {
return UM.Theme.getColor("setting_control_highlight") return UM.Theme.getColor("setting_control_highlight")
} }
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 || control.activeFocus)
{ if (control.hovered || control.activeFocus) {
return 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")
} }
} }
@ -68,29 +69,34 @@ SettingItem
sourceSize.width: width + 5 * screenScaleFactor sourceSize.width: width + 5 * screenScaleFactor
sourceSize.height: width + 5 * screenScaleFactor sourceSize.height: width + 5 * screenScaleFactor
color: UM.Theme.getColor("setting_control_text"); color: UM.Theme.getColor("setting_control_text")
} }
contentItem: Label contentItem: Label
{ {
text: control.currentText; anchors.left: parent.left
font: UM.Theme.getFont("default"); anchors.leftMargin: UM.Theme.getSize("setting_unit_margin").width
color: !enabled ? UM.Theme.getColor("setting_control_disabled_text") : UM.Theme.getColor("setting_control_text"); anchors.verticalCenter: parent.verticalCenter
elide: Text.ElideRight; anchors.right: parent.left
verticalAlignment: Text.AlignVCenter;
text: control.currentText
font: UM.Theme.getFont("default")
color: !enabled ? UM.Theme.getColor("setting_control_disabled_text") : UM.Theme.getColor("setting_control_text")
elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter
} }
onActivated: onActivated:
{ {
forceActiveFocus(); forceActiveFocus()
propertyProvider.setPropertyValue("value", definition.options[index].key); propertyProvider.setPropertyValue("value", definition.options[index].key)
} }
onActiveFocusChanged: onActiveFocusChanged:
{ {
if(activeFocus) if(activeFocus)
{ {
base.focusReceived(); base.focusReceived()
} }
} }
@ -98,6 +104,7 @@ SettingItem
{ {
base.setActiveFocusToNextSetting(true) base.setActiveFocusToNextSetting(true)
} }
Keys.onBacktabPressed: Keys.onBacktabPressed:
{ {
base.setActiveFocusToNextSetting(false) base.setActiveFocusToNextSetting(false)

View file

@ -107,14 +107,18 @@ SettingItem
return UM.Theme.getColor("setting_control_border") return UM.Theme.getColor("setting_control_border")
} }
} }
contentItem: Item contentItem: Item
{ {
Label Label
{ {
id: extruderText id: extruderText
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: UM.Theme.getSize("setting_unit_margin").width
anchors.right: swatch.left anchors.right: swatch.left
text: control.currentText text: control.currentText
font: UM.Theme.getFont("default") font: UM.Theme.getFont("default")
color: enabled ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text") color: enabled ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text")
@ -122,6 +126,7 @@ SettingItem
elide: Text.ElideLeft elide: Text.ElideLeft
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
} }
Rectangle Rectangle
{ {
id: swatch id: swatch
@ -129,9 +134,11 @@ SettingItem
width: height width: height
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: control.indicator.width + control.spacing anchors.rightMargin: control.indicator.width + UM.Theme.getSize("setting_unit_margin").width
anchors.verticalCenter: parent.verticalCenter
anchors.margins: UM.Theme.getSize("default_margin").width / 4
border.width: UM.Theme.getSize("default_lining").width * 2 border.width: UM.Theme.getSize("default_lining").width
border.color: enabled ? UM.Theme.getColor("setting_control_border") : UM.Theme.getColor("setting_control_disabled_border") border.color: enabled ? UM.Theme.getColor("setting_control_border") : UM.Theme.getColor("setting_control_disabled_border")
radius: width / 2 radius: width / 2

View file

@ -132,8 +132,10 @@ SettingItem
Label Label
{ {
id: extruderText id: extruderText
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: UM.Theme.getSize("setting_unit_margin").width
anchors.right: swatch.left anchors.right: swatch.left
text: control.currentText text: control.currentText
@ -143,6 +145,7 @@ SettingItem
elide: Text.ElideRight elide: Text.ElideRight
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
} }
Rectangle Rectangle
{ {
id: swatch id: swatch
@ -150,9 +153,11 @@ SettingItem
width: height width: height
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: control.indicator.width + control.spacing anchors.rightMargin: control.indicator.width + UM.Theme.getSize("setting_unit_margin").width
anchors.verticalCenter: parent.verticalCenter
anchors.margins: UM.Theme.getSize("default_margin").width / 4
border.width: UM.Theme.getSize("default_lining").width * 2 border.width: UM.Theme.getSize("default_lining").width
border.color: enabled ? UM.Theme.getColor("setting_control_border") : UM.Theme.getColor("setting_control_disabled_border") border.color: enabled ? UM.Theme.getColor("setting_control_border") : UM.Theme.getColor("setting_control_disabled_border")
radius: width / 2 radius: width / 2