summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Swift/Controllers/HistoryViewController.cpp8
-rw-r--r--Swift/QtUI/QtChatView.cpp8
-rw-r--r--Swift/QtUI/QtChatView.h2
-rw-r--r--Swift/QtUI/QtHistoryWindow.cpp2
-rwxr-xr-xSwift/resources/themes/Default/Template.html4
-rwxr-xr-xSwift/resources/themes/Default/main.css4
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 3ad957c..f6250bc 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 d2d4b57..25bd5bc 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%;
+}