Make composer/eventList ctrl-c work again

This commit is contained in:
miruka 2020-03-26 21:23:43 -04:00
parent a61f1d5d04
commit 18f53829d9
6 changed files with 37 additions and 31 deletions

View File

@ -1,5 +1,6 @@
# TODO # TODO
- show "copy selection" when right clicking on image
- make it not select messages when closing context menu - make it not select messages when closing context menu
- long-press-drag to select multiple messages on touch - long-press-drag to select multiple messages on touch
- drag to select on non-touch - drag to select on non-touch

View File

@ -81,7 +81,7 @@ HColumnPage {
Composer { Composer {
id: composer id: composer
eventList: loadEventList ? eventListLoader.item : null eventList: loadEventList ? eventListLoader.item.eventList : null
visible: visible:
! chat.roomInfo.left && ! chat.roomInfo.inviter_id ! chat.roomInfo.left && ! chat.roomInfo.inviter_id
} }

View File

@ -18,7 +18,7 @@ Rectangle {
Layout.maximumHeight: pageLoader.height / 2 Layout.maximumHeight: pageLoader.height / 2
property Item eventList property HListView eventList
property string indent: " " property string indent: " "
@ -165,11 +165,6 @@ Rectangle {
} }
} }
// XXX
// area.onSelectedTextChanged: if (area.selectedText && eventList) {
// eventList.selectableLabelContainer.clearSelection()
// }
Component.onCompleted: { Component.onCompleted: {
area.Keys.onReturnPressed.connect(ev => { area.Keys.onReturnPressed.connect(ev => {
ev.accepted = true ev.accepted = true
@ -207,16 +202,15 @@ Rectangle {
}) })
area.Keys.onPressed.connect(ev => { area.Keys.onPressed.connect(ev => {
// XXX if (ev.matches(StandardKey.Copy) &&
// if (ev.matches(StandardKey.Copy) && ! area.selectedText &&
// eventList && eventList &&
// eventList.selectableLabelContainer.joinedSelection eventList.selectedCount) {
// ) {
// ev.accepted = true ev.accepted = true
// Clipboard.text = eventList.copySelectedDelegates()
// eventList.selectableLabelContainer.joinedSelection return
// return }
// }
// FIXME: buggy // FIXME: buggy
// if (ev.modifiers === Qt.NoModifier && // if (ev.modifiers === Qt.NoModifier &&

View File

@ -162,8 +162,13 @@ HRowLayout {
Layout.maximumWidth: eventContent.maxMessageWidth Layout.maximumWidth: eventContent.maxMessageWidth
Layout.fillWidth: true Layout.fillWidth: true
onSelectedTextChanged: onSelectedTextChanged: if (selectedText) {
if (selectedText) eventList.delegateWithSelectedText = model.id eventList.delegateWithSelectedText = model.id
eventList.selectedText = selectedText
} else if (eventList.delegateWithSelectedText === model.id) {
eventList.delegateWithSelectedText = ""
eventList.selectedText = ""
}
Connections { Connections {
target: eventList target: eventList

View File

@ -196,18 +196,7 @@ HColumnLayout {
return return
} }
if (eventContent.selectedText) { eventList.copySelectedDelegates()
Clipboard.text = eventContent.selectedText
return
}
const contents = []
for (const model of eventList.getSortedCheckedDelegates()) {
contents.push(JSON.parse(model.source).body)
}
Clipboard.text = contents.join("\n\n")
} }
} }

View File

@ -3,6 +3,7 @@
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import QtQuick.Window 2.12 import QtQuick.Window 2.12
import Clipboard 0.1
import "../../.." import "../../.."
import "../../../Base" import "../../../Base"
@ -77,8 +78,24 @@ Rectangle {
width < theme.chat.eventList.ownEventsOnRightUnderWidth width < theme.chat.eventList.ownEventsOnRightUnderWidth
property string delegateWithSelectedText: "" property string delegateWithSelectedText: ""
property string selectedText: ""
function copySelectedDelegates() {
if (eventList.selectedText) {
Clipboard.text = eventList.selectedText
return
}
const contents = []
for (const model of eventList.getSortedCheckedDelegates()) {
contents.push(JSON.parse(model.source).body)
}
Clipboard.text = contents.join("\n\n")
}
function canCombine(item, itemAfter) { function canCombine(item, itemAfter) {
if (! item || ! itemAfter) return false if (! item || ! itemAfter) return false