From ec6a35e75bbd86247ea6700d4018cb49e42675d2 Mon Sep 17 00:00:00 2001 From: Simon Redman Date: Mon, 17 Jun 2024 02:00:41 +0000 Subject: [PATCH] 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) --- smsapp/conversationlistmodel.cpp | 2 +- smsapp/qml/ConversationList.qml | 29 +++++++++++++++-------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/smsapp/conversationlistmodel.cpp b/smsapp/conversationlistmodel.cpp index db0fbc3d0..95c213de9 100644 --- a/smsapp/conversationlistmodel.cpp +++ b/smsapp/conversationlistmodel.cpp @@ -184,7 +184,7 @@ void ConversationListModel::createRowFromMessage(const ConversationMessage &mess const QIcon displayIcon = SmsHelper::getIconForAddresses(rawAddresses); item->setText(displayNames); - item->setData(displayIcon.name(), Qt::DecorationRole); + item->setData(displayIcon, Qt::DecorationRole); item->setData(message.threadID(), ConversationIdRole); item->setData(rawAddresses[0].address(), SenderRole); } diff --git a/smsapp/qml/ConversationList.qml b/smsapp/qml/ConversationList.qml index f39894d04..ff72d1260 100644 --- a/smsapp/qml/ConversationList.qml +++ b/smsapp/qml/ConversationList.qml @@ -191,12 +191,11 @@ Kirigami.ScrollablePage delegate: ItemDelegate { id: listItem text: displayNames - icon.name: decoration width: view.width required property string displayNames required property string toolTip - required property string decoration + required property var decoration required property var attachmentPreview required property int index required property var addresses @@ -223,9 +222,23 @@ Kirigami.ScrollablePage // Note: Width calcs to account for scrollbar coming and going contentItem: RowLayout { + id: contentRow spacing: Kirigami.Units.smallSpacing 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 { id: thumbnailItem source: { @@ -240,21 +253,9 @@ Kirigami.ScrollablePage return listItem.attachmentPreview; } - width: Kirigami.Units.iconSizes.small - height: Kirigami.Units.iconSizes.small - 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 - } } - } } }