summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-08-30 18:45:55 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-08-30 18:45:55 (GMT)
commit97643bb9103a7b4a61cd267648f36cc7ffb36e6d (patch)
tree2c814cda1093f322a349237e01b58f5c7e44bcad /Swift
parentb675400b6bc22d841ca5273939ab64be277adb32 (diff)
downloadswift-97643bb9103a7b4a61cd267648f36cc7ffb36e6d.zip
swift-97643bb9103a7b4a61cd267648f36cc7ffb36e6d.tar.bz2
Start scrolling on new messages.
Resolves: #551
Diffstat (limited to 'Swift')
-rw-r--r--Swift/QtUI/QtChatView.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/Swift/QtUI/QtChatView.cpp b/Swift/QtUI/QtChatView.cpp
index 52b399b..32f2394 100644
--- a/Swift/QtUI/QtChatView.cpp
+++ b/Swift/QtUI/QtChatView.cpp
@@ -13,6 +13,7 @@
#include <QWebFrame>
#include <QKeyEvent>
#include <QStackedWidget>
+#include <QTimer>
#include "QtWebView.h"
#include "QtChatTheme.h"
@@ -88,6 +89,8 @@ QWebElement QtChatView::snippetToDOM(boost::shared_ptr<ChatSnippet> snippet) {
}
void QtChatView::addToDOM(boost::shared_ptr<ChatSnippet> snippet) {
+ bool bottom = isScrolledToBottom();
+ qDebug() << "Appending to the dom - scrolled to bottom? " << bottom;
QWebElement newElement = snippetToDOM(snippet);
QWebElement continuationElement = lastElement_.findFirst("#insert");
if (snippet->getAppendToPrevious()) {
@@ -98,6 +101,10 @@ void QtChatView::addToDOM(boost::shared_ptr<ChatSnippet> snippet) {
newInsertPoint_.prependOutside(newElement);
}
lastElement_ = newElement;
+ if (bottom /* Or was me? */) {
+ QTimer::singleShot(0, this, SLOT(scrollToBottom()));
+ }
+ qDebug() << "Appended, now at bottom? " << isScrolledToBottom();
}
void QtChatView::correctLastMessage(const QString& newMessage) {