fix(StatusSearchLocationMenu): fix emoji rendering

- we have a dedicated asset category for them; makes no sense to try to
parse the path to the emoji file and treat it as an (SVG) image
- also fix the signal calls; over time more params were added and not
all the calls were adjusted
- fix selecting the "Chats" category, `model.colorHash.toJson()` is not
something we can do directly in QML :)
- fix group chat images
This commit is contained in:
Lukáš Tinkl 2024-12-12 00:33:45 +01:00 committed by Jonathan Rainville
parent aaa1ac630c
commit cdc2ab1a20
4 changed files with 44 additions and 15 deletions

View File

@ -7,15 +7,28 @@ export base_item
type
SubItem* = ref object of BaseItem
isUserIcon: bool
isImage: bool
colorId: int
colorHash: color_hash_model.Model
position: int
proc initSubItem*(value, text, image, icon, iconColor: string,
isUserIcon: bool = false, position: int, colorId: int = 0, colorHash: seq[ColorHashSegment] = @[]): SubItem =
proc initSubItem*(
value,
text,
image,
icon,
iconColor: string,
isUserIcon: bool,
isImage: bool,
position: int,
lastMessageTimestamp: int,
colorId: int = 0,
colorHash: seq[ColorHashSegment] = @[]
): SubItem =
result = SubItem()
result.setup(value, text, image, icon, iconColor)
result.isUserIcon = isUserIcon
result.isImage = isImage
result.position = position
result.colorId = colorId
result.colorHash = color_hash_model.newModel()
@ -29,6 +42,9 @@ proc `$`*(self: SubItem): string =
value: {self.value},
text: {self.text},
position: {self.position},
lastMessageTimestamp: {self.lastMessageTimestamp},
isUserIcon: {self.isUserIcon},
isImage: {self.isImage},
imageSource: {self.image},
iconName: {self.icon},
iconColor: {self.iconColor},
@ -43,6 +59,7 @@ proc toJsonNode*(self: SubItem): JsonNode =
"iconName": self.icon,
"iconColor": self.iconColor,
"isUserIcon": self.isUserIcon,
"isImage": self.isImage,
"colorId": self.colorId,
"colorHash": self.colorHash.toJson()
}
@ -53,6 +70,9 @@ proc position*(self: SubItem): int =
proc isUserIcon*(self: SubItem): bool =
return self.isUserIcon
proc isImage*(self: SubItem): bool =
return self.isImage
proc colorId*(self: SubItem): int =
return self.colorId

View File

@ -10,6 +10,7 @@ type
Icon
IconColor
IsUserIcon
IsImage
Position
ColorId
ColorHash
@ -58,6 +59,7 @@ QtObject:
SubModelRole.Icon.int:"iconName",
SubModelRole.IconColor.int:"iconColor",
SubModelRole.IsUserIcon.int:"isUserIcon",
SubModelRole.IsImage.int:"isImage",
SubModelRole.Position.int:"position",
SubModelRole.ColorId.int:"colorId",
SubModelRole.ColorHash.int:"colorHash"
@ -86,6 +88,8 @@ QtObject:
result = newQVariant(item.iconColor)
of SubModelRole.IsUserIcon:
result = newQVariant(item.isUserIcon)
of SubModelRole.IsImage:
result = newQVariant(item.isImage)
of SubModelRole.Position:
result = newQVariant(item.position)
of SubModelRole.ColorId:

View File

@ -103,6 +103,7 @@ proc getChatSubItems(self: Module, chats: seq[ChatDto], categories: seq[Category
"",
chatDto.color,
isOneToOneChat,
isImage = chatImage != "",
chatDto.position,
colorId,
colorHash,
@ -122,6 +123,7 @@ proc getChatSubItems(self: Module, chats: seq[ChatDto], categories: seq[Category
"",
chat.color,
isUserIcon = false,
isImage = false,
chatPosition,
))
highestPosition += categoryChats[categoryPosition].len

View File

@ -1,6 +1,6 @@
import QtQuick 2.14
import QtQml 2.14
import QtQuick.Controls 2.14
import QtQuick 2.15
import QtQml 2.15
import QtQuick.Controls 2.15
import Qt.labs.qmlmodels 1.0
@ -24,10 +24,10 @@ StatusMenu {
signal setSearchSelection(string text,
string secondaryText,
string imageSource,
string isIdenticon,
bool isIdenticon,
string iconName,
string iconColor,
var isUserIcon,
bool isUserIcon,
int colorId,
string colorHash)
@ -80,9 +80,12 @@ StatusMenu {
root.setSearchSelection(text,
"",
"",
assetSettings.isIdenticon,
assetSettings.imgIsIdenticon,
assetSettings.name,
assetSettings.color)
assetSettings.color,
model.isUserIcon,
model.colorId,
JSON.stringify(model.colorHash))
root.itemClicked(model.value, "")
}
}
@ -115,7 +118,7 @@ StatusMenu {
readonly property string parentIconName: subMenuDelegate.parentIconName
readonly property string parentImageSource: subMenuDelegate.parentImageSource
readonly property string parentIdenticonColor: subMenuDelegate.parentIdenticonColor
readonly property string parentIsIdenticon: subMenuDelegate.parentIsIdenticon
readonly property bool parentIsIdenticon: subMenuDelegate.parentIsIdenticon
menu: subMenuDelegate
model: SortFilterProxyModel {
@ -129,13 +132,14 @@ StatusMenu {
delegate: StatusSearchPopupMenuItem {
value: model.value
text: model.text
assetSettings.isImage: !!model.imageSource
assetSettings.name: !!StatusQUtils.Emoji.iconSource(model.imageSource) ?
StatusQUtils.Emoji.iconSource(model.imageSource) : model.imageSource
assetSettings.name: model.isImage ? model.imageSource : ""
assetSettings.emoji: !model.isUserIcon ? model.imageSource : ""
assetSettings.color: model.isUserIcon ? Theme.palette.userCustomizationColors[model.colorId] : model.iconColor
assetSettings.bgColor: model.iconColor
assetSettings.charactersLen: model.isUserIcon ? 2 : 1
ringSettings.ringSpecModel: model.colorHash
onTriggered: {
root.resetSearchSelection()
if (menuLoader.parentTitleText === "Chat") {
@ -147,7 +151,7 @@ StatusMenu {
model.iconColor,
model.isUserIcon,
model.colorId,
model.colorHash.toJson())
JSON.stringify(model.colorHash))
} else {
root.setSearchSelection(menuLoader.parentTitleText,
model.text,
@ -168,5 +172,4 @@ StatusMenu {
}
}
}
}