Skip to content

Commit

Permalink
Add edit shortcuts and fix some focus stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
deepbluev7 committed Feb 2, 2021
1 parent 3556899 commit ae59ed3
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 7 deletions.
6 changes: 5 additions & 1 deletion resources/qml/MessageInput.qml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ Rectangle {
if (TimelineManager.timeline)
TimelineManager.timeline.input.updateState(selectionStart, selectionEnd, cursorPosition, text);

forceActiveFocus();
}
onCursorRectangleChanged: textInput.ensureVisible(cursorRectangle)
onCursorPositionChanged: {
Expand Down Expand Up @@ -256,7 +257,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;
Expand All @@ -267,6 +270,7 @@ Rectangle {
Connections {
ignoreUnknownSignals: true
onReplyChanged: messageInput.forceActiveFocus()
onEditChanged: messageInput.forceActiveFocus()
target: TimelineManager.timeline
}

Expand Down
12 changes: 11 additions & 1 deletion resources/qml/MessageView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -66,6 +71,11 @@ ListView {
}
}

Shortcut {
sequence: "Ctrl+E"
onActivated: chat.model.edit = chat.model.reply
}

Component {
id: sectionHeader

Expand Down
6 changes: 3 additions & 3 deletions resources/qml/ReplyPopup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
8 changes: 6 additions & 2 deletions resources/qml/TimelineRow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Item {
ImageButton {
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
Layout.alignment: Qt.AlignRight | Qt.AlignTop
Layout.preferredHeight: 16
Expand All @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions resources/qml/TimelineView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ae59ed3

Please sign in to comment.