diff options
author | Konstantinos Sideris <sideris.konstantin@gmail.com> | 2017-12-19 22:36:12 +0200 |
---|---|---|
committer | Konstantinos Sideris <sideris.konstantin@gmail.com> | 2017-12-19 22:36:12 +0200 |
commit | f11044b5eb9cf42cc71930b567b7566f1293a936 (patch) | |
tree | cff5928ed2e8044905a3880731ee45f7a4a4176e /include | |
parent | 101bf47443a1005f09e5369f232719cd9b67c189 (diff) |
Handle incoming invites
fixes #128
Diffstat (limited to 'include')
-rw-r--r-- | include/Cache.h | 7 | ||||
-rw-r--r-- | include/ChatPage.h | 1 | ||||
-rw-r--r-- | include/RoomInfoListItem.h | 79 | ||||
-rw-r--r-- | include/RoomList.h | 6 |
4 files changed, 69 insertions, 24 deletions
diff --git a/include/Cache.h b/include/Cache.h index 031c8b16..c141a42a 100644 --- a/include/Cache.h +++ b/include/Cache.h @@ -19,6 +19,7 @@ #include <QDir> #include <lmdb++.h> +#include <mtx/responses.hpp> class RoomState; @@ -33,10 +34,15 @@ public: QString nextBatchToken() const; QMap<QString, RoomState> states(); + using Invites = std::map<std::string, mtx::responses::InvitedRoom>; + Invites invites(); + void setInvites(const Invites &invites); + void deleteData(); void unmount() { isMounted_ = false; }; void removeRoom(const QString &roomid); + void removeInvite(const QString &roomid); void setup(); bool isFormatValid(); @@ -49,6 +55,7 @@ private: lmdb::env env_; lmdb::dbi stateDb_; lmdb::dbi roomDb_; + lmdb::dbi invitesDb_; bool isMounted_; diff --git a/include/ChatPage.h b/include/ChatPage.h index 94c54f0b..14d44ff3 100644 --- a/include/ChatPage.h +++ b/include/ChatPage.h @@ -78,6 +78,7 @@ private slots: void logout(); void addRoom(const QString &room_id); void removeRoom(const QString &room_id); + void removeInvite(const QString &room_id); private: using UserID = QString; diff --git a/include/RoomInfoListItem.h b/include/RoomInfoListItem.h index acb1ab84..d4e4f983 100644 --- a/include/RoomInfoListItem.h +++ b/include/RoomInfoListItem.h @@ -21,6 +21,8 @@ #include <QSharedPointer> #include <QWidget> +#include <mtx/responses.hpp> + #include "RoomState.h" class Menu; @@ -52,12 +54,17 @@ class RoomInfoListItem : public QWidget Q_PROPERTY(QColor highlightedSubtitleColor READ highlightedSubtitleColor WRITE setHighlightedSubtitleColor) + Q_PROPERTY(QColor btnColor READ btnColor WRITE setBtnColor) + Q_PROPERTY(QColor btnTextColor READ btnTextColor WRITE setBtnTextColor) + public: RoomInfoListItem(QSharedPointer<RoomSettings> settings, RoomState state, QString room_id, QWidget *parent = 0); + RoomInfoListItem(QString room_id, mtx::responses::InvitedRoom room, QWidget *parent = 0); + ~RoomInfoListItem(); void updateUnreadMessageCount(int count); @@ -71,35 +78,36 @@ public: void setAvatar(const QImage &avatar_image); void setDescriptionMessage(const DescInfo &info); - inline QColor highlightedBackgroundColor() const { return highlightedBackgroundColor_; } - inline QColor hoverBackgroundColor() const { return hoverBackgroundColor_; } - inline QColor backgroundColor() const { return backgroundColor_; } + QColor highlightedBackgroundColor() const { return highlightedBackgroundColor_; } + QColor hoverBackgroundColor() const { return hoverBackgroundColor_; } + QColor backgroundColor() const { return backgroundColor_; } - inline QColor highlightedTitleColor() const { return highlightedTitleColor_; } - inline QColor highlightedSubtitleColor() const { return highlightedSubtitleColor_; } + QColor highlightedTitleColor() const { return highlightedTitleColor_; } + QColor highlightedSubtitleColor() const { return highlightedSubtitleColor_; } - inline QColor titleColor() const { return titleColor_; } - inline QColor subtitleColor() const { return subtitleColor_; } + QColor titleColor() const { return titleColor_; } + QColor subtitleColor() const { return subtitleColor_; } + QColor btnColor() const { return btnColor_; } + QColor btnTextColor() const { return btnTextColor_; } - inline void setHighlightedBackgroundColor(QColor &color) - { - highlightedBackgroundColor_ = color; - } - inline void setHoverBackgroundColor(QColor &color) { hoverBackgroundColor_ = color; } - inline void setBackgroundColor(QColor &color) { backgroundColor_ = color; } + void setHighlightedBackgroundColor(QColor &color) { highlightedBackgroundColor_ = color; } + void setHoverBackgroundColor(QColor &color) { hoverBackgroundColor_ = color; } + void setBackgroundColor(QColor &color) { backgroundColor_ = color; } - inline void setHighlightedTitleColor(QColor &color) { highlightedTitleColor_ = color; } - inline void setHighlightedSubtitleColor(QColor &color) - { - highlightedSubtitleColor_ = color; - } + void setHighlightedTitleColor(QColor &color) { highlightedTitleColor_ = color; } + void setHighlightedSubtitleColor(QColor &color) { highlightedSubtitleColor_ = color; } + + void setTitleColor(QColor &color) { titleColor_ = color; } + void setSubtitleColor(QColor &color) { subtitleColor_ = color; } - inline void setTitleColor(QColor &color) { titleColor_ = color; } - inline void setSubtitleColor(QColor &color) { subtitleColor_ = color; } + void setBtnColor(QColor &color) { btnColor_ = color; } + void setBtnTextColor(QColor &color) { btnTextColor_ = color; } signals: void clicked(const QString &room_id); void leaveRoom(const QString &room_id); + void acceptInvite(const QString &room_id); + void declineInvite(const QString &room_id); public slots: void setPressedState(bool state); @@ -111,15 +119,33 @@ protected: void contextMenuEvent(QContextMenuEvent *event) override; private: - QString notificationText(); + void init(QWidget *parent); + QString roomName() + { + if (roomType_ == RoomType::Joined) + return state_.getName(); - const int Padding = 7; - const int IconSize = 48; + return roomName_; + } + + QString notificationText(); RippleOverlay *ripple_overlay_; + enum class RoomType + { + Joined, + Invited, + }; + + RoomType roomType_ = RoomType::Joined; + + // State information for the joined rooms. RoomState state_; + // State information for the invited rooms. + mtx::responses::InvitedRoom invitedRoom_; + QString roomId_; QString roomName_; @@ -135,7 +161,6 @@ private: bool isPressed_ = false; - int maxHeight_; int unreadMsgCount_ = 0; QColor highlightedBackgroundColor_; @@ -147,4 +172,10 @@ private: QColor titleColor_; QColor subtitleColor_; + + QColor btnColor_; + QColor btnTextColor_; + + QRectF acceptBtnRegion_; + QRectF declineBtnRegion_; }; diff --git a/include/RoomList.h b/include/RoomList.h index f75f7ba4..8487df10 100644 --- a/include/RoomList.h +++ b/include/RoomList.h @@ -24,6 +24,8 @@ #include <QVBoxLayout> #include <QWidget> +#include <mtx.hpp> + #include "dialogs/LeaveRoom.h" class LeaveRoomDialog; @@ -47,17 +49,21 @@ public: const QMap<QString, RoomState> &states); void sync(const QMap<QString, RoomState> &states, QMap<QString, QSharedPointer<RoomSettings>> &settings); + void syncInvites(const std::map<std::string, mtx::responses::InvitedRoom> &rooms); void clear(); void addRoom(const QMap<QString, QSharedPointer<RoomSettings>> &settings, const RoomState &state, const QString &room_id); + void addInvitedRoom(const QString &room_id, const mtx::responses::InvitedRoom &room); void removeRoom(const QString &room_id, bool reset); signals: void roomChanged(const QString &room_id); void totalUnreadMessageCountUpdated(int count); + void acceptInvite(const QString &room_id); + void declineInvite(const QString &room_id); public slots: void updateRoomAvatar(const QString &roomid, const QPixmap &img); |