Merge pull request #650 from LorenDB/qml-all-the-things

Open room members when member info label clicked
This commit is contained in:
DeepBlueV7.X 2021-07-21 23:18:21 +00:00 committed by GitHub
commit 1d3579196a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 56 additions and 44 deletions

View file

@ -41,7 +41,7 @@ ApplicationWindow {
displayName: members.roomName displayName: members.roomName
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
url: members.avatarUrl.replace("mxc://", "image://MxcImage/") url: members.avatarUrl.replace("mxc://", "image://MxcImage/")
onClicked: Rooms.currentRoom.openRoomSettings(members.roomId) onClicked: TimelineManager.openRoomSettings(members.roomId)
} }
ElidedLabel { ElidedLabel {
@ -57,7 +57,7 @@ ApplicationWindow {
hoverEnabled: true hoverEnabled: true
ToolTip.visible: hovered ToolTip.visible: hovered
ToolTip.text: qsTr("Invite more people") ToolTip.text: qsTr("Invite more people")
onClicked: Rooms.currentRoom.openInviteUsers() onClicked: TimelineManager.openInviteUsers(members.roomId)
} }
ScrollView { ScrollView {
@ -121,7 +121,6 @@ ApplicationWindow {
footer: Item { footer: Item {
width: parent.width width: parent.width
visible: (members.numUsersLoaded < members.memberCount) && members.loadingMoreMembers visible: (members.numUsersLoaded < members.memberCount) && members.loadingMoreMembers
// use the default height if it's visible, otherwise no height at all // use the default height if it's visible, otherwise no height at all
height: membersLoadingSpinner.height height: membersLoadingSpinner.height
anchors.margins: Nheko.paddingMedium anchors.margins: Nheko.paddingMedium

View file

@ -4,7 +4,7 @@
import "./ui" import "./ui"
import Qt.labs.platform 1.1 as Platform import Qt.labs.platform 1.1 as Platform
import QtQuick 2.9 import QtQuick 2.15
import QtQuick.Controls 2.3 import QtQuick.Controls 2.3
import QtQuick.Layouts 1.2 import QtQuick.Layouts 1.2
import QtQuick.Window 2.3 import QtQuick.Window 2.3
@ -105,6 +105,16 @@ ApplicationWindow {
MatrixText { MatrixText {
text: qsTr("%1 member(s)").arg(roomSettings.memberCount) text: qsTr("%1 member(s)").arg(roomSettings.memberCount)
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
TapHandler {
onTapped: TimelineManager.openRoomMembers(roomSettings.roomId)
}
CursorShape {
cursorShape: Qt.PointingHandCursor
anchors.fill: parent
}
} }
} }

View file

@ -133,7 +133,7 @@ Page {
} }
Connections { Connections {
target: Rooms.currentRoom target: TimelineManager
onOpenRoomMembersDialog: { onOpenRoomMembersDialog: {
var membersDialog = roomMembersComponent.createObject(timelineRoot, { var membersDialog = roomMembersComponent.createObject(timelineRoot, {
"members": members, "members": members,

View file

@ -24,7 +24,7 @@ Rectangle {
TapHandler { TapHandler {
onSingleTapped: { onSingleTapped: {
if (room) if (room)
room.openRoomSettings(); TimelineManager.openRoomSettings(room.roomId);
eventPoint.accepted = true; eventPoint.accepted = true;
} }
@ -66,7 +66,7 @@ Rectangle {
displayName: roomName displayName: roomName
onClicked: { onClicked: {
if (room) if (room)
room.openRoomSettings(); TimelineManager.openRoomSettings(room.roomId);
} }
} }
@ -111,12 +111,12 @@ Rectangle {
Platform.MenuItem { Platform.MenuItem {
visible: room ? room.permissions.canInvite() : false visible: room ? room.permissions.canInvite() : false
text: qsTr("Invite users") text: qsTr("Invite users")
onTriggered: Rooms.currentRoom.openInviteUsers() onTriggered: TimelineManager.openInviteUsers(room.roomId)
} }
Platform.MenuItem { Platform.MenuItem {
text: qsTr("Members") text: qsTr("Members")
onTriggered: Rooms.currentRoom.openRoomMembers() onTriggered: TimelineManager.openRoomMembers(room.roomId)
} }
Platform.MenuItem { Platform.MenuItem {
@ -126,7 +126,7 @@ Rectangle {
Platform.MenuItem { Platform.MenuItem {
text: qsTr("Settings") text: qsTr("Settings")
onTriggered: room.openRoomSettings() onTriggered: TimelineManager.openRoomSettings(room.roomId)
} }
} }

View file

@ -22,7 +22,7 @@
#include "timeline/TimelineViewManager.h" #include "timeline/TimelineViewManager.h"
#include "ui/Avatar.h" #include "ui/Avatar.h"
MemberList::MemberList(const QString &room_id, QWidget *parent) MemberList::MemberList(const QString &room_id, QObject *parent)
: QAbstractListModel{parent} : QAbstractListModel{parent}
, room_id_{room_id} , room_id_{room_id}
{ {

View file

@ -25,7 +25,7 @@ public:
DisplayName, DisplayName,
AvatarUrl, AvatarUrl,
}; };
MemberList(const QString &room_id, QWidget *parent = nullptr); MemberList(const QString &room_id, QObject *parent = nullptr);
QHash<int, QByteArray> roleNames() const override; QHash<int, QByteArray> roleNames() const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override int rowCount(const QModelIndex &parent = QModelIndex()) const override

View file

@ -1066,31 +1066,6 @@ TimelineModel::openUserProfile(QString userid)
emit manager_->openProfile(userProfile); emit manager_->openProfile(userProfile);
} }
void
TimelineModel::openRoomMembers()
{
MemberList *memberList = new MemberList(roomId());
emit openRoomMembersDialog(memberList);
}
void
TimelineModel::openRoomSettings(QString room_id)
{
RoomSettings *settings = new RoomSettings(room_id == QString() ? roomId() : room_id, this);
connect(this, &TimelineModel::roomAvatarUrlChanged, settings, &RoomSettings::avatarChanged);
emit openRoomSettingsDialog(settings);
}
void
TimelineModel::openInviteUsers(QString roomId)
{
InviteesModel *model = new InviteesModel{this};
connect(model, &InviteesModel::accept, this, [this, model, roomId]() {
emit manager_->inviteUsers(roomId == QString() ? room_id_ : roomId, model->mxids());
});
emit openInviteUsersDialog(model);
}
void void
TimelineModel::replyAction(QString id) TimelineModel::replyAction(QString id)
{ {

View file

@ -239,9 +239,6 @@ public:
Q_INVOKABLE void forwardMessage(QString eventId, QString roomId); Q_INVOKABLE void forwardMessage(QString eventId, QString roomId);
Q_INVOKABLE void viewDecryptedRawMessage(QString id) const; Q_INVOKABLE void viewDecryptedRawMessage(QString id) const;
Q_INVOKABLE void openUserProfile(QString userid); Q_INVOKABLE void openUserProfile(QString userid);
Q_INVOKABLE void openRoomMembers();
Q_INVOKABLE void openRoomSettings(QString room_id = QString());
Q_INVOKABLE void openInviteUsers(QString roomId = QString());
Q_INVOKABLE void editAction(QString id); Q_INVOKABLE void editAction(QString id);
Q_INVOKABLE void replyAction(QString id); Q_INVOKABLE void replyAction(QString id);
Q_INVOKABLE void readReceiptsAction(QString id) const; Q_INVOKABLE void readReceiptsAction(QString id) const;
@ -358,10 +355,6 @@ signals:
void lastMessageChanged(); void lastMessageChanged();
void notificationsChanged(); void notificationsChanged();
void openRoomMembersDialog(MemberList *members);
void openRoomSettingsDialog(RoomSettings *settings);
void openInviteUsersDialog(InviteesModel *invitees);
void newMessageToSend(mtx::events::collections::TimelineEvents event); void newMessageToSend(mtx::events::collections::TimelineEvents event);
void addPendingMessageToStore(mtx::events::collections::TimelineEvents event); void addPendingMessageToStore(mtx::events::collections::TimelineEvents event);
void updateFlowEventId(std::string event_id); void updateFlowEventId(std::string event_id);

View file

@ -351,6 +351,34 @@ TimelineViewManager::TimelineViewManager(CallManager *callManager, ChatPage *par
&TimelineViewManager::openImageOverlayInternal); &TimelineViewManager::openImageOverlayInternal);
} }
void
TimelineViewManager::openRoomMembers(QString room_id)
{
MemberList *memberList = new MemberList(room_id, this);
emit openRoomMembersDialog(memberList);
}
void
TimelineViewManager::openRoomSettings(QString room_id)
{
RoomSettings *settings = new RoomSettings(room_id, this);
connect(rooms_->getRoomById(room_id).data(),
&TimelineModel::roomAvatarUrlChanged,
settings,
&RoomSettings::avatarChanged);
emit openRoomSettingsDialog(settings);
}
void
TimelineViewManager::openInviteUsers(QString roomId)
{
InviteesModel *model = new InviteesModel{this};
connect(model, &InviteesModel::accept, this, [this, model, roomId]() {
emit inviteUsers(roomId, model->mxids());
});
emit openInviteUsersDialog(model);
}
void void
TimelineViewManager::setVideoCallItem() TimelineViewManager::setVideoCallItem()
{ {

View file

@ -64,6 +64,10 @@ public:
Q_INVOKABLE QString userPresence(QString id) const; Q_INVOKABLE QString userPresence(QString id) const;
Q_INVOKABLE QString userStatus(QString id) const; Q_INVOKABLE QString userStatus(QString id) const;
Q_INVOKABLE void openRoomMembers(QString room_id);
Q_INVOKABLE void openRoomSettings(QString room_id);
Q_INVOKABLE void openInviteUsers(QString roomId);
Q_INVOKABLE void focusMessageInput(); Q_INVOKABLE void focusMessageInput();
Q_INVOKABLE void openLeaveRoomDialog(QString roomid) const; Q_INVOKABLE void openLeaveRoomDialog(QString roomid) const;
Q_INVOKABLE void removeVerificationFlow(DeviceVerificationFlow *flow); Q_INVOKABLE void removeVerificationFlow(DeviceVerificationFlow *flow);
@ -85,6 +89,9 @@ signals:
void focusChanged(); void focusChanged();
void focusInput(); void focusInput();
void openImageOverlayInternalCb(QString eventId, QImage img); void openImageOverlayInternalCb(QString eventId, QImage img);
void openRoomMembersDialog(MemberList *members);
void openRoomSettingsDialog(RoomSettings *settings);
void openInviteUsersDialog(InviteesModel *invitees);
void openProfile(UserProfile *profile); void openProfile(UserProfile *profile);
public slots: public slots: