summary refs log tree commit diff
path: root/src/ChatPage.cc
diff options
context:
space:
mode:
authorThomas Herzog <thomas.herzog@mail.com>2017-10-31 19:11:49 +0100
committermujx <mujx@users.noreply.github.com>2017-10-31 20:11:49 +0200
commit287b5aa4c0d52e1ac80a0785ab136aa0f98b3e9f (patch)
tree8535d6ec3717ba551b17fc70f0cc80306273e82c /src/ChatPage.cc
parentAdd missing headers (diff)
downloadnheko-287b5aa4c0d52e1ac80a0785ab136aa0f98b3e9f.tar.xz
Implemented sending of typing notifications (#105)
Diffstat (limited to 'src/ChatPage.cc')
-rw-r--r--src/ChatPage.cc29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/ChatPage.cc b/src/ChatPage.cc

index 5fefd767..d81b64fb 100644 --- a/src/ChatPage.cc +++ b/src/ChatPage.cc
@@ -122,6 +122,9 @@ ChatPage::ChatPage(QSharedPointer<MatrixClient> client, QWidget *parent) contentLayout_->addWidget(typingDisplay_); contentLayout_->addWidget(text_input_); + typingRefresher_ = new QTimer(this); + typingRefresher_->setInterval(TYPING_REFRESH_TIMEOUT); + user_info_widget_ = new UserInfoWidget(sideBarTopWidget_); sideBarTopWidgetLayout_->addWidget(user_info_widget_); @@ -139,6 +142,7 @@ ChatPage::ChatPage(QSharedPointer<MatrixClient> client, QWidget *parent) typingDisplay_->setUsers(users); }); + connect(room_list_, &RoomList::roomChanged, text_input_, &TextInputWidget::stopTyping); connect(room_list_, &RoomList::roomChanged, this, &ChatPage::changeTopRoomInfo); connect(room_list_, &RoomList::roomChanged, text_input_, &TextInputWidget::focusLineEdit); @@ -159,6 +163,20 @@ ChatPage::ChatPage(QSharedPointer<MatrixClient> client, QWidget *parent) room_list_->updateUnreadMessageCount(roomid, count); }); + connect(text_input_, &TextInputWidget::startedTyping, this, [=]() { + typingRefresher_->start(); + client_->sendTypingNotification(current_room_); + }); + + connect(text_input_, &TextInputWidget::stoppedTyping, this, [=]() { + typingRefresher_->stop(); + client_->removeTypingNotification(current_room_); + }); + + connect(typingRefresher_, &QTimer::timeout, this, [=]() { + client_->sendTypingNotification(current_room_); + }); + connect(view_manager_, &TimelineViewManager::updateRoomsLastMessage, room_list_, @@ -600,13 +618,20 @@ ChatPage::updateTypingUsers(const QString &roomid, const QList<QString> &user_id { QStringList users; - for (const auto uid : user_ids) + QSettings settings; + QString user_id = settings.value("auth/user_id").toString(); + + for (const auto uid : user_ids) { + if (uid == user_id) + continue; users.append(TimelineViewManager::displayName(uid)); + } users.sort(); - if (current_room_ == roomid) + if (current_room_ == roomid) { typingDisplay_->setUsers(users); + } typingUsers_.insert(roomid, users); }