Add a dev setting to allow relations to be sent to any message

Add a dev setting to allow relations to be sent to any message using the right click delegate menu. This shouldn't be a main feature, but since it's technically allowed in matrix this will help any future debugging
This commit is contained in:
James Graham
2025-07-28 19:47:29 +01:00
parent 6082bc89b0
commit f288367653
10 changed files with 63 additions and 19 deletions

View File

@@ -189,6 +189,10 @@
<label>Don't hide any events in the timeline</label>
<default>false</default>
</entry>
<entry name="RelateAnyEvent" type="bool">
<label>Send relations to any event, including state events and events normally hidden.</label>
<default>false</default>
</entry>
<entry name="AlwaysVerifyDevice" type="bool">
<label>Always allow device verification</label>
<default>false</default>

View File

@@ -20,6 +20,13 @@ FormCard.FormCard {
onToggled: NeoChatConfig.showAllEvents = checked
}
FormCard.FormCheckDelegate {
text: i18nc("@option:check", "Allow sending relations to any event in the timeline")
description: i18nc("@info", "This includes state events")
checked: NeoChatConfig.relateAnyEvent
onToggled: NeoChatConfig.relateAnyEvent = checked
}
FormCard.FormCheckDelegate {
id: roomAccountDataVisibleCheck
text: i18nc("@option:check Enable the matrix 'threads' feature", "Always allow device verification")

View File

@@ -71,4 +71,26 @@ RowLayout {
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.IBeamCursor
}
}
TapHandler {
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad | PointerDevice.Stylus
acceptedButtons: Qt.RightButton
onTapped: _private.showMessageMenu()
}
TapHandler {
acceptedDevices: PointerDevice.TouchScreen
acceptedButtons: Qt.LeftButton
onLongPressed: _private.showMessageMenu()
}
QtObject {
id: _private
function showMessageMenu() {
if (!NeoChatConfig.developerTools) {
return;
}
RoomManager.viewEventMenu(root.modelData.eventId, root.Message.room, root.author, "", "");
}
}
}

View File

@@ -50,18 +50,18 @@ QQC2.ScrollView {
DelegateChoice {
roleValue: Timeline.MediaMessageFilterModel.Image
delegate: Timeline.MessageDelegate {
Timeline.Message.room: root.room
alwaysFillWidth: true
cardBackground: false
room: root.room
}
}
DelegateChoice {
roleValue: Timeline.MediaMessageFilterModel.Video
delegate: Timeline.MessageDelegate {
Timeline.Message.room: root.room
alwaysFillWidth: true
cardBackground: false
room: root.room
}
}
}

View File

@@ -53,6 +53,11 @@ KirigamiComponents.ConvergentContextMenu {
*/
required property var author
/**
* @brief The delegate type of the message.
*/
required property int messageComponentType
/**
* @brief The display text of the message as plain text.
*/
@@ -79,7 +84,7 @@ KirigamiComponents.ConvergentContextMenu {
}
component RemoveMessageAction: Kirigami.Action {
visible: author.isLocalMember || currentRoom.canSendState("redact")
visible: (author.isLocalMember || currentRoom.canSendState("redact")) && root.messageComponentType !== MessageComponentType.Other
text: i18nc("@action:button", "Remove…")
icon.name: "edit-delete-remove"
icon.color: "red"
@@ -99,7 +104,8 @@ KirigamiComponents.ConvergentContextMenu {
}
}
component ReplyMessageAction: QQC2.Action {
component ReplyMessageAction: Kirigami.Action {
visible: root.messageComponentType !== MessageComponentType.Other || NeoChatConfig.relateAnyEvent
text: i18n("Reply")
icon.name: "mail-replied-symbolic"
onTriggered: {
@@ -109,7 +115,8 @@ KirigamiComponents.ConvergentContextMenu {
}
}
component ReplyThreadMessageAction: QQC2.Action {
component ReplyThreadMessageAction: Kirigami.Action {
visible: root.messageComponentType !== MessageComponentType.Other || NeoChatConfig.relateAnyEvent
text: i18nc("@action:button", "Reply in Thread")
icon.name: "dialog-messages"
onTriggered: {
@@ -145,7 +152,7 @@ KirigamiComponents.ConvergentContextMenu {
component PinMessageAction: Kirigami.Action {
readonly property bool pinned: currentRoom.isEventPinned(root.eventId)
visible: currentRoom.canSendState("m.room.pinned_events")
visible: currentRoom.canSendState("m.room.pinned_events") && root.messageComponentType !== MessageComponentType.Other
text: pinned ? i18nc("@action:button 'Unpin' as in 'Unpin this message'", "Unpin") : i18nc("@action:button 'Pin' as in 'Pin the message in the room'", "Pin")
icon.name: pinned ? "window-unpin-symbolic" : "pin-symbolic"
onTriggered: pinned ? currentRoom.unpinEvent(root.eventId) : currentRoom.pinEvent(root.eventId)
@@ -185,9 +192,11 @@ KirigamiComponents.ConvergentContextMenu {
}
Kirigami.Action {
visible: Kirigami.Settings.isMobile
id: emojiAction
visible: root.messageComponentType === MessageComponentType.Other ? NeoChatConfig.relateAnyEvent : true
displayComponent: RowLayout {
visible: emojiAction.visible
spacing: 0
Layout.fillWidth: true
Layout.preferredHeight: Kirigami.Units.gridUnit * 2.5

View File

@@ -21,7 +21,9 @@ DelegateChooser {
DelegateChoice {
roleValue: DelegateType.State
delegate: StateDelegate {}
delegate: StateDelegate {
room: root.room
}
}
DelegateChoice {

View File

@@ -33,11 +33,6 @@ DelegateContextMenu {
*/
required property var progressInfo
/**
* @brief The delegate type of the message.
*/
required property int messageComponentType
DelegateContextMenu.ReplyMessageAction {}
Kirigami.Action {

View File

@@ -27,11 +27,6 @@ import org.kde.neochat
DelegateContextMenu {
id: root
/**
* @brief The delegate type of the message.
*/
required property int messageComponentType
/**
* @brief The display text of the message as rich text.
*/
@@ -52,7 +47,8 @@ DelegateContextMenu {
DelegateContextMenu.ReplyThreadMessageAction {}
QQC2.Action {
Kirigami.Action {
visible: root.messageComponentType !== MessageComponentType.Other
text: i18nc("@action:inmenu As in 'Forward this message'", "Forward…")
icon.name: "mail-forward-symbolic"
onTriggered: {
@@ -69,6 +65,7 @@ DelegateContextMenu {
}
}
Kirigami.Action {
visible: root.messageComponentType !== MessageComponentType.Other || NeoChatConfig.relateAnyEvent
separator: true
}
DelegateContextMenu.RemoveMessageAction {}

View File

@@ -18,6 +18,11 @@ import org.kde.neochat
TimelineDelegate {
id: root
/**
* @brief The NeoChatRoom the delegate is being displayed in.
*/
required property NeoChatRoom room
/**
* @brief List of the first 5 unique authors of the aggregated state event.
*/
@@ -63,6 +68,8 @@ TimelineDelegate {
*/
property bool folded: true
Message.room: root.room
width: parent?.width
rightPadding: NeoChatConfig.compactLayout && root.ListView.view.width >= Kirigami.Units.gridUnit * 20 ? Kirigami.Units.gridUnit * 2 + Kirigami.Units.largeSpacing : Kirigami.Units.largeSpacing

View File

@@ -198,6 +198,7 @@ QVariantList MessageFilterModel::stateEventsList(int sourceRow) const
QVariantList stateEvents;
for (int i = sourceRow; i >= 0; i--) {
auto nextState = QVariantMap{
{u"eventId"_s, sourceModel()->data(sourceModel()->index(i, 0), TimelineMessageModel::EventIdRole)},
{u"author"_s, sourceModel()->data(sourceModel()->index(i, 0), TimelineMessageModel::AuthorRole)},
{u"authorDisplayName"_s, sourceModel()->data(sourceModel()->index(i, 0), TimelineMessageModel::AuthorDisplayNameRole).toString()},
{u"text"_s, sourceModel()->data(sourceModel()->index(i, 0), Qt::DisplayRole).toString()},