summary refs log tree commit diff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/ChatPage.h1
-rw-r--r--include/RoomInfoListItem.h8
-rw-r--r--include/RoomState.h40
-rw-r--r--include/events/MemberEventContent.h10
4 files changed, 46 insertions, 13 deletions
diff --git a/include/ChatPage.h b/include/ChatPage.h

index 12eaf6b7..68495276 100644 --- a/include/ChatPage.h +++ b/include/ChatPage.h
@@ -59,6 +59,7 @@ private slots: void logout(); private: + void updateDisplayNames(const RoomState &state); void updateRoomState(RoomState &room_state, const QJsonArray &events); QHBoxLayout *topLayout_; diff --git a/include/RoomInfoListItem.h b/include/RoomInfoListItem.h
index 75a90ff3..17c75fc3 100644 --- a/include/RoomInfoListItem.h +++ b/include/RoomInfoListItem.h
@@ -50,8 +50,8 @@ protected: void paintEvent(QPaintEvent *event) override; private: - const int Padding = 10; - const int IconSize = 45; + const int Padding = 7; + const int IconSize = 46; RippleOverlay *ripple_overlay_; @@ -66,7 +66,7 @@ private: bool isPressed_ = false; - int maxHeight_ = 60; + int maxHeight_; int unreadMsgCount_ = 0; }; @@ -87,5 +87,5 @@ inline RoomState RoomInfoListItem::state() const inline void RoomInfoListItem::setAvatar(const QImage &img) { - roomAvatar_ = QPixmap::fromImage(img.scaled(IconSize, IconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation)); + roomAvatar_ = QPixmap::fromImage(img.scaled(IconSize, IconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); } diff --git a/include/RoomState.h b/include/RoomState.h
index 788940e2..0389a6df 100644 --- a/include/RoomState.h +++ b/include/RoomState.h
@@ -18,6 +18,7 @@ #pragma once #include <QPixmap> +#include <QUrl> #include "AliasesEventContent.h" #include "AvatarEventContent.h" @@ -25,6 +26,7 @@ #include "CreateEventContent.h" #include "HistoryVisibilityEventContent.h" #include "JoinRulesEventContent.h" +#include "MemberEventContent.h" #include "NameEventContent.h" #include "PowerLevelsEventContent.h" #include "TopicEventContent.h" @@ -38,11 +40,20 @@ namespace events = matrix::events; class RoomState { public: - QString resolveName() const; - inline QString resolveTopic() const; + // Calculate room data that are not immediatly accessible. Like room name and avatar. + // + // e.g If the room is 1-on-1 name and avatar should be extracted from a user. + void resolveName(); + void resolveAvatar(); - QPixmap avatar_img_; + inline QUrl getAvatar() const; + inline QString getName() const; + inline QString getTopic() const; + void removeLeaveMemberships(); + void update(const RoomState &state); + + // The latest state events. events::StateEvent<events::AliasesEventContent> aliases; events::StateEvent<events::AvatarEventContent> avatar; events::StateEvent<events::CanonicalAliasEventContent> canonical_alias; @@ -52,9 +63,30 @@ public: events::StateEvent<events::NameEventContent> name; events::StateEvent<events::PowerLevelsEventContent> power_levels; events::StateEvent<events::TopicEventContent> topic; + + // Contains the m.room.member events for all the joined users. + QMap<QString, events::StateEvent<events::MemberEventContent>> memberships; + +private: + QUrl avatar_; + QString name_; + + // It defines the user whose avatar is used for the room. If the room has an avatar + // event this should be empty. + QString userAvatar_; }; -inline QString RoomState::resolveTopic() const +inline QString RoomState::getTopic() const { return topic.content().topic().simplified(); } + +inline QString RoomState::getName() const +{ + return name_; +} + +inline QUrl RoomState::getAvatar() const +{ + return avatar_; +} diff --git a/include/events/MemberEventContent.h b/include/events/MemberEventContent.h
index f3714462..e61d0cda 100644 --- a/include/events/MemberEventContent.h +++ b/include/events/MemberEventContent.h
@@ -28,19 +28,19 @@ namespace events { enum class Membership { // The user is banned. - BanState, + Ban, // The user has been invited. - InviteState, + Invite, // The user has joined. - JoinState, + Join, // The user has requested to join. - KnockState, + Knock, // The user has left. - LeaveState, + Leave, }; /*