mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-08-06 07:45:51 +02:00
generalMenuItem: refinement on long text solution for menuItems
This will make sure that texts are aligned when some of the texts grow longer (translations) Change-Id: I28300c3eea01d539ca62c6532daf7d802931b425
This commit is contained in:
parent
ddc793e361
commit
7084f6dda0
2 changed files with 32 additions and 16 deletions
|
@ -45,6 +45,9 @@ MenuItem {
|
||||||
property int leftBorderWidth: JamiTheme.menuItemsCommonBorderWidth
|
property int leftBorderWidth: JamiTheme.menuItemsCommonBorderWidth
|
||||||
property int rightBorderWidth: JamiTheme.menuItemsCommonBorderWidth
|
property int rightBorderWidth: JamiTheme.menuItemsCommonBorderWidth
|
||||||
|
|
||||||
|
property int itemImageLeftMargin: 24
|
||||||
|
property int itemTextMargin: 20
|
||||||
|
|
||||||
signal clicked
|
signal clicked
|
||||||
|
|
||||||
contentItem: AbstractButton {
|
contentItem: AbstractButton {
|
||||||
|
@ -69,7 +72,7 @@ MenuItem {
|
||||||
id: contextMenuItemImage
|
id: contextMenuItemImage
|
||||||
|
|
||||||
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
|
||||||
Layout.leftMargin: status === Image.Ready ? 24 : 0
|
Layout.leftMargin: status === Image.Ready ? itemImageLeftMargin : 0
|
||||||
|
|
||||||
visible: status === Image.Ready
|
visible: status === Image.Ready
|
||||||
|
|
||||||
|
@ -81,28 +84,41 @@ MenuItem {
|
||||||
id: contextMenuItemText
|
id: contextMenuItemText
|
||||||
|
|
||||||
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
|
||||||
Layout.leftMargin: contextMenuItemImage.status === Image.Ready ? 20 : 10
|
Layout.leftMargin: contextMenuItemImage.status === Image.Ready ?
|
||||||
Layout.rightMargin: contextMenuItemImage.status === Image.Ready ? 20 : 10
|
itemTextMargin : itemTextMargin / 2
|
||||||
|
Layout.rightMargin: contextMenuItemImage.status === Image.Ready ?
|
||||||
|
itemTextMargin : itemTextMargin / 2
|
||||||
Layout.preferredHeight: itemPreferredHeight
|
Layout.preferredHeight: itemPreferredHeight
|
||||||
Layout.preferredWidth: JamiTheme.contextMenuItemTextPreferredWidth
|
Layout.fillWidth: true
|
||||||
|
|
||||||
text: itemName
|
text: itemName
|
||||||
color: JamiTheme.textColor
|
color: JamiTheme.textColor
|
||||||
font.pointSize: JamiTheme.textFontSize
|
font.pointSize: JamiTheme.textFontSize
|
||||||
horizontalAlignment: Text.AlignLeft
|
horizontalAlignment: Text.AlignLeft
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
elide: Text.ElideRight
|
|
||||||
|
|
||||||
onWidthChanged: {
|
TextMetrics {
|
||||||
if (autoTextSizeAdjustment
|
id: contextMenuItemTextMetrics
|
||||||
&& width > contextMenuItemText.Layout.preferredWidth) {
|
|
||||||
if (width > JamiTheme.contextMenuItemTextMaxWidth)
|
font: contextMenuItemText.font
|
||||||
contextMenuItemText.Layout.preferredWidth
|
text: contextMenuItemText.text
|
||||||
= JamiTheme.contextMenuItemTextMaxWidth
|
|
||||||
else
|
onBoundingRectChanged: {
|
||||||
contextMenuItemText.Layout.preferredWidth = width
|
var sizeToCompare = itemPreferredWidth -
|
||||||
itemPreferredWidth += contextMenuItemText.Layout.preferredWidth
|
(contextMenuItemImage.source.toString().length > 0 ?
|
||||||
- JamiTheme.contextMenuItemTextPreferredWidth
|
itemTextMargin + itemImageLeftMargin + contextMenuItemImage.width :
|
||||||
|
itemTextMargin / 2)
|
||||||
|
if (autoTextSizeAdjustment
|
||||||
|
&& boundingRect.width > sizeToCompare) {
|
||||||
|
if (boundingRect.width > JamiTheme.contextMenuItemTextMaxWidth) {
|
||||||
|
itemPreferredWidth += JamiTheme.contextMenuItemTextMaxWidth
|
||||||
|
- JamiTheme.contextMenuItemTextPreferredWidth
|
||||||
|
+ itemTextMargin
|
||||||
|
contextMenuItemText.elide = Text.ElideRight
|
||||||
|
} else
|
||||||
|
itemPreferredWidth += boundingRect.width + itemTextMargin
|
||||||
|
- sizeToCompare
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,7 +198,7 @@ Item {
|
||||||
property real avatarSizeInCall: 130
|
property real avatarSizeInCall: 130
|
||||||
property real aboutButtonPreferredWidth: 150
|
property real aboutButtonPreferredWidth: 150
|
||||||
property real callButtonPreferredSize: 50
|
property real callButtonPreferredSize: 50
|
||||||
property real contextMenuItemTextPreferredWidth: 142
|
property real contextMenuItemTextPreferredWidth: 152
|
||||||
property real contextMenuItemTextMaxWidth: 182
|
property real contextMenuItemTextMaxWidth: 182
|
||||||
property int participantCallInStatusViewWidth: 175
|
property int participantCallInStatusViewWidth: 175
|
||||||
property int participantCallInStatusViewHeight: 300
|
property int participantCallInStatusViewHeight: 300
|
||||||
|
|
Loading…
Add table
Reference in a new issue