From 77c8ac3950c2cc50131c0011b9d4078c9f60b787 Mon Sep 17 00:00:00 2001 From: ChrisTerBeke Date: Wed, 3 Jan 2018 11:46:20 +0100 Subject: [PATCH] Layout fixes for controls 2.0 --- resources/qml/Settings/SettingComboBox.qml | 49 +++++++++++-------- resources/qml/Settings/SettingExtruder.qml | 11 ++++- .../qml/Settings/SettingOptionalExtruder.qml | 9 +++- 3 files changed, 44 insertions(+), 25 deletions(-) diff --git a/resources/qml/Settings/SettingComboBox.qml b/resources/qml/Settings/SettingComboBox.qml index eaa22e1a9f..63ed5d2030 100644 --- a/resources/qml/Settings/SettingComboBox.qml +++ b/resources/qml/Settings/SettingComboBox.qml @@ -16,42 +16,43 @@ SettingItem id: control model: definition.options - textRole: "value"; + textRole: "value" anchors.fill: parent MouseArea { - anchors.fill: parent; - acceptedButtons: Qt.NoButton; - onWheel: wheel.accepted = true; + anchors.fill: parent + acceptedButtons: Qt.NoButton + onWheel: wheel.accepted = true } background: Rectangle { color: { - if(!enabled) - { + if (!enabled) { 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") } + border.width: UM.Theme.getSize("default_lining").width border.color: { - if(!enabled) - { + if (!enabled) { 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") } } @@ -68,29 +69,34 @@ SettingItem sourceSize.width: width + 5 * screenScaleFactor sourceSize.height: width + 5 * screenScaleFactor - color: UM.Theme.getColor("setting_control_text"); + color: UM.Theme.getColor("setting_control_text") } contentItem: Label { - 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; + anchors.left: parent.left + anchors.leftMargin: UM.Theme.getSize("setting_unit_margin").width + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.left + + 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: { - forceActiveFocus(); - propertyProvider.setPropertyValue("value", definition.options[index].key); + forceActiveFocus() + propertyProvider.setPropertyValue("value", definition.options[index].key) } onActiveFocusChanged: { if(activeFocus) { - base.focusReceived(); + base.focusReceived() } } @@ -98,6 +104,7 @@ SettingItem { base.setActiveFocusToNextSetting(true) } + Keys.onBacktabPressed: { base.setActiveFocusToNextSetting(false) diff --git a/resources/qml/Settings/SettingExtruder.qml b/resources/qml/Settings/SettingExtruder.qml index 0568343b8c..94e565551a 100644 --- a/resources/qml/Settings/SettingExtruder.qml +++ b/resources/qml/Settings/SettingExtruder.qml @@ -107,14 +107,18 @@ SettingItem return UM.Theme.getColor("setting_control_border") } } + contentItem: Item { Label { id: extruderText + anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left + anchors.leftMargin: UM.Theme.getSize("setting_unit_margin").width anchors.right: swatch.left + text: control.currentText font: UM.Theme.getFont("default") color: enabled ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_disabled_text") @@ -122,6 +126,7 @@ SettingItem elide: Text.ElideLeft verticalAlignment: Text.AlignVCenter } + Rectangle { id: swatch @@ -129,9 +134,11 @@ SettingItem width: height 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") radius: width / 2 diff --git a/resources/qml/Settings/SettingOptionalExtruder.qml b/resources/qml/Settings/SettingOptionalExtruder.qml index 43588edfce..e336ad4101 100644 --- a/resources/qml/Settings/SettingOptionalExtruder.qml +++ b/resources/qml/Settings/SettingOptionalExtruder.qml @@ -132,8 +132,10 @@ SettingItem Label { id: extruderText + anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left + anchors.leftMargin: UM.Theme.getSize("setting_unit_margin").width anchors.right: swatch.left text: control.currentText @@ -143,6 +145,7 @@ SettingItem elide: Text.ElideRight verticalAlignment: Text.AlignVCenter } + Rectangle { id: swatch @@ -150,9 +153,11 @@ SettingItem width: height 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") radius: width / 2