From 9de51fc77e374a2c4882a91fe08c5d0cd057b815 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Tue, 10 Nov 2020 17:06:38 +0000 Subject: [PATCH] Dynamic load reply qml stuff if needed --- .../Component/Timeline/MessageDelegate.qml | 44 ++------------- .../Component/Timeline/ReplyComponent.qml | 53 +++++++++++++++++++ res.qrc | 3 +- 3 files changed, 58 insertions(+), 42 deletions(-) create mode 100644 imports/NeoChat/Component/Timeline/ReplyComponent.qml diff --git a/imports/NeoChat/Component/Timeline/MessageDelegate.qml b/imports/NeoChat/Component/Timeline/MessageDelegate.qml index 3ce8cc1b2..094e8ac0b 100644 --- a/imports/NeoChat/Component/Timeline/MessageDelegate.qml +++ b/imports/NeoChat/Component/Timeline/MessageDelegate.qml @@ -89,47 +89,9 @@ RowLayout { color: author.color wrapMode: Text.Wrap } - - RowLayout { - Layout.fillWidth: true - - visible: replyVisible - - Rectangle { - Layout.preferredWidth: Kirigami.Units.smallSpacing - Layout.fillHeight: true - - color: Kirigami.Theme.highlightColor - } - - Kirigami.Avatar { - Layout.preferredWidth: Kirigami.Units.iconSizes.smallMedium - Layout.preferredHeight: Kirigami.Units.iconSizes.smallMedium - Layout.alignment: Qt.AlignTop - - source: replyVisible && reply.author.avatarMediaId ? "image://mxc/" + reply.author.avatarMediaId : "" - name: replyVisible ? reply.author.displayName : "H" - color: replyVisible ? reply.author.color : Kirigami.Theme.highlightColor - } - - ColumnLayout { - Layout.fillWidth: true - - QQC2.Label { - Layout.fillWidth: true - - text: replyVisible ? reply.author.displayName : "" - color: replyVisible ? reply.author.color: null - wrapMode: Text.Wrap - } - - QQC2.Label { - Layout.fillWidth: true - text: replyVisible ? reply.display : "" - wrapMode: Text.WrapAtWordBoundaryOrAnywhere - textFormat: Text.RichText - } - } + Loader { + source: 'qrc:imports/NeoChat/Component/Timeline/ReplyComponent.qml' + active: replyVisible } } } diff --git a/imports/NeoChat/Component/Timeline/ReplyComponent.qml b/imports/NeoChat/Component/Timeline/ReplyComponent.qml new file mode 100644 index 000000000..f122a530e --- /dev/null +++ b/imports/NeoChat/Component/Timeline/ReplyComponent.qml @@ -0,0 +1,53 @@ +/** + * SPDX-FileCopyrightText: 2019 Black Hat + * SPDX-FileCopyrightText: 2020 Carl Schwan + * + * SPDX-LicenseIdentifier: GPL-3.0-or-later + */ +import QtQuick 2.12 +import QtQuick.Controls 2.12 as QQC2 +import QtQuick.Layouts 1.12 +import org.kde.kirigami 2.13 as Kirigami + +RowLayout { + Layout.fillWidth: true + + visible: replyVisible + + Rectangle { + Layout.preferredWidth: Kirigami.Units.smallSpacing + Layout.fillHeight: true + + color: Kirigami.Theme.highlightColor + } + + Kirigami.Avatar { + Layout.preferredWidth: Kirigami.Units.iconSizes.smallMedium + Layout.preferredHeight: Kirigami.Units.iconSizes.smallMedium + Layout.alignment: Qt.AlignTop + + source: replyVisible && reply.author.avatarMediaId ? "image://mxc/" + reply.author.avatarMediaId : "" + name: replyVisible ? reply.author.displayName : "H" + color: replyVisible ? reply.author.color : Kirigami.Theme.highlightColor + } + + ColumnLayout { + Layout.fillWidth: true + + QQC2.Label { + Layout.fillWidth: true + + text: replyVisible ? reply.author.displayName : "" + color: replyVisible ? reply.author.color: null + wrapMode: Text.Wrap + } + + QQC2.Label { + Layout.fillWidth: true + text: replyVisible ? reply.display : "" + wrapMode: Text.WrapAtWordBoundaryOrAnywhere + textFormat: Text.RichText + } + } +} + diff --git a/res.qrc b/res.qrc index 048da7a74..779ecb3b2 100644 --- a/res.qrc +++ b/res.qrc @@ -19,8 +19,9 @@ imports/NeoChat/Component/FullScreenImage.qml imports/NeoChat/Component/Emoji/EmojiPicker.qml imports/NeoChat/Component/Emoji/qmldir - imports/NeoChat/Component/Timeline/MessageDelegate.qml imports/NeoChat/Component/Timeline/qmldir + imports/NeoChat/Component/Timeline/MessageDelegate.qml + imports/NeoChat/Component/Timeline/ReplyComponent.qml imports/NeoChat/Component/Timeline/StateDelegate.qml imports/NeoChat/Component/Timeline/TextDelegate.qml imports/NeoChat/Component/Timeline/TimelineContainer.qml