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 e4895c0dad
commit 73370a9e52
4 changed files with 44 additions and 15 deletions

View File

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

View File

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

View File

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

View File

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