client: Optionally ensure backlog on buffer show
[quassel.git] / src / qtui / bufferwidget.cpp
index ceb2806..db209a3 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "action.h"
 #include "actioncollection.h"
+#include "backlogsettings.h"
 #include "chatline.h"
 #include "chatview.h"
 #include "chatviewsearchbar.h"
@@ -83,6 +84,9 @@ BufferWidget::BufferWidget(QWidget* parent)
     ChatViewSettings s;
     s.initAndNotify("AutoMarkerLine", this, &BufferWidget::setAutoMarkerLine, true);
     s.initAndNotify("AutoMarkerLineOnLostFocus", this, &BufferWidget::setAutoMarkerLineOnLostFocus, true);
+
+    BacklogSettings backlogSettings;
+    backlogSettings.initAndNotify("EnsureBacklogOnBufferShow", this, &BufferWidget::setEnsureBacklogOnBufferShow);
 }
 
 BufferWidget::~BufferWidget()
@@ -101,6 +105,11 @@ void BufferWidget::setAutoMarkerLineOnLostFocus(const QVariant& v)
     _autoMarkerLineOnLostFocus = v.toBool();
 }
 
+void BufferWidget::setEnsureBacklogOnBufferShow(const QVariant& v)
+{
+    _ensureBacklogOnBufferShow = v.toBool();
+}
+
 AbstractChatView* BufferWidget::createChatView(BufferId id)
 {
     ChatView* chatView;
@@ -132,6 +141,10 @@ void BufferWidget::showChatView(BufferId id)
         Q_ASSERT(view);
         ui.stackedWidget->setCurrentWidget(view);
         _chatViewSearchController->setScene(view->scene());
+        if (_ensureBacklogOnBufferShow) {
+            // Try to ensure some messages are visible
+            view->requestBacklogForScroll();
+        }
     }
 }