summary refs log tree commit diff
path: root/src/timeline/TimelineViewManager.cpp
diff options
context:
space:
mode:
authorJoseph Donofry <joedonofry@gmail.com>2020-01-28 19:20:51 -0500
committerJoseph Donofry <joedonofry@gmail.com>2020-01-28 19:20:51 -0500
commitd6d4076d36bdc7171c7d422fb24f64f273ee5f83 (patch)
tree9ce36ae841adb047f736119badc08bf45b574b7e /src/timeline/TimelineViewManager.cpp
parentChange tooltip palette settings for QML (diff)
parentRemove stale deps folder (diff)
downloadnheko-d6d4076d36bdc7171c7d422fb24f64f273ee5f83.tar.xz
Merge branch '0.7.0-dev' of ssh://github.com/Nheko-Reborn/nheko into 0.7.0-dev
Diffstat (limited to 'src/timeline/TimelineViewManager.cpp')
-rw-r--r--src/timeline/TimelineViewManager.cpp37
1 files changed, 28 insertions, 9 deletions
diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp

index 676f5ca5..33441a62 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp
@@ -18,8 +18,7 @@ Q_DECLARE_METATYPE(mtx::events::collections::TimelineEvents) void TimelineViewManager::updateColorPalette() { - UserSettings settings; - if (settings.theme() == "light") { + if (settings->theme() == "light") { QPalette lightActive(/*windowText*/ QColor("#333"), /*button*/ QColor("#333"), /*light*/ QColor(), @@ -33,7 +32,7 @@ TimelineViewManager::updateColorPalette() lightActive.setColor(QPalette::ToolTipText, lightActive.text().color()); view->rootContext()->setContextProperty("currentActivePalette", lightActive); view->rootContext()->setContextProperty("currentInactivePalette", lightActive); - } else if (settings.theme() == "dark") { + } else if (settings->theme() == "dark") { QPalette darkActive(/*windowText*/ QColor("#caccd1"), /*button*/ QColor("#caccd1"), /*light*/ QColor(), @@ -54,9 +53,10 @@ TimelineViewManager::updateColorPalette() } } -TimelineViewManager::TimelineViewManager(QWidget *parent) +TimelineViewManager::TimelineViewManager(QSharedPointer<UserSettings> userSettings, QWidget *parent) : imgProvider(new MxcImageProvider()) , colorImgProvider(new ColorImageProvider()) + , settings(userSettings) { qmlRegisterUncreatableMetaObject(qml_mtx_events::staticMetaObject, "im.nheko", @@ -190,8 +190,16 @@ TimelineViewManager::queueTextMessage(const QString &msg, const std::optional<Re { mtx::events::msg::Text text = {}; text.body = msg.trimmed().toStdString(); - text.format = "org.matrix.custom.html"; - text.formatted_body = utils::markdownToHtml(msg).toStdString(); + + if (settings->isMarkdownEnabled()) { + text.formatted_body = utils::markdownToHtml(msg).toStdString(); + + // Don't send formatted_body, when we don't need to + if (text.formatted_body == text.body) + text.formatted_body = ""; + else + text.format = "org.matrix.custom.html"; + } if (related) { QString body; @@ -206,8 +214,17 @@ TimelineViewManager::queueTextMessage(const QString &msg, const std::optional<Re } text.body = QString("%1\n%2").arg(body).arg(msg).toStdString(); - text.formatted_body = - utils::getFormattedQuoteBody(*related, utils::markdownToHtml(msg)).toStdString(); + + // NOTE(Nico): rich replies always need a formatted_body! + text.format = "org.matrix.custom.html"; + if (settings->isMarkdownEnabled()) + text.formatted_body = + utils::getFormattedQuoteBody(*related, utils::markdownToHtml(msg)) + .toStdString(); + else + text.formatted_body = + utils::getFormattedQuoteBody(*related, msg.toHtmlEscaped()).toStdString(); + text.relates_to.in_reply_to.event_id = related->related_event; } @@ -223,8 +240,10 @@ TimelineViewManager::queueEmoteMessage(const QString &msg) mtx::events::msg::Emote emote; emote.body = msg.trimmed().toStdString(); - if (html != msg.trimmed().toHtmlEscaped()) + if (html != msg.trimmed().toHtmlEscaped() && settings->isMarkdownEnabled()) { emote.formatted_body = html.toStdString(); + emote.format = "org.matrix.custom.html"; + } if (timeline_) timeline_->sendMessage(emote);