From 5aac009e969cc3bd15c484ba3437348cb7a4d186 Mon Sep 17 00:00:00 2001 From: ConfuSomu Date: Sat, 20 Jan 2024 21:57:39 -0500 Subject: Implemement Actor information tab This class still has improvements to be made, but it works and I am satisfied with it! --- src/activitypub/apattachment.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/activitypub/apattachment.cpp') diff --git a/src/activitypub/apattachment.cpp b/src/activitypub/apattachment.cpp index 0589291..342ea21 100644 --- a/src/activitypub/apattachment.cpp +++ b/src/activitypub/apattachment.cpp @@ -1,5 +1,6 @@ #include "apattachment.h" #include +#include APAttachment::APAttachment() {} @@ -28,6 +29,31 @@ QString APAttachment::get_html_render(HtmlRenderDetails info) { return html; } +const QPixmap& APAttachment::get_pixmap(int width, int height) { + if (pixmap) return *pixmap; + + if (width > 0 or height > 0) { + QPixmap image(path_url); + + /* proportionality rule: + * width image width + * ----- = ----------- + * height image height + */ + if (height == 0) + height = (width * image.height()) / image.width(); + else if (width == 0) + width = (height * image.width()) / image.height(); + + pixmap = new QPixmap(image.scaled(QSize(width, height))); + } else { + pixmap = new QPixmap; + if (not pixmap->load(path_url)) + qDebug() << "failed to load" << path_url; + } + return *pixmap; +} + QString APAttachmentList::get_html_render(HtmlRenderDetails render_info) { QString html; -- cgit v1.2.3-54-g00ecf