Skip to content
Snippets Groups Projects
Commit 6e2ae1d8 authored by Nicolas Werner's avatar Nicolas Werner
Browse files

Add edit shortcuts and fix some focus stuff

parent 9b7d33e8
No related branches found
No related tags found
No related merge requests found
Pipeline #602 passed
...@@ -139,6 +139,7 @@ Rectangle { ...@@ -139,6 +139,7 @@ Rectangle {
if (TimelineManager.timeline) if (TimelineManager.timeline)
TimelineManager.timeline.input.updateState(selectionStart, selectionEnd, cursorPosition, text); TimelineManager.timeline.input.updateState(selectionStart, selectionEnd, cursorPosition, text);
forceActiveFocus();
} }
onCursorRectangleChanged: textInput.ensureVisible(cursorRectangle) onCursorRectangleChanged: textInput.ensureVisible(cursorRectangle)
onCursorPositionChanged: { onCursorPositionChanged: {
...@@ -260,7 +261,9 @@ Rectangle { ...@@ -260,7 +261,9 @@ Rectangle {
Connections { Connections {
ignoreUnknownSignals: true ignoreUnknownSignals: true
onInsertText: messageInput.insert(messageInput.cursorPosition, text) onInsertText: {
messageInput.insert(messageInput.cursorPosition, text);
}
onTextChanged: { onTextChanged: {
messageInput.text = newText; messageInput.text = newText;
messageInput.cursorPosition = newText.length; messageInput.cursorPosition = newText.length;
...@@ -271,6 +274,7 @@ Rectangle { ...@@ -271,6 +274,7 @@ Rectangle {
Connections { Connections {
ignoreUnknownSignals: true ignoreUnknownSignals: true
onReplyChanged: messageInput.forceActiveFocus() onReplyChanged: messageInput.forceActiveFocus()
onEditChanged: messageInput.forceActiveFocus()
target: TimelineManager.timeline target: TimelineManager.timeline
} }
......
...@@ -50,7 +50,12 @@ ListView { ...@@ -50,7 +50,12 @@ ListView {
Shortcut { Shortcut {
sequence: StandardKey.Cancel sequence: StandardKey.Cancel
onActivated: chat.model.reply = undefined onActivated: {
if (chat.model.edit)
chat.model.edit = undefined;
else
chat.model.reply = undefined;
}
} }
Shortcut { Shortcut {
...@@ -66,6 +71,11 @@ ListView { ...@@ -66,6 +71,11 @@ ListView {
} }
} }
Shortcut {
sequence: "Ctrl+E"
onActivated: chat.model.edit = chat.model.reply
}
Component { Component {
id: sectionHeader id: sectionHeader
......
...@@ -18,8 +18,8 @@ Rectangle { ...@@ -18,8 +18,8 @@ Rectangle {
Reply { Reply {
id: replyPreview id: replyPreview
visible: room && room.reply
visible: room && room.reply
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 2 * 22 + 3 * 16 anchors.leftMargin: 2 * 22 + 3 * 16
anchors.right: closeReplyButton.left anchors.right: closeReplyButton.left
...@@ -32,8 +32,8 @@ Rectangle { ...@@ -32,8 +32,8 @@ Rectangle {
ImageButton { ImageButton {
id: closeReplyButton id: closeReplyButton
visible: room && room.reply
visible: room && room.reply
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: 16 anchors.rightMargin: 16
anchors.top: replyPreview.top anchors.top: replyPreview.top
...@@ -48,8 +48,8 @@ Rectangle { ...@@ -48,8 +48,8 @@ Rectangle {
Button { Button {
id: closeEditButton id: closeEditButton
visible: room && room.edit
visible: room && room.edit
anchors.left: parent.left anchors.left: parent.left
anchors.rightMargin: 16 anchors.rightMargin: 16
anchors.topMargin: 10 anchors.topMargin: 10
......
...@@ -88,7 +88,7 @@ Item { ...@@ -88,7 +88,7 @@ Item {
ImageButton { ImageButton {
id: editButton id: editButton
visible: (Settings.buttonsInTimeline && model.isEditable) || model.isEdited visible: (Settings.buttonsInTimeline && model.isEditable) || model.isEdited
buttonTextColor: chat.model.edit == model.id ? colors.highlight : colors.buttonText buttonTextColor: chat.model.edit == model.id ? colors.highlight : colors.buttonText
Layout.alignment: Qt.AlignRight | Qt.AlignTop Layout.alignment: Qt.AlignRight | Qt.AlignTop
Layout.preferredHeight: 16 Layout.preferredHeight: 16
...@@ -97,7 +97,11 @@ Item { ...@@ -97,7 +97,11 @@ Item {
image: ":/icons/icons/ui/edit.png" image: ":/icons/icons/ui/edit.png"
ToolTip.visible: hovered ToolTip.visible: hovered
ToolTip.text: model.isEditable ? qsTr("Edit") : qsTr("Edited") 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 { EmojiButton {
......
...@@ -91,6 +91,11 @@ Page { ...@@ -91,6 +91,11 @@ Page {
onClicked: TimelineManager.timeline.replyAction(messageContextMenu.eventId) onClicked: TimelineManager.timeline.replyAction(messageContextMenu.eventId)
} }
MenuItem {
text: qsTr("Edit")
onClicked: TimelineManager.timeline.editAction(messageContextMenu.eventId)
}
MenuItem { MenuItem {
text: qsTr("Read receipts") text: qsTr("Read receipts")
onTriggered: TimelineManager.timeline.readReceiptsAction(messageContextMenu.eventId) onTriggered: TimelineManager.timeline.readReceiptsAction(messageContextMenu.eventId)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment