Compare commits

...

14 Commits
v1.2 ... v1.1.1

Author SHA1 Message Date
Carl Schwan
cc372f67eb Update version to 1.1.1 2021-02-23 14:39:22 +01:00
Tobias Fella
aaa042a2f0 Fix include
(cherry picked from commit 37a681596b)
2021-02-23 11:36:29 +00:00
Tobias Fella
6fdc8a9298 Fix another include
(cherry picked from commit b67a35bfe3)
2021-02-23 11:36:09 +00:00
Carl Schwan
1526c81a2f Add 1.1 release information 2021-02-22 21:01:57 +01:00
Carl Schwan
03d13bb543 Bump version 2021-02-22 20:58:10 +01:00
Carl Schwan
d8916aa133 Update AppStream 2021-02-22 20:56:55 +01:00
Carl Schwan
bb3b3bc088 Input field fixes
* Message with multiple mentions are not broken in IRC. Fix #267
* Editing a message won't remove mentions anymore
2021-02-22 19:09:56 +00:00
l10n daemon script
1234132a05 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2021-02-22 10:25:39 +01:00
l10n daemon script
52e5ec50c6 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2021-02-20 12:01:33 +01:00
l10n daemon script
16f661f6ae SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2021-02-19 17:00:04 +01:00
l10n daemon script
df1835de2d SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2021-02-18 11:51:49 +01:00
l10n daemon script
1432ba2368 GIT_SILENT made messages (after extraction) 2021-02-18 10:23:48 +01:00
Tobias Fella
edcbc9ab01 Port away from QQC1
The only usage was a dialog that was never called


(cherry picked from commit f71bbe20dc)
2021-02-17 21:34:30 +00:00
Carl Schwan
1afbd42523 Revert "Revert "Improve sending message with mentions""
This reverts commit 0f043e36c4.
2021-02-17 21:58:57 +01:00
13 changed files with 80 additions and 82 deletions

View File

