summary refs log tree commit diff
path: root/src/timeline
diff options
context:
space:
mode:
authorJoseph Donofry <joedonofry@gmail.com>2020-05-13 00:35:26 -0400
committerJoseph Donofry <joedonofry@gmail.com>2020-05-13 00:36:41 -0400
commitee4dcef90f285f49ee27fec13afb486d93781b8b (patch)
treee6e4313098ef2c2fa4841fa7d6310825b08c0c4b /src/timeline
parentInitial support for sending reactions (diff)
downloadnheko-ee4dcef90f285f49ee27fec13afb486d93781b8b.tar.xz
Add new QML-based emoji picker (work in progress)
This is necessary to support having a picker within QML.
Eventually, this should replace the existing widget-based one.
Diffstat (limited to 'src/timeline')
-rw-r--r--src/timeline/TimelineModel.cpp38
-rw-r--r--src/timeline/TimelineModel.h5
-rw-r--r--src/timeline/TimelineViewManager.cpp10
-rw-r--r--src/timeline/TimelineViewManager.h6
4 files changed, 35 insertions, 24 deletions
diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp

index bb1a0ae5..4068148b 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp
@@ -1384,28 +1384,26 @@ struct SendMessageVisitor void operator()(const mtx::events::RoomEvent<mtx::events::msg::Reaction> &msg) { - QString txn_id_qstr = txn_id_qstr_; TimelineModel *model = model_; - http::client()->send_room_message<mtx::events::msg::Reaction, mtx::events::EventType::Reaction>( - model->room_id_.toStdString(), - txn_id_qstr.toStdString(), - msg.content, - [txn_id_qstr, model](const mtx::responses::EventId &res, - mtx::http::RequestErr err) { - if (err) { - const int status_code = - static_cast<int>(err->status_code); - nhlog::net()->warn("[{}] failed to send message: {} {}", - txn_id_qstr.toStdString(), - err->matrix_error.error, - status_code); - emit model->messageFailed(txn_id_qstr); - } - emit model->messageSent( - txn_id_qstr, QString::fromStdString(res.event_id.to_string())); - }); - + http::client() + ->send_room_message<mtx::events::msg::Reaction, mtx::events::EventType::Reaction>( + model->room_id_.toStdString(), + txn_id_qstr.toStdString(), + msg.content, + [txn_id_qstr, model](const mtx::responses::EventId &res, + mtx::http::RequestErr err) { + if (err) { + const int status_code = static_cast<int>(err->status_code); + nhlog::net()->warn("[{}] failed to send message: {} {}", + txn_id_qstr.toStdString(), + err->matrix_error.error, + status_code); + emit model->messageFailed(txn_id_qstr); + } + emit model->messageSent( + txn_id_qstr, QString::fromStdString(res.event_id.to_string())); + }); } QString txn_id_qstr_; diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h
index df231925..65f6b38c 100644 --- a/src/timeline/TimelineModel.h +++ b/src/timeline/TimelineModel.h
@@ -126,7 +126,8 @@ class TimelineModel : public QAbstractListModel int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) Q_PROPERTY(std::vector<QString> typingUsers READ typingUsers WRITE updateTypingUsers NOTIFY typingUsersChanged) - Q_PROPERTY(QString reaction READ reaction WRITE setReaction NOTIFY reactionChanged RESET resetReaction) + Q_PROPERTY(QString reaction READ reaction WRITE setReaction NOTIFY reactionChanged RESET + resetReaction) Q_PROPERTY(QString reply READ reply WRITE setReply NOTIFY replyChanged RESET resetReply) Q_PROPERTY( bool paginationInProgress READ paginationInProgress NOTIFY paginationInProgressChanged) @@ -230,7 +231,7 @@ public slots: if (!reaction_.isEmpty()) { reaction_ = ""; emit reactionChanged(reaction_); - } + } } QString reply() const { return reply_; } void setReply(QString newReply) diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp
index f17e3090..3f8a5b76 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp
@@ -13,6 +13,8 @@ #include "MxcImageProvider.h" #include "UserSettingsPage.h" #include "dialogs/ImageOverlay.h" +#include "emoji/EmojiModel.h" +#include "emoji/Provider.h" Q_DECLARE_METATYPE(mtx::events::collections::TimelineEvents) @@ -72,6 +74,12 @@ TimelineViewManager::TimelineViewManager(QSharedPointer<UserSettings> userSettin qmlRegisterType<DelegateChoice>("im.nheko", 1, 0, "DelegateChoice"); qmlRegisterType<DelegateChooser>("im.nheko", 1, 0, "DelegateChooser"); qRegisterMetaType<mtx::events::collections::TimelineEvents>(); + qmlRegisterType<emoji::EmojiModel>("im.nheko.EmojiModel", 1, 0, "EmojiModel"); + qmlRegisterType<emoji::EmojiProxyModel>("im.nheko.EmojiModel", 1, 0, "EmojiProxyModel"); + qmlRegisterUncreatableType<QAbstractItemModel>( + "im.nheko.EmojiModel", 1, 0, "QAbstractItemModel", "Used by proxy models"); + qmlRegisterUncreatableType<emoji::Emoji>( + "im.nheko.EmojiModel", 1, 0, "Emoji", "Used by emoji models"); #ifdef USE_QUICK_VIEW view = new QQuickView(); @@ -290,7 +298,7 @@ TimelineViewManager::queueReactionMessage(const QString &roomId, mtx::events::msg::Reaction reaction; reaction.relates_to.rel_type = mtx::common::RelationType::Annotation; reaction.relates_to.event_id = reactedEvent.toStdString(); - reaction.relates_to.key = reactionKey.toStdString(); + reaction.relates_to.key = reactionKey.toStdString(); auto model = models.value(roomId); model->sendMessage(reaction); diff --git a/src/timeline/TimelineViewManager.h b/src/timeline/TimelineViewManager.h
index eb2223e2..f5f57df4 100644 --- a/src/timeline/TimelineViewManager.h +++ b/src/timeline/TimelineViewManager.h
@@ -1,5 +1,6 @@ #pragma once +#include <QHash> #include <QQuickView> #include <QQuickWidget> #include <QSharedPointer> @@ -12,6 +13,8 @@ #include "Logging.h" #include "TimelineModel.h" #include "Utils.h" +#include "emoji/EmojiModel.h" +#include "emoji/Provider.h" class MxcImageProvider; class BlurhashProvider; @@ -102,7 +105,8 @@ private: QHash<QString, QSharedPointer<TimelineModel>> models; TimelineModel *timeline_ = nullptr; - bool isInitialSync_ = true; + + bool isInitialSync_ = true; QSharedPointer<UserSettings> settings; QHash<QString, QColor> userColors;