aboutsummaryrefslogtreecommitdiffstats
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
authorConfuSomu2023-08-24 18:43:15 -0400
committerConfuSomu2023-08-24 19:35:58 -0400
commit9c60bc8ce4a0990c228d2cd746791b88c41532b8 (patch)
treef6e7d56422f95f8202980a87866f0d798c199f47 /src/mainwindow.cpp
parente625d3fcca7c735ed98570bc1acbcaa840541e61 (diff)
downloadActorViewer-9c60bc8ce4a0990c228d2cd746791b88c41532b8.tar
ActorViewer-9c60bc8ce4a0990c228d2cd746791b88c41532b8.tar.gz
ActorViewer-9c60bc8ce4a0990c228d2cd746791b88c41532b8.zip
Implement basic Mastodon API support
Implement support for OAuth 2.0 code entry, which is then used to retrieve a token that is stored in the application's settings. Authentification allowed the implementation of a basic "get post from URL" feature mostly made for testing.
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index c6203d4..4ab0bb2 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -1,12 +1,15 @@
#include "mainwindow.h"
#include "./ui_mainwindow.h"
+#include "src/activitypub/appost.h"
#include "src/archive/base_archive.h"
#include "src/finddialog.h"
#include "src/list_item.h"
#include "src/command_line.h"
#include "src/settingsdialog.h"
+#include "src/net/instance.h"
#include <QFileDialog>
+#include <QInputDialog>
#include <QMessageBox>
#include <QRandomGenerator>
#include <QClipboard>
@@ -148,6 +151,22 @@ void MainWindow::set_search_text(const QString &text) {
ui->textInputSearch->setText(text);
}
+void MainWindow::on_actionOpen_URL_triggered(bool checked) {
+ bool ok;
+ QString url = QInputDialog::getText(this, tr("Open status from URL"), tr("Status URL:"), QLineEdit::Normal, "https://…", &ok);
+
+ // TODO: Move all of this to another thread
+ // TODO: Reuse the Instance object
+ // Really hacky code but works as a PoC and allows testing
+ if (ok and not url.isEmpty()) {
+ Instance* instance = Instance::create_instance();
+ APPost* post = instance->get_post_from_url(url);
+ QString html = post->get_html_render({ui->statusInfoText->width(), &locale_context});
+ ui->statusInfoText->setHtml(html);
+ delete instance; instance = nullptr;
+ } else return;
+}
+
void MainWindow::relist_statuses() {
if (data_archive) {
ui->listWidget->clear();