diff options
author | ConfuSomu | 2023-11-12 00:16:02 -0500 |
---|---|---|
committer | ConfuSomu | 2023-11-12 00:16:02 -0500 |
commit | 8ee7a379bbd8c1e2d7831208308bf11eabcdc79d (patch) | |
tree | 601b9d6e453d0be1acc7a56a3df6f233cc4a73da /src/widgets/status_info.h | |
parent | 80a658f062328ab8b47dc6b2557d274f51278b3a (diff) | |
download | ActorViewer-8ee7a379bbd8c1e2d7831208308bf11eabcdc79d.tar ActorViewer-8ee7a379bbd8c1e2d7831208308bf11eabcdc79d.tar.gz ActorViewer-8ee7a379bbd8c1e2d7831208308bf11eabcdc79d.zip |
Move status info widget to its own widget
It is responsable of processing list items which are given to it, via
signals, and then displaying them on the interface. Making this widget
separate and modular will allow creating more advanced status views that
aren't only HTML-based and that are more intuitive to use.
Diffstat (limited to 'src/widgets/status_info.h')
-rw-r--r-- | src/widgets/status_info.h | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/widgets/status_info.h b/src/widgets/status_info.h new file mode 100644 index 0000000..988f930 --- /dev/null +++ b/src/widgets/status_info.h @@ -0,0 +1,56 @@ +#pragma once +#include <QWidget> +#include <QLocale> +#include <QThread> +#include "./ui_status_info.h" +#include "src/activitypub/apactivity.h" +#include "src/activitypub/apbase.h" +#include "src/list_item.h" + +class StatusInfoWidgetWorker : public QObject { + Q_OBJECT + +public slots: + void process_item(StatusListItem* item); + void process_activity(APActivity* activity); + void set_text_zone_width(int width) {render_info.text_zone_width = width;} + +signals: + void itemProcessed(const QString &html, APActivity* activity = nullptr); + +private: + QLocale locale_context; + HtmlRenderDetails render_info = {0, &locale_context}; +}; + +QT_BEGIN_NAMESPACE +namespace Ui { class StatusInfo; } +QT_END_NAMESPACE + +class StatusInfoWidget : public QWidget { + Q_OBJECT + +public: + StatusInfoWidget(QWidget *parent = nullptr); + ~StatusInfoWidget(); + + void resizeEvent(QResizeEvent* event); + +public slots: + void show_list_item(StatusListItem* status); // Call from GUI thread + void postProcess(const QString &html, APActivity* activity); + +signals: + // These signals are called privetely by StatusInfoWidget + void do_process_item(StatusListItem* item); + void do_process_activity(APActivity* activity); + +private: + Ui::StatusInfo* ui; + QThread worker_thread; + StatusInfoWidgetWorker worker; + + // Used for determining if we are dealing with a new list item or not + StatusListItem* displayed_item = nullptr; + APActivity* displayed_activity = nullptr; +}; |