Add edit shortcuts and fix some focus stuff

This commit is contained in:
Nicolas Werner 2021-02-02 18:54:45 +01:00
parent 9b7d33e847
commit 6e2ae1d812
5 changed files with 30 additions and 7 deletions

View File

@ -139,6 +139,7 @@ Rectangle {
if (TimelineManager.timeline)
TimelineManager.timeline.input.updateState(selectionStart, selectionEnd, cursorPosition, text);
forceActiveFocus();
}
onCursorRectangleChanged: textInput.ensureVisible(cursorRectangle)
onCursorPositionChanged: {
@ -260,7 +261,9 @@ Rectangle {
Connections {
ignoreUnknownSignals: true
onInsertText: messageInput.insert(messageInput.cursorPosition, text)
onInsertText: {
messageInput.insert(messageInput.cursorPosition, text);
}
onTextChanged: {
messageInput.text = newText;
messageInput.cursorPosition = newText.length;
@ -271,6 +274,7 @@ Rectangle {
Connections {
ignoreUnknownSignals: true
onReplyChanged: messageInput.forceActiveFocus()
onEditChanged: messageInput.forceActiveFocus()
target: TimelineManager.timeline
}

View File

@ -50,7 +50,12 @@ ListView {
Shortcut {
sequence: StandardKey.Cancel
onActivated: chat.model.reply = undefined
onActivated: {
if (chat.model.edit)
chat.model.edit = undefined;
else
chat.model.reply = undefined;
}
}
Shortcut {
@ -66,6 +71,11 @@ ListView {
}
}
Shortcut {
sequence: "Ctrl+E"
onActivated: chat.model.edit = chat.model.reply
}
Component {
id: sectionHeader

View File

@ -18,8 +18,8 @@ Rectangle {
Reply {
id: replyPreview
visible: room && room.reply
visible: room && room.reply
anchors.left: parent.left
anchors.leftMargin: 2 * 22 + 3 * 16
anchors.right: closeReplyButton.left
@ -32,8 +32,8 @@ Rectangle {
ImageButton {
id: closeReplyButton
visible: room && room.reply
visible: room && room.reply
anchors.right: parent.right
anchors.rightMargin: 16
anchors.top: replyPreview.top
@ -48,8 +48,8 @@ Rectangle {
Button {
id: closeEditButton
visible: room && room.edit
visible: room && room.edit
anchors.left: parent.left
anchors.rightMargin: 16
anchors.topMargin: 10

View File

@ -97,7 +97,11 @@ Item {
image: ":/icons/icons/ui/edit.png"
ToolTip.visible: hovered
ToolTip.text: model.isEditable ? qsTr("Edit") : qsTr("Edited")
onClicked: if (model.isEditable) chat.model.editAction(model.id)
onClicked: {
if (model.isEditable)
chat.model.editAction(model.id);
}
}
EmojiButton {

View File

@ -91,6 +91,11 @@ Page {
onClicked: TimelineManager.timeline.replyAction(messageContextMenu.eventId)
}
MenuItem {
text: qsTr("Edit")
onClicked: TimelineManager.timeline.editAction(messageContextMenu.eventId)
}
MenuItem {
text: qsTr("Read receipts")
onTriggered: TimelineManager.timeline.readReceiptsAction(messageContextMenu.eventId)