Add "Copy Link Address" context menu

Allows copying just the link address of a hyperlink.
This commit is contained in:
Kai Uwe Broulik
2024-12-05 13:41:04 +01:00
parent 3356e6c6cf
commit c585f3d8ae
8 changed files with 43 additions and 6 deletions

View File

@@ -57,6 +57,11 @@ Loader {
*/
property string selectedText: ""
/**
* @brief The link the user has currently hovered.
*/
property string hoveredLink: ""
/**
* @brief The list of menu item actions that have sub-actions.
*

View File

@@ -63,6 +63,12 @@ DelegateContextMenu {
separator: true
},
DelegateContextMenu.RemoveMessageAction {},
Kirigami.Action {
text: i18nc("@action:inmenu", "Copy Link Address")
icon.name: "edit-copy"
visible: root.hoveredLink.length > 0
onTriggered: Clipboard.saveText(root.hoveredLink)
},
Kirigami.Action {
text: i18nc("@action:inmenu", "Copy Text")
icon.name: "edit-copy"

View File

@@ -245,9 +245,10 @@ Kirigami.Page {
});
}
function onShowMessageMenu(eventId, author, messageComponentType, plainText, htmlText, selectedText, isThread) {
function onShowMessageMenu(eventId, author, messageComponentType, plainText, htmlText, selectedText, hoveredLink, isThread) {
const contextMenu = messageDelegateContextMenu.createObject(root, {
selectedText: selectedText,
hoveredLink: hoveredLink,
author: author,
eventId: eventId,
messageComponentType: messageComponentType,