Keep return-to-latest action available in historical message windows
This commit is contained in:
1 parent
38257a7f54
commit
7773a0c648
2 files changed
+10
-1
No files matched your search
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user