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
This commit is contained in:
miruka 2019-09-01 04:13:39 -04:00
parent 32fde57ba7
commit 6a346264be
3 changed files with 40 additions and 7 deletions

View File

@ -2,6 +2,7 @@
- Copy text with triple click, copy text + name + date with quadruple click - Copy text with triple click, copy text + name + date with quadruple click
- Copy to X11 selection - Copy to X11 selection
- Make scroll wheel usable - Make scroll wheel usable
- Copy links
- Refactoring - Refactoring
- Banners - Banners
@ -27,7 +28,6 @@
- Don't strip user spacing in html - Don't strip user spacing in html
- Do something when access token is invalid - Do something when access token is invalid
- Don't store states in delegates
- Message position after daybreak delegate (fixed by commit 57b1313 ?) - Message position after daybreak delegate (fixed by commit 57b1313 ?)
- [hr not working](https://bugreports.qt.io/browse/QTBUG-74342) - [hr not working](https://bugreports.qt.io/browse/QTBUG-74342)
- Terrible performance using `QT_QPA_PLATFORM=wayland-egl`, must use `xcb` - 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 - Way to open context menus without a right mouse button
- Room header descriptions: styled text - Room header descriptions: styled text
- Single message context menu - Message selection
- Copy text - Make scroll wheel usable
- Copy link - Copy to X11 selection
- Single message selection
- Just use Shortcut onHeld instead of analyzing the current velocity - Just use Shortcut onHeld instead of analyzing the current velocity
in `smartVerticalFlick()` in `smartVerticalFlick()`

View File

@ -92,6 +92,11 @@ TextEdit {
updateContainerSelectedTexts() updateContainerSelectedTexts()
} }
function selectAllTextPlus() {
// Unimplemented by default
container.clearSelection()
}
Connections { Connections {
target: container target: container
@ -119,6 +124,7 @@ TextEdit {
onTapped: { onTapped: {
tapCount == 2 ? selectWordAt(eventPoint.position) : tapCount == 2 ? selectWordAt(eventPoint.position) :
tapCount == 3 ? selectAllText() : tapCount == 3 ? selectAllText() :
tapCount == 4 ? selectAllTextPlus() :
container.clearSelection() container.clearSelection()
} }
} }

View File

@ -8,6 +8,8 @@ Row {
spacing: theme.spacing / 2 spacing: theme.spacing / 2
readonly property string eventText: Utils.processedEventText(model) readonly property string eventText: Utils.processedEventText(model)
readonly property string eventTime: Utils.formatTime(model.date)
readonly property int eventTimeSpaces: 2
Item { Item {
width: hideAvatar ? 0 : 48 width: hideAvatar ? 0 : 48
@ -64,6 +66,10 @@ Row {
leftPadding: theme.spacing leftPadding: theme.spacing
rightPadding: leftPadding rightPadding: leftPadding
topPadding: theme.spacing / 2 topPadding: theme.spacing / 2
function selectAllTextPlus() {
contentLabel.selectAllTextPlus()
}
} }
HSelectableLabel { HSelectableLabel {
@ -75,9 +81,10 @@ Row {
text: theme.chat.message.styleInclude + text: theme.chat.message.styleInclude +
eventContent.eventText + eventContent.eventText +
// time // time
"&nbsp;&nbsp;<font size=" + theme.fontSize.small + "&nbsp;".repeat(eventTimeSpaces) +
"<font size=" + theme.fontSize.small +
"px color=" + theme.chat.message.date + ">" + "px color=" + theme.chat.message.date + ">" +
Utils.formatTime(model.date) + eventTime +
"</font>" + "</font>" +
// local echo icon // local echo icon
(model.is_local_echo ? (model.is_local_echo ?
@ -92,6 +99,27 @@ Row {
rightPadding: leftPadding rightPadding: leftPadding
topPadding: nameLabel.visible ? 0 : bottomPadding topPadding: nameLabel.visible ? 0 : bottomPadding
bottomPadding: theme.spacing / 2 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()
}
} }
} }
} }