@@ -28,7 +28,7 @@ endif()
# Fix a crash due to problems with quotient's event system. Can probably be removed once the reworked event system is in
cmake_policy(SET CMP0063 OLD)
ecm_setup_version(1.0.80
ecm_setup_version(1.1.1
VARIABLE_PREFIX NEOCHAT
VERSION_HEADER ${CMAKE_CURRENT_BINARY_DIR}/neochat-version.h
)

View File

@@ -318,6 +318,11 @@ ToolBar {
property real progress: 0
property bool autoAppeared: false
// store each user we autoComplete here, this will be helpful later to generate
// the matrix.to links.
// This use an hack to define: https://doc.qt.io/qt-5/qml-var.html#property-value-initialization-semantics
property var userAutocompleted: ({})
ChatDocumentHandler {
id: documentHandler
document: inputField.textDocument
@@ -469,11 +474,6 @@ ToolBar {
autoCompleteEndPosition = cursorPosition
}
// store each user we autoComplete here, this will be helpful later to generate
// the matrix.to links.
// This use an hack to define: https://doc.qt.io/qt-5/qml-var.html#property-value-initialization-semantics
property var userAutocompleted: ({})
function postMessage() {
roomManager.actionsHandler.postMessage(inputField.text.trim(), attachmentPath,
replyEventID, editEventId, inputField.userAutocompleted);
@@ -487,10 +487,10 @@ ToolBar {
function autoComplete() {
documentHandler.replaceAutoComplete(autoCompleteListView.currentItem.displayText)
// Unfortunally it doesn't
if (!autoCompleteListView.currentItem.isEmoji) {
inputField.userAutocompleted[autoCompleteListView.currentItem.displayText] = autoCompleteListView.currentItem.userId;
}
}
}
}
@@ -582,16 +582,14 @@ ToolBar {
}
function clear() {
inputField.clear()
inputField.clear();
inputField.userAutocompleted = {};
}
function clearEditReply() {
isReply = false;
replyUser = null;
if (root.editEventId.length > 0) {
clear();
}
clear();
root.replyContent = "";
root.replyEventID = "";
root.editEventId = "";
@@ -602,9 +600,26 @@ ToolBar {
inputField.forceActiveFocus()
}
function edit(editContent, editEventId) {
function edit(editContent, editFormatedContent, editEventId) {
console.log("Editing ", editContent, "html:", editFormatedContent)
// Set the input field in edit mode
inputField.text = editContent;
root.editEventId = editEventId
// clean autocompletion list
inputField.userAutocompleted = {};
// Fill autocompletion list with values extracted from message.
// We can't just iterate on every user in the list and try to
// find matching display name since some users have display name
// matching frequent words and this will marks too many words as
// mentions.
const regex = /<a href=\"https:\/\/matrix.to\/#\/(@[a-zA-Z09]*:[a-zA-Z09.]*)\">([^<]*)<\/a>/g;
let match;
while ((match = regex.exec(editFormatedContent.toString())) !== null) {
inputField.userAutocompleted[match[2]] = match[1];
}
}
function closeAll() {

View File

@@ -139,7 +139,7 @@ RowLayout {
QQC2.ToolTip.visible: hovered
visible: controlContainer.hovered && author.id === Controller.activeConnection.localUserId && (model.eventType === "emote" || model.eventType === "message")
icon.name: "document-edit"
onClicked: chatTextInput.edit(message, eventId)
onClicked: chatTextInput.edit(message, model.formattedBody, eventId)
}
QQC2.Button {
QQC2.ToolTip.text: i18n("Reply")

View File

@@ -8,7 +8,6 @@ import QtQuick 2.10
import QtQuick.Controls 2.1 as QQC2
import QtQuick.Layouts 1.12
import org.kde.kirigami 2.12 as Kirigami
import QtQuick.Dialogs 1.2
import org.kde.kquickimageeditor 1.0 as KQuickImageEditor
import QtGraphicalEffects 1.12
import Qt.labs.platform 1.0 as Platform
@@ -81,21 +80,6 @@ Kirigami.Page {
onActivated: saveAsAction.trigger();
} anchors.fill: parent
FileDialog {
id: fileDialog
title: i18n("Save As")
folder: shortcuts.home
selectMultiple: false
selectExisting: false
onAccepted: {
fileDialog.close()
}
onRejected: {
fileDialog.close()
}
Component.onCompleted: visible = false
}
KQuickImageEditor.ImageDocument {
id: imageDoc
path: rootEditorView.imagePath

View File

@@ -1,7 +1,6 @@
[Global]
IconName=org.kde.neochat
Name=Neochat
Name[az]=Neochat
Name[ca]=Neochat
Name[ca@valencia]=Neochat
Name[da]=Neochat
@@ -15,7 +14,6 @@ Name[hu]=Neochat
Name[it]=Neochat
Name[nl]=Neochat
Name[nn]=Neochat
Name[pa]=ਨਿਓ-ਚੈਟ
Name[pl]=Neochat
Name[pt]=Neochat
Name[pt_BR]=Neochat
@@ -27,23 +25,16 @@ Name[x-test]=xxNeochatxx
Name[zh_CN]=Neochat
DesktopEntry=org.kde.neochat
Comment=A client for matrix, the decentralized communication protocol
Comment[az]=Matrix üçün müştəri, mərkəzləşməmiş kommunikasiya protokolu
Comment[ca]=Un client per al Matrix, el protocol de comunicacions descentralitzat
Comment[ca@valencia]=Un client per al Matrix, el protocol de comunicacions descentralitzat
Comment[en_GB]=A client for matrix, the decentralised communication protocol
Comment[es]=Un cliente para Matrix, el protocolo de comunicaciones descentralizado
Comment[eu]=Matrix, deszentralizatutako komunikazio protokolorako, bezero bat
Comment[fi]=Hajautetun Matrix-viestintäyhteyskäytännön asiakasohjelma
Comment[hu]=Kliens a matrixhoz, a decentralizált kommunikációs protokollhoz
Comment[fr]=Un client pour « Matrix », le protocole décentralisé de communications.
Comment[it]=Un client per matrix, il protocollo di comunicazione decentralizzato
Comment[nl]=Een client voor matrix, het gedecentraliseerde communicatieprotocol
Comment[nn]=Klient for Matrix, den desentraliserte lynmeldings­protokollen.
Comment[pa]=ਮੈਟਰਿਕਸ, ਸਰਬ-ਸਾਂਝੇ ਸੰਚਾਰ ਪਰੋਟੋਕਾਲ, ਲਈ ਕਲਾਈਂਟ ਹੈ
Comment[pl]=Program do obsługi matriksa, rozproszonego protokołu porozumiewania się
Comment[pt]=Um cliente para o Matrix, o protocolo descentralizado de comunicações
Comment[pt_BR]=Um cliente para o Matrix, o protocolo de comunicação decentralizado
Comment[sk]=Klient pre matrix, decentralizovaný komunikačný protokol
Comment[sl]=Odjemalec za decentralizirani komunikacijski protokol matrix
Comment[sv]=En klient för matrix, det decentraliserade kommunikationsprotokollet
Comment[uk]=Клієнт matrix, децентралізованого протоколу обміну даними
Comment[x-test]=xxA client for matrix, the decentralized communication protocolxx
@@ -51,7 +42,6 @@ Comment[x-test]=xxA client for matrix, the decentralized communication protocolx
[Event/message]
Name=New message
Name[az]=Yeni ismarıc
Name[ca]=Missatge nou
Name[ca@valencia]=Missatge nou
Name[de]=Neue Nachricht
@@ -64,7 +54,6 @@ Name[hu]=Új üzenet
Name[it]=Nuovo messaggio
Name[nl]=Nieuw bericht
Name[nn]=Ny melding
Name[pa]=ਨਵਾਂ ਸੁਨੇਹਾ
Name[pl]=Nowa wiadomość
Name[pt]=Nova mensagem
Name[pt_BR]=Nova mensagem
@@ -75,7 +64,6 @@ Name[uk]=Нове повідомлення
Name[x-test]=xxNew messagexx
Name[zh_CN]=新消息
Comment=There is a new message
Comment[az]=Yeni ismarıc var
Comment[ca]=Hi ha un missatge nou
Comment[ca@valencia]=Hi ha un missatge nou
Comment[de]=Es ist eine neue Nachricht vorhanden
@@ -88,7 +76,6 @@ Comment[hu]=Új üzenet érkezett
Comment[it]=È presente un nuovo messaggio
Comment[nl]=Er is een nieuw bericht
Comment[nn]=Du har ei ny melding
Comment[pa]=ਨਵਾਂ ਸੁਨੇਹਾ ਹੈ
Comment[pl]=Dostępna jest nowa wiadomość
Comment[pt]=Tem uma mensagem nova
Comment[pt_BR]=Existe uma nova mensagem

View File

@@ -5,7 +5,6 @@
<binary>neochat</binary>
</provides>
<name>Neochat</name>
<name xml:lang="az">Neochat</name>
<name xml:lang="ca">Neochat</name>
<name xml:lang="ca-valencia">Neochat</name>
<name xml:lang="da">Neochat</name>
@@ -20,7 +19,6 @@
<name xml:lang="it">Neochat</name>
<name xml:lang="nl">Neochat</name>
<name xml:lang="nn">Neochat</name>
<name xml:lang="pa">ਨਿਓ-ਚੈਟ</name>
<name xml:lang="pl">Neochat</name>
<name xml:lang="pt">Neochat</name>
<name xml:lang="pt-BR">Neochat</name>
@@ -30,7 +28,6 @@
<name xml:lang="uk">Neochat</name>
<name xml:lang="x-test">xxNeochatxx</name>
<summary>A client for matrix, the decentralized communication protocol</summary>
<summary xml:lang="az">Matrix üçün müştəri, mərkəzləşməmiş kommunikasiya protokolu</summary>
<summary xml:lang="ca">Un client per al Matrix, el protocol de comunicacions descentralitzat</summary>
<summary xml:lang="ca-valencia">Un client per al Matrix, el protocol de comunicacions descentralitzat</summary>
<summary xml:lang="de">Ein Programm für Matrix, das dezentrale Kommunikationsprotokoll</summary>
@@ -44,7 +41,6 @@
<summary xml:lang="it">Un client per matrix, il protocollo di comunicazione decentralizzato</summary>
<summary xml:lang="nl">Een client voor matrix, het gedecentraliseerde communicatieprotocol</summary>
<summary xml:lang="nn">Ein klient for Matrix, den desentraliserte lynmeldings­protokollen</summary>
<summary xml:lang="pa">ਮੈਟਰਿਕਸ, ਸਰਬ-ਸਾਂਝੇ ਸੰਚਾਰ ਪਰੋਟੋਕਾਲ, ਲਈ ਕਲਾਈਂਟ ਹੈ</summary>
<summary xml:lang="pl">Program do obsługi matriksa, rozproszonego protokołu porozumiewania się</summary>
<summary xml:lang="pt">Um cliente para o Matrix, o protocolo de comunicação descentralizado</summary>
<summary xml:lang="pt-BR">Um cliente do Matrix, o protocolo de comunicação descentralizado</summary>
@@ -55,7 +51,6 @@
<summary xml:lang="x-test">xxA client for matrix, the decentralized communication protocolxx</summary>
<description>
<p>A client for matrix, the decentralized communication protocol.</p>
<p xml:lang="az">Matrix üçün müştəri, mərkəzləşməmiş kommunikasiya protokolu.</p>
<p xml:lang="ca">Un client per al Matrix, el protocol de comunicacions descentralitzat.</p>
<p xml:lang="ca-valencia">Un client per al Matrix, el protocol de comunicacions descentralitzat.</p>
<p xml:lang="de">Ein Programm für Matrix, das dezentrale Kommunikationsprotokoll.</p>
@@ -69,7 +64,6 @@
<p xml:lang="it">Un client per matrix, il protocollo di comunicazione decentralizzato.</p>
<p xml:lang="nl">Een client voor matrix, het gedecentraliseerde communicatieprotocol.</p>
<p xml:lang="nn">Ein klient for Matrix, den desentraliserte lynmeldings­protokollen.</p>
<p xml:lang="pa">ਮੈਟਰਿਕਸ, ਸਰਬ-ਸਾਂਝੇ ਸੰਚਾਰ ਪਰੋਟੋਕਾਲ, ਲਈ ਕਲਾਈਂਟ ਹੈ।</p>
<p xml:lang="pl">Program do obsługi matriksa, rozproszonego protokołu porozumiewania się.</p>
<p xml:lang="pt">Um cliente para o Matrix, o protocolo de comunicação descentralizado.</p>
<p xml:lang="pt-BR">Um cliente do Matrix, o protocolo de comunicação descentralizado.</p>
@@ -85,7 +79,6 @@
<category>Network</category>
</categories>
<developer_name>The KDE Community</developer_name>
<developer_name xml:lang="az">KDE Cəmiyyəti</developer_name>
<developer_name xml:lang="ca">La comunitat KDE</developer_name>
<developer_name xml:lang="ca-valencia">La comunitat KDE</developer_name>
<developer_name xml:lang="de">Die KDE-Gemeinschaft</developer_name>
@@ -112,13 +105,27 @@
<value key="KDE::matrix">#neochat:kde.org</value>
<screenshots>
<screenshot type="default">
<image>https://www.plasma-mobile.org/img/post-2020-10/post-2020-10-neochat-timeline.png</image>
<image>https://cdn.kde.org/screenshots/neochat/application.png</image>
</screenshot>
<screenshot>
<image>https://cdn.kde.org/screenshots/neochat/application-mobile.png</image>
</screenshot>
</screenshots>
<content_rating type="oars-1.1">
<content_attribute id="social-chat">intense</content_attribute>
</content_rating>
<releases>
<release urgency="critical" version="1.1.1" date="2021-02-23"></release>
<release version="1.1.0" date="2021-02-22">
<description>
<p>Probably the highlight of this release is the completely new login page. It detects the server configuration based on your Matrix Id. This allows you to login to servers requiring Single Sign On (SSO) (like the Mozilla or the incoming Fedora Matrix instance).</p>
<p>Servers that require agreeing to the TOS before usage are correctly detected now and redirect to their TOS webpage, allowing the user to agree to them instead of silently failing to load the account.</p>
<p>It is now possible to open a room into a new window. This allows you to view and interact with multiple rooms at the same time.</p>
<p>We added a few commands to NeoChat (/shrug, /lenny, /join, /ignore, ...).</p>
<p>We improved the Plasma integration a bit. Now the number of unread messages is displayed in the Plasma Taskbar.</p>
</description>
<url>https://carlschwan.eu/2020/02/22/neochat-1.1/</url>
</release>
<release version="1.0.1" date="2021-01-13">
<description>
<p>This version fixes several bugs.</p>

View File

@@ -1,6 +1,5 @@
[Desktop Entry]
Name=Neochat
Name[az]=Neochat
Name[ca]=Neochat
Name[ca@valencia]=Neochat
Name[da]=Neochat
@@ -14,7 +13,6 @@ Name[hu]=Neochat
Name[it]=Neochat
Name[nl]=Neochat
Name[nn]=Neochat
Name[pa]=ਨਿਓ-ਚੈਟ
Name[pl]=Neochat
Name[pt]=Neochat
Name[pt_BR]=Neochat
@@ -25,7 +23,6 @@ Name[uk]=Neochat
Name[x-test]=xxNeochatxx
Name[zh_CN]=Neochat
GenericName=Matrix Client
GenericName[az]=Matrix Müştərisi
GenericName[ca]=Client del Matrix
GenericName[ca@valencia]=Client del Matrix
GenericName[de]=Matrix-Programm
@@ -38,7 +35,6 @@ GenericName[hu]=Matrix kliens
GenericName[it]=Client Matrix
GenericName[nl]=Matrix-client
GenericName[nn]=Matrix-klient
GenericName[pa]=ਮੈਟਰਿਕਸ ਕਲਾਈਂਟ
GenericName[pl]=Program Matriksa
GenericName[pt]=Cliente de Matrix
GenericName[pt_BR]=Cliente Matrix
@@ -49,7 +45,6 @@ GenericName[uk]=Клієнт Matrix
GenericName[x-test]=xxMatrix Clientxx
GenericName[zh_CN]=Matrix 客户端
Comment=Client for the Matrix protocol
Comment[az]=Matrix protokolu üçün müştəri
Comment[ca]=Client per al protocol Matrix
Comment[ca@valencia]=Client per al protocol Matrix
Comment[de]=Programm für das Matrix-Protokoll
@@ -62,7 +57,6 @@ Comment[hu]=Kliens a Matrix protokollhoz
Comment[it]=Client per il protocollo Matrix
Comment[nl]=Client voor het Matrix-protocol
Comment[nn]=Lynmeldings­klient for Matrix-protokollen
Comment[pa]=ਮੈਟਰਿਕਸ ਪਰੋਟੋਕਾਲ ਲਈ ਕਲਾਈਂਟ ਹੈ
Comment[pl]=Program obsługi protokołu Matriksa
Comment[pt]=Cliente para o protocolo Matrix
Comment[pt_BR]=Cliente para o protocolo Matrix

View File

@@ -142,7 +142,6 @@ void ActionsHandler::joinRoom(const QString &alias)
joinRoomJob->errorString()));
});
Quotient::JoinRoomJob::connect(joinRoomJob, &JoinRoomJob::success, [this, joinRoomJob] {
qDebug() << "joined" << joinRoomJob->roomId();
Q_EMIT roomJoined(joinRoomJob->roomId());
});
}
@@ -160,15 +159,15 @@ void ActionsHandler::createRoom(const QString &name, const QString &topic)
void ActionsHandler::postMessage(const QString &text,
const QString &attachementPath, const QString &replyEventId, const QString &editEventId,
const QVariantMap usernames)
const QVariantMap &usernames)
{
QString rawText = text;
QString cleanedText = text;
for (const auto username : usernames.keys()) {
const auto replacement = usernames.value(username);
cleanedText = cleanedText.replace(username,
"[" + username + "](https://matrix.to/#/" + replacement.toString() + ")");
for (auto it = usernames.constBegin(); it != usernames.constEnd(); it++) {
cleanedText = cleanedText.replace(it.key(),
"[" + it.key() + "](https://matrix.to/#/" + it.value().toString() + ")");
}
if (attachementPath.length() > 0) {
@@ -277,9 +276,6 @@ void ActionsHandler::postMessage(const QString &text,
if (rawText.indexOf(partPrefix) == 0) {
rawText = rawText.remove(0, partPrefix.length());
const QStringList splittedText = rawText.split(" ");
qDebug() << m_room;
qDebug() << "m_room";
qDebug() << splittedText;
if (splittedText.count() == 0 || splittedText[0].isEmpty()) {
// leave current room
m_connection->leaveRoom(m_room);
@@ -332,5 +328,5 @@ void ActionsHandler::postMessage(const QString &text,
cleanedText = cleanedText.remove(0, noticePrefix.length());
messageEventType = RoomMessageEvent::MsgType::Notice;
}
m_room->postMessage(cleanedText, messageEventType, replyEventId, editEventId);
m_room->postMessage(rawText, cleanedText, messageEventType, replyEventId, editEventId);
}

View File

@@ -72,8 +72,7 @@ public Q_SLOTS:
///
/// This also interprets commands if any.
void postMessage(const QString &text, const QString &attachementPath,
const QString &replyEventId, const QString &editEventId,
const QVariantMap usernames);
const QString &replyEventId, const QString &editEventId, const QVariantMap &usernames);
private:
Connection *m_connection = nullptr;

View File

@@ -11,10 +11,11 @@
#include <events/redactionevent.h>
#include <events/roomavatarevent.h>
#include <events/roommemberevent.h>
#include <events/stickerevent.h>
#include <events/simplestateevents.h>
#include <user.h>
#include "stickerevent.h"
#include <QDebug>
#include <QQmlEngine> // for qmlRegisterType()
#include <QTimeZone>
@@ -46,6 +47,7 @@ QHash<int, QByteArray> MessageEventModel::roleNames() const
roles[ShowSectionRole] = "showSection";
roles[ReactionRole] = "reaction";
roles[IsEditedRole] = "isEdited";
roles[FormattedBodyRole] = "formattedBody";
return roles;
}
@@ -334,6 +336,16 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const
return m_currentRoom->eventToString(evt, Qt::RichText);
}
if (role == FormattedBodyRole) {
if (auto e = eventCast<const RoomMessageEvent>(&evt)) {
if (e->hasTextContent() && e->mimeType().name() != "text/plain") {
return static_cast<const Quotient::EventContent::TextContent *>(e->content())->body;
}
}
return {};
}
if (role == MessageRole) {
return m_currentRoom->eventToString(evt);
}

View File

@@ -32,6 +32,7 @@ public:
LongOperationRole,
AnnotationRole,
UserMarkerRole,
FormattedBodyRole,
ReplyRole,

View File

@@ -27,7 +27,7 @@
#include "events/roomcanonicalaliasevent.h"
#include "events/roommessageevent.h"
#include "events/roompowerlevelsevent.h"
#include "events/stickerevent.h"
#include "stickerevent.h"
#include "events/typingevent.h"
#include "jobs/downloadfilejob.h"
#include "neochatconfig.h"
@@ -105,7 +105,6 @@ void NeoChatRoom::uploadFile(const QUrl &url, const QString &body)
});
connect(this, &Room::fileTransferProgress, [=](const QString &id, qint64 progress, qint64 total) {
if (id == txnId) {
qDebug() << "Progress:" << progress << total;
setFileUploadingProgress(int(float(progress) / float(total) * 100));
}
});
@@ -539,19 +538,17 @@ QString msgTypeToString(MessageEventType msgType)
}
}
void NeoChatRoom::postMessage(const QString &text, MessageEventType type, const QString &replyEventId, const QString &relateToEventId)
void NeoChatRoom::postMessage(const QString &rawText, const QString &text, MessageEventType type, const QString &replyEventId, const QString &relateToEventId)
{
const auto html = markdownToHTML(text);
QString cleanText(text);
cleanText.replace(QRegularExpression("\\[(.+)\\]\\(.+\\)"), "\\1");
postHtmlMessage(cleanText, html, type, replyEventId, relateToEventId);
postHtmlMessage(rawText, html, type, replyEventId, relateToEventId);
}
void NeoChatRoom::postHtmlMessage(const QString &text, const QString &html, MessageEventType type, const QString &replyEventId, const QString &relateToEventId)
{
QString htmlWithLinks = html;
htmlWithLinks = htmlWithLinks.replace(QRegularExpression("@([^: ]*):([^ ]*\\.[^ ]*)"), "<a href=\"https://matrix.to/#/@$1:$2\">@$1:$2</a>");
bool isRichText = Qt::mightBeRichText(htmlWithLinks);
bool isRichText = Qt::mightBeRichText(html);
bool isReply = !replyEventId.isEmpty();
bool isEdit = !relateToEventId.isEmpty();
const auto replyIt = findInTimeline(replyEventId);
@@ -564,11 +561,15 @@ void NeoChatRoom::postHtmlMessage(const QString &text, const QString &html, Mess
QJsonObject json {
{"type", "m.room.message"},
{"msgtype", msgTypeToString(type)},
{"body", "* " + (isRichText ? text : htmlWithLinks)},
{"body", "* " + text},
{"format", "org.matrix.custom.html"},
{"formatted_body", html},
{"m.new_content",
QJsonObject {
{"body", (isRichText ? text : htmlWithLinks)},
{"msgtype", msgTypeToString(type)}
{"body", text},
{"msgtype", msgTypeToString(type)},
{"format", "org.matrix.custom.html"},
{"formatted_body", html}
}
},
{"m.relates_to",
@@ -607,7 +608,7 @@ void NeoChatRoom::postHtmlMessage(const QString &text, const QString &html, Mess
"\">In reply to</a> <a href=\"https://matrix.to/#/" +
replyEvt.senderId() + "\">" + replyEvt.senderId() +
"</a><br>" + eventToString(replyEvt, Qt::RichText) +
"</blockquote></mx-reply>" + (isRichText ? htmlWithLinks : text)
"</blockquote></mx-reply>" + (isRichText ? html : text)
}
};
// clang-format on

View File

@@ -139,7 +139,9 @@ public Q_SLOTS:
void acceptInvitation();
void forget();
void sendTypingNotification(bool isTyping);
void postMessage(const QString &text, Quotient::MessageEventType type = Quotient::MessageEventType::Text, const QString &replyEventId = QString(), const QString &relateToEventId = QString());
/// @param rawText The text as it was typed.
/// @param cleanedText The text with link to the users.
void postMessage(const QString &rawText, const QString &cleanedText, Quotient::MessageEventType type = Quotient::MessageEventType::Text, const QString &replyEventId = QString(), const QString &relateToEventId = QString());
void postHtmlMessage(const QString &text, const QString &html, Quotient::MessageEventType type = Quotient::MessageEventType::Text, const QString &replyEventId = QString(), const QString &relateToEventId = QString());
void changeAvatar(const QUrl &localFile);
void addLocalAlias(const QString &alias);