Move various room auxiliary functions to TimelineManager

This commit is contained in:
Loren Burkholder 2021-07-21 18:56:20 -04:00
parent b17002929c
commit 44be4c1f4a
8 changed files with 44 additions and 42 deletions

View file

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

View file

@ -107,7 +107,7 @@ ApplicationWindow {
Layout.alignment: Qt.AlignHCenter
TapHandler {
onTapped: Rooms.currentRoom.openRoomMembers(roomSettings.roomId)
onTapped: TimelineManager.openRoomMembers(roomSettings.roomId)
}
CursorShape {

View file

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

View file

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

View file

@ -1066,31 +1066,6 @@ TimelineModel::openUserProfile(QString userid)
emit manager_->openProfile(userProfile);
}
void
TimelineModel::openRoomMembers(QString room_id)
{
MemberList *memberList = new MemberList(room_id == QString() ? roomId() : room_id, this);
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
TimelineModel::replyAction(QString id)
{

View file

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

View file

@ -351,6 +351,34 @@ TimelineViewManager::TimelineViewManager(CallManager *callManager, ChatPage *par
&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
TimelineViewManager::setVideoCallItem()
{

View file

@ -64,6 +64,10 @@ public:
Q_INVOKABLE QString userPresence(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 openLeaveRoomDialog(QString roomid) const;
Q_INVOKABLE void removeVerificationFlow(DeviceVerificationFlow *flow);
@ -85,6 +89,9 @@ signals:
void focusChanged();
void focusInput();
void openImageOverlayInternalCb(QString eventId, QImage img);
void openRoomMembersDialog(MemberList *members);
void openRoomSettingsDialog(RoomSettings *settings);
void openInviteUsersDialog(InviteesModel *invitees);
void openProfile(UserProfile *profile);
public slots: