Add context menu to copy message link URLs

This commit is contained in:
miruka
2019-09-01 19:03:32 -04:00
parent bf2004ed84
commit 01f8bc3d6c
6 changed files with 51 additions and 20 deletions

View File

@@ -7,6 +7,9 @@ Row {
id: eventContent
spacing: theme.spacing / 2
readonly property string hoveredLink:
nameLabel.hoveredLink || contentLabel.hoveredLink
readonly property string eventText: Utils.processedEventText(model)
readonly property string eventTime: Utils.formatTime(model.date)
readonly property int eventTimeSpaces: 2

View File

@@ -60,7 +60,51 @@ Column {
}
EventContent {
id: eventContent
x: onRight ? parent.width - width : 0
Behavior on x { HNumberAnimation {} }
}
TapHandler {
acceptedButtons: Qt.RightButton
onTapped: {
contextMenu.link = eventContent.hoveredLink
contextMenu.popup()
}
}
TapHandler {
acceptedButtons: Qt.LeftButton | Qt.RightButton
onLongPressed: {
contextMenu.link = eventContent.hoveredLink
contextMenu.popup()
}
}
HMenu {
id: contextMenu
property string link: ""
onClosed: link = ""
HMenuItem {
id: copyLink
icon.name: "copy-link"
text: qsTr("Copy link address")
visible: Boolean(contextMenu.link)
onTriggered: Utils.copyToClipboard(contextMenu.link)
}
HMenuItem {
icon.name: "copy-text"
text: qsTr("Copy text")
visible: enabled || ! copyLink.visible
enabled: Boolean(selectableLabelContainer.joinedSelection)
onTriggered:
Utils.copyToClipboard(selectableLabelContainer.joinedSelection)
}
}
}