summary refs log tree commit diff
path: root/src/timeline/InputBar.h
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2020-11-17 02:37:43 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2020-11-25 19:05:12 +0100
commit921379a4cc3bc6381c4562bfdb9ce0dcde6b1f2c (patch)
treed81f85f20a62f5cd642e787f7ec891a60feec7f2 /src/timeline/InputBar.h
parentMove emoji picker to qml (diff)
downloadnheko-921379a4cc3bc6381c4562bfdb9ce0dcde6b1f2c.tar.xz
Send typing updates from QML
Diffstat (limited to 'src/timeline/InputBar.h')
-rw-r--r--src/timeline/InputBar.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/timeline/InputBar.h b/src/timeline/InputBar.h
index a52a3904..0e9ef592 100644
--- a/src/timeline/InputBar.h
+++ b/src/timeline/InputBar.h
@@ -1,6 +1,7 @@
 #pragma once
 
 #include <QObject>
+#include <QTimer>
 #include <deque>
 
 #include <mtx/common.hpp>
@@ -19,7 +20,14 @@ public:
         InputBar(TimelineModel *parent)
           : QObject()
           , room(parent)
-        {}
+        {
+                typingRefresh_.setInterval(10'000);
+                typingRefresh_.setSingleShot(true);
+                typingTimeout_.setInterval(5'000);
+                typingTimeout_.setSingleShot(true);
+                connect(&typingRefresh_, &QTimer::timeout, this, &InputBar::startTyping);
+                connect(&typingTimeout_, &QTimer::timeout, this, &InputBar::stopTyping);
+        }
 
 public slots:
         void send();
@@ -29,6 +37,10 @@ public slots:
         bool uploading() const { return uploading_; }
         void callButton();
 
+private slots:
+        void startTyping();
+        void stopTyping();
+
 signals:
         void insertText(QString text);
         void uploadingChanged(bool value);
@@ -69,6 +81,8 @@ private:
                 }
         }
 
+        QTimer typingRefresh_;
+        QTimer typingTimeout_;
         TimelineModel *room;
         QString text;
         std::deque<QString> history_;