mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-28 08:52: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 <QDesktopServices>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
|
#include <QTimer>
|
||||||
#include <libcockatrice/network/server/remote/user_level.h>
|
#include <libcockatrice/network/server/remote/user_level.h>
|
||||||
#include <libcockatrice/settings/chat_settings.h>
|
#include <libcockatrice/settings/chat_settings.h>
|
||||||
|
|
||||||
|
|
@ -327,7 +328,20 @@ void ChatView::appendMessage(QString message,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (atBottom || messageType.testFlag(Event_RoomSay::ChatHistory)) {
|
if (atBottom || messageType.testFlag(Event_RoomSay::ChatHistory)) {
|
||||||
|
scrollToBottom();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChatView::scrollToBottom()
|
||||||
|
{
|
||||||
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
|
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;
|
QStringList highlightedWords;
|
||||||
bool evenNumber;
|
bool evenNumber;
|
||||||
bool showTimestamps;
|
bool showTimestamps;
|
||||||
|
bool scrollToBottomPending = false;
|
||||||
HoveredItemType hoveredItemType;
|
HoveredItemType hoveredItemType;
|
||||||
QString hoveredContent;
|
QString hoveredContent;
|
||||||
QAction *messageClicked;
|
QAction *messageClicked;
|
||||||
|
|
@ -67,6 +68,7 @@ private:
|
||||||
|
|
||||||
[[nodiscard]] QTextFragment getFragmentUnderMouse(const QPoint &pos) const;
|
[[nodiscard]] QTextFragment getFragmentUnderMouse(const QPoint &pos) const;
|
||||||
QTextCursor prepareBlock(bool same = false);
|
QTextCursor prepareBlock(bool same = false);
|
||||||
|
void scrollToBottom();
|
||||||
void appendCardTag(QTextCursor &cursor, const QString &cardName);
|
void appendCardTag(QTextCursor &cursor, const QString &cardName);
|
||||||
void appendUrlTag(QTextCursor &cursor, QString url);
|
void appendUrlTag(QTextCursor &cursor, QString url);
|
||||||
static QColor getCustomMentionColor();
|
static QColor getCustomMentionColor();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue