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

@ -26,6 +26,7 @@
- Message position after daybreak delegate (fixed by commit 57b1313 ?)
- [hr not working](https://bugreports.qt.io/browse/QTBUG-74342)
- Terrible performance using `QT_QPA_PLATFORM=wayland-egl`, must use `xcb`
- Verify big avatars aren't downloaded uselessly
- UI
- Set an explicit placeholder text color for text field/area
@ -35,7 +36,6 @@
- Room header descriptions: styled text
- Message selection
- Copy link
- Make scroll wheel usable
- Copy to X11 selection
- Images don't load correctly in TextEdit

View File

@ -0,0 +1,3 @@
<svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
<path d="m6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74s3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093zm6.836-6.836-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0s1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z"/>
</svg>

After

Width:  |  Height:  |  Size: 836 B

View File

Before

Width:  |  Height:  |  Size: 429 B

After

Width:  |  Height:  |  Size: 429 B

View File

@ -38,7 +38,6 @@ FocusScope {
readonly property alias dragPoint: dragHandler.centroid
readonly property alias dragPosition: dragHandler.centroid.position
readonly property alias contextMenu: contextMenu
function clearSelection() {
@ -74,23 +73,5 @@ FocusScope {
TapHandler {
acceptedButtons: Qt.LeftButton
onTapped: clearSelection()
onLongPressed: contextMenu.popup()
}
TapHandler {
acceptedButtons: Qt.RightButton
onTapped: contextMenu.popup()
onLongPressed: contextMenu.popup()
}
HMenu {
id: contextMenu
HMenuItem {
icon.name: "copy"
text: qsTr("Copy")
enabled: Boolean(joinedSelection)
onTriggered: Utils.copyToClipboard(joinedSelection)
}
}
}

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)
}
}
}