Implement sending other message types in qml timeline

not using placeholders in timeline for now
remotes/origin/0.7.0-dev
Nicolas Werner 5 years ago
parent a7595eab5a
commit 5c87d6faa6
  1. 78
      src/timeline2/TimelineViewManager.cpp
  2. 14
      src/timeline2/TimelineViewManager.h

@ -100,3 +100,81 @@ TimelineViewManager::queueReplyMessage(const QString &reply, const RelatedInfo &
if (timeline_)
timeline_->sendMessage(text);
}
void
TimelineViewManager::queueEmoteMessage(const QString &msg)
{
auto html = utils::markdownToHtml(msg);
mtx::events::msg::Emote emote;
emote.body = msg.trimmed().toStdString();
if (html != msg.trimmed().toHtmlEscaped())
emote.formatted_body = html.toStdString();
if (timeline_)
timeline_->sendMessage(emote);
}
void
TimelineViewManager::queueImageMessage(const QString &roomid,
const QString &filename,
const QString &url,
const QString &mime,
uint64_t dsize,
const QSize &dimensions)
{
mtx::events::msg::Image image;
image.info.mimetype = mime.toStdString();
image.info.size = dsize;
image.body = filename.toStdString();
image.url = url.toStdString();
image.info.h = dimensions.height();
image.info.w = dimensions.width();
models.value(roomid)->sendMessage(image);
}
void
TimelineViewManager::queueFileMessage(const QString &roomid,
const QString &filename,
const QString &url,
const QString &mime,
uint64_t dsize)
{
mtx::events::msg::File file;
file.info.mimetype = mime.toStdString();
file.info.size = dsize;
file.body = filename.toStdString();
file.url = url.toStdString();
models.value(roomid)->sendMessage(file);
}
void
TimelineViewManager::queueAudioMessage(const QString &roomid,
const QString &filename,
const QString &url,
const QString &mime,
uint64_t dsize)
{
mtx::events::msg::Audio audio;
audio.info.mimetype = mime.toStdString();
audio.info.size = dsize;
audio.body = filename.toStdString();
audio.url = url.toStdString();
models.value(roomid)->sendMessage(audio);
}
void
TimelineViewManager::queueVideoMessage(const QString &roomid,
const QString &filename,
const QString &url,
const QString &mime,
uint64_t dsize)
{
mtx::events::msg::Video video;
video.info.mimetype = mime.toStdString();
video.info.size = dsize;
video.body = filename.toStdString();
video.url = url.toStdString();
models.value(roomid)->sendMessage(video);
}

@ -48,32 +48,28 @@ public slots:
void queueTextMessage(const QString &msg);
void queueReplyMessage(const QString &reply, const RelatedInfo &related);
void queueEmoteMessage(const QString &msg) {}
void queueEmoteMessage(const QString &msg);
void queueImageMessage(const QString &roomid,
const QString &filename,
const QString &url,
const QString &mime,
uint64_t dsize,
const QSize &dimensions)
{}
const QSize &dimensions);
void queueFileMessage(const QString &roomid,
const QString &filename,
const QString &url,
const QString &mime,
uint64_t dsize)
{}
uint64_t dsize);
void queueAudioMessage(const QString &roomid,
const QString &filename,
const QString &url,
const QString &mime,
uint64_t dsize)
{}
uint64_t dsize);
void queueVideoMessage(const QString &roomid,
const QString &filename,
const QString &url,
const QString &mime,
uint64_t dsize)
{}
uint64_t dsize);
private:
QQuickView *view;

Loading…
Cancel
Save