From 0137a1bad4d9fcb4460703e9b26906169b662457 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 16 Jul 2026 13:03:23 +0300 Subject: [PATCH] chatgui: preserve input focus on chat refresh (save/restore focusWidget in loadChannel) --- tools/chatgui/src/messagelist.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/chatgui/src/messagelist.cpp b/tools/chatgui/src/messagelist.cpp index abc2c3f5..4702fe7f 100644 --- a/tools/chatgui/src/messagelist.cpp +++ b/tools/chatgui/src/messagelist.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -165,6 +166,7 @@ MessageList::MessageList(DbManager* db, QWidget *parent) } void MessageList::loadChannel(const QString& channelId) { + QWidget* prevFocus = QApplication::focusWidget(); m_model->clear(); m_avatarCache.clear(); m_currentChannelId = channelId; @@ -197,7 +199,10 @@ void MessageList::loadChannel(const QString& channelId) { if (m_model->rowCount() > 0) m_view->scrollToBottom(); - m_inputBar->setFocus(); + if (prevFocus) + prevFocus->setFocus(); + else + m_inputBar->setFocus(); } void MessageList::refresh() {