From 550cef52d0ea2a2e1e5e09bcb3a2a5e7d8d0dfe9 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Fri, 27 Nov 2020 15:29:11 +0100 Subject: [PATCH] Use more adapted delegate for showing emote (/me) Now use a standard MessageDelegate and don't display the title part. This now make the reply and reaction button available and also make it possible to see the reactions. Fix: #69 Fix: #75 --- .../Component/Timeline/MessageDelegate.qml | 5 ++-- .../Component/Timeline/TextDelegate.qml | 9 +++--- imports/NeoChat/Page/RoomPage.qml | 27 ++++++++++++++--- imports/NeoChat/Page/StartChatPage.qml | 30 ++++++++++--------- 4 files changed, 47 insertions(+), 24 deletions(-) diff --git a/imports/NeoChat/Component/Timeline/MessageDelegate.qml b/imports/NeoChat/Component/Timeline/MessageDelegate.qml index f1bff0763..16a92b6e9 100644 --- a/imports/NeoChat/Component/Timeline/MessageDelegate.qml +++ b/imports/NeoChat/Component/Timeline/MessageDelegate.qml @@ -27,6 +27,7 @@ RowLayout { readonly property color replyAuthorColor: replyVisible ? reply.author.color : Kirigami.Theme.focusColor property alias mouseArea: controlContainer.children + property bool isEmote: false signal saveFileAs() signal openExternally() @@ -90,7 +91,7 @@ RowLayout { Layout.fillWidth: true topInset: 0 - visible: showAuthor + visible: showAuthor && !isEmote text: author.displayName font.bold: true @@ -98,7 +99,7 @@ RowLayout { wrapMode: Text.Wrap } QQC2.Label { - visible: showAuthor + visible: showAuthor && !isEmote text: time.toLocaleTimeString(Locale.ShortFormat) color: Kirigami.Theme.disabledTextColor } diff --git a/imports/NeoChat/Component/Timeline/TextDelegate.qml b/imports/NeoChat/Component/Timeline/TextDelegate.qml index 8b461186f..cf0c900d4 100644 --- a/imports/NeoChat/Component/Timeline/TextDelegate.qml +++ b/imports/NeoChat/Component/Timeline/TextDelegate.qml @@ -11,12 +11,13 @@ import org.kde.kirigami 2.4 as Kirigami TextEdit { id: contentLabel - text: "" + display - - color: Kirigami.Theme.textColor - readonly property var isEmoji: /^(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])+$/ + property bool isEmote: false + + text: "" + (isEmote ? "* " + author.displayName + " " : "") + display + + color: Kirigami.Theme.textColor font.pointSize: isEmoji.test(message) ? Kirigami.Theme.defaultFont.pointSize * 4 : Kirigami.Theme.defaultFont.pointSize selectByMouse: !Kirigami.Settings.isMobile readOnly: true diff --git a/imports/NeoChat/Page/RoomPage.qml b/imports/NeoChat/Page/RoomPage.qml index 9df71e0e3..9700646b9 100644 --- a/imports/NeoChat/Page/RoomPage.qml +++ b/imports/NeoChat/Page/RoomPage.qml @@ -183,10 +183,29 @@ Kirigami.ScrollablePage { roleValue: "emote" delegate: TimelineContainer { width: messageListView.width - - innerObject: StateDelegate { - Layout.maximumWidth: parent.width - Layout.alignment: Qt.AlignHCenter + innerObject: MessageDelegate { + Layout.fillWidth: true + Layout.maximumWidth: messageListView.width + isEmote: true + mouseArea: MouseArea { + acceptedButtons: Qt.RightButton + anchors.fill: parent + onClicked: openMessageContext(author, display, eventId, toolTip); + } + onReplyClicked: goToEvent(eventID) + onReplyToMessageClicked: replyToMessage(replyUser, replyContent, eventId); + innerObject: [ + TextDelegate { + isEmote: true + Layout.fillWidth: true + Layout.rightMargin: Kirigami.Units.largeSpacing + }, + ReactionDelegate { + Layout.fillWidth: true + Layout.topMargin: 0 + Layout.bottomMargin: Kirigami.Units.largeSpacing * 2 + } + ] } } } diff --git a/imports/NeoChat/Page/StartChatPage.qml b/imports/NeoChat/Page/StartChatPage.qml index eb902ac8c..3965ed61e 100644 --- a/imports/NeoChat/Page/StartChatPage.qml +++ b/imports/NeoChat/Page/StartChatPage.qml @@ -22,27 +22,29 @@ Kirigami.ScrollablePage { title: i18n("Start a Chat") - header: RowLayout { - Layout.fillWidth: true - Kirigami.SearchField { - id: identifierField + header: Control { + padding: Kirigami.Units.largeSpacing + contentItem: RowLayout { + Kirigami.SearchField { + id: identifierField - property bool isUserID: text.match(/@(.+):(.+)/g) + property bool isUserID: text.match(/@(.+):(.+)/g) - Layout.fillWidth: true + Layout.fillWidth: true - placeholderText: i18n("Find a user...") + placeholderText: i18n("Find a user...") - onAccepted: userDictListModel.search() - } + onAccepted: userDictListModel.search() + } - Button { - visible: identifierField.isUserID + Button { + visible: identifierField.isUserID - text: i18n("Chat") - highlighted: true + text: i18n("Chat") + highlighted: true - onClicked: Controller.createDirectChat(connection, identifierField.text) + onClicked: Controller.createDirectChat(connection, identifierField.text) + } } }