Fix overlap of unit and setting value with RTL-languages

The unit was hard-coded to be anchored to the right. The text was getting the full width and aligned implicitly by the language. We'll keep the layout of the text properly internationalised, but make sure that the unit is opposite of wherever the text is.

Fixes CURA-8206.
Fixes #9667.
This commit is contained in:
Ghostkeeper 2021-06-07 18:00:32 +02:00
parent dc8c5e4268
commit 836e7c0c9b
No known key found for this signature in database
GPG key ID: D2A8871EE34EC59A

View file

@ -1,4 +1,4 @@
// Copyright (c) 2017 Ultimaker B.V.
// Copyright (c) 2021 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.7
@ -92,11 +92,18 @@ SettingItem
Label
{
anchors.right: parent.right
anchors.rightMargin: Math.round(UM.Theme.getSize("setting_unit_margin").width)
anchors.verticalCenter: parent.verticalCenter
anchors
{
left: parent.left
leftMargin: Math.round(UM.Theme.getSize("setting_unit_margin").width)
right: parent.right
rightMargin: Math.round(UM.Theme.getSize("setting_unit_margin").width)
verticalCenter: parent.verticalCenter
}
text: definition.unit
//However the setting value is aligned, align the unit opposite. That way it stays readable with right-to-left languages.
horizontalAlignment: (input.effectiveHorizontalAlignment == Text.AlignLeft) ? Text.AlignRight : Text.AlignLeft
textFormat: Text.PlainText
renderType: Text.NativeRendering
color: UM.Theme.getColor("setting_unit")