Skip to content

Commit

Permalink
Merge pull request #420 from Nheko-Reborn/render-edits
Browse files Browse the repository at this point in the history
Switch to new relations format and show edits
  • Loading branch information
deepbluev7 authored Feb 10, 2021
2 parents 463cee7 + 29c89b1 commit 4a5b5f9
Show file tree
Hide file tree
Showing 22 changed files with 555 additions and 169 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ if(USE_BUNDLED_MTXCLIENT)
FetchContent_Declare(
MatrixClient
GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git
GIT_TAG v0.4.1
GIT_TAG fee5298f068394958c2de935836a2c145f273906
)
set(BUILD_LIB_EXAMPLES OFF CACHE INTERNAL "")
set(BUILD_LIB_TESTS OFF CACHE INTERNAL "")
Expand Down
3 changes: 1 addition & 2 deletions io.github.NhekoReborn.Nheko.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,7 @@
"name": "mtxclient",
"sources": [
{
"commit": "4951190c938740defa0988d98d5e861038622936",
"tag": "v0.4.1",
"commit": "fee5298f068394958c2de935836a2c145f273906",
"type": "git",
"url": "https://github.com/Nheko-Reborn/mtxclient.git"
}
Expand Down
10 changes: 9 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 @@ -260,13 +261,20 @@ Rectangle {

Connections {
ignoreUnknownSignals: true
onInsertText: messageInput.insert(messageInput.cursorPosition, text)
onInsertText: {
messageInput.insert(messageInput.cursorPosition, text);
}
onTextChanged: {
messageInput.text = newText;
messageInput.cursorPosition = newText.length;
}
target: TimelineManager.timeline ? TimelineManager.timeline.input : null
}

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
21 changes: 18 additions & 3 deletions resources/qml/ReplyPopup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ Rectangle {
property var room: TimelineManager.timeline

Layout.fillWidth: true
visible: room && room.reply
visible: room && (room.reply || room.edit)
// Height of child, plus margins, plus border
implicitHeight: replyPreview.height + 10
implicitHeight: (room && room.reply ? replyPreview.height : closeEditButton.height) + 10
color: colors.window
z: 3

Reply {
id: replyPreview

visible: room && room.reply
anchors.left: parent.left
anchors.leftMargin: 2 * 22 + 3 * 16
anchors.right: closeReplyButton.left
Expand All @@ -32,8 +33,9 @@ Rectangle {
ImageButton {
id: closeReplyButton

visible: room && room.reply
anchors.right: parent.right
anchors.rightMargin: 15
anchors.rightMargin: 16
anchors.top: replyPreview.top
hoverEnabled: true
width: 16
Expand All @@ -44,4 +46,17 @@ Rectangle {
onClicked: room.reply = undefined
}

Button {
id: closeEditButton

visible: room && room.edit
anchors.left: parent.left
anchors.rightMargin: 16
anchors.topMargin: 10
anchors.top: parent.top
//height: 16
text: qsTr("Cancel edit")
onClicked: room.edit = undefined
}

}
19 changes: 19 additions & 0 deletions resources/qml/TimelineRow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,25 @@ Item {
width: 16
}

ImageButton {
id: editButton

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
width: 16
hoverEnabled: true
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);

}
}

EmojiButton {
id: reactButton

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
Loading

0 comments on commit 4a5b5f9

Please sign in to comment.