summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCatalin Badea <catalin.badea392@gmail.com>2012-08-01 10:55:21 (GMT)
committerCatalin Badea <catalin.badea392@gmail.com>2012-08-01 10:55:21 (GMT)
commitddd4265b65c4a523d6f86abf6cad8fcda16be021 (patch)
tree07308a4bff15198844be1bc217d9533b7fb68c5d /Swift/QtUI
parent2fe9c9f3952b5ab6b8a158233deda8a89fe0b589 (diff)
downloadswift-contrib-ddd4265b65c4a523d6f86abf6cad8fcda16be021.zip
swift-contrib-ddd4265b65c4a523d6f86abf6cad8fcda16be021.tar.bz2
Fix javascript autoscrolling.
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/QtChatView.cpp8
-rw-r--r--Swift/QtUI/QtChatView.h2
-rw-r--r--Swift/QtUI/QtHistoryWindow.cpp2
3 files changed, 9 insertions, 3 deletions
diff --git a/Swift/QtUI/QtChatView.cpp b/Swift/QtUI/QtChatView.cpp
index 4ae613a..74ffb8b 100644
--- a/Swift/QtUI/QtChatView.cpp
+++ b/Swift/QtUI/QtChatView.cpp
@@ -28,7 +28,7 @@
namespace Swift {
-QtChatView::QtChatView(QtChatTheme* theme, QWidget* parent) : QWidget(parent), fontSizeSteps_(0) {
+QtChatView::QtChatView(QtChatTheme* theme, QWidget* parent, bool disableAutoScroll) : QWidget(parent), fontSizeSteps_(0) {
theme_ = theme;
QVBoxLayout* mainLayout = new QVBoxLayout(this);
@@ -66,6 +66,10 @@ QtChatView::QtChatView(QtChatTheme* theme, QWidget* parent) : QWidget(parent), f
viewReady_ = false;
isAtBottom_ = true;
resetView();
+
+ if (disableAutoScroll) {
+ webPage_->mainFrame()->evaluateJavaScript("var disableAutoScroll = true;");
+ }
}
void QtChatView::handleClearRequested() {
@@ -360,6 +364,8 @@ void QtChatView::resetView() {
chatElement.appendInside(newInsertPoint_);
Q_ASSERT(!newInsertPoint_.isNull());
+ scrollToBottom();
+
connect(webPage_->mainFrame(), SIGNAL(contentsSizeChanged(const QSize&)), this, SLOT(handleFrameSizeChanged()), Qt::UniqueConnection);
}
diff --git a/Swift/QtUI/QtChatView.h b/Swift/QtUI/QtChatView.h
index dada46a..8c523d5 100644
--- a/Swift/QtUI/QtChatView.h
+++ b/Swift/QtUI/QtChatView.h
@@ -28,7 +28,7 @@ namespace Swift {
class QtChatView : public QWidget {
Q_OBJECT
public:
- QtChatView(QtChatTheme* theme, QWidget* parent);
+ QtChatView(QtChatTheme* theme, QWidget* parent, bool disableAutoScroll = false);
void addMessageTop(boost::shared_ptr<ChatSnippet> snippet);
void addMessageBottom(boost::shared_ptr<ChatSnippet> snippet);
void addLastSeenLine();
diff --git a/Swift/QtUI/QtHistoryWindow.cpp b/Swift/QtUI/QtHistoryWindow.cpp
index 94d604e..d926db7 100644
--- a/Swift/QtUI/QtHistoryWindow.cpp
+++ b/Swift/QtUI/QtHistoryWindow.cpp
@@ -36,7 +36,7 @@ QtHistoryWindow::QtHistoryWindow(SettingsProvider* settings, UIEventStream* even
idCounter_ = 0;
delete ui_.conversation_;
- conversation_ = new QtChatView(theme_, this);
+ conversation_ = new QtChatView(theme_, this, true);
QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
sizePolicy.setHorizontalStretch(80);
sizePolicy.setVerticalStretch(0);