mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-28 00:42:19 -07:00
Harden scrolling to bottom
Took 11 minutes
This commit is contained in:
parent
15123ed0d2
commit
5da29fc52b
2 changed files with 17 additions and 1 deletions
|
|
@ -13,6 +13,7 @@
|
|||
#include <QDesktopServices>
|
||||
#include <QMouseEvent>
|
||||
#include <QScrollBar>
|
||||
#include <QTimer>
|
||||
#include <libcockatrice/network/server/remote/user_level.h>
|
||||
#include <libcockatrice/settings/chat_settings.h>
|
||||
|
||||
|
|
@ -327,7 +328,20 @@ void ChatView::appendMessage(QString message,
|
|||
}
|
||||
|
||||
if (atBottom || messageType.testFlag(Event_RoomSay::ChatHistory)) {
|
||||
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
|
||||
scrollToBottom();
|
||||
}
|
||||
}
|
||||
|
||||
void ChatView::scrollToBottom()
|
||||
{
|
||||
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
|
||||
|
||||
if (!scrollToBottomPending) {
|
||||
scrollToBottomPending = true;
|
||||
QTimer::singleShot(0, this, [this] {
|
||||
scrollToBottomPending = false;
|
||||
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ private:
|
|||
QStringList highlightedWords;
|
||||
bool evenNumber;
|
||||
bool showTimestamps;
|
||||
bool scrollToBottomPending = false;
|
||||
HoveredItemType hoveredItemType;
|
||||
QString hoveredContent;
|
||||
QAction *messageClicked;
|
||||
|
|
@ -67,6 +68,7 @@ private:
|
|||
|
||||
[[nodiscard]] QTextFragment getFragmentUnderMouse(const QPoint &pos) const;
|
||||
QTextCursor prepareBlock(bool same = false);
|
||||
void scrollToBottom();
|
||||
void appendCardTag(QTextCursor &cursor, const QString &cardName);
|
||||
void appendUrlTag(QTextCursor &cursor, QString url);
|
||||
static QColor getCustomMentionColor();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue