focus message input on adding emoji/reacting to a message

This commit is contained in:
Jedi18 2021-02-05 22:42:08 +05:30
parent f02342fe22
commit 4aefac08a4
4 changed files with 15 additions and 0 deletions

View file

@ -270,6 +270,11 @@ Rectangle {
target: TimelineManager.timeline target: TimelineManager.timeline
} }
Connections {
target: TimelineManager
onFocusInput: messageInput.forceActiveFocus()
}
MouseArea { MouseArea {
// workaround for wrong cursor shape on some platforms // workaround for wrong cursor shape on some platforms
anchors.fill: parent anchors.fill: parent
@ -297,6 +302,7 @@ Rectangle {
ToolTip.text: qsTr("Emoji") ToolTip.text: qsTr("Emoji")
onClicked: emojiPopup.visible ? emojiPopup.close() : emojiPopup.show(emojiButton, function(emoji) { onClicked: emojiPopup.visible ? emojiPopup.close() : emojiPopup.show(emojiButton, function(emoji) {
messageInput.insert(messageInput.cursorPosition, emoji); messageInput.insert(messageInput.cursorPosition, emoji);
TimelineManager.focusMessageInput()
}) })
} }

View file

@ -14,5 +14,6 @@ ImageButton {
image: ":/icons/icons/ui/smile.png" image: ":/icons/icons/ui/smile.png"
onClicked: emojiPicker.visible ? emojiPicker.close() : emojiPicker.show(emojiButton, function(emoji) { onClicked: emojiPicker.visible ? emojiPicker.close() : emojiPicker.show(emojiButton, function(emoji) {
TimelineManager.queueReactionMessage(event_id, emoji); TimelineManager.queueReactionMessage(event_id, emoji);
TimelineManager.focusMessageInput()
}) })
} }

View file

@ -545,3 +545,9 @@ TimelineViewManager::queueCallMessage(const QString &roomid,
{ {
models.value(roomid)->sendMessageEvent(callHangUp, mtx::events::EventType::CallHangUp); models.value(roomid)->sendMessageEvent(callHangUp, mtx::events::EventType::CallHangUp);
} }
void
TimelineViewManager::focusMessageInput()
{
emit focusInput();
}

View file

@ -66,6 +66,7 @@ public:
Q_INVOKABLE void openLink(QString link) const; Q_INVOKABLE void openLink(QString link) const;
Q_INVOKABLE void focusMessageInput();
Q_INVOKABLE void openInviteUsersDialog(); Q_INVOKABLE void openInviteUsersDialog();
Q_INVOKABLE void openMemberListDialog() const; Q_INVOKABLE void openMemberListDialog() const;
Q_INVOKABLE void openLeaveRoomDialog() const; Q_INVOKABLE void openLeaveRoomDialog() const;
@ -87,6 +88,7 @@ signals:
void showRoomList(); void showRoomList();
void narrowViewChanged(); void narrowViewChanged();
void focusChanged(); void focusChanged();
void focusInput();
public slots: public slots:
void updateReadReceipts(const QString &room_id, const std::vector<QString> &event_ids); void updateReadReceipts(const QString &room_id, const std::vector<QString> &event_ids);