Fix SMS app icons and thumbnails

## Summary

Due to the difficult-to-test Qt5 -> Qt6 transition, there were some GUI errors with the SMS app:
- Contact photos were missing
- Attachment previews, if present, were in the place where the contact photo should be

This also takes a shot at fixing the long-standing issue that attachment previews were shown much taller than the row item, drawing over the items above and below. 

## Test Plan

### Before:
As in description, the conversations list items were not correct.

![image](/uploads/f68b662fecd6a4826986ede6e8191470/image.png)

### After:
Contact photos are shown to the left of the text preview, attachment preview, if present, is shown to the far right.

![image](/uploads/95f2b4d6e6ff26371a2f36d97fc3f52b/image.png)
This commit is contained in:
Simon Redman 2024-06-17 02:00:41 +00:00
parent 846b584f5c
commit ec6a35e75b
2 changed files with 16 additions and 15 deletions

View file

@ -184,7 +184,7 @@ void ConversationListModel::createRowFromMessage(const ConversationMessage &mess
const QIcon displayIcon = SmsHelper::getIconForAddresses(rawAddresses); const QIcon displayIcon = SmsHelper::getIconForAddresses(rawAddresses);
item->setText(displayNames); item->setText(displayNames);
item->setData(displayIcon.name(), Qt::DecorationRole); item->setData(displayIcon, Qt::DecorationRole);
item->setData(message.threadID(), ConversationIdRole); item->setData(message.threadID(), ConversationIdRole);
item->setData(rawAddresses[0].address(), SenderRole); item->setData(rawAddresses[0].address(), SenderRole);
} }

View file

@ -191,12 +191,11 @@ Kirigami.ScrollablePage
delegate: ItemDelegate { delegate: ItemDelegate {
id: listItem id: listItem
text: displayNames text: displayNames
icon.name: decoration
width: view.width width: view.width
required property string displayNames required property string displayNames
required property string toolTip required property string toolTip
required property string decoration required property var decoration
required property var attachmentPreview required property var attachmentPreview
required property int index required property int index
required property var addresses required property var addresses
@ -223,9 +222,23 @@ Kirigami.ScrollablePage
// Note: Width calcs to account for scrollbar coming and going // Note: Width calcs to account for scrollbar coming and going
contentItem: RowLayout { contentItem: RowLayout {
id: contentRow
spacing: Kirigami.Units.smallSpacing spacing: Kirigami.Units.smallSpacing
implicitWidth: view.width - Kirigami.Units.largeSpacing implicitWidth: view.width - Kirigami.Units.largeSpacing
Kirigami.Icon {
id: contactIcon
source: listItem.decoration
}
// Set width here to force elide and account for scrollbar
KirigamiDelegates.TitleSubtitle {
title: listItem.text
subtitle: listItem.toolTip
elide: Text.ElideRight
Layout.fillWidth: true
}
Kirigami.Icon { Kirigami.Icon {
id: thumbnailItem id: thumbnailItem
source: { source: {
@ -240,21 +253,9 @@ Kirigami.ScrollablePage
return listItem.attachmentPreview; return listItem.attachmentPreview;
} }
width: Kirigami.Units.iconSizes.small
height: Kirigami.Units.iconSizes.small
visible: source !== undefined visible: source !== undefined
} }
// Set width here to force elide and account for scrollbar
KirigamiDelegates.TitleSubtitle {
title: listItem.text
subtitle: listItem.toolTip
elide: Text.ElideRight
implicitWidth: view.width - Kirigami.Units.largeSpacing*2
}
} }
} }
} }
} }