Skip to content
Snippets Groups Projects
Commit 978e8d79 authored by Ming Rui Zhang's avatar Ming Rui Zhang Committed by Sébastien Blin
Browse files

messagelistview: fix binding loop and simplify typing indicator logic

Removed unnecessary settings.json

Change-Id: If2eccb5c918192e33cd4e742a98c43c212eee547
parent b9c7058b
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@ doc/Doxyfile
GeneratedFiles/
.vs/
.vscode/
x64/
x86/
[wW]in32/
......
{
"files.associations": {
"*.tcc": "cpp",
"array": "cpp",
"string": "cpp",
"string_view": "cpp",
"ranges": "cpp",
"thread": "cpp",
"xstring": "cpp"
}
}
\ No newline at end of file
......@@ -297,62 +297,77 @@ ListView {
Layout.alignment: Qt.AlignVCenter
}
Text {
id: typeIndicatorNameText
Layout.alignment: Qt.AlignVCenter
Layout.leftMargin: JamiTheme.sbsMessageBasePreferredPadding
Layout.preferredWidth: {
var textSize = text ? JamiQmlUtils.getTextBoundingRect(font, text).width : 0
var typingContentWidth = typingDots.width + typingDots.anchors.leftMargin
+ typeIndicatorNameText.anchors.leftMargin
+ typeIndicatorEndingText.contentWidth
return Math.min(typeIndicatorContainer.width - 5 - typingContentWidth, textSize)
}
Connections {
target: MessagesAdapter
font.pointSize: 8
font.bold: Font.DemiBold
elide: Text.ElideRight
color: JamiTheme.textColor
text: {
var finalText = ""
function onCurrentConvComposingListChanged () {
var typeIndicatorNameTextString = ""
var nameList = MessagesAdapter.currentConvComposingList
if (nameList.length > 4)
return ""
if (nameList.length === 1)
return nameList[0]
if (nameList.length > 4) {
typeIndicatorNameText.text = ""
typeIndicatorEndingText.text = JamiStrings.typeIndicatorMax
typeIndicatorNameText.calculateWidth()
return
}
if (nameList.length === 1) {
typeIndicatorNameText.text = nameList[0]
typeIndicatorEndingText.text =
JamiStrings.typeIndicatorSingle.replace("{}", "")
typeIndicatorNameText.calculateWidth()
return
}
for (var i = 0; i < nameList.length; i++) {
finalText += nameList[i]
typeIndicatorNameTextString += nameList[i]
if (i === nameList.length - 2)
finalText += JamiStrings.typeIndicatorAnd
typeIndicatorNameTextString += JamiStrings.typeIndicatorAnd
else if (i !== nameList.length - 1)
finalText += ", "
typeIndicatorNameTextString += ", "
}
return finalText
typeIndicatorNameText.text = typeIndicatorNameTextString
typeIndicatorEndingText.text =
JamiStrings.typeIndicatorPlural.replace("{}", "")
typeIndicatorNameText.calculateWidth()
}
}
Text {
id: typeIndicatorEndingText
id: typeIndicatorNameText
property int textWidth: 0
function calculateWidth () {
if (!text)
return 0
else {
var textSize = JamiQmlUtils.getTextBoundingRect(font, text).width
var typingContentWidth = typingDots.width + typingDots.anchors.leftMargin
+ typeIndicatorNameText.anchors.leftMargin
+ typeIndicatorEndingText.contentWidth
typeIndicatorNameText.Layout.preferredWidth =
Math.min(typeIndicatorContainer.width - 5 - typingContentWidth,
textSize)
}
}
Layout.alignment: Qt.AlignVCenter
Layout.leftMargin: JamiTheme.sbsMessageBasePreferredPadding
font.pointSize: 8
font.bold: Font.DemiBold
elide: Text.ElideRight
color: JamiTheme.textColor
text: {
var nameList = MessagesAdapter.currentConvComposingList
}
if (nameList.length > 4)
return JamiStrings.typeIndicatorMax
if (nameList.length === 1)
return JamiStrings.typeIndicatorSingle.replace("{}", "")
Text {
id: typeIndicatorEndingText
return JamiStrings.typeIndicatorPlural.replace("{}", "")
}
Layout.alignment: Qt.AlignVCenter
font.pointSize: 8
color: JamiTheme.textColor
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment