From 6a346264beadc3cb943b9e46e09a64de01d4ee63 Mon Sep 17 00:00:00 2001 From: miruka Date: Sun, 1 Sep 2019 04:13:39 -0400 Subject: [PATCH] Improve multiple clicks message selection - Triple click selects the message body without date or name - Quadruple click (yes) selects the entire message with name and date - Quadruple click on the name label does the same --- TODO.md | 9 ++++---- src/qml/Base/HSelectableLabel.qml | 6 +++++ src/qml/Chat/Timeline/EventContent.qml | 32 ++++++++++++++++++++++++-- 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/TODO.md b/TODO.md index 5b0a4d6f..9dfbfad1 100644 --- a/TODO.md +++ b/TODO.md @@ -2,6 +2,7 @@ - Copy text with triple click, copy text + name + date with quadruple click - Copy to X11 selection - Make scroll wheel usable + - Copy links - Refactoring - Banners @@ -27,7 +28,6 @@ - Don't strip user spacing in html - Do something when access token is invalid - - Don't store states in delegates - 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` @@ -39,10 +39,9 @@ - Way to open context menus without a right mouse button - Room header descriptions: styled text - - Single message context menu - - Copy text - - Copy link - - Single message selection + - Message selection + - Make scroll wheel usable + - Copy to X11 selection - Just use Shortcut onHeld instead of analyzing the current velocity in `smartVerticalFlick()` diff --git a/src/qml/Base/HSelectableLabel.qml b/src/qml/Base/HSelectableLabel.qml index cd4fcb0f..a380397a 100644 --- a/src/qml/Base/HSelectableLabel.qml +++ b/src/qml/Base/HSelectableLabel.qml @@ -92,6 +92,11 @@ TextEdit { updateContainerSelectedTexts() } + function selectAllTextPlus() { + // Unimplemented by default + container.clearSelection() + } + Connections { target: container @@ -119,6 +124,7 @@ TextEdit { onTapped: { tapCount == 2 ? selectWordAt(eventPoint.position) : tapCount == 3 ? selectAllText() : + tapCount == 4 ? selectAllTextPlus() : container.clearSelection() } } diff --git a/src/qml/Chat/Timeline/EventContent.qml b/src/qml/Chat/Timeline/EventContent.qml index 4c488693..e12d5670 100644 --- a/src/qml/Chat/Timeline/EventContent.qml +++ b/src/qml/Chat/Timeline/EventContent.qml @@ -8,6 +8,8 @@ Row { spacing: theme.spacing / 2 readonly property string eventText: Utils.processedEventText(model) + readonly property string eventTime: Utils.formatTime(model.date) + readonly property int eventTimeSpaces: 2 Item { width: hideAvatar ? 0 : 48 @@ -64,6 +66,10 @@ Row { leftPadding: theme.spacing rightPadding: leftPadding topPadding: theme.spacing / 2 + + function selectAllTextPlus() { + contentLabel.selectAllTextPlus() + } } HSelectableLabel { @@ -75,9 +81,10 @@ Row { text: theme.chat.message.styleInclude + eventContent.eventText + // time - "  " + - Utils.formatTime(model.date) + + eventTime + "" + // local echo icon (model.is_local_echo ? @@ -92,6 +99,27 @@ Row { rightPadding: leftPadding topPadding: nameLabel.visible ? 0 : bottomPadding bottomPadding: theme.spacing / 2 + + + function selectAllText() { + // Select the message body without the date or name + container.clearSelection() + contentLabel.select( + 0, + contentLabel.length - + eventTime.length - eventTimeSpaces, + ) + contentLabel.updateContainerSelectedTexts() + } + + function selectAllTextPlus() { + // select the sender name, body and date + container.clearSelection() + nameLabel.selectAll() + contentLabel.selectAll() + contentLabel.updateContainerSelectedTexts() + } + } } }