diff --git a/TODO.md b/TODO.md index 6b2797f6..290702bb 100644 --- a/TODO.md +++ b/TODO.md @@ -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 diff --git a/src/icons/thin/copy-link.svg b/src/icons/thin/copy-link.svg new file mode 100644 index 00000000..75c9bc47 --- /dev/null +++ b/src/icons/thin/copy-link.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/icons/thin/copy.svg b/src/icons/thin/copy-text.svg similarity index 100% rename from src/icons/thin/copy.svg rename to src/icons/thin/copy-text.svg diff --git a/src/qml/Base/HSelectableLabelContainer.qml b/src/qml/Base/HSelectableLabelContainer.qml index c67cb266..37deec87 100644 --- a/src/qml/Base/HSelectableLabelContainer.qml +++ b/src/qml/Base/HSelectableLabelContainer.qml @@ -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) - } } } diff --git a/src/qml/Chat/Timeline/EventContent.qml b/src/qml/Chat/Timeline/EventContent.qml index a387e9d5..d09e5d31 100644 --- a/src/qml/Chat/Timeline/EventContent.qml +++ b/src/qml/Chat/Timeline/EventContent.qml @@ -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 diff --git a/src/qml/Chat/Timeline/EventDelegate.qml b/src/qml/Chat/Timeline/EventDelegate.qml index b60b3b91..788ed518 100644 --- a/src/qml/Chat/Timeline/EventDelegate.qml +++ b/src/qml/Chat/Timeline/EventDelegate.qml @@ -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) + } + } }