Fix ctrl-c behavior

This commit is contained in:
miruka 2019-09-01 06:56:03 -04:00
parent 922eac4ea9
commit 9936a7e2ee
5 changed files with 31 additions and 23 deletions

View File

@ -18,15 +18,6 @@ TextEdit {
onLinkActivated: Qt.openUrlExternally(link)
Keys.onPressed: ev => {
if (ev.matches(StandardKey.Copy)) {
ev.accepted = true
Utils.copyToClipboard(container.joinedSelection)
return
}
ev.accepted = false
}
// If index is a whole number, the label will get two \n before itself
// in container.joinedSelection. If it's a decimal number, if gets one \n.

View File

@ -2,7 +2,7 @@ import QtQuick 2.12
import "../utils.js" as Utils
FocusScope {
onFocusChanged: if (! focus) clearSelection()
onSelectedTextsChanged: if (selectedTexts) composer.textArea.deselect()
signal deselectAll()

View File

@ -13,6 +13,8 @@ HSplitView {
Layout.fillWidth: true
EventList {
id: eventList
// Avoid a certain binding loop
Layout.minimumWidth: theme.minimumSupportedWidth
Layout.fillWidth: true

View File

@ -140,13 +140,17 @@ Rectangle {
}
}
Component.onCompleted: {
area.Keys.onReturnPressed.connect(event => {
event.accepted = true
area.onSelectedTextChanged: if (area.selectedText) {
eventList.selectableLabelContainer.clearSelection()
}
if (event.modifiers & Qt.ShiftModifier ||
event.modifiers & Qt.ControlModifier ||
event.modifiers & Qt.AltModifier)
Component.onCompleted: {
area.Keys.onReturnPressed.connect(ev => {
ev.accepted = true
if (ev.modifiers & Qt.ShiftModifier ||
ev.modifiers & Qt.ControlModifier ||
ev.modifiers & Qt.AltModifier)
{
let indents = 0
let parts = lineText.split(indent)
@ -171,17 +175,27 @@ Rectangle {
area.Keys.onEnterPressed.connect(area.Keys.onReturnPressed)
area.Keys.onTabPressed.connect(event => {
event.accepted = true
area.Keys.onTabPressed.connect(ev => {
ev.accepted = true
textArea.insert(cursorPosition, indent)
})
area.Keys.onPressed.connect(event => {
if (event.modifiers == Qt.NoModifier &&
event.key == Qt.Key_Backspace &&
area.Keys.onPressed.connect(ev => {
if (ev.matches(StandardKey.Copy) &&
eventList.selectableLabelContainer.joinedSelection
) {
ev.accepted = true
Utils.copyToClipboard(
eventList.selectableLabelContainer.joinedSelection,
)
return
}
if (ev.modifiers == Qt.NoModifier &&
ev.key == Qt.Key_Backspace &&
! textArea.selectedText)
{
event.accepted = true
ev.accepted = true
textArea.remove(
cursorPosition - deleteCharsOnBackspace,
cursorPosition

View File

@ -3,7 +3,8 @@ import "../../Base"
import "../../utils.js" as Utils
Rectangle {
property alias listView: eventList
property alias selectableLabelContainer: selectableLabelContainer
property alias eventList: eventList
color: theme.chat.eventList.background