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/widgets/tab_actor_info.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/widgets/tab_actor_info.cpp (limited to 'src/widgets/tab_actor_info.cpp') diff --git a/src/widgets/tab_actor_info.cpp b/src/widgets/tab_actor_info.cpp new file mode 100644 index 0000000..79630df --- /dev/null +++ b/src/widgets/tab_actor_info.cpp @@ -0,0 +1,49 @@ +#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); + + actor = archive->get_main_actor(); + qDebug() << actor; + update_ui(); +} + +TabActorInfo::~TabActorInfo() { + if (actor) delete actor; + delete ui; +} + +// TODO: do this in another thread, like for status_info +void TabActorInfo::update_ui() { + if (not actor) 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())); + // TODO: set header as top of background of widget + // Affiche le nom et la description fonctionne sans problèmes + + 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)); + } +} -- cgit v1.2.3-54-g00ecf