Add member list
This commit is contained in:
parent
3097037c3d
commit
763330fd3c
13 changed files with 300 additions and 14 deletions
|
|
@ -24,6 +24,13 @@
|
|||
#include <lmdb++.h>
|
||||
#include <mtx/responses.hpp>
|
||||
|
||||
struct RoomMember
|
||||
{
|
||||
QString user_id;
|
||||
QString display_name;
|
||||
QImage avatar;
|
||||
};
|
||||
|
||||
struct SearchResult
|
||||
{
|
||||
QString user_id;
|
||||
|
|
@ -32,6 +39,7 @@ struct SearchResult
|
|||
|
||||
Q_DECLARE_METATYPE(SearchResult)
|
||||
Q_DECLARE_METATYPE(QVector<SearchResult>)
|
||||
Q_DECLARE_METATYPE(RoomMember);
|
||||
|
||||
//! Used to uniquely identify a list of read receipts.
|
||||
struct ReadReceiptKey
|
||||
|
|
@ -164,6 +172,11 @@ public:
|
|||
lmdb::dbi &membersdb,
|
||||
const QString &room_id);
|
||||
|
||||
//! Retrieve member info from a room.
|
||||
std::vector<RoomMember> getMembers(const std::string &room_id,
|
||||
std::size_t startIndex = 0,
|
||||
std::size_t len = 30);
|
||||
|
||||
void saveState(const mtx::responses::Sync &res);
|
||||
bool isInitialized() const;
|
||||
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ class InviteUsers;
|
|||
class JoinRoom;
|
||||
class LeaveRoom;
|
||||
class Logout;
|
||||
class MemberList;
|
||||
class ReCaptcha;
|
||||
class RoomSettings;
|
||||
}
|
||||
|
|
@ -70,6 +71,7 @@ public:
|
|||
void openJoinRoomDialog(std::function<void(const QString &room_id)> callback);
|
||||
void openLogoutDialog(std::function<void()> callback);
|
||||
void openRoomSettings(const QString &room_id = "");
|
||||
void openMemberListDialog(const QString &room_id = "");
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
|
@ -153,4 +155,8 @@ private:
|
|||
QSharedPointer<OverlayModal> roomSettingsModal_;
|
||||
//! Room settings dialog.
|
||||
QSharedPointer<dialogs::RoomSettings> roomSettingsDialog_;
|
||||
//! Member list modal.
|
||||
QSharedPointer<OverlayModal> memberListModal_;
|
||||
//! Member list dialog.
|
||||
QSharedPointer<dialogs::MemberList> memberListDialog_;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ private:
|
|||
|
||||
Menu *menu_;
|
||||
QAction *leaveRoom_;
|
||||
QAction *roomMembers_;
|
||||
QAction *roomSettings_;
|
||||
QAction *inviteUsers_;
|
||||
|
||||
|
|
|
|||
57
include/dialogs/MemberList.hpp
Normal file
57
include/dialogs/MemberList.hpp
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#pragma once
|
||||
|
||||
#include <QFrame>
|
||||
#include <QListWidget>
|
||||
|
||||
class Avatar;
|
||||
class Cache;
|
||||
class FlatButton;
|
||||
class QHBoxLayout;
|
||||
class QLabel;
|
||||
class QVBoxLayout;
|
||||
|
||||
struct RoomMember;
|
||||
|
||||
template<class T>
|
||||
class QSharedPointer;
|
||||
|
||||
namespace dialogs {
|
||||
|
||||
class MemberItem : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MemberItem(const RoomMember &member, QWidget *parent);
|
||||
|
||||
private:
|
||||
QHBoxLayout *topLayout_;
|
||||
QVBoxLayout *textLayout_;
|
||||
|
||||
Avatar *avatar_;
|
||||
|
||||
QLabel *userName_;
|
||||
QLabel *userId_;
|
||||
};
|
||||
|
||||
class MemberList : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MemberList(const QString &room_id, QSharedPointer<Cache> cache, QWidget *parent = nullptr);
|
||||
|
||||
public slots:
|
||||
void addUsers(const std::vector<RoomMember> &users);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
void moveButtonToBottom();
|
||||
|
||||
private:
|
||||
QString room_id_;
|
||||
QLabel *topLabel_;
|
||||
QListWidget *list_;
|
||||
QSharedPointer<Cache> cache_;
|
||||
FlatButton *moreBtn_;
|
||||
};
|
||||
} // dialogs
|
||||
Loading…
Add table
Add a link
Reference in a new issue