#include "tab_actor_info.h" #include "ui_tab_actor_info.h" #include "src/activitypub/apactor.h" #include "src/archive/base_archive.h" #include #include TabActorInfo::TabActorInfo(APActor* actor, QWidget* parent) : QWidget(parent), ui(new Ui::TabActorInfo), actor(actor) { ui->setupUi(this); ui->gridLayout->setContentsMargins(0, 0, 0, 0); update_ui(); } TabActorInfo::TabActorInfo(Archive* archive, QWidget* parent) : QWidget(parent), ui(new Ui::TabActorInfo) { ui->setupUi(this); ui->gridLayout->setContentsMargins(0, 0, 0, 0); if (archive) actor = archive->get_main_actor(); update_ui(); } TabActorInfo::~TabActorInfo() { delete ui; } // TODO: do this in another thread, like for status_info void TabActorInfo::update_ui() { if (not actor) { ui->displayNameText->setText(QStringLiteral("

%1

").arg(tr("Failed to display Actor"))); ui->avatarImage->setText(""); return; } ui->displayNameText->setText(ui->displayNameText->text().arg(actor->name).arg(actor->username)); ui->summaryText->setHtml(actor->summary); ui->avatarImage->setPixmap(*actor->avatar->get_pixmap(ui->avatarImage->size().width())); int row = 0; for (APPropertyValue prop : actor->table) { ui->attachments->insertRow(row); ui->attachments->setItem(row, 0, new QTableWidgetItem(prop.key)); ui->attachments->setItem(row++, 1, new QTableWidgetItem(prop.value)); } } void TabActorInfo::paintEvent(QPaintEvent* event) { QPainter painter(this); if (actor and actor->header) { painter.setOpacity(0.75); auto &widget = *(ui->displayNameText); std::shared_ptr pixmap = actor->header->get_pixmap(widget.width()); QPoint centre(widget.width() / 2 - pixmap->width() / 2, widget.height() / 2 - pixmap->height() / 2); QRect source( QPoint(0, abs(widget.height() - pixmap->height()) / 2), QPoint(pixmap->width(), abs(widget.height() - pixmap->height()) / 2 + widget.height()) ); painter.drawPixmap(widget.pos(), *pixmap, source); painter.setOpacity(1.0); } }