From 7773a0c6482d2b079ea9c59b1e563668c5bd582d Mon Sep 17 00:00:00 2001 From: evgeny Date: Thu, 8 Oct 2026 00:27:02 +0200 Subject: [PATCH] Keep return-to-latest action available in historical message windows --- tools/chatgui/src/chatview.cpp | 8 +++++++- tools/chatgui/src/chatview.h | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/chatgui/src/chatview.cpp b/tools/chatgui/src/chatview.cpp index 9ceb718f..89586a46 100644 --- a/tools/chatgui/src/chatview.cpp +++ b/tools/chatgui/src/chatview.cpp @@ -49,6 +49,7 @@ ChatView::ChatView(QWidget *parent) m_scrollDownBtn->setVisible(false); connect(m_scrollDownBtn, &QPushButton::clicked, this, [this]() { + emit latestRequested(); scrollToBottom(); }); connect(verticalScrollBar(), &QScrollBar::valueChanged, this, &ChatView::updateScrollDownBtn); @@ -65,6 +66,11 @@ void ChatView::setBackgroundImage(const QString &path) { viewport()->update(); } +void ChatView::setHistoricalWindow(bool enabled) { + m_historicalWindow = enabled; + updateScrollDownBtn(); +} + void ChatView::resizeEvent(QResizeEvent *event) { QListView::resizeEvent(event); scheduleDelayedItemsLayout(); @@ -241,7 +247,7 @@ void ChatView::copySelection() { void ChatView::updateScrollDownBtn() { QScrollBar* sb = verticalScrollBar(); bool atBottom = sb && (sb->value() >= sb->maximum()); - m_scrollDownBtn->setVisible(!atBottom); + m_scrollDownBtn->setVisible(m_historicalWindow || !atBottom); if (!atBottom) { QRect vr = viewport()->geometry(); m_scrollDownBtn->move(vr.right() - 44, vr.bottom() - 44); diff --git a/tools/chatgui/src/chatview.h b/tools/chatgui/src/chatview.h index 7cfbd951..3801ba7e 100644 --- a/tools/chatgui/src/chatview.h +++ b/tools/chatgui/src/chatview.h @@ -24,6 +24,7 @@ public: explicit ChatView(QWidget *parent = nullptr); void setBackgroundImage(const QString &path); + void setHistoricalWindow(bool enabled); bool hasSelection() const { return m_selStart.isValid(); } QModelIndex selStart() const { return QModelIndex(m_selStart); } @@ -38,6 +39,7 @@ public: signals: void animationTriggered(); void linkActivated(const QString& link); + void latestRequested(); protected: bool viewportEvent(QEvent *event) override; @@ -62,6 +64,7 @@ private: QPersistentModelIndex m_pressIndex; QPoint m_pressPos; bool m_selecting = false; + bool m_historicalWindow = false; std::function m_linkHitTest; QPushButton *m_scrollDownBtn = nullptr; };