2021-03-05 00:35:15 +01:00
|
|
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
2022-01-01 04:57:53 +01:00
|
|
|
// SPDX-FileCopyrightText: 2022 Nheko Contributors
|
2021-03-05 00:35:15 +01:00
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
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>
|
2021-07-15 00:26:39 +02:00
|
|
|
#include <QQuickItem>
|
|
|
|
#include <QQuickTextDocument>
|
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>
|
2020-10-27 17:45:28 +01:00
|
|
|
#include <mtx/responses/messages.hpp>
|
2022-06-16 01:19:26 +02:00
|
|
|
|
2022-06-18 01:35:30 +02:00
|
|
|
#include "ReadReceiptsModel.h"
|
2021-06-09 23:52:28 +02:00
|
|
|
#include "timeline/CommunitiesModel.h"
|
2021-12-30 04:54:03 +01:00
|
|
|
#include "timeline/PresenceEmitter.h"
|
2021-05-19 19:34:10 +02:00
|
|
|
#include "timeline/RoomlistModel.h"
|
2022-06-18 01:35:30 +02:00
|
|
|
#include "ui/RoomSettings.h"
|
|
|
|
#include "ui/UserProfile.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;
|
2020-09-03 17:01:58 +02:00
|
|
|
class ChatPage;
|
2021-07-21 13:37:57 +02:00
|
|
|
class ImagePackListModel;
|
2022-06-16 01:19:26 +02:00
|
|
|
class TimelineModel;
|
|
|
|
class CallManager;
|
|
|
|
class VerificationManager;
|
|
|
|
|
|
|
|
namespace mtx::responses {
|
|
|
|
struct Sync;
|
|
|
|
}
|
2017-04-06 01:06:42 +02:00
|
|
|
|
2019-11-09 03:06:10 +01:00
|
|
|
class TimelineViewManager : public QObject
|
2017-04-06 01:06:42 +02:00
|
|
|
{
|
2021-09-18 00:22:33 +02:00
|
|
|
Q_OBJECT
|
2017-04-06 01:06:42 +02:00
|
|
|
|
2021-09-18 00:22:33 +02:00
|
|
|
Q_PROPERTY(
|
|
|
|
bool isInitialSync MEMBER isInitialSync_ READ isInitialSync NOTIFY initialSyncChanged)
|
2022-01-26 02:16:06 +01:00
|
|
|
Q_PROPERTY(bool isConnected READ isConnected NOTIFY isConnectedChanged)
|
2017-10-01 18:49:36 +02:00
|
|
|
|
2019-11-09 03:06:10 +01:00
|
|
|
public:
|
2021-09-18 00:22:33 +02:00
|
|
|
TimelineViewManager(CallManager *callManager, ChatPage *parent = nullptr);
|
2017-10-01 18:49:36 +02:00
|
|
|
|
2021-11-20 22:48:04 +01:00
|
|
|
void sync(const mtx::responses::Sync &sync_);
|
2021-05-19 19:34:10 +02:00
|
|
|
|
2021-10-15 02:44:48 +02:00
|
|
|
VerificationManager *verificationManager() { return verificationManager_; }
|
2017-10-07 19:50:32 +02:00
|
|
|
|
2021-09-18 00:22:33 +02:00
|
|
|
void clearAll() { rooms_->clear(); }
|
2019-11-09 03:06:10 +01:00
|
|
|
|
2021-09-18 00:22:33 +02:00
|
|
|
Q_INVOKABLE bool isInitialSync() const { return isInitialSync_; }
|
2022-01-26 02:16:06 +01:00
|
|
|
bool isConnected() const { return isConnected_; }
|
2022-05-10 03:19:53 +02:00
|
|
|
Q_INVOKABLE void openImageOverlay(TimelineModel *room,
|
|
|
|
QString mxcUrl,
|
|
|
|
QString eventId,
|
|
|
|
double originalWidth,
|
|
|
|
double proportionalHeight);
|
2021-09-18 00:22:33 +02:00
|
|
|
Q_INVOKABLE void openImagePackSettings(QString roomid);
|
2022-01-02 21:46:29 +01:00
|
|
|
Q_INVOKABLE void saveMedia(QString mxcUrl);
|
2021-09-18 00:22:33 +02:00
|
|
|
Q_INVOKABLE QColor userColor(QString id, QColor background);
|
|
|
|
Q_INVOKABLE QString escapeEmoji(QString str) const;
|
|
|
|
Q_INVOKABLE QString htmlEscape(QString str) const { return str.toHtmlEscaped(); }
|
2017-04-11 21:48:02 +02:00
|
|
|
|
2021-09-18 00:22:33 +02:00
|
|
|
Q_INVOKABLE void openRoomMembers(TimelineModel *room);
|
|
|
|
Q_INVOKABLE void openRoomSettings(QString room_id);
|
|
|
|
Q_INVOKABLE void openInviteUsers(QString roomId);
|
|
|
|
Q_INVOKABLE void openGlobalUserProfile(QString userId);
|
2022-03-26 22:28:31 +01:00
|
|
|
Q_INVOKABLE UserProfile *getGlobalUserProfile(QString userId);
|
2021-07-22 00:56:20 +02:00
|
|
|
|
2021-09-18 00:22:33 +02:00
|
|
|
Q_INVOKABLE void focusMessageInput();
|
2020-09-03 17:01:58 +02:00
|
|
|
|
2021-09-18 00:22:33 +02:00
|
|
|
Q_INVOKABLE void fixImageRendering(QQuickTextDocument *t, QQuickItem *i);
|
2021-07-15 00:26:39 +02:00
|
|
|
|
2017-04-15 01:56:04 +02:00
|
|
|
signals:
|
2021-09-18 00:22:33 +02:00
|
|
|
void activeTimelineChanged(TimelineModel *timeline);
|
|
|
|
void initialSyncChanged(bool isInitialSync);
|
2022-01-26 02:16:06 +01:00
|
|
|
void isConnectedChanged(bool state);
|
2021-09-18 00:22:33 +02:00
|
|
|
void replyingEventChanged(QString replyingEvent);
|
|
|
|
void replyClosed();
|
|
|
|
void inviteUsers(QString roomId, QStringList users);
|
|
|
|
void showRoomList();
|
|
|
|
void narrowViewChanged();
|
|
|
|
void focusInput();
|
|
|
|
void openRoomMembersDialog(MemberList *members, TimelineModel *room);
|
|
|
|
void openRoomSettingsDialog(RoomSettings *settings);
|
|
|
|
void openInviteUsersDialog(InviteesModel *invitees);
|
|
|
|
void openProfile(UserProfile *profile);
|
2021-12-13 23:25:42 +01:00
|
|
|
void showImagePackSettings(TimelineModel *room, ImagePackListModel *packlist);
|
2022-03-31 23:34:01 +02:00
|
|
|
void openLeaveRoomDialog(QString roomid, QString reason = "");
|
2022-05-10 03:19:53 +02:00
|
|
|
void showImageOverlay(TimelineModel *room,
|
|
|
|
QString eventId,
|
|
|
|
QString url,
|
|
|
|
double originalWidth,
|
|
|
|
double proportionalHeight);
|
2017-04-15 01:56:04 +02:00
|
|
|
|
2017-04-06 01:06:42 +02:00
|
|
|
public slots:
|
2021-09-18 00:22:33 +02:00
|
|
|
void updateReadReceipts(const QString &room_id, const std::vector<QString> &event_ids);
|
|
|
|
void receivedSessionKey(const std::string &room_id, const std::string &session_id);
|
|
|
|
void initializeRoomlist();
|
|
|
|
|
|
|
|
void showEvent(const QString &room_id, const QString &event_id);
|
|
|
|
|
|
|
|
void updateColorPalette();
|
|
|
|
void queueReply(const QString &roomid, const QString &repliedToEvent, const QString &replyBody);
|
|
|
|
void queueCallMessage(const QString &roomid, const mtx::events::msg::CallInvite &);
|
|
|
|
void queueCallMessage(const QString &roomid, const mtx::events::msg::CallCandidates &);
|
|
|
|
void queueCallMessage(const QString &roomid, const mtx::events::msg::CallAnswer &);
|
|
|
|
void queueCallMessage(const QString &roomid, const mtx::events::msg::CallHangUp &);
|
|
|
|
|
|
|
|
void setVideoCallItem();
|
|
|
|
|
2021-12-29 04:28:08 +01:00
|
|
|
QObject *completerFor(QString completerName, QString roomId = QLatin1String(QLatin1String("")));
|
2021-09-18 00:22:33 +02:00
|
|
|
void forwardMessageToRoom(mtx::events::collections::TimelineEvents *e, QString roomId);
|
|
|
|
|
|
|
|
RoomlistModel *rooms() { return rooms_; }
|
2021-05-28 22:14:59 +02:00
|
|
|
|
2017-04-06 01:06:42 +02:00
|
|
|
private:
|
2022-01-24 00:41:55 +01:00
|
|
|
bool isInitialSync_ = true;
|
2022-01-26 02:16:06 +01:00
|
|
|
bool isConnected_ = true;
|
2020-01-27 15:59:25 +01:00
|
|
|
|
2021-09-18 00:22:33 +02:00
|
|
|
RoomlistModel *rooms_ = nullptr;
|
|
|
|
CommunitiesModel *communities_ = nullptr;
|
2021-05-19 19:34:10 +02:00
|
|
|
|
2021-10-15 02:44:48 +02:00
|
|
|
// don't move this above the rooms_
|
|
|
|
VerificationManager *verificationManager_ = nullptr;
|
2021-12-30 04:54:03 +01:00
|
|
|
PresenceEmitter *presenceEmitter = nullptr;
|
2020-06-17 20:28:35 +02:00
|
|
|
|
2021-11-18 22:33:45 +01:00
|
|
|
QHash<QPair<QString, quint64>, QColor> userColors;
|
2017-04-06 01:06:42 +02:00
|
|
|
};
|
2020-07-17 22:16:30 +02:00
|
|
|
Q_DECLARE_METATYPE(mtx::events::msg::KeyVerificationAccept)
|
|
|
|
Q_DECLARE_METATYPE(mtx::events::msg::KeyVerificationCancel)
|
|
|
|
Q_DECLARE_METATYPE(mtx::events::msg::KeyVerificationDone)
|
|
|
|
Q_DECLARE_METATYPE(mtx::events::msg::KeyVerificationKey)
|
|
|
|
Q_DECLARE_METATYPE(mtx::events::msg::KeyVerificationMac)
|
|
|
|
Q_DECLARE_METATYPE(mtx::events::msg::KeyVerificationReady)
|
|
|
|
Q_DECLARE_METATYPE(mtx::events::msg::KeyVerificationRequest)
|
|
|
|
Q_DECLARE_METATYPE(mtx::events::msg::KeyVerificationStart)
|