aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorConfuSomu2023-01-06 16:59:36 -0500
committerConfuSomu2023-01-06 16:59:36 -0500
commit1beb256de0a6e0c92f2c23b29d0577f282ea165a (patch)
tree504d004d24ca1435a438db88fdbd7e5abda4c512 /src
parent8c202e0719bb417f8e495cd4761799c6a694a26f (diff)
downloadActorViewer-1beb256de0a6e0c92f2c23b29d0577f282ea165a.tar
ActorViewer-1beb256de0a6e0c92f2c23b29d0577f282ea165a.tar.gz
ActorViewer-1beb256de0a6e0c92f2c23b29d0577f282ea165a.zip
Show hyperlink with attachment filename
Only the hyperlink with filename is displayed for non-image attachment file types.
Diffstat (limited to 'src')
-rw-r--r--src/archive_parser.cpp30
-rw-r--r--src/templates/attachment.html3
2 files changed, 19 insertions, 14 deletions
diff --git a/src/archive_parser.cpp b/src/archive_parser.cpp
index 30e613a..98056e2 100644
--- a/src/archive_parser.cpp
+++ b/src/archive_parser.cpp
@@ -210,21 +210,25 @@ QString Archive::get_html_status_attachments(QJsonValueRef attachments_ref) {
QString att_html(*get_html_status_info_attachment_template());
QJsonObject attachment = attachment_ref.toObject();
- if (attachment.contains("mediaType") and attachment["mediaType"].toString().startsWith("image/")) {
- att_html.replace("{{id}}", QString::number(i));
-
- if (attachment.contains("url")) {
- QString url = attachment["url"].toString();
- QFileInfo path(outbox_filename);
- url.prepend(path.absolutePath());
- att_html.replace("{{path}}", url);
- }
+ att_html.replace("{{id}}", QString::number(i));
+
+ if (attachment.contains("url")) {
+ QString url = attachment["url"].toString();
+ QFileInfo path(outbox_filename);
+ url.prepend(path.absolutePath());
+ att_html.replace("{{path}}", url);
+ att_html.replace("{{filename}}", QFileInfo(url).fileName()); // FIXME: this is ugly
+ }
- if (attachment.contains("name"))
- att_html.replace("{{alt-text}}", attachment["name"].toString());
+ if (attachment.contains("mediaType") and attachment["mediaType"].toString().startsWith("image/"))
+ att_html.replace("{{img-width}}", "440");
+ else
+ att_html.replace("{{img-width}}", "0");
- text.append(att_html);
- }
+ if (attachment.contains("name"))
+ att_html.replace("{{alt-text}}", attachment["name"].toString());
+
+ text.append(att_html);
++i;
}
diff --git a/src/templates/attachment.html b/src/templates/attachment.html
index 4c7731c..33c452a 100644
--- a/src/templates/attachment.html
+++ b/src/templates/attachment.html
@@ -1,4 +1,5 @@
<h2>Attachment {{id}}</h2><br/>
-<img src="{{path}}" style="display:span;float:none;" width="440"/>
+<img src="{{path}}" style="float:none;" width="{{img-width}}"/>
+<p><a href="{{path}}">{{filename}}</a></p>
<p style="text-indent:5px;"><b>Alt:</b> {{alt-text}}</p>
<hr width="80%" />