aboutsummaryrefslogtreecommitdiffstats
path: root/src/activitypub/apattachment.cpp
diff options
context:
space:
mode:
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;