summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorDeepBlueV7.X <nicolas.werner@hotmail.de>2021-01-23 02:02:59 +0100
committerGitHub <noreply@github.com>2021-01-23 02:02:59 +0100
commita082a98ede6fc5bd162169c2525e55ae26aef44a (patch)
treeeaf9225d0c02fa1a54fcb466551a342ab8d95da9 /src
parentFix Qt < 5.14 compat (diff)
parentRemove useless parentheses (diff)
downloadnheko-a082a98ede6fc5bd162169c2525e55ae26aef44a.tar.xz
Merge pull request #393 from LorenDB/mdCommands
Markdown setting override commands
Diffstat (limited to 'src')
-rw-r--r--src/timeline/InputBar.cpp10
-rw-r--r--src/timeline/InputBar.h9
2 files changed, 16 insertions, 3 deletions
diff --git a/src/timeline/InputBar.cpp b/src/timeline/InputBar.cpp

index 3cddd613..b31c1f76 100644 --- a/src/timeline/InputBar.cpp +++ b/src/timeline/InputBar.cpp
@@ -251,12 +251,14 @@ InputBar::openFileSelection() } void -InputBar::message(QString msg) +InputBar::message(QString msg, MarkdownOverride useMarkdown) { mtx::events::msg::Text text = {}; text.body = msg.trimmed().toStdString(); - if (ChatPage::instance()->userSettings()->markdown()) { + if ((ChatPage::instance()->userSettings()->markdown() && + useMarkdown == MarkdownOverride::NOT_SPECIFIED) || + useMarkdown == MarkdownOverride::ON) { text.formatted_body = utils::markdownToHtml(msg).toStdString(); // Don't send formatted_body, when we don't need to @@ -477,6 +479,10 @@ InputBar::command(QString command, QString args) room->clearTimeline(); } else if (command == "rotate-megolm-session") { cache::dropOutboundMegolmSession(room->roomId().toStdString()); + } else if (command == "md") { + message(args, MarkdownOverride::ON); + } else if (command == "plain") { + message(args, MarkdownOverride::OFF); } } diff --git a/src/timeline/InputBar.h b/src/timeline/InputBar.h
index c729a6fc..f173bbc0 100644 --- a/src/timeline/InputBar.h +++ b/src/timeline/InputBar.h
@@ -12,6 +12,13 @@ class QMimeData; class QDropEvent; class QStringList; +enum class MarkdownOverride +{ + NOT_SPECIFIED, // no override set + ON, + OFF, +}; + class InputBar : public QObject { Q_OBJECT @@ -41,7 +48,7 @@ public slots: void updateState(int selectionStart, int selectionEnd, int cursorPosition, QString text); void openFileSelection(); bool uploading() const { return uploading_; } - void message(QString body); + void message(QString body, MarkdownOverride useMarkdown = MarkdownOverride::NOT_SPECIFIED); QObject *completerFor(QString completerName);