aboutsummaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/tab_actor_info.cpp49
-rw-r--r--src/widgets/tab_actor_info.h27
-rw-r--r--src/widgets/tab_actor_info.ui79
3 files changed, 155 insertions, 0 deletions
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 <QTableWidgetItem>
+#include <QDebug>
+
+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));
+ }
+}
diff --git a/src/widgets/tab_actor_info.h b/src/widgets/tab_actor_info.h
new file mode 100644
index 0000000..a1dd84f
--- /dev/null
+++ b/src/widgets/tab_actor_info.h
@@ -0,0 +1,27 @@
+#pragma once
+#include <QWidget>
+#include "src/activitypub/apactor.h"
+#include "src/archive/base_archive.h"
+
+QT_BEGIN_NAMESPACE
+namespace Ui { class TabActorInfo; }
+QT_END_NAMESPACE
+
+class TabActorInfo : public QWidget {
+ Q_OBJECT
+
+public:
+ TabActorInfo(APActor* actor, QWidget *parent = nullptr);
+ TabActorInfo(Archive* archive, QWidget *parent = nullptr);
+ ~TabActorInfo();
+ // TODO: when clicking/activating avatar image, open it with the user's default image viewer
+
+public slots:
+ // Update displayed information to match Actor
+ void update_ui();
+
+private:
+ Ui::TabActorInfo* ui;
+
+ APActor* actor = nullptr;
+};
diff --git a/src/widgets/tab_actor_info.ui b/src/widgets/tab_actor_info.ui
new file mode 100644
index 0000000..8fb7e21
--- /dev/null
+++ b/src/widgets/tab_actor_info.ui
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>TabActorInfo</class>
+ <widget class="QWidget" name="TabActorInfo">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout" columnminimumwidth="50,0">
+ <item row="0" column="1">
+ <widget class="QLabel" name="displayNameText">
+ <property name="text">
+ <string notr="true">&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:12pt; font-weight:600;&quot;&gt;%1&lt;/span&gt; &lt;span style=&quot; font-size:10pt;&quot;&gt;(@%2)&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QTextBrowser" name="summaryText">
+ <property name="openExternalLinks">
+ <bool>true</bool>
+ </property>
+ <property name="openLinks">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTableWidget" name="attachments">
+ <property name="verticalScrollMode">
+ <enum>QAbstractItemView::ScrollPerPixel</enum>
+ </property>
+ <property name="cornerButtonEnabled">
+ <bool>false</bool>
+ </property>
+ <property name="columnCount">
+ <number>2</number>
+ </property>
+ <attribute name="horizontalHeaderVisible">
+ <bool>false</bool>
+ </attribute>
+ <attribute name="horizontalHeaderStretchLastSection">
+ <bool>true</bool>
+ </attribute>
+ <attribute name="verticalHeaderVisible">
+ <bool>false</bool>
+ </attribute>
+ <column/>
+ <column/>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="avatarImage">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string notr="true">aaaaa</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>