2017-05-16 20:46:45 +02:00
|
|
|
#pragma once
|
2017-04-06 01:06:42 +02:00
|
|
|
|
2020-05-13 06:35:26 +02:00
|
|
|
#include <QHash>
|
2019-11-09 03:06:10 +01:00
|
|
|
#include <QQuickView>
|
|
|
|
#include <QQuickWidget>
|
2017-04-13 03:11:22 +02:00
|
|
|
#include <QSharedPointer>
|
2019-11-09 03:06:10 +01:00
|
|
|
#include <QWidget>
|
2017-04-06 01:06:42 +02:00
|
|
|
|
2019-12-05 15:31:53 +01:00
|
|
|
#include <mtx/common.hpp>
|
2019-11-09 03:06:10 +01:00
|
|
|
#include <mtx/responses.hpp>
|
2017-11-15 17:38:50 +01:00
|
|
|
|
2019-11-09 03:06:10 +01:00
|
|
|
#include "Cache.h"
|
2020-03-13 21:05:18 +01:00
|
|
|
#include "DeviceVerificationFlow.h"
|
2019-11-09 03:06:10 +01:00
|
|
|
#include "Logging.h"
|
|
|
|
#include "TimelineModel.h"
|
2019-06-14 04:33:04 +02:00
|
|
|
#include "Utils.h"
|
2020-05-13 06:35:26 +02:00
|
|
|
#include "emoji/EmojiModel.h"
|
|
|
|
#include "emoji/Provider.h"
|
2019-06-14 04:33:04 +02:00
|
|
|
|
2019-11-09 03:06:10 +01:00
|
|
|
class MxcImageProvider;
|
2020-03-01 19:55:43 +01:00
|
|
|
class BlurhashProvider;
|
2019-11-09 03:06:10 +01:00
|
|
|
class ColorImageProvider;
|
2020-01-27 15:59:25 +01:00
|
|
|
class UserSettings;
|
2017-04-06 01:06:42 +02:00
|
|
|
|
2020-06-17 20:28:35 +02:00
|
|
|
class DeviceVerificationList : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
Q_INVOKABLE void add(QString tran_id);
|
|
|
|
Q_INVOKABLE void remove(QString tran_id);
|
|
|
|
Q_INVOKABLE bool exist(QString tran_id);
|
2020-07-05 18:03:27 +02:00
|
|
|
signals:
|
|
|
|
void updateProfile(QString userId);
|
2020-06-17 20:28:35 +02:00
|
|
|
|
|
|
|
private:
|
2020-06-24 19:35:32 +02:00
|
|
|
QVector<QString> deviceVerificationList;
|
2020-06-17 20:28:35 +02:00
|
|
|
};
|
|
|
|
|
2019-11-09 03:06:10 +01:00
|
|
|
class TimelineViewManager : public QObject
|
2017-04-06 01:06:42 +02:00
|
|
|
{
|
2017-08-26 10:33:26 +02:00
|
|
|
Q_OBJECT
|
2017-04-06 01:06:42 +02:00
|
|
|
|
2019-11-09 03:06:10 +01:00
|
|
|
Q_PROPERTY(
|
|
|
|
TimelineModel *timeline MEMBER timeline_ READ activeTimeline NOTIFY activeTimelineChanged)
|
2019-11-10 00:30:02 +01:00
|
|
|
Q_PROPERTY(
|
|
|
|
bool isInitialSync MEMBER isInitialSync_ READ isInitialSync NOTIFY initialSyncChanged)
|
2017-10-01 18:49:36 +02:00
|
|
|
|
2019-11-09 03:06:10 +01:00
|
|
|
public:
|
2020-02-04 04:58:43 +01:00
|
|
|
TimelineViewManager(QSharedPointer<UserSettings> userSettings, QWidget *parent = nullptr);
|
2019-11-09 03:06:10 +01:00
|
|
|
QWidget *getWidget() const { return container; }
|
2017-10-01 18:49:36 +02:00
|
|
|
|
2017-12-04 17:41:19 +01:00
|
|
|
void sync(const mtx::responses::Rooms &rooms);
|
2019-11-09 03:06:10 +01:00
|
|
|
void addRoom(const QString &room_id);
|
2017-10-07 19:50:32 +02:00
|
|
|
|
2019-11-09 03:06:10 +01:00
|
|
|
void clearAll() { models.clear(); }
|
|
|
|
|
|
|
|
Q_INVOKABLE TimelineModel *activeTimeline() const { return timeline_; }
|
2019-11-10 00:30:02 +01:00
|
|
|
Q_INVOKABLE bool isInitialSync() const { return isInitialSync_; }
|
2019-12-03 02:26:41 +01:00
|
|
|
Q_INVOKABLE void openImageOverlay(QString mxcUrl, QString eventId) const;
|
2020-02-20 20:51:07 +01:00
|
|
|
Q_INVOKABLE QColor userColor(QString id, QColor background);
|
2017-04-11 21:48:02 +02:00
|
|
|
|
2020-06-24 16:24:22 +02:00
|
|
|
Q_INVOKABLE QString userPresence(QString id) const;
|
2020-06-08 01:45:24 +02:00
|
|
|
Q_INVOKABLE QString userStatus(QString id) const;
|
|
|
|
|
2017-04-15 01:56:04 +02:00
|
|
|
signals:
|
2017-11-23 23:10:58 +01:00
|
|
|
void clearRoomMessageCount(QString roomid);
|
2019-11-09 03:06:10 +01:00
|
|
|
void updateRoomsLastMessage(QString roomid, const DescInfo &info);
|
|
|
|
void activeTimelineChanged(TimelineModel *timeline);
|
2019-11-10 00:30:02 +01:00
|
|
|
void initialSyncChanged(bool isInitialSync);
|
2020-01-28 05:28:11 +01:00
|
|
|
void replyingEventChanged(QString replyingEvent);
|
2020-02-05 00:17:14 +01:00
|
|
|
void replyClosed();
|
2020-06-20 14:20:43 +02:00
|
|
|
void newDeviceVerificationRequest(DeviceVerificationFlow *flow,
|
|
|
|
QString transactionId,
|
|
|
|
QString userId,
|
|
|
|
QString deviceId);
|
2017-04-15 01:56:04 +02:00
|
|
|
|
2017-04-06 01:06:42 +02:00
|
|
|
public slots:
|
2018-07-17 22:50:18 +02:00
|
|
|
void updateReadReceipts(const QString &room_id, const std::vector<QString> &event_ids);
|
2018-06-28 15:16:43 +02:00
|
|
|
void initWithMessages(const std::map<QString, mtx::responses::Timeline> &msgs);
|
2018-06-09 15:03:14 +02:00
|
|
|
|
2017-08-26 10:33:26 +02:00
|
|
|
void setHistoryView(const QString &room_id);
|
2019-11-09 03:06:10 +01:00
|
|
|
void updateColorPalette();
|
2020-07-20 00:42:48 +02:00
|
|
|
void queueReactionMessage(const QString &reactedEvent, const QString &reactionKey);
|
2020-04-13 16:22:30 +02:00
|
|
|
void queueTextMessage(const QString &msg);
|
2017-11-15 17:38:50 +01:00
|
|
|
void queueEmoteMessage(const QString &msg);
|
2018-01-10 08:52:59 +01:00
|
|
|
void queueImageMessage(const QString &roomid,
|
|
|
|
const QString &filename,
|
2019-12-14 17:08:36 +01:00
|
|
|
const std::optional<mtx::crypto::EncryptedFile> &file,
|
2018-02-18 21:52:31 +01:00
|
|
|
const QString &url,
|
|
|
|
const QString &mime,
|
2018-07-10 22:31:51 +02:00
|
|
|
uint64_t dsize,
|
2020-01-12 16:39:01 +01:00
|
|
|
const QSize &dimensions,
|
2020-04-13 16:22:30 +02:00
|
|
|
const QString &blurhash);
|
2018-02-18 21:52:31 +01:00
|
|
|
void queueFileMessage(const QString &roomid,
|
|
|
|
const QString &filename,
|
2019-12-14 17:08:36 +01:00
|
|
|
const std::optional<mtx::crypto::EncryptedFile> &file,
|
2018-02-18 21:52:31 +01:00
|
|
|
const QString &url,
|
|
|
|
const QString &mime,
|
2020-04-13 16:22:30 +02:00
|
|
|
uint64_t dsize);
|
2018-02-18 21:52:31 +01:00
|
|
|
void queueAudioMessage(const QString &roomid,
|
|
|
|
const QString &filename,
|
2019-12-14 17:08:36 +01:00
|
|
|
const std::optional<mtx::crypto::EncryptedFile> &file,
|
2018-02-18 21:52:31 +01:00
|
|
|
const QString &url,
|
|
|
|
const QString &mime,
|
2020-04-13 16:22:30 +02:00
|
|
|
uint64_t dsize);
|
2018-02-18 21:52:31 +01:00
|
|
|
void queueVideoMessage(const QString &roomid,
|
|
|
|
const QString &filename,
|
2019-12-14 17:08:36 +01:00
|
|
|
const std::optional<mtx::crypto::EncryptedFile> &file,
|
2018-02-18 21:52:31 +01:00
|
|
|
const QString &url,
|
|
|
|
const QString &mime,
|
2020-04-13 16:22:30 +02:00
|
|
|
uint64_t dsize);
|
2020-04-23 01:52:30 +02:00
|
|
|
void updateEncryptedDescriptions();
|
2017-04-13 03:11:22 +02:00
|
|
|
|
2017-04-06 01:06:42 +02:00
|
|
|
private:
|
2019-11-09 03:06:10 +01:00
|
|
|
#ifdef USE_QUICK_VIEW
|
|
|
|
QQuickView *view;
|
|
|
|
#else
|
|
|
|
QQuickWidget *view;
|
|
|
|
#endif
|
|
|
|
QWidget *container;
|
2019-11-10 00:30:02 +01:00
|
|
|
|
2019-11-09 03:06:10 +01:00
|
|
|
MxcImageProvider *imgProvider;
|
|
|
|
ColorImageProvider *colorImgProvider;
|
2020-03-01 19:55:43 +01:00
|
|
|
BlurhashProvider *blurhashProvider;
|
2019-11-09 03:06:10 +01:00
|
|
|
|
|
|
|
QHash<QString, QSharedPointer<TimelineModel>> models;
|
2019-11-10 00:30:02 +01:00
|
|
|
TimelineModel *timeline_ = nullptr;
|
2020-05-13 06:35:26 +02:00
|
|
|
|
|
|
|
bool isInitialSync_ = true;
|
2020-01-27 15:59:25 +01:00
|
|
|
|
|
|
|
QSharedPointer<UserSettings> settings;
|
2020-02-20 20:51:07 +01:00
|
|
|
QHash<QString, QColor> userColors;
|
2020-06-17 20:28:35 +02:00
|
|
|
|
|
|
|
DeviceVerificationList *dvList;
|
2017-04-06 01:06:42 +02:00
|
|
|
};
|
2020-06-24 16:24:22 +02:00
|
|
|
Q_DECLARE_METATYPE(mtx::events::collections::DeviceEvents)
|