Move back to plain text

This commit is contained in:
Carl Schwan
2020-12-04 21:24:58 +01:00
parent bdaf661399
commit 7ed41a8f68
3 changed files with 9 additions and 12 deletions

View File

@@ -110,8 +110,8 @@ ToolBar {
selectByMouse: true selectByMouse: true
readOnly: true readOnly: true
wrapMode: Label.Wrap wrapMode: Label.Wrap
selectedTextColor: "white"
textFormat: Text.RichText textFormat: Text.RichText
selectedTextColor: "white"
} }
} }
@@ -133,7 +133,6 @@ ToolBar {
keyNavigationWraps: true keyNavigationWraps: true
delegate: Control { delegate: Control {
property string autoCompleteText: modelData.displayName ? ("<a href=\"https://matrix.to/#/" + modelData.id + "\">" + modelData.displayName + "</a>:") : modelData.unicode
property string displayText: modelData.displayName ?? modelData.unicode property string displayText: modelData.displayName ?? modelData.unicode
property bool isEmoji: modelData.unicode != null property bool isEmoji: modelData.unicode != null
readonly property bool highlighted: autoCompleteListView.currentIndex == index readonly property bool highlighted: autoCompleteListView.currentIndex == index
@@ -147,7 +146,7 @@ ToolBar {
width: Kirigami.Units.gridUnit width: Kirigami.Units.gridUnit
height: Kirigami.Units.gridUnit height: Kirigami.Units.gridUnit
visible: isEmoji visible: isEmoji
text: autoCompleteText text: displayText
font.family: "Emoji" font.family: "Emoji"
font.pointSize: 20 font.pointSize: 20
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
@@ -177,7 +176,7 @@ ToolBar {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
autoCompleteListView.currentIndex = index autoCompleteListView.currentIndex = index
documentHandler.replaceAutoComplete(autoCompleteText) documentHandler.replaceAutoComplete(displayText)
} }
} }
} }
@@ -255,9 +254,7 @@ ToolBar {
Layout.fillWidth: true Layout.fillWidth: true
wrapMode: Text.Wrap wrapMode: Text.Wrap
textFormat: TextEdit.RichText
placeholderText: i18n("Write your message...") placeholderText: i18n("Write your message...")
topPadding: 0 topPadding: 0
bottomPadding: 0 bottomPadding: 0
@@ -298,7 +295,7 @@ ToolBar {
Keys.onReturnPressed: { Keys.onReturnPressed: {
if (isAutoCompleting) { if (isAutoCompleting) {
documentHandler.replaceAutoComplete(autoCompleteListView.currentItem.autoCompleteText) documentHandler.replaceAutoComplete(autoCompleteListView.currentItem.displayText)
isAutoCompleting = false; isAutoCompleting = false;
return; return;
} }
@@ -353,7 +350,7 @@ ToolBar {
autoAppeared = false; autoAppeared = false;
} }
documentHandler.replaceAutoComplete(autoCompleteListView.currentItem.autoCompleteText) documentHandler.replaceAutoComplete(autoCompleteListView.currentItem.displayText)
} }
onTextChanged: { onTextChanged: {
@@ -390,7 +387,7 @@ ToolBar {
} }
function postMessage() { function postMessage() {
documentHandler.postMessage(attachmentPath, replyEventID); documentHandler.postMessage(inputField.text, attachmentPath, replyEventID);
clearAttachment(); clearAttachment();
currentRoom.markAllMessagesAsRead(); currentRoom.markAllMessagesAsRead();
clear(); clear();

View File

@@ -167,13 +167,13 @@ QVariantMap ChatDocumentHandler::getAutocompletionInfo()
}; };
} }
void ChatDocumentHandler::postMessage(const QString &attachementPath, const QString &replyEventId) const void ChatDocumentHandler::postMessage(const QString &text, const QString &attachementPath, const QString &replyEventId) const
{ {
if (!m_room || !m_document) { if (!m_room || !m_document) {
return; return;
} }
QString cleanedText = m_document->textDocument()->toMarkdown(); QString cleanedText = text;
cleanedText = cleanedText.trimmed(); cleanedText = cleanedText.trimmed();

View File

@@ -51,7 +51,7 @@ public:
[[nodiscard]] NeoChatRoom *room() const; [[nodiscard]] NeoChatRoom *room() const;
void setRoom(NeoChatRoom *room); void setRoom(NeoChatRoom *room);
Q_INVOKABLE void postMessage(const QString &attachementPath, const QString &replyEventId) const; Q_INVOKABLE void postMessage(const QString &text, const QString &attachementPath, const QString &replyEventId) const;
/// This function will look at the current QTextCursor and determine if there /// This function will look at the current QTextCursor and determine if there
/// is the posibility to autocomplete it. /// is the posibility to autocomplete it.