aboutsummaryrefslogtreecommitdiffstats
path: root/src/activitypub/apattachment.cpp
diff options
context:
space:
mode:
authorConfuSomu2024-01-20 21:57:39 -0500
committerConfuSomu2024-01-20 21:57:39 -0500
commit5aac009e969cc3bd15c484ba3437348cb7a4d186 (patch)
tree96cff55a273b9de31d639b00f7139110946ce1b6 /src/activitypub/apattachment.cpp
parent328c9b166e9d623cd1b80c7ae064baf6172da58f (diff)
downloadActorViewer-5aac009e969cc3bd15c484ba3437348cb7a4d186.tar
ActorViewer-5aac009e969cc3bd15c484ba3437348cb7a4d186.tar.gz
ActorViewer-5aac009e969cc3bd15c484ba3437348cb7a4d186.zip
Implemement Actor information tab
This class still has improvements to be made, but it works and I am satisfied with it!
Diffstat (limited to 'src/activitypub/apattachment.cpp')
-rw-r--r--src/activitypub/apattachment.cpp26
1 files changed, 26 insertions, 0 deletions
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 <QFileInfo>
+#include <QDebug>
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;