Always open the invite dialog properly from the member list

This commit is contained in:
Loren Burkholder 2023-02-25 23:19:15 -05:00
parent f3ab0abadf
commit 24d401365e
5 changed files with 12 additions and 9 deletions

View file

@ -268,8 +268,6 @@ Pane {
var component = Qt.createComponent("qrc:/qml/dialogs/InviteDialog.qml")
if (component.status == Component.Ready) {
var dialog = component.createObject(timelineRoot, {
"roomId": Rooms.currentRoom.roomId,
"plainRoomName": Rooms.currentRoom.plainRoomName,
"invitees": invitees
});
dialog.show();

View file

@ -12,8 +12,6 @@ import im.nheko 1.0
ApplicationWindow {
id: inviteDialogRoot
property string roomId
property string plainRoomName
property InviteesModel invitees
property var friendsCompleter
property var profile
@ -39,7 +37,7 @@ ApplicationWindow {
close();
}
title: qsTr("Invite users to %1").arg(plainRoomName)
title: qsTr("Invite users to %1").arg(invitees.room.plainRoomName)
height: 380
width: 340
palette: Nheko.colors

View file

@ -9,8 +9,9 @@
#include "MatrixClient.h"
#include "mtx/responses/profile.hpp"
InviteesModel::InviteesModel(QObject *parent)
: QAbstractListModel{parent}
InviteesModel::InviteesModel(TimelineModel *room, QObject *parent)
: QAbstractListModel{parent},
room_{room}
{
}

View file

@ -8,6 +8,8 @@
#include <QAbstractListModel>
#include <QVector>
class TimelineModel;
class Invitee final : public QObject
{
Q_OBJECT
@ -34,6 +36,7 @@ class InviteesModel final : public QAbstractListModel
Q_OBJECT
Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
Q_PROPERTY(TimelineModel * room READ room CONSTANT)
public:
enum Roles
@ -43,7 +46,9 @@ public:
AvatarUrl,
};
InviteesModel(QObject *parent = nullptr);
InviteesModel(TimelineModel *room, QObject *parent = nullptr);
TimelineModel *room() const { return room_; }
Q_INVOKABLE void addUser(QString mxid, QString displayName = "", QString avatarUrl = "");
Q_INVOKABLE void removeUser(QString mxid);
@ -63,6 +68,7 @@ signals:
private:
QVector<Invitee *> invitees_;
TimelineModel *room_;
};
#endif // INVITEESMODEL_H

View file

@ -180,7 +180,7 @@ TimelineViewManager::openRoomSettings(QString room_id)
void
TimelineViewManager::openInviteUsers(QString roomId)
{
InviteesModel *model = new InviteesModel{};
InviteesModel *model = new InviteesModel{rooms_->getRoomById(roomId).data()};
connect(model, &InviteesModel::accept, this, [this, model, roomId]() {
emit inviteUsers(roomId, model->mxids());
});