Message attached property
Create Message attached property to propagate parameters like room, timeline, index and maxContentWidth down to the message content avoiding lots of boilerplate
This commit is contained in:
@@ -296,6 +296,9 @@ ecm_add_qml_module(neochat URI org.kde.neochat GENERATE_PLUGIN_SOURCE
|
|||||||
qml/HoverLinkIndicator.qml
|
qml/HoverLinkIndicator.qml
|
||||||
qml/AvatarNotification.qml
|
qml/AvatarNotification.qml
|
||||||
qml/ReasonDialog.qml
|
qml/ReasonDialog.qml
|
||||||
|
SOURCES
|
||||||
|
messageattached.cpp
|
||||||
|
messageattached.h
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
QtCore
|
QtCore
|
||||||
QtQuick
|
QtQuick
|
||||||
|
|||||||
@@ -349,7 +349,7 @@ QQC2.Control {
|
|||||||
replyEventId: _private.chatBarCache.replyId
|
replyEventId: _private.chatBarCache.replyId
|
||||||
replyAuthor: _private.chatBarCache.relationAuthor
|
replyAuthor: _private.chatBarCache.relationAuthor
|
||||||
replyContentModel: _private.chatBarCache.relationEventContentModel
|
replyContentModel: _private.chatBarCache.relationEventContentModel
|
||||||
maxContentWidth: paneLoader.item.width
|
Message.maxContentWidth: paneLoader.item.width
|
||||||
}
|
}
|
||||||
QQC2.Button {
|
QQC2.Button {
|
||||||
id: cancelButton
|
id: cancelButton
|
||||||
|
|||||||
126
src/messageattached.cpp
Normal file
126
src/messageattached.cpp
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
// 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
|
||||||
|
|
||||||
|
#include "messageattached.h"
|
||||||
|
|
||||||
|
MessageAttached::MessageAttached(QObject *parent)
|
||||||
|
: QQuickAttachedPropertyPropagator(parent)
|
||||||
|
{
|
||||||
|
if (parent == nullptr) {
|
||||||
|
qWarning() << "Message must be attached to an Item" << parent;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageAttached *MessageAttached::qmlAttachedProperties(QObject *object)
|
||||||
|
{
|
||||||
|
return new MessageAttached(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
NeoChatRoom *MessageAttached::room() const
|
||||||
|
{
|
||||||
|
return m_room;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessageAttached::setRoom(NeoChatRoom *room)
|
||||||
|
{
|
||||||
|
m_explicitRoom = true;
|
||||||
|
if (m_room == room) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_room = room;
|
||||||
|
propagateMessage(this);
|
||||||
|
Q_EMIT roomChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
QQuickItem *MessageAttached::timeline() const
|
||||||
|
{
|
||||||
|
return m_timeline;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessageAttached::setTimeline(QQuickItem *timeline)
|
||||||
|
{
|
||||||
|
m_explicitTimeline = true;
|
||||||
|
if (m_timeline == timeline) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_timeline = timeline;
|
||||||
|
propagateMessage(this);
|
||||||
|
Q_EMIT timelineChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
int MessageAttached::index() const
|
||||||
|
{
|
||||||
|
return m_index;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessageAttached::setIndex(int index)
|
||||||
|
{
|
||||||
|
m_explicitIndex = true;
|
||||||
|
if (m_index == index) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_index = index;
|
||||||
|
propagateMessage(this);
|
||||||
|
Q_EMIT indexChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal MessageAttached::maxContentWidth() const
|
||||||
|
{
|
||||||
|
return m_maxContentWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessageAttached::setMaxContentWidth(qreal maxContentWidth)
|
||||||
|
{
|
||||||
|
m_explicitMaxContentWidth = true;
|
||||||
|
if (m_maxContentWidth == maxContentWidth) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_maxContentWidth = maxContentWidth;
|
||||||
|
propagateMessage(this);
|
||||||
|
Q_EMIT maxContentWidthChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessageAttached::propagateMessage(MessageAttached *message)
|
||||||
|
{
|
||||||
|
if (m_explicitRoom || m_room != message->room()) {
|
||||||
|
m_room = message->room();
|
||||||
|
Q_EMIT roomChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_explicitTimeline || m_timeline != message->timeline()) {
|
||||||
|
m_timeline = message->timeline();
|
||||||
|
Q_EMIT timelineChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_explicitIndex || m_index != message->index()) {
|
||||||
|
m_index = message->index();
|
||||||
|
Q_EMIT indexChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_explicitMaxContentWidth || m_maxContentWidth != message->maxContentWidth()) {
|
||||||
|
m_maxContentWidth = message->maxContentWidth();
|
||||||
|
Q_EMIT maxContentWidthChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto styles = attachedChildren();
|
||||||
|
for (auto *child : attachedChildren()) {
|
||||||
|
MessageAttached *message = qobject_cast<MessageAttached *>(child);
|
||||||
|
if (message != nullptr) {
|
||||||
|
message->propagateMessage(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessageAttached::attachedParentChange(QQuickAttachedPropertyPropagator *newParent, QQuickAttachedPropertyPropagator *oldParent)
|
||||||
|
{
|
||||||
|
Q_UNUSED(oldParent);
|
||||||
|
|
||||||
|
MessageAttached *attachedParent = qobject_cast<MessageAttached *>(newParent);
|
||||||
|
if (attachedParent) {
|
||||||
|
propagateMessage(attachedParent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "moc_messageattached.cpp"
|
||||||
78
src/messageattached.h
Normal file
78
src/messageattached.h
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
// 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
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QQmlEngine>
|
||||||
|
#include <QQuickAttachedPropertyPropagator>
|
||||||
|
#include <QQuickItem>
|
||||||
|
|
||||||
|
#include "neochatroom.h"
|
||||||
|
|
||||||
|
class MessageAttached : public QQuickAttachedPropertyPropagator
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
QML_NAMED_ELEMENT(Message)
|
||||||
|
QML_ATTACHED(MessageAttached)
|
||||||
|
QML_UNCREATABLE("")
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The room that the message comes from.
|
||||||
|
*/
|
||||||
|
Q_PROPERTY(NeoChatRoom *room READ room WRITE setRoom NOTIFY roomChanged FINAL)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The timeline for the current message.
|
||||||
|
*/
|
||||||
|
Q_PROPERTY(QQuickItem *timeline READ timeline WRITE setTimeline NOTIFY timelineChanged FINAL)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The index of the message in the timeline
|
||||||
|
*/
|
||||||
|
Q_PROPERTY(int index READ index WRITE setIndex NOTIFY indexChanged FINAL)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The width available to the message content.
|
||||||
|
*/
|
||||||
|
Q_PROPERTY(qreal maxContentWidth READ maxContentWidth WRITE setMaxContentWidth NOTIFY maxContentWidthChanged FINAL)
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit MessageAttached(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
static MessageAttached *qmlAttachedProperties(QObject *object);
|
||||||
|
|
||||||
|
NeoChatRoom *room() const;
|
||||||
|
void setRoom(NeoChatRoom *room);
|
||||||
|
|
||||||
|
QQuickItem *timeline() const;
|
||||||
|
void setTimeline(QQuickItem *timeline);
|
||||||
|
|
||||||
|
int index() const;
|
||||||
|
void setIndex(int index);
|
||||||
|
|
||||||
|
qreal maxContentWidth() const;
|
||||||
|
void setMaxContentWidth(qreal maxContentWidth);
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void roomChanged();
|
||||||
|
void timelineChanged();
|
||||||
|
void indexChanged();
|
||||||
|
void maxContentWidthChanged();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void propagateMessage(MessageAttached *message);
|
||||||
|
void attachedParentChange(QQuickAttachedPropertyPropagator *newParent, QQuickAttachedPropertyPropagator *oldParent) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPointer<NeoChatRoom> m_room;
|
||||||
|
bool m_explicitRoom = false;
|
||||||
|
|
||||||
|
QPointer<QQuickItem> m_timeline;
|
||||||
|
bool m_explicitTimeline = false;
|
||||||
|
|
||||||
|
int m_index;
|
||||||
|
bool m_explicitIndex = false;
|
||||||
|
|
||||||
|
qreal m_maxContentWidth = -1;
|
||||||
|
bool m_explicitMaxContentWidth = false;
|
||||||
|
};
|
||||||
@@ -18,11 +18,6 @@ import org.kde.neochat
|
|||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The NeoChatRoom the delegate is being displayed in.
|
|
||||||
*/
|
|
||||||
required property NeoChatRoom room
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The matrix ID of the message event.
|
* @brief The matrix ID of the message event.
|
||||||
*/
|
*/
|
||||||
@@ -56,11 +51,6 @@ ColumnLayout {
|
|||||||
audio.play();
|
audio.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The maximum width that the bubble's content can be.
|
|
||||||
*/
|
|
||||||
property real maxContentWidth: -1
|
|
||||||
|
|
||||||
MediaPlayer {
|
MediaPlayer {
|
||||||
id: audio
|
id: audio
|
||||||
onErrorOccurred: (error, errorString) => console.warn("Audio playback error:" + error + errorString)
|
onErrorOccurred: (error, errorString) => console.warn("Audio playback error:" + error + errorString)
|
||||||
@@ -75,7 +65,7 @@ ColumnLayout {
|
|||||||
PropertyChanges {
|
PropertyChanges {
|
||||||
target: playButton
|
target: playButton
|
||||||
icon.name: "media-playback-start"
|
icon.name: "media-playback-start"
|
||||||
onClicked: root.room.downloadFile(root.eventId)
|
onClicked: Message.room.downloadFile(root.eventId)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
State {
|
State {
|
||||||
@@ -89,7 +79,7 @@ ColumnLayout {
|
|||||||
target: playButton
|
target: playButton
|
||||||
icon.name: "media-playback-stop"
|
icon.name: "media-playback-stop"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
root.room.cancelFileTransfer(root.eventId);
|
Message.room.cancelFileTransfer(root.eventId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -159,7 +149,7 @@ ColumnLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QQC2.Label {
|
QQC2.Label {
|
||||||
visible: root.maxContentWidth > Kirigami.Units.gridUnit * 12
|
visible: root.Message.maxContentWidth > Kirigami.Units.gridUnit * 12
|
||||||
|
|
||||||
text: Format.formatDuration(audio.position) + "/" + Format.formatDuration(audio.duration)
|
text: Format.formatDuration(audio.position) + "/" + Format.formatDuration(audio.duration)
|
||||||
}
|
}
|
||||||
@@ -167,7 +157,7 @@ ColumnLayout {
|
|||||||
QQC2.Label {
|
QQC2.Label {
|
||||||
Layout.alignment: Qt.AlignRight
|
Layout.alignment: Qt.AlignRight
|
||||||
Layout.rightMargin: Kirigami.Units.smallSpacing
|
Layout.rightMargin: Kirigami.Units.smallSpacing
|
||||||
visible: audio.hasAudio && root.maxContentWidth < Kirigami.Units.gridUnit * 12
|
visible: audio.hasAudio && root.Message.maxContentWidth < Kirigami.Units.gridUnit * 12
|
||||||
|
|
||||||
text: Format.formatDuration(audio.position) + "/" + Format.formatDuration(audio.duration)
|
text: Format.formatDuration(audio.position) + "/" + Format.formatDuration(audio.duration)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,13 +31,8 @@ RowLayout {
|
|||||||
*/
|
*/
|
||||||
required property string timeString
|
required property string timeString
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The maximum width that the bubble's content can be.
|
|
||||||
*/
|
|
||||||
property real maxContentWidth: -1
|
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.maximumWidth: root.maxContentWidth
|
Layout.maximumWidth: Message.maxContentWidth
|
||||||
|
|
||||||
implicitHeight: Math.max(nameButton.implicitHeight, timeLabel.implicitHeight)
|
implicitHeight: Math.max(nameButton.implicitHeight, timeLabel.implicitHeight)
|
||||||
|
|
||||||
|
|||||||
@@ -15,31 +15,6 @@ import org.kde.neochat
|
|||||||
DelegateChooser {
|
DelegateChooser {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The NeoChatRoom the delegate is being displayed in.
|
|
||||||
*/
|
|
||||||
required property NeoChatRoom room
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The index of the delegate in the model.
|
|
||||||
*/
|
|
||||||
required property var index
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The timeline ListView this component is being used in.
|
|
||||||
*/
|
|
||||||
required property ListView timeline
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The maximum width that the bubble's content can be.
|
|
||||||
*/
|
|
||||||
property real maxContentWidth: -1
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The reply has been clicked.
|
|
||||||
*/
|
|
||||||
signal replyClicked(string eventID)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The user selected text has changed.
|
* @brief The user selected text has changed.
|
||||||
*/
|
*/
|
||||||
@@ -66,15 +41,12 @@ DelegateChooser {
|
|||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.Author
|
roleValue: MessageComponentType.Author
|
||||||
delegate: AuthorComponent {
|
delegate: AuthorComponent {}
|
||||||
maxContentWidth: root.maxContentWidth
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.Text
|
roleValue: MessageComponentType.Text
|
||||||
delegate: TextComponent {
|
delegate: TextComponent {
|
||||||
maxContentWidth: root.maxContentWidth
|
|
||||||
onSelectedTextChanged: root.selectedTextChanged(selectedText)
|
onSelectedTextChanged: root.selectedTextChanged(selectedText)
|
||||||
onHoveredLinkChanged: root.hoveredLinkChanged(hoveredLink)
|
onHoveredLinkChanged: root.hoveredLinkChanged(hoveredLink)
|
||||||
onShowMessageMenu: root.showMessageMenu()
|
onShowMessageMenu: root.showMessageMenu()
|
||||||
@@ -83,28 +55,17 @@ DelegateChooser {
|
|||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.Image
|
roleValue: MessageComponentType.Image
|
||||||
delegate: ImageComponent {
|
delegate: ImageComponent {}
|
||||||
room: root.room
|
|
||||||
index: root.index
|
|
||||||
timeline: root.timeline
|
|
||||||
maxContentWidth: root.maxContentWidth
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.Video
|
roleValue: MessageComponentType.Video
|
||||||
delegate: VideoComponent {
|
delegate: VideoComponent {}
|
||||||
room: root.room
|
|
||||||
index: root.index
|
|
||||||
timeline: root.timeline
|
|
||||||
maxContentWidth: root.maxContentWidth
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.Code
|
roleValue: MessageComponentType.Code
|
||||||
delegate: CodeComponent {
|
delegate: CodeComponent {
|
||||||
maxContentWidth: root.maxContentWidth
|
|
||||||
onSelectedTextChanged: selectedText => {
|
onSelectedTextChanged: selectedText => {
|
||||||
root.selectedTextChanged(selectedText);
|
root.selectedTextChanged(selectedText);
|
||||||
}
|
}
|
||||||
@@ -115,7 +76,6 @@ DelegateChooser {
|
|||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.Quote
|
roleValue: MessageComponentType.Quote
|
||||||
delegate: QuoteComponent {
|
delegate: QuoteComponent {
|
||||||
maxContentWidth: root.maxContentWidth
|
|
||||||
onSelectedTextChanged: selectedText => {
|
onSelectedTextChanged: selectedText => {
|
||||||
root.selectedTextChanged(selectedText);
|
root.selectedTextChanged(selectedText);
|
||||||
}
|
}
|
||||||
@@ -125,86 +85,57 @@ DelegateChooser {
|
|||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.Audio
|
roleValue: MessageComponentType.Audio
|
||||||
delegate: AudioComponent {
|
delegate: AudioComponent {}
|
||||||
room: root.room
|
|
||||||
maxContentWidth: root.maxContentWidth
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.File
|
roleValue: MessageComponentType.File
|
||||||
delegate: FileComponent {
|
delegate: FileComponent {}
|
||||||
room: root.room
|
|
||||||
maxContentWidth: root.maxContentWidth
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.Itinerary
|
roleValue: MessageComponentType.Itinerary
|
||||||
delegate: ItineraryComponent {
|
delegate: ItineraryComponent {}
|
||||||
maxContentWidth: root.maxContentWidth
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.Pdf
|
roleValue: MessageComponentType.Pdf
|
||||||
delegate: PdfPreviewComponent {
|
delegate: PdfPreviewComponent {}
|
||||||
maxContentWidth: root.maxContentWidth
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.Poll
|
roleValue: MessageComponentType.Poll
|
||||||
delegate: PollComponent {
|
delegate: PollComponent {}
|
||||||
room: root.room
|
|
||||||
maxContentWidth: root.maxContentWidth
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.Location
|
roleValue: MessageComponentType.Location
|
||||||
delegate: LocationComponent {
|
delegate: LocationComponent {}
|
||||||
maxContentWidth: root.maxContentWidth
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.LiveLocation
|
roleValue: MessageComponentType.LiveLocation
|
||||||
delegate: LiveLocationComponent {
|
delegate: LiveLocationComponent {}
|
||||||
room: root.room
|
|
||||||
maxContentWidth: root.maxContentWidth
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.Encrypted
|
roleValue: MessageComponentType.Encrypted
|
||||||
delegate: EncryptedComponent {
|
delegate: EncryptedComponent {}
|
||||||
maxContentWidth: root.maxContentWidth
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.Reply
|
roleValue: MessageComponentType.Reply
|
||||||
delegate: ReplyComponent {
|
delegate: ReplyComponent {}
|
||||||
maxContentWidth: root.maxContentWidth
|
|
||||||
onReplyClicked: eventId => {
|
|
||||||
root.replyClicked(eventId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.Reaction
|
roleValue: MessageComponentType.Reaction
|
||||||
delegate: ReactionComponent {
|
delegate: ReactionComponent {}
|
||||||
room: root.room
|
|
||||||
maxContentWidth: root.maxContentWidth
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.LinkPreview
|
roleValue: MessageComponentType.LinkPreview
|
||||||
delegate: LinkPreviewComponent {
|
delegate: LinkPreviewComponent {
|
||||||
maxContentWidth: root.maxContentWidth
|
|
||||||
onRemove: index => root.removeLinkPreview(index)
|
onRemove: index => root.removeLinkPreview(index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -213,31 +144,23 @@ DelegateChooser {
|
|||||||
roleValue: MessageComponentType.LinkPreviewLoad
|
roleValue: MessageComponentType.LinkPreviewLoad
|
||||||
delegate: LinkPreviewLoadComponent {
|
delegate: LinkPreviewLoadComponent {
|
||||||
type: LinkPreviewLoadComponent.LinkPreview
|
type: LinkPreviewLoadComponent.LinkPreview
|
||||||
maxContentWidth: root.maxContentWidth
|
|
||||||
onRemove: index => root.removeLinkPreview(index)
|
onRemove: index => root.removeLinkPreview(index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.ChatBar
|
roleValue: MessageComponentType.ChatBar
|
||||||
delegate: ChatBarComponent {
|
delegate: ChatBarComponent {}
|
||||||
room: root.room
|
|
||||||
maxContentWidth: root.maxContentWidth
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.ReplyButton
|
roleValue: MessageComponentType.ReplyButton
|
||||||
delegate: ReplyButtonComponent {
|
delegate: ReplyButtonComponent {}
|
||||||
room: root.room
|
|
||||||
maxContentWidth: root.maxContentWidth
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.FetchButton
|
roleValue: MessageComponentType.FetchButton
|
||||||
delegate: FetchButtonComponent {
|
delegate: FetchButtonComponent {
|
||||||
maxContentWidth: root.maxContentWidth
|
|
||||||
onFetchMoreEvents: root.fetchMoreEvents()
|
onFetchMoreEvents: root.fetchMoreEvents()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -252,16 +175,14 @@ DelegateChooser {
|
|||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.Loading
|
roleValue: MessageComponentType.Loading
|
||||||
delegate: LoadComponent {
|
delegate: LoadComponent {}
|
||||||
maxContentWidth: root.maxContentWidth
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.Separator
|
roleValue: MessageComponentType.Separator
|
||||||
delegate: Kirigami.Separator {
|
delegate: Kirigami.Separator {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.maximumWidth: root.maxContentWidth
|
Layout.maximumWidth: Message.maxContentWidth
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,16 +22,6 @@ import org.kde.neochat
|
|||||||
QQC2.Control {
|
QQC2.Control {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The NeoChatRoom the delegate is being displayed in.
|
|
||||||
*/
|
|
||||||
required property NeoChatRoom room
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The index of the delegate in the model.
|
|
||||||
*/
|
|
||||||
required property var index
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The message author.
|
* @brief The message author.
|
||||||
*
|
*
|
||||||
@@ -66,23 +56,8 @@ QQC2.Control {
|
|||||||
*/
|
*/
|
||||||
property alias showBackground: bubbleBackground.visible
|
property alias showBackground: bubbleBackground.visible
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The timeline ListView this component is being used in.
|
|
||||||
*/
|
|
||||||
required property ListView timeline
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The maximum width that the bubble's content can be.
|
|
||||||
*/
|
|
||||||
property real maxContentWidth: -1
|
|
||||||
|
|
||||||
required property bool isPending
|
required property bool isPending
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The reply has been clicked.
|
|
||||||
*/
|
|
||||||
signal replyClicked(string eventID)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The user selected text has changed.
|
* @brief The user selected text has changed.
|
||||||
*/
|
*/
|
||||||
@@ -108,6 +83,7 @@ QQC2.Control {
|
|||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: contentColumn
|
id: contentColumn
|
||||||
spacing: Kirigami.Units.smallSpacing
|
spacing: Kirigami.Units.smallSpacing
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
id: contentRepeater
|
id: contentRepeater
|
||||||
model: MessageContentFilterModel {
|
model: MessageContentFilterModel {
|
||||||
@@ -115,14 +91,6 @@ QQC2.Control {
|
|||||||
sourceModel: root.contentModel
|
sourceModel: root.contentModel
|
||||||
}
|
}
|
||||||
delegate: MessageComponentChooser {
|
delegate: MessageComponentChooser {
|
||||||
room: root.room
|
|
||||||
index: root.index
|
|
||||||
timeline: root.timeline
|
|
||||||
maxContentWidth: root.maxContentWidth
|
|
||||||
|
|
||||||
onReplyClicked: eventId => {
|
|
||||||
root.replyClicked(eventId);
|
|
||||||
}
|
|
||||||
onSelectedTextChanged: selectedText => {
|
onSelectedTextChanged: selectedText => {
|
||||||
root.selectedTextChanged(selectedText);
|
root.selectedTextChanged(selectedText);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,25 +16,15 @@ import org.kde.neochat.chatbar
|
|||||||
QQC2.TextArea {
|
QQC2.TextArea {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The NeoChatRoom the delegate is being displayed in.
|
|
||||||
*/
|
|
||||||
required property NeoChatRoom room
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The ChatBarCache to use.
|
* @brief The ChatBarCache to use.
|
||||||
*/
|
*/
|
||||||
required property ChatBarCache chatBarCache
|
required property ChatBarCache chatBarCache
|
||||||
onChatBarCacheChanged: documentHandler.chatBarCache = chatBarCache
|
onChatBarCacheChanged: documentHandler.chatBarCache = chatBarCache
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The maximum width that the bubble's content can be.
|
|
||||||
*/
|
|
||||||
property real maxContentWidth: -1
|
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredWidth: textMetrics.advanceWidth + rightPadding + Kirigami.Units.smallSpacing + Kirigami.Units.gridUnit
|
Layout.preferredWidth: textMetrics.advanceWidth + rightPadding + Kirigami.Units.smallSpacing + Kirigami.Units.gridUnit
|
||||||
Layout.maximumWidth: root.maxContentWidth
|
Layout.maximumWidth: Message.maxContentWidth
|
||||||
Layout.minimumHeight: chatButtons.height + topPadding + bottomPadding
|
Layout.minimumHeight: chatButtons.height + topPadding + bottomPadding
|
||||||
|
|
||||||
Component.onCompleted: _private.updateText()
|
Component.onCompleted: _private.updateText()
|
||||||
@@ -124,7 +114,7 @@ QQC2.TextArea {
|
|||||||
height: implicitHeight
|
height: implicitHeight
|
||||||
y: -height - 5
|
y: -height - 5
|
||||||
z: 10
|
z: 10
|
||||||
connection: root.room.connection
|
connection: root.Message.room.connection
|
||||||
chatDocumentHandler: documentHandler
|
chatDocumentHandler: documentHandler
|
||||||
Behavior on height {
|
Behavior on height {
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
@@ -144,7 +134,7 @@ QQC2.TextArea {
|
|||||||
cursorPosition: root.cursorPosition
|
cursorPosition: root.cursorPosition
|
||||||
selectionStart: root.selectionStart
|
selectionStart: root.selectionStart
|
||||||
selectionEnd: root.selectionEnd
|
selectionEnd: root.selectionEnd
|
||||||
room: root.room // We don't care about saving for edits so this is OK.
|
room: root.Message.room // We don't care about saving for edits so this is OK.
|
||||||
mentionColor: Kirigami.Theme.linkColor
|
mentionColor: Kirigami.Theme.linkColor
|
||||||
errorColor: Kirigami.Theme.negativeTextColor
|
errorColor: Kirigami.Theme.negativeTextColor
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,11 +37,6 @@ QQC2.Control {
|
|||||||
*/
|
*/
|
||||||
required property var componentAttributes
|
required property var componentAttributes
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The maximum width that the bubble's content can be.
|
|
||||||
*/
|
|
||||||
property real maxContentWidth: -1
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The user selected text has changed.
|
* @brief The user selected text has changed.
|
||||||
*/
|
*/
|
||||||
@@ -54,7 +49,7 @@ QQC2.Control {
|
|||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
Layout.maximumWidth: root.maxContentWidth
|
Layout.maximumWidth: Message.maxContentWidth
|
||||||
Layout.maximumHeight: Kirigami.Units.gridUnit * 20
|
Layout.maximumHeight: Kirigami.Units.gridUnit * 20
|
||||||
|
|
||||||
topPadding: 0
|
topPadding: 0
|
||||||
@@ -64,7 +59,7 @@ QQC2.Control {
|
|||||||
|
|
||||||
contentItem: QQC2.ScrollView {
|
contentItem: QQC2.ScrollView {
|
||||||
id: codeScrollView
|
id: codeScrollView
|
||||||
contentWidth: root.maxContentWidth
|
contentWidth: root.Message.maxContentWidth
|
||||||
|
|
||||||
// HACK: Hide unnecessary horizontal scrollbar (https://bugreports.qt.io/browse/QTBUG-83890)
|
// HACK: Hide unnecessary horizontal scrollbar (https://bugreports.qt.io/browse/QTBUG-83890)
|
||||||
QQC2.ScrollBar.horizontal.policy: QQC2.ScrollBar.AlwaysOff
|
QQC2.ScrollBar.horizontal.policy: QQC2.ScrollBar.AlwaysOff
|
||||||
|
|||||||
@@ -6,17 +6,14 @@ import QtQuick.Layouts
|
|||||||
|
|
||||||
import org.kde.kirigami as Kirigami
|
import org.kde.kirigami as Kirigami
|
||||||
|
|
||||||
|
import org.kde.neochat
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A component for an encrypted message that can't be decrypted.
|
* @brief A component for an encrypted message that can't be decrypted.
|
||||||
*/
|
*/
|
||||||
TextEdit {
|
TextEdit {
|
||||||
/**
|
|
||||||
* @brief The maximum width that the bubble's content can be.
|
|
||||||
*/
|
|
||||||
property real maxContentWidth: -1
|
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.maximumWidth: root.maxContentWidth
|
Layout.maximumWidth: Message.maxContentWidth
|
||||||
|
|
||||||
text: i18n("This message is encrypted and the sender has not shared the key with this device.")
|
text: i18n("This message is encrypted and the sender has not shared the key with this device.")
|
||||||
color: Kirigami.Theme.disabledTextColor
|
color: Kirigami.Theme.disabledTextColor
|
||||||
|
|||||||
@@ -17,18 +17,13 @@ import org.kde.neochat.chatbar
|
|||||||
Delegates.RoundedItemDelegate {
|
Delegates.RoundedItemDelegate {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The maximum width that the bubble's content can be.
|
|
||||||
*/
|
|
||||||
property real maxContentWidth: -1
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Request more events in the thread be loaded.
|
* @brief Request more events in the thread be loaded.
|
||||||
*/
|
*/
|
||||||
signal fetchMoreEvents()
|
signal fetchMoreEvents()
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.maximumWidth: root.maxContentWidth
|
Layout.maximumWidth: Message.maxContentWidth
|
||||||
|
|
||||||
leftInset: 0
|
leftInset: 0
|
||||||
rightInset: 0
|
rightInset: 0
|
||||||
|
|||||||
@@ -20,11 +20,6 @@ import org.kde.neochat
|
|||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The NeoChatRoom the delegate is being displayed in.
|
|
||||||
*/
|
|
||||||
required property NeoChatRoom room
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The matrix ID of the message event.
|
* @brief The matrix ID of the message event.
|
||||||
*/
|
*/
|
||||||
@@ -65,14 +60,9 @@ ColumnLayout {
|
|||||||
*/
|
*/
|
||||||
property bool autoOpenFile: false
|
property bool autoOpenFile: false
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The maximum width that the bubble's content can be.
|
|
||||||
*/
|
|
||||||
property real maxContentWidth: -1
|
|
||||||
|
|
||||||
function saveFileAs() {
|
function saveFileAs() {
|
||||||
const dialog = fileDialog.createObject(QQC2.Overlay.overlay);
|
const dialog = fileDialog.createObject(QQC2.Overlay.overlay);
|
||||||
dialog.selectedFile = root.room.fileNameToDownload(root.eventId);
|
dialog.selectedFile = Message.room.fileNameToDownload(root.eventId);
|
||||||
dialog.open();
|
dialog.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,7 +71,7 @@ ColumnLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.maximumWidth: root.maxContentWidth
|
Layout.maximumWidth: Message.maxContentWidth
|
||||||
spacing: Kirigami.Units.largeSpacing
|
spacing: Kirigami.Units.largeSpacing
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
@@ -138,7 +128,7 @@ ColumnLayout {
|
|||||||
target: downloadButton
|
target: downloadButton
|
||||||
icon.name: "media-playback-stop"
|
icon.name: "media-playback-stop"
|
||||||
QQC2.ToolTip.text: i18nc("tooltip for a button on a message; stops downloading the message's file", "Stop Download")
|
QQC2.ToolTip.text: i18nc("tooltip for a button on a message; stops downloading the message's file", "Stop Download")
|
||||||
onClicked: root.room.cancelFileTransfer(root.eventId)
|
onClicked: Message.room.cancelFileTransfer(root.eventId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -171,7 +161,7 @@ ColumnLayout {
|
|||||||
icon.name: "document-open"
|
icon.name: "document-open"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
autoOpenFile = true;
|
autoOpenFile = true;
|
||||||
root.room.downloadTempFile(root.eventId);
|
root.Message.room.downloadTempFile(root.eventId);
|
||||||
}
|
}
|
||||||
|
|
||||||
QQC2.ToolTip.text: i18nc("tooltip for a button on a message; offers ability to open its downloaded file with an appropriate application", "Open File")
|
QQC2.ToolTip.text: i18nc("tooltip for a button on a message; offers ability to open its downloaded file with an appropriate application", "Open File")
|
||||||
@@ -201,7 +191,7 @@ ColumnLayout {
|
|||||||
if (autoOpenFile) {
|
if (autoOpenFile) {
|
||||||
UrlHelper.copyTo(root.fileTransferInfo.localPath, selectedFile);
|
UrlHelper.copyTo(root.fileTransferInfo.localPath, selectedFile);
|
||||||
} else {
|
} else {
|
||||||
root.room.download(root.eventId, selectedFile);
|
root.Message.room.download(root.eventId, selectedFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,16 +16,6 @@ import org.kde.neochat
|
|||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The NeoChatRoom the delegate is being displayed in.
|
|
||||||
*/
|
|
||||||
required property NeoChatRoom room
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The index of the delegate in the model.
|
|
||||||
*/
|
|
||||||
required property var index
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The matrix ID of the message event.
|
* @brief The matrix ID of the message event.
|
||||||
*/
|
*/
|
||||||
@@ -56,16 +46,6 @@ Item {
|
|||||||
*/
|
*/
|
||||||
required property var fileTransferInfo
|
required property var fileTransferInfo
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The timeline ListView this component is being used in.
|
|
||||||
*/
|
|
||||||
required property ListView timeline
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The maximum width that the bubble's content can be.
|
|
||||||
*/
|
|
||||||
property real maxContentWidth: -1
|
|
||||||
|
|
||||||
implicitWidth: mediaSizeHelper.currentSize.width
|
implicitWidth: mediaSizeHelper.currentSize.width
|
||||||
implicitHeight: mediaSizeHelper.currentSize.height
|
implicitHeight: mediaSizeHelper.currentSize.height
|
||||||
|
|
||||||
@@ -153,13 +133,13 @@ Item {
|
|||||||
if (root.mediaInfo.animated) {
|
if (root.mediaInfo.animated) {
|
||||||
_private.imageItem.paused = true;
|
_private.imageItem.paused = true;
|
||||||
}
|
}
|
||||||
root.timeline.interactive = false;
|
root.Message.timeline.interactive = false;
|
||||||
if (!root.mediaInfo.isSticker) {
|
if (!root.mediaInfo.isSticker) {
|
||||||
// We need to make sure the index is that of the MediaMessageFilterModel.
|
// We need to make sure the index is that of the MediaMessageFilterModel.
|
||||||
if (root.timeline.model instanceof MessageFilterModel) {
|
if (root.Message.timeline.model instanceof MessageFilterModel) {
|
||||||
RoomManager.maximizeMedia(RoomManager.mediaMessageFilterModel.getRowForSourceItem(root.index));
|
RoomManager.maximizeMedia(RoomManager.mediaMessageFilterModel.getRowForSourceItem(root.Message.index));
|
||||||
} else {
|
} else {
|
||||||
RoomManager.maximizeMedia(root.index);
|
RoomManager.maximizeMedia(root.Message.index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -170,7 +150,7 @@ Item {
|
|||||||
openSavedFile();
|
openSavedFile();
|
||||||
} else {
|
} else {
|
||||||
openOnFinished = true;
|
openOnFinished = true;
|
||||||
root.room.downloadFile(root.eventId, StandardPaths.writableLocation(StandardPaths.CacheLocation) + "/" + root.eventId.replace(":", "_").replace("/", "_").replace("+", "_") + root.room.fileNameToDownload(root.eventId));
|
Message.room.downloadFile(root.eventId, StandardPaths.writableLocation(StandardPaths.CacheLocation) + "/" + root.eventId.replace(":", "_").replace("/", "_").replace("+", "_") + Message.room.fileNameToDownload(root.eventId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,7 +163,7 @@ Item {
|
|||||||
|
|
||||||
MediaSizeHelper {
|
MediaSizeHelper {
|
||||||
id: mediaSizeHelper
|
id: mediaSizeHelper
|
||||||
contentMaxWidth: root.maxContentWidth
|
contentMaxWidth: root.Message.maxContentWidth
|
||||||
mediaWidth: root?.mediaInfo.isSticker ? 256 : (root?.mediaInfo.width ?? 0)
|
mediaWidth: root?.mediaInfo.isSticker ? 256 : (root?.mediaInfo.width ?? 0)
|
||||||
mediaHeight: root?.mediaInfo.isSticker ? 256 : (root?.mediaInfo.height ?? 0)
|
mediaHeight: root?.mediaInfo.isSticker ? 256 : (root?.mediaInfo.height ?? 0)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import Qt.labs.qmlmodels
|
|||||||
|
|
||||||
import org.kde.kirigami as Kirigami
|
import org.kde.kirigami as Kirigami
|
||||||
|
|
||||||
|
import org.kde.neochat
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A component to show a preview of a file that can integrate with KDE itinerary.
|
* @brief A component to show a preview of a file that can integrate with KDE itinerary.
|
||||||
*/
|
*/
|
||||||
@@ -20,13 +22,8 @@ ColumnLayout {
|
|||||||
*/
|
*/
|
||||||
required property var itineraryModel
|
required property var itineraryModel
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The maximum width that the bubble's content can be.
|
|
||||||
*/
|
|
||||||
property real maxContentWidth: -1
|
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.maximumWidth: root.maxContentWidth
|
Layout.maximumWidth: Message.maxContentWidth
|
||||||
spacing: Kirigami.Units.largeSpacing
|
spacing: Kirigami.Units.largeSpacing
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
|
|||||||
@@ -43,18 +43,13 @@ QQC2.Control {
|
|||||||
|
|
||||||
property bool truncated: linkPreviewDescription.truncated || !linkPreviewDescription.visible
|
property bool truncated: linkPreviewDescription.truncated || !linkPreviewDescription.visible
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The maximum width that the bubble's content can be.
|
|
||||||
*/
|
|
||||||
property real maxContentWidth: -1
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Request for this delegate to be removed.
|
* @brief Request for this delegate to be removed.
|
||||||
*/
|
*/
|
||||||
signal remove(int index)
|
signal remove(int index)
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.maximumWidth: root.maxContentWidth
|
Layout.maximumWidth: Message.maxContentWidth
|
||||||
Layout.minimumHeight: root.defaultHeight
|
Layout.minimumHeight: root.defaultHeight
|
||||||
|
|
||||||
leftPadding: 0
|
leftPadding: 0
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import QtQuick.Layouts
|
|||||||
|
|
||||||
import org.kde.kirigami as Kirigami
|
import org.kde.kirigami as Kirigami
|
||||||
|
|
||||||
|
import org.kde.neochat
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A component to show a link preview loading from a message.
|
* @brief A component to show a link preview loading from a message.
|
||||||
*/
|
*/
|
||||||
@@ -28,11 +30,6 @@ QQC2.Control {
|
|||||||
*/
|
*/
|
||||||
property var defaultHeight: Kirigami.Units.gridUnit * 3 + Kirigami.Units.smallSpacing * 2
|
property var defaultHeight: Kirigami.Units.gridUnit * 3 + Kirigami.Units.smallSpacing * 2
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The maximum width that the bubble's content can be.
|
|
||||||
*/
|
|
||||||
property real maxContentWidth: -1
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Request for this delegate to be removed.
|
* @brief Request for this delegate to be removed.
|
||||||
*/
|
*/
|
||||||
@@ -44,7 +41,7 @@ QQC2.Control {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.maximumWidth: root.maxContentWidth
|
Layout.maximumWidth: Message.maxContentWidth
|
||||||
|
|
||||||
contentItem : RowLayout {
|
contentItem : RowLayout {
|
||||||
spacing: Kirigami.Units.smallSpacing
|
spacing: Kirigami.Units.smallSpacing
|
||||||
|
|||||||
@@ -17,11 +17,6 @@ import org.kde.neochat
|
|||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The NeoChatRoom the delegate is being displayed in.
|
|
||||||
*/
|
|
||||||
required property NeoChatRoom room
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The matrix ID of the message event.
|
* @brief The matrix ID of the message event.
|
||||||
*/
|
*/
|
||||||
@@ -32,24 +27,19 @@ ColumnLayout {
|
|||||||
*/
|
*/
|
||||||
required property string display
|
required property string display
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The maximum width that the bubble's content can be.
|
|
||||||
*/
|
|
||||||
property real maxContentWidth: -1
|
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.maximumWidth: root.maxContentWidth
|
Layout.maximumWidth: Message.maxContentWidth
|
||||||
|
|
||||||
LiveLocationsModel {
|
LiveLocationsModel {
|
||||||
id: liveLocationModel
|
id: liveLocationModel
|
||||||
eventId: root.eventId
|
eventId: root.eventId
|
||||||
room: root.room
|
room: Message.room
|
||||||
}
|
}
|
||||||
MapView {
|
MapView {
|
||||||
id: mapView
|
id: mapView
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredWidth: root.maxContentWidth
|
Layout.preferredWidth: root.Message.maxContentWidth
|
||||||
Layout.preferredHeight: root.maxContentWidth / 16 * 9
|
Layout.preferredHeight: root.Message.maxContentWidth / 16 * 9
|
||||||
|
|
||||||
map.center: QtPositioning.coordinate(liveLocationModel.boundingBox.y, liveLocationModel.boundingBox.x)
|
map.center: QtPositioning.coordinate(liveLocationModel.boundingBox.y, liveLocationModel.boundingBox.x)
|
||||||
map.zoomLevel: 15
|
map.zoomLevel: 15
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import QtQuick.Layouts
|
|||||||
|
|
||||||
import org.kde.kirigami as Kirigami
|
import org.kde.kirigami as Kirigami
|
||||||
|
|
||||||
|
import org.kde.neochat
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A component to show that part of a message is loading.
|
* @brief A component to show that part of a message is loading.
|
||||||
*/
|
*/
|
||||||
@@ -15,13 +17,8 @@ RowLayout {
|
|||||||
|
|
||||||
required property string display
|
required property string display
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The maximum width that the bubble's content can be.
|
|
||||||
*/
|
|
||||||
property real maxContentWidth: -1
|
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.maximumWidth: root.maxContentWidth
|
Layout.maximumWidth: Message.maxContentWidth
|
||||||
spacing: Kirigami.Units.smallSpacing
|
spacing: Kirigami.Units.smallSpacing
|
||||||
|
|
||||||
QQC2.BusyIndicator {}
|
QQC2.BusyIndicator {}
|
||||||
|
|||||||
@@ -49,19 +49,14 @@ ColumnLayout {
|
|||||||
*/
|
*/
|
||||||
required property string asset
|
required property string asset
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The maximum width that the bubble's content can be.
|
|
||||||
*/
|
|
||||||
property real maxContentWidth: -1
|
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.maximumWidth: root.maxContentWidth
|
Layout.maximumWidth: Message.maxContentWidth
|
||||||
|
|
||||||
MapView {
|
MapView {
|
||||||
id: mapView
|
id: mapView
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredWidth: root.maxContentWidth
|
Layout.preferredWidth: root.Message.maxContentWidth
|
||||||
Layout.preferredHeight: root.maxContentWidth / 16 * 9
|
Layout.preferredHeight: root.Message.maxContentWidth / 16 * 9
|
||||||
|
|
||||||
map.center: QtPositioning.coordinate(root.latitude, root.longitude)
|
map.center: QtPositioning.coordinate(root.latitude, root.longitude)
|
||||||
map.zoomLevel: 15
|
map.zoomLevel: 15
|
||||||
|
|||||||
@@ -14,11 +14,6 @@ BaseMessageComponentChooser {
|
|||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.ThreadBody
|
roleValue: MessageComponentType.ThreadBody
|
||||||
delegate: ThreadBodyComponent {
|
delegate: ThreadBodyComponent {}
|
||||||
room: root.room
|
|
||||||
index: root.index
|
|
||||||
timeline: root.timeline
|
|
||||||
maxContentWidth: root.maxContentWidth
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,12 +143,6 @@ TimelineDelegate {
|
|||||||
*/
|
*/
|
||||||
signal openExternally
|
signal openExternally
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The reply has been clicked.
|
|
||||||
*/
|
|
||||||
signal replyClicked(string eventID)
|
|
||||||
onReplyClicked: eventID => ListView.view.goToEvent(eventID)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The main delegate content item to show in the bubble.
|
* @brief The main delegate content item to show in the bubble.
|
||||||
*/
|
*/
|
||||||
@@ -198,6 +192,11 @@ TimelineDelegate {
|
|||||||
*/
|
*/
|
||||||
property real contentMaxWidth: (root.isThreaded ? bubbleSizeHelper.parentWidth : bubbleSizeHelper.currentWidth) - bubble.leftPadding - bubble.rightPadding
|
property real contentMaxWidth: (root.isThreaded ? bubbleSizeHelper.parentWidth : bubbleSizeHelper.currentWidth) - bubble.leftPadding - bubble.rightPadding
|
||||||
|
|
||||||
|
Message.room: root.room
|
||||||
|
Message.timeline: root.ListView.view
|
||||||
|
Message.index: root.index
|
||||||
|
Message.maxContentWidth: contentMaxWidth
|
||||||
|
|
||||||
width: parent?.width
|
width: parent?.width
|
||||||
rightPadding: NeoChatConfig.compactLayout && root.ListView.view.width >= Kirigami.Units.gridUnit * 20 ? Kirigami.Units.gridUnit * 2 + Kirigami.Units.largeSpacing : Kirigami.Units.largeSpacing
|
rightPadding: NeoChatConfig.compactLayout && root.ListView.view.width >= Kirigami.Units.gridUnit * 20 ? Kirigami.Units.gridUnit * 2 + Kirigami.Units.largeSpacing : Kirigami.Units.largeSpacing
|
||||||
|
|
||||||
@@ -255,7 +254,6 @@ TimelineDelegate {
|
|||||||
anchors.left: avatar.right
|
anchors.left: avatar.right
|
||||||
anchors.leftMargin: Kirigami.Units.largeSpacing
|
anchors.leftMargin: Kirigami.Units.largeSpacing
|
||||||
anchors.rightMargin: rightPadding
|
anchors.rightMargin: rightPadding
|
||||||
maxContentWidth: root.contentMaxWidth
|
|
||||||
|
|
||||||
topPadding: NeoChatConfig.compactLayout ? Kirigami.Units.smallSpacing / 2 : Kirigami.Units.largeSpacing
|
topPadding: NeoChatConfig.compactLayout ? Kirigami.Units.smallSpacing / 2 : Kirigami.Units.largeSpacing
|
||||||
bottomPadding: NeoChatConfig.compactLayout ? Kirigami.Units.mediumSpacing / 2 : Kirigami.Units.largeSpacing
|
bottomPadding: NeoChatConfig.compactLayout ? Kirigami.Units.mediumSpacing / 2 : Kirigami.Units.largeSpacing
|
||||||
@@ -284,22 +282,16 @@ TimelineDelegate {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
room: root.room
|
|
||||||
index: root.index
|
|
||||||
author: root.author
|
author: root.author
|
||||||
showAuthor: root.showAuthor
|
showAuthor: root.showAuthor
|
||||||
isThreaded: root.isThreaded
|
isThreaded: root.isThreaded
|
||||||
|
|
||||||
contentModel: root.contentModel
|
contentModel: root.contentModel
|
||||||
timeline: root.ListView.view
|
|
||||||
|
|
||||||
showHighlight: root.showHighlight
|
showHighlight: root.showHighlight
|
||||||
|
|
||||||
isPending: root.isPending
|
isPending: root.isPending
|
||||||
|
|
||||||
onReplyClicked: eventId => {
|
|
||||||
root.replyClicked(eventId);
|
|
||||||
}
|
|
||||||
onSelectedTextChanged: selectedText => {
|
onSelectedTextChanged: selectedText => {
|
||||||
root.selectedText = selectedText;
|
root.selectedText = selectedText;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,11 +20,6 @@ Rectangle {
|
|||||||
*/
|
*/
|
||||||
required property var componentAttributes
|
required property var componentAttributes
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The maximum width that the bubble's content can be.
|
|
||||||
*/
|
|
||||||
property real maxContentWidth: -1
|
|
||||||
|
|
||||||
Layout.preferredWidth: mediaSizeHelper.currentSize.width
|
Layout.preferredWidth: mediaSizeHelper.currentSize.width
|
||||||
Layout.preferredHeight: mediaSizeHelper.currentSize.height
|
Layout.preferredHeight: mediaSizeHelper.currentSize.height
|
||||||
|
|
||||||
@@ -36,7 +31,7 @@ Rectangle {
|
|||||||
|
|
||||||
MediaSizeHelper {
|
MediaSizeHelper {
|
||||||
id: mediaSizeHelper
|
id: mediaSizeHelper
|
||||||
contentMaxWidth: root.maxContentWidth
|
contentMaxWidth: root.Message.maxContentWidth
|
||||||
mediaWidth: root.componentAttributes.size.width
|
mediaWidth: root.componentAttributes.size.width
|
||||||
mediaHeight: root.componentAttributes.size.height
|
mediaHeight: root.componentAttributes.size.height
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,11 +16,6 @@ import org.kde.neochat
|
|||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The NeoChatRoom the delegate is being displayed in.
|
|
||||||
*/
|
|
||||||
required property NeoChatRoom room
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The matrix ID of the message event.
|
* @brief The matrix ID of the message event.
|
||||||
*/
|
*/
|
||||||
@@ -34,13 +29,8 @@ ColumnLayout {
|
|||||||
*/
|
*/
|
||||||
required property var pollHandler
|
required property var pollHandler
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The maximum width that the bubble's content can be.
|
|
||||||
*/
|
|
||||||
property real maxContentWidth: -1
|
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.maximumWidth: root.maxContentWidth
|
Layout.maximumWidth: Message.maxContentWidth
|
||||||
|
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
||||||
@@ -59,7 +49,7 @@ ColumnLayout {
|
|||||||
Layout.leftMargin: -Kirigami.Units.largeSpacing - Kirigami.Units.smallSpacing
|
Layout.leftMargin: -Kirigami.Units.largeSpacing - Kirigami.Units.smallSpacing
|
||||||
Layout.rightMargin: -Kirigami.Units.largeSpacing - Kirigami.Units.smallSpacing
|
Layout.rightMargin: -Kirigami.Units.largeSpacing - Kirigami.Units.smallSpacing
|
||||||
|
|
||||||
checked: root.pollHandler.answers[root.room.localMember.id] ? root.pollHandler.answers[root.room.localMember.id].includes(modelData["id"]) : false
|
checked: root.pollHandler.answers[root.Message.room.localMember.id] ? root.pollHandler.answers[root.Message.room.localMember.id].includes(modelData["id"]) : false
|
||||||
onClicked: root.pollHandler.sendPollAnswer(root.eventId, modelData["id"])
|
onClicked: root.pollHandler.sendPollAnswer(root.eventId, modelData["id"])
|
||||||
enabled: !root.pollHandler.hasEnded
|
enabled: !root.pollHandler.hasEnded
|
||||||
text: modelData["org.matrix.msc1767.text"]
|
text: modelData["org.matrix.msc1767.text"]
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import QtQuick.Layouts
|
|||||||
|
|
||||||
import org.kde.kirigami as Kirigami
|
import org.kde.kirigami as Kirigami
|
||||||
|
|
||||||
|
import org.kde.neochat
|
||||||
|
|
||||||
QQC2.Control {
|
QQC2.Control {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
@@ -15,11 +17,6 @@ QQC2.Control {
|
|||||||
*/
|
*/
|
||||||
required property string display
|
required property string display
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The maximum width that the bubble's content can be.
|
|
||||||
*/
|
|
||||||
property real maxContentWidth: -1
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The user selected text has changed.
|
* @brief The user selected text has changed.
|
||||||
*/
|
*/
|
||||||
@@ -32,7 +29,7 @@ QQC2.Control {
|
|||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
Layout.maximumWidth: root.maxContentWidth
|
Layout.maximumWidth: Message.maxContentWidth
|
||||||
|
|
||||||
topPadding: 0
|
topPadding: 0
|
||||||
bottomPadding: 0
|
bottomPadding: 0
|
||||||
|
|||||||
@@ -13,11 +13,6 @@ import org.kde.neochat
|
|||||||
Flow {
|
Flow {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The NeoChatRoom the delegate is being displayed in.
|
|
||||||
*/
|
|
||||||
required property NeoChatRoom room
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The matrix ID of the message event.
|
* @brief The matrix ID of the message event.
|
||||||
*/
|
*/
|
||||||
@@ -28,14 +23,9 @@ Flow {
|
|||||||
*/
|
*/
|
||||||
required property ReactionModel reactionModel
|
required property ReactionModel reactionModel
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The maximum width that the bubble's content can be.
|
|
||||||
*/
|
|
||||||
property real maxContentWidth: -1
|
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
Layout.maximumWidth: root.maxContentWidth
|
Layout.maximumWidth: Message.maxContentWidth
|
||||||
|
|
||||||
spacing: Kirigami.Units.smallSpacing
|
spacing: Kirigami.Units.smallSpacing
|
||||||
|
|
||||||
@@ -79,7 +69,9 @@ Flow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked: root.room.toggleReaction(root.eventId, reactionDelegate.reaction)
|
onClicked: {
|
||||||
|
root.Message.room.toggleReaction(root.eventId, reactionDelegate.reaction)
|
||||||
|
}
|
||||||
|
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
|
|
||||||
@@ -114,7 +106,7 @@ Flow {
|
|||||||
onClicked: {
|
onClicked: {
|
||||||
var dialog = emojiDialog.createObject(reactButton);
|
var dialog = emojiDialog.createObject(reactButton);
|
||||||
dialog.chosen.connect(emoji => {
|
dialog.chosen.connect(emoji => {
|
||||||
root.room.toggleReaction(root.eventId, emoji);
|
root.Message.room.toggleReaction(root.eventId, emoji);
|
||||||
if (!Kirigami.Settings.isMobile) {
|
if (!Kirigami.Settings.isMobile) {
|
||||||
root.focusChatBar();
|
root.focusChatBar();
|
||||||
}
|
}
|
||||||
@@ -133,7 +125,7 @@ Flow {
|
|||||||
id: emojiDialog
|
id: emojiDialog
|
||||||
|
|
||||||
EmojiDialog {
|
EmojiDialog {
|
||||||
currentRoom: root.room
|
currentRoom: root.Message.room
|
||||||
showQuickReaction: true
|
showQuickReaction: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,23 +17,13 @@ import org.kde.neochat.chatbar
|
|||||||
Delegates.RoundedItemDelegate {
|
Delegates.RoundedItemDelegate {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The NeoChatRoom the delegate is being displayed in.
|
|
||||||
*/
|
|
||||||
required property NeoChatRoom room
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The thread root ID.
|
* @brief The thread root ID.
|
||||||
*/
|
*/
|
||||||
required property string threadRoot
|
required property string threadRoot
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The maximum width that the bubble's content can be.
|
|
||||||
*/
|
|
||||||
property real maxContentWidth: -1
|
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.maximumWidth: root.maxContentWidth
|
Layout.maximumWidth: Message.maxContentWidth
|
||||||
|
|
||||||
leftInset: 0
|
leftInset: 0
|
||||||
rightInset: 0
|
rightInset: 0
|
||||||
@@ -44,9 +34,9 @@ Delegates.RoundedItemDelegate {
|
|||||||
text: i18nc("@action:button", "Reply")
|
text: i18nc("@action:button", "Reply")
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
root.room.threadCache.replyId = "";
|
Message.room.threadCache.replyId = "";
|
||||||
root.room.threadCache.threadId = root.threadRoot;
|
Message.room.threadCache.threadId = root.threadRoot;
|
||||||
root.room.mainCache.clearRelations();
|
Message.room.mainCache.clearRelations();
|
||||||
root.room.editCache.clearRelations();
|
Message.room.editCache.clearRelations();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,16 +43,6 @@ RowLayout {
|
|||||||
*/
|
*/
|
||||||
required property var replyContentModel
|
required property var replyContentModel
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The maximum width that the bubble's content can be.
|
|
||||||
*/
|
|
||||||
property real maxContentWidth: -1
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The reply has been clicked.
|
|
||||||
*/
|
|
||||||
signal replyClicked(string eventID)
|
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
spacing: Kirigami.Units.largeSpacing
|
spacing: Kirigami.Units.largeSpacing
|
||||||
@@ -69,13 +59,13 @@ RowLayout {
|
|||||||
id: contentColumn
|
id: contentColumn
|
||||||
spacing: Kirigami.Units.smallSpacing
|
spacing: Kirigami.Units.smallSpacing
|
||||||
|
|
||||||
|
Message.maxContentWidth: _private.availableContentWidth
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
id: contentRepeater
|
id: contentRepeater
|
||||||
model: root.replyContentModel
|
model: root.replyContentModel
|
||||||
delegate: ReplyMessageComponentChooser {
|
delegate: ReplyMessageComponentChooser {
|
||||||
maxContentWidth: _private.availableContentWidth
|
onReplyClicked: root.Message.timeline.goToEvent(root.replyEventId)
|
||||||
|
|
||||||
onReplyClicked: root.replyClicked(root.replyEventId)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -84,11 +74,11 @@ RowLayout {
|
|||||||
}
|
}
|
||||||
TapHandler {
|
TapHandler {
|
||||||
acceptedButtons: Qt.LeftButton
|
acceptedButtons: Qt.LeftButton
|
||||||
onTapped: root.replyClicked(root.replyEventId)
|
onTapped: root.Message.timeline.goToEvent(root.replyEventId)
|
||||||
}
|
}
|
||||||
QtObject {
|
QtObject {
|
||||||
id: _private
|
id: _private
|
||||||
// The space available for the component after taking away the border
|
// The space available for the component after taking away the border
|
||||||
readonly property real availableContentWidth: root.maxContentWidth - verticalBorder.implicitWidth - root.spacing
|
readonly property real availableContentWidth: root.Message.maxContentWidth - verticalBorder.implicitWidth - root.spacing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,11 +15,6 @@ import org.kde.neochat
|
|||||||
DelegateChooser {
|
DelegateChooser {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The maximum width that the bubble's content can be.
|
|
||||||
*/
|
|
||||||
property real maxContentWidth: -1
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The reply has been clicked.
|
* @brief The reply has been clicked.
|
||||||
*/
|
*/
|
||||||
@@ -29,16 +24,12 @@ DelegateChooser {
|
|||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.Author
|
roleValue: MessageComponentType.Author
|
||||||
delegate: ReplyAuthorComponent {
|
delegate: ReplyAuthorComponent {}
|
||||||
maxContentWidth: root.maxContentWidth
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.Text
|
roleValue: MessageComponentType.Text
|
||||||
delegate: TextComponent {
|
delegate: TextComponent {
|
||||||
maxContentWidth: root.maxContentWidth
|
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
acceptedButtons: Qt.LeftButton
|
acceptedButtons: Qt.LeftButton
|
||||||
@@ -61,7 +52,7 @@ DelegateChooser {
|
|||||||
|
|
||||||
MediaSizeHelper {
|
MediaSizeHelper {
|
||||||
id: mediaSizeHelper
|
id: mediaSizeHelper
|
||||||
contentMaxWidth: root.maxContentWidth
|
contentMaxWidth: Message.maxContentWidth
|
||||||
contentMaxHeight: Kirigami.Units.gridUnit * 5
|
contentMaxHeight: Kirigami.Units.gridUnit * 5
|
||||||
mediaWidth: image.mediaInfo.width ?? 0
|
mediaWidth: image.mediaInfo.width ?? 0
|
||||||
mediaHeight: image.mediaInfo.height ?? 0
|
mediaHeight: image.mediaInfo.height ?? 0
|
||||||
@@ -85,7 +76,6 @@ DelegateChooser {
|
|||||||
roleValue: MessageComponentType.Code
|
roleValue: MessageComponentType.Code
|
||||||
delegate: CodeComponent {
|
delegate: CodeComponent {
|
||||||
Layout.maximumHeight: Kirigami.Units.gridUnit * 5
|
Layout.maximumHeight: Kirigami.Units.gridUnit * 5
|
||||||
maxContentWidth: root.maxContentWidth
|
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@@ -99,8 +89,6 @@ DelegateChooser {
|
|||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.Quote
|
roleValue: MessageComponentType.Quote
|
||||||
delegate: QuoteComponent {
|
delegate: QuoteComponent {
|
||||||
maxContentWidth: root.maxContentWidth
|
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
acceptedButtons: Qt.LeftButton
|
acceptedButtons: Qt.LeftButton
|
||||||
@@ -137,10 +125,7 @@ DelegateChooser {
|
|||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.Poll
|
roleValue: MessageComponentType.Poll
|
||||||
delegate: PollComponent {
|
delegate: PollComponent {}
|
||||||
room: root.room
|
|
||||||
maxContentWidth: root.maxContentWidth
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
@@ -161,16 +146,12 @@ DelegateChooser {
|
|||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.Encrypted
|
roleValue: MessageComponentType.Encrypted
|
||||||
delegate: EncryptedComponent {
|
delegate: EncryptedComponent {}
|
||||||
maxContentWidth: root.maxContentWidth
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MessageComponentType.Loading
|
roleValue: MessageComponentType.Loading
|
||||||
delegate: LoadComponent {
|
delegate: LoadComponent {}
|
||||||
maxContentWidth: root.maxContentWidth
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
|
|||||||
@@ -35,11 +35,6 @@ TextEdit {
|
|||||||
*/
|
*/
|
||||||
property bool spoilerRevealed: !hasSpoiler.test(display)
|
property bool spoilerRevealed: !hasSpoiler.test(display)
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The maximum width that the bubble's content can be.
|
|
||||||
*/
|
|
||||||
property real maxContentWidth: -1
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Request a context menu be show for the message.
|
* @brief Request a context menu be show for the message.
|
||||||
*/
|
*/
|
||||||
@@ -47,7 +42,7 @@ TextEdit {
|
|||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
Layout.maximumWidth: root.maxContentWidth
|
Layout.maximumWidth: Message.maxContentWidth
|
||||||
|
|
||||||
ListView.onReused: Qt.binding(() => !hasSpoiler.test(display))
|
ListView.onReused: Qt.binding(() => !hasSpoiler.test(display))
|
||||||
|
|
||||||
|
|||||||
@@ -16,36 +16,11 @@ import org.kde.neochat
|
|||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The NeoChatRoom the delegate is being displayed in.
|
|
||||||
*/
|
|
||||||
required property NeoChatRoom room
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The index of the delegate in the model.
|
|
||||||
*/
|
|
||||||
required property var index
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The Matrix ID of the root message in the thread, if any.
|
* @brief The Matrix ID of the root message in the thread, if any.
|
||||||
*/
|
*/
|
||||||
required property string threadRoot
|
required property string threadRoot
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The timeline ListView this component is being used in.
|
|
||||||
*/
|
|
||||||
required property ListView timeline
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The maximum width that the bubble's content can be.
|
|
||||||
*/
|
|
||||||
property real maxContentWidth: -1
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The reply has been clicked.
|
|
||||||
*/
|
|
||||||
signal replyClicked(string eventID)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The user selected text has changed.
|
* @brief The user selected text has changed.
|
||||||
*/
|
*/
|
||||||
@@ -63,22 +38,14 @@ ColumnLayout {
|
|||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
Layout.maximumWidth: root.maxContentWidth
|
Layout.maximumWidth: Message.maxContentWidth
|
||||||
spacing: Kirigami.Units.smallSpacing
|
spacing: Kirigami.Units.smallSpacing
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
id: threadRepeater
|
id: threadRepeater
|
||||||
model: root.room.modelForThread(root.threadRoot);
|
model: root.Message.room.modelForThread(root.threadRoot);
|
||||||
|
|
||||||
delegate: BaseMessageComponentChooser {
|
delegate: BaseMessageComponentChooser {
|
||||||
room: root.room
|
|
||||||
index: root.index
|
|
||||||
timeline: root.timeline
|
|
||||||
maxContentWidth: root.maxContentWidth
|
|
||||||
|
|
||||||
onReplyClicked: eventId => {
|
|
||||||
root.replyClicked(eventId);
|
|
||||||
}
|
|
||||||
onSelectedTextChanged: selectedText => {
|
onSelectedTextChanged: selectedText => {
|
||||||
root.selectedTextChanged(selectedText);
|
root.selectedTextChanged(selectedText);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,16 +19,6 @@ import org.kde.neochat
|
|||||||
Video {
|
Video {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The NeoChatRoom the delegate is being displayed in.
|
|
||||||
*/
|
|
||||||
required property NeoChatRoom room
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The index of the delegate in the model.
|
|
||||||
*/
|
|
||||||
required property var index
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The matrix ID of the message event.
|
* @brief The matrix ID of the message event.
|
||||||
*/
|
*/
|
||||||
@@ -77,16 +67,6 @@ Video {
|
|||||||
*/
|
*/
|
||||||
property bool playOnFinished: false
|
property bool playOnFinished: false
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The timeline ListView this component is being used in.
|
|
||||||
*/
|
|
||||||
required property ListView timeline
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The maximum width that the bubble's content can be.
|
|
||||||
*/
|
|
||||||
property real maxContentWidth: -1
|
|
||||||
|
|
||||||
Layout.preferredWidth: mediaSizeHelper.currentSize.width
|
Layout.preferredWidth: mediaSizeHelper.currentSize.width
|
||||||
Layout.preferredHeight: mediaSizeHelper.currentSize.height
|
Layout.preferredHeight: mediaSizeHelper.currentSize.height
|
||||||
|
|
||||||
@@ -382,13 +362,13 @@ Video {
|
|||||||
text: i18n("Maximize")
|
text: i18n("Maximize")
|
||||||
icon.name: "view-fullscreen"
|
icon.name: "view-fullscreen"
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
root.timeline.interactive = false;
|
root.Message.timeline.interactive = false;
|
||||||
root.pause();
|
root.pause();
|
||||||
// We need to make sure the index is that of the MediaMessageFilterModel.
|
// We need to make sure the index is that of the MediaMessageFilterModel.
|
||||||
if (root.timeline.model instanceof MessageFilterModel) {
|
if (root.Message.timeline.model instanceof MessageFilterModel) {
|
||||||
RoomManager.maximizeMedia(RoomManager.mediaMessageFilterModel.getRowForSourceItem(root.index));
|
RoomManager.maximizeMedia(RoomManager.mediaMessageFilterModel.getRowForSourceItem(root.Message.index));
|
||||||
} else {
|
} else {
|
||||||
RoomManager.maximizeMedia(root.index);
|
RoomManager.maximizeMedia(root.Message.index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -440,7 +420,7 @@ Video {
|
|||||||
|
|
||||||
MediaSizeHelper {
|
MediaSizeHelper {
|
||||||
id: mediaSizeHelper
|
id: mediaSizeHelper
|
||||||
contentMaxWidth: root.maxContentWidth
|
contentMaxWidth: root.Message.maxContentWidth
|
||||||
mediaWidth: root.mediaInfo.width
|
mediaWidth: root.mediaInfo.width
|
||||||
mediaHeight: root.mediaInfo.height
|
mediaHeight: root.mediaInfo.height
|
||||||
}
|
}
|
||||||
@@ -450,7 +430,7 @@ Video {
|
|||||||
playSavedFile();
|
playSavedFile();
|
||||||
} else {
|
} else {
|
||||||
playOnFinished = true;
|
playOnFinished = true;
|
||||||
root.room.downloadFile(root.eventId, Core.StandardPaths.writableLocation(Core.StandardPaths.CacheLocation) + "/" + root.eventId.replace(":", "_").replace("/", "_").replace("+", "_") + root.room.fileNameToDownload(root.eventId));
|
Message.room.downloadFile(root.eventId, Core.StandardPaths.writableLocation(Core.StandardPaths.CacheLocation) + "/" + root.eventId.replace(":", "_").replace("/", "_").replace("+", "_") + Message.room.fileNameToDownload(root.eventId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user