From 9c60bc8ce4a0990c228d2cd746791b88c41532b8 Mon Sep 17 00:00:00 2001 From: ConfuSomu Date: Thu, 24 Aug 2023 18:43:15 -0400 Subject: 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. --- src/mainwindow.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/mainwindow.cpp') 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 +#include #include #include #include @@ -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(); -- cgit v1.2.3-54-g00ecf