From fafdc293f4f875e09ca90faeae6dfac962f144b2 Mon Sep 17 00:00:00 2001 From: ConfuSomu Date: Fri, 6 Jan 2023 17:15:12 -0500 Subject: Dynamically resize image depending on widget size --- src/archive_parser.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/archive_parser.cpp') diff --git a/src/archive_parser.cpp b/src/archive_parser.cpp index 98056e2..27d059b 100644 --- a/src/archive_parser.cpp +++ b/src/archive_parser.cpp @@ -201,7 +201,7 @@ QString get_html_status_object_as_list(QJsonObject obj, QString element_name) { return text; } -QString Archive::get_html_status_attachments(QJsonValueRef attachments_ref) { +QString Archive::get_html_status_attachments(QJsonValueRef attachments_ref, int text_zone_width) { QString text; QJsonArray attachments = attachments_ref.toArray(); @@ -221,7 +221,8 @@ QString Archive::get_html_status_attachments(QJsonValueRef attachments_ref) { } if (attachment.contains("mediaType") and attachment["mediaType"].toString().startsWith("image/")) - att_html.replace("{{img-width}}", "440"); + // dynamically resize image based on the display widget size to avoid horizontal scrolling + att_html.replace("{{img-width}}", QString::number((float)text_zone_width - (float)text_zone_width*0.15)); else att_html.replace("{{img-width}}", "0"); @@ -236,7 +237,7 @@ QString Archive::get_html_status_attachments(QJsonValueRef attachments_ref) { } // status_index is assumed to be a valid index -QString Archive::get_html_status_info(int status_index) { +QString Archive::get_html_status_info(int status_index, int text_zone_width) { QString info_text(*get_html_status_info_template()); QJsonObject obj = outbox_items->at(status_index).toObject(); @@ -262,7 +263,7 @@ QString Archive::get_html_status_info(int status_index) { info_text.replace("{{summary}}", summary_text); } - info_text.replace("{{attachment-div}}", get_html_status_attachments(activity["attachment"])); + info_text.replace("{{attachment-div}}", get_html_status_attachments(activity["attachment"], text_zone_width)); if (activity.contains("url") and activity["url"].isString()) info_text.replace("{{url-status}}", activity["url"].toString()); -- cgit v1.2.3-54-g00ecf