Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to new relations format and show edits #420

Merged
merged 9 commits into from
Feb 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
deepbluev7 marked this conversation as resolved.
Show resolved Hide resolved
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think room && is probably superfluous here? Since the popup is only visible if 'room' is defined, I'm thinking the height doesn't really matter much.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't do the room &&, you get null warnings. It's stupid, but sadly necessary. It's just in the condition to prevent the null warning, apart from this the conditional sets this to reply height or edit height, depending o. if this has a reply or not.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm reading this correctly, you're overloading this button to be for messages that are already edited as well as for messages that can be edited. If this is the case, it seems like it could be confusing to users. Also, what happens if someone tries to edit the same message twice? the button will say 'Edited' when the user may want to edit again and it may lead them to think they cannot edit the message again despite a button being there that allows them to edit in other scenarios.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I don't really have a good idea on how to solve that. So I just left it like that for now and will later move the edit button into a dedicated action button bar, that shows on hover, while only status icons like read, edited and timestamp are shown by default?

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