client: Workaround initial backlog fetch scrolling
[quassel.git] / src / qtui / chatview.h
index d624e05..0f90a66 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-2018 by the Quassel Project                        *
+ *   Copyright (C) 2005-2020 by the Quassel Project                        *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
@@ -79,6 +79,17 @@ public:
      */
     void setHasCache(ChatLine* line, bool hasCache = true);
 
+    /**
+     * Requests backlog if the scrollbar is not currently visible
+     *
+     * Use this whenever trying to scroll the backlog to try to ensure some text is visible.  If the
+     * backlog does not have additional messages or those messages are filtered out, the scrollbar
+     * might remain invisible.
+     *
+     * @return True if the scrollbar isn't visible and a backlog request was made, otherwise false
+     */
+    bool requestBacklogForScroll();
+
 public slots:
     inline virtual void clear() {}
     void zoomIn();
@@ -91,6 +102,7 @@ public slots:
 
 protected:
     bool event(QEvent* event) override;
+    bool eventFilter(QObject* watched, QEvent* event) override;
     void resizeEvent(QResizeEvent* event) override;
     void scrollContentsBy(int dx, int dy) override;
 
@@ -118,6 +130,8 @@ private:
     bool _invalidateFilter;
     QSet<ChatLine*> _linesWithCache;
     bool _firstTouchUpdateHappened = false;
+    /// Workaround: If true, backlog has been requested before the vertical scrollbar became visible
+    bool _backlogRequestedBeforeScrollable{false};
 };
 
 #endif