Link Previews

Uses Matrix's preview API to generate embedded link previews.

Only title and description for now.

![image](/uploads/2c5d632480073fe54345cdbe22ea54dc/image.png)
This commit is contained in:
Bharadwaj Raju
2022-09-22 15:42:53 +00:00
committed by Tobias Fella
parent 53b9f42399
commit 37780c2e3b
8 changed files with 196 additions and 4 deletions

46
src/linkpreviewer.h Normal file
View File

@@ -0,0 +1,46 @@
// SPDX-FileCopyrightText: 2022 Bharadwaj Raju <bharadwaj.raju777@protonmail.com>
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-or-later OR LicenseRef-KDE-Accepted-GPL
#pragma once
#include <connection.h>
#include <csapi/content-repo.h>
#include <QObject>
using namespace Quotient;
class LinkPreviewer : public QObject
{
Q_OBJECT
Q_PROPERTY(bool loaded READ loaded NOTIFY loadedChanged)
Q_PROPERTY(QString title READ title NOTIFY titleChanged)
Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
Q_PROPERTY(QString imageSource READ imageSource NOTIFY imageSourceChanged)
Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged)
public:
explicit LinkPreviewer(QObject *parent = nullptr);
[[nodiscard]] bool loaded() const;
[[nodiscard]] QString title() const;
[[nodiscard]] QString description() const;
[[nodiscard]] QString imageSource() const;
[[nodiscard]] QUrl url() const;
void setUrl(QUrl);
private:
bool m_loaded;
QString m_title;
QString m_description;
QString m_imageSource;
QUrl m_url;
Q_SIGNALS:
void loadedChanged();
void titleChanged();
void descriptionChanged();
void imageSourceChanged();
void urlChanged();
};