Commit 9b757216 authored by Simon Redman's avatar Simon Redman
Browse files

[SMS App] Improve placeholder messages when the most-recent message has an attachment body

parent 64124fb3
Pipeline #34195 passed with stage
in 21 minutes and 57 seconds
......@@ -184,14 +184,24 @@ void ConversationListModel::createRowFromMessage(const ConversationMessage& mess
item->setData(rawAddresses[0].address(), SenderRole);
}
// TODO: Upgrade to support other kinds of media
// Get the body that we should display
QString displayBody;
if (message.containsTextBody()) {
displayBody = message.body();
} else if (message.containsAttachment()) {
const QString mimeType = message.attachments().last().mimeType();
const QString type = QStringLiteral("\"") + mimeType.left(mimeType.indexOf(QStringLiteral("/"))) + QStringLiteral(" file\"");
QString type;
if (mimeType.startsWith(QStringLiteral("image"))) {
type = i18nc("Used as a text placeholder when the most-recent message is an image", "Picture");
}
else if (mimeType.startsWith(QStringLiteral("video"))) {
type = i18nc("Used as a text placeholder when the most-recent message is a video", "Video");
} else {
// Craft a somewhat-descriptive string, like "pdf file"
type = i18nc("Used as a text placeholder when the most-recent message is an arbitrary attachment, resulting in something like \"pdf file\"",
"% file",
mimeType.right(mimeType.indexOf(QStringLiteral("/"))));
}
displayBody = type;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment