diff options
author | Catalin Badea <catalin.badea392@gmail.com> | 2012-08-01 10:55:21 (GMT) |
---|---|---|
committer | Catalin Badea <catalin.badea392@gmail.com> | 2012-08-01 10:55:21 (GMT) |
commit | ddd4265b65c4a523d6f86abf6cad8fcda16be021 (patch) | |
tree | 07308a4bff15198844be1bc217d9533b7fb68c5d | |
parent | 2fe9c9f3952b5ab6b8a158233deda8a89fe0b589 (diff) | |
download | swift-contrib-ddd4265b65c4a523d6f86abf6cad8fcda16be021.zip swift-contrib-ddd4265b65c4a523d6f86abf6cad8fcda16be021.tar.bz2 |
Fix javascript autoscrolling.
-rw-r--r-- | Swift/Controllers/HistoryViewController.cpp | 8 | ||||
-rw-r--r-- | Swift/QtUI/QtChatView.cpp | 8 | ||||
-rw-r--r-- | Swift/QtUI/QtChatView.h | 2 | ||||
-rw-r--r-- | Swift/QtUI/QtHistoryWindow.cpp | 2 | ||||
-rwxr-xr-x | Swift/resources/themes/Default/Template.html | 4 | ||||
-rwxr-xr-x | Swift/resources/themes/Default/main.css | 4 |
6 files changed, 25 insertions, 3 deletions
diff --git a/Swift/Controllers/HistoryViewController.cpp b/Swift/Controllers/HistoryViewController.cpp index 57b331b..819ba4e 100644 --- a/Swift/Controllers/HistoryViewController.cpp +++ b/Swift/Controllers/HistoryViewController.cpp @@ -163,6 +163,10 @@ void HistoryViewController::handleReturnPressed(const std::string& keyword) { } void HistoryViewController::handleScrollReachedTop(const boost::gregorian::date& date) { + if (!selectedItem_) { + return; + } + std::vector<HistoryMessage> messages = historyController_->getMessagesFromPreviousDate(selfJID_, selectedItem_->getJID(), selectedItemType_, date); foreach (const HistoryMessage& message, messages) { @@ -172,6 +176,10 @@ void HistoryViewController::handleScrollReachedTop(const boost::gregorian::date& } void HistoryViewController::handleScrollReachedBottom(const boost::gregorian::date& date) { + if (!selectedItem_) { + return; + } + std::vector<HistoryMessage> messages = historyController_->getMessagesFromNextDate(selfJID_, selectedItem_->getJID(), selectedItemType_, date); foreach (const HistoryMessage& message, messages) { 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); diff --git a/Swift/resources/themes/Default/Template.html b/Swift/resources/themes/Default/Template.html index e94701a..3885330 100755 --- a/Swift/resources/themes/Default/Template.html +++ b/Swift/resources/themes/Default/Template.html @@ -272,6 +272,10 @@ var intervall_scroll; function scrollToBottom() { + if (disableAutoScroll) { + return; + } + //document.body.scrollTop = (document.body.scrollHeight-window.innerHeight); //return; if( intervall_scroll ) clearInterval( intervall_scroll ); diff --git a/Swift/resources/themes/Default/main.css b/Swift/resources/themes/Default/main.css index 4982ba6..cd79f6e 100755 --- a/Swift/resources/themes/Default/main.css +++ b/Swift/resources/themes/Default/main.css @@ -291,3 +291,7 @@ body { .outgoingItem .timeStamp { color:#9ecf35; } + +html { + height: 101%; +} |