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 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()`

View File

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

View File

@ -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
"&nbsp;&nbsp;<font size=" + theme.fontSize.small +
"&nbsp;".repeat(eventTimeSpaces) +
"<font size=" + theme.fontSize.small +
"px color=" + theme.chat.message.date + ">" +
Utils.formatTime(model.date) +
eventTime +
"</font>" +
// 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()
}
}
}
}