From 666ee81fb3be16c9bdde453d2a5b73949b1242f6 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Tue, 10 Oct 2017 10:28:44 +0200 Subject: [PATCH] Set label width based on the column width CURA-4428 - Remove the magic number solution - Use a fixed width for labels so the right side widgets can be properly left-aligned. --- .../MachineSettingsAction/MachineSettingsAction.qml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/plugins/MachineSettingsAction/MachineSettingsAction.qml b/plugins/MachineSettingsAction/MachineSettingsAction.qml index cd7738da11..5e2e67eed6 100644 --- a/plugins/MachineSettingsAction/MachineSettingsAction.qml +++ b/plugins/MachineSettingsAction/MachineSettingsAction.qml @@ -71,6 +71,7 @@ Cura.MachineAction anchors.topMargin: UM.Theme.getSize("default_margin").height property real columnWidth: ((width - 3 * UM.Theme.getSize("default_margin").width) / 2) | 0 + property real labelColumnWidth: columnWidth * 0.5 Tab { @@ -247,13 +248,13 @@ Cura.MachineAction Row { - spacing: UM.Theme.getSize("default_margin").width * 4 / 5 + spacing: UM.Theme.getSize("default_margin").width Label { text: catalog.i18nc("@label", "Number of Extruders") elide: Text.ElideRight - width: Math.max(0, settingsTabs.columnWidth - 2 * UM.Theme.getSize("default_margin").width - extruderCountComboBox.width) + width: Math.max(0, settingsTabs.labelColumnWidth) anchors.verticalCenter: extruderCountComboBox.verticalCenter } ComboBox @@ -562,7 +563,7 @@ Cura.MachineAction text: _label visible: _label != "" elide: Text.ElideRight - width: Math.max(0, settingsTabs.columnWidth - 2 * UM.Theme.getSize("default_margin").width - textFieldWithUnit.width) + width: Math.max(0, settingsTabs.labelColumnWidth) anchors.verticalCenter: textFieldWithUnit.verticalCenter } @@ -648,14 +649,14 @@ Cura.MachineAction Row { - spacing: UM.Theme.getSize("default_margin").width * 4 / 5 + spacing: UM.Theme.getSize("default_margin").width Label { text: _label visible: _label != "" elide: Text.ElideRight - width: Math.max(0, settingsTabs.columnWidth - 2 * UM.Theme.getSize("default_margin").width - comboBox.width) + width: Math.max(0, settingsTabs.labelColumnWidth) anchors.verticalCenter: comboBox.verticalCenter } ComboBox @@ -787,7 +788,7 @@ Cura.MachineAction text: _label visible: _label != "" elide: Text.ElideRight - width: Math.max(0, settingsTabs.columnWidth - 2 * UM.Theme.getSize("default_margin").width - textFieldWithUnit.width) + width: Math.max(0, settingsTabs.labelColumnWidth) anchors.verticalCenter: textFieldWithUnit.verticalCenter }