mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-08-21 07:05:59 +02:00
messagelistview: fix binding loop and simplify typing indicator logic
Removed unnecessary settings.json Change-Id: If2eccb5c918192e33cd4e742a98c43c212eee547
This commit is contained in:
parent
b9c7058b26
commit
978e8d7935
3 changed files with 53 additions and 48 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,6 +3,7 @@ doc/Doxyfile
|
||||||
|
|
||||||
GeneratedFiles/
|
GeneratedFiles/
|
||||||
.vs/
|
.vs/
|
||||||
|
.vscode/
|
||||||
x64/
|
x64/
|
||||||
x86/
|
x86/
|
||||||
[wW]in32/
|
[wW]in32/
|
||||||
|
|
11
.vscode/settings.json
vendored
11
.vscode/settings.json
vendored
|
@ -1,11 +0,0 @@
|
||||||
{
|
|
||||||
"files.associations": {
|
|
||||||
"*.tcc": "cpp",
|
|
||||||
"array": "cpp",
|
|
||||||
"string": "cpp",
|
|
||||||
"string_view": "cpp",
|
|
||||||
"ranges": "cpp",
|
|
||||||
"thread": "cpp",
|
|
||||||
"xstring": "cpp"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -297,43 +297,68 @@ ListView {
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: MessagesAdapter
|
||||||
|
|
||||||
|
function onCurrentConvComposingListChanged () {
|
||||||
|
var typeIndicatorNameTextString = ""
|
||||||
|
var nameList = MessagesAdapter.currentConvComposingList
|
||||||
|
|
||||||
|
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++) {
|
||||||
|
typeIndicatorNameTextString += nameList[i]
|
||||||
|
|
||||||
|
if (i === nameList.length - 2)
|
||||||
|
typeIndicatorNameTextString += JamiStrings.typeIndicatorAnd
|
||||||
|
else if (i !== nameList.length - 1)
|
||||||
|
typeIndicatorNameTextString += ", "
|
||||||
|
}
|
||||||
|
typeIndicatorNameText.text = typeIndicatorNameTextString
|
||||||
|
typeIndicatorEndingText.text =
|
||||||
|
JamiStrings.typeIndicatorPlural.replace("{}", "")
|
||||||
|
typeIndicatorNameText.calculateWidth()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: typeIndicatorNameText
|
id: typeIndicatorNameText
|
||||||
|
|
||||||
Layout.alignment: Qt.AlignVCenter
|
property int textWidth: 0
|
||||||
Layout.leftMargin: JamiTheme.sbsMessageBasePreferredPadding
|
|
||||||
Layout.preferredWidth: {
|
function calculateWidth () {
|
||||||
var textSize = text ? JamiQmlUtils.getTextBoundingRect(font, text).width : 0
|
if (!text)
|
||||||
|
return 0
|
||||||
|
else {
|
||||||
|
var textSize = JamiQmlUtils.getTextBoundingRect(font, text).width
|
||||||
var typingContentWidth = typingDots.width + typingDots.anchors.leftMargin
|
var typingContentWidth = typingDots.width + typingDots.anchors.leftMargin
|
||||||
+ typeIndicatorNameText.anchors.leftMargin
|
+ typeIndicatorNameText.anchors.leftMargin
|
||||||
+ typeIndicatorEndingText.contentWidth
|
+ typeIndicatorEndingText.contentWidth
|
||||||
return Math.min(typeIndicatorContainer.width - 5 - typingContentWidth, textSize)
|
typeIndicatorNameText.Layout.preferredWidth =
|
||||||
|
Math.min(typeIndicatorContainer.width - 5 - typingContentWidth,
|
||||||
|
textSize)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
Layout.leftMargin: JamiTheme.sbsMessageBasePreferredPadding
|
||||||
|
|
||||||
font.pointSize: 8
|
font.pointSize: 8
|
||||||
font.bold: Font.DemiBold
|
font.bold: Font.DemiBold
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
color: JamiTheme.textColor
|
color: JamiTheme.textColor
|
||||||
text: {
|
|
||||||
var finalText = ""
|
|
||||||
var nameList = MessagesAdapter.currentConvComposingList
|
|
||||||
|
|
||||||
if (nameList.length > 4)
|
|
||||||
return ""
|
|
||||||
if (nameList.length === 1)
|
|
||||||
return nameList[0]
|
|
||||||
|
|
||||||
for (var i = 0; i < nameList.length; i++) {
|
|
||||||
finalText += nameList[i]
|
|
||||||
|
|
||||||
if (i === nameList.length - 2)
|
|
||||||
finalText += JamiStrings.typeIndicatorAnd
|
|
||||||
else if (i !== nameList.length - 1)
|
|
||||||
finalText += ", "
|
|
||||||
}
|
|
||||||
|
|
||||||
return finalText
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
|
@ -343,16 +368,6 @@ ListView {
|
||||||
|
|
||||||
font.pointSize: 8
|
font.pointSize: 8
|
||||||
color: JamiTheme.textColor
|
color: JamiTheme.textColor
|
||||||
text: {
|
|
||||||
var nameList = MessagesAdapter.currentConvComposingList
|
|
||||||
|
|
||||||
if (nameList.length > 4)
|
|
||||||
return JamiStrings.typeIndicatorMax
|
|
||||||
if (nameList.length === 1)
|
|
||||||
return JamiStrings.typeIndicatorSingle.replace("{}", "")
|
|
||||||
|
|
||||||
return JamiStrings.typeIndicatorPlural.replace("{}", "")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue