diff options
author | Nicolas Werner <nicolas.werner@hotmail.de> | 2023-07-08 19:22:50 +0200 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2023-08-25 19:03:15 +0200 |
commit | eab8731f5bd695342ad6412d42b1065872f12691 (patch) | |
tree | fbee3ed476f3479bbbb9e609c1c2af7e52715069 /resources/qml | |
parent | Working text messages in delegate rework (diff) | |
download | nheko-eab8731f5bd695342ad6412d42b1065872f12691.tar.xz |
Port state events and images
Diffstat (limited to 'resources/qml')
-rw-r--r-- | resources/qml/MessageView.qml | 82 | ||||
-rw-r--r-- | resources/qml/delegates/ImageMessage.qml | 15 | ||||
-rw-r--r-- | resources/qml/delegates/MessageDelegate.qml | 2 | ||||
-rw-r--r-- | resources/qml/delegates/TextMessage.qml | 4 |
4 files changed, 93 insertions, 10 deletions
diff --git a/resources/qml/MessageView.qml b/resources/qml/MessageView.qml index 2852e5f7..2d4f592c 100644 --- a/resources/qml/MessageView.qml +++ b/resources/qml/MessageView.qml @@ -191,13 +191,40 @@ Item { roleValues: [ MtxEvent.TextMessage, MtxEvent.NoticeMessage, + MtxEvent.ElementEffectMessage, + MtxEvent.UnknownMessage, ] TextMessage { - id: textMes + keepFullText: true + required property string userId + required property string userName + required property string formattedBody + required property int type + color: type == MtxEvent.NoticeMessage ? palette.buttonText : palette.text + font.italic: type == MtxEvent.NoticeMessage + formatted: formattedBody + + Layout.fillWidth: true + //Layout.maximumWidth: implicitWidth + + } + } + + EventDelegateChoice { + roleValues: [ + MtxEvent.EmoteMessage, + ] + TextMessage { keepFullText: true required property string userId required property string userName + required property string formattedBody + + formatted: TimelineManager.escapeEmoji(userName) + " " + formattedBody + + color: TimelineManager.userColor(userId, palette.base) + font.italic: true Layout.fillWidth: true //Layout.maximumWidth: implicitWidth @@ -207,6 +234,59 @@ Item { EventDelegateChoice { roleValues: [ + MtxEvent.CanonicalAlias, + MtxEvent.ServerAcl, + MtxEvent.Name, + MtxEvent.Topic, + MtxEvent.Avatar, + MtxEvent.PinnedEvents, + MtxEvent.ImagePackInRoom, + MtxEvent.SpaceParent, + MtxEvent.RoomCreate, + MtxEvent.PowerLevels, + MtxEvent.PolicyRuleUser, + MtxEvent.PolicyRuleRoom, + MtxEvent.PolicyRuleServer, + MtxEvent.RoomJoinRules, + MtxEvent.RoomHistoryVisibility, + MtxEvent.RoomGuestAccess, + ] + TextMessage { + keepFullText: true + + required property string userId + required property string userName + required property string formattedStateEvent + + isOnlyEmoji: false + text: formattedStateEvent + formatted: '' + body: '' + + color: palette.buttonText + font.italic: true + + Layout.fillWidth: true + //Layout.maximumWidth: implicitWidth + + } + } + + EventDelegateChoice { + roleValues: [ + MtxEvent.ImageMessage, + MtxEvent.Sticker, + ] + ImageMessage { + Layout.fillWidth: true + + containerHeight: timelineView.height + Layout.maximumWidth: tempWidth + } + } + + EventDelegateChoice { + roleValues: [ ] MatrixText { Layout.fillWidth: true diff --git a/resources/qml/delegates/ImageMessage.qml b/resources/qml/delegates/ImageMessage.qml index 20d727c3..48b7c5e4 100644 --- a/resources/qml/delegates/ImageMessage.qml +++ b/resources/qml/delegates/ImageMessage.qml @@ -2,10 +2,11 @@ // // SPDX-License-Identifier: GPL-3.0-or-later -import QtQuick 2.15 -import QtQuick.Window 2.15 -import QtQuick.Controls 2.3 -import im.nheko 1.0 +import QtQuick +import QtQuick.Window +import QtQuick.Controls +import QtQuick.Layouts +import im.nheko AbstractButton { required property int type @@ -17,13 +18,13 @@ AbstractButton { required property string filename required property bool isReply required property string eventId + required property int containerHeight property double divisor: isReply ? 5 : 3 property int tempWidth: originalWidth < 1? 400: originalWidth - implicitWidth: Math.round(tempWidth*Math.min((timelineView.height/divisor)/(tempWidth*proportionalHeight), 1)) - width: Math.min(parent?.width ?? 2000,implicitWidth) - height: width*proportionalHeight + Layout.preferredWidth: Math.round(tempWidth*Math.min((containerHeight/divisor)/(tempWidth*proportionalHeight), 1)) + Layout.preferredHeight: width*proportionalHeight hoverEnabled: true state: (img.status != Image.Ready || timeline.privacyScreen.active) ? "BlurhashVisible" : "ImageVisible" diff --git a/resources/qml/delegates/MessageDelegate.qml b/resources/qml/delegates/MessageDelegate.qml index 68f65062..44726a63 100644 --- a/resources/qml/delegates/MessageDelegate.qml +++ b/resources/qml/delegates/MessageDelegate.qml @@ -175,6 +175,7 @@ Item { isReply: d.isReply eventId: d.eventId metadataWidth: d.metadataWidth + containerHeight: timelineView.height } } @@ -193,6 +194,7 @@ Item { isReply: d.isReply eventId: d.eventId metadataWidth: d.metadataWidth + containerHeight: timelineView.height } } diff --git a/resources/qml/delegates/TextMessage.qml b/resources/qml/delegates/TextMessage.qml index d4b72965..dc8caf01 100644 --- a/resources/qml/delegates/TextMessage.qml +++ b/resources/qml/delegates/TextMessage.qml @@ -12,7 +12,7 @@ MatrixText { required property bool isOnlyEmoji required property bool isReply required property bool keepFullText - required property string formattedBody + required property string formatted property string copyText: selectedText ? getText(selectionStart, selectionEnd) : body property int metadataWidth: 100 @@ -40,7 +40,7 @@ MatrixText { background-color: " + palette.text + "; }" : "") + // TODO(Nico): Figure out how to support mobile "</style> - " + formattedBody.replace(/<del>/g, "<s>").replace(/<\/del>/g, "</s>").replace(/<strike>/g, "<s>").replace(/<\/strike>/g, "</s>") + " + formatted.replace(/<del>/g, "<s>").replace(/<\/del>/g, "</s>").replace(/<strike>/g, "<s>").replace(/<\/strike>/g, "</s>") Layout.maximumHeight: !keepFullText ? Math.round(Math.min(timelineView.height / 8, implicitHeight)) : implicitHeight clip: !keepFullText selectByMouse: !Settings.mobileMode && !isReply |