diff --git a/include/ChatPage.h b/include/ChatPage.h
index 8becc17f..8332225b 100644
--- a/include/ChatPage.h
+++ b/include/ChatPage.h
@@ -31,6 +31,7 @@
#include "TextInputWidget.h"
#include "TimelineViewManager.h"
#include "TopRoomBar.h"
+#include "TypingDisplay.h"
#include "UserInfoWidget.h"
class ChatPage : public QWidget
@@ -68,6 +69,7 @@ protected:
void keyPressEvent(QKeyEvent *event) override;
private:
+ void updateTypingUsers(const QString &roomid, const QList<QString> &user_ids);
void updateDisplayNames(const RoomState &state);
void loadStateFromCache();
void showQuickSwitcher();
@@ -92,6 +94,7 @@ private:
TopRoomBar *top_bar_;
TextInputWidget *text_input_;
+ TypingDisplay *typingDisplay_;
QTimer *sync_timer_;
int sync_interval_;
@@ -104,6 +107,9 @@ private:
QMap<QString, RoomState> state_manager_;
QMap<QString, QSharedPointer<RoomSettings>> settingsManager_;
+ // Keeps track of the users currently typing on each room.
+ QMap<QString, QList<QString>> typingUsers_;
+
QuickSwitcher *quickSwitcher_ = nullptr;
OverlayModal *quickSwitcherModal_ = nullptr;
diff --git a/include/Config.h b/include/Config.h
index 654eadb6..50f9eb85 100644
--- a/include/Config.h
+++ b/include/Config.h
@@ -7,9 +7,10 @@
namespace conf
{
// Global settings.
-static const int fontSize = 12;
-static const int emojiSize = 14;
-static const int headerFontSize = 21;
+static const int fontSize = 12;
+static const int emojiSize = 14;
+static const int headerFontSize = 21;
+static const int typingNotificationFontSize = 11;
// Window geometry.
namespace window
diff --git a/include/Sync.h b/include/Sync.h
index a9caf473..c49d7101 100644
--- a/include/Sync.h
+++ b/include/Sync.h
@@ -142,23 +142,30 @@ Timeline::limited() const
return limited_;
}
-// TODO: Add support for ehpmeral, account_data, undread_notifications
+// TODO: Add support for account_data, undread_notifications
class JoinedRoom : public Deserializable
{
public:
inline State state() const;
inline Timeline timeline() const;
+ inline QList<QString> typingUserIDs() const;
void deserialize(const QJsonValue &data) override;
private:
State state_;
Timeline timeline_;
- /* Ephemeral ephemeral_; */
+ QList<QString> typingUserIDs_;
/* AccountData account_data_; */
/* UnreadNotifications unread_notifications_; */
};
+inline QList<QString>
+JoinedRoom::typingUserIDs() const
+{
+ return typingUserIDs_;
+}
+
inline State
JoinedRoom::state() const
{
diff --git a/include/TypingDisplay.h b/include/TypingDisplay.h
new file mode 100644
index 00000000..db8a9519
--- /dev/null
+++ b/include/TypingDisplay.h
@@ -0,0 +1,21 @@
+#pragma once
+
+#include <QPaintEvent>
+#include <QWidget>
+
+class TypingDisplay : public QWidget
+{
+ Q_OBJECT
+
+public:
+ TypingDisplay(QWidget *parent = nullptr);
+
+ void setUsers(const QStringList &user_ids);
+
+protected:
+ void paintEvent(QPaintEvent *event) override;
+
+private:
+ QString text_;
+ int leftPadding_;
+};
|