Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Network
KDE Connect
Commits
9b757216
Commit
9b757216
authored
Sep 12, 2020
by
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
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
smsapp/conversationlistmodel.cpp
View file @
9b757216
...
...
@@ -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
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment