This is mostly just for text type messages at the moment but give the framework so that when other message types can be sent in threads they can be added easily
55 lines
1.4 KiB
QML
55 lines
1.4 KiB
QML
// SPDX-FileCopyrightText: 2025 James Graham <james.h.graham@protonmail.com>
|
|
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
|
|
|
import QtQuick
|
|
import QtQuick.Layouts
|
|
|
|
import org.kde.kirigami as Kirigami
|
|
|
|
import org.kde.neochat
|
|
|
|
/**
|
|
* @brief A component to visualize a ThreadModel.
|
|
*
|
|
* @sa ThreadModel
|
|
*/
|
|
ColumnLayout {
|
|
id: root
|
|
|
|
/**
|
|
* @brief The Matrix ID of the root message in the thread, if any.
|
|
*/
|
|
required property string threadRoot
|
|
|
|
/**
|
|
* @brief The user selected text has changed.
|
|
*/
|
|
signal selectedTextChanged(string selectedText)
|
|
|
|
/**
|
|
* @brief The user hovered link has changed.
|
|
*/
|
|
signal hoveredLinkChanged(string hoveredLink)
|
|
|
|
Layout.fillWidth: true
|
|
Layout.fillHeight: true
|
|
Layout.maximumWidth: Message.maxContentWidth
|
|
spacing: Kirigami.Units.smallSpacing
|
|
|
|
Repeater {
|
|
id: threadRepeater
|
|
model: root.Message.room.modelForThread(root.threadRoot);
|
|
|
|
delegate: BaseMessageComponentChooser {
|
|
onSelectedTextChanged: selectedText => {
|
|
root.selectedTextChanged(selectedText);
|
|
}
|
|
onHoveredLinkChanged: hoveredLink => {
|
|
root.hoveredLinkChanged(hoveredLink);
|
|
}
|
|
onRemoveLinkPreview: index => threadRepeater.model.closeLinkPreview(index)
|
|
onFetchMoreEvents: threadRepeater.model.fetchMoreEvents(5)
|
|
}
|
|
}
|
|
}
